knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject knox git commit: KNOX-637 - Compilation Error in gateway-service-admin and gateway-test test projects (arshad.mohammad via lmccay)
Date Sat, 05 Dec 2015 22:46:41 GMT
Repository: knox
Updated Branches:
  refs/heads/master 18a2eecd7 -> 0a919c0b1


KNOX-637 - Compilation Error in gateway-service-admin and gateway-test test projects (arshad.mohammad
via lmccay)

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

Branch: refs/heads/master
Commit: 0a919c0b100d22bb0252ec8bac25b197f8ee87e4
Parents: 18a2eec
Author: Larry McCay <larry.mccay@oracle.com>
Authored: Sat Dec 5 17:46:30 2015 -0500
Committer: Larry McCay <larry.mccay@oracle.com>
Committed: Sat Dec 5 17:46:30 2015 -0500

----------------------------------------------------------------------
 .../TopologyResourceTest.java                   | 185 -------------------
 .../service/admin/TopologyResourceTest.java     | 185 +++++++++++++++++++
 .../gateway/KnoxCliLdapFuncTestNegative.java    |   2 +-
 .../gateway/KnoxCliLdapFuncTestPositive.java    |   2 +-
 4 files changed, 187 insertions(+), 187 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/0a919c0b/gateway-service-admin/src/test/java/org.apache.hadoop.gateway.service.admin/TopologyResourceTest.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/test/java/org.apache.hadoop.gateway.service.admin/TopologyResourceTest.java
b/gateway-service-admin/src/test/java/org.apache.hadoop.gateway.service.admin/TopologyResourceTest.java
deleted file mode 100644
index d4007f7..0000000
--- a/gateway-service-admin/src/test/java/org.apache.hadoop.gateway.service.admin/TopologyResourceTest.java
+++ /dev/null
@@ -1,185 +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.hadoop.gateway.service.admin;
-
-import org.apache.hadoop.gateway.topology.Topology;
-import org.apache.hadoop.gateway.config.GatewayConfig;
-import javax.servlet.http.HttpServletRequest;
-
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
-
-public class TopologyResourceTest {
-
-  private final String X_Forwarded = "X-Forwarded-";
-  private final String X_Forwarded_Context = X_Forwarded + "Context";
-  private final String X_Forwarded_Proto = X_Forwarded + "Proto";
-  private final String X_Forwarded_Host = X_Forwarded + "Host";
-  private final String X_Forwarded_Port = X_Forwarded + "Port";
-  private final String X_Forwarded_Server = X_Forwarded + "Server";
-
-  private String reqProto = "http";
-  private String reqServer = "req-server";
-  private String reqPort = "9001";
-  private String gatewayPath = "gateway-path";
-  private String reqContext = "/" + gatewayPath + "/a-topology";
-  private String proto = "proto", port = "1337", server = "my-server", host = server + ":"
+ port, startContext = "/mycontext";
-  private String fullContext = startContext + reqContext;
-  private String pathInfo = "/api/version";
-  private String topologyName = "topology-name";
-  private String expectedBase =  proto + "://" + server + ":" + port + "/mycontext/" + gatewayPath;
-  private String expectedURI =  expectedBase + "/" + topologyName;
-  private String expectedHref = expectedBase + "/a-topology" + pathInfo + "/" + topologyName;
-
-  @Test
-  public void testTopologyURLMethods(){
-//     Note: had to change method signature due to these tests. Changed methods to public
and added
-//    HttpServletRequest argument.
-    HttpServletRequest request = EasyMock.createNiceMock( HttpServletRequest.class );
-    setDefaultExpectations(request);
-    setMockRequestHeader(request, X_Forwarded_Host, host);
-    setMockRequestHeader(request, X_Forwarded_Port, port);
-    setMockRequestHeader(request, X_Forwarded_Proto, proto);
-    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
-    setMockRequestHeader(request, X_Forwarded_Server, server);
-
-    Topology t = EasyMock.createNiceMock( Topology.class );
-    EasyMock.expect( t.getName() ).andReturn( topologyName ).anyTimes();
-
-    GatewayConfig conf = EasyMock.createNiceMock( GatewayConfig.class );
-    EasyMock.expect( conf.getGatewayPath() ).andReturn( gatewayPath ).anyTimes();
-    EasyMock.replay( request, t, conf );
-
-    TopologiesResource res = new TopologiesResource();
-    String href = res.buildHref(t, request);
-    String uri = res.buildURI(t, conf, request);
-
-    assertThat( uri, containsString( proto ) );
-    assertThat( uri, containsString( host ) );
-    assertThat( uri, containsString( server ) );
-    assertThat( uri, containsString( port ) );
-    assertThat( uri, containsString( topologyName ) );
-    assert( uri.equals(expectedURI) );
-
-    assertThat( href, containsString( proto ) );
-    assertThat( href, containsString( host ) );
-    assertThat( href, containsString( server ) );
-    assertThat( href, containsString( port ) );
-    assertThat( href, containsString( fullContext ) );
-    assert( href.equals(expectedHref) );
-
-//    Test 2 - No Protocol Header
-    EasyMock.reset( request );
-    setDefaultExpectations(request);
-    setMockRequestHeader(request, X_Forwarded_Host, host);
-    setMockRequestHeader(request, X_Forwarded_Port, port);
-    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
-    setMockRequestHeader(request, X_Forwarded_Server, server);
-    EasyMock.replay(request);
-
-    String test2URI = expectedURI.replace(proto, reqProto);
-    String test2href = expectedHref.replace(proto, reqProto);
-    assert(res.buildURI(t, conf, request).equals(test2URI));
-    assert(res.buildHref(t, request).equals(test2href));
-
-//    Test 3 - No port in host Header
-    EasyMock.reset( request );
-    setDefaultExpectations(request);
-    setMockRequestHeader(request, X_Forwarded_Host, server);
-    setMockRequestHeader(request, X_Forwarded_Port, port);
-    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
-    setMockRequestHeader(request, X_Forwarded_Server, server);
-    setMockRequestHeader(request, X_Forwarded_Proto, proto);
-    EasyMock.replay(request);
-
-    assert(res.buildURI(t, conf, request).equals(expectedURI));
-    assert(res.buildHref(t, request).equals(expectedHref));
-
-
-//    Test 4 - server & no host Header
-    EasyMock.reset( request );
-    setDefaultExpectations(request);
-    setMockRequestHeader(request, X_Forwarded_Server, server);
-    setMockRequestHeader(request, X_Forwarded_Port, port);
-    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
-    setMockRequestHeader(request, X_Forwarded_Proto, proto);
-    EasyMock.replay(request);
-
-    assert(res.buildURI(t, conf, request).equals(expectedURI));
-    assert(res.buildHref(t, request).equals(expectedHref));
-
-
-    //    Test 5 - no server & no host Header
-    EasyMock.reset( request );
-    setDefaultExpectations(request);
-    setMockRequestHeader(request, X_Forwarded_Port, port);
-    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
-    setMockRequestHeader(request, X_Forwarded_Proto, proto);
-    EasyMock.replay(request);
-
-    String test5URI = expectedURI.replace(server, reqServer);
-    String test5href = expectedHref.replace(server, reqServer);
-    assertEquals(res.buildURI(t, conf, request), test5URI);
-    assertEquals(res.buildHref(t, request), test5href);
-
-
-    //    Test 6 - no port, no server & no host Header
-    EasyMock.reset( request );
-    setDefaultExpectations(request);
-    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
-    setMockRequestHeader(request, X_Forwarded_Proto, proto);
-    EasyMock.replay(request);
-
-    String test6URI = expectedURI.replace(server, reqServer).replace(port, reqPort);
-    String test6href = expectedHref.replace(server, reqServer).replace(port, reqPort);
-    assertEquals(res.buildURI(t, conf, request), (test6URI));
-    assertEquals(res.buildHref(t, request), (test6href));
-
-    //    Test 7 - No Context
-    EasyMock.reset( request );
-    setDefaultExpectations(request);
-    setMockRequestHeader(request, X_Forwarded_Host, host);
-    setMockRequestHeader(request, X_Forwarded_Port, port);
-    setMockRequestHeader(request, X_Forwarded_Proto, proto);
-    setMockRequestHeader(request, X_Forwarded_Server, server);
-    EasyMock.replay(request);
-
-    String test7URI = expectedURI.replace(startContext, "");
-    String test7href = expectedHref.replace(startContext, "");
-    assertEquals(res.buildURI(t, conf, request), test7URI);
-    assertEquals(res.buildHref(t, request), test7href);
-
-  }
-
-  private void setDefaultExpectations(HttpServletRequest request){
-    EasyMock.expect( request.getPathInfo() ).andReturn( pathInfo ).anyTimes();
-    EasyMock.expect( request.getContextPath() ).andReturn( reqContext ).anyTimes();
-    EasyMock.expect( request.getServerName() ).andReturn( reqServer ).anyTimes();
-    EasyMock.expect( request.getLocalPort() ).andReturn( Integer.parseInt( reqPort ) ).anyTimes();
-    EasyMock.expect( request.getProtocol() ).andReturn(reqProto).anyTimes();
-  }
-
-  private void setMockRequestHeader(HttpServletRequest request, String header, String expected){
-    EasyMock.expect( request.getHeader( header ) ).andReturn( expected ).anyTimes();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/0a919c0b/gateway-service-admin/src/test/java/org/apache/hadoop/gateway/service/admin/TopologyResourceTest.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/test/java/org/apache/hadoop/gateway/service/admin/TopologyResourceTest.java
b/gateway-service-admin/src/test/java/org/apache/hadoop/gateway/service/admin/TopologyResourceTest.java
new file mode 100644
index 0000000..d4007f7
--- /dev/null
+++ b/gateway-service-admin/src/test/java/org/apache/hadoop/gateway/service/admin/TopologyResourceTest.java
@@ -0,0 +1,185 @@
+/**
+ * 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.hadoop.gateway.service.admin;
+
+import org.apache.hadoop.gateway.topology.Topology;
+import org.apache.hadoop.gateway.config.GatewayConfig;
+import javax.servlet.http.HttpServletRequest;
+
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+
+public class TopologyResourceTest {
+
+  private final String X_Forwarded = "X-Forwarded-";
+  private final String X_Forwarded_Context = X_Forwarded + "Context";
+  private final String X_Forwarded_Proto = X_Forwarded + "Proto";
+  private final String X_Forwarded_Host = X_Forwarded + "Host";
+  private final String X_Forwarded_Port = X_Forwarded + "Port";
+  private final String X_Forwarded_Server = X_Forwarded + "Server";
+
+  private String reqProto = "http";
+  private String reqServer = "req-server";
+  private String reqPort = "9001";
+  private String gatewayPath = "gateway-path";
+  private String reqContext = "/" + gatewayPath + "/a-topology";
+  private String proto = "proto", port = "1337", server = "my-server", host = server + ":"
+ port, startContext = "/mycontext";
+  private String fullContext = startContext + reqContext;
+  private String pathInfo = "/api/version";
+  private String topologyName = "topology-name";
+  private String expectedBase =  proto + "://" + server + ":" + port + "/mycontext/" + gatewayPath;
+  private String expectedURI =  expectedBase + "/" + topologyName;
+  private String expectedHref = expectedBase + "/a-topology" + pathInfo + "/" + topologyName;
+
+  @Test
+  public void testTopologyURLMethods(){
+//     Note: had to change method signature due to these tests. Changed methods to public
and added
+//    HttpServletRequest argument.
+    HttpServletRequest request = EasyMock.createNiceMock( HttpServletRequest.class );
+    setDefaultExpectations(request);
+    setMockRequestHeader(request, X_Forwarded_Host, host);
+    setMockRequestHeader(request, X_Forwarded_Port, port);
+    setMockRequestHeader(request, X_Forwarded_Proto, proto);
+    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
+    setMockRequestHeader(request, X_Forwarded_Server, server);
+
+    Topology t = EasyMock.createNiceMock( Topology.class );
+    EasyMock.expect( t.getName() ).andReturn( topologyName ).anyTimes();
+
+    GatewayConfig conf = EasyMock.createNiceMock( GatewayConfig.class );
+    EasyMock.expect( conf.getGatewayPath() ).andReturn( gatewayPath ).anyTimes();
+    EasyMock.replay( request, t, conf );
+
+    TopologiesResource res = new TopologiesResource();
+    String href = res.buildHref(t, request);
+    String uri = res.buildURI(t, conf, request);
+
+    assertThat( uri, containsString( proto ) );
+    assertThat( uri, containsString( host ) );
+    assertThat( uri, containsString( server ) );
+    assertThat( uri, containsString( port ) );
+    assertThat( uri, containsString( topologyName ) );
+    assert( uri.equals(expectedURI) );
+
+    assertThat( href, containsString( proto ) );
+    assertThat( href, containsString( host ) );
+    assertThat( href, containsString( server ) );
+    assertThat( href, containsString( port ) );
+    assertThat( href, containsString( fullContext ) );
+    assert( href.equals(expectedHref) );
+
+//    Test 2 - No Protocol Header
+    EasyMock.reset( request );
+    setDefaultExpectations(request);
+    setMockRequestHeader(request, X_Forwarded_Host, host);
+    setMockRequestHeader(request, X_Forwarded_Port, port);
+    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
+    setMockRequestHeader(request, X_Forwarded_Server, server);
+    EasyMock.replay(request);
+
+    String test2URI = expectedURI.replace(proto, reqProto);
+    String test2href = expectedHref.replace(proto, reqProto);
+    assert(res.buildURI(t, conf, request).equals(test2URI));
+    assert(res.buildHref(t, request).equals(test2href));
+
+//    Test 3 - No port in host Header
+    EasyMock.reset( request );
+    setDefaultExpectations(request);
+    setMockRequestHeader(request, X_Forwarded_Host, server);
+    setMockRequestHeader(request, X_Forwarded_Port, port);
+    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
+    setMockRequestHeader(request, X_Forwarded_Server, server);
+    setMockRequestHeader(request, X_Forwarded_Proto, proto);
+    EasyMock.replay(request);
+
+    assert(res.buildURI(t, conf, request).equals(expectedURI));
+    assert(res.buildHref(t, request).equals(expectedHref));
+
+
+//    Test 4 - server & no host Header
+    EasyMock.reset( request );
+    setDefaultExpectations(request);
+    setMockRequestHeader(request, X_Forwarded_Server, server);
+    setMockRequestHeader(request, X_Forwarded_Port, port);
+    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
+    setMockRequestHeader(request, X_Forwarded_Proto, proto);
+    EasyMock.replay(request);
+
+    assert(res.buildURI(t, conf, request).equals(expectedURI));
+    assert(res.buildHref(t, request).equals(expectedHref));
+
+
+    //    Test 5 - no server & no host Header
+    EasyMock.reset( request );
+    setDefaultExpectations(request);
+    setMockRequestHeader(request, X_Forwarded_Port, port);
+    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
+    setMockRequestHeader(request, X_Forwarded_Proto, proto);
+    EasyMock.replay(request);
+
+    String test5URI = expectedURI.replace(server, reqServer);
+    String test5href = expectedHref.replace(server, reqServer);
+    assertEquals(res.buildURI(t, conf, request), test5URI);
+    assertEquals(res.buildHref(t, request), test5href);
+
+
+    //    Test 6 - no port, no server & no host Header
+    EasyMock.reset( request );
+    setDefaultExpectations(request);
+    setMockRequestHeader(request, X_Forwarded_Context, fullContext);
+    setMockRequestHeader(request, X_Forwarded_Proto, proto);
+    EasyMock.replay(request);
+
+    String test6URI = expectedURI.replace(server, reqServer).replace(port, reqPort);
+    String test6href = expectedHref.replace(server, reqServer).replace(port, reqPort);
+    assertEquals(res.buildURI(t, conf, request), (test6URI));
+    assertEquals(res.buildHref(t, request), (test6href));
+
+    //    Test 7 - No Context
+    EasyMock.reset( request );
+    setDefaultExpectations(request);
+    setMockRequestHeader(request, X_Forwarded_Host, host);
+    setMockRequestHeader(request, X_Forwarded_Port, port);
+    setMockRequestHeader(request, X_Forwarded_Proto, proto);
+    setMockRequestHeader(request, X_Forwarded_Server, server);
+    EasyMock.replay(request);
+
+    String test7URI = expectedURI.replace(startContext, "");
+    String test7href = expectedHref.replace(startContext, "");
+    assertEquals(res.buildURI(t, conf, request), test7URI);
+    assertEquals(res.buildHref(t, request), test7href);
+
+  }
+
+  private void setDefaultExpectations(HttpServletRequest request){
+    EasyMock.expect( request.getPathInfo() ).andReturn( pathInfo ).anyTimes();
+    EasyMock.expect( request.getContextPath() ).andReturn( reqContext ).anyTimes();
+    EasyMock.expect( request.getServerName() ).andReturn( reqServer ).anyTimes();
+    EasyMock.expect( request.getLocalPort() ).andReturn( Integer.parseInt( reqPort ) ).anyTimes();
+    EasyMock.expect( request.getProtocol() ).andReturn(reqProto).anyTimes();
+  }
+
+  private void setMockRequestHeader(HttpServletRequest request, String header, String expected){
+    EasyMock.expect( request.getHeader( header ) ).andReturn( expected ).anyTimes();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/0a919c0b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestNegative.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestNegative.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestNegative.java
index 85e5f8f..0872428 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestNegative.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestNegative.java
@@ -24,7 +24,7 @@ import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.hadoop.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.hadoop.gateway.services.DefaultGatewayServices;
 import org.apache.hadoop.gateway.services.ServiceLifecycleException;
-import org.apache.hadoop.gateway.util.KnoxCLI;;
+import org.apache.hadoop.gateway.util.KnoxCLI;
 import org.apache.hadoop.test.log.NoOpAppender;
 import org.apache.hadoop.test.log.NoOpLogger;
 import org.apache.log4j.Appender;

http://git-wip-us.apache.org/repos/asf/knox/blob/0a919c0b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestPositive.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestPositive.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestPositive.java
index d6f6d45..5aad293 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestPositive.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestPositive.java
@@ -23,7 +23,7 @@ import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.hadoop.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.hadoop.gateway.services.DefaultGatewayServices;
 import org.apache.hadoop.gateway.services.ServiceLifecycleException;
-import org.apache.hadoop.gateway.util.KnoxCLI;;
+import org.apache.hadoop.gateway.util.KnoxCLI;
 import org.apache.hadoop.test.log.NoOpAppender;
 import org.apache.log4j.Appender;
 import org.hamcrest.Matchers;


Mime
View raw message