knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [2/4] knox git commit: KNOX-1442 - Enable forbiddenapis for static build checking
Date Tue, 25 Sep 2018 01:37:47 GMT
http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/websockets/MessageFailureTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/MessageFailureTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/MessageFailureTest.java
index 58568d0..1cf30e1 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/MessageFailureTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/MessageFailureTest.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;
@@ -41,6 +32,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;
+
 /**
  * Dummy Test for max message size.
  *
@@ -145,7 +145,7 @@ public class MessageFailureTest {
       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));
 
   }
 
@@ -171,7 +171,7 @@ public class MessageFailureTest {
       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/ProxyInboundClientTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ProxyInboundClientTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ProxyInboundClientTest.java
index f8dd167..859c7a3 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ProxyInboundClientTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ProxyInboundClientTest.java
@@ -35,6 +35,8 @@ import javax.websocket.WebSocketContainer;
 import java.io.IOException;
 import java.net.URI;
 import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.Locale;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import static org.hamcrest.Matchers.instanceOf;
@@ -81,7 +83,7 @@ public class ProxyInboundClientTest {
       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));
   }
 
   @AfterClass
@@ -102,7 +104,7 @@ public class ProxyInboundClientTest {
   public void testClientInstance() throws IOException, DeploymentException {
 
     final String textMessage = "Echo";
-    final ByteBuffer binarymessage = ByteBuffer.wrap(textMessage.getBytes());
+    final ByteBuffer binarymessage = ByteBuffer.wrap(textMessage.getBytes(StandardCharsets.UTF_8));
 
     final AtomicBoolean isTestComplete = new AtomicBoolean(false);
 
@@ -192,7 +194,7 @@ public class ProxyInboundClientTest {
   public void testBinarymessage() throws IOException, DeploymentException {
 
     final String textMessage = "Echo";
-    final ByteBuffer binarymessage = ByteBuffer.wrap(textMessage.getBytes());
+    final ByteBuffer binarymessage = ByteBuffer.wrap(textMessage.getBytes(StandardCharsets.UTF_8));
 
     final AtomicBoolean isTestComplete = new AtomicBoolean(false);
 
@@ -276,7 +278,7 @@ public class ProxyInboundClientTest {
       /* just wait for the test to finish */
     }
 
-    Assert.assertEquals("Binary message does not match", textMessage, new String(recievedBinaryMessage));
+    Assert.assertEquals("Binary message does not match", textMessage, new String(recievedBinaryMessage, StandardCharsets.UTF_8));
   }
 
   @Test(timeout = 3000)

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketEchoTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketEchoTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketEchoTest.java
index 64ad87c..18ac7aa 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketEchoTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketEchoTest.java
@@ -17,25 +17,8 @@
  */
 package org.apache.knox.gateway.websockets;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-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.ContainerProvider;
-import javax.websocket.Session;
-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;
@@ -56,8 +39,24 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import com.mycila.xmltool.XMLDoc;
-import com.mycila.xmltool.XMLTag;
+import javax.websocket.ContainerProvider;
+import javax.websocket.Session;
+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;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 /**
  * A basic test that attempts to proxy websocket connections through Knox
@@ -220,7 +219,7 @@ public class WebsocketEchoTest {
       host = "localhost";
     }
     int port = connector.getLocalPort();
-    backendServerUri = new URI(String.format("ws://%s:%d/ws", host, port));
+    backendServerUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/ws", host, port));
 
   }
 
@@ -252,7 +251,7 @@ public class WebsocketEchoTest {
       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(backendServerUri.toString());

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketMultipleConnectionTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketMultipleConnectionTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketMultipleConnectionTest.java
index 5e5006c..e2c7df7 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketMultipleConnectionTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketMultipleConnectionTest.java
@@ -17,28 +17,8 @@
  */
 package org.apache.knox.gateway.websockets;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryMXBean;
-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.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.websocket.ContainerProvider;
-import javax.websocket.Endpoint;
-import javax.websocket.EndpointConfig;
-import javax.websocket.MessageHandler;
-import javax.websocket.Session;
-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;
@@ -60,8 +40,27 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import com.mycila.xmltool.XMLDoc;
-import com.mycila.xmltool.XMLTag;
+import javax.websocket.ContainerProvider;
+import javax.websocket.Endpoint;
+import javax.websocket.EndpointConfig;
+import javax.websocket.MessageHandler;
+import javax.websocket.Session;
+import javax.websocket.WebSocketContainer;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
+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.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Test how Knox holds up under multiple concurrent connections.
@@ -211,7 +210,7 @@ public class WebsocketMultipleConnectionTest {
       host = "localhost";
     }
     int port = connector.getLocalPort();
-    backendServerUri = new URI(String.format("ws://%s:%d/ws", host, port));
+    backendServerUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/ws", host, port));
 
   }
 
@@ -244,7 +243,7 @@ public class WebsocketMultipleConnectionTest {
       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(backendServerUri.toString());

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-service-health/src/main/java/org/apache/knox/gateway/service/health/MetricsResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-health/src/main/java/org/apache/knox/gateway/service/health/MetricsResource.java b/gateway-service-health/src/main/java/org/apache/knox/gateway/service/health/MetricsResource.java
index ec0af2b..14bbe12 100644
--- a/gateway-service-health/src/main/java/org/apache/knox/gateway/service/health/MetricsResource.java
+++ b/gateway-service-health/src/main/java/org/apache/knox/gateway/service/health/MetricsResource.java
@@ -74,7 +74,7 @@ public class MetricsResource {
       if (registryAttr instanceof MetricRegistry) {
         this.registry = (MetricRegistry) registryAttr;
       } else {
-        throw new IllegalStateException(String.format("Couldn't find a MetricRegistry instance with key %s",
+        throw new IllegalStateException(String.format(Locale.ROOT, "Couldn't find a MetricRegistry instance with key %s",
             METRICS_REGISTRY));
       }
     }
@@ -86,7 +86,7 @@ public class MetricsResource {
     this.mapper = new ObjectMapper().registerModule(new MetricsModule(rateUnit, durationUnit,
         showSamples));
     this.allowedOrigin = context.getInitParameter(ALLOWED_ORIGIN);
-    log.basicInfo(String.format("Successfully initialized the registry '%s'", METRICS_REGISTRY));
+    log.basicInfo(String.format(Locale.ROOT, "Successfully initialized the registry '%s'", METRICS_REGISTRY));
   }
 
   @GET
@@ -118,7 +118,7 @@ public class MetricsResource {
       }
     } catch (IOException ioe) {
       log.logException("metrics", ioe);
-      return Response.serverError().entity(String.format("Failed to reply correctly due to : %s ", ioe)).build();
+      return Response.serverError().entity(String.format(Locale.ROOT, "Failed to reply correctly due to : %s ", ioe)).build();
     }
     return Response.ok().build();
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-service-health/src/main/java/org/apache/knox/gateway/service/health/PingResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-health/src/main/java/org/apache/knox/gateway/service/health/PingResource.java b/gateway-service-health/src/main/java/org/apache/knox/gateway/service/health/PingResource.java
index afcb6ff..6467894 100644
--- a/gateway-service-health/src/main/java/org/apache/knox/gateway/service/health/PingResource.java
+++ b/gateway-service-health/src/main/java/org/apache/knox/gateway/service/health/PingResource.java
@@ -30,6 +30,7 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.Locale;
 
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 import static javax.ws.rs.core.MediaType.TEXT_PLAIN;
@@ -76,7 +77,7 @@ public class PingResource {
       writer.println(getPingContent());
     } catch (IOException ioe) {
       log.logException("ping", ioe);
-      return Response.serverError().entity(String.format("Failed to reply correctly due to : %s ", ioe)).build();
+      return Response.serverError().entity(String.format(Locale.ROOT, "Failed to reply correctly due to : %s ", ioe)).build();
     } finally {
       if (writer != null) {
         writer.close();

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiDispatch.java b/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiDispatch.java
index d939180..da2c529 100644
--- a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiDispatch.java
+++ b/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiDispatch.java
@@ -17,19 +17,19 @@
  */
 package org.apache.knox.gateway.dispatch;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.knox.gateway.util.MimeTypes;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.entity.ContentType;
+import org.apache.knox.gateway.util.MimeTypes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+import java.util.Set;
 
 public class NiFiDispatch extends DefaultDispatch {
 
@@ -54,7 +54,7 @@ public class NiFiDispatch extends DefaultDispatch {
     }
     for ( Header header : headers ) {
       String name = header.getName();
-      if (hasExcludeHeaders && excludeHeaders.contains(name.toUpperCase())) {
+      if (hasExcludeHeaders && excludeHeaders.contains(name.toUpperCase(Locale.ROOT))) {
         continue;
       }
       String value = header.getValue();

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiHaDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiHaDispatch.java b/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiHaDispatch.java
index 724eb42..bea1fac 100644
--- a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiHaDispatch.java
+++ b/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiHaDispatch.java
@@ -17,20 +17,20 @@
  */
 package org.apache.knox.gateway.dispatch;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.knox.gateway.ha.dispatch.DefaultHaDispatch;
-import org.apache.knox.gateway.util.MimeTypes;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.entity.ContentType;
+import org.apache.knox.gateway.ha.dispatch.DefaultHaDispatch;
+import org.apache.knox.gateway.util.MimeTypes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+import java.util.Set;
 
 public class NiFiHaDispatch extends DefaultHaDispatch {
 
@@ -65,7 +65,7 @@ public class NiFiHaDispatch extends DefaultHaDispatch {
     }
     for ( Header header : headers ) {
       String name = header.getName();
-      if (hasExcludeHeaders && excludeHeaders.contains(name.toUpperCase())) {
+      if (hasExcludeHeaders && excludeHeaders.contains(name.toUpperCase(Locale.ROOT))) {
         continue;
       }
       String value = header.getValue();

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
----------------------------------------------------------------------
diff --git a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java b/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
index 7df3a09..ac5de7a 100644
--- a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
+++ b/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
@@ -17,20 +17,19 @@
  */
 package org.apache.knox.gateway.dispatch;
 
-import java.io.IOException;
-
-import javax.security.auth.Subject;
-import javax.servlet.http.HttpServletRequest;
-
+import com.google.common.base.Objects;
+import com.google.common.base.Strings;
 import org.apache.commons.lang.StringUtils;
-import org.apache.knox.gateway.security.SubjectUtils;
 import org.apache.http.Header;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.client.methods.RequestBuilder;
+import org.apache.knox.gateway.security.SubjectUtils;
 import org.apache.log4j.Logger;
 
-import com.google.common.base.Objects;
-import com.google.common.base.Strings;
+import javax.security.auth.Subject;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.Locale;
 
 class NiFiRequestUtil {
 
@@ -63,7 +62,7 @@ class NiFiRequestUtil {
         if (index >= 0) {
           knoxRouteContext = inboundRequestPathInfo.substring(0, index);
         } else {
-          Logger.getLogger(NiFiHaDispatch.class.getName()).error(String.format("Unable to find index of %s in %s", outboundRequestUriPathNoTrailingSlash, inboundRequestPathInfo));
+          Logger.getLogger(NiFiHaDispatch.class.getName()).error(String.format(Locale.ROOT, "Unable to find index of %s in %s", outboundRequestUriPathNoTrailingSlash, inboundRequestPathInfo));
         }
         outboundRequest.setHeader(NiFiHeaders.X_FORWARDED_CONTEXT, xForwardedContextHeaderValue + knoxRouteContext);
       }
@@ -77,7 +76,7 @@ class NiFiRequestUtil {
     final Subject subject = SubjectUtils.getCurrentSubject();
     String effectivePrincipalName = SubjectUtils.getEffectivePrincipalName(subject);
     outboundRequest.setHeader(NiFiHeaders.X_PROXIED_ENTITIES_CHAIN, Objects.firstNonNull(inboundRequest.getHeader(NiFiHeaders.X_PROXIED_ENTITIES_CHAIN), "") +
-        String.format("<%s>", effectivePrincipalName.equalsIgnoreCase("anonymous") ? "" : effectivePrincipalName));
+        String.format(Locale.ROOT, "<%s>", effectivePrincipalName.equalsIgnoreCase("anonymous") ? "" : effectivePrincipalName));
 
     // Make sure headers named "Cookie" are removed from the request to NiFi, since NiFi does not use cookies.
     Header[] cookieHeaders = outboundRequest.getHeaders("Cookie");

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java
----------------------------------------------------------------------
diff --git a/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java b/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java
index c6dbf36..2a00ef4 100644
--- a/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java
+++ b/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java
@@ -26,6 +26,7 @@ import javax.security.auth.login.AppConfigurationEntry;
 import javax.security.auth.login.Configuration;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 /**
@@ -157,7 +158,7 @@ class RemoteConfigurationRegistryJAASConfig extends Configuration {
                 }
                 break;
             case Digest:
-                loginModuleName = digestLoginModules.get(registryType.toUpperCase());
+                loginModuleName = digestLoginModules.get(registryType.toUpperCase(Locale.ROOT));
         }
         return loginModuleName;
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryClientServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryClientServiceTest.java b/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryClientServiceTest.java
index 8a817a4..5828c1c 100644
--- a/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryClientServiceTest.java
+++ b/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryClientServiceTest.java
@@ -23,11 +23,10 @@ import org.apache.curator.retry.ExponentialBackoffRetry;
 import org.apache.curator.test.InstanceSpec;
 import org.apache.curator.test.TestingCluster;
 import org.apache.knox.gateway.config.GatewayConfig;
-import org.apache.knox.gateway.services.config.client.RemoteConfigurationRegistryClient.ChildEntryListener;
-import org.apache.knox.gateway.services.config.client.RemoteConfigurationRegistryClient;
-import org.apache.knox.gateway.services.config.client.RemoteConfigurationRegistryClientService;
 import org.apache.knox.gateway.service.config.remote.RemoteConfigurationRegistryClientServiceFactory;
 import org.apache.knox.gateway.service.config.remote.util.RemoteRegistryConfigTestUtils;
+import org.apache.knox.gateway.services.config.client.RemoteConfigurationRegistryClient;
+import org.apache.knox.gateway.services.config.client.RemoteConfigurationRegistryClientService;
 import org.apache.knox.gateway.services.security.AliasService;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.data.ACL;
@@ -38,6 +37,7 @@ import org.junit.Test;
 import javax.security.auth.login.AppConfigurationEntry;
 import javax.security.auth.login.Configuration;
 import java.io.File;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -380,7 +380,7 @@ public class RemoteConfigurationRegistryClientServiceTest {
             listenerLog.add("EXTERNAL: " + type.toString() + ":" + path);
             if (RemoteConfigurationRegistryClient.ChildEntryListener.Type.ADDED.equals(type)) {
                 try {
-                    c.addEntryListener(path, (cc, p, d) -> listenerLog.add("EXTERNAL: " + p + ":" + (d != null ? new String(d) : "null")));
+                    c.addEntryListener(path, (cc, p, d) -> listenerLog.add("EXTERNAL: " + p + ":" + (d != null ? new String(d, StandardCharsets.UTF_8) : "null")));
                 } catch (Exception e) {
                     e.printStackTrace();
                 }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSh.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSh.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSh.java
index c80581f..33446f2 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSh.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSh.java
@@ -37,8 +37,10 @@ import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.HashSet;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.TimeZone;
 
 /**
  *
@@ -261,11 +263,11 @@ public class KnoxSh {
   private void displayTokenDetails(Map<String, String> json) {
     System.out.println("Token Type: " + json.get("token_type"));
 
-    DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");
+    DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss", Locale.getDefault());
 
     long milliSeconds= Long.parseLong(json.get("expires_in"));
 
-    Calendar calendar = Calendar.getInstance();
+    Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
     calendar.setTimeInMillis(milliSeconds);
     System.out.println("Expires On: " + formatter.format(calendar.getTime()));
     String targetUrl = json.get("target_url");

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultDispatch.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultDispatch.java
index 8757192..d702809 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultDispatch.java
@@ -51,6 +51,7 @@ import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.HashSet;
+import java.util.Locale;
 import java.util.Set;
 
 /**
@@ -161,7 +162,7 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
     }
     for ( Header header : headers ) {
       String name = header.getName();
-      if (hasExcludeHeaders && excludeHeaders.contains(name.toUpperCase())) {
+      if (hasExcludeHeaders && excludeHeaders.contains(name.toUpperCase(Locale.ROOT))) {
         continue;
       }
       String value = header.getValue();

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
index f23ba55..13c7a69 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
@@ -17,12 +17,12 @@
  */
 package org.apache.knox.gateway.dispatch;
 
+import org.apache.http.client.HttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.knox.gateway.SpiGatewayMessages;
-import org.apache.knox.gateway.filter.AbstractGatewayFilter;
 import org.apache.knox.gateway.config.ConfigurationInjectorBuilder;
+import org.apache.knox.gateway.filter.AbstractGatewayFilter;
 import org.apache.knox.gateway.i18n.messages.MessagesFactory;
-import org.apache.http.client.HttpClient;
-import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.knox.gateway.util.RegExUtils;
 import org.apache.knox.gateway.util.WhitelistUtils;
 
@@ -37,6 +37,7 @@ import java.net.URISyntaxException;
 import java.net.URLDecoder;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 
 public class GatewayDispatchFilter extends AbstractGatewayFilter {
@@ -114,7 +115,7 @@ public class GatewayDispatchFilter 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);
     Adapter adapter = METHOD_ADAPTERS.get(method);
     if (adapter != null) {
       if (isDispatchAllowed(request)) {

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-spi/src/main/java/org/apache/knox/gateway/util/WhitelistUtils.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/util/WhitelistUtils.java b/gateway-spi/src/main/java/org/apache/knox/gateway/util/WhitelistUtils.java
index 7e58c0e..2aa6ce2 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/util/WhitelistUtils.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/util/WhitelistUtils.java
@@ -21,11 +21,10 @@ import org.apache.knox.gateway.config.GatewayConfig;
 import org.apache.knox.gateway.i18n.messages.MessagesFactory;
 
 import javax.servlet.http.HttpServletRequest;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import java.util.Locale;
 
 public class WhitelistUtils {
 
@@ -41,7 +40,7 @@ public class WhitelistUtils {
 
   private static final SpiGatewayMessages LOG = MessagesFactory.get(SpiGatewayMessages.class);
 
-  private static final List<String> DEFAULT_SERVICE_ROLES = Arrays.asList("KNOXSSO");
+  private static final List<String> DEFAULT_SERVICE_ROLES = Collections.singletonList("KNOXSSO");
 
 
   public static String getDispatchWhitelist(HttpServletRequest request) {
@@ -89,14 +88,14 @@ public class WhitelistUtils {
       if (!requestedHost.matches(LOCALHOST_REGEXP)) { // localhost will be handled subsequently
         // Use the requested host address/name for the whitelist
         LOG.unableToDetermineKnoxDomainForDefaultWhitelist(requestedHost);
-        defaultWhitelist = String.format(DEFAULT_DISPATCH_WHITELIST_TEMPLATE, requestedHost);
+        defaultWhitelist = String.format(Locale.ROOT, DEFAULT_DISPATCH_WHITELIST_TEMPLATE, requestedHost);
       }
     }
 
     // If the whitelist has not been determined at this point, default to just the local/relative whitelist
     if (defaultWhitelist == null) {
       LOG.unableToDetermineKnoxDomainForDefaultWhitelist("localhost");
-      defaultWhitelist = String.format(DEFAULT_DISPATCH_WHITELIST_TEMPLATE, LOCALHOST_REGEXP_SEGMENT);
+      defaultWhitelist = String.format(Locale.ROOT, DEFAULT_DISPATCH_WHITELIST_TEMPLATE, LOCALHOST_REGEXP_SEGMENT);
     }
 
     return defaultWhitelist;
@@ -127,7 +126,7 @@ public class WhitelistUtils {
 
     if (domain != null && !domain.isEmpty()) {
       String domainPattern = ".+" + domain.replaceAll("\\.", "\\\\.");
-      whitelist = String.format(DEFAULT_DISPATCH_WHITELIST_TEMPLATE, "(" + domainPattern + ")");
+      whitelist = String.format(Locale.ROOT, DEFAULT_DISPATCH_WHITELIST_TEMPLATE, "(" + domainPattern + ")");
     }
 
     return whitelist;

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/HadoopAuthCookieStoreTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/HadoopAuthCookieStoreTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/HadoopAuthCookieStoreTest.java
index b1685f3..0b57d69 100644
--- a/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/HadoopAuthCookieStoreTest.java
+++ b/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/HadoopAuthCookieStoreTest.java
@@ -17,18 +17,22 @@
  */
 package org.apache.knox.gateway.dispatch;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.List;
-
 import org.apache.http.cookie.Cookie;
 import org.apache.http.impl.cookie.BasicClientCookie;
 import org.apache.knox.gateway.config.GatewayConfig;
 import org.easymock.EasyMock;
 import org.junit.Test;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 
 public class HadoopAuthCookieStoreTest {
 
@@ -163,7 +167,7 @@ public class HadoopAuthCookieStoreTest {
     try {
       File f = File.createTempFile(filename, ".conf");
       FileOutputStream out = new FileOutputStream(f);
-      out.write(contents.getBytes());
+      out.write(contents.getBytes(StandardCharsets.UTF_8));
       out.flush();
       out.close();
       result = f;

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-spi/src/test/java/org/apache/knox/gateway/util/WhitelistUtilsTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/util/WhitelistUtilsTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/util/WhitelistUtilsTest.java
index 37d7d5c..01ee2b7 100644
--- a/gateway-spi/src/test/java/org/apache/knox/gateway/util/WhitelistUtilsTest.java
+++ b/gateway-spi/src/test/java/org/apache/knox/gateway/util/WhitelistUtilsTest.java
@@ -26,6 +26,7 @@ import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Locale;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -218,7 +219,7 @@ public class WhitelistUtilsTest {
   }
 
   private static boolean isLocalhostServerName(final String serverName) {
-    return LOCALHOST_NAMES.contains(serverName.toLowerCase());
+    return LOCALHOST_NAMES.contains(serverName.toLowerCase(Locale.ROOT));
   }
 
   private static GatewayConfig createMockGatewayConfig(final List<String> serviceRoles, final String whitelist) {

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureClusterTest.java
----------------------------------------------------------------------
diff --git a/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureClusterTest.java b/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureClusterTest.java
index 5395a82..b14c248 100644
--- a/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureClusterTest.java
+++ b/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureClusterTest.java
@@ -17,12 +17,6 @@
  */
 package org.apache.knox.gateway;
 
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.security.Principal;
-import java.util.Properties;
-
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
 import org.apache.hadoop.fs.Path;
@@ -33,8 +27,6 @@ import org.apache.hadoop.minikdc.MiniKdc;
 import org.apache.hadoop.security.SecurityUtil;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
-import org.apache.knox.test.TestUtils;
-import org.apache.knox.test.category.ReleaseTest;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.auth.AuthScope;
@@ -47,12 +39,24 @@ import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.util.EntityUtils;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.ReleaseTest;
 import org.apache.log4j.PropertyConfigurator;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+import java.security.Principal;
+import java.util.Locale;
+import java.util.Properties;
+
 import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_ENABLE_KEY;
 import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_CLIENT_HTTPS_KEYSTORE_RESOURCE_KEY;
 import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_HTTPS_ADDRESS_KEY;
@@ -254,8 +258,9 @@ public class SecureClusterTest {
       file.delete();
       file.createNewFile();
     }
-    FileWriter writer = new FileWriter(file);
-    String content = String.format("com.sun.security.jgss.initiate {\n" +
+    Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
+    String content = String.format(Locale.ROOT,
+        "com.sun.security.jgss.initiate {\n" +
         "com.sun.security.auth.module.Krb5LoginModule required\n" +
         "renewTGT=true\n" +
         "doNotPrompt=true\n" +

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-test-utils/src/main/java/org/apache/knox/test/TestUtils.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/TestUtils.java b/gateway-test-utils/src/main/java/org/apache/knox/test/TestUtils.java
index 8d8ce24..3470d8e 100644
--- a/gateway-test-utils/src/main/java/org/apache/knox/test/TestUtils.java
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/TestUtils.java
@@ -42,6 +42,7 @@ import java.net.Socket;
 import java.net.URL;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
+import java.util.Locale;
 import java.util.Properties;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
@@ -110,14 +111,14 @@ public class TestUtils {
   public static void LOG_ENTER() {
     StackTraceElement caller = Thread.currentThread().getStackTrace()[2];
     System.out.flush();
-    System.out.println( String.format( "Running %s#%s", caller.getClassName(), caller.getMethodName() ) );
+    System.out.println( String.format( Locale.ROOT, "Running %s#%s", caller.getClassName(), caller.getMethodName() ) );
     System.out.flush();
   }
 
   public static void LOG_EXIT() {
     StackTraceElement caller = Thread.currentThread().getStackTrace()[2];
     System.out.flush();
-    System.out.println( String.format( "Exiting %s#%s", caller.getClassName(), caller.getMethodName() ) );
+    System.out.println( String.format( Locale.ROOT, "Exiting %s#%s", caller.getClassName(), caller.getMethodName() ) );
     System.out.flush();
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
index f6536d9..c8e2f64 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
@@ -17,24 +17,8 @@
  */
 package org.apache.knox.gateway;
 
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.StringWriter;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import javax.ws.rs.core.MediaType;
-
+import com.mycila.xmltool.XMLDoc;
+import com.mycila.xmltool.XMLTag;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
 import io.restassured.http.Cookie;
@@ -42,15 +26,8 @@ import io.restassured.http.Header;
 import io.restassured.path.json.JsonPath;
 import io.restassured.response.Response;
 import io.restassured.specification.ResponseSpecification;
-import com.mycila.xmltool.XMLDoc;
-import com.mycila.xmltool.XMLTag;
 import org.apache.commons.io.filefilter.WildcardFileFilter;
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.knox.gateway.util.KnoxCLI;
-import org.apache.knox.test.TestUtils;
-import org.apache.knox.test.category.MediumTests;
-import org.apache.knox.test.category.VerifyTest;
-import org.apache.knox.test.mock.MockRequestMatcher;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
@@ -68,6 +45,11 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
+import org.apache.knox.gateway.util.KnoxCLI;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.MediumTests;
+import org.apache.knox.test.category.VerifyTest;
+import org.apache.knox.test.mock.MockRequestMatcher;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
@@ -86,10 +68,34 @@ import org.junit.experimental.categories.Category;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.core.MediaType;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.StringWriter;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+
 import static io.restassured.RestAssured.given;
 import static org.apache.knox.test.TestUtils.LOG_ENTER;
 import static org.apache.knox.test.TestUtils.LOG_EXIT;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.anyOf;
+import static org.hamcrest.CoreMatchers.either;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.text.IsEmptyString.isEmptyString;
@@ -2375,7 +2381,7 @@ public class GatewayBasicFuncTest {
     driver.getMock( "RESOURCEMANAGER" ).expect().method( "GET" )
         .pathInfo( path ).queryParam( "user.name", username ).respond()
         .status( HttpStatus.SC_OK )
-        .content( request.getBytes() )
+        .content( request.getBytes(StandardCharsets.UTF_8) )
         .contentType( contentType.toString() );
 
     ResponseSpecification response = given()
@@ -2628,7 +2634,7 @@ public class GatewayBasicFuncTest {
         .pathInfo( path )
         .queryParam( "user.name", username ).respond()
         .status( HttpStatus.SC_OK )
-        .content( request.getBytes() )
+        .content( request.getBytes(StandardCharsets.UTF_8) )
         .contentType( ContentType.JSON.toString() );
 
     String encryptedTrackingUrl = given()
@@ -3655,16 +3661,16 @@ public class GatewayBasicFuncTest {
     PrintStream out = System.out;
     InetSocketAddress gatewayAddress = driver.gateway.getAddresses()[0];
     final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
-    System.setOut(new PrintStream(outContent));
+    System.setOut(new PrintStream(outContent, false, "UTF-8"));
 
     String args[] = {"service-test", "--master", "knox", "--cluster", driver.clusterName, "--hostname", gatewayAddress.getHostName(),
         "--port", Integer.toString(gatewayAddress.getPort()), "--u", "kminder","--p", "kminder-password" };
     KnoxCLI cli = new KnoxCLI();
     cli.run(args);
 
-    assertThat(outContent.toString(), not(containsString("\"httpCode\": 401")));
-    assertThat( outContent.toString(), not(containsString("404")));
-    assertThat(outContent.toString(), not(containsString("403")));
+    assertThat(outContent.toString("UTF-8"), not(containsString("\"httpCode\": 401")));
+    assertThat( outContent.toString("UTF-8"), not(containsString("404")));
+    assertThat(outContent.toString("UTF-8"), not(containsString("403")));
     outContent.reset();
 
     setupResources();
@@ -3675,7 +3681,7 @@ public class GatewayBasicFuncTest {
 
     cli = new KnoxCLI();
     cli.run(args2);
-    assertThat(outContent.toString(), (containsString("Username and/or password not supplied. Expect HTTP 401 Unauthorized responses.")));
+    assertThat(outContent.toString("UTF-8"), (containsString("Username and/or password not supplied. Expect HTTP 401 Unauthorized responses.")));
     outContent.reset();
 
 
@@ -3684,7 +3690,7 @@ public class GatewayBasicFuncTest {
 
     cli = new KnoxCLI();
     cli.run(args3);
-    assertThat(outContent.toString().toLowerCase(),
+    assertThat(outContent.toString("UTF-8").toLowerCase(Locale.ROOT),
         either(containsString("nodename nor servname provided")).or(containsString("name or service not known"))
             .or(containsString("//bad-host:0/")));
     outContent.reset();
@@ -3694,7 +3700,7 @@ public class GatewayBasicFuncTest {
 
     cli = new KnoxCLI();
     cli.run(args4);
-    assertThat(outContent.toString(), containsString("failed: Connection refused"));
+    assertThat(outContent.toString("UTF-8"), containsString("failed: Connection refused"));
     outContent.reset();
 
 
@@ -3703,7 +3709,7 @@ public class GatewayBasicFuncTest {
 
     cli = new KnoxCLI();
     cli.run(args5);
-    assertThat(outContent.toString(), containsString("--cluster argument is required"));
+    assertThat(outContent.toString("UTF-8"), containsString("--cluster argument is required"));
     outContent.reset();
 
 //    Reset the out content
@@ -3777,7 +3783,7 @@ public class GatewayBasicFuncTest {
         .status(HttpStatus.SC_OK)
         .contentType("application/json")
         .characterEncoding("utf-8");
-//            .content(driver.getResourceBytes(classLoaderResource + "." + type.toString().toLowerCase()))
+//            .content(driver.getResourceBytes(classLoaderResource + "." + type.toString().toLowerCase(Locale.ROOT)))
 //            .contentType(type.toString());
   }
 
@@ -4125,7 +4131,7 @@ public class GatewayBasicFuncTest {
         .respond()
         .status( HttpStatus.SC_OK )
         .contentType( "application/json" )
-        .content( "{\"boolean\": true}".getBytes() );
+        .content( "{\"boolean\": true}".getBytes(StandardCharsets.UTF_8) );
     Response response = given()
         //.log().all()
         .auth().preemptive().basic( user, password )
@@ -4163,7 +4169,7 @@ public class GatewayBasicFuncTest {
         .respond()
         .status( status )
         .contentType( "application/json" )
-        .content( "{\"id\":\"job_201210301335_0086\"}".getBytes() );
+        .content( "{\"id\":\"job_201210301335_0086\"}".getBytes(StandardCharsets.UTF_8) );
     String json = given()
         //.log().all()
         .auth().preemptive().basic( user, password )
@@ -4191,7 +4197,7 @@ public class GatewayBasicFuncTest {
         .respond()
         .status( status[0] )
         .contentType( "application/json" )
-        .content( "{\"id\":\"job_201210301335_0086\"}".getBytes() );
+        .content( "{\"id\":\"job_201210301335_0086\"}".getBytes(StandardCharsets.UTF_8) );
     String json = given()
         //.log().all()
         .auth().preemptive().basic( user, password )
@@ -4225,7 +4231,7 @@ public class GatewayBasicFuncTest {
         .respond()
         .status( status[ 0 ] )
         .contentType( "application/json" )
-        .content( "{\"id\":\"job_201210301335_0086\"}".getBytes() );
+        .content( "{\"id\":\"job_201210301335_0086\"}".getBytes(StandardCharsets.UTF_8) );
     String json = given()
         //.log().all()
         .auth().preemptive().basic( user, password )

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-test/src/test/java/org/apache/knox/gateway/GatewayMultiFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayMultiFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayMultiFuncTest.java
index e14f44a..5529343 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayMultiFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayMultiFuncTest.java
@@ -17,25 +17,9 @@
  */
 package org.apache.knox.gateway;
 
-import java.io.File;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.UUID;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.directory.server.protocol.shared.transport.TcpTransport;
-import org.apache.knox.gateway.services.DefaultGatewayServices;
-import org.apache.knox.gateway.services.GatewayServices;
-import org.apache.knox.gateway.services.ServiceLifecycleException;
-import org.apache.knox.gateway.services.topology.TopologyService;
-import org.apache.knox.test.TestUtils;
-import org.apache.knox.test.category.ReleaseTest;
-import org.apache.knox.test.mock.MockServer;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpStatus;
 import org.apache.http.auth.AuthScope;
@@ -50,6 +34,13 @@ import org.apache.http.impl.client.BasicAuthCache;
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
+import org.apache.knox.gateway.services.DefaultGatewayServices;
+import org.apache.knox.gateway.services.GatewayServices;
+import org.apache.knox.gateway.services.ServiceLifecycleException;
+import org.apache.knox.gateway.services.topology.TopologyService;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.ReleaseTest;
+import org.apache.knox.test.mock.MockServer;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
 import org.junit.AfterClass;
@@ -59,6 +50,15 @@ import org.junit.experimental.categories.Category;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.UUID;
+
 import static io.restassured.RestAssured.given;
 import static org.apache.knox.test.TestUtils.LOG_ENTER;
 import static org.apache.knox.test.TestUtils.LOG_EXIT;
@@ -178,7 +178,7 @@ public class GatewayMultiFuncTest {
     String pword = uname + "-password";
 
     mock.expect().method( "GET" )
-        .respond().contentType( "application/json" ).contentLength( -1 ).content( "{\"msg\":\"H\u00eallo\"}", Charset.forName( "UTF-8" ) );
+        .respond().contentType( "application/json" ).contentLength( -1 ).content( "{\"msg\":\"H\u00eallo\"}", StandardCharsets.UTF_8 );
     String json = given()
         //.log().all()
         .auth().preemptive().basic( uname, pword )
@@ -191,7 +191,7 @@ public class GatewayMultiFuncTest {
     assertThat( mock.isEmpty(), is(true) );
 
     mock.expect().method( "GET" )
-        .respond().contentType( "application/octet-stream" ).contentLength( -1 ).content( "H\u00eallo".getBytes() );
+        .respond().contentType( "application/octet-stream" ).contentLength( -1 ).content( "H\u00eallo".getBytes(StandardCharsets.UTF_8) );
     byte[] bytes = given()
         //.log().all()
         .auth().preemptive().basic( uname, pword )
@@ -200,7 +200,7 @@ public class GatewayMultiFuncTest {
         .statusCode( HttpStatus.SC_OK )
         .contentType( "application/octet-stream" )
         .when().get( gatewayUrl + "/knox678/repeat" ).andReturn().asByteArray();
-    assertThat( bytes, is(equalTo("H\u00eallo".getBytes())) );
+    assertThat( bytes, is(equalTo("H\u00eallo".getBytes(StandardCharsets.UTF_8))) );
     assertThat( mock.isEmpty(), is(true) );
 
     mock.stop();
@@ -230,7 +230,7 @@ public class GatewayMultiFuncTest {
         .pathInfo( "/repeat-context/" )
         .respond()
         .status( HttpStatus.SC_CREATED )
-        .content( "{\"name\":\"value\"}".getBytes() )
+        .content( "{\"name\":\"value\"}".getBytes(StandardCharsets.UTF_8) )
         .contentLength( -1 )
         .contentType( "application/json; charset=UTF-8" )
         .header( "Location", gatewayUrl + "/knox681/repeat" );
@@ -260,7 +260,7 @@ public class GatewayMultiFuncTest {
     assertThat( response.getStatusLine().getStatusCode(), is( HttpStatus.SC_CREATED ) );
     assertThat( response.getFirstHeader( "Location" ).getValue(), endsWith("/gateway/knox681/repeat" ) );
     assertThat( response.getFirstHeader( "Content-Type" ).getValue(), is("application/json; charset=UTF-8") );
-    String body = new String( IOUtils.toByteArray( response.getEntity().getContent() ), Charset.forName( "UTF-8" ) );
+    String body = new String( IOUtils.toByteArray( response.getEntity().getContent() ), StandardCharsets.UTF_8 );
     assertThat( body, is( "{\"name\":\"value\"}" ) );
     response.close();
     client.close();
@@ -271,7 +271,7 @@ public class GatewayMultiFuncTest {
         .pathInfo( "/repeat-context/" )
         .respond()
         .status( HttpStatus.SC_CREATED )
-        .content( "<test-xml/>".getBytes() )
+        .content( "<test-xml/>".getBytes(StandardCharsets.UTF_8) )
         .contentType( "application/xml; charset=UTF-8" )
         .header( "Location", gatewayUrl + "/knox681/repeat" );
 
@@ -283,7 +283,7 @@ public class GatewayMultiFuncTest {
     assertThat( response.getStatusLine().getStatusCode(), is( HttpStatus.SC_CREATED ) );
     assertThat( response.getFirstHeader( "Location" ).getValue(), endsWith("/gateway/knox681/repeat" ) );
     assertThat( response.getFirstHeader( "Content-Type" ).getValue(), is("application/xml; charset=UTF-8") );
-    body = new String( IOUtils.toByteArray( response.getEntity().getContent() ), Charset.forName( "UTF-8" ) );
+    body = new String( IOUtils.toByteArray( response.getEntity().getContent() ), StandardCharsets.UTF_8 );
     assertThat( the(body), hasXPath( "/test-xml" ) );
     response.close();
     client.close();

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
index e59f3a0..6ee33d0 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
@@ -25,14 +25,14 @@ import org.apache.knox.gateway.util.KnoxCLI;
 import org.apache.knox.test.TestUtils;
 import org.apache.knox.test.log.NoOpAppender;
 import org.apache.log4j.Appender;
-import org.junit.BeforeClass;
 import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
-import java.io.PrintStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -60,8 +60,8 @@ public class KnoxCliLdapFuncTestNegative {
   @BeforeClass
   public static void setupSuite() throws Exception {
     LOG_ENTER();
-    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"));
     driver.setupLdap(0);
     setupGateway();
     LOG_EXIT();
@@ -248,10 +248,10 @@ public class KnoxCliLdapFuncTestNegative {
         "--u", username, "--p", password, "--g" };
     cli.run( args1 );
 
-    assertThat(outContent.toString(), containsString("LDAP authentication successful"));
-    assertThat(outContent.toString(), containsString("Your topology file may be incorrectly configured for group lookup"));
-    assertThat(outContent.toString(), containsString("Warn: "));
-    assertFalse(outContent.toString().contains("analyst"));
+    assertThat(outContent.toString("UTF-8"), containsString("LDAP authentication successful"));
+    assertThat(outContent.toString("UTF-8"), containsString("Your topology file may be incorrectly configured for group lookup"));
+    assertThat(outContent.toString("UTF-8"), containsString("Warn: "));
+    assertFalse(outContent.toString("UTF-8").contains("analyst"));
 
 
     outContent.reset();
@@ -269,8 +269,8 @@ public class KnoxCliLdapFuncTestNegative {
       NoOpAppender.tearDown( before );
     }
 
-    assertThat(outContent.toString(), containsString("LDAP authentication failed"));
-    assertThat(outContent.toString(), containsString("INVALID_CREDENTIALS"));
+    assertThat(outContent.toString("UTF-8"), containsString("LDAP authentication failed"));
+    assertThat(outContent.toString("UTF-8"), containsString("INVALID_CREDENTIALS"));
 
     outContent.reset();
     username = "sam";
@@ -282,11 +282,11 @@ public class KnoxCliLdapFuncTestNegative {
         "--u", username, "--p", password, "--g" };
     cli.run( args3 );
 
-    assertThat(outContent.toString(), containsString("LDAP authentication successful"));
-    assertThat(outContent.toString(), containsString("Your topology file may be incorrectly configured for group lookup"));
-    assertThat(outContent.toString(), containsString("Warn:"));
-    assertFalse(outContent.toString().contains("analyst"));
-    assertFalse(outContent.toString().contains("scientist"));
+    assertThat(outContent.toString("UTF-8"), containsString("LDAP authentication successful"));
+    assertThat(outContent.toString("UTF-8"), containsString("Your topology file may be incorrectly configured for group lookup"));
+    assertThat(outContent.toString("UTF-8"), containsString("Warn:"));
+    assertFalse(outContent.toString("UTF-8").contains("analyst"));
+    assertFalse(outContent.toString("UTF-8").contains("scientist"));
 
     LOG_EXIT();
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
index 12a7c15..da86723 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
@@ -25,14 +25,14 @@ import org.apache.knox.gateway.util.KnoxCLI;
 import org.apache.knox.test.TestUtils;
 import org.apache.knox.test.log.NoOpAppender;
 import org.apache.log4j.Appender;
-import org.junit.BeforeClass;
 import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
-import java.io.PrintStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -60,8 +60,8 @@ public class KnoxCliLdapFuncTestPositive {
   @BeforeClass
   public static void setupSuite() throws Exception {
     LOG_ENTER();
-    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"));
     driver.setupLdap(0);
     setupGateway();
     LOG_EXIT();
@@ -236,9 +236,9 @@ public class KnoxCliLdapFuncTestPositive {
     KnoxCLI cli = new KnoxCLI();
     cli.setConf(config);
     cli.run(args);
-    assertThat(outContent.toString(), containsString("success"));
-    assertThat(outContent.toString(), containsString("analyst"));
-    assertThat(outContent.toString(), containsString("scientist"));
+    assertThat(outContent.toString("UTF-8"), containsString("success"));
+    assertThat(outContent.toString("UTF-8"), containsString("analyst"));
+    assertThat(outContent.toString("UTF-8"), containsString("scientist"));
 
 //    Test 2: Give an invalid name and password combinatinon.
     outContent.reset();
@@ -253,7 +253,7 @@ public class KnoxCliLdapFuncTestPositive {
     } finally {
       NoOpAppender.tearDown( before );
     }
-    assertThat(outContent.toString(), containsString("LDAP authentication failed"));
+    assertThat(outContent.toString("UTF-8"), containsString("LDAP authentication failed"));
 
 //    Test 3: Authenticate a user who belongs to no groups, but specify groups with --g
     outContent.reset();
@@ -264,8 +264,8 @@ public class KnoxCliLdapFuncTestPositive {
     String args3[] = {"user-auth-test", "--master", "knox", "--cluster", "test-cluster",
         "--u", username, "--p", password, "--g" };
     cli.run(args3);
-    assertThat(outContent.toString(), containsString("LDAP authentication success"));
-    assertThat(outContent.toString(), containsString("does not belong to any groups"));
+    assertThat(outContent.toString("UTF-8"), containsString("LDAP authentication success"));
+    assertThat(outContent.toString("UTF-8"), containsString("does not belong to any groups"));
 
     //    Test 4: Pass a non-existent topology
     outContent.reset();
@@ -276,7 +276,7 @@ public class KnoxCliLdapFuncTestPositive {
     String args4[] = {"user-auth-test", "--master", "knox", "--cluster", "cluster-dne",
         "--u", username, "--p", password };
     cli.run(args4);
-    assertThat(outContent.toString(), containsString("Topology cluster-dne does not exist"));
+    assertThat(outContent.toString("UTF-8"), containsString("Topology cluster-dne does not exist"));
 
 
     //    Test 5: Authenticate a user who belongs to no groups, but specify groups with --g
@@ -288,8 +288,8 @@ public class KnoxCliLdapFuncTestPositive {
     String args5[] = {"user-auth-test", "--master", "knox", "--cluster", "test-cluster",
         "--u", username, "--p", password };
     cli.run( args5 );
-    assertThat(outContent.toString(), containsString("LDAP authentication success"));
-    assertThat(outContent.toString(), not(containsString("does not belong to any groups")));
+    assertThat(outContent.toString("UTF-8"), containsString("LDAP authentication success"));
+    assertThat(outContent.toString("UTF-8"), not(containsString("does not belong to any groups")));
 
     LOG_EXIT();
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
index d8b6496..7fa115a 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
@@ -30,9 +30,9 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.PrintStream;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -59,8 +59,8 @@ public class KnoxCliSysBindTest {
   @BeforeClass
   public static void setupSuite() throws Exception {
     LOG_ENTER();
-    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"));
     driver.setupLdap(0);
     setupGateway();
     LOG_EXIT();
@@ -237,7 +237,7 @@ public class KnoxCliSysBindTest {
     KnoxCLI cli = new KnoxCLI();
     cli.setConf(config);
     cli.run(args);
-    assertThat(outContent.toString(), containsString("System LDAP Bind successful"));
+    assertThat(outContent.toString("UTF-8"), containsString("System LDAP Bind successful"));
 
     //    Test 2: Make sure authentication fails
     outContent.reset();
@@ -245,7 +245,7 @@ public class KnoxCliSysBindTest {
     cli = new KnoxCLI();
     cli.setConf(config);
     cli.run(args2);
-    assertThat(outContent.toString(), containsString("System LDAP Bind successful"));
+    assertThat(outContent.toString("UTF-8"), containsString("System LDAP Bind successful"));
 
 
     //    Test 3: Make sure authentication is successful
@@ -259,8 +259,8 @@ public class KnoxCliSysBindTest {
     } finally {
       NoOpAppender.tearDown( before );
     }
-    assertThat(outContent.toString(), containsString("LDAP authentication failed"));
-    assertThat(outContent.toString(), containsString("Unable to successfully bind to LDAP server with topology credentials"));
+    assertThat(outContent.toString("UTF-8"), containsString("LDAP authentication failed"));
+    assertThat(outContent.toString("UTF-8"), containsString("Unable to successfully bind to LDAP server with topology credentials"));
 
     //    Test 4: Assert that we get a username/password not present error is printed
     outContent.reset();
@@ -268,8 +268,8 @@ public class KnoxCliSysBindTest {
     cli = new KnoxCLI();
     cli.setConf(config);
     cli.run(args4);
-    assertThat(outContent.toString(), containsString("Warn: main.ldapRealm.contextFactory.systemUsername is not present"));
-    assertThat(outContent.toString(), containsString("Warn: main.ldapRealm.contextFactory.systemPassword is not present"));
+    assertThat(outContent.toString("UTF-8"), containsString("Warn: main.ldapRealm.contextFactory.systemUsername is not present"));
+    assertThat(outContent.toString("UTF-8"), containsString("Warn: main.ldapRealm.contextFactory.systemPassword is not present"));
 
 
     //    Test 5: Assert that we get a username/password not present error is printed
@@ -278,7 +278,7 @@ public class KnoxCliSysBindTest {
     cli = new KnoxCLI();
     cli.setConf(config);
     cli.run(args5);
-    assertThat(outContent.toString(), containsString("Topology not-a-cluster does not exist"));
+    assertThat(outContent.toString("UTF-8"), containsString("Topology not-a-cluster does not exist"));
 
     LOG_EXIT();
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java
index cb2bcdf..fc8823d 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java
@@ -40,7 +40,10 @@ import org.junit.BeforeClass;
 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.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -133,7 +136,7 @@ public class RemoteConfigurationMonitorTest {
      */
     private static File setupDigestSaslConfig(String username, String password) throws Exception {
         File saslConfigFile = new File(testTmp, "server-jaas.conf");
-        FileWriter fw = new FileWriter(saslConfigFile);
+        Writer fw = new OutputStreamWriter(new FileOutputStream(saslConfigFile), StandardCharsets.UTF_8);
         fw.write("Server {\n" +
                 "    org.apache.zookeeper.server.auth.DigestLoginModule required\n" +
                 "    user_" + username + " =\"" + password + "\";\n" +
@@ -502,17 +505,17 @@ public class RemoteConfigurationMonitorTest {
             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));
@@ -532,22 +535,22 @@ public class RemoteConfigurationMonitorTest {
             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-util-common/src/main/java/org/apache/knox/gateway/util/MimeTypes.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/MimeTypes.java b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/MimeTypes.java
index 9bf26cb..62c0d09 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/MimeTypes.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/MimeTypes.java
@@ -17,10 +17,11 @@
  */
 package org.apache.knox.gateway.util;
 
-import java.util.HashMap;
-import java.util.Map;
 import javax.activation.MimeType;
 import javax.activation.MimeTypeParseException;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
 
 public class MimeTypes {
 
@@ -70,7 +71,7 @@ public class MimeTypes {
   public static String getDefaultCharsetForMimeType( final String mimeType ) {
     String charset = null;
     if( mimeType != null ) {
-      charset = DEFAULT_CHARSETS.get( mimeType.trim().toLowerCase() );
+      charset = DEFAULT_CHARSETS.get( mimeType.trim().toLowerCase(Locale.ROOT) );
     }
     return charset;
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/AuditLayoutTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/AuditLayoutTest.java b/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/AuditLayoutTest.java
index 6400f1b..5e27694 100644
--- a/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/AuditLayoutTest.java
+++ b/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/AuditLayoutTest.java
@@ -37,6 +37,7 @@ import org.junit.Test;
 import java.io.File;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Locale;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -110,10 +111,10 @@ public class AuditLayoutTest {
     
     assertThat( CollectAppender.queue.size(), is( 1 ) );
     LoggingEvent event = CollectAppender.queue.iterator().next();
-    SimpleDateFormat format = new SimpleDateFormat( "yy/MM/dd HH:mm:ss" );
+    SimpleDateFormat format = new SimpleDateFormat( "yy/MM/dd HH:mm:ss", Locale.getDefault() );
     String formatedDate = format.format( new Date( event.getTimeStamp() ) );
     //14/01/24 12:40:24 1|2|3|audit.forward|hostaddress|WEBHDFS|username|proxy_username|system_username|action|resource_type|resource_name|outcome|message
-    String expectedOutput = String.format(
+    String expectedOutput = String.format(Locale.ROOT,
         RECORD_PATTERN, formatedDate,
         ROOT_REQUEST_ID, PARENT_REQUEST_ID, REQUEST_ID, "audit.forward",
         HOST_ADDRESS, TARGET_SERVICE, USERNAME, PROXYUSERNAME, SYSTEMUSERNAME, ACTION,
@@ -128,10 +129,11 @@ public class AuditLayoutTest {
     auditor.audit( ACTION, RESOURCE_NAME, RESOURCE_TYPE, OUTCOME, MESSAGE );
     assertThat( CollectAppender.queue.size(), is( 1 ) );
     LoggingEvent event = CollectAppender.queue.iterator().next();
-    SimpleDateFormat format = new SimpleDateFormat( "yy/MM/dd HH:mm:ss" );
+    SimpleDateFormat format = new SimpleDateFormat( "yy/MM/dd HH:mm:ss", Locale.getDefault() );
     String formatedDate = format.format( new Date( event.getTimeStamp() ) );
     //14/01/24 12:41:47 |||audit.forward|||||action|resource_type|resource_name|outcome|message
-    String expectedOutput = String.format( RECORD_PATTERN, formatedDate,
+    String expectedOutput = String.format( Locale.ROOT,
+        RECORD_PATTERN, formatedDate,
         EMPTY, EMPTY, EMPTY, "audit.forward",
         EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, ACTION, RESOURCE_TYPE, RESOURCE_NAME, OUTCOME, MESSAGE, AuditLayout.LINE_SEP );
     String auditOutput = layout.format( event );
@@ -144,10 +146,11 @@ public class AuditLayoutTest {
     auditor.audit( ACTION, RESOURCE_NAME, RESOURCE_TYPE, OUTCOME );
     assertThat( CollectAppender.queue.size(), is( 1 ) );
     LoggingEvent event = CollectAppender.queue.iterator().next();
-    SimpleDateFormat format = new SimpleDateFormat( "yy/MM/dd HH:mm:ss" );
+    SimpleDateFormat format = new SimpleDateFormat( "yy/MM/dd HH:mm:ss", Locale.getDefault() );
     String formatedDate = format.format( new Date( event.getTimeStamp() ) );
     //14/01/24 12:41:47 |||audit.forward|||||action|resource_type|resource_name|outcome|
-    String expectedOutput = String.format( RECORD_PATTERN, formatedDate,
+    String expectedOutput = String.format( Locale.ROOT,
+        RECORD_PATTERN, formatedDate,
         EMPTY, EMPTY, EMPTY, "audit.forward",
         EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, ACTION, RESOURCE_TYPE, RESOURCE_NAME, OUTCOME, EMPTY, AuditLayout.LINE_SEP );
     String auditOutput = layout.format( event );

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/JdbmQueueTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/JdbmQueueTest.java b/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/JdbmQueueTest.java
index 04f0860..30afe4d 100644
--- a/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/JdbmQueueTest.java
+++ b/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/JdbmQueueTest.java
@@ -27,7 +27,9 @@ import org.junit.Test;
 import java.io.File;
 import java.io.IOException;
 import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
 import java.util.HashSet;
+import java.util.Locale;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -281,7 +283,8 @@ public class JdbmQueueTest {
     if(size <= 0) return "0";
     final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" };
     int digitGroups = (int) (Math.log10(size)/Math.log10(1024));
-    return new DecimalFormat("#,##0.#").format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
+    return new DecimalFormat("#,##0.#", DecimalFormatSymbols.getInstance(Locale.getDefault()))
+        .format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
   }
 
   public static String createFillString( int size ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/ConfigurationInjectorBuilder.java
----------------------------------------------------------------------
diff --git a/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/ConfigurationInjectorBuilder.java b/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/ConfigurationInjectorBuilder.java
index 999c2b4..21672a1 100755
--- a/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/ConfigurationInjectorBuilder.java
+++ b/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/ConfigurationInjectorBuilder.java
@@ -23,6 +23,7 @@ import org.apache.knox.gateway.config.impl.MappedConfigurationBinding;
 import org.apache.knox.gateway.config.spi.ConfigurationInjector;
 
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.ServiceLoader;
 
 public class ConfigurationInjectorBuilder {
@@ -50,7 +51,7 @@ public class ConfigurationInjectorBuilder {
       }
     }
     if( injector == null ) {
-      throw new ConfigurationException( String.format(
+      throw new ConfigurationException( String.format(Locale.ROOT,
           "Failed to load an implementation of %s", ConfigurationInjector.class.getName() ) );
     }
     return injector;

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/impl/BeanConfigurationAdapter.java
----------------------------------------------------------------------
diff --git a/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/impl/BeanConfigurationAdapter.java b/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/impl/BeanConfigurationAdapter.java
index 27dc9f3..5a6227c 100755
--- a/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/impl/BeanConfigurationAdapter.java
+++ b/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/impl/BeanConfigurationAdapter.java
@@ -34,7 +34,7 @@ public class BeanConfigurationAdapter implements ConfigurationAdapter {
     try {
       return PropertyUtils.getSimpleProperty( bean, name );
     } catch( Exception e ) {
-      throw new ConfigurationException( String.format( "" ), e );
+      throw new ConfigurationException("", e );
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/impl/DefaultConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/impl/DefaultConfigurationInjector.java b/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/impl/DefaultConfigurationInjector.java
index f211e28..9fc61a3 100755
--- a/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/impl/DefaultConfigurationInjector.java
+++ b/gateway-util-configinjector/src/main/java/org/apache/knox/gateway/config/impl/DefaultConfigurationInjector.java
@@ -30,6 +30,7 @@ import org.apache.knox.gateway.config.spi.ConfigurationInjector;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.util.Locale;
 
 public class DefaultConfigurationInjector implements ConfigurationInjector {
 
@@ -68,7 +69,7 @@ public class DefaultConfigurationInjector implements ConfigurationInjector {
       if( value == null ) {
         Optional optional = field.getAnnotation( Optional.class );
         if( optional == null ) {
-          throw new ConfigurationException( String.format(
+          throw new ConfigurationException( String.format( Locale.ROOT, 
               "Failed to find configuration for %s bound to %s of %s via %s",
               bind, name, target.getClass().getName(), adapter.getClass().getName() ) );
         }
@@ -79,7 +80,7 @@ public class DefaultConfigurationInjector implements ConfigurationInjector {
           }
           field.set( target, value );
         } catch( Exception e ) {
-          throw new ConfigurationException( String.format(
+          throw new ConfigurationException( String.format( Locale.ROOT,
               "Failed to inject field configuration property %s of %s",
               name, target.getClass().getName() ), e );
         }
@@ -106,7 +107,7 @@ public class DefaultConfigurationInjector implements ConfigurationInjector {
             String strValue = defTag.value();
             argValue = convertValue( target, argName, strValue, argTypes[i] );
           } else {
-            throw new ConfigurationException( String.format(
+            throw new ConfigurationException( String.format( Locale.ROOT, 
                 "Failed to find configuration for %s as %s of %s via %s",
                 bndName, argName, target.getClass().getName(), adapter.getClass().getName() ) );
           }
@@ -119,7 +120,7 @@ public class DefaultConfigurationInjector implements ConfigurationInjector {
       try {
         method.invoke( target, args );
       } catch( Exception e ) {
-        throw new ConfigurationException( String.format(
+        throw new ConfigurationException( String.format( Locale.ROOT,
             "Failed to inject method configuration via %s of %s",
             methodName, target.getClass().getName() ), e );
       }
@@ -131,7 +132,7 @@ public class DefaultConfigurationInjector implements ConfigurationInjector {
     try {
       objValue = DEFAULT_CONVERTER.convert( strValue, type );
     } catch( Exception e ) {
-      throw new ConfigurationException( String.format(
+      throw new ConfigurationException( String.format( Locale.ROOT,
           "Failed to convert configuration for %s of %s to %s",
           name, target.getClass().getName(), type.getName() ), e );
     }
@@ -143,7 +144,7 @@ public class DefaultConfigurationInjector implements ConfigurationInjector {
     try {
       value = adapter.getConfigurationValue( bind );
     } catch( Exception e ) {
-      throw new ConfigurationException( String.format(
+      throw new ConfigurationException( String.format( Locale.ROOT,
           "Failed to retrieve configuration for %s bound to %s of %s via %s",
           bind, name, target.getClass().getName(), adapter.getClass().getName() ), e );
     }
@@ -181,7 +182,7 @@ public class DefaultConfigurationInjector implements ConfigurationInjector {
     try {
       bind = binding.getConfigurationName( name );
     } catch( Exception e ) {
-      throw new ConfigurationException( String.format(
+      throw new ConfigurationException( String.format( Locale.ROOT,
           "Failed to bind configuration for %s of %s via %s",
           name, target.getClass().getName(), binding.getClass().getName() ), e );
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/159bb800/gateway-util-configinjector/src/test/java/org/apache/knox/gateway/config/AdapterSampleTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-configinjector/src/test/java/org/apache/knox/gateway/config/AdapterSampleTest.java b/gateway-util-configinjector/src/test/java/org/apache/knox/gateway/config/AdapterSampleTest.java
index a97ccb8..9b5b835 100755
--- a/gateway-util-configinjector/src/test/java/org/apache/knox/gateway/config/AdapterSampleTest.java
+++ b/gateway-util-configinjector/src/test/java/org/apache/knox/gateway/config/AdapterSampleTest.java
@@ -19,6 +19,7 @@ package org.apache.knox.gateway.config;
 
 import org.junit.Test;
 
+import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -39,7 +40,7 @@ public class AdapterSampleTest {
     }
     @Override
     public Object getConfigurationValue( String name ) throws ConfigurationException {
-      Object value = config.get( name.toUpperCase() );
+      Object value = config.get( name.toUpperCase(Locale.ROOT) );
       return value == null ? null : value.toString();
     }
   }


Mime
View raw message