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 2019/01/06 15:23:32 UTC

svn commit: r1850564 - in /axis/axis2/java/core/branches/1_7: ./ modules/testutils/ modules/testutils/src/main/java/org/apache/axis2/testutils/

Author: veithen
Date: Sun Jan  6 15:23:32 2019
New Revision: 1850564

URL: http://svn.apache.org/viewvc?rev=1850564&view=rev
Log:
Merge r1779816 and r1780723 to the 1.7 branch.

Added:
    axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
      - copied unchanged from r1780723, axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
Modified:
    axis/axis2/java/core/branches/1_7/   (props changed)
    axis/axis2/java/core/branches/1_7/modules/testutils/   (props changed)
    axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java
    axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/JettyServer.java

Propchange: axis/axis2/java/core/branches/1_7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jan  6 15:23:32 2019
@@ -1,4 +1,4 @@
 /axis/axis2/java/core/branches/1_6:1295540
 /axis/axis2/java/core/branches/AXIOM-420:1334386-1336397
 /axis/axis2/java/core/branches/AXIS2-4318:1230452,1295542,1324772,1327468,1329571,1332141,1335355,1335357,1340985
-/axis/axis2/java/core/trunk:1726494,1726509,1726513,1727171,1727174,1727177,1727180,1729891,1730095,1730139,1730180,1730186,1730195,1730197,1730222,1730300,1730308,1730310,1730317,1730322,1730335,1730369,1730427,1730618,1731425,1731441,1731446,1731448,1732354,1733137,1733225,1733663,1733713,1733766,1733770,1733773,1733850,1734176,1735331,1735795,1735801,1736512,1736543,1737030,1737567,1739001,1739186,1739343,1739346,1739348,1739493,1739592,1739594-1739595,1739815,1739826,1740693-1740694,1741976,1742201,1743824,1745826,1745860,1745869,1745875,1745912,1745924,1745929,1745941,1746001,1746028,1746109,1746782,1746784,1746787,1746813,1746842,1746880,1746883,1746889,1746894,1747448,1747466,1747503,1747575,1747578,1747601,1747773,1747920,1751057,1752039,1765132,1765183,1765188,1765192-1765193,1775081,1775102,1776253,1776585,1776594,1778204,1779069,1779074,1780290,1780684,1780714,1787632,1787676,1789029,1792353,1792376,1792650,1792655,1792802,1792804,1793723-1793724,1793728,1794114,1794192,1
 797821,1797823,1799068,1800495,1803414,1805563,1806088,1806288,1806292,1806303-1806305,1806309,1806319,1806344,1806349-1806350,1806577,1806581,1806719,1807643,1807837,1807941,1807943,1808789,1809384-1809385,1809411,1809504,1809507,1809514,1809517,1810596,1810600,1810603,1815035,1815137,1815139,1817866,1817872,1819265,1820601,1821801,1821809,1823604,1823614,1823712,1826036,1831475,1831477,1831917,1832205,1835900,1836506,1837506-1837507,1837540,1838336,1843339,1843344,1844999,1845031,1845035,1845166,1845183,1848535,1848643-1848644,1848708,1848721,1848799,1849034,1849255,1849801,1850485
+/axis/axis2/java/core/trunk:1726494,1726509,1726513,1727171,1727174,1727177,1727180,1729891,1730095,1730139,1730180,1730186,1730195,1730197,1730222,1730300,1730308,1730310,1730317,1730322,1730335,1730369,1730427,1730618,1731425,1731441,1731446,1731448,1732354,1733137,1733225,1733663,1733713,1733766,1733770,1733773,1733850,1734176,1735331,1735795,1735801,1736512,1736543,1737030,1737567,1739001,1739186,1739343,1739346,1739348,1739493,1739592,1739594-1739595,1739815,1739826,1740693-1740694,1741976,1742201,1743824,1745826,1745860,1745869,1745875,1745912,1745924,1745929,1745941,1746001,1746028,1746109,1746782,1746784,1746787,1746813,1746842,1746880,1746883,1746889,1746894,1747448,1747466,1747503,1747575,1747578,1747601,1747773,1747920,1751057,1752039,1765132,1765183,1765188,1765192-1765193,1775081,1775102,1776253,1776585,1776594,1778204,1779069,1779074,1779816,1780290,1780684,1780714,1780723,1787632,1787676,1789029,1792353,1792376,1792650,1792655,1792802,1792804,1793723-1793724,1793728,1
 794114,1794192,1797821,1797823,1799068,1800495,1803414,1805563,1806088,1806288,1806292,1806303-1806305,1806309,1806319,1806344,1806349-1806350,1806577,1806581,1806719,1807643,1807837,1807941,1807943,1808789,1809384-1809385,1809411,1809504,1809507,1809514,1809517,1810596,1810600,1810603,1815035,1815137,1815139,1817866,1817872,1819265,1820601,1821801,1821809,1823604,1823614,1823712,1826036,1831475,1831477,1831917,1832205,1835900,1836506,1837506-1837507,1837540,1838336,1843339,1843344,1844999,1845031,1845035,1845166,1845183,1848535,1848643-1848644,1848708,1848721,1848799,1849034,1849255,1849801,1850485

Propchange: axis/axis2/java/core/branches/1_7/modules/testutils/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jan  6 15:23:32 2019
@@ -1,4 +1,4 @@
 /axis/axis2/java/core/branches/1_6/modules/testutils:1295540
 /axis/axis2/java/core/branches/AXIOM-420/modules/testutils:1334386-1336397
 /axis/axis2/java/core/branches/AXIS2-4318/modules/testutils:1230452,1295542,1324772,1327468,1329571,1332141,1335355,1335357,1340985
-/axis/axis2/java/core/trunk/modules/testutils:1726494,1726509,1726513,1727171,1727174,1727177,1727180,1729891,1730095,1730139,1730180,1730186,1730195,1730197,1730222,1730300,1730308,1730310,1730317,1730322,1730335,1730369,1730427,1730618,1731425,1731441,1731446,1731448,1732354,1733137,1733225,1733663,1733713,1733766,1733770,1733773,1733850,1734176,1735331,1735795,1735801,1736512,1736543,1737030,1737567,1739001,1739186,1739343,1739346,1739348,1739493,1739592,1739594-1739595,1739815,1739826,1740693-1740694,1741976-1741977,1742201,1743824,1745826,1745860,1745869,1745875,1745912,1745924,1745929,1745941,1746001,1746028,1746109,1746782,1746784,1746787,1746813,1746842,1746880,1746883,1746889,1746894,1747448,1747466,1747503,1747575,1747578,1747601,1747773,1747920,1751057,1752039,1765132,1765183,1765188,1765192-1765193,1775081,1775102,1776253,1776585,1776594,1778204,1779069,1779074,1780290,1780684,1780714,1787632,1787676,1789029,1792353,1792376,1792650,1792655,1792802,1792804,1793723-1793724
 ,1793728,1794114,1794192,1797821,1797823,1799068,1800495,1803414,1805563,1806088,1806288,1806292,1806303-1806305,1806309,1806319,1806344,1806349-1806350,1806577,1806581,1806719,1807643,1807837,1807941,1807943,1808789,1809384-1809385,1809411,1809504,1809507,1809514,1809517,1810596,1810600,1810603,1815035,1815137,1815139,1817866,1817872,1819265,1820601,1821801,1821809,1823604,1823614,1823712,1826036,1831475,1831477,1831917,1832205,1835900,1836506,1837506-1837507,1837540,1838336,1843339,1843344,1844999,1845031,1845035,1845166,1845183,1848535,1848643-1848644,1848708,1848721,1848799,1849034,1849255,1849801,1850485
+/axis/axis2/java/core/trunk/modules/testutils:1726494,1726509,1726513,1727171,1727174,1727177,1727180,1729891,1730095,1730139,1730180,1730186,1730195,1730197,1730222,1730300,1730308,1730310,1730317,1730322,1730335,1730369,1730427,1730618,1731425,1731441,1731446,1731448,1732354,1733137,1733225,1733663,1733713,1733766,1733770,1733773,1733850,1734176,1735331,1735795,1735801,1736512,1736543,1737030,1737567,1739001,1739186,1739343,1739346,1739348,1739493,1739592,1739594-1739595,1739815,1739826,1740693-1740694,1741976-1741977,1742201,1743824,1745826,1745860,1745869,1745875,1745912,1745924,1745929,1745941,1746001,1746028,1746109,1746782,1746784,1746787,1746813,1746842,1746880,1746883,1746889,1746894,1747448,1747466,1747503,1747575,1747578,1747601,1747773,1747920,1751057,1752039,1765132,1765183,1765188,1765192-1765193,1775081,1775102,1776253,1776585,1776594,1778204,1779069,1779074,1779816,1780290,1780684,1780714,1780723,1787632,1787676,1789029,1792353,1792376,1792650,1792655,1792802,1792804
 ,1793723-1793724,1793728,1794114,1794192,1797821,1797823,1799068,1800495,1803414,1805563,1806088,1806288,1806292,1806303-1806305,1806309,1806319,1806344,1806349-1806350,1806577,1806581,1806719,1807643,1807837,1807941,1807943,1808789,1809384-1809385,1809411,1809504,1809507,1809514,1809517,1810596,1810600,1810603,1815035,1815137,1815139,1817866,1817872,1819265,1820601,1821801,1821809,1823604,1823614,1823712,1826036,1831475,1831477,1831917,1832205,1835900,1836506,1837506-1837507,1837540,1838336,1843339,1843344,1844999,1845031,1845035,1845166,1845183,1848535,1848643-1848644,1848708,1848721,1848799,1849034,1849255,1849801,1850485

Modified: axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java?rev=1850564&r1=1850563&r2=1850564&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java (original)
+++ axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java Sun Jan  6 15:23:32 2019
@@ -21,20 +21,22 @@ package org.apache.axis2.testutils;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.transport.http.SimpleHTTPServer;
-import org.junit.rules.ExternalResource;
 
-public class Axis2Server extends ExternalResource {
-    private final String repositoryPath;
+public class Axis2Server extends AbstractAxis2Server {
     private int port = -1;
-    private ConfigurationContext configurationContext;
     private SimpleHTTPServer server;
 
     public Axis2Server(String repositoryPath) {
-        this.repositoryPath = repositoryPath;
+        super(repositoryPath);
     }
 
+    @Override
+    public boolean isSecure() {
+        return false;
+    }
+
+    @Override
     public int getPort() {
         if (port == -1) {
             throw new IllegalStateException();
@@ -42,34 +44,26 @@ public class Axis2Server extends Externa
         return port;
     }
 
-    public ConfigurationContext getConfigurationContext() {
-        if (configurationContext == null) {
-            throw new IllegalStateException();
-        }
-        return configurationContext;
-    }
-
+    @Override
     public String getEndpoint(String serviceName) throws AxisFault {
-        return getConfigurationContext().getAxisConfiguration().getService(serviceName).getEPRs()[0];
+        return getEndpointReference(serviceName).getAddress();
     }
 
+    @Override
     public EndpointReference getEndpointReference(String serviceName) throws AxisFault {
-        return new EndpointReference(getEndpoint(serviceName));
+        return server.getEPRForService(serviceName, "localhost");
     }
 
     @Override
-    protected void before() throws Throwable {
+    protected void startServer(ConfigurationContext configurationContext) throws Throwable {
         port = PortAllocator.allocatePort();
-        configurationContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(repositoryPath);
         server = new SimpleHTTPServer(configurationContext, port);
         server.start();
     }
 
     @Override
-    protected void after() {
+    protected void stopServer() {
         port = -1;
-        configurationContext = null;
         server.stop();
         server = null;
     }

Modified: axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/JettyServer.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/JettyServer.java?rev=1850564&r1=1850563&r2=1850564&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/JettyServer.java (original)
+++ axis/axis2/java/core/branches/1_7/modules/testutils/src/main/java/org/apache/axis2/testutils/JettyServer.java Sun Jan  6 15:23:32 2019
@@ -41,10 +41,8 @@ import org.eclipse.jetty.server.ssl.SslS
 import org.eclipse.jetty.servlet.ServletHolder;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.webapp.WebAppContext;
-import org.junit.rules.ExternalResource;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.transport.http.AxisServlet;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -58,7 +56,7 @@ import org.bouncycastle.operator.jcajce.
 /**
  * Support for running an embedded Jetty server
  */
-public class JettyServer extends ExternalResource {
+public class JettyServer extends AbstractAxis2Server {
     /**
      * The alias of the certificate to configure for Jetty's ssl context factory: {@value}
      */
@@ -71,7 +69,6 @@ public class JettyServer extends Externa
     
     private static final Log log = LogFactory.getLog(JettyServer.class);
     
-    private final String repository;
     private final boolean secure;
     private File keyStoreFile;
     private File trustStoreFile;
@@ -84,16 +81,13 @@ public class JettyServer extends Externa
     /**
      * Constructor.
      * 
-     * @param repository
+     * @param repositoryPath
      *            The path to the Axis2 repository to use. Must not be null or empty.
      * @param secure
      *            Whether to enable HTTPS.
      */
-    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;
+    public JettyServer(String repositoryPath, boolean secure) {
+        super(repositoryPath);
         this.secure = secure;
     }
     
@@ -115,7 +109,7 @@ public class JettyServer extends Externa
     }
     
     @Override
-    protected void before() throws Throwable {
+    protected void startServer(final ConfigurationContext configurationContext) throws Throwable {
         server = new Server();
         
         if (!secure) {
@@ -187,8 +181,6 @@ public class JettyServer extends Externa
         context.setParentLoaderPriority(true);
         context.setThrowUnavailableOnStartupException(true);
         
-        final ConfigurationContext configurationContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository);
         @SuppressWarnings("serial")
         ServletHolder servlet = new ServletHolder(new AxisServlet() {
             @Override
@@ -222,7 +214,7 @@ public class JettyServer extends Externa
     }
     
     @Override
-    protected void after() {
+    protected void stopServer() {
         if (server != null) {
             log.info("Stop called");
             try {
@@ -263,10 +255,16 @@ public class JettyServer extends Externa
         }
     }
 
+    @Override
+    public boolean isSecure() {
+        return secure;
+    }
+
     /**
      * @return Jetty's http connector port. 
      * @throws IllegalStateException If Jetty is not running or the http connector cannot be found.
      */
+    @Override
     public int getPort() throws IllegalStateException {
         if (server == null) {
             throw new IllegalStateException("Jetty server is not initialized");
@@ -290,10 +288,12 @@ public class JettyServer extends Externa
         throw new IllegalStateException("Could not find Jetty http connector");
     }
 
+    @Override
     public String getEndpoint(String serviceName) {
         return String.format("%s://localhost:%s/axis2/services/%s", secure ? "https" : "http", getPort(), serviceName);
     }
 
+    @Override
     public EndpointReference getEndpointReference(String serviceName) {
         return new EndpointReference(getEndpoint(serviceName));
     }