This is an automated email from the ASF dual-hosted git repository.

billblough pushed a commit to branch 1_7
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git

commit c97d9ce14a50e9b3c78e3d81ce89cd82d657ad54
Author: Andreas Veithen <veit...@apache.org>
AuthorDate: Sun Jan 6 16:57:56 2019 +0000

    Partially merge r1780724 to the 1.7 branch.
---
 .../axis2/testutils/AbstractAxis2Server.java       |  4 +++
 ...{AbstractAxis2Server.java => ClientHelper.java} | 37 +++++++++++-----------
 2 files changed, 22 insertions(+), 19 deletions(-)

diff --git 
a/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
 
b/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
index 8c91b7d..4f89cd7 100644
--- 
a/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
+++ 
b/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
@@ -35,6 +35,10 @@ public abstract class AbstractAxis2Server extends 
ExternalResource {
         this.repositoryPath = repositoryPath;
     }
 
+    final String getRepositoryPath() {
+        return repositoryPath;
+    }
+
     public final ConfigurationContext getConfigurationContext() {
         if (configurationContext == null) {
             throw new IllegalStateException();
diff --git 
a/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
 b/modules/testutils/src/main/java/org/apache/axis2/testutils/ClientHelper.java
similarity index 59%
copy from 
modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
copy to 
modules/testutils/src/main/java/org/apache/axis2/testutils/ClientHelper.java
index 8c91b7d..538e311 100644
--- 
a/modules/testutils/src/main/java/org/apache/axis2/testutils/AbstractAxis2Server.java
+++ 
b/modules/testutils/src/main/java/org/apache/axis2/testutils/ClientHelper.java
@@ -19,47 +19,46 @@
 package org.apache.axis2.testutils;
 
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
+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 abstract class AbstractAxis2Server extends ExternalResource {
+public final class ClientHelper extends ExternalResource {
+    private final AbstractAxis2Server server;
     private final String repositoryPath;
     private ConfigurationContext configurationContext;
 
-    public AbstractAxis2Server(String repositoryPath) {
-        if (repositoryPath == null || repositoryPath.trim().length() == 0) {
-            throw new IllegalArgumentException("Axis2 repository must not be 
null or empty");
-        }
+    public ClientHelper(AbstractAxis2Server server, String repositoryPath) {
+        this.server = server;
         this.repositoryPath = repositoryPath;
     }
 
-    public final ConfigurationContext getConfigurationContext() {
-        if (configurationContext == null) {
-            throw new IllegalStateException();
-        }
-        return configurationContext;
+    public ClientHelper(AbstractAxis2Server server) {
+        this(server, server.getRepositoryPath());
     }
 
     @Override
     protected void before() throws Throwable {
         configurationContext =
                 
ConfigurationContextFactory.createConfigurationContextFromFileSystem(repositoryPath);
-        startServer(configurationContext);
     }
 
     @Override
     protected void after() {
-        stopServer();
         configurationContext = null;
     }
 
-    protected abstract void startServer(ConfigurationContext 
configurationContext) throws Throwable;
-    protected abstract void stopServer();
+    public ServiceClient createServiceClient(String serviceName) throws 
AxisFault {
+        ServiceClient serviceClient = new ServiceClient(configurationContext, 
null);
+        
serviceClient.getOptions().setTo(server.getEndpointReference(serviceName));
+        return serviceClient;
+    }
 
-    public abstract boolean isSecure();
-    public abstract int getPort();
-    public abstract String getEndpoint(String serviceName) throws AxisFault;
-    public abstract EndpointReference getEndpointReference(String serviceName) 
throws AxisFault;
+    public <T extends Stub> T createStub(Class<T> type, String serviceName) 
throws Exception {
+        return type
+                .getConstructor(ConfigurationContext.class, String.class)
+                .newInstance(configurationContext, 
server.getEndpoint(serviceName));
+    }
 }

Reply via email to