You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/01/14 19:15:51 UTC

svn commit: r1778821 - in /axis/axis2/java/rampart/branches/RAMPART-433: ./ modules/rampart-integration/src/main/java/org/apache/axis2/integration/ modules/rampart-integration/src/main/java/org/apache/rahas/ modules/rampart-integration/src/test/java/or...

Author: veithen
Date: Sat Jan 14 19:15:51 2017
New Revision: 1778821

URL: http://svn.apache.org/viewvc?rev=1778821&view=rev
Log:
Merge latest changes from trunk.

Modified:
    axis/axis2/java/rampart/branches/RAMPART-433/   (props changed)
    axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
    axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
    axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java
    axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java

Propchange: axis/axis2/java/rampart/branches/RAMPART-433/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jan 14 19:15:51 2017
@@ -1 +1 @@
-/axis/axis2/java/rampart/trunk:1778760-1778814
+/axis/axis2/java/rampart/trunk:1778760-1778820

Modified: axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java?rev=1778821&r1=1778820&r2=1778821&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java Sat Jan 14 19:15:51 2017
@@ -27,7 +27,7 @@ import org.eclipse.jetty.webapp.WebAppCo
 import org.junit.rules.ExternalResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.axis2.testutils.PortAllocator;
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.transport.http.AxisServlet;
 
 /**
@@ -73,7 +73,6 @@ public class JettyServer extends Externa
     private static final Logger logger = LoggerFactory.getLogger(JettyServer.class);
     
     private final String repository;
-    private final int port;
     private final boolean secure;
     private Server server;
     private boolean systemPropertiesSet;
@@ -86,30 +85,23 @@ public class JettyServer extends Externa
      * 
      * @param repository
      *            The path to the Axis2 repository to use. Must not be null or empty.
-     * @param port
-     *            The port to use. Set to <code>0</code> to enable dynamic port allocation.
      * @param secure
      *            Whether to enable HTTPS.
      */
-    public JettyServer(String repository, int port, boolean secure) {
+    public JettyServer(String repository, boolean secure) {
         if (repository == null || repository.trim().length() == 0) {
             throw new IllegalArgumentException("Axis2 repository must not be null or empty");
         }
         this.repository = repository;
-        this.port = port;
         this.secure = secure;
     }
     
     @Override
     protected void before() throws Throwable {
-        int port = this.port == 0 ? PortAllocator.allocatePort() : this.port;
-        
         server = new Server();
         
-        logger.info("Starting server on port: " + port);
         if (!secure) {
             SelectChannelConnector connector = new SelectChannelConnector();
-            connector.setPort(port);
             server.addConnector(connector);
         } else {
             SslContextFactory sslContextFactory = new SslContextFactory();
@@ -121,7 +113,6 @@ public class JettyServer extends Externa
             sslContextFactory.setCertAlias(CERT_ALIAS);
             SslSelectChannelConnector sslConnector = new SslSelectChannelConnector(sslContextFactory);
             
-            sslConnector.setPort(port);
             server.addConnector(sslConnector);
             
             savedTrustStore = System.getProperty("javax.net.ssl.trustStore");
@@ -168,6 +159,8 @@ public class JettyServer extends Externa
                 throw e;
             }
         }
+        
+        logger.info("Server started on port " + getPort());
     }
     
     @Override
@@ -224,10 +217,18 @@ public class JettyServer extends Externa
         for (Connector connector : connectors) {
             if (connector instanceof SelectChannelConnector) {
                 //must be the http connector
-                return connector.getPort();
+                return connector.getLocalPort();
             }
         }
         
         throw new IllegalStateException("Could not find Jetty http connector");
     }
+
+    public String getEndpoint(String serviceName) {
+        return String.format("%s://localhost:%s/axis2/services/%s", secure ? "https" : "http", getPort(), serviceName);
+    }
+
+    public EndpointReference getEndpointReference(String serviceName) {
+        return new EndpointReference(getEndpoint(serviceName));
+    }
 }

Modified: axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java?rev=1778821&r1=1778820&r2=1778821&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java Sat Jan 14 19:15:51 2017
@@ -24,7 +24,6 @@ import org.apache.axiom.om.OMXMLBuilderF
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
@@ -39,10 +38,8 @@ import org.junit.Test;
 
 public abstract class TestClient {
 
-    protected int port = 5555;
-
     @Rule
-    public final JettyServer server = new JettyServer(Constants.TESTING_PATH + getServiceRepo(), port, false);
+    public final JettyServer server = new JettyServer(Constants.TESTING_PATH + getServiceRepo(), false);
 
     /**
      */
@@ -62,7 +59,7 @@ public abstract class TestClient {
         System.setProperty("javax.net.ssl.trustStorePassword", "password");
         System.setProperty("javax.net.ssl.trustStoreType","JKS");
 
-        options.setTo(new EndpointReference("http://127.0.0.1:" + port + "/axis2/services/SecureService"));
+        options.setTo(server.getEndpointReference("SecureService"));
 //        options.setTo(new EndpointReference("http://127.0.0.1:" + 9090 + "/axis2/services/UTSAMLHoK"));
 //        options.setTo(new EndpointReference("https://www-lk.wso2.com:8443/axis2/services/UTSAMLHoK"));
 //        options.setTo(new EndpointReference("https://192.18.49.133:2343/jaxws-s1-sts/sts"));

Modified: axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java?rev=1778821&r1=1778820&r2=1778821&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java Sat Jan 14 19:15:51 2017
@@ -65,7 +65,7 @@ public class RampartKerberosTest extends
     public static final String KERBEROS_CONF_KDC_PORT_TOKEN = "KDC_PORT";
     
     @Rule
-    public final JettyServer server = new JettyServer("target/test-resources/rampart_service_repo", 0, true);
+    public final JettyServer server = new JettyServer("target/test-resources/rampart_service_repo", true);
     
     /**
      * Stores any original JAAS configuration set via {@link #JAAS_CONF_SYS_PROP} property to restore it after test execution.
@@ -80,7 +80,7 @@ public class RampartKerberosTest extends
     @Test
     public void testKerberosOverTransportKeytab() throws XMLStreamException, SAXException, IOException {
         final String serviceName = "KerberosOverTransportKeytab";
-        URL serviceUrl = new URL(String.format("https://localhost:%s/axis2/services/%s?wsdl", server.getPort(), serviceName));
+        URL serviceUrl = new URL(server.getEndpoint(serviceName) + "?wsdl");
         
         ServiceClient serviceClient = getServiceClientInstance(serviceUrl);
 
@@ -107,7 +107,7 @@ public class RampartKerberosTest extends
     @Test
     public void testKerberosOverTransportPWCB() throws XMLStreamException, SAXException, IOException {
         final String serviceName = "KerberosOverTransportPWCB";
-        URL serviceUrl = new URL(String.format("https://localhost:%s/axis2/services/%s?wsdl", server.getPort(), serviceName));
+        URL serviceUrl = new URL(server.getEndpoint(serviceName) + "?wsdl");
         
         ServiceClient serviceClient = getServiceClientInstance(serviceUrl);
 
@@ -136,7 +136,7 @@ public class RampartKerberosTest extends
     @Test
     public void testKerberosDelegation() throws XMLStreamException, SAXException, IOException {
         final String serviceName = "KerberosDelegation";
-        URL serviceUrl = new URL(String.format("https://localhost:%s/axis2/services/%s?wsdl", server.getPort(), serviceName));
+        URL serviceUrl = new URL(server.getEndpoint(serviceName) + "?wsdl");
 
         ServiceClient serviceClient = getServiceClientInstance(serviceUrl);
 

Modified: axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java?rev=1778821&r1=1778820&r2=1778821&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java Sat Jan 14 19:15:51 2017
@@ -27,7 +27,6 @@ import org.apache.axiom.om.util.AXIOMUti
 import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
@@ -47,10 +46,10 @@ public class RampartTest {
     private static ResourceBundle resources;
     
     @Rule
-    public final JettyServer server = new JettyServer(Constants.TESTING_PATH + "rampart_service_repo", 0, false);
+    public final JettyServer server = new JettyServer(Constants.TESTING_PATH + "rampart_service_repo", false);
     
     @Rule
-    public final JettyServer secureServer = new JettyServer(Constants.TESTING_PATH + "rampart_service_repo", 0, true);
+    public final JettyServer secureServer = new JettyServer(Constants.TESTING_PATH + "rampart_service_repo", true);
     
     static {
         try {
@@ -104,17 +103,13 @@ public class RampartTest {
                 Options options = new Options();
                 
                 if( i == 13 ) {
-                    options.setTo(new EndpointReference("https://localhost:" +
-                                    secureServer.getPort() +  
-                                    "/axis2/services/SecureService" + i));
+                    options.setTo(secureServer.getEndpointReference("SecureService" + i));
                     //Username token created with user/pass from options
                     options.setUserName("alice");
                     options.setPassword("password");
                 }
                 else {
-                    options.setTo(new EndpointReference("http://localhost:" +
-                                    server.getPort() +  
-                                    "/axis2/services/SecureService" + i));
+                    options.setTo(server.getEndpointReference("SecureService" + i));
                 }
                 
                 System.out.println("Testing WS-Sec: custom scenario " + i);
@@ -180,17 +175,13 @@ public class RampartTest {
                 Options options = new Options();
 
                 if (i == 13) {
-                    options.setTo(new EndpointReference("https://localhost:" +
-                                    secureServer.getPort() +
-                                    "/axis2/services/SecureService" + i));
+                    options.setTo(secureServer.getEndpointReference("SecureService" + i));
                     //Username token created with user/pass from options
                     options.setUserName("alice");
                     options.setPassword("password");
                 }
                 else {
-                    options.setTo(new EndpointReference("http://localhost:" +
-                                    server.getPort() +
-                                    "/axis2/services/SecureService" + i));
+                    options.setTo(server.getEndpointReference("SecureService" + i));
                 }
                 System.out.println("Testing WS-Sec: negative scenario " + i);
                 options.setAction("urn:returnError");
@@ -215,10 +206,10 @@ public class RampartTest {
                 Options options = new Options();
                 
                 if (i == 3 || i == 6) {
-                    options.setTo(new EndpointReference("https://localhost:" + secureServer.getPort() + "/axis2/services/SecureServiceSC" + i));
+                    options.setTo(secureServer.getEndpointReference("SecureServiceSC" + i));
                 }
                 else {
-                    options.setTo(new EndpointReference("http://localhost:" + server.getPort() + "/axis2/services/SecureServiceSC" + i));
+                    options.setTo(server.getEndpointReference("SecureServiceSC" + i));
                 }
 
                 System.out.println("Testing WS-SecConv: custom scenario " + i);