knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [3/4] knox git commit: KNOX-1442 - Enable forbiddenapis for static build checking
Date Tue, 25 Sep 2018 01:37:48 GMT
http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServer.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServer.java b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServer.java
index bf4929d..b3b9dcf 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServer.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServer.java
@@ -105,6 +105,7 @@ import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 import java.util.ServiceLoader;
@@ -455,7 +456,7 @@ public class GatewayServer {
 
         topologyContextHandler.setHandler(updateHandler);
         topologyContextHandler.setVirtualHosts(
-            new String[] { "@" + entry.getKey().toLowerCase() });
+            new String[] { "@" + entry.getKey().toLowerCase(Locale.ROOT) });
 
         handlers.addHandler(topologyContextHandler);
       }
@@ -498,16 +499,16 @@ public class GatewayServer {
       } else {
         log.portAlreadyInUse(port, topologyName);
       }
-      throw new IOException(String.format(" Port %d already in use. ", port));
+      throw new IOException(String.format(Locale.ROOT, "Port %d already in use.", port));
     }
 
     // if topology name is blank which means we have all topologies listening on this port
     if (StringUtils.isBlank(topologyName)) {
       // If we have Default Topology old and new configuration (Port Mapping) throw error.
-      if (config.getGatewayPortMappings().containsValue(Integer.valueOf(port))
+      if (config.getGatewayPortMappings().containsValue(port)
           && !StringUtils.isBlank(config.getDefaultTopologyName())) {
         log.portAlreadyInUse(port);
-        throw new IOException(String.format(
+        throw new IOException(String.format(Locale.ROOT,
             " Please map port %d using either \"gateway.port.mapping.sandbox\" or "
                 + "\"default.app.topology.name\" property, "
                 + "specifying both is not a valid configuration. ",
@@ -520,7 +521,7 @@ public class GatewayServer {
         if (connectors[i] instanceof ServerConnector
             && ((ServerConnector) connectors[i]).getPort() == port) {
           log.portAlreadyInUse(port, topologyName);
-          throw new IOException(String.format(
+          throw new IOException(String.format(Locale.ROOT,
               " Port %d used by topology %s is used by other topology, ports for topologies (if defined) have to be unique. ",
               port, topologyName));
         }
@@ -589,15 +590,15 @@ public class GatewayServer {
       for (Map.Entry<String, Integer> entry : topologyPortMap.entrySet()) {
         // Add connector for only valid topologies, i.e. deployed topologies.
         // and NOT for Default Topology listening on standard gateway port.
-        if(deployedTopologyList.contains(entry.getKey()) && (entry.getValue().intValue() != config.getGatewayPort()) ) {
-          log.createJettyConnector(entry.getKey().toLowerCase(), entry.getValue());
+        if(deployedTopologyList.contains(entry.getKey()) && (entry.getValue() != config.getGatewayPort()) ) {
+          log.createJettyConnector(entry.getKey().toLowerCase(Locale.ROOT), entry.getValue());
           try {
             jetty.addConnector(createConnector(jetty, config, entry.getValue(),
-                entry.getKey().toLowerCase()));
+                entry.getKey().toLowerCase(Locale.ROOT)));
           } catch(final IOException e) {
             /* in case of port conflict we log error and move on */
             if( e.toString().contains("ports for topologies (if defined) have to be unique.") ) {
-              log.startedGatewayPortConflict(entry.getKey().toLowerCase(), entry.getValue());
+              log.startedGatewayPortConflict(entry.getKey().toLowerCase(Locale.ROOT), entry.getValue());
             } else {
               throw e;
             }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
index 51abba2..11ca218 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
@@ -37,6 +37,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
@@ -987,12 +988,12 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig {
 
   @Override
   public int getClusterMonitorPollingInterval(String type) {
-    return getInt(CLUSTER_CONFIG_MONITOR_PREFIX + type.toLowerCase() + CLUSTER_CONFIG_MONITOR_INTERVAL_SUFFIX, -1);
+    return getInt(CLUSTER_CONFIG_MONITOR_PREFIX + type.toLowerCase(Locale.ROOT) + CLUSTER_CONFIG_MONITOR_INTERVAL_SUFFIX, -1);
   }
   
   @Override
   public boolean isClusterMonitorEnabled(String type) {
-    return getBoolean(CLUSTER_CONFIG_MONITOR_PREFIX + type.toLowerCase() + CLUSTER_CONFIG_MONITOR_ENABLED_SUFFIX, true);
+    return getBoolean(CLUSTER_CONFIG_MONITOR_PREFIX + type.toLowerCase(Locale.ROOT) + CLUSTER_CONFIG_MONITOR_ENABLED_SUFFIX, true);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/deploy/DeploymentFactory.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/DeploymentFactory.java b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/DeploymentFactory.java
index 285bb43..f12bb77 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/DeploymentFactory.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/DeploymentFactory.java
@@ -17,26 +17,6 @@
  */
 package org.apache.knox.gateway.deploy;
 
-import java.beans.Statement;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.ServiceLoader;
-import java.util.Set;
-import java.util.TreeMap;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-
 import org.apache.knox.gateway.GatewayMessages;
 import org.apache.knox.gateway.GatewayServlet;
 import org.apache.knox.gateway.config.GatewayConfig;
@@ -63,6 +43,27 @@ import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor;
 import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterType;
 import org.jboss.shrinkwrap.descriptor.api.webcommon30.ServletType;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import java.beans.Statement;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.ServiceLoader;
+import java.util.Set;
+import java.util.TreeMap;
+
 public abstract class DeploymentFactory {
 
   private static final String SERVLET_NAME_SUFFIX = "-knox-gateway-servlet";
@@ -353,7 +354,7 @@ public abstract class DeploymentFactory {
         for( String url : urls ) {
           if( url == null || url.isEmpty() || url.equals( "/" ) ) {
             if( !topology.getServices().isEmpty() ) {
-              throw new DeploymentException( String.format(
+              throw new DeploymentException( String.format(Locale.ROOT,
                   "Topologies with services cannot contain an application (%s) with a root url.", name ) );
             }
           }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ApplicationDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ApplicationDeploymentContributor.java b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ApplicationDeploymentContributor.java
index 2a8f872..61ee5ff 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ApplicationDeploymentContributor.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ApplicationDeploymentContributor.java
@@ -51,6 +51,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 public class ApplicationDeploymentContributor extends ServiceDeploymentContributorBase {
@@ -200,7 +201,7 @@ public class ApplicationDeploymentContributor extends ServiceDeploymentContribut
       if ( role == null ) {
         throw new IllegalArgumentException("Policy defined has no role for service " + service.getName());
       }
-      role = role.trim().toLowerCase();
+      role = role.trim().toLowerCase(Locale.ROOT);
       if ( "rewrite".equals(role) ) {
         addRewriteFilter(context, service, filterParams, params, resource);
       } else if ( topologyContainsProviderType(context, role) ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
index 8064846..cd74656 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
@@ -40,6 +40,7 @@ import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 public class ServiceDefinitionDeploymentContributor extends ServiceDeploymentContributorBase {
@@ -151,7 +152,7 @@ public class ServiceDefinitionDeploymentContributor extends ServiceDeploymentCon
       if ( role == null ) {
         throw new IllegalArgumentException("Policy defined has no role for service " + service.getName());
       }
-      role = role.trim().toLowerCase();
+      role = role.trim().toLowerCase(Locale.ROOT);
       if ( "rewrite".equals(role) ) {
         addRewriteFilter(context, service, filterParams, params, resource);
       } else if ( topologyContainsProviderType(context, role) ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/dispatch/UrlConnectionDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/dispatch/UrlConnectionDispatch.java b/gateway-server/src/main/java/org/apache/knox/gateway/dispatch/UrlConnectionDispatch.java
index ff40983..d750733 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/dispatch/UrlConnectionDispatch.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/dispatch/UrlConnectionDispatch.java
@@ -18,6 +18,9 @@
 package org.apache.knox.gateway.dispatch;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
+import org.apache.hadoop.security.authentication.client.AuthenticationException;
+import org.apache.hadoop.security.authentication.client.KerberosAuthenticator;
 import org.apache.knox.gateway.GatewayMessages;
 import org.apache.knox.gateway.GatewayResources;
 import org.apache.knox.gateway.audit.api.Action;
@@ -33,15 +36,11 @@ import org.apache.knox.gateway.util.urltemplate.Parser;
 import org.apache.knox.gateway.util.urltemplate.Resolver;
 import org.apache.knox.gateway.util.urltemplate.Rewriter;
 import org.apache.knox.gateway.util.urltemplate.Template;
-import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
-import org.apache.hadoop.security.authentication.client.AuthenticationException;
-import org.apache.hadoop.security.authentication.client.KerberosAuthenticator;
 
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
@@ -52,6 +51,7 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLEncoder;
 import java.util.Enumeration;
+import java.util.Locale;
 
 /**
  *
@@ -65,7 +65,7 @@ public class UrlConnectionDispatch extends AbstractGatewayFilter {
 
   @Override
   protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
-    String method = request.getMethod().toUpperCase();
+    String method = request.getMethod().toUpperCase(Locale.ROOT);
     if ("GET".equals(method)) {
       try {
         doGet(getDispatchUrl(request), request, response);

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/instr/InstrHttpClientBuilderProvider.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/instr/InstrHttpClientBuilderProvider.java b/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/instr/InstrHttpClientBuilderProvider.java
index 1299d6f..e8ccc08 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/instr/InstrHttpClientBuilderProvider.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/instr/InstrHttpClientBuilderProvider.java
@@ -20,17 +20,17 @@ package org.apache.knox.gateway.services.metrics.impl.instr;
 import com.codahale.metrics.MetricRegistry;
 import com.codahale.metrics.httpclient.HttpClientMetricNameStrategy;
 import com.codahale.metrics.httpclient.InstrumentedHttpRequestExecutor;
-import org.apache.knox.gateway.services.metrics.InstrumentationProvider;
-import org.apache.knox.gateway.services.metrics.MetricsContext;
-import org.apache.knox.gateway.services.metrics.impl.DefaultMetricsService;
 import org.apache.http.Header;
 import org.apache.http.HttpRequest;
 import org.apache.http.RequestLine;
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.knox.gateway.services.metrics.InstrumentationProvider;
+import org.apache.knox.gateway.services.metrics.MetricsContext;
+import org.apache.knox.gateway.services.metrics.impl.DefaultMetricsService;
 
 import java.net.URISyntaxException;
+import java.util.Locale;
 
 public class InstrHttpClientBuilderProvider implements
     InstrumentationProvider<HttpClientBuilder> {
@@ -64,7 +64,7 @@ public class InstrHttpClientBuilderProvider implements
     }
 
     private String methodNameString(HttpRequest request) {
-      return request.getRequestLine().getMethod().toLowerCase() + "-requests";
+      return request.getRequestLine().getMethod().toLowerCase(Locale.ROOT) + "-requests";
     }
   };
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
index f4cf523..bbc45b0 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
@@ -43,6 +43,7 @@ import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
 import java.text.MessageFormat;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.locks.Lock;
@@ -221,7 +222,7 @@ public class DefaultKeystoreService extends BaseKeystoreService implements
   }
 
   private String buildDistinguishedName(String hostname) {
-    MessageFormat headerFormatter = new MessageFormat(dnTemplate);
+    MessageFormat headerFormatter = new MessageFormat(dnTemplate, Locale.ROOT);
     String[] paramArray = new String[1];
     paramArray[0] = hostname;
     String dn = headerFormatter.format(paramArray);

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/RemoteAliasService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/RemoteAliasService.java b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/RemoteAliasService.java
index 4af4991..a55334e 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/RemoteAliasService.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/RemoteAliasService.java
@@ -38,6 +38,7 @@ import java.security.cert.Certificate;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 /**
@@ -246,7 +247,7 @@ public class RemoteAliasService implements AliasService {
 
     /* merge */
     for (final String alias : safe(localAliases)) {
-      if (!remoteAliases.contains(alias.toLowerCase())) {
+      if (!remoteAliases.contains(alias.toLowerCase(Locale.ROOT))) {
         remoteAliases.add(alias);
       }
     }
@@ -260,7 +261,7 @@ public class RemoteAliasService implements AliasService {
       throws AliasServiceException {
 
     /* convert all alias names to lower case since JDK expects the same behaviour */
-    final String alias = givenAlias.toLowerCase();
+    final String alias = givenAlias.toLowerCase(Locale.ROOT);
 
     /* first add the alias to the local keystore */
     localAliasService.addAliasForCluster(clusterName, alias, value);
@@ -281,7 +282,7 @@ public class RemoteAliasService implements AliasService {
       }
 
       if (remoteClient.getEntryData(aliasEntryPath) == null) {
-        throw new IllegalStateException(String.format(
+        throw new IllegalStateException(String.format(Locale.ROOT, 
             "Failed to store alias %s for cluster %s in remote registry", alias,
             clusterName));
       }
@@ -294,7 +295,7 @@ public class RemoteAliasService implements AliasService {
       final String givenAlias) throws AliasServiceException {
 
     /* convert all alias names to lower case since JDK expects the same behaviour */
-    final String alias = givenAlias.toLowerCase();
+    final String alias = givenAlias.toLowerCase(Locale.ROOT);
 
     /* first remove it from the local keystore */
     localAliasService.removeAliasForCluster(clusterName, alias);
@@ -308,7 +309,7 @@ public class RemoteAliasService implements AliasService {
         remoteClient.deleteEntry(aliasEntryPath);
 
         if (remoteClient.entryExists(aliasEntryPath)) {
-          throw new IllegalStateException(String.format(
+          throw new IllegalStateException(String.format(Locale.ROOT, 
               "Failed to delete alias %s for cluster %s in remote registry",
               alias, clusterName));
         }
@@ -332,7 +333,7 @@ public class RemoteAliasService implements AliasService {
       String givenAlias, boolean generate) throws AliasServiceException {
 
     /* convert all alias names to lower case since JDK expects the same behaviour */
-    final String alias = givenAlias.toLowerCase();
+    final String alias = givenAlias.toLowerCase(Locale.ROOT);
 
     char[] password = null;
 
@@ -387,7 +388,7 @@ public class RemoteAliasService implements AliasService {
       final String givenAlias) throws AliasServiceException {
 
     /* convert all alias names to lower case since JDK expects the same behaviour */
-    final String alias = givenAlias.toLowerCase();
+    final String alias = givenAlias.toLowerCase(Locale.ROOT);
     /* auto-generated password */
     final String passwordString = DefaultAliasService.generatePassword(16);
     addAliasForCluster(clusterName, alias, passwordString);

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
index affd46f..e411665 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
@@ -41,6 +41,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -525,7 +526,7 @@ public class SimpleDescriptorHandler {
                 Map<String, String> svcParams = serviceParams.get(serviceName);
                 if (svcParams != null) {
                     for (Entry<String, String> svcParam : svcParams.entrySet()) {
-                        if (!(svcParam.getKey().toLowerCase()).startsWith(DISCOVERY_PARAM_PREFIX)) {
+                        if (!(svcParam.getKey().toLowerCase(Locale.ROOT)).startsWith(DISCOVERY_PARAM_PREFIX)) {
                             sw.write("        <param>\n");
                             sw.write("            <name>" + svcParam.getKey() + "</name>\n");
                             sw.write("            <value>" + svcParam.getValue() + "</value>\n");

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceInput.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceInput.java b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceInput.java
index 4a33e90..a1ab75d 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceInput.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceInput.java
@@ -22,6 +22,7 @@ import org.apache.log4j.Logger;
 
 import javax.servlet.ServletInputStream;
 import java.io.IOException;
+import java.util.Locale;
 
 class TraceInput extends SynchronousServletInputStreamAdapter {
 
@@ -61,7 +62,7 @@ class TraceInput extends SynchronousServletInputStreamAdapter {
       buffer.setLength( 0 );
       StringBuilder sb = new StringBuilder();
       TraceUtil.appendCorrelationContext( sb );
-      sb.append( String.format( "|RequestBody[%d]%n\t%s", body.length(), body ) );
+      sb.append( String.format(Locale.ROOT, "|RequestBody[%d]%n\t%s", body.length(), body ) );
       if( bodyLog.isTraceEnabled() ) {
         log.trace( sb.toString() );
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceOutput.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceOutput.java b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceOutput.java
index 08f370b..ed42e03 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceOutput.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceOutput.java
@@ -22,6 +22,7 @@ import org.apache.log4j.Logger;
 
 import javax.servlet.ServletOutputStream;
 import java.io.IOException;
+import java.util.Locale;
 
 class TraceOutput extends SynchronousServletOutputStreamAdapter {
 
@@ -66,7 +67,7 @@ class TraceOutput extends SynchronousServletOutputStreamAdapter {
       buffer.setLength( 0 );
       StringBuilder sb = new StringBuilder();
       TraceUtil.appendCorrelationContext( sb );
-      sb.append( String.format( "|ResponseBody[%d]%n\t%s", body.length(), body ) );
+      sb.append( String.format(Locale.ROOT, "|ResponseBody[%d]%n\t%s", body.length(), body ) );
       if( bodyLog.isTraceEnabled() ) {
         log.trace( sb.toString() );
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceRequest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceRequest.java b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceRequest.java
index 28573fa..5e8b81d 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceRequest.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceRequest.java
@@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
 import java.io.IOException;
 import java.util.Enumeration;
+import java.util.Locale;
 
 class TraceRequest extends HttpServletRequestWrapper {
 
@@ -74,7 +75,7 @@ class TraceRequest extends HttpServletRequestWrapper {
         Enumeration<String> values = getHeaders( name );
         while( values.hasMoreElements() ) {
           String value = values.nextElement();
-          sb.append( String.format( "%n\tHeader[%s]=%s", name, value ) );
+          sb.append( String.format(Locale.ROOT, "%n\tHeader[%s]=%s", name, value ) );
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceResponse.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceResponse.java b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceResponse.java
index 2bebd53..b708204 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceResponse.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceResponse.java
@@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 import java.io.IOException;
 import java.util.Collection;
+import java.util.Locale;
 import java.util.Set;
 
 class TraceResponse extends HttpServletResponseWrapper {
@@ -66,7 +67,7 @@ class TraceResponse extends HttpServletResponseWrapper {
       Collection<String> names = getHeaderNames();
       for( String name : names ) {
         for( String value : getHeaders( name ) ) {
-          sb.append( String.format( "%n\tHeader[%s]=%s", name, value ) );
+          sb.append( String.format(Locale.ROOT, "%n\tHeader[%s]=%s", name, value ) );
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java b/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java
index 6ff8a91..24ad6f7 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java
@@ -80,6 +80,7 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 import java.util.UUID;
@@ -969,7 +970,7 @@ public class KnoxCLI extends Configured implements Tool {
     public void execute() throws Exception {
       Properties buildProperties = loadBuildProperties();
       System.out.println(
-          String.format(
+          String.format(Locale.ROOT,
               "Apache Knox: %s (%s)",
               buildProperties.getProperty( "build.version", "unknown" ),
               buildProperties.getProperty( "build.hash", "unknown" ) ) );

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/main/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandler.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandler.java b/gateway-server/src/main/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandler.java
index 69634a7..6d51d76 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandler.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandler.java
@@ -17,16 +17,6 @@
  */
 package org.apache.knox.gateway.websockets;
 
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
 import org.apache.commons.lang3.StringUtils;
 import org.apache.knox.gateway.config.GatewayConfig;
 import org.apache.knox.gateway.i18n.messages.MessagesFactory;
@@ -43,6 +33,16 @@ import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
 import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
 
 import javax.websocket.ClientEndpointConfig;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * Websocket handler that will handle websocket connection request. This class
@@ -193,7 +193,7 @@ public class GatewayWebsocketHandler extends WebSocketHandler
 
     if (entry == null) {
       throw new RuntimeException(
-          String.format("Cannot find service for the given path: %s", path));
+          String.format(Locale.ROOT, "Cannot find service for the given path: %s", path));
     }
 
     /* Filter out /cluster/topology/service to get endpoint */
@@ -253,7 +253,7 @@ public class GatewayWebsocketHandler extends WebSocketHandler
     final String[] contexts = path.split("/");
 
     final String serviceURL = serviceRegistry.lookupServiceURL(contexts[2],
-        entry.getName().toUpperCase());
+        entry.getName().toUpperCase(Locale.ROOT));
 
     /*
      * we have a match, if ws:// is present it is returned else http:// is

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/GatewayPortMappingConfigTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/GatewayPortMappingConfigTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/GatewayPortMappingConfigTest.java
index b7d69d5..7039ebe 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/GatewayPortMappingConfigTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/GatewayPortMappingConfigTest.java
@@ -19,7 +19,6 @@ package org.apache.knox.gateway;
  */
 
 import org.apache.knox.gateway.config.GatewayConfig;
-import org.apache.knox.gateway.config.impl.GatewayConfigImpl;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.topology.TopologyService;
 import org.apache.velocity.VelocityContext;
@@ -37,7 +36,7 @@ import org.junit.rules.ExpectedException;
 
 import java.io.IOException;
 import java.lang.reflect.Field;
-import java.util.Collections;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
@@ -159,7 +158,7 @@ public class GatewayPortMappingConfigTest {
       throws IOException, NoSuchFieldException, IllegalAccessException {
     /* Check port conflict with default port */
     exception.expect(IOException.class);
-    exception.expectMessage(String.format(
+    exception.expectMessage(String.format(Locale.ROOT, 
         " Port %d used by topology %s is used by other topology, ports for topologies (if defined) have to be unique. ",
         huronPort, "eerie"));
 
@@ -196,7 +195,7 @@ public class GatewayPortMappingConfigTest {
 
     exception.expect(IOException.class);
     exception
-        .expectMessage(String.format("Port %d already in use.", defaultPort));
+        .expectMessage(String.format(Locale.ROOT, "Port %d already in use.", defaultPort));
 
     final GatewayServer gatewayServer = new GatewayServer(gatewayConfig);
     gatewayServer.checkPortConflict(defaultPort, null, gatewayConfig);

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java
index f65c220..1a24628 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java
@@ -17,24 +17,33 @@
  */
 package org.apache.knox.gateway.jetty;
 
-import org.apache.knox.test.category.MediumTests;
-import org.apache.knox.test.category.ManualTests;
 import org.apache.http.HttpVersion;
 import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
+import org.apache.knox.test.category.ManualTests;
+import org.apache.knox.test.category.MediumTests;
 import org.eclipse.jetty.server.Server;
-import org.junit.*;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.net.ssl.*;
-import java.io.*;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocket;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.net.InetSocketAddress;
-
-import static org.junit.Assert.assertThat;
+import java.nio.charset.StandardCharsets;
 
 @Category( { ManualTests.class, MediumTests.class } )
 public class SslSocketTest {
@@ -77,7 +86,7 @@ public class SslSocketTest {
         SSLSocket sslsocket = (SSLSocket)sslserversocket.accept();
 
         InputStream inputstream = sslsocket.getInputStream();
-        InputStreamReader inputstreamreader = new InputStreamReader( inputstream );
+        InputStreamReader inputstreamreader = new InputStreamReader( inputstream, StandardCharsets.UTF_8 );
         BufferedReader bufferedreader = new BufferedReader( inputstreamreader );
 
         String string = bufferedreader.readLine();
@@ -108,7 +117,7 @@ public class SslSocketTest {
     sslsocket.connect( new InetSocketAddress( "localhost", 9999 ) );
 
     OutputStream outputstream = sslsocket.getOutputStream();
-    OutputStreamWriter outputstreamwriter = new OutputStreamWriter( outputstream );
+    OutputStreamWriter outputstreamwriter = new OutputStreamWriter( outputstream, StandardCharsets.UTF_8 );
     BufferedWriter bufferedwriter = new BufferedWriter( outputstreamwriter );
 
     bufferedwriter.write( "HELLO\n" );

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/security/impl/RemoteAliasMonitorTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/security/impl/RemoteAliasMonitorTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/security/impl/RemoteAliasMonitorTest.java
index 4f2a853..46ce2c7 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/security/impl/RemoteAliasMonitorTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/security/impl/RemoteAliasMonitorTest.java
@@ -39,8 +39,7 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.testng.Assert;
 
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -70,17 +69,8 @@ public class RemoteAliasMonitorTest {
   private static String preferRemoteAlias = "prefer.remote.alias";
   private static String preferRemoteAliasEncryptedPassword = "QmgrK2JBRlE1MUU9OjpIYzZlVUttKzdaWkFOSjlYZVVyVzNRPT06Om5kdTQ3WTJ1by9vSHprZUZHcjBqVG5TaGxsMFVUdUNyN0EvUlZDV1ZHQUU9";
   private static String preferRemoteAliasClearPassword = "ApacheKnoxPassword123";
-  /* For CLI tests */
-  private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
-  private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
   private GatewayConfig gc;
 
-  public RemoteAliasMonitorTest() {
-    super();
-    System.setOut(new PrintStream(outContent));
-    System.setErr(new PrintStream(errContent));
-  }
-
   @BeforeClass
   public static void setupSuite() throws Exception {
     // Configure security for the ZK cluster instances
@@ -141,7 +131,7 @@ public class RemoteAliasMonitorTest {
                 + RemoteAliasService.
                 PATH_SEPARATOR + expectedClusterName
                 + RemoteAliasService.PATH_SEPARATOR + preferRemoteAlias,
-            preferRemoteAliasEncryptedPassword.getBytes());
+            preferRemoteAliasEncryptedPassword.getBytes(StandardCharsets.UTF_8));
   }
 
   @AfterClass
@@ -241,7 +231,7 @@ public class RemoteAliasMonitorTest {
                 + RemoteAliasService.
                 PATH_SEPARATOR + expectedClusterName
                 + RemoteAliasService.PATH_SEPARATOR + expectedAlias,
-            zkAlias.encrypt(expectedPassword).getBytes());
+            zkAlias.encrypt(expectedPassword).getBytes(StandardCharsets.UTF_8));
 
     /* Create an alias in Zookeeper externally */
     client.create().withMode(CreateMode.PERSISTENT).
@@ -249,7 +239,7 @@ public class RemoteAliasMonitorTest {
                 + RemoteAliasService.
                 PATH_SEPARATOR + expectedClusterNameDev
                 + RemoteAliasService.PATH_SEPARATOR + expectedAliasDev,
-            zkAlias.encrypt(expectedPasswordDev).getBytes());
+            zkAlias.encrypt(expectedPasswordDev).getBytes(StandardCharsets.UTF_8));
 
     /* Try */
     aliases = zkAlias.getAliasesForCluster(expectedClusterName);

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/service/config/remote/LocalFileSystemRemoteConfigurationRegistryClientService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/service/config/remote/LocalFileSystemRemoteConfigurationRegistryClientService.java b/gateway-server/src/test/java/org/apache/knox/gateway/service/config/remote/LocalFileSystemRemoteConfigurationRegistryClientService.java
index c17ef87..677fc79 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/service/config/remote/LocalFileSystemRemoteConfigurationRegistryClientService.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/service/config/remote/LocalFileSystemRemoteConfigurationRegistryClientService.java
@@ -32,12 +32,11 @@ import java.nio.file.Paths;
 import java.nio.file.attribute.PosixFilePermission;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
-import java.util.function.Function;
 
 /**
  * An implementation of RemoteConfigurationRegistryClientService intended to be used for testing without having to
@@ -107,7 +106,7 @@ public class LocalFileSystemRemoteConfigurationRegistryClientService implements
                     Set<PosixFilePermission> perms = Files.getPosixFilePermissions(resolved);
                     for (PosixFilePermission perm : perms) {
                         String[] parsed = perm.toString().split("_");
-                        collected.computeIfAbsent(parsed[0].toLowerCase(), s -> new ArrayList<>()).add(parsed[1].toLowerCase());
+                        collected.computeIfAbsent(parsed[0].toLowerCase(Locale.ROOT), s -> new ArrayList<>()).add(parsed[1].toLowerCase(Locale.ROOT));
                     }
 
                     for (String id : collected.keySet()) {

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/PropertiesFileServiceDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/PropertiesFileServiceDiscoveryTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/PropertiesFileServiceDiscoveryTest.java
index fa64b40..9f8897b 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/PropertiesFileServiceDiscoveryTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/PropertiesFileServiceDiscoveryTest.java
@@ -24,10 +24,13 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 
 public class PropertiesFileServiceDiscoveryTest {
@@ -109,7 +112,7 @@ public class PropertiesFileServiceDiscoveryTest {
                     value += url + " ";
                 }
             }
-            System.out.println(String.format("%18s: %s", name, value));
+            System.out.println(String.format(Locale.ROOT, "%18s: %s", name, value));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/ServiceDiscoveryFactoryTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/ServiceDiscoveryFactoryTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/ServiceDiscoveryFactoryTest.java
index 470d8b6..babfaa6 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/ServiceDiscoveryFactoryTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/ServiceDiscoveryFactoryTest.java
@@ -21,8 +21,12 @@ import org.apache.knox.gateway.services.security.impl.DefaultAliasService;
 import org.junit.Test;
 
 import java.lang.reflect.Field;
+import java.util.Locale;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 
 public class ServiceDiscoveryFactoryTest {
@@ -41,7 +45,7 @@ public class ServiceDiscoveryFactoryTest {
         String TYPE = "dUmmY";
         ServiceDiscovery sd = ServiceDiscoveryFactory.get(TYPE);
         assertNotNull("Expected to get a ServiceDiscovery object.", sd);
-        assertEquals("Unexpected ServiceDiscovery type.", TYPE.toUpperCase(), sd.getType());
+        assertEquals("Unexpected ServiceDiscovery type.", TYPE.toUpperCase(Locale.ROOT), sd.getType());
     }
 
 

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/topology/monitor/ZooKeeperConfigurationMonitorTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/monitor/ZooKeeperConfigurationMonitorTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/topology/monitor/ZooKeeperConfigurationMonitorTest.java
index 2e753f1..20eaa2a 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/monitor/ZooKeeperConfigurationMonitorTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/monitor/ZooKeeperConfigurationMonitorTest.java
@@ -37,6 +37,7 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import java.io.File;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -168,7 +169,7 @@ public class ZooKeeperConfigurationMonitorTest {
         // will download existing entries upon starting.
         final String preExistingProviderConfig = getProviderPath("pre-existing-providers.xml");
         client.create().withMode(CreateMode.PERSISTENT).forPath(preExistingProviderConfig,
-                                                                TEST_PROVIDERS_CONFIG_1.getBytes());
+                                                                TEST_PROVIDERS_CONFIG_1.getBytes(StandardCharsets.UTF_8));
         File preExistingProviderConfigLocalFile = new File(providersDir, "pre-existing-providers.xml");
         assertFalse("This file should not exist locally prior to monitor starting.",
                     preExistingProviderConfigLocalFile.exists());
@@ -189,17 +190,17 @@ public class ZooKeeperConfigurationMonitorTest {
             final String pc_two_znode = getProviderPath("providers-config2.xml");
             final File pc_two         = new File(providersDir, "providers-config2.xml");
 
-            client.create().withMode(CreateMode.PERSISTENT).forPath(pc_one_znode, TEST_PROVIDERS_CONFIG_1.getBytes());
+            client.create().withMode(CreateMode.PERSISTENT).forPath(pc_one_znode, TEST_PROVIDERS_CONFIG_1.getBytes(StandardCharsets.UTF_8));
             Thread.sleep(100);
             assertTrue(pc_one.exists());
             assertEquals(TEST_PROVIDERS_CONFIG_1, FileUtils.readFileToString(pc_one));
 
-            client.create().withMode(CreateMode.PERSISTENT).forPath(getProviderPath("providers-config2.xml"), TEST_PROVIDERS_CONFIG_2.getBytes());
+            client.create().withMode(CreateMode.PERSISTENT).forPath(getProviderPath("providers-config2.xml"), TEST_PROVIDERS_CONFIG_2.getBytes(StandardCharsets.UTF_8));
             Thread.sleep(100);
             assertTrue(pc_two.exists());
             assertEquals(TEST_PROVIDERS_CONFIG_2, FileUtils.readFileToString(pc_two));
 
-            client.setData().forPath(pc_two_znode, TEST_PROVIDERS_CONFIG_1.getBytes());
+            client.setData().forPath(pc_two_znode, TEST_PROVIDERS_CONFIG_1.getBytes(StandardCharsets.UTF_8));
             Thread.sleep(100);
             assertTrue(pc_two.exists());
             assertEquals(TEST_PROVIDERS_CONFIG_1, FileUtils.readFileToString(pc_two));
@@ -219,22 +220,22 @@ public class ZooKeeperConfigurationMonitorTest {
             final File desc_two           = new File(descriptorsDir, "test2.json");
             final File desc_three         = new File(descriptorsDir, "test3.json");
 
-            client.create().withMode(CreateMode.PERSISTENT).forPath(desc_one_znode, TEST_DESCRIPTOR_1.getBytes());
+            client.create().withMode(CreateMode.PERSISTENT).forPath(desc_one_znode, TEST_DESCRIPTOR_1.getBytes(StandardCharsets.UTF_8));
             Thread.sleep(100);
             assertTrue(desc_one.exists());
             assertEquals(TEST_DESCRIPTOR_1, FileUtils.readFileToString(desc_one));
 
-            client.create().withMode(CreateMode.PERSISTENT).forPath(desc_two_znode, TEST_DESCRIPTOR_1.getBytes());
+            client.create().withMode(CreateMode.PERSISTENT).forPath(desc_two_znode, TEST_DESCRIPTOR_1.getBytes(StandardCharsets.UTF_8));
             Thread.sleep(100);
             assertTrue(desc_two.exists());
             assertEquals(TEST_DESCRIPTOR_1, FileUtils.readFileToString(desc_two));
 
-            client.setData().forPath(desc_two_znode, TEST_DESCRIPTOR_2.getBytes());
+            client.setData().forPath(desc_two_znode, TEST_DESCRIPTOR_2.getBytes(StandardCharsets.UTF_8));
             Thread.sleep(100);
             assertTrue(desc_two.exists());
             assertEquals(TEST_DESCRIPTOR_2, FileUtils.readFileToString(desc_two));
 
-            client.create().withMode(CreateMode.PERSISTENT).forPath(desc_three_znode, TEST_DESCRIPTOR_1.getBytes());
+            client.create().withMode(CreateMode.PERSISTENT).forPath(desc_three_znode, TEST_DESCRIPTOR_1.getBytes(StandardCharsets.UTF_8));
             Thread.sleep(100);
             assertTrue(desc_three.exists());
             assertEquals(TEST_DESCRIPTOR_1, FileUtils.readFileToString(desc_three));

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParserTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParserTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParserTest.java
index b7cdab9..6d4f5dd 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParserTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParserTest.java
@@ -24,9 +24,11 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 
@@ -304,7 +306,7 @@ public class ProviderConfigurationParserTest {
 
     File testConfig = new File(tmpDir, fileName);
 
-    Writer fw = new FileWriter(testConfig);
+    Writer fw = new OutputStreamWriter(new FileOutputStream(testConfig), StandardCharsets.UTF_8);
     fw.write(config);
     fw.flush();
     fw.close();

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorFactoryTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorFactoryTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorFactoryTest.java
index 0fdabee..45dd389 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorFactoryTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorFactoryTest.java
@@ -16,13 +16,23 @@
  */
 package org.apache.knox.gateway.topology.simple;
 
+import org.junit.Test;
+
 import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
 import java.io.Writer;
-import java.util.*;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
-import org.junit.Test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 
 public class SimpleDescriptorFactoryTest {
@@ -533,7 +543,7 @@ public class SimpleDescriptorFactoryTest {
                            Map<String, Map<String, String>> appParams) throws Exception {
         File f = new File(path);
 
-        Writer fw = new FileWriter(f);
+        Writer fw = new OutputStreamWriter(new FileOutputStream(f), StandardCharsets.UTF_8);
         fw.write("{" + "\n");
         fw.write("\"discovery-type\":\"" + discoveryType + "\",\n");
         fw.write("\"discovery-address\":\"" + discoveryAddress + "\",\n");
@@ -629,7 +639,7 @@ public class SimpleDescriptorFactoryTest {
 
         File f = new File(path);
 
-        Writer fw = new FileWriter(f);
+        Writer fw = new OutputStreamWriter(new FileOutputStream(f), StandardCharsets.UTF_8);
         fw.write("---" + "\n");
         fw.write("discovery-type: " + discoveryType + "\n");
         fw.write("discovery-address: " + discoveryAddress + "\n");

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
index 58a6c72..befde7d 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
@@ -17,17 +17,31 @@
  */
 package org.apache.knox.gateway.topology.simple;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.knox.gateway.config.GatewayConfig;
-import org.apache.knox.gateway.topology.discovery.test.extension.DummyServiceDiscoveryType;
 import org.apache.knox.gateway.topology.validation.TopologyValidator;
 import org.apache.knox.gateway.util.XmlUtils;
+import org.easymock.EasyMock;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
-
 import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -35,22 +49,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.commons.io.FileUtils;
-import org.easymock.EasyMock;
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
 import static org.hamcrest.Matchers.hasXPath;
 import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertEquals;
@@ -245,7 +243,7 @@ public class SimpleDescriptorHandlerTest {
             // Validate the provider configuration
             Node gatewayNode = (Node) xpath.compile("/topology/gateway").evaluate(topologyXml, XPathConstants.NODE);
             ProviderConfiguration testProviderConfiguration =
-                        ProviderConfigurationParser.parseXML(new ByteArrayInputStream(TEST_PROVIDER_CONFIG.getBytes()));
+                        ProviderConfigurationParser.parseXML(new ByteArrayInputStream(TEST_PROVIDER_CONFIG.getBytes(StandardCharsets.UTF_8)));
             validateGeneratedProviderConfiguration(testProviderConfiguration, gatewayNode);
 
             // Validate the service declarations
@@ -415,7 +413,7 @@ public class SimpleDescriptorHandlerTest {
             // Validate the provider configuration
             Node gatewayNode = (Node) xpath.compile("/topology/gateway").evaluate(topologyXml, XPathConstants.NODE);
             ProviderConfiguration testProviderConfiguration =
-                ProviderConfigurationParser.parseXML(new ByteArrayInputStream(TEST_PROVIDER_CONFIG.getBytes()));
+                ProviderConfigurationParser.parseXML(new ByteArrayInputStream(TEST_PROVIDER_CONFIG.getBytes(StandardCharsets.UTF_8)));
             validateGeneratedProviderConfiguration(testProviderConfiguration, gatewayNode);
 
             // Validate the service declarations
@@ -637,7 +635,7 @@ public class SimpleDescriptorHandlerTest {
             // Validate the provider configuration
             Node gatewayNode = (Node) xpath.compile("/topology/gateway").evaluate(topologyXml, XPathConstants.NODE);
             ProviderConfiguration testProviderConfiguration =
-                ProviderConfigurationParser.parseXML(new ByteArrayInputStream(TEST_HA_PROVIDER_CONFIG.getBytes()));
+                ProviderConfigurationParser.parseXML(new ByteArrayInputStream(TEST_HA_PROVIDER_CONFIG.getBytes(StandardCharsets.UTF_8)));
             validateGeneratedProviderConfiguration(testProviderConfiguration, gatewayNode);
 
             // Validate the service declarations
@@ -784,7 +782,7 @@ public class SimpleDescriptorHandlerTest {
         Transformer transformer = TransformerFactory.newInstance().newTransformer();
         transformer.transform(new DOMSource(generatedGatewayNode), new StreamResult(writer));
         ProviderConfiguration generatedProviderConfiguration =
-                        ProviderConfigurationParser.parseXML(new ByteArrayInputStream(writer.toString().getBytes()));
+                        ProviderConfigurationParser.parseXML(new ByteArrayInputStream(writer.toString().getBytes(StandardCharsets.UTF_8)));
         assertNotNull(generatedProviderConfiguration);
 
         // Compare the generated ProviderConfiguration to the expected one

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/util/KnoxCLITest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/util/KnoxCLITest.java b/gateway-server/src/test/java/org/apache/knox/gateway/util/KnoxCLITest.java
index 116b8dd..3a27d72 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/util/KnoxCLITest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/util/KnoxCLITest.java
@@ -60,8 +60,8 @@ public class KnoxCLITest {
 
   @Before
   public void setup() throws Exception {
-    System.setOut(new PrintStream(outContent));
-    System.setErr(new PrintStream(errContent));
+    System.setOut(new PrintStream(outContent, false, "UTF-8"));
+    System.setErr(new PrintStream(errContent, false, "UTF-8"));
   }
 
   @Test
@@ -99,7 +99,7 @@ public class KnoxCLITest {
     // Test with no registry clients configured
     int rc = cli.run(args);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().isEmpty());
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").isEmpty());
 
     // Test with a single client configured
     // Configure a client for the test local filesystem registry implementation
@@ -108,7 +108,7 @@ public class KnoxCLITest {
     outContent.reset();
     rc = cli.run(args);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("test_client"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("test_client"));
 
     // Configure another client for the test local filesystem registry implementation
     config.set("gateway.remote.config.registry.another_client", "type=LocalFileSystem;address=/test2");
@@ -116,8 +116,8 @@ public class KnoxCLITest {
     outContent.reset();
     rc = cli.run(args);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("test_client"));
-    assertTrue(outContent.toString(), outContent.toString().contains("another_client"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("test_client"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("another_client"));
   }
 
   @Test
@@ -156,7 +156,7 @@ public class KnoxCLITest {
 
       // Validate the result
       assertEquals(0, rc);
-      String result = outContent.toString();
+      String result = outContent.toString("UTF-8");
       assertEquals(result, 3, result.split("\n").length);
     } finally {
       FileUtils.forceDelete(testRoot);
@@ -197,7 +197,7 @@ public class KnoxCLITest {
       outContent.reset();
       final String[] listArgs = {"list-provider-configs", "--registry-client", "test_client"};
       cli.run(listArgs);
-      String outStr =  outContent.toString().trim();
+      String outStr =  outContent.toString("UTF-8").trim();
       assertTrue(outStr.startsWith("Provider Configurations"));
       assertTrue(outStr.endsWith(")\n"+providerConfigName));
 
@@ -284,7 +284,7 @@ public class KnoxCLITest {
       outContent.reset();
       final String[] listArgs = {"list-descriptors", "--registry-client", "test_client"};
       cli.run(listArgs);
-      String outStr =  outContent.toString().trim();
+      String outStr =  outContent.toString("UTF-8").trim();
       assertTrue(outStr.startsWith("Descriptors"));
       assertTrue(outStr.endsWith(")\n"+descriptorName));
 
@@ -450,7 +450,7 @@ public class KnoxCLITest {
     cli.setConf(new GatewayConfigImpl());
     rc = cli.run(args1);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("alias1 has been successfully " +
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias1 has been successfully " +
         "created."));
 
     outContent.reset();
@@ -458,20 +458,20 @@ public class KnoxCLITest {
         "master"};
     rc = cli.run(args2);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("alias1"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias1"));
 
     outContent.reset();
     String[] args4 = {"delete-alias", "alias1", "--master", 
       "master"};
     rc = cli.run(args4);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("alias1 has been successfully " +
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias1 has been successfully " +
         "deleted."));
 
     outContent.reset();
     rc = cli.run(args2);
     assertEquals(0, rc);
-    assertFalse(outContent.toString(), outContent.toString().contains("alias1"));
+    assertFalse(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias1"));
   }
   
   @Test
@@ -485,24 +485,24 @@ public class KnoxCLITest {
     cli.setConf(new GatewayConfigImpl());
     rc = cli.run(args1);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains(
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains(
       "alias1 has been successfully " + "created."));
 
     outContent.reset();
     String[] args2 = { "list-alias", "--cluster", "Invalidcluster1", "--master", "master" };
     rc = cli.run(args2);
     assertEquals(0, rc);
-    System.out.println(outContent.toString());
-    assertTrue(outContent.toString(),
-      outContent.toString().contains("Invalid cluster name provided: Invalidcluster1"));
+    System.out.println(outContent.toString("UTF-8"));
+    assertTrue(outContent.toString("UTF-8"),
+      outContent.toString("UTF-8").contains("Invalid cluster name provided: Invalidcluster1"));
 
     outContent.reset();
     String[] args4 =
         { "delete-alias", "alias1", "--cluster", "Invalidcluster1", "--master", "master" };
     rc = cli.run(args4);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(),
-      outContent.toString().contains("Invalid cluster name provided: Invalidcluster1"));
+    assertTrue(outContent.toString("UTF-8"),
+      outContent.toString("UTF-8").contains("Invalid cluster name provided: Invalidcluster1"));
 
   }
 
@@ -523,7 +523,7 @@ public class KnoxCLITest {
       String[] args2 = { "delete-alias", "alias2", "--cluster", "cluster1", "--master", "master" };
       rc = cli.run(args2);
       assertEquals(0, rc);
-      assertTrue(outContent.toString().contains("No such alias exists in the cluster."));
+      assertTrue(outContent.toString("UTF-8").contains("No such alias exists in the cluster."));
     } finally {
       outContent.reset();
       String[] args1 = { "delete-alias", "alias1", "--cluster", "cluster1", "--master", "master" };
@@ -546,7 +546,7 @@ public class KnoxCLITest {
       String[] args2 = { "delete-alias", "alias2", "--master", "master" };
       rc = cli.run(args2);
       assertEquals(0, rc);
-      assertTrue(outContent.toString().contains("No such alias exists in the cluster."));
+      assertTrue(outContent.toString("UTF-8").contains("No such alias exists in the cluster."));
     } finally {
       outContent.reset();
       String[] args1 = { "delete-alias", "alias1", "--master", "master" };
@@ -562,7 +562,7 @@ public class KnoxCLITest {
     cli.setConf(new GatewayConfigImpl());
     int rc = cli.run(args1);
     assertEquals(-2, rc);
-    assertTrue(outContent.toString().contains("ERROR: Invalid Command"));
+    assertTrue(outContent.toString("UTF-8").contains("ERROR: Invalid Command"));
   }
 
   @Test
@@ -576,28 +576,28 @@ public class KnoxCLITest {
     cli.setConf(new GatewayConfigImpl());
     rc = cli.run(args1);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains(
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains(
       "alias1 has been successfully " + "created."));
 
     outContent.reset();
     String[] args2 = { "list-alias", "--cluster", "cluster1", "--master", "master" };
     rc = cli.run(args2);
     assertEquals(0, rc);
-    System.out.println(outContent.toString());
-    assertTrue(outContent.toString(), outContent.toString().contains("alias1"));
+    System.out.println(outContent.toString("UTF-8"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias1"));
 
     outContent.reset();
     String[] args4 =
         { "delete-alias", "alias1", "--cluster", "cluster1", "--master", "master" };
     rc = cli.run(args4);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains(
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains(
       "alias1 has been successfully " + "deleted."));
 
     outContent.reset();
     rc = cli.run(args2);
     assertEquals(0, rc);
-    assertFalse(outContent.toString(), outContent.toString().contains("alias1"));
+    assertFalse(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias1"));
 
   }
 
@@ -613,7 +613,7 @@ public class KnoxCLITest {
     cli.setConf( config );
     rc = cli.run(gwCreateArgs);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("alias1 has been successfully " +
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias1 has been successfully " +
         "created."));
 
     AliasService as = cli.getGatewayServices().getService(GatewayServices.ALIAS_SERVICE);
@@ -625,7 +625,7 @@ public class KnoxCLITest {
     cli.setConf( config );
     rc = cli.run(clusterCreateArgs);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("alias2 has been successfully " +
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias2 has been successfully " +
         "created."));
 
     outContent.reset();
@@ -633,27 +633,27 @@ public class KnoxCLITest {
     cli = new KnoxCLI();
     rc = cli.run(args2);
     assertEquals(0, rc);
-    assertFalse(outContent.toString(), outContent.toString().contains("alias2"));
-    assertTrue(outContent.toString(), outContent.toString().contains("alias1"));
+    assertFalse(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias2"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias1"));
 
     char[] passwordChars = as.getPasswordFromAliasForCluster("test", "alias2");
     assertNotNull(passwordChars);
-    assertTrue(new String(passwordChars), "testvalue1".equals(new String(passwordChars)));
+    assertEquals(new String(passwordChars), "testvalue1", new String(passwordChars));
 
     outContent.reset();
     String[] args1 = {"list-alias", "--cluster", "test", "--master", "master"};
     cli = new KnoxCLI();
     rc = cli.run(args1);
     assertEquals(0, rc);
-    assertFalse(outContent.toString(), outContent.toString().contains("alias1"));
-    assertTrue(outContent.toString(), outContent.toString().contains("alias2"));
+    assertFalse(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias1"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias2"));
 
     outContent.reset();
     String[] args4 = {"delete-alias", "alias1", "--master", "master"};
     cli = new KnoxCLI();
     rc = cli.run(args4);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("alias1 has been successfully " +
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias1 has been successfully " +
         "deleted."));
     
     outContent.reset();
@@ -661,7 +661,7 @@ public class KnoxCLITest {
     cli = new KnoxCLI();
     rc = cli.run(args5);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("alias2 has been successfully " +
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("alias2 has been successfully " +
         "deleted."));
   }
 
@@ -674,7 +674,7 @@ public class KnoxCLITest {
     MasterService ms = cli.getGatewayServices().getService("MasterService");
     String master = String.copyValueOf( ms.getMasterSecret() );
     assertThat( master, is( "master" ) );
-    assertThat( outContent.toString(), containsString( "Master secret has been persisted to disk." ) );
+    assertThat( outContent.toString("UTF-8"), containsString( "Master secret has been persisted to disk." ) );
   }
 
   @Test
@@ -689,7 +689,7 @@ public class KnoxCLITest {
     int rc = 0;
     rc = cli.run(gwCreateArgs);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("gateway-identity has been successfully " +
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("gateway-identity has been successfully " +
         "created."));
   }
 
@@ -705,7 +705,7 @@ public class KnoxCLITest {
     int rc = 0;
     rc = cli.run(gwCreateArgs);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("gateway-identity has been successfully " +
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("gateway-identity has been successfully " +
         "created."));
 
     outContent.reset();
@@ -713,31 +713,31 @@ public class KnoxCLITest {
     rc = 0;
     rc = cli.run(gwCreateArgs2);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("Certificate gateway-identity has been successfully exported to"));
-    assertTrue(outContent.toString(), outContent.toString().contains("gateway-identity.pem"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("Certificate gateway-identity has been successfully exported to"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("gateway-identity.pem"));
 
     outContent.reset();
     String[] gwCreateArgs2_5 = {"export-cert"};
     rc = 0;
     rc = cli.run(gwCreateArgs2_5);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("Certificate gateway-identity has been successfully exported to"));
-    assertTrue(outContent.toString(), outContent.toString().contains("gateway-identity.pem"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("Certificate gateway-identity has been successfully exported to"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("gateway-identity.pem"));
 
     outContent.reset();
     String[] gwCreateArgs3 = {"export-cert", "--type", "JKS"};
     rc = 0;
     rc = cli.run(gwCreateArgs3);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("Certificate gateway-identity has been successfully exported to"));
-    assertTrue(outContent.toString(), outContent.toString().contains("gateway-client-trust.jks"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("Certificate gateway-identity has been successfully exported to"));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("gateway-client-trust.jks"));
 
     outContent.reset();
     String[] gwCreateArgs4 = {"export-cert", "--type", "invalid"};
     rc = 0;
     rc = cli.run(gwCreateArgs4);
     assertEquals(0, rc);
-    assertTrue(outContent.toString(), outContent.toString().contains("Invalid type for export file provided."));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("Invalid type for export file provided."));
   }
 
   @Test
@@ -754,7 +754,7 @@ public class KnoxCLITest {
     MasterService ms = cli.getGatewayServices().getService("MasterService");
     // assertTrue(ms.getClass().getName(), ms.getClass().getName().equals("kjdfhgjkhfdgjkh"));
     assertTrue( new String( ms.getMasterSecret() ), "master".equals( new String( ms.getMasterSecret() ) ) );
-    assertTrue(outContent.toString(), outContent.toString().contains("Master secret has been persisted to disk."));
+    assertTrue(outContent.toString("UTF-8"), outContent.toString("UTF-8").contains("Master secret has been persisted to disk."));
   }
 
   @Test
@@ -781,7 +781,7 @@ public class KnoxCLITest {
     assertThat( master.indexOf( '-', 14 ), is( 18 ) );
     assertThat( master.indexOf( '-', 19 ), is( 23 ) );
     assertThat( UUID.fromString( master ), notNullValue() );
-    assertThat( outContent.toString(), containsString( "Master secret has been persisted to disk." ) );
+    assertThat( outContent.toString("UTF-8"), containsString( "Master secret has been persisted to disk." ) );
 
     // Need to delete the master file so that the change isn't ignored.
     if( masterFile.exists() ) {
@@ -796,7 +796,7 @@ public class KnoxCLITest {
     assertThat( UUID.fromString( master2 ), notNullValue() );
     assertThat( master2, not( is( master ) ) );
     assertThat( rc, is( 0 ) );
-    assertThat(outContent.toString(), containsString("Master secret has been persisted to disk."));
+    assertThat(outContent.toString("UTF-8"), containsString("Master secret has been persisted to disk."));
   }
 
   @Test
@@ -822,12 +822,12 @@ public class KnoxCLITest {
     ms = cli.getGatewayServices().getService("MasterService");
     String master = String.copyValueOf( ms.getMasterSecret() );
     assertThat( master, is( "test-master-1" ) );
-    assertThat( outContent.toString(), containsString( "Master secret has been persisted to disk." ) );
+    assertThat( outContent.toString("UTF-8"), containsString( "Master secret has been persisted to disk." ) );
 
     outContent.reset();
     rc = cli.run(args);
     assertThat( rc, is(0 ) );
-    assertThat( outContent.toString(), containsString( "Master secret is already present on disk." ) );
+    assertThat( outContent.toString("UTF-8"), containsString( "Master secret is already present on disk." ) );
 
     outContent.reset();
     args = new String[]{ "create-master", "--master", "test-master-2", "--force" };
@@ -836,7 +836,7 @@ public class KnoxCLITest {
     ms = cli.getGatewayServices().getService("MasterService");
     master = String.copyValueOf( ms.getMasterSecret() );
     assertThat( master, is( "test-master-2" ) );
-    assertThat( outContent.toString(), containsString( "Master secret has been persisted to disk." ) );
+    assertThat( outContent.toString("UTF-8"), containsString( "Master secret has been persisted to disk." ) );
   }
 
   @Test
@@ -851,8 +851,8 @@ public class KnoxCLITest {
     cli.setConf( config );
 
     cli.run( args );
-    assertThat(outContent.toString(), containsString("sandbox"));
-    assertThat(outContent.toString(), containsString("admin"));
+    assertThat(outContent.toString("UTF-8"), containsString("sandbox"));
+    assertThat(outContent.toString("UTF-8"), containsString("admin"));
   }
 
   private class GatewayConfigMock extends GatewayConfigImpl{
@@ -967,30 +967,30 @@ public class KnoxCLITest {
     cli.setConf( config );
     cli.run( args );
 
-    assertThat(outContent.toString(), containsString(config.getGatewayTopologyDir()));
-    assertThat(outContent.toString(), containsString("sandbox"));
-    assertThat(outContent.toString(), containsString("success"));
+    assertThat(outContent.toString("UTF-8"), containsString(config.getGatewayTopologyDir()));
+    assertThat(outContent.toString("UTF-8"), containsString("sandbox"));
+    assertThat(outContent.toString("UTF-8"), containsString("success"));
     outContent.reset();
 
 
     String args2[] = {"validate-topology", "--master", "knox", "--cluster", "NotATopology"};
     cli.run(args2);
 
-    assertThat(outContent.toString(), containsString("NotATopology"));
-    assertThat(outContent.toString(), containsString("does not exist"));
+    assertThat(outContent.toString("UTF-8"), containsString("NotATopology"));
+    assertThat(outContent.toString("UTF-8"), containsString("does not exist"));
     outContent.reset();
 
     String args3[] = {"validate-topology", "--master", "knox", "--path", config.getGatewayTopologyDir() + "/admin.xml"};
     cli.run(args3);
 
-    assertThat(outContent.toString(), containsString("admin"));
-    assertThat(outContent.toString(), containsString("success"));
+    assertThat(outContent.toString("UTF-8"), containsString("admin"));
+    assertThat(outContent.toString("UTF-8"), containsString("success"));
     outContent.reset();
 
     String args4[] = {"validate-topology", "--master", "knox", "--path", "not/a/path"};
     cli.run(args4);
-    assertThat(outContent.toString(), containsString("does not exist"));
-    assertThat(outContent.toString(), containsString("not/a/path"));
+    assertThat(outContent.toString("UTF-8"), containsString("does not exist"));
+    assertThat(outContent.toString("UTF-8"), containsString("not/a/path"));
   }
 
   @Test
@@ -1008,11 +1008,11 @@ public class KnoxCLITest {
     cli.setConf( config );
     cli.run( args );
 
-    assertThat(outContent.toString(), containsString(config.getGatewayTopologyDir()));
-    assertThat(outContent.toString(), containsString("test-cluster-bad"));
-    assertThat(outContent.toString(), containsString("unsuccessful"));
-    assertThat(outContent.toString(), containsString("Invalid content"));
-    assertThat(outContent.toString(), containsString("Line"));
+    assertThat(outContent.toString("UTF-8"), containsString(config.getGatewayTopologyDir()));
+    assertThat(outContent.toString("UTF-8"), containsString("test-cluster-bad"));
+    assertThat(outContent.toString("UTF-8"), containsString("unsuccessful"));
+    assertThat(outContent.toString("UTF-8"), containsString("Invalid content"));
+    assertThat(outContent.toString("UTF-8"), containsString("Line"));
 
 
     outContent.reset();
@@ -1021,9 +1021,9 @@ public class KnoxCLITest {
 
     cli.run(args2);
 
-    assertThat(outContent.toString(), containsString(config.getGatewayTopologyDir()));
-    assertThat(outContent.toString(), containsString("success"));
-    assertThat(outContent.toString(), containsString("test-cluster-good"));
+    assertThat(outContent.toString("UTF-8"), containsString(config.getGatewayTopologyDir()));
+    assertThat(outContent.toString("UTF-8"), containsString("success"));
+    assertThat(outContent.toString("UTF-8"), containsString("test-cluster-good"));
 
 
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/websockets/BadBackendTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/BadBackendTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/BadBackendTest.java
index ec7bfc7..7fbb673 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/BadBackendTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/BadBackendTest.java
@@ -17,15 +17,6 @@
  */
 package org.apache.knox.gateway.websockets;
 
-import java.io.IOException;
-import java.net.URI;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.websocket.CloseReason;
-import javax.websocket.ContainerProvider;
-import javax.websocket.WebSocketContainer;
-
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.server.handler.ContextHandler;
@@ -35,6 +26,15 @@ import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import javax.websocket.CloseReason;
+import javax.websocket.ContainerProvider;
+import javax.websocket.WebSocketContainer;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Locale;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
 /**
  * Test a case where the backend is down.
  *
@@ -109,7 +109,7 @@ public class BadBackendTest {
       host = "localhost";
     }
     int port = proxyConnector.getLocalPort();
-    proxyUri = new URI(String.format("ws://%s:%d/", host, port));
+    proxyUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port));
     
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/websockets/BadUrlTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/BadUrlTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/BadUrlTest.java
index 2ca5ede..7ead272 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/BadUrlTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/BadUrlTest.java
@@ -17,22 +17,8 @@
  */
 package org.apache.knox.gateway.websockets;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import javax.websocket.CloseReason;
-import javax.websocket.ContainerProvider;
-import javax.websocket.WebSocketContainer;
-
+import com.mycila.xmltool.XMLDoc;
+import com.mycila.xmltool.XMLTag;
 import org.apache.commons.io.FileUtils;
 import org.apache.knox.gateway.config.GatewayConfig;
 import org.apache.knox.gateway.config.impl.GatewayConfigImpl;
@@ -55,8 +41,21 @@ import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import com.mycila.xmltool.XMLDoc;
-import com.mycila.xmltool.XMLTag;
+import javax.websocket.CloseReason;
+import javax.websocket.ContainerProvider;
+import javax.websocket.WebSocketContainer;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Test for bad URLs.
@@ -167,7 +166,7 @@ public class BadUrlTest {
       host = "localhost";
     }
     int port = connector.getLocalPort();
-    serverUri = new URI(String.format("ws://%s:%d/", host, port));
+    serverUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port));
 
     /* Setup websocket handler */
     setupGatewayConfig(BACKEND);

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ConnectionDroppedTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ConnectionDroppedTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ConnectionDroppedTest.java
index 888e466..343b782 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ConnectionDroppedTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ConnectionDroppedTest.java
@@ -17,14 +17,6 @@
  */
 package org.apache.knox.gateway.websockets;
 
-import java.io.IOException;
-import java.net.URI;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.websocket.ContainerProvider;
-import javax.websocket.WebSocketContainer;
-
 import org.eclipse.jetty.io.RuntimeIOException;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.ServerConnector;
@@ -38,6 +30,14 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import javax.websocket.ContainerProvider;
+import javax.websocket.WebSocketContainer;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Locale;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
 /**
  * Test to simulate unexpected connection drop. Here we establish a connection
  * and then try to simulate an error.
@@ -120,7 +120,7 @@ public class ConnectionDroppedTest {
       host = "localhost";
     }
     int port = connector.getLocalPort();
-    serverUri = new URI(String.format("ws://%s:%d/", host, port));
+    serverUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port));
 
   }
 
@@ -146,7 +146,7 @@ public class ConnectionDroppedTest {
       host = "localhost";
     }
     int port = proxyConnector.getLocalPort();
-    proxyUri = new URI(String.format("ws://%s:%d/", host, port));
+    proxyUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port));
 
   }
 


Mime
View raw message