knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject knox git commit: [KNOX-685] - Knox tests cleanup after Jetty 9 upgrade. More debug logging.
Date Wed, 09 Mar 2016 15:58:04 GMT
Repository: knox
Updated Branches:
  refs/heads/master 8706baa1d -> 5bd464f52


[KNOX-685] - Knox tests cleanup after Jetty 9 upgrade. More debug logging.


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/5bd464f5
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/5bd464f5
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/5bd464f5

Branch: refs/heads/master
Commit: 5bd464f5200c8184b24feed158002677be1a1584
Parents: 8706baa
Author: Kevin Minder <kminder@apache.org>
Authored: Wed Mar 9 10:57:13 2016 -0500
Committer: Kevin Minder <kminder@apache.org>
Committed: Wed Mar 9 10:57:13 2016 -0500

----------------------------------------------------------------------
 .../function/UsernameFunctionProcessorTest.java | 17 +++++--
 .../impl/ServiceRegistryFunctionsTest.java      | 15 +++++-
 .../api/UrlRewriteServletFilterTest.java        | 51 ++++++++++++--------
 .../impl/FrontendFunctionProcessorTest.java     | 15 +++++-
 .../hadoop/gateway/GatewayMultiFuncTest.java    | 20 ++------
 5 files changed, 74 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/5bd464f5/gateway-provider-identity-assertion-common/src/test/java/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/test/java/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
b/gateway-provider-identity-assertion-common/src/test/java/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
index 18ca52d..1f6d4ec 100644
--- a/gateway-provider-identity-assertion-common/src/test/java/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
+++ b/gateway-provider-identity-assertion-common/src/test/java/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
@@ -50,6 +50,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -119,6 +120,16 @@ public class UsernameFunctionProcessorTest {
     }
   }
 
+  private void execute() throws Exception {
+    System.out.println( "REQUEST=" + request );
+    ByteBuffer requestBuffer = request.generate();
+    System.out.println( "REQUEST-BUFFER=[" + new String(requestBuffer.array(),0,requestBuffer.limit())
+ "]" );
+    ByteBuffer responseBuffer = server.getResponses( requestBuffer );
+    response = HttpTester.parseResponse( responseBuffer );
+    System.out.println( "RESPONSE-BUFFER=[" + new String(responseBuffer.array(),0,responseBuffer.limit())
+ "]" );
+    System.out.println( "RESPONSE=" + response );
+  }
+
   @Test
   public void testInitialize() throws Exception {
     UsernameFunctionProcessor processor = new UsernameFunctionProcessor();
@@ -181,10 +192,8 @@ public class UsernameFunctionProcessorTest {
         .queryParam( "test-query-input-name", "test-query-input-value" )
         .queryParam( "test-query-output-name", "test-query-output-value" )
         .contentType( "text/xml" )
-        .characterEncoding( "UTF-8" )
         .content( expect, Charset.forName( "UTF-8" ) );
-    interaction.respond()
-        .status( 200 );
+    interaction.respond().status( 200 );
     interactions.add( interaction );
     request.setMethod( "PUT" );
     request.setURI( "/test-input-path?test-query-input-name=test-query-input-value" );
@@ -193,7 +202,7 @@ public class UsernameFunctionProcessorTest {
     request.setHeader( "Content-Type", "text/xml; charset=UTF-8" );
     request.setContent( input );
 
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), Is.is( 200 ) );

http://git-wip-us.apache.org/repos/asf/knox/blob/5bd464f5/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
index c7b6312..6035605 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
@@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -112,6 +113,16 @@ public class ServiceRegistryFunctionsTest {
     response = null;
   }
 
+  private void execute() throws Exception {
+    System.out.println( "REQUEST=" + request );
+    ByteBuffer requestBuffer = request.generate();
+    System.out.println( "REQUEST-BUFFER=[" + new String(requestBuffer.array(),0,requestBuffer.limit())
+ "]" );
+    ByteBuffer responseBuffer = server.getResponses( requestBuffer );
+    response = HttpTester.parseResponse( responseBuffer );
+    System.out.println( "RESPONSE-BUFFER=[" + new String(responseBuffer.array(),0,responseBuffer.limit())
+ "]" );
+    System.out.println( "RESPONSE=" + response );
+  }
+
   @Test
   public void testServiceRegistryFunctionsOnXmlRequestBody() throws Exception {
     Map<String,String> initParams = new HashMap<String,String>();
@@ -138,7 +149,7 @@ public class ServiceRegistryFunctionsTest {
     request.setHeader( "Content-Type", "text/xml; charset=UTF-8" );
     request.setContent( input );
 
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), Is.is( 200 ) );
@@ -170,7 +181,7 @@ public class ServiceRegistryFunctionsTest {
     request.setHeader( "Content-Type", "application/json; charset=UTF-8" );
     request.setContent( input );
 
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), Is.is( 200 ) );

http://git-wip-us.apache.org/repos/asf/knox/blob/5bd464f5/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
b/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
index 82524ee..6c61e93 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
@@ -47,6 +47,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.util.EnumSet;
 import java.util.Enumeration;
@@ -114,6 +115,16 @@ public class UrlRewriteServletFilterTest {
     }
   }
 
+  private void execute() throws Exception {
+    System.out.println( "REQUEST=" + request );
+    ByteBuffer requestBuffer = request.generate();
+    System.out.println( "REQUEST-BUFFER=[" + new String(requestBuffer.array(),0,requestBuffer.limit())
+ "]" );
+    ByteBuffer responseBuffer = server.getResponses( requestBuffer );
+    response = HttpTester.parseResponse( responseBuffer );
+    System.out.println( "RESPONSE-BUFFER=[" + new String(responseBuffer.array(),0,responseBuffer.limit())
+ "]" );
+    System.out.println( "RESPONSE=" + response );
+  }
+
   @Test
   public void testInboundRequestUrlRewrite() throws Exception {
     setUp( null );
@@ -129,7 +140,7 @@ public class UrlRewriteServletFilterTest {
     //request.setVersion( "HTTP/1.1" );
     request.setHeader( "Host", "mock-host:1" );
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -154,7 +165,7 @@ public class UrlRewriteServletFilterTest {
     request.setHeader( "Host", "mock-host:1" );
     request.setHeader( "Location", "http://mock-host:1/test-input-path" );
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -177,7 +188,7 @@ public class UrlRewriteServletFilterTest {
     //request.setVersion( "HTTP/1.1" );
     request.setHeader( "Host", "mock-host:1" );
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 201 ) );
@@ -204,7 +215,7 @@ public class UrlRewriteServletFilterTest {
     request.setHeader( "Cookie", "cookie-name=cookie-value; Domain=docs.foo.com; Path=/accounts;
Expires=Wed, 13-Jan-2021 22:23:01 GMT; Secure; HttpOnly" );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 201 ) );
@@ -230,7 +241,7 @@ public class UrlRewriteServletFilterTest {
     request.setHeader( "Host", "mock-host:1" );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -261,7 +272,7 @@ public class UrlRewriteServletFilterTest {
     request.setContent( inputJson );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -293,7 +304,7 @@ public class UrlRewriteServletFilterTest {
     request.setContent( input );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -322,7 +333,7 @@ public class UrlRewriteServletFilterTest {
     request.setHeader( "Host", "mock-host:1" );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -352,7 +363,7 @@ public class UrlRewriteServletFilterTest {
     request.setContent( input );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -381,7 +392,7 @@ public class UrlRewriteServletFilterTest {
     request.setContent( input );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -414,7 +425,7 @@ public class UrlRewriteServletFilterTest {
     request.setContent( input );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -449,7 +460,7 @@ public class UrlRewriteServletFilterTest {
     request.setContent( input );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -489,7 +500,7 @@ public class UrlRewriteServletFilterTest {
     request.setContent( inputJson );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -522,7 +533,7 @@ public class UrlRewriteServletFilterTest {
     request.setContent( input );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -558,7 +569,7 @@ public class UrlRewriteServletFilterTest {
       request.setContent( input );
 
       // Execute the request.
-      response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+      execute();
 
       // Test the results.
       assertThat( response.getStatus(), is( 500 ) );
@@ -593,7 +604,7 @@ public class UrlRewriteServletFilterTest {
     request.setContent( input );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );
@@ -623,7 +634,7 @@ public class UrlRewriteServletFilterTest {
     request.setHeader( "Host", "mock-host:42" );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 307 ) );
@@ -668,7 +679,7 @@ public class UrlRewriteServletFilterTest {
     request.setContent( responseJson );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     assertThat( response.getStatus(), is( 200 ) );
     JsonAssert.with( response.getContent() ).assertThat( "$.url", is( "http://mock-host:42/test-output-path-2"
) );
@@ -693,11 +704,11 @@ public class UrlRewriteServletFilterTest {
     interactions.add( interaction );
     request.setMethod( "GET" );
     request.setURI( "/test-input-path" );
-    //request.setVersion( "HTTP/1.1" );
+    request.setVersion( "HTTP/1.0" );
     request.setHeader( "Host", "mock-host:42" );
 
     // Execute the request.
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     // Test the results.
     assertThat( response.getStatus(), is( 200 ) );

http://git-wip-us.apache.org/repos/asf/knox/blob/5bd464f5/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/impl/FrontendFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/impl/FrontendFunctionProcessorTest.java
b/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/impl/FrontendFunctionProcessorTest.java
index d755514..f245836 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/impl/FrontendFunctionProcessorTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/impl/FrontendFunctionProcessorTest.java
@@ -56,6 +56,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -79,6 +80,16 @@ public class FrontendFunctionProcessorTest {
   private ArrayQueue<MockInteraction> interactions;
   private MockInteraction interaction;
 
+  private void execute() throws Exception {
+    System.out.println( "REQUEST=" + request );
+    ByteBuffer requestBuffer = request.generate();
+    System.out.println( "REQUEST-BUFFER=[" + new String(requestBuffer.array(),0,requestBuffer.limit())
+ "]" );
+    ByteBuffer responseBuffer = server.getResponses( requestBuffer );
+    response = HttpTester.parseResponse( responseBuffer );
+    System.out.println( "RESPONSE-BUFFER=[" + new String(responseBuffer.array(),0,responseBuffer.limit())
+ "]" );
+    System.out.println( "RESPONSE=" + response );
+  }
+
   @SuppressWarnings("rawtypes")
   @Test
   public void testServiceLoader() throws Exception {
@@ -192,7 +203,7 @@ public class FrontendFunctionProcessorTest {
     //request.setVersion( "HTTP/1.1" );
     request.setHeader( "Host", "test-host:42" );
 
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     assertThat( response.getStatus(), Is.is( 200 ) );
 
@@ -237,7 +248,7 @@ public class FrontendFunctionProcessorTest {
     //request.setVersion( "HTTP/1.1" );
     request.setHeader( "Host", "test-host:42" );
 
-    response = HttpTester.parseResponse( server.getResponses( request.generate() ) );
+    execute();
 
     assertThat( response.getStatus(), Is.is( 200 ) );
 

http://git-wip-us.apache.org/repos/asf/knox/blob/5bd464f5/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
index 3271dab..7ae7c71 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
@@ -65,6 +65,7 @@ import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
 import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
@@ -187,7 +188,7 @@ public class GatewayMultiFuncTest {
     String pword = uname + "-password";
 
     mock.expect().method( "GET" )
-        .respond().contentType( "application/json" ).contentLength( -1 ).content( "{\"msg\":\"H\u00eallo\"}",
Charset.forName( "UTF8" ) );
+        .respond().contentType( "application/json" ).contentLength( -1 ).content( "{\"msg\":\"H\u00eallo\"}",
Charset.forName( "UTF-8" ) );
     given()
         //.log().all()
         .auth().preemptive().basic( uname, pword )
@@ -195,19 +196,7 @@ public class GatewayMultiFuncTest {
         //.log().all()
         .statusCode( HttpStatus.SC_OK )
         .body( "msg", is( "H\u00eallo" ) )
-        .when().get( gatewayUrl + "/knox678/repeat" );
-    assertThat( mock.isEmpty(), is(true) );
-
-    mock.expect().method( "GET" )
-        .respond().contentType( "application/json" ).contentLength( -1 ).content( "{\"msg\":\"H\u00eallo\"}",
Charset.forName( "UTF8" ) );
-    given()
-        //.log().all()
-        .auth().preemptive().basic( uname, pword )
-        .expect()
-        //.log().all()
-        .statusCode( HttpStatus.SC_OK )
-        .body( "msg", is( "H\u00eallo" ) )
-        .when().get( gatewayUrl + "/knox678/repeat" );
+        .when().log().ifError().get( gatewayUrl + "/knox678/repeat" );
     assertThat( mock.isEmpty(), is(true) );
 
     mock.expect().method( "GET" )
@@ -218,8 +207,7 @@ public class GatewayMultiFuncTest {
         .expect()
         //.log().all()
         .statusCode( HttpStatus.SC_OK )
-        //.contentType( "application/octet-stream" )
-        .when().get( gatewayUrl + "/knox678/repeat" ).andReturn().asByteArray();
+        .when().log().ifError().get( gatewayUrl + "/knox678/repeat" ).andReturn().asByteArray();
     assertThat( body, is(equalTo("H\u00eallo".getBytes())) );
     assertThat( mock.isEmpty(), is(true) );
 


Mime
View raw message