Merge "Switch to using StandardCharsets"
authorTomas Cere <tcere@cisco.com>
Tue, 19 Jul 2016 07:57:28 +0000 (07:57 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 19 Jul 2016 07:57:28 +0000 (07:57 +0000)
24 files changed:
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/MdsalNetconfOperationServiceFactory.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/MessageParserTest.java
netconf/netconf-it/src/test/java/org/opendaylight/netconf/it/NetconfITMonitoringTest.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ChunkedFramingMechanismEncoder.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfHelloMessageToXMLEncoder.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfXMLToHelloMessageDecoder.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/ChunkedFramingMechanismEncoderTest.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/NetconfChunkAggregatorTest.java
netconf/netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoClientHandler.java
netconf/netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoServerHandler.java
netconf/netconf-ssh/src/test/java/org/opendaylight/netconf/netty/ProxyServerHandler.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/messages/NetconfMessageConstants.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/test/XmlFileLoader.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/Main.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/TesttoolParameters.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/http/perf/RestPerfClient.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/stress/StressClient.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/NormalizedNodeJsonBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/PATCHJsonBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/JSONRestconfServiceImpl.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java

index 4e98d2938e1456d03756ced4a102315d31b94a14..56eb032a99bb937a9379d51f85d4e3c7235e92db 100644 (file)
@@ -8,13 +8,13 @@
 
 package org.opendaylight.netconf.mdsal.connector;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.io.CharStreams;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
@@ -103,7 +103,7 @@ public class MdsalNetconfOperationServiceFactory implements NetconfOperationServ
         String source;
         try {
             sourceStream = rootSchemaSourceProviderDependency.getSource(moduleSourceIdentifier).checkedGet().openStream();
-            source = CharStreams.toString(new InputStreamReader(sourceStream, Charsets.UTF_8));
+            source = CharStreams.toString(new InputStreamReader(sourceStream, StandardCharsets.UTF_8));
         } catch (IOException | SchemaSourceException e) {
             LOG.warn("Ignoring source for module {}. Unable to read content", moduleSourceIdentifier, e);
             source = null;
index 562d4a4ba993b4d307ca366e9e261a8f86f256a7..46a5695670da3676ac8434ea53bb428f6361f71d 100644 (file)
@@ -15,11 +15,11 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.base.Charsets;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.embedded.EmbeddedChannel;
 import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
 import java.util.Queue;
 import org.junit.Before;
 import org.junit.Test;
@@ -111,7 +111,7 @@ public class MessageParserTest {
 
     private static long getHeaderLength(byte[] bytes) {
         byte[] HEADER_START = new byte[] { (byte) 0x0a, (byte) 0x23 };
-        return Long.parseLong(Charsets.US_ASCII.decode(
+        return Long.parseLong(StandardCharsets.US_ASCII.decode(
                 ByteBuffer.wrap(bytes, HEADER_START.length, bytes.length - HEADER_START.length - 1)).toString());
     }
 }
index 87b145717bad04d83b9a3f95ce13a3055434e3f6..8e1b1a0f5f4870a3ec24adf19c310647bf17b3cd 100644 (file)
@@ -15,7 +15,6 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.opendaylight.netconf.util.test.XmlUnitUtil.assertContainsElementWithText;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Optional;
 import com.google.common.collect.Sets;
 import java.io.BufferedReader;
@@ -23,6 +22,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.InetSocketAddress;
 import java.net.Socket;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
@@ -71,12 +71,12 @@ public class NetconfITMonitoringTest extends AbstractNetconfConfigTest {
         final String get = XmlFileLoader.fileToString(fileName);
 
         final Socket sock = new Socket(TCP_ADDRESS.getHostName(), TCP_ADDRESS.getPort());
-        sock.getOutputStream().write(hello.getBytes(Charsets.UTF_8));
+        sock.getOutputStream().write(hello.getBytes(StandardCharsets.UTF_8));
         final String separator = "]]>]]>";
 
-        sock.getOutputStream().write(separator.getBytes(Charsets.UTF_8));
-        sock.getOutputStream().write(get.getBytes(Charsets.UTF_8));
-        sock.getOutputStream().write(separator.getBytes(Charsets.UTF_8));
+        sock.getOutputStream().write(separator.getBytes(StandardCharsets.UTF_8));
+        sock.getOutputStream().write(get.getBytes(StandardCharsets.UTF_8));
+        sock.getOutputStream().write(separator.getBytes(StandardCharsets.UTF_8));
 
         final StringBuilder responseBuilder = new StringBuilder();
 
index af8b6fdcdd3b47aee7aeaee8753a844a843ce561..8c9a2b35c973267b7336b1713ed9aa29c71e2c29 100644 (file)
@@ -8,11 +8,11 @@
 
 package org.opendaylight.netconf.nettyutil.handler;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.MessageToByteEncoder;
+import java.nio.charset.StandardCharsets;
 import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
 
 public class ChunkedFramingMechanismEncoder extends MessageToByteEncoder<ByteBuf> {
@@ -41,7 +41,7 @@ public class ChunkedFramingMechanismEncoder extends MessageToByteEncoder<ByteBuf
             final int xfer = Math.min(chunkSize, msg.readableBytes());
 
             out.writeBytes(NetconfMessageConstants.START_OF_CHUNK);
-            out.writeBytes(String.valueOf(xfer).getBytes(Charsets.US_ASCII));
+            out.writeBytes(String.valueOf(xfer).getBytes(StandardCharsets.US_ASCII));
             out.writeByte('\n');
 
             out.writeBytes(msg, xfer);
index f1f110751d5a59f3a518ac4ace6f7521f49e746e..82f963afb07f5e74f3bca323d689d5119e658766 100644 (file)
@@ -8,12 +8,12 @@
 package org.opendaylight.netconf.nettyutil.handler;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import javax.xml.transform.TransformerException;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
@@ -51,7 +51,7 @@ public final class NetconfHelloMessageToXMLEncoder extends NetconfMessageToXMLEn
 
         // If additional header present, serialize it along with netconf hello message
         if (headerOptional.isPresent()) {
-            out.writeBytes(headerOptional.get().toFormattedString().getBytes(Charsets.UTF_8));
+            out.writeBytes(headerOptional.get().toFormattedString().getBytes(StandardCharsets.UTF_8));
         }
 
         super.encode(ctx, msg, out);
index cc14fdf32d8acf968aa9e5c5b6acab314f3f6cb7..1ff2464501378d246c0b5153749830ada60ed163 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.netconf.nettyutil.handler;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
@@ -19,6 +18,7 @@ import io.netty.handler.codec.ByteToMessageDecoder;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.List;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
@@ -161,7 +161,7 @@ public final class NetconfXMLToHelloMessageDecoder extends ByteToMessageDecoder
 
     private static void logMessage(final byte[] bytes) {
         if (LOG.isDebugEnabled()) {
-            String s = Charsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString();
+            String s = StandardCharsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString();
             LOG.debug("Parsing message \n{}", s);
         }
     }
@@ -184,7 +184,7 @@ public final class NetconfXMLToHelloMessageDecoder extends ByteToMessageDecoder
     }
 
     private static String additionalHeaderToString(final byte[] bytes) {
-        return Charsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString();
+        return StandardCharsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString();
     }
 
     /**
index b5bf756de6151edd74c56a019b7812dd57b5d392..e9a1d75c55e33c897ad29241dc9ce0792655972d 100644 (file)
@@ -8,11 +8,11 @@
 
 package org.opendaylight.netconf.nettyutil.handler.ssh.client;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelPromise;
+import java.nio.charset.StandardCharsets;
 import java.util.Deque;
 import java.util.LinkedList;
 import java.util.Queue;
@@ -147,7 +147,7 @@ public final class AsyncSshHandlerWriter implements AutoCloseable {
     }
 
     public static String byteBufToString(final ByteBuf msg) {
-        final String s = msg.toString(Charsets.UTF_8);
+        final String s = msg.toString(StandardCharsets.UTF_8);
         msg.resetReaderIndex();
         return s;
     }
index 6d0bbd2707a031130e292c43d502caee94390868..c8837dfd95c5d54e20d951bfc5f300c6b5c59a8b 100644 (file)
@@ -11,11 +11,11 @@ package org.opendaylight.netconf.nettyutil.handler;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.base.Charsets;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
 import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -55,7 +55,7 @@ public class ChunkedFramingMechanismEncoderTest {
 
         byte[] buf = new byte[destination.readableBytes()];
         destination.readBytes(buf);
-        String s = Charsets.US_ASCII.decode(ByteBuffer.wrap(buf)).toString();
+        String s = StandardCharsets.US_ASCII.decode(ByteBuffer.wrap(buf)).toString();
 
         assertTrue(s.startsWith("\n#256\na"));
         assertTrue(s.endsWith("\n#20\naaaaaaaaaaaaaaaaaaaa\n##\n"));
index fe3c96d2b789fc8352b03f89b494879795c2516e..321b34ccf77bfc0602e40141f6c13df860cdd6af 100644 (file)
@@ -9,10 +9,10 @@ package org.opendaylight.netconf.nettyutil.handler;
 
 import static org.junit.Assert.assertEquals;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -46,25 +46,25 @@ public class NetconfChunkAggregatorTest {
     @Test
     public void testMultipleChunks() throws Exception {
         final List<Object> output = Lists.newArrayList();
-        final ByteBuf input = Unpooled.copiedBuffer(CHUNKED_MESSAGE.getBytes(Charsets.UTF_8));
+        final ByteBuf input = Unpooled.copiedBuffer(CHUNKED_MESSAGE.getBytes(StandardCharsets.UTF_8));
         agr.decode(null, input, output);
 
         assertEquals(1, output.size());
         final ByteBuf chunk = (ByteBuf) output.get(0);
 
-        assertEquals(EXPECTED_MESSAGE, chunk.toString(Charsets.UTF_8));
+        assertEquals(EXPECTED_MESSAGE, chunk.toString(StandardCharsets.UTF_8));
     }
 
     @Test
     public void testOneChunks() throws Exception {
         final List<Object> output = Lists.newArrayList();
-        final ByteBuf input = Unpooled.copiedBuffer(CHUNKED_MESSAGE_ONE.getBytes(Charsets.UTF_8));
+        final ByteBuf input = Unpooled.copiedBuffer(CHUNKED_MESSAGE_ONE.getBytes(StandardCharsets.UTF_8));
         agr.decode(null, input, output);
 
         assertEquals(1, output.size());
         final ByteBuf chunk = (ByteBuf) output.get(0);
 
-        assertEquals(EXPECTED_MESSAGE, chunk.toString(Charsets.UTF_8));
+        assertEquals(EXPECTED_MESSAGE, chunk.toString(StandardCharsets.UTF_8));
     }
 
 
index ccc63f6513923e6c7a563e3330ed4ec3324cc73b..5d571a5caad660d9c21db1db0f407c2f76e99ce7 100644 (file)
@@ -9,8 +9,8 @@
 package org.opendaylight.netconf.netty;
 
 import static com.google.common.base.Preconditions.checkState;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
-import com.google.common.base.Charsets;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelFuture;
@@ -52,7 +52,7 @@ public class EchoClientHandler extends ChannelInboundHandlerAdapter implements C
     @Override
     public synchronized void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
         ByteBuf bb = (ByteBuf) msg;
-        String string = bb.toString(Charsets.UTF_8);
+        String string = bb.toString(UTF_8);
         fromServer.append(string);
         LOG.info(">{}", string);
         bb.release();
index ea157e04ac08a752de2fca56f32f7ab119889ae3..38634280ffd8ca5f506c01c0abffab5c5e84e464 100644 (file)
@@ -8,12 +8,12 @@
 
 package org.opendaylight.netconf.netty;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Splitter;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandler.Sharable;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
+import java.nio.charset.StandardCharsets;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -36,7 +36,7 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
     @Override
     public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
         ByteBuf byteBuf = (ByteBuf) msg;
-        String message = byteBuf.toString(Charsets.UTF_8);
+        String message = byteBuf.toString(StandardCharsets.UTF_8);
         LOG.info("writing back '{}'", message);
         ctx.write(msg);
         fromLastNewLine += message;
index 43296d0b1c20256e82191714a62422ab24be8264..dc879c233229f0755dd138f12a1eba034f26767b 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.netconf.netty;
 
-import com.google.common.base.Charsets;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -20,6 +19,7 @@ import io.netty.channel.ChannelInitializer;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.local.LocalAddress;
 import io.netty.channel.local.LocalChannel;
+import java.nio.charset.StandardCharsets;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -95,7 +95,7 @@ class ProxyClientHandler extends ChannelInboundHandlerAdapter {
     @Override
     public void channelRead(ChannelHandlerContext ctx, Object msg) {
         ByteBuf bb = (ByteBuf) msg;
-        LOG.info(">{}", bb.toString(Charsets.UTF_8));
+        LOG.info(">{}", bb.toString(StandardCharsets.UTF_8));
         remoteCtx.write(msg);
     }
 
index 5a8d588dfe17351ef495c93f8c6250db99689129..4117918d5322ae79e8cfa9b0e8138c08ddb3ce7e 100644 (file)
@@ -8,16 +8,17 @@
 
 package org.opendaylight.netconf.util.messages;
 
-import com.google.common.base.Charsets;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 public final class NetconfMessageConstants {
 
     private NetconfMessageConstants(){}
+
     /**
      * The NETCONF 1.0 old-style message separator. This is framing mechanism
      * is used by default.
      */
-    public static final byte[] END_OF_MESSAGE = "]]>]]>".getBytes(Charsets.UTF_8);
+    public static final byte[] END_OF_MESSAGE = "]]>]]>".getBytes(UTF_8);
 
     // bytes
 
@@ -27,7 +28,7 @@ public final class NetconfMessageConstants {
 
     public static final int MAX_HEADER_LENGTH = 13;
 
-    public static final byte[] START_OF_CHUNK = "\n#".getBytes(Charsets.UTF_8);
-    public static final byte[] END_OF_CHUNK = "\n##\n".getBytes(Charsets.UTF_8);
+    public static final byte[] START_OF_CHUNK = "\n#".getBytes(UTF_8);
+    public static final byte[] END_OF_CHUNK = "\n##\n".getBytes(UTF_8);
 
 }
index 43f42fd63d3319645ffe592a6a42367bdd6c7d6b..ed51ae000e592701a5abd8e996d34ada6beb7a55 100644 (file)
@@ -8,11 +8,11 @@
 
 package org.opendaylight.netconf.util.test;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
 import com.google.common.io.ByteSource;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import javax.xml.parsers.ParserConfigurationException;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
@@ -54,7 +54,7 @@ public class XmlFileLoader {
                 public InputStream openStream() {
                     return resourceAsStream;
                 }
-            }.asCharSource(Charsets.UTF_8).read();
+            }.asCharSource(StandardCharsets.UTF_8).read();
 
         }
     }
index bd29ef4395439992c9e77a498a36fd2c465d39d7..8f2728b9e1c55c26b19c7e2550351d91999bc15e 100644 (file)
@@ -11,7 +11,6 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_DATA_QNAME;
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Function;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Optional;
@@ -22,6 +21,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import javax.xml.transform.dom.DOMSource;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
@@ -191,7 +191,7 @@ public final class NetconfRemoteSchemaYangSourceProvider implements SchemaSource
 
         @Override
         public InputStream openStream() throws IOException {
-            return new ByteArrayInputStream(schemaString.get().getBytes(Charsets.UTF_8));
+            return new ByteArrayInputStream(schemaString.get().getBytes(StandardCharsets.UTF_8));
         }
     }
 }
index 324ea36880f5b3aa39ba206a6b2d1af7e1758f66..3ac9c46717a87d21fa08f902eb5d19886d0c8631 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.netconf.test.tool;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import ch.qos.logback.classic.Level;
-import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Stopwatch;
 import com.google.common.collect.Lists;
@@ -26,6 +25,7 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -156,7 +156,7 @@ public final class Main {
 
             try (InputStream stream = Main.class.getResourceAsStream(NETCONF_CONNECTOR_XML)) {
                 checkNotNull(stream, "Cannot load %s", NETCONF_CONNECTOR_XML);
-                String configBlueprint = CharStreams.toString(new InputStreamReader(stream, Charsets.UTF_8));
+                String configBlueprint = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
 
                 final String before = configBlueprint.substring(0, configBlueprint.indexOf("<module>"));
                 final String middleBlueprint = configBlueprint.substring(configBlueprint.indexOf("<module>"), configBlueprint.indexOf("</module>"));
@@ -185,7 +185,7 @@ public final class Main {
                             b.append(after);
                             final File to = new File(configDir, String.format(SIM_DEVICE_CFG_PREFIX + "%d-%d.xml", batchStart, openDevice));
                             generatedConfigs.add(to);
-                            Files.write(b.toString(), to, Charsets.UTF_8);
+                            Files.write(b.toString(), to, StandardCharsets.UTF_8);
                             connectorCount = 0;
                             b = new StringBuilder();
                             b.append(before);
@@ -199,7 +199,7 @@ public final class Main {
                     b.append(after);
                     final File to = new File(configDir, String.format(SIM_DEVICE_CFG_PREFIX + "%d-%d.xml", batchStart, openDevices.get(openDevices.size() - 1)));
                     generatedConfigs.add(to);
-                    Files.write(b.toString(), to, Charsets.UTF_8);
+                    Files.write(b.toString(), to, StandardCharsets.UTF_8);
                 }
 
                 LOG.info("Config files generated in {}", configDir);
index a5a075b30551e435a119d593d169e7bf3f523b16..cc53aa5e218099da101d7a711aedf484f8c5f576 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.netconf.test.tool;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
 import com.google.common.io.CharStreams;
 import com.google.common.io.Files;
@@ -18,6 +17,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -291,9 +291,9 @@ public class TesttoolParameters {
         final String editContentString;
         try {
             if (stream == null) {
-                editContentString = Files.toString(editContent, Charsets.UTF_8);
+                editContentString = Files.toString(editContent, StandardCharsets.UTF_8);
             } else {
-                editContentString = CharStreams.toString(new InputStreamReader(stream, Charsets.UTF_8));
+                editContentString = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
             }
         } catch (final IOException e) {
             throw new IllegalArgumentException("Cannot read content of " + editContent);
index 64fbaacdc637b4fbf8420148432d1ebe8ad25dde..518b48eb4866cb174be198fe0cfe5ebfa8347729 100644 (file)
@@ -8,10 +8,10 @@
 
 package org.opendaylight.netconf.test.tool.client.http.perf;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Stopwatch;
 import com.google.common.io.Files;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
@@ -75,7 +75,7 @@ public class RestPerfClient {
 
         final String editContentString;
         try {
-            editContentString = Files.toString(parameters.editContent, Charsets.UTF_8);
+            editContentString = Files.toString(parameters.editContent, StandardCharsets.UTF_8);
         } catch (final IOException e) {
             throw new IllegalArgumentException("Cannot read content of " + parameters.editContent);
         }
index 11e8641fd9ae5531644a4aae238c0a61794507dd..e32c99c10e84a17f32a9c31acf615be9cd054741 100644 (file)
@@ -9,13 +9,13 @@
 package org.opendaylight.netconf.test.tool.client.stress;
 
 import ch.qos.logback.classic.Level;
-import com.google.common.base.Charsets;
 import com.google.common.base.Stopwatch;
 import com.google.common.io.Files;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.util.HashedWheelTimer;
 import io.netty.util.Timer;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
@@ -130,7 +130,7 @@ public final class StressClient {
 
         final String editContentString;
         try {
-            editContentString = Files.toString(params.editContent, Charsets.UTF_8);
+            editContentString = Files.toString(params.editContent, StandardCharsets.UTF_8);
         } catch (final IOException e) {
             throw new IllegalArgumentException("Cannot read content of " + params.editContent);
         }
index 3b65083c0512a71663904584d944556c36d48826..09c4b724c2a8f235563cda66d0fd8461a92ff751 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.netconf.sal.rest.impl;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Optional;
 import com.google.gson.stream.JsonWriter;
 import java.io.IOException;
@@ -16,6 +15,7 @@ import java.io.OutputStreamWriter;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.net.URI;
+import java.nio.charset.StandardCharsets;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
@@ -150,10 +150,10 @@ public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter<Normalize
 
     private JsonWriter createJsonWriter(final OutputStream entityStream, final boolean prettyPrint) {
         if (prettyPrint) {
-            return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, Charsets.UTF_8),
+            return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, StandardCharsets.UTF_8),
                     DEFAULT_INDENT_SPACES_NUM);
         } else {
-            return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, Charsets.UTF_8));
+            return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, StandardCharsets.UTF_8));
         }
     }
 
index 9f9ab949339890eaeb4de347ab2214cea15fe97e..66b26d66c07d952a25c5a101047e573df797793a 100644 (file)
@@ -8,13 +8,13 @@
 
 package org.opendaylight.netconf.sal.rest.impl;
 
-import com.google.common.base.Charsets;
 import com.google.gson.stream.JsonWriter;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
@@ -106,6 +106,6 @@ public class PATCHJsonBodyWriter implements MessageBodyWriter<PATCHStatusContext
     }
 
     private static JsonWriter createJsonWriter(final OutputStream entityStream) {
-        return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, Charsets.UTF_8));
+        return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, StandardCharsets.UTF_8));
     }
 }
index 6cdb33bf8cfc7a4edfb36c1aef39dabbf08b12dc..dea493ea27eb5f6695f1d64ffaf01634d4478111 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.netconf.sal.rest.impl;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
 import com.google.common.collect.Iterables;
@@ -17,6 +16,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.net.URI;
+import java.nio.charset.StandardCharsets;
 import java.util.Iterator;
 import java.util.List;
 import javax.ws.rs.core.Context;
@@ -213,7 +213,7 @@ public class RestconfDocumentedExceptionMapper implements ExceptionMapper<Restco
         final DataSchemaNode schema = (DataSchemaNode) context.getSchemaNode();
 
         SchemaPath path = context.getSchemaNode().getPath();
-        final OutputStreamWriter outputWriter = new OutputStreamWriter(outStream, Charsets.UTF_8);
+        final OutputStreamWriter outputWriter = new OutputStreamWriter(outStream, StandardCharsets.UTF_8);
         if (data == null) {
             throw new RestconfDocumentedException(Response.Status.NOT_FOUND);
         }
index cfe12c7bed67041b66b62128c1513d6ffa613733..14f8c22d5325021effe16852a5c057d3b781195d 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.netconf.sal.restconf.impl;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.io.ByteArrayInputStream;
@@ -15,6 +14,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import javax.ws.rs.core.MediaType;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -45,7 +45,7 @@ public class JSONRestconfServiceImpl implements JSONRestconfService, AutoCloseab
 
         LOG.debug("put: uriPath: {}, payload: {}", uriPath, payload);
 
-        InputStream entityStream = new ByteArrayInputStream(payload.getBytes(Charsets.UTF_8));
+        InputStream entityStream = new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8));
         NormalizedNodeContext context = JsonNormalizedNodeBodyReader.readFrom(uriPath, entityStream, false);
 
         LOG.debug("Parsed YangInstanceIdentifier: {}", context.getInstanceIdentifierContext().getInstanceIdentifier());
@@ -64,7 +64,7 @@ public class JSONRestconfServiceImpl implements JSONRestconfService, AutoCloseab
 
         LOG.debug("post: uriPath: {}, payload: {}", uriPath, payload);
 
-        InputStream entityStream = new ByteArrayInputStream(payload.getBytes(Charsets.UTF_8));
+        InputStream entityStream = new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8));
         NormalizedNodeContext context = JsonNormalizedNodeBodyReader.readFrom(uriPath, entityStream, true);
 
         LOG.debug("Parsed YangInstanceIdentifier: {}", context.getInstanceIdentifierContext().getInstanceIdentifier());
@@ -127,7 +127,7 @@ public class JSONRestconfServiceImpl implements JSONRestconfService, AutoCloseab
         try {
             NormalizedNodeContext outputContext;
             if(actualInput != null) {
-                InputStream entityStream = new ByteArrayInputStream(actualInput.getBytes(Charsets.UTF_8));
+                InputStream entityStream = new ByteArrayInputStream(actualInput.getBytes(StandardCharsets.UTF_8));
                 NormalizedNodeContext inputContext = JsonNormalizedNodeBodyReader.readFrom(uriPath, entityStream, true);
 
                 LOG.debug("Parsed YangInstanceIdentifier: {}", inputContext.getInstanceIdentifierContext()
@@ -158,7 +158,7 @@ public class JSONRestconfServiceImpl implements JSONRestconfService, AutoCloseab
         ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         writer.writeTo(readData, NormalizedNodeContext.class, null, EMPTY_ANNOTATIONS,
                 MediaType.APPLICATION_JSON_TYPE, null, outputStream );
-        return outputStream.toString(Charsets.UTF_8.name());
+        return outputStream.toString(StandardCharsets.UTF_8.name());
     }
 
     private boolean isDataMissing(Exception e) {
index 2289d2e4dd63945b83bea38672be8764abdca3f0..51286725770a045244088329fa893b61c55b7f60 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.netconf.sal.streams.listeners;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
 import com.google.common.eventbus.AsyncEventBus;
 import com.google.common.eventbus.EventBus;
@@ -19,6 +18,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Date;
@@ -250,7 +250,7 @@ public class ListenerAdapter implements DOMDataChangeListener {
             transformer.setOutputProperty(OutputKeys.INDENT, "yes");
             transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
             transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
-            transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out, Charsets.UTF_8)));
+            transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out, StandardCharsets.UTF_8)));
             final byte[] charData = out.toByteArray();
             return new String(charData, "UTF-8");
         } catch (TransformerException | UnsupportedEncodingException e) {