Remove use of Guava Charsets 74/41974/4
authorRobert Varga <rovarga@cisco.com>
Mon, 18 Jul 2016 14:19:35 +0000 (16:19 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 19 Jul 2016 10:20:45 +0000 (10:20 +0000)
We have StandardCharsets, use those.

Change-Id: I92677e8a72cf16fc03df25226c967221959f14c5
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/Bug2964Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlDocumentUtilsTest.java
yang/yang-data-operations/src/test/java/org/opendaylight/yangtools/yang/data/operations/retest/YangDataOperationsTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/repo/util/FilesystemSchemaSourceCacheTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/repo/util/InMemorySchemaSourceCacheTest.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/TextToASTTransformer.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryTest.java

index 3ab0ecc0387a76385f22c98f2793ed22be143b12..9976f4379c40a7551968c269cb713c9ca5ecf971 100644 (file)
@@ -11,12 +11,12 @@ package org.opendaylight.yangtools.yang.data.impl.codec.xml;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import com.google.common.base.Charsets;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+import java.nio.charset.StandardCharsets;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -64,7 +64,7 @@ public class Bug2964Test {
     }
 
     public static Document readXmlToDocument(final String xmlContent) throws SAXException, IOException {
-        return readXmlToDocument(new ByteArrayInputStream(xmlContent.getBytes(Charsets.UTF_8)));
+        return readXmlToDocument(new ByteArrayInputStream(xmlContent.getBytes(StandardCharsets.UTF_8)));
     }
 
     @Test
index dc86f82ea7b9f63cb54a78d5d4849f702edcfe8e..0324bb45ae6c7f0dadc0fa4a8bfb909da124a90d 100644 (file)
@@ -8,13 +8,13 @@
 
 package org.opendaylight.yangtools.yang.data.impl.codec.xml;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -84,7 +84,7 @@ public class XmlDocumentUtilsTest {
     }
 
     public static Document readXmlToDocument(final String xmlContent) throws SAXException, IOException {
-        return readXmlToDocument(new ByteArrayInputStream(xmlContent.getBytes(Charsets.UTF_8)));
+        return readXmlToDocument(new ByteArrayInputStream(xmlContent.getBytes(StandardCharsets.UTF_8)));
     }
 
     public static Document readXmlToDocument(final InputStream xmlContent) throws SAXException, IOException {
index 4367c77defdd05ae5f750064d49cbdf4847492b8..e1b779f78aab79c5d3f45d3c2e3c7680940e69be 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.data.operations.retest;
 
 import static org.junit.Assert.assertNull;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.io.Files;
@@ -21,10 +20,10 @@ import java.io.InputStream;
 import java.io.StringWriter;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-
 import javax.activation.UnsupportedDataTypeException;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -140,7 +139,7 @@ public class YangDataOperationsTest {
             return ModifyAction.MERGE;
         }
 
-        return ModifyAction.fromXmlValue(Files.toString(new File(resource.toURI()), Charsets.UTF_8).trim());
+        return ModifyAction.fromXmlValue(Files.toString(new File(resource.toURI()), StandardCharsets.UTF_8).trim());
     }
 
     private void verifyModificationResult(final Optional<ContainerNode> result, final Optional<ContainerNode> expectedResult)
index 0c4d48cb7ba71f18cd56c37b9d1029460475f115..ec956dbb98d59007ce3f75b28fe2e434622abfb7 100644 (file)
@@ -21,7 +21,6 @@ import static org.mockito.Mockito.verify;
 
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Function;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Optional;
@@ -32,6 +31,7 @@ import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -83,8 +83,8 @@ public class FilesystemSchemaSourceCacheTest {
 
         assertThat(fileNames, both(hasItem("test2@0000-00-00")).and(hasItem("test@2012-12-12")));
 
-        assertThat(Files.toString(storedFiles.get(0), Charsets.UTF_8), either(containsString(content)).or(containsString(content2)));
-        assertThat(Files.toString(storedFiles.get(1), Charsets.UTF_8), either(containsString(content)).or(containsString(content2)));
+        assertThat(Files.toString(storedFiles.get(0), StandardCharsets.UTF_8), either(containsString(content)).or(containsString(content2)));
+        assertThat(Files.toString(storedFiles.get(1), StandardCharsets.UTF_8), either(containsString(content)).or(containsString(content2)));
 
         verify(this.registry, times(2)).registerSchemaSource(any(SchemaSourceProvider.class), any(PotentialSchemaSource.class));
 
@@ -240,7 +240,7 @@ public class FilesystemSchemaSourceCacheTest {
 
         @Override
         public InputStream openStream() throws IOException {
-            return new ByteArrayInputStream(this.content.getBytes(Charsets.UTF_8));
+            return new ByteArrayInputStream(this.content.getBytes(StandardCharsets.UTF_8));
         }
     }
 }
index 14d5e2ffce831c74c28ffc9dce387516a9c36260..597d16017c43d1d978d1cf8c27f18fc287306c9c 100644 (file)
@@ -10,13 +10,13 @@ package org.opendaylight.yangtools.yang.model.repo.util;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doReturn;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import org.junit.Assert;
@@ -143,7 +143,7 @@ public class InMemorySchemaSourceCacheTest {
 
         @Override
         public InputStream openStream() throws IOException {
-            return new ByteArrayInputStream(this.content.getBytes(Charsets.UTF_8));
+            return new ByteArrayInputStream(this.content.getBytes(StandardCharsets.UTF_8));
         }
     }
 
index aed627fd54aa0cadaa89535e8f14da77d4c6a9f1..25b5b9d1e5e0e7367e17b80adc6834c74c882854 100644 (file)
@@ -9,11 +9,11 @@
 package org.opendaylight.yangtools.yang.parser.util;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Charsets;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import org.antlr.v4.runtime.ParserRuleContext;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
@@ -42,7 +42,7 @@ public final class TextToASTTransformer extends SchemaSourceTransformer<YangText
                 //:TODO missing validation (YangModelBasicValidationListener should be re-implemented to new parser)
 
                 // Backwards compatibility
-                final String text = input.asCharSource(Charsets.UTF_8).read();
+                final String text = input.asCharSource(StandardCharsets.UTF_8).read();
 
                 return Futures.immediateCheckedFuture(ASTSchemaSource.create(input.getIdentifier(), ctx, text));
             }
index b8fca69ffb9d05f56c1606aca8e6622099586372..2a2fd60f11e88cbfd3eeb18914c5bc0990f3568d 100644 (file)
@@ -21,9 +21,6 @@ import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-
-import com.google.common.base.Charsets;
 import com.google.common.base.Function;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Optional;
@@ -37,12 +34,14 @@ import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
@@ -226,16 +225,16 @@ public class SharedSchemaRepositoryTest {
         sharedSchemaRepository.registerSchemaSourceListener(listener);
 
         final File test = new File(storageDir, "test.yang");
-        Files.write("content-test", test, Charsets.UTF_8);
+        Files.write("content-test", test, StandardCharsets.UTF_8);
 
         final File test2 = new File(storageDir, "test@2012-12-12.yang");
-        Files.write("content-test-2012", test2, Charsets.UTF_8);
+        Files.write("content-test-2012", test2, StandardCharsets.UTF_8);
 
         final File test3 = new File(storageDir, "test@2013-12-12.yang");
-        Files.write("content-test-2013", test3, Charsets.UTF_8);
+        Files.write("content-test-2013", test3, StandardCharsets.UTF_8);
 
         final File test4 = new File(storageDir, "module@2010-12-12.yang");
-        Files.write("content-module-2010", test4, Charsets.UTF_8);
+        Files.write("content-module-2010", test4, StandardCharsets.UTF_8);
 
 
         final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(sharedSchemaRepository, YangTextSchemaSource.class, storageDir);
@@ -279,7 +278,7 @@ public class SharedSchemaRepositoryTest {
 
                     @Override
                     public InputStream openStream() throws IOException {
-                        return new ByteArrayInputStream("running".getBytes(Charsets.UTF_8));
+                        return new ByteArrayInputStream("running".getBytes(StandardCharsets.UTF_8));
                     }
                 });
             }