Repository: knox
Updated Branches:
  refs/heads/master 59954fb32 -> 89caa5fee


http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/AuditServiceTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/AuditServiceTest.java
 
b/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/AuditServiceTest.java
index a1b7076..039856d 100644
--- 
a/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/AuditServiceTest.java
+++ 
b/gateway-util-common/src/test/java/org/apache/knox/gateway/audit/AuditServiceTest.java
@@ -55,12 +55,12 @@ public class AuditServiceTest {
   private String targetServiceName = "service";
 
   @Before
-  public void setup() {
-    cleanup();
+  public void setUp() {
+    tearDown();
   }
 
   @After
-  public void cleanup() {
+  public void tearDown() {
     CollectAppender.queue.clear();
     LogManager.shutdown();
     String absolutePath = "target/audit";

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/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 47f1f92..cbe604c 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
@@ -26,10 +26,7 @@ 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;
@@ -40,19 +37,18 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
 
 public class JdbmQueueTest {
-
   private File file;
   private JdbmQueue<String> queue;
 
   @Before
-  public void setup() throws IOException {
+  public void setUp() throws IOException {
     file = new File( "target/JdbmQueueTest" );
-    cleanup();
+    tearDown();
     queue = new JdbmQueue<>( file );
   }
 
   @After
-  public void cleanup() throws IOException {
+  public void tearDown() throws IOException {
     if( queue != null ) {
       queue.close();
       queue = null;
@@ -96,75 +92,6 @@ public class JdbmQueueTest {
     assertThat( counter.get(), is( 1 ) );
   }
 
-//  @Ignore
-//  @Test
-//  public void testPerformanceAndStorageFootprint() throws IOException, 
InterruptedException {
-//    System.out.println( "Running " + 
Thread.currentThread().getStackTrace()[1].getClassName() + "#" + 
Thread.currentThread().getStackTrace()[1].getMethodName() );
-//
-//    String fill = createFillString( 100 );
-//    File dbFile = new File( file.getAbsolutePath() + ".db" );
-//    File lgFile = new File( file.getAbsolutePath() + ".lg" );
-//
-//    String s = null;
-//    long writeCount = 0;
-//    long writeTime = 0;
-//    long before;
-//
-//    int iterations = 10000;
-//
-//    for( int i=0; i<iterations; i++ ) {
-//      s = UUID.randomUUID().toString() + ":" + fill;
-//      before = System.currentTimeMillis();
-//      queue.enqueue( s );
-//      writeTime += ( System.currentTimeMillis() - before );
-//      writeCount++;
-//    }
-//
-//    System.out.println( String.format( "Line: len=%d", s.length() ) );
-//    System.out.println( String.format( "Perf: avg=%.4fs, tot=%.2fs, cnt=%d", 
( (double)writeTime / (double)writeCount / 1000.0 ),  (double)writeTime/1000.0, 
writeCount ) );
-//    System.out.println( String.format(
-//        "File: db=%s, lg=%s, tot=%s, per=%s",
-//        humanReadableSize( dbFile.length() ),
-//        humanReadableSize( lgFile.length() ),
-//        humanReadableSize( dbFile.length() + lgFile.length() ),
-//        humanReadableSize( ( ( dbFile.length() + lgFile.length() ) / 
writeCount ) ) ) );
-//  }
-
-//  @Ignore
-//  @Test
-//  public void testFileGrowth() throws IOException, InterruptedException {
-//    System.out.println( "Running " + 
Thread.currentThread().getStackTrace()[1].getClassName() + "#" + 
Thread.currentThread().getStackTrace()[1].getMethodName() );
-//
-//    String fill = createFillString( 100 );
-//    File dbFile = new File( file.getAbsolutePath() + ".db" );
-//    File lgFile = new File( file.getAbsolutePath() + ".lg" );
-//
-//    String s = null;
-//    long writeCount = 0;
-//    long writeTime = 0;
-//    long before;
-//
-//    int iterations = 10000;
-//
-//    for( int i=0; i<iterations; i++ ) {
-//      s = UUID.randomUUID().toString() + ":" + fill;
-//      before = System.currentTimeMillis();
-//      queue.enqueue( s );
-//      assertThat( queue.dequeue(), is( s ) );
-//      writeTime += ( System.currentTimeMillis() - before );
-//      writeCount++;
-//    }
-//
-//    System.out.println( String.format( "Line: len=%d", s.length() ) );
-//    System.out.println( String.format( "Perf: avg=%.4fs, tot=%.2fs, cnt=%d", 
( (double)writeTime / (double)writeCount / 1000.0 ),  (double)writeTime/1000.0, 
writeCount ) );
-//    System.out.println( String.format(
-//        "File: db=%s, lg=%s, tot=%s, per=%s",
-//        humanReadableSize( dbFile.length() ),
-//        humanReadableSize( lgFile.length() ),
-//        humanReadableSize( dbFile.length() + lgFile.length() ),
-//        humanReadableSize( ( ( dbFile.length() + lgFile.length() ) / 
writeCount ) ) ) );
-//  }
-
   @Test( timeout = 120000 )
   public void testConcurrentConsumer() throws InterruptedException, 
IOException {
     System.out.println( "Running " + 
Thread.currentThread().getStackTrace()[1].getClassName() + "#" + 
Thread.currentThread().getStackTrace()[1].getMethodName() );
@@ -209,6 +136,7 @@ public class JdbmQueueTest {
     assertThat( consumed, hasSize( iterations * 2 ) );
   }
 
+  @SuppressWarnings("PMD.DoNotUseThreads")
   public class Producer extends Thread {
     public int iterations;
     public Producer( int iterations ) {
@@ -226,6 +154,7 @@ public class JdbmQueueTest {
     }
   }
 
+  @SuppressWarnings("PMD.DoNotUseThreads")
   public class Consumer extends Thread {
     public Set<String> consumed;
     public Consumer( Set<String> consumed ) {
@@ -251,6 +180,7 @@ public class JdbmQueueTest {
     }
   }
 
+  @SuppressWarnings("PMD.DoNotUseThreads")
   public class Processor extends Thread {
     public Set<String> consumed;
     public Processor( Set<String> consumed ) {
@@ -281,22 +211,4 @@ public class JdbmQueueTest {
       }
     }
   }
-
-  public static String humanReadableSize( long size ) {
-    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.#", 
DecimalFormatSymbols.getInstance(Locale.getDefault()))
-        .format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
-  }
-
-  public static String createFillString( int size ) {
-    StringBuilder s = new StringBuilder();
-    for( int i=0; i<size; i++ ) {
-      s.append( UUID.randomUUID().toString() );
-      s.append( "+" );
-    }
-    return s.toString();
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-util-common/src/test/java/org/apache/knox/gateway/util/JsonPathTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-util-common/src/test/java/org/apache/knox/gateway/util/JsonPathTest.java
 
b/gateway-util-common/src/test/java/org/apache/knox/gateway/util/JsonPathTest.java
index 4569647..89ee5c1 100644
--- 
a/gateway-util-common/src/test/java/org/apache/knox/gateway/util/JsonPathTest.java
+++ 
b/gateway-util-common/src/test/java/org/apache/knox/gateway/util/JsonPathTest.java
@@ -35,6 +35,7 @@ import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.hamcrest.CoreMatchers.sameInstance;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 public class JsonPathTest {
@@ -67,9 +68,9 @@ public class JsonPathTest {
         fail( "Expected IllegalArgumentException" );
       } catch( IllegalArgumentException e ) {
         // Expected exception
+        assertNotNull(e);
       }
     }
-
   }
 
   @Test
@@ -91,9 +92,9 @@ public class JsonPathTest {
         fail( "Expected IllegalArgumentException for " + path );
       } catch( IllegalArgumentException e ) {
         // Expected.
+        assertNotNull(e);
       }
     }
-
   }
 
   @Test
@@ -475,12 +476,9 @@ public class JsonPathTest {
   @Test
   public void testEvaluateArrays() throws IOException {
     String json;
-    JsonPath.Segment seg;
     List<JsonPath.Match> matches;
     JsonPath.Match match;
-    JsonPath.Match parent;
     JsonNode root;
-    JsonNode node;
     JsonPath.Expression expression;
 
     JsonFactory factory = new JsonFactory();
@@ -535,11 +533,8 @@ public class JsonPathTest {
   @Test
   public void testGlobMatching() throws IOException {
     String json;
-    JsonPath.Segment seg;
     List<JsonPath.Match> matches;
-    JsonPath.Match parent;
     JsonNode root;
-    JsonNode node;
     JsonPath.Expression expression;
     Set<String> matchValues;
 
@@ -575,7 +570,5 @@ public class JsonPathTest {
     assertThat( matchValues, hasItem( "value-C" ) );
     assertThat( matchValues, hasItem( "value-D" ) );
     assertThat( matchValues, hasItem( "value-E" ) );
-
   }
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-util-configinjector/src/test/java/org/apache/knox/gateway/config/FuncTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-util-configinjector/src/test/java/org/apache/knox/gateway/config/FuncTest.java
 
b/gateway-util-configinjector/src/test/java/org/apache/knox/gateway/config/FuncTest.java
index 3452c95..849a807 100755
--- 
a/gateway-util-configinjector/src/test/java/org/apache/knox/gateway/config/FuncTest.java
+++ 
b/gateway-util-configinjector/src/test/java/org/apache/knox/gateway/config/FuncTest.java
@@ -236,6 +236,7 @@ public class FuncTest {
   @Test
   public void testMissingRequiredFieldConfiguration() {
     class RequiredFieldTarget {
+      @SuppressWarnings("unused")
       @Configure
       private String required;
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/ExpanderTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/ExpanderTest.java
 
b/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/ExpanderTest.java
index ba95056..59527da 100644
--- 
a/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/ExpanderTest.java
+++ 
b/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/ExpanderTest.java
@@ -310,9 +310,12 @@ public class ExpanderTest {
     assertThat( expandedString, equalTo( 
"schemeA://host/{path=*]?query=queryA" ) );
     try {
       expandedUri = Expander.expand( template, params, null );
+      assertNotNull(expandedUri);
       fail( "Should have thrown exception" );
     } catch( URISyntaxException e ) {
       // Expected.
+      assertThat("Illegal character in path at index 15: 
schemeA://host/{path=*]?query=queryA",
+          is(e.getMessage()));
     }
 
     template = Parser.parseTemplate( "{scheme}://host/{path=**}?{query=**}" );

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/MatcherTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/MatcherTest.java
 
b/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/MatcherTest.java
index cc37da7..b09f04b 100644
--- 
a/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/MatcherTest.java
+++ 
b/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/MatcherTest.java
@@ -795,7 +795,6 @@ public class MatcherTest {
   public void testMultipleDoubleStarPathMatching() throws URISyntaxException {
     Template template;
     Template input;
-    Matcher<?> matcher;
     Matcher<String> stringMatcher;
     Matcher<?>.Match match;
 
@@ -1004,5 +1003,4 @@ public class MatcherTest {
     assertThat( expandedStr, containsString( "createparent=true" ) );
     assertThat( expandedStr, containsString( "&" ) );
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/RewriterTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/RewriterTest.java
 
b/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/RewriterTest.java
index 91e44d3..15db534 100644
--- 
a/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/RewriterTest.java
+++ 
b/gateway-util-urltemplate/src/test/java/org/apache/knox/gateway/util/urltemplate/RewriterTest.java
@@ -369,7 +369,7 @@ public class RewriterTest {
     final Map<String, String> parameter_pairs = new LinkedHashMap<>();
     final String[] pairs = url.getQuery().split("&");
     for (String pair : pairs) {
-       final int idx = pair.indexOf("=");
+       final int idx = pair.indexOf('=');
        final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), 
StandardCharsets.UTF_8.name()) : pair;
        final String value = idx > 0 && pair.length() > idx + 1 ? 
URLDecoder.decode(pair.substring(idx + 1), StandardCharsets.UTF_8.name()) : "";
        parameter_pairs.put(key, value);
@@ -382,7 +382,7 @@ public class RewriterTest {
     private FilterConfig config;
     private HttpServletRequest request;
 
-    private TestResolver( FilterConfig config, HttpServletRequest request ) {
+    TestResolver( FilterConfig config, HttpServletRequest request ) {
       this.config = config;
       this.request = request;
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 416ffb9..a5fc9d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -631,6 +631,7 @@
                         <ruleset>build-tools/pmd/pmd-ruleset.xml</ruleset>
                     </rulesets>
                     <printFailingErrors>true</printFailingErrors>
+                    <includeTests>true</includeTests>
                     <linkXRef>false</linkXRef>
                     <targetJdk>1.8</targetJdk>
                 </configuration>
@@ -699,6 +700,7 @@
                     <rulesets>
                         <ruleset>build-tools/pmd/pmd-ruleset.xml</ruleset>
                     </rulesets>
+                    <includeTests>true</includeTests>
                     <linkXRef>false</linkXRef>
                     <targetJdk>1.8</targetJdk>
                 </configuration>

Reply via email to