Author: veithen
Date: Tue Dec 26 23:20:28 2017
New Revision: 1819304
URL: http://svn.apache.org/viewvc?rev=1819304&view=rev
Log:
Extract the common code from AbstractAxis2Server and ClientHelper.
Added:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractConfigurationContextRule.java
- copied, changed from r1819298,
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
Modified:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/ClientHelper.java
Modified:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java?rev=1819304&r1=1819303&r2=1819304&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
(original)
+++
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
Tue Dec 26 23:20:28 2017
@@ -23,35 +23,20 @@ import javax.net.ssl.SSLContext;
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.engine.AxisConfiguration;
-import org.junit.rules.ExternalResource;
-public abstract class AbstractAxis2Server extends ExternalResource {
- private final String repositoryPath;
+public abstract class AbstractAxis2Server extends
AbstractConfigurationContextRule {
private final AxisServiceFactory[] serviceFactories;
- private ConfigurationContext configurationContext;
public AbstractAxis2Server(String repositoryPath, AxisServiceFactory...
serviceFactories) {
- this.repositoryPath = repositoryPath;
+ super(repositoryPath);
this.serviceFactories = serviceFactories;
}
- final String getRepositoryPath() {
- return repositoryPath;
- }
-
- public final ConfigurationContext getConfigurationContext() {
- if (configurationContext == null) {
- throw new IllegalStateException();
- }
- return configurationContext;
- }
-
@Override
protected void before() throws Throwable {
- configurationContext =
-
ConfigurationContextFactory.createConfigurationContextFromFileSystem(repositoryPath);
+ super.before();
+ ConfigurationContext configurationContext = getConfigurationContext();
AxisConfiguration axisConfiguration =
configurationContext.getAxisConfiguration();
for (AxisServiceFactory serviceFactory : serviceFactories) {
axisConfiguration.addService(serviceFactory.createService(axisConfiguration));
@@ -62,7 +47,7 @@ public abstract class AbstractAxis2Serve
@Override
protected void after() {
stopServer();
- configurationContext = null;
+ super.after();
}
protected abstract void startServer(ConfigurationContext
configurationContext) throws Throwable;
Copied:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractConfigurationContextRule.java
(from r1819298,
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java)
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractConfigurationContextRule.java?p2=axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractConfigurationContextRule.java&p1=axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java&r1=1819298&r2=1819304&rev=1819304&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
(original)
+++
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractConfigurationContextRule.java
Tue Dec 26 23:20:28 2017
@@ -18,23 +18,16 @@
*/
package org.apache.axis2.testutils;
-import javax.net.ssl.SSLContext;
-
-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.engine.AxisConfiguration;
import org.junit.rules.ExternalResource;
-public abstract class AbstractAxis2Server extends ExternalResource {
+public abstract class AbstractConfigurationContextRule extends
ExternalResource {
private final String repositoryPath;
- private final AxisServiceFactory[] serviceFactories;
private ConfigurationContext configurationContext;
- public AbstractAxis2Server(String repositoryPath, AxisServiceFactory...
serviceFactories) {
+ public AbstractConfigurationContextRule(String repositoryPath) {
this.repositoryPath = repositoryPath;
- this.serviceFactories = serviceFactories;
}
final String getRepositoryPath() {
@@ -52,25 +45,10 @@ public abstract class AbstractAxis2Serve
protected void before() throws Throwable {
configurationContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(repositoryPath);
- AxisConfiguration axisConfiguration =
configurationContext.getAxisConfiguration();
- for (AxisServiceFactory serviceFactory : serviceFactories) {
-
axisConfiguration.addService(serviceFactory.createService(axisConfiguration));
- }
- startServer(configurationContext);
}
@Override
protected void after() {
- stopServer();
configurationContext = null;
}
-
- protected abstract void startServer(ConfigurationContext
configurationContext) throws Throwable;
- protected abstract void stopServer();
-
- public abstract boolean isSecure();
- public abstract SSLContext getClientSSLContext() throws Exception;
- public abstract int getPort();
- public abstract String getEndpoint(String serviceName) throws AxisFault;
- public abstract EndpointReference getEndpointReference(String serviceName)
throws AxisFault;
}
Modified:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/ClientHelper.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/ClientHelper.java?rev=1819304&r1=1819303&r2=1819304&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/ClientHelper.java
(original)
+++
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/ClientHelper.java
Tue Dec 26 23:20:28 2017
@@ -30,17 +30,13 @@ import javax.xml.namespace.QName;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.Stub;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.junit.rules.ExternalResource;
-public class ClientHelper extends ExternalResource {
+public class ClientHelper extends AbstractConfigurationContextRule {
private final AbstractAxis2Server server;
- private final String repositoryPath;
- private ConfigurationContext configurationContext;
public ClientHelper(AbstractAxis2Server server, String repositoryPath) {
+ super(repositoryPath);
this.server = server;
- this.repositoryPath = repositoryPath;
}
public ClientHelper(AbstractAxis2Server server) {
@@ -49,21 +45,15 @@ public class ClientHelper extends Extern
@Override
protected final void before() throws Throwable {
- configurationContext =
-
ConfigurationContextFactory.createConfigurationContextFromFileSystem(repositoryPath);
+ super.before();
SSLContext sslContext = server.getClientSSLContext();
if (sslContext != null) {
- configurationContext.setProperty(SSLContext.class.getName(),
sslContext);
+ getConfigurationContext().setProperty(SSLContext.class.getName(),
sslContext);
}
}
- @Override
- protected final void after() {
- configurationContext = null;
- }
-
public final ServiceClient createServiceClient(String serviceName) throws
Exception {
- ServiceClient serviceClient = new ServiceClient(configurationContext,
null);
+ ServiceClient serviceClient = new
ServiceClient(getConfigurationContext(), null);
serviceClient.getOptions().setTo(server.getEndpointReference(serviceName));
configureServiceClient(serviceClient);
return serviceClient;
@@ -84,7 +74,7 @@ public class ClientHelper extends Extern
} else {
handler = null;
}
- ServiceClient serviceClient = new ServiceClient(configurationContext,
+ ServiceClient serviceClient = new
ServiceClient(getConfigurationContext(),
new URL(null, server.getEndpoint(serviceName) + "?wsdl",
handler), wsdlServiceName, portName);
configureServiceClient(serviceClient);
return serviceClient;
@@ -93,7 +83,7 @@ public class ClientHelper extends Extern
public final <T extends Stub> T createStub(Class<T> type, String
serviceName) throws Exception {
T stub = type
.getConstructor(ConfigurationContext.class, String.class)
- .newInstance(configurationContext,
server.getEndpoint(serviceName));
+ .newInstance(getConfigurationContext(),
server.getEndpoint(serviceName));
configureServiceClient(stub._getServiceClient());
return stub;
}