knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [4/5] knox git commit: KNOX-1676 - Enable PMD for tests
Date Thu, 13 Dec 2018 16:40:50 GMT
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
index 6c7e8ff..93015ad 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
@@ -72,7 +72,7 @@ public class UrlRewriteServletFilterTest {
     return ClassLoader.getSystemResource( name );
   }
 
-  public void setUp( Map<String,String> initParams ) throws Exception {
+  private void testSetUp(Map<String,String> initParams ) throws Exception {
     String descriptorUrl = getTestResource( "rewrite.xml" ).toExternalForm();
 
     server = new ServletTester();
@@ -112,7 +112,7 @@ public class UrlRewriteServletFilterTest {
 
   @Test
   public void testInboundRequestUrlRewrite() throws Exception {
-    setUp( null );
+    testSetUp( null );
     // Setup the server side request/response interaction.
     interaction.expect()
         .method( "GET" )
@@ -134,7 +134,7 @@ public class UrlRewriteServletFilterTest {
 
   @Test
   public void testInboundHeaderRewrite() throws Exception {
-    setUp( null );
+    testSetUp( null );
     // Setup the server side request/response interaction.
     interaction.expect()
         .method( "GET" )
@@ -158,7 +158,7 @@ public class UrlRewriteServletFilterTest {
 
   @Test
   public void testOutboundHeaderRewrite() throws Exception {
-    setUp( null );
+    testSetUp( null );
     // Setup the server side request/response interaction.
     interaction.expect()
         .method( "GET" )
@@ -236,7 +236,7 @@ public class UrlRewriteServletFilterTest {
 
   @Test
   public void testInboundJsonBodyRewrite() throws Exception {
-    setUp( null );
+    testSetUp( null );
 
     String inputJson = "{\"url\":\"http://mock-host:1/test-input-path\"}";
     String outputJson = "{\"url\":\"http://mock-host:1/test-output-path-1\"}";
@@ -265,7 +265,7 @@ public class UrlRewriteServletFilterTest {
 
   @Test
   public void testInboundXmlBodyRewrite() throws Exception {
-    setUp( null );
+    testSetUp( null );
     String input = "<root attribute=\"http://mock-host:1/test-input-path\">http://mock-host:1/test-input-path</root>";
     String output;
     if(System.getProperty("java.vendor").contains("IBM")){
@@ -298,7 +298,7 @@ public class UrlRewriteServletFilterTest {
   // MatcherAssert.assertThat( XmlConverters.the( outputHtml ), XmlMatchers.hasXPath( "/html" ) );
   @Test
   public void testOutboundJsonBodyRewrite() throws Exception {
-    setUp( null );
+    testSetUp( null );
 
     String input = "{\"url\":\"http://mock-host:1/test-input-path\"}";
     String expect = "{\"url\":\"http://mock-host:1/test-output-path-1\"}";
@@ -327,7 +327,7 @@ public class UrlRewriteServletFilterTest {
 
   @Test
   public void testOutboundHtmlBodyRewrite() throws Exception {
-    setUp( null );
+    testSetUp( null );
 
     String input = "<html><head></head><body><a href=\"http://mock-host:1/test-input-path\">link text</a></body></html>";
     String output = "<html><head></head><body><a href=\"http://mock-host:1/test-output-path-1\">link text</a></body></html>";
@@ -356,7 +356,7 @@ public class UrlRewriteServletFilterTest {
 
   @Test
   public void testInboundHtmlFormRewrite() throws Exception {
-    setUp( null );
+    testSetUp( null );
 
     String input = "Name=Jonathan+Doe&Age=23&Formula=a+%2B+b+%3D%3D+13%25%21&url=http%3A%2F%2Fmock-host%3A1%2Ftest-input-path";
     String expect = "Name=Jonathan+Doe&Age=23&Formula=a+%2B+b+%3D%3D+13%25%21&url=http%3A%2F%2Fmock-host%3A1%2Ftest-output-path-1";
@@ -387,7 +387,7 @@ public class UrlRewriteServletFilterTest {
   public void testRequestUrlRewriteWithFilterInitParam() throws Exception {
     Map<String,String> initParams = new HashMap<>();
     initParams.put( "request.url", "test-rule-2" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String input = "<root/>";
     String expect = "<root/>";
@@ -420,7 +420,7 @@ public class UrlRewriteServletFilterTest {
   public void testRequestHeaderRewriteWithFilterInitParam() throws Exception {
     Map<String,String> initParams = new HashMap<>();
     initParams.put( "request.headers", "test-filter-2" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String input = "<root/>";
     String expect = "<root/>";
@@ -463,7 +463,7 @@ public class UrlRewriteServletFilterTest {
     //initParams.put( "url, "" );
     initParams.put( "request.body", "test-filter-2" );
     //initParams.put( "response", "" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String inputJson = "{\"url\":\"http://mock-host:42/test-input-path-1\"}";
     String expectJson = "{\"url\":\"http://mock-host:42/test-output-path-2\"}";
@@ -495,7 +495,7 @@ public class UrlRewriteServletFilterTest {
   public void testRequestXmlBodyRewriteWithFilterInitParam() throws Exception {
     Map<String,String> initParams = new HashMap<>();
     initParams.put( "request.body", "test-filter-2" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String input = "<root url='http://mock-host:42/test-input-path-1'><url>http://mock-host:42/test-input-path-1</url></root>";
     String expect = "<root url='http://mock-host:42/test-output-path-2'><url>http://mock-host:42/test-output-path-2</url></root>";
@@ -531,7 +531,7 @@ public class UrlRewriteServletFilterTest {
 
       Map<String,String> initParams = new HashMap<>();
       initParams.put( "request.body", "test-filter-3" );
-      setUp( initParams );
+      testSetUp( initParams );
 
       String input = "<root url='http://mock-host:42/test-input-path-1'><url>http://mock-host:42/test-input-path-2</url></root>";
       String expect = "<root url='http://mock-host:42/test-input-path-2'><url>http://mock-host:42/test-input-path-2</url></root>";
@@ -567,7 +567,7 @@ public class UrlRewriteServletFilterTest {
   public void testRequestFormBodyRewriteWithFilterInitParam() throws Exception {
     Map<String,String> initParams = new HashMap<>();
     initParams.put( "request.body", "test-filter-2" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String input = "Name=Jonathan+Doe&Age=23&Formula=a+%2B+b+%3D%3D+13%25%21&url=http%3A%2F%2Fmock-host%3A1%2Ftest-input-path";
     String expect = "Name=Jonathan+Doe&Age=23&Formula=a+%2B+b+%3D%3D+13%25%21&url=http%3A%2F%2Fmock-host%3A1%2Ftest-output-path-2";
@@ -599,7 +599,7 @@ public class UrlRewriteServletFilterTest {
   public void testResponseHeaderRewriteWithFilterInitParam() throws Exception {
     Map<String,String> initParams = new HashMap<>();
     initParams.put( "response.headers", "test-filter-2" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String output = "<root url='http://mock-host:42/test-input-path-2'><url>http://mock-host:42/test-input-path-3</url></root>";
 
@@ -643,7 +643,7 @@ public class UrlRewriteServletFilterTest {
     //initParams.put( "url, "" );
     initParams.put( "response.body", "test-filter-2" );
     //initParams.put( "response", "" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String responseJson = "{\"url\":\"http://mock-host:42/test-input-path-1\"}";
 
@@ -676,7 +676,7 @@ public class UrlRewriteServletFilterTest {
     //initParams.put( "url, "" );
     initParams.put( "response.body", "test-filter-4" );
     //initParams.put( "response", "" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String responseHtml = "<!DOCTYPE html>\n" +
         "<html>\n" +
@@ -725,7 +725,7 @@ public class UrlRewriteServletFilterTest {
   public void testResponseXmlBodyRewriteWithFilterInitParam() throws Exception {
     Map<String,String> initParams = new HashMap<>();
     initParams.put( "response.body", "test-filter-2" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String output = "<root url='http://mock-host:42/test-input-path-1'><url>http://mock-host:42/test-input-path-1</url></root>";
 
@@ -761,7 +761,7 @@ public class UrlRewriteServletFilterTest {
     //initParams.put( "url, "" );
     initParams.put( "response.body", "test-filter-5" );
     //initParams.put( "response", "" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String responseHtml = "<html>" +
                           "  <head>" +
@@ -811,7 +811,7 @@ public class UrlRewriteServletFilterTest {
   public void testResponseHtmlBodyRewritePrefixFunctionTestPrefix() throws Exception {
 
     Map<String,String> initParams = new HashMap<>();
-    setUp( initParams );
+    testSetUp( initParams );
 
     String responseHtml = "<html><div src=\"'components/navbar/navbar.html?v=1496201914075\"></div></html>";
     String responseHtmlOne = "<html><div src=\"'http://0.0.0.0:0/zeppelin/components/navbar/navbar.html?v=1496201914075\"></div></html>";
@@ -850,7 +850,7 @@ public class UrlRewriteServletFilterTest {
 
     Map<String,String> initParams = new HashMap<>();
     initParams.put( "response.headers", "test-filter-6" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String locationHeader = "https://localhost:8443/gateway/knoxsso/api/v1/websso?originalUrl=http://localhost:20070/index.html&doAs=anonymous";
     String responseHtml = "<html>Hello There !</html>";
@@ -890,7 +890,7 @@ public class UrlRewriteServletFilterTest {
 
     Map<String,String> initParams = new HashMap<>();
     initParams.put( "response.headers", "test-filter-6" );
-    setUp( initParams );
+    testSetUp( initParams );
 
     String customHeader = "https://localhost:8443/gateway/sandbox/?query=http://localhost:20070";
     String responseHtml = "<html>Hello There !</html>";
@@ -927,7 +927,7 @@ public class UrlRewriteServletFilterTest {
   public void testResponseHtmlAttributeEscaping() throws Exception {
     final Map<String, String> initParams = new HashMap<>();
     initParams.put("response.body", "test-filter-4");
-    setUp(initParams);
+    testSetUp(initParams);
 
     final String responseHtml = "<!DOCTYPE html>\n" + "<html>\n" + "  <head>\n"
         + "    <meta charset=\"UTF-8\">\n"
@@ -970,8 +970,7 @@ public class UrlRewriteServletFilterTest {
       StringBuffer sourceUrl = httpRequest.getRequestURL();
       String queryString = httpRequest.getQueryString();
       if( queryString != null ) {
-        sourceUrl.append( "?" );
-        sourceUrl.append( queryString );
+        sourceUrl.append('?').append( queryString );
       }
       try {
         request.setAttribute(

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/FrontendFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/FrontendFunctionProcessorTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/FrontendFunctionProcessorTest.java
index 65b75bf..1a359b3 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/FrontendFunctionProcessorTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/FrontendFunctionProcessorTest.java
@@ -123,7 +123,7 @@ public class FrontendFunctionProcessorTest {
     processor.resolve( null, null );
   }
 
-  public void setUp( String username, Map<String, String> initParams, Attributes attributes ) throws Exception {
+  private void testSetup(String username, Map<String, String> initParams, Attributes attributes) throws Exception {
     ServiceRegistry mockServiceRegistry = EasyMock.createNiceMock( ServiceRegistry.class );
     EasyMock.expect( mockServiceRegistry.lookupServiceURL( "test-cluster", "NAMENODE" ) ).andReturn( "test-nn-scheme://test-nn-host:411" ).anyTimes();
     EasyMock.expect( mockServiceRegistry.lookupServiceURL( "test-cluster", "JOBTRACKER" ) ).andReturn( "test-jt-scheme://test-jt-host:511" ).anyTimes();
@@ -175,7 +175,7 @@ public class FrontendFunctionProcessorTest {
   public void testFrontendFunctionsOnJsonRequestBody() throws Exception {
     Map<String,String> initParams = new HashMap<>();
     initParams.put( "response.body", "test-filter" );
-    setUp( "test-user", initParams, null );
+    testSetup( "test-user", initParams, null );
 
     String input = TestUtils.getResourceString( FrontendFunctionProcessorTest.class, "test-input-body.json", StandardCharsets.UTF_8 );
 
@@ -221,7 +221,7 @@ public class FrontendFunctionProcessorTest {
     Attributes attributes = new AttributesMap(  );
     attributes.setAttribute( FrontendFunctionDescriptor.FRONTEND_URI_ATTRIBUTE, new URI( "mock-frontend-scheme://mock-frontend-host:777/mock-frontend-path" ) );
 
-    setUp( "test-user", initParams, attributes );
+    testSetup( "test-user", initParams, attributes );
 
     String input = TestUtils.getResourceString( FrontendFunctionProcessorTest.class, "test-input-body.json", StandardCharsets.UTF_8 );
 
@@ -273,7 +273,7 @@ public class FrontendFunctionProcessorTest {
       StringBuffer sourceUrl = httpRequest.getRequestURL();
       String queryString = httpRequest.getQueryString();
       if( queryString != null ) {
-        sourceUrl.append( "?" );
+        sourceUrl.append( '?' );
         sourceUrl.append( queryString );
       }
       try {
@@ -300,5 +300,4 @@ public class FrontendFunctionProcessorTest {
     public void destroy() {
     }
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponseTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponseTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponseTest.java
index 4d643b3..4124761 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponseTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponseTest.java
@@ -30,12 +30,11 @@ import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
 import java.util.List;
 import java.util.zip.GZIPInputStream;
 import java.util.zip.GZIPOutputStream;
@@ -144,26 +143,22 @@ public class UrlRewriteResponseTest {
     File targetDir = new File( System.getProperty( "user.dir" ), "target" );
     File inputFile = new File( targetDir, "input.test" );
     File outputFile = new File( targetDir, "output.test" );
-    OutputStream outStream, output;
-    InputStream inStream = null, input = null;
-    try {
-      outStream = isGzip ? new GZIPOutputStream( new FileOutputStream( inputFile ) ) : new FileOutputStream( inputFile );
-      outStream.write( content.getBytes(StandardCharsets.UTF_8) );
-      outStream.close();
-
-      input = new FileInputStream( inputFile );
-      output = new FileOutputStream( outputFile );
-      rewriteResponse.streamResponse( input, output );
-
-      inStream = isGzip ? new GZIPInputStream( new FileInputStream( outputFile ) ) : new FileInputStream( outputFile );
-      assertThat( String.valueOf( IOUtils.toCharArray( inStream, StandardCharsets.UTF_8 ) ), is( content ) );
-    } finally {
-      if ( inStream != null ) {
-        inStream.close();
+    try (OutputStream outputStream = Files.newOutputStream(inputFile.toPath())) {
+      try(OutputStream outStream = isGzip ? new GZIPOutputStream( outputStream ) : outputStream) {
+        outStream.write(content.getBytes(StandardCharsets.UTF_8));
+      }
+
+      try(InputStream input = Files.newInputStream(inputFile.toPath());
+          OutputStream output = Files.newOutputStream(outputFile.toPath())){
+
+        rewriteResponse.streamResponse(input, output);
       }
-      if ( input != null ) {
-        input.close();
+
+      try(InputStream inputStream = Files.newInputStream(outputFile.toPath());
+          InputStream inStream = isGzip ? new GZIPInputStream(inputStream) : inputStream) {
+        assertThat(String.valueOf(IOUtils.toCharArray(inStream, StandardCharsets.UTF_8)), is(content));
       }
+    } finally {
       inputFile.delete();
       outputFile.delete();
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlFilterReaderBaseTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlFilterReaderBaseTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlFilterReaderBaseTest.java
index e611b9b..2cb1000 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlFilterReaderBaseTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlFilterReaderBaseTest.java
@@ -618,7 +618,6 @@ public class HtmlFilterReaderBaseTest {
       Reader reader;
       UrlRewriteRulesDescriptor config;
       UrlRewriteRuleDescriptor rule;
-      List<UrlRewriteStepDescriptor> steps;
       UrlRewriteCheckDescriptorExt step;
 
       reader = new StringReader( "<rules><rule><check></check></rule></rules>" );
@@ -691,7 +690,6 @@ public class HtmlFilterReaderBaseTest {
       Reader reader;
       UrlRewriteRulesDescriptor config;
       UrlRewriteRuleDescriptor rule;
-      List<UrlRewriteStepDescriptor> steps;
 
       reader = new StringReader( "<rules><rule><control></control></rule></rules>" );
       config = digester.parse( reader );
@@ -739,27 +737,4 @@ public class HtmlFilterReaderBaseTest {
     assertThat( the( outputXml ), hasXPath( "/root/br/table[1]/@name", equalTo( "table1" ) ) );
     assertThat( the( outputXml ), hasXPath( "/root/br/table[2]/@name", equalTo( "table2" ) ) );
   }
-
-  private class TestXmlFilterReader extends HtmlFilterReaderBase {
-
-    protected TestXmlFilterReader( Reader reader, UrlRewriteFilterContentDescriptor contentConfig ) throws IOException, ParserConfigurationException {
-      super( reader );
-    }
-
-    @Override
-    protected String filterAttribute( QName elementName, QName attributeName, String attributeValue, String ruleName ) {
-      return "attr:" + ruleName + "{" + attributeValue + "}";
-    }
-
-    @Override
-    protected String filterText( QName elementName, String text, String ruleName ) {
-      return "text:" + ruleName + "{" + text + "}";
-    }
-
-    @Override
-    public String filterValueString( String name, String value, String ruleName ) {
-      return value;
-    }
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/json/JsonFilterReaderTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/json/JsonFilterReaderTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/json/JsonFilterReaderTest.java
index 25488a0..3a022e0 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/json/JsonFilterReaderTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/json/JsonFilterReaderTest.java
@@ -40,6 +40,7 @@ import java.util.Random;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 public class JsonFilterReaderTest {
@@ -53,6 +54,7 @@ public class JsonFilterReaderTest {
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/json" );
     UrlRewriteFilterBufferDescriptor bufferConfig = contentConfig.addBuffer( "$.apps.app[*]" );
     UrlRewriteFilterApplyDescriptor applyConfig = bufferConfig.addApply( "$.id", "test-rule" );
+    assertNotNull(applyConfig);
 
     JsonFilterReader filter = new JsonFilterReader( new StringReader( input ), contentConfig );
     String output = IOUtils.toString( filter );
@@ -161,6 +163,7 @@ public class JsonFilterReaderTest {
     UrlRewriteFilterDescriptor filterConfig = rulesConfig.addFilter( "filter=1" );
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/json" );
     UrlRewriteFilterApplyDescriptor applyConfig = contentConfig.addApply( "$['test-str']", "test-rule" );
+    assertNotNull(applyConfig);
 
     JsonFilterReader filter = new TestJsonFilterReader( new StringReader( input ), contentConfig );
     String output = IOUtils.toString( filter );
@@ -261,6 +264,7 @@ public class JsonFilterReaderTest {
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/json" );
     UrlRewriteFilterBufferDescriptor bufferConfig = contentConfig.addBuffer( "$" );
     UrlRewriteFilterApplyDescriptor applyConfig = bufferConfig.addApply( "$['name<test-str>']", "test-rule" );
+    assertNotNull(applyConfig);
     //UrlRewriteRulesDescriptorFactory.store( rulesConfig, "xml", new PrintWriter( System.out ) );
 
     JsonFilterReader filter = new TestJsonFilterReader( new StringReader( input ), contentConfig );
@@ -284,6 +288,7 @@ public class JsonFilterReaderTest {
     UrlRewriteFilterBufferDescriptor bufferConfig = contentConfig.addBuffer( "$.name<properties>.*.name<property>" );
     UrlRewriteFilterDetectDescriptor detectConfig = bufferConfig.addDetect( "$.name<property-name>", "test-name-2" );
     UrlRewriteFilterApplyDescriptor applyConfig = detectConfig.addApply( "$.name<property-value>", "test-rule-2" );
+    assertNotNull(applyConfig);
 
     //UrlRewriteRulesDescriptorFactory.store( rulesConfig, "xml", new PrintWriter( System.out ) );
 
@@ -312,6 +317,7 @@ public class JsonFilterReaderTest {
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/json" );
     UrlRewriteFilterBufferDescriptor bufferConfig = contentConfig.addBuffer( "$.name<properties>.*.name<property>" );
     UrlRewriteFilterApplyDescriptor applyConfig = bufferConfig.addApply( "$.name<property-value>", "test-rule" );
+    assertNotNull(applyConfig);
 
     //UrlRewriteRulesDescriptorFactory.store( rulesConfig, "xml", new PrintWriter( System.out ) );
 
@@ -340,6 +346,7 @@ public class JsonFilterReaderTest {
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/json" );
     UrlRewriteFilterBufferDescriptor bufferConfig = contentConfig.addBuffer( "$.name<properties>" );
     UrlRewriteFilterApplyDescriptor applyConfig = bufferConfig.addApply( "$.*.name<property>.name<property-value>", "test-rule" );
+    assertNotNull(applyConfig);
 
     //UrlRewriteRulesDescriptorFactory.store( rulesConfig, "xml", new PrintWriter( System.out ) );
 
@@ -395,10 +402,4 @@ public class JsonFilterReaderTest {
     output = IOUtils.toString( filter );
     assertThat( output, is( "{\"test-name\":\"\\b\"}" ) );
   }
-
-//  private void dump( ObjectMapper mapper, JsonGenerator generator, JsonNode node ) throws IOException {
-//    mapper.writeTree( generator, node );
-//    System.out.println();
-//  }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReaderTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReaderTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReaderTest.java
index e489f7a..d041661 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReaderTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReaderTest.java
@@ -65,6 +65,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 import static org.xmlmatchers.XmlMatchers.hasXPath;
 import static org.xmlmatchers.transform.XmlConverters.the;
@@ -147,6 +148,7 @@ public class XmlFilterReaderTest {
     UrlRewriteFilterDescriptor filterConfig = rulesConfig.addFilter( "filter-1" );
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/xml" );
     UrlRewriteFilterBufferDescriptor scopeConfig = contentConfig.addBuffer( "/root" );
+    assertNotNull(scopeConfig);
 
     String input = "<root/>";
     //System.out.println( "INPUT=" + input );
@@ -211,6 +213,7 @@ public class XmlFilterReaderTest {
     UrlRewriteFilterDescriptor filterConfig = rulesConfig.addFilter( "filter-1" );
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/xml" );
     UrlRewriteFilterBufferDescriptor scopeConfig = contentConfig.addBuffer( "/root" );
+    assertNotNull(scopeConfig);
 
     String inputXml = "<root>text</root>";
     StringReader inputReader = new StringReader( inputXml );
@@ -226,6 +229,7 @@ public class XmlFilterReaderTest {
     UrlRewriteFilterDescriptor filterConfig = rulesConfig.addFilter( "filter-1" );
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/xml" );
     UrlRewriteFilterBufferDescriptor scopeConfig = contentConfig.addBuffer( "/root" );
+    assertNotNull(scopeConfig);
 
     String inputXml = "<root name='value'/>";
     StringReader inputReader = new StringReader( inputXml );
@@ -587,7 +591,6 @@ public class XmlFilterReaderTest {
       Reader reader;
       UrlRewriteRulesDescriptor config;
       UrlRewriteRuleDescriptor rule;
-      List<UrlRewriteStepDescriptor> steps;
       UrlRewriteCheckDescriptorExt step;
 
       reader = new StringReader( "<rules><rule><check></check></rule></rules>" );
@@ -660,7 +663,6 @@ public class XmlFilterReaderTest {
       Reader reader;
       UrlRewriteRulesDescriptor config;
       UrlRewriteRuleDescriptor rule;
-      List<UrlRewriteStepDescriptor> steps;
 
       reader = new StringReader( "<rules><rule><control></control></rule></rules>" );
       config = digester.parse( reader );
@@ -720,6 +722,7 @@ public class XmlFilterReaderTest {
     UrlRewriteFilterDescriptor filterConfig = rulesConfig.addFilter( "filter-1" );
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/xml" );
     UrlRewriteFilterApplyDescriptor applyConfig = contentConfig.addApply( "/properties/property/value/text()", "test-rule-2" );
+    assertNotNull(applyConfig);
 
     //UrlRewriteRulesDescriptorFactory.store( rulesConfig, "xml", new PrintWriter( System.out ) );
 
@@ -747,6 +750,7 @@ public class XmlFilterReaderTest {
     UrlRewriteFilterDescriptor filterConfig = rulesConfig.addFilter( "filter-1" );
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/xml" );
     UrlRewriteFilterApplyDescriptor applyConfig = contentConfig.addApply( "/properties/property/value", "test-rule-2" );
+    assertNotNull(applyConfig);
 
     //UrlRewriteRulesDescriptorFactory.store( rulesConfig, "xml", new PrintWriter( System.out ) );
 
@@ -774,6 +778,7 @@ public class XmlFilterReaderTest {
     UrlRewriteFilterDescriptor filterConfig = rulesConfig.addFilter( "filter-1" );
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/xml" );
     UrlRewriteFilterApplyDescriptor applyConfig = contentConfig.addApply( "/properties/property/@value", "test-rule-2" );
+    assertNotNull(applyConfig);
 
     //UrlRewriteRulesDescriptorFactory.store( rulesConfig, "xml", new PrintWriter( System.out ) );
 
@@ -802,6 +807,7 @@ public class XmlFilterReaderTest {
     UrlRewriteFilterContentDescriptor contentConfig = filterConfig.addContent( "text/xml" );
     UrlRewriteFilterBufferDescriptor bufferconfig = contentConfig.addBuffer( "/properties/property" );
     UrlRewriteFilterApplyDescriptor applyConfig = bufferconfig.addApply( "@value", "test-rule-2" );
+    assertNotNull(applyConfig);
 
     //UrlRewriteRulesDescriptorFactory.store( rulesConfig, "xml", new PrintWriter( System.out ) );
 
@@ -831,6 +837,7 @@ public class XmlFilterReaderTest {
     UrlRewriteFilterBufferDescriptor bufferConfig = contentConfig.addBuffer( "/properties/property" );
     UrlRewriteFilterDetectDescriptor detectConfig = bufferConfig.addDetect( "name", "test-name-2" );
     UrlRewriteFilterApplyDescriptor applyConfig = detectConfig.addApply( "value", "test-rule-2" );
+    assertNotNull(applyConfig);
 
     //UrlRewriteRulesDescriptorFactory.store( rulesConfig, "xml", new PrintWriter( System.out ) );
 
@@ -860,6 +867,7 @@ public class XmlFilterReaderTest {
     UrlRewriteFilterBufferDescriptor bufferConfig = contentConfig.addBuffer( "/properties/property" );
     UrlRewriteFilterDetectDescriptor detectConfig = bufferConfig.addDetect( "@name", "test-name-2" );
     UrlRewriteFilterApplyDescriptor applyConfig = detectConfig.addApply( "@value", "test-rule-2" );
+    assertNotNull(applyConfig);
 
     //UrlRewriteRulesDescriptorFactory.store( rulesConfig, "xml", new PrintWriter( System.out ) );
 

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporterTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporterTest.java
index 959d09c..31f3602 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporterTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporterTest.java
@@ -25,6 +25,7 @@ import org.apache.knox.gateway.filter.rewrite.ext.UrlRewriteActionRewriteDescrip
 import org.apache.knox.gateway.filter.rewrite.ext.UrlRewriteCheckDescriptor;
 import org.apache.knox.gateway.filter.rewrite.ext.UrlRewriteControlDescriptor;
 import org.apache.knox.gateway.filter.rewrite.ext.UrlRewriteMatchDescriptor;
+import org.junit.Assert;
 import org.junit.Test;
 import org.xmlmatchers.XmlMatchers;
 import org.xmlmatchers.transform.XmlConverters;
@@ -57,7 +58,6 @@ public class XmlUrlRewriteRulesExporterTest {
     UrlRewriteRulesDescriptorFactory.store( rules, "xml", writer );
 
     String str = writer.toString();
-    //System.out.println( str );
     Source xml = XmlConverters.the( str );
     assertThat( xml, XmlMatchers.hasXPath( "/rules" ) );
     assertThat( xml, XmlMatchers.hasXPath( "/rules/rule" ) );
@@ -77,7 +77,6 @@ public class XmlUrlRewriteRulesExporterTest {
     UrlRewriteRulesDescriptorFactory.store( rules, "xml", writer );
 
     String str = writer.toString();
-    //System.out.println( str );
     Source xml = XmlConverters.the( str );
     assertThat( xml, XmlMatchers.hasXPath( "/rules" ) );
     assertThat( xml, XmlMatchers.hasXPath( "/rules/rule" ) );
@@ -102,7 +101,6 @@ public class XmlUrlRewriteRulesExporterTest {
     UrlRewriteRulesDescriptorFactory.store( rules, "xml", writer );
 
     String str = writer.toString();
-    //System.out.println( str );
     Source xml = XmlConverters.the( str );
     assertThat( xml, XmlMatchers.hasXPath( "/rules" ) );
     assertThat( xml, XmlMatchers.hasXPath( "/rules/rule" ) );
@@ -124,7 +122,6 @@ public class XmlUrlRewriteRulesExporterTest {
     UrlRewriteRulesDescriptorFactory.store( rules, "xml", writer );
 
     String str = writer.toString();
-    //System.out.println( str );
     Source xml = XmlConverters.the( str );
     assertThat( xml, XmlMatchers.hasXPath( "/rules" ) );
     assertThat( xml, XmlMatchers.hasXPath( "/rules/rule" ) );
@@ -148,7 +145,6 @@ public class XmlUrlRewriteRulesExporterTest {
     UrlRewriteRulesDescriptorFactory.store( rules, "xml", writer );
 
     String str = writer.toString();
-    //System.out.println( str );
     Source xml = XmlConverters.the( str );
     assertThat( xml, XmlMatchers.hasXPath( "/rules" ) );
     assertThat( xml, XmlMatchers.hasXPath( "/rules/rule" ) );
@@ -169,26 +165,38 @@ public class XmlUrlRewriteRulesExporterTest {
     UrlRewriteCheckDescriptor matchCheck = match.addStep( "check" );
     UrlRewriteControlDescriptor matchControl = match.addStep( "control" );
     UrlRewriteActionDescriptor matchRewrite = match.addStep( "rewrite" );
+    Assert.assertNotNull(matchMatch);
+    Assert.assertNotNull(matchCheck);
+    Assert.assertNotNull(matchControl);
+    Assert.assertNotNull(matchRewrite);
 
     UrlRewriteCheckDescriptor check = rule.addStep( "check" );
     UrlRewriteMatchDescriptor checkMatch = check.addStep( "match" );
     UrlRewriteCheckDescriptor checkCheck = check.addStep( "check" );
     UrlRewriteControlDescriptor checkControl = check.addStep( "control" );
     UrlRewriteActionDescriptor checkRewrite = check.addStep( "rewrite" );
+    Assert.assertNotNull(checkMatch);
+    Assert.assertNotNull(checkCheck);
+    Assert.assertNotNull(checkControl);
+    Assert.assertNotNull(checkRewrite);
 
     UrlRewriteControlDescriptor control = rule.addStep( "control" );
     UrlRewriteMatchDescriptor controlMatch = control.addStep( "match" );
     UrlRewriteCheckDescriptor controlCheck = control.addStep( "check" );
     UrlRewriteControlDescriptor controlControl = control.addStep( "control" );
     UrlRewriteActionDescriptor controlRewrite = control.addStep( "rewrite" );
+    Assert.assertNotNull(controlMatch);
+    Assert.assertNotNull(controlCheck);
+    Assert.assertNotNull(controlControl);
+    Assert.assertNotNull(controlRewrite);
 
     UrlRewriteActionDescriptor rewrite = rule.addStep( "rewrite" );
+    Assert.assertNotNull(rewrite);
 
     StringWriter writer = new StringWriter();
     UrlRewriteRulesDescriptorFactory.store( rules, "xml", writer );
 
     String str = writer.toString();
-    //System.out.println( str );
     Source xml = XmlConverters.the( str );
     assertThat( xml, XmlMatchers.hasXPath( "/rules" ) );
     assertThat( xml, XmlMatchers.hasXPath( "/rules/rule" ) );
@@ -211,5 +219,4 @@ public class XmlUrlRewriteRulesExporterTest {
     assertThat( xml, XmlMatchers.hasXPath( "/rules/rule/control/rewrite" ) );
     assertThat( xml, XmlMatchers.hasXPath( "/rules/rule/rewrite" ) );
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclParserTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclParserTest.java b/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclParserTest.java
index 113b499..3096916 100644
--- a/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclParserTest.java
+++ b/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclParserTest.java
@@ -19,6 +19,7 @@ package org.apache.knox.gateway.filter;
 
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -29,7 +30,7 @@ import static org.junit.Assert.fail;
  */
 public class AclParserTest {
   @Test
-  public void testValidAcls() throws Exception {
+  public void testValidAcls() {
     AclParser p = new AclParser();
     p.parseAcls("test", "guest;*;*");
     assertTrue(p.users.contains("guest"));
@@ -91,7 +92,7 @@ public class AclParserTest {
   }
 
   @Test
-  public void testValidMultiValuedAcls() throws Exception {
+  public void testValidMultiValuedAcls() {
     AclParser p = new AclParser();
     p.parseAcls("test", "*;admins;127.0.0.1,127.0.0.2");
     assertFalse(p.users.contains("guest"));
@@ -133,81 +134,78 @@ public class AclParserTest {
   }
 
   @Test
-  public void testNullACL() throws Exception {
+  public void testNullACL() {
     AclParser p = new AclParser();
     try {
       p.parseAcls("test", null);
-    }
-    catch (InvalidACLException sle) {
-      // expected
+    } catch (InvalidACLException sle) {
       fail("NULL acl should NOT have thrown InvalidACLException.");
     }
   }
 
   @Test
-  public void testInvalidAcls() throws Exception {
+  public void testInvalidAcls() {
     AclParser p = new AclParser();
     try {
       p.parseAcls("test", "guest");
       fail("Invalid acl should have thrown InvalidACLException.");
-    }
-    catch (InvalidACLException sle) {
+    } catch (InvalidACLException sle) {
       // expected
+      assertEquals("Invalid ACLs specified for requested resource: test", sle.getMessage());
     }
 
     p = new AclParser();
     try {
       p.parseAcls("test", "guest;;");
       fail("Invalid acl should have thrown InvalidACLException.");
-    }
-    catch (InvalidACLException sle) {
+    } catch (InvalidACLException sle) {
       // expected
+      assertEquals("Invalid ACLs specified for requested resource: test", sle.getMessage());
     }
 
     p = new AclParser();
     try {
       p.parseAcls("test", ";;");
       fail("Invalid acl should have thrown InvalidACLException.");
-    }
-    catch (InvalidACLException sle) {
+    } catch (InvalidACLException sle) {
       // expected
+      assertEquals("Invalid ACLs specified for requested resource: test", sle.getMessage());
     }
 
     p = new AclParser();
     try {
       p.parseAcls("test", ";");
       fail("Invalid acl should have thrown InvalidACLException.");
-    }
-    catch (InvalidACLException sle) {
+    } catch (InvalidACLException sle) {
       // expected
+      assertEquals("Invalid ACLs specified for requested resource: test", sle.getMessage());
     }
 
     p = new AclParser();
     try {
       p.parseAcls("test", "guest;");
       fail("Invalid acl should have thrown InvalidACLException.");
-    }
-    catch (InvalidACLException sle) {
+    } catch (InvalidACLException sle) {
       // expected
+      assertEquals("Invalid ACLs specified for requested resource: test", sle.getMessage());
     }
 
     p = new AclParser();
     try {
       p.parseAcls("test", ";admins");
       fail("Invalid acl should have thrown InvalidACLException.");
-    }
-    catch (InvalidACLException sle) {
+    } catch (InvalidACLException sle) {
       // expected
+      assertEquals("Invalid ACLs specified for requested resource: test", sle.getMessage());
     }
 
     p = new AclParser();
     try {
       p.parseAcls("test", "");
       fail("Invalid acl should have thrown InvalidACLException.");
-    }
-    catch (InvalidACLException sle) {
+    } catch (InvalidACLException sle) {
       // expected
+      assertEquals("Invalid ACLs specified for requested resource: test", sle.getMessage());
     }
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclsAuthzFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclsAuthzFilterTest.java b/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclsAuthzFilterTest.java
index 43c9bec..396a13b 100644
--- a/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclsAuthzFilterTest.java
+++ b/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclsAuthzFilterTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
-import java.net.URISyntaxException;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 
@@ -46,13 +45,12 @@ public class AclsAuthzFilterTest {
   private Filter filter;
 
   @Before
-  public void setup() {
+  public void setUp() {
     filter = new AclsAuthorizationFilter() {
       @Override
       public void doFilter(ServletRequest request, ServletResponse response,
                            FilterChain chain) throws IOException, ServletException {
         boolean accessGranted = enforceAclAuthorizationPolicy(request, response, chain);
-        String sourceUrl = (String)request.getAttribute( AbstractGatewayFilter.SOURCE_REQUEST_CONTEXT_URL_ATTRIBUTE_NAME );
         if (accessGranted) {
           chain.doFilter(request, response);
         }
@@ -68,9 +66,7 @@ public class AclsAuthzFilterTest {
   }
 
   @Test
-  public void testKnoxAdminGroupsValid() throws ServletException, IOException,
-      URISyntaxException {
-
+  public void testKnoxAdminGroupsValid() throws ServletException, IOException {
     FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
     EasyMock.expect(config.getInitParameter("knox.admin.users")).andReturn(null);
     EasyMock.expect(config.getInitParameter("knox.admin.groups")).andReturn("admin");
@@ -125,9 +121,7 @@ public class AclsAuthzFilterTest {
   }
 
   @Test
-  public void testKnoxAdminGroupsInvalid() throws ServletException, IOException,
-      URISyntaxException {
-
+  public void testKnoxAdminGroupsInvalid() throws ServletException, IOException {
     FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
     EasyMock.expect(config.getInitParameter("knox.admin.users")).andReturn(null);
     EasyMock.expect(config.getInitParameter("knox.admin.groups")).andReturn("admin");
@@ -144,8 +138,7 @@ public class AclsAuthzFilterTest {
 
     final FilterChain chain = new FilterChain() {
       @Override
-      public void doFilter(ServletRequest request, ServletResponse response)
-          throws IOException, ServletException {
+      public void doFilter(ServletRequest request, ServletResponse response) {
       }
     };
 
@@ -182,9 +175,7 @@ public class AclsAuthzFilterTest {
   }
 
   @Test
-  public void testKnoxAdminUsersValid() throws ServletException, IOException,
-      URISyntaxException {
-
+  public void testKnoxAdminUsersValid() throws ServletException, IOException {
     FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
     EasyMock.expect(config.getInitParameter("knox.admin.users")).andReturn("adminuser");
     EasyMock.expect(config.getInitParameter("knox.admin.groups")).andReturn(null);
@@ -201,8 +192,7 @@ public class AclsAuthzFilterTest {
 
     final FilterChain chain = new FilterChain() {
       @Override
-      public void doFilter(ServletRequest request, ServletResponse response)
-          throws IOException, ServletException {
+      public void doFilter(ServletRequest request, ServletResponse response) {
       }
     };
 
@@ -239,9 +229,7 @@ public class AclsAuthzFilterTest {
   }
 
   @Test
-  public void testKnoxAdminUsersInvalid() throws ServletException, IOException,
-      URISyntaxException {
-
+  public void testKnoxAdminUsersInvalid() throws ServletException, IOException {
     FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
     EasyMock.expect(config.getInitParameter("knox.admin.users")).andReturn("adminuser");
     EasyMock.expect(config.getInitParameter("knox.admin.groups")).andReturn(null);
@@ -258,8 +246,7 @@ public class AclsAuthzFilterTest {
 
     final FilterChain chain = new FilterChain() {
       @Override
-      public void doFilter(ServletRequest request, ServletResponse response)
-          throws IOException, ServletException {
+      public void doFilter(ServletRequest request, ServletResponse response) {
       }
     };
 
@@ -296,9 +283,7 @@ public class AclsAuthzFilterTest {
   }
 
   @Test
-  public void testKnoxAdminUsersInvalidButACLUsersValid() throws ServletException, IOException,
-      URISyntaxException {
-
+  public void testKnoxAdminUsersInvalidButACLUsersValid() throws ServletException, IOException {
     FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
     EasyMock.expect(config.getInitParameter("knox.admin.users")).andReturn("adminuser");
     EasyMock.expect(config.getInitParameter("knox.admin.groups")).andReturn(null);
@@ -353,9 +338,7 @@ public class AclsAuthzFilterTest {
   }
 
   @Test
-  public void testKnoxAdminUsersInvalidButACLGroupValid() throws ServletException, IOException,
-      URISyntaxException {
-
+  public void testKnoxAdminUsersInvalidButACLGroupValid() throws ServletException, IOException {
     FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
     EasyMock.expect(config.getInitParameter("knox.admin.users")).andReturn("adminuser");
     EasyMock.expect(config.getInitParameter("knox.admin.groups")).andReturn(null);
@@ -372,8 +355,7 @@ public class AclsAuthzFilterTest {
 
     final FilterChain chain = new FilterChain() {
       @Override
-      public void doFilter(ServletRequest request, ServletResponse response)
-          throws IOException, ServletException {
+      public void doFilter(ServletRequest request, ServletResponse response) {
       }
     };
 
@@ -410,9 +392,7 @@ public class AclsAuthzFilterTest {
   }
 
   @Test
-  public void testKnoxAdminUsersInvalidButKnoxAdminGroupValid() throws ServletException, IOException,
-      URISyntaxException {
-
+  public void testKnoxAdminUsersInvalidButKnoxAdminGroupValid() throws ServletException, IOException {
     FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
     EasyMock.expect(config.getInitParameter("knox.admin.users")).andReturn("adminuser");
     EasyMock.expect(config.getInitParameter("knox.admin.groups")).andReturn("admingroup");
@@ -429,8 +409,7 @@ public class AclsAuthzFilterTest {
 
     final FilterChain chain = new FilterChain() {
       @Override
-      public void doFilter(ServletRequest request, ServletResponse response)
-          throws IOException, ServletException {
+      public void doFilter(ServletRequest request, ServletResponse response) {
       }
     };
 

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/AbstractJWTFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/AbstractJWTFilterTest.java b/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/AbstractJWTFilterTest.java
index 23967c9..22a46fd 100644
--- a/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/AbstractJWTFilterTest.java
+++ b/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/AbstractJWTFilterTest.java
@@ -90,7 +90,7 @@ public abstract class AbstractJWTFilterTest  {
   }
 
   @BeforeClass
-  public static void generateKeys() throws Exception {
+  public static void setUpBeforeClass() throws Exception {
     KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
     kpg.initialize(2048);
     KeyPair KPair = kpg.generateKeyPair();
@@ -105,7 +105,7 @@ public abstract class AbstractJWTFilterTest  {
   }
 
   @After
-  public void teardown() {
+  public void tearDown() {
     handler.destroy();
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/SSOCookieProviderTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/SSOCookieProviderTest.java b/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/SSOCookieProviderTest.java
index e0da4f1..7fc28a6 100644
--- a/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/SSOCookieProviderTest.java
+++ b/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/SSOCookieProviderTest.java
@@ -19,7 +19,6 @@ package org.apache.knox.gateway.provider.federation;
 
 import static org.junit.Assert.fail;
 
-import java.security.NoSuchAlgorithmException;
 import java.security.Principal;
 import java.util.Properties;
 import java.util.Date;
@@ -45,7 +44,7 @@ public class SSOCookieProviderTest extends AbstractJWTFilterTest {
   private static final String SERVICE_URL = "https://localhost:8888/resource";
 
   @Before
-  public void setup() throws Exception, NoSuchAlgorithmException {
+  public void setUp() {
     handler = new TestSSOCookieFederationProvider();
     ((TestSSOCookieFederationProvider) handler).setTokenService(new TestJWTokenAuthority(publicKey));
   }
@@ -100,7 +99,7 @@ public class SSOCookieProviderTest extends AbstractJWTFilterTest {
   }
 
   @Test
-  public void testNoProviderURLJWT() throws Exception {
+  public void testNoProviderURLJWT() {
     try {
       Properties props = getProperties();
       props.remove("sso.authentication.provider.url");
@@ -123,7 +122,7 @@ public class SSOCookieProviderTest extends AbstractJWTFilterTest {
     EasyMock.expect(request.getQueryString()).andReturn("name=value");
     EasyMock.replay(request);
 
-    String loginURL = ((TestSSOCookieFederationProvider)handler).testConstructLoginURL(request);
+    String loginURL = ((TestSSOCookieFederationProvider)handler).constructLoginURL(request);
     Assert.assertNotNull("loginURL should not be null.", loginURL);
     Assert.assertEquals("https://localhost:8443/authserver?originalUrl=" + SERVICE_URL + "?name=value", loginURL);
   }
@@ -139,7 +138,7 @@ public class SSOCookieProviderTest extends AbstractJWTFilterTest {
     EasyMock.expect(request.getQueryString()).andReturn(null);
     EasyMock.replay(request);
 
-    String loginURL = ((TestSSOCookieFederationProvider)handler).testConstructLoginURL(request);
+    String loginURL = ((TestSSOCookieFederationProvider)handler).constructLoginURL(request);
     Assert.assertNotNull("LoginURL should not be null.", loginURL);
     Assert.assertEquals("https://localhost:8443/authserver?originalUrl=" + SERVICE_URL, loginURL);
   }
@@ -162,7 +161,7 @@ public class SSOCookieProviderTest extends AbstractJWTFilterTest {
     Assert.assertNotNull("LoginURL should not be null.", providerURL);
     Assert.assertEquals(providerURL, "https://localhost:8443/gateway/knoxsso/api/v1/websso");
 
-    String loginURL = ((TestSSOCookieFederationProvider) handler).testConstructLoginURL(request);
+    String loginURL = ((TestSSOCookieFederationProvider) handler).constructLoginURL(request);
     Assert.assertNotNull("LoginURL should not be null.", loginURL);
     Assert.assertEquals(loginURL, "https://localhost:8443/gateway/knoxsso/api/v1/websso?originalUrl=" + SERVICE_URL);
   }
@@ -184,7 +183,7 @@ public class SSOCookieProviderTest extends AbstractJWTFilterTest {
     Assert.assertNotNull("LoginURL should not be null.", providerURL);
     Assert.assertEquals(providerURL, "https://remotehost:8443/gateway/knoxsso/api/v1/websso");
 
-    String loginURL = ((TestSSOCookieFederationProvider) handler).testConstructLoginURL(request);
+    String loginURL = ((TestSSOCookieFederationProvider) handler).constructLoginURL(request);
     Assert.assertNotNull("LoginURL should not be null.", loginURL);
     Assert.assertEquals(loginURL, "https://remotehost:8443/gateway/knoxsso/api/v1/websso?originalUrl=" + SERVICE_URL);
   }
@@ -206,7 +205,7 @@ public class SSOCookieProviderTest extends AbstractJWTFilterTest {
     Assert.assertNotNull("LoginURL should not be null.", providerURL);
     Assert.assertEquals(providerURL, "https://remotehost:8443/notgateway/knoxsso/api/v1/websso");
 
-    String loginURL = ((TestSSOCookieFederationProvider) handler).testConstructLoginURL(request);
+    String loginURL = ((TestSSOCookieFederationProvider) handler).constructLoginURL(request);
     Assert.assertNotNull("LoginURL should not be null.", loginURL);
     Assert.assertEquals(loginURL, "https://remotehost:8443/notgateway/knoxsso/api/v1/websso?originalUrl=" + SERVICE_URL);
   }
@@ -217,13 +216,13 @@ public class SSOCookieProviderTest extends AbstractJWTFilterTest {
   }
 
   private static class TestSSOCookieFederationProvider extends SSOCookieFederationFilter {
-    public String testConstructLoginURL(HttpServletRequest req) {
-      return constructLoginURL(req);
+    @Override
+    public String constructLoginURL(HttpServletRequest req) {
+      return super.constructLoginURL(req);
     }
 
-    public void setTokenService(JWTokenAuthority ts) {
+    void setTokenService(JWTokenAuthority ts) {
       authority = ts;
     }
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-security-pac4j/src/test/java/org/apache/knox/gateway/pac4j/MockHttpServletResponse.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-pac4j/src/test/java/org/apache/knox/gateway/pac4j/MockHttpServletResponse.java b/gateway-provider-security-pac4j/src/test/java/org/apache/knox/gateway/pac4j/MockHttpServletResponse.java
index 6608e28..688465d 100644
--- a/gateway-provider-security-pac4j/src/test/java/org/apache/knox/gateway/pac4j/MockHttpServletResponse.java
+++ b/gateway-provider-security-pac4j/src/test/java/org/apache/knox/gateway/pac4j/MockHttpServletResponse.java
@@ -32,7 +32,6 @@ import java.util.Map;
 public class MockHttpServletResponse extends HttpServletResponseWrapper {
 
     private List<Cookie> cookies = new ArrayList<>();
-    private String location;
     private int status;
     private Map<String, String> headers = new HashMap<>();
 

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/HeaderPreAuthFederationFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/HeaderPreAuthFederationFilterTest.java b/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/HeaderPreAuthFederationFilterTest.java
index 86516fe..2cd72d3 100644
--- a/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/HeaderPreAuthFederationFilterTest.java
+++ b/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/HeaderPreAuthFederationFilterTest.java
@@ -124,7 +124,7 @@ public class HeaderPreAuthFederationFilterTest extends org.junit.Assert {
 
 
   public static class DummyValidator implements PreAuthValidator {
-    static String NAME = "DummyValidator";
+    static final String NAME = "DummyValidator";
 
     public DummyValidator() {
 
@@ -133,7 +133,7 @@ public class HeaderPreAuthFederationFilterTest extends org.junit.Assert {
     @Override
     public boolean validate(HttpServletRequest httpRequest, FilterConfig filterConfig) {
       String token = httpRequest.getHeader("CUSTOM_TOKEN");
-      return token.equalsIgnoreCase("HelloWorld");
+      return "HelloWorld".equalsIgnoreCase(token);
     }
 
     @Override
@@ -141,5 +141,4 @@ public class HeaderPreAuthFederationFilterTest extends org.junit.Assert {
       return NAME;
     }
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/PreAuthSSOTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/PreAuthSSOTest.java b/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/PreAuthSSOTest.java
deleted file mode 100644
index 6b90400..0000000
--- a/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/PreAuthSSOTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.knox.gateway.provider.federation;
-
-import org.junit.Test;
-
-public class PreAuthSSOTest extends org.junit.Assert {
-  @Test
-  public void testPreAuth() throws Exception {
-    assertTrue(true);
-  }
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/PreAuthServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/PreAuthServiceTest.java b/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/PreAuthServiceTest.java
index cae69ee..3d812b2 100644
--- a/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/PreAuthServiceTest.java
+++ b/gateway-provider-security-preauth/src/test/java/org/apache/knox/gateway/provider/federation/PreAuthServiceTest.java
@@ -124,6 +124,9 @@ public class PreAuthServiceTest extends org.junit.Assert {
       fail("Should throw exception due to invalid validator");
     } catch (Exception e) {
       //Expected
+      assertEquals("Unable to find validator with name 'preauth.default.validation,  " +
+                       "NOT_EXISTED_VALIDATOR'",
+          e.getMessage());
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/CSRFTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/CSRFTest.java b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/CSRFTest.java
deleted file mode 100644
index e58de37..0000000
--- a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/CSRFTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.knox.gateway.webappsec;
-
-
-import org.junit.Test;
-
-public class CSRFTest extends org.junit.Assert {
-  @Test
-  public void testCsrf() throws Exception {
-    assertTrue(true);
-  }
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/CompositeEnumerationTest.java
----------------------------------------------------------------------
diff --git a/gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/CompositeEnumerationTest.java b/gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/CompositeEnumerationTest.java
index 5372efb..d8a544d 100644
--- a/gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/CompositeEnumerationTest.java
+++ b/gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/CompositeEnumerationTest.java
@@ -26,13 +26,10 @@ import java.util.NoSuchElementException;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
 
 public class CompositeEnumerationTest {
-
   @Test
   public void testBasics() {
-
     String[] a = new String[]{ "1", "2" };
     Enumeration<String> ea = Collections.enumeration( Arrays.asList( a ) );
 
@@ -46,7 +43,6 @@ public class CompositeEnumerationTest {
     assertThat( ce.nextElement(), is( "3" ) );
     assertThat( ce.nextElement(), is( "4" ) );
     assertThat( ce.hasMoreElements(), is( false ) );
-
   }
 
   @Test
@@ -66,7 +62,6 @@ public class CompositeEnumerationTest {
 
   @Test
   public void testEmptyEnumerations() {
-
     String[] a = new String[]{ "1", "2" };
     String[] b = new String[]{ "3", "4" };
     String[] c = new String[]{};
@@ -91,27 +86,15 @@ public class CompositeEnumerationTest {
     assertThat( ce.hasMoreElements(), is( false ) );
   }
 
-  @Test
+  @Test (expected = NoSuchElementException.class)
   public void testEmpty() {
     CompositeEnumeration<String> ce = new CompositeEnumeration<>();
     assertThat( ce.hasMoreElements(), is( false ) );
-
-    try {
-      ce.nextElement();
-      fail( "Should have throws NoSuchElementExcpetion" );
-    } catch( NoSuchElementException e ) {
-      // Expected.
-    }
+    ce.nextElement();
   }
 
-  @Test
+  @Test (expected = IllegalArgumentException.class)
   public void testNulls() {
-    try {
-      CompositeEnumeration<String> ce = new CompositeEnumeration<>( null );
-      fail( "Expected IllegalArgumentException" );
-    } catch( IllegalArgumentException e ) {
-      // Expected.
-    }
+    new CompositeEnumeration<>( null );
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/TestFilterChain.java
----------------------------------------------------------------------
diff --git a/gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/TestFilterChain.java b/gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/TestFilterChain.java
index e3b2378..e5a0d6e 100644
--- a/gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/TestFilterChain.java
+++ b/gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/TestFilterChain.java
@@ -28,7 +28,9 @@ import java.util.Stack;
 public class TestFilterChain extends Stack<Filter> implements FilterChain {
   @Override
   public void doFilter( ServletRequest request, ServletResponse response ) throws IOException, ServletException {
-    if( !isEmpty() ) pop().doFilter( request, response, this );
+    if( !isEmpty() ) {
+      pop().doFilter( request, response, this );
+    }
   }
 }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-server/src/test/java/org/apache/knox/gateway/AuditLoggingTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/AuditLoggingTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/AuditLoggingTest.java
index affd47d..861a886 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/AuditLoggingTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/AuditLoggingTest.java
@@ -30,7 +30,6 @@ import org.apache.knox.gateway.audit.log4j.audit.Log4jAuditService;
 import org.apache.knox.gateway.audit.log4j.correlation.Log4jCorrelationService;
 import org.apache.knox.gateway.config.GatewayConfig;
 import org.apache.knox.gateway.dispatch.DefaultDispatch;
-import org.apache.knox.gateway.i18n.resources.ResourcesFactory;
 import org.apache.knox.test.log.CollectAppender;
 import org.apache.log4j.spi.LoggingEvent;
 import org.easymock.EasyMock;
@@ -76,16 +75,14 @@ public class AuditLoggingTest {
   private static final String ADDRESS = "address";
   private static final String HOST = "host";
 
-  private static final GatewayResources RES = ResourcesFactory.get( GatewayResources.class );
-
   @Before
-  public void loggingSetup() {
+  public void setUp() {
     AuditServiceFactory.getAuditService().createContext();
     CollectAppender.queue.clear();
   }
 
   @After
-  public void reset() {
+  public void tearDown() {
     AuditServiceFactory.getAuditService().detachContext();
   }
 
@@ -291,11 +288,4 @@ public class AuditLoggingTest {
       assertThat( actual, is( expected ) );
     }
   }
-
-  private String getRequestId( LoggingEvent event ) {
-    CorrelationContext cc = (CorrelationContext) event
-        .getMDC( Log4jCorrelationService.MDC_CORRELATION_CONTEXT_KEY );
-    return cc == null ? null : cc.getRequestId();
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-server/src/test/java/org/apache/knox/gateway/GatewayFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/GatewayFilterTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/GatewayFilterTest.java
index 6f5129e..5e0d844 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/GatewayFilterTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/GatewayFilterTest.java
@@ -46,12 +46,12 @@ import static org.hamcrest.MatcherAssert.assertThat;
 public class GatewayFilterTest {
 
   @Before
-  public void setup() {
+  public void setUp() {
     AuditServiceFactory.getAuditService().createContext();
   }
 
   @After
-  public void reset() {
+  public void tearDown() {
     AuditServiceFactory.getAuditService().detachContext();
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-server/src/test/java/org/apache/knox/gateway/deploy/DeploymentFactoryTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/deploy/DeploymentFactoryTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/deploy/DeploymentFactoryTest.java
index a74a985..9fde6ad 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/deploy/DeploymentFactoryTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/deploy/DeploymentFactoryTest.java
@@ -36,10 +36,10 @@ import org.xml.sax.SAXException;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.IsEqual.equalTo;
 import static org.hamcrest.xml.HasXPath.hasXPath;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 public class DeploymentFactoryTest {
-
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )
   public void testEmptyTopology() throws IOException, SAXException, ParserConfigurationException, TransformerException {
     GatewayConfig config = new GatewayConfigImpl();
@@ -90,6 +90,9 @@ public class DeploymentFactoryTest {
       fail( "Expected DeploymentException" );
     } catch ( DeploymentException e ) {
       // Expected.
+      assertEquals("Topology test-topology contains both services and " +
+                       "an application test-application with a root url.",
+          e.getMessage());
     }
 
     topology = new Topology();
@@ -107,6 +110,9 @@ public class DeploymentFactoryTest {
       fail( "Expected DeploymentException" );
     } catch ( DeploymentException e ) {
       // Expected.
+      assertEquals("Topology test-topology contains both services and an " +
+                       "application test-application with a root url.",
+          e.getMessage());
     }
 
     topology = new Topology();
@@ -124,6 +130,9 @@ public class DeploymentFactoryTest {
       fail( "Expected DeploymentException" );
     } catch ( DeploymentException e ) {
       // Expected.
+      assertEquals("Topology test-topology contains both services and an " +
+                       "application test-application with a root url.",
+          e.getMessage());
     }
 
     topology = new Topology();
@@ -142,8 +151,10 @@ public class DeploymentFactoryTest {
       fail( "Expected DeploymentException" );
     } catch ( DeploymentException e ) {
       // Expected.
+      assertEquals("Topology test-topology contains both services and an " +
+                       "application test-application with a root url.",
+          e.getMessage());
     }
-
   }
 
   @Test( timeout = TestUtils.SHORT_TIMEOUT )
@@ -233,6 +244,10 @@ public class DeploymentFactoryTest {
       fail( "Expected DeploymentException" );
     } catch ( DeploymentException e ) {
       // Expected.
+      assertEquals("Topology test-topology contains applications " +
+                       "test-application-1 and test-application-2 with the " +
+                       "same url: /test-application-dup",
+          e.getMessage());
     }
 
     topology = new Topology();
@@ -250,6 +265,9 @@ public class DeploymentFactoryTest {
       fail( "Expected DeploymentException" );
     } catch ( DeploymentException e ) {
       // Expected.
+      assertEquals("Topology test-topology contains applications " +
+                       "test-application-1 and test-application-2 with the same url: /",
+          e.getMessage());
     }
 
     topology = new Topology();
@@ -267,6 +285,9 @@ public class DeploymentFactoryTest {
       fail( "Expected DeploymentException" );
     } catch ( DeploymentException e ) {
       // Expected.
+      assertEquals("Topology test-topology contains applications " +
+                       "test-application-1 and test-application-2 with the same url: ",
+          e.getMessage());
     }
 
     topology = new Topology();
@@ -283,6 +304,10 @@ public class DeploymentFactoryTest {
       fail( "Expected DeploymentException" );
     } catch ( DeploymentException e ) {
       // Expected.
+      assertEquals("Topology test-topology contains applications " +
+                       "test-application-1 and test-application-2 with the " +
+                       "same url: test-application-1",
+          e.getMessage());
     }
 
     topology = new Topology();
@@ -298,6 +323,10 @@ public class DeploymentFactoryTest {
       fail( "Expected DeploymentException" );
     } catch ( DeploymentException e ) {
       // Expected.
+      assertEquals("Topology test-topology contains applications " +
+                       "test-application-1 and test-application-1 with the " +
+                       "same url: test-application-1",
+          e.getMessage());
     }
 
     topology = new Topology();
@@ -317,8 +346,10 @@ public class DeploymentFactoryTest {
       fail( "Expected DeploymentException" );
     } catch ( DeploymentException e ) {
       // Expected.
+      assertEquals("Topology test-topology contains applications " +
+                       "test-application-1 and test-application-2 with the " +
+                       "same url: /test-application-3",
+          e.getMessage());
     }
-
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-server/src/test/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributorTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributorTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributorTest.java
index 16f0c55..10c635f 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributorTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributorTest.java
@@ -138,8 +138,8 @@ public class ServiceDefinitionDeploymentContributorTest {
     sddc.contributeService(context, service);
 
     List<ResourceDescriptor> resources = gd.resources();
-    assertEquals(1, gd.resources().size());
-    ResourceDescriptor res = gd.resources().get(0);
+    assertEquals(1, resources.size());
+    ResourceDescriptor res = resources.get(0);
     assertNotNull(res);
     List<FilterDescriptor> filterList = res.filters();
     assertEquals(1, filterList.size());
@@ -254,8 +254,8 @@ public class ServiceDefinitionDeploymentContributorTest {
     sddc.contributeService(context, service);
 
     List<ResourceDescriptor> resources = gd.resources();
-    assertEquals(1, gd.resources().size());
-    ResourceDescriptor res = gd.resources().get(0);
+    assertEquals(1, resources.size());
+    ResourceDescriptor res = resources.get(0);
     assertNotNull(res);
     List<FilterDescriptor> filterList = res.filters();
     assertEquals(1, filterList.size());

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-server/src/test/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityServiceTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityServiceTest.java
index 24f1665..2251f16 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityServiceTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityServiceTest.java
@@ -40,7 +40,6 @@ public class DefaultTokenAuthorityServiceTest extends org.junit.Assert {
 
   @Test
   public void testTokenCreation() throws Exception {
-
     Principal principal = EasyMock.createNiceMock(Principal.class);
     EasyMock.expect(principal.getName()).andReturn("john.doe@example.com");
 
@@ -82,7 +81,6 @@ public class DefaultTokenAuthorityServiceTest extends org.junit.Assert {
 
   @Test
   public void testTokenCreationAudience() throws Exception {
-
     Principal principal = EasyMock.createNiceMock(Principal.class);
     EasyMock.expect(principal.getName()).andReturn("john.doe@example.com");
 
@@ -125,7 +123,6 @@ public class DefaultTokenAuthorityServiceTest extends org.junit.Assert {
 
   @Test
   public void testTokenCreationNullAudience() throws Exception {
-
     Principal principal = EasyMock.createNiceMock(Principal.class);
     EasyMock.expect(principal.getName()).andReturn("john.doe@example.com");
 
@@ -167,7 +164,6 @@ public class DefaultTokenAuthorityServiceTest extends org.junit.Assert {
 
   @Test
   public void testTokenCreationSignatureAlgorithm() throws Exception {
-
     Principal principal = EasyMock.createNiceMock(Principal.class);
     EasyMock.expect(principal.getName()).andReturn("john.doe@example.com");
 
@@ -208,9 +204,8 @@ public class DefaultTokenAuthorityServiceTest extends org.junit.Assert {
     assertTrue(ta.verifyToken(token));
   }
 
-  @Test
+  @Test (expected = TokenServiceException.class)
   public void testTokenCreationBadSignatureAlgorithm() throws Exception {
-
     Principal principal = EasyMock.createNiceMock(Principal.class);
     EasyMock.expect(principal.getName()).andReturn("john.doe@example.com");
 
@@ -242,13 +237,7 @@ public class DefaultTokenAuthorityServiceTest extends org.junit.Assert {
     ta.setKeystoreService(ks);
 
     ta.init(config, new HashMap<>());
-
-    try {
-      ta.issueToken(principal, "none");
-      fail("Failure expected on a bad signature algorithm");
-    } catch (TokenServiceException ex) {
-        // expected
-    }
+    ta.issueToken(principal, "none");
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java
index 99dd6d4..c0b861e 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java
@@ -21,8 +21,6 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.monitor.FileAlterationListener;
-import org.apache.commons.io.monitor.FileAlterationMonitor;
-import org.apache.commons.io.monitor.FileAlterationObserver;
 import org.apache.knox.gateway.config.GatewayConfig;
 import org.apache.knox.gateway.services.topology.impl.DefaultTopologyService;
 import org.apache.knox.gateway.services.security.AliasService;
@@ -62,7 +60,6 @@ import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 public class DefaultTopologyServiceTest {
-
   private File createDir() throws IOException {
     return TestUtils.createTempDir(this.getClass().getSimpleName() + "-");
   }
@@ -101,7 +98,6 @@ public class DefaultTopologyServiceTest {
       createFile(topologyDir, "one.xml", "org/apache/knox/gateway/topology/file/topology-one.xml", time);
 
       TestTopologyListener topoListener = new TestTopologyListener();
-      FileAlterationMonitor monitor = new FileAlterationMonitor(Long.MAX_VALUE);
 
       TopologyService provider = new DefaultTopologyService();
       Map<String, String> c = new HashMap<>();
@@ -203,7 +199,6 @@ public class DefaultTopologyServiceTest {
 
     try {
       TestTopologyListener topoListener = new TestTopologyListener();
-      FileAlterationMonitor monitor = new FileAlterationMonitor(Long.MAX_VALUE);
 
       DefaultTopologyService provider = new DefaultTopologyService();
       Map<String, String> c = new HashMap<>();
@@ -322,7 +317,6 @@ public class DefaultTopologyServiceTest {
 
     try {
       TestTopologyListener topoListener = new TestTopologyListener();
-      FileAlterationMonitor monitor = new FileAlterationMonitor(Long.MAX_VALUE);
 
       TopologyService ts = new DefaultTopologyService();
       Map<String, String> c = new HashMap<>();
@@ -415,7 +409,6 @@ public class DefaultTopologyServiceTest {
 
     try {
       TestTopologyListener topoListener = new TestTopologyListener();
-      FileAlterationMonitor monitor = new FileAlterationMonitor(Long.MAX_VALUE);
 
       TopologyService ts = new DefaultTopologyService();
       Map<String, String> c = new HashMap<>();
@@ -544,12 +537,6 @@ public class DefaultTopologyServiceTest {
     }
   }
 
-  private void kickMonitor(FileAlterationMonitor monitor) {
-    for (FileAlterationObserver observer : monitor.getObservers()) {
-      observer.checkAndNotify();
-    }
-  }
-
   @Test
   public void testProviderParamsOrderIsPreserved() {
 
@@ -580,14 +567,12 @@ public class DefaultTopologyServiceTest {
   }
 
   private class TestTopologyListener implements TopologyListener {
-
-    ArrayList<List<TopologyEvent>> events = new ArrayList<>();
+    List<List<TopologyEvent>> events = new ArrayList<>();
 
     @Override
     public void handleTopologyEvent(List<TopologyEvent> events) {
       this.events.add(events);
     }
-
   }
 
   private class TestTopologyDeleteListener implements TopologyListener {

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-server/src/test/java/org/apache/knox/gateway/topology/builder/PropertyTopologyBuilderTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/builder/PropertyTopologyBuilderTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/topology/builder/PropertyTopologyBuilderTest.java
index 1a6bb3b..8896dc3 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/builder/PropertyTopologyBuilderTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/builder/PropertyTopologyBuilderTest.java
@@ -35,12 +35,12 @@ public class PropertyTopologyBuilderTest {
   private static Enumeration<Appender> realAppenders;
 
   @BeforeClass
-  public static void setup() {
+  public static void setUpBeforeClass() {
     realAppenders = NoOpAppender.setUpAndReturnOriginalAppenders();
   }
 
   @AfterClass
-  public static void teardown() {
+  public static void tearDownAfterClass() {
     NoOpAppender.resetOriginalAppenders( realAppenders );
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/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 6a118a1..026adab 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
@@ -21,10 +21,10 @@ import org.easymock.EasyMock;
 import org.junit.Test;
 
 import java.io.File;
-import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 
@@ -32,7 +32,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
-
 public class PropertiesFileServiceDiscoveryTest {
 
     private static final Map<String, String> clusterProperties = new HashMap<>();
@@ -57,7 +56,6 @@ public class PropertiesFileServiceDiscoveryTest {
         }
     }
 
-
     @Test
     public void testPropertiesFileServiceDiscovery() throws Exception {
         ServiceDiscovery sd = ServiceDiscoveryFactory.get("PROPERTIES_FILE");
@@ -68,8 +66,8 @@ public class PropertiesFileServiceDiscoveryTest {
 
         String discoveryAddress = this.getClass().getName() + "__test-discovery-source.properties";
         File discoverySource = new File(discoveryAddress);
-        try {
-            config.store(new FileOutputStream(discoverySource), "Test discovery source for PropertiesFileServiceDiscovery");
+        try (OutputStream outputStream = Files.newOutputStream(discoverySource.toPath())){
+            config.store(outputStream, "Test discovery source for PropertiesFileServiceDiscovery");
 
             ServiceDiscovery.Cluster c =
                     sd.discover(gc, new DefaultServiceDiscoveryConfig(discoverySource.getAbsolutePath()), "mycluster");
@@ -101,18 +99,4 @@ public class PropertiesFileServiceDiscoveryTest {
             discoverySource.delete();
         }
     }
-
-
-    private void printServiceURLs(ServiceDiscovery.Cluster cluster, String...services) {
-        for (String name : services) {
-            StringBuilder value = new StringBuilder();
-            List<String> urls = cluster.getServiceURLs(name);
-            if (urls != null && !urls.isEmpty()) {
-                for (String url : urls) {
-                    value.append(url).append(" ");
-                }
-            }
-            System.out.println(String.format(Locale.ROOT, "%18s: %s", name, value.toString()));
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/test/extension/PropertiesFileServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/test/extension/PropertiesFileServiceDiscovery.java b/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/test/extension/PropertiesFileServiceDiscovery.java
index fa9a717..e5ad8f3 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/test/extension/PropertiesFileServiceDiscovery.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/discovery/test/extension/PropertiesFileServiceDiscovery.java
@@ -23,8 +23,10 @@ import org.apache.knox.gateway.topology.discovery.GatewayService;
 import org.apache.knox.gateway.topology.discovery.ServiceDiscovery;
 import org.apache.knox.gateway.topology.discovery.ServiceDiscoveryConfig;
 
-import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -50,8 +52,8 @@ class PropertiesFileServiceDiscovery implements ServiceDiscovery {
         Map<String, ServiceDiscovery.Cluster> result = new HashMap<>();
 
         Properties p = new Properties();
-        try {
-            p.load(new FileInputStream(discoveryConfig.getAddress()));
+        try (InputStream inputStream = Files.newInputStream(Paths.get(discoveryConfig.getAddress()))){
+            p.load(inputStream);
 
             Map<String, Map<String, Map<String, String>>> clusterProperties = new HashMap<>();
             Map<String, Map<String, List<String>>> clusterURLs = new HashMap<>();
@@ -68,7 +70,7 @@ class PropertiesFileServiceDiscovery implements ServiceDiscovery {
                     }
                     String serviceName = parts[1];
                     String property    = parts[2];
-                    if (property.equals("url")) {
+                    if ("url".equals(property)) {
                         String serviceURL = p.getProperty(propertyKey);
                         Map<String, List<String>> serviceURLs = clusterURLs.get(clusterName);
                         if (!serviceURLs.containsKey(serviceName)) {
@@ -80,7 +82,7 @@ class PropertiesFileServiceDiscovery implements ServiceDiscovery {
                         for (String url : svcURLs) {
                           serviceURLs.get(serviceName).add(url);
                         }
-                    } else if (!property.equalsIgnoreCase("name")) { // ZooKeeper config properties
+                    } else if (!"name".equalsIgnoreCase(property)) { // ZooKeeper config properties
                         Map<String, Map<String, String>> props = clusterProperties.get(clusterName);
                         if (!props.containsKey(serviceName)) {
                             props.put(serviceName, new HashMap<>());


Mime
View raw message