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 2016/04/17 14:27:50 UTC
svn commit: r1739595 - in /axis/axis2/java/core/trunk/modules: adb-tests/
adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5741/
adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5749/
testutils/src/main/java/org/apache/axis2/testutils/
Author: veithen
Date: Sun Apr 17 12:27:50 2016
New Revision: 1739595
URL: http://svn.apache.org/viewvc?rev=1739595&view=rev
Log:
Use JUnit rule to start Axis2 test server.
Added:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java (with props)
Modified:
axis/axis2/java/core/trunk/modules/adb-tests/pom.xml
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5741/ServiceTest.java
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5749/ServiceTest.java
Modified: axis/axis2/java/core/trunk/modules/adb-tests/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-tests/pom.xml?rev=1739595&r1=1739594&r2=1739595&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-tests/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/adb-tests/pom.xml Sun Apr 17 12:27:50 2016
@@ -65,6 +65,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axis2-testutils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
</dependency>
Modified: axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5741/ServiceTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5741/ServiceTest.java?rev=1739595&r1=1739594&r2=1739595&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5741/ServiceTest.java (original)
+++ axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5741/ServiceTest.java Sun Apr 17 12:27:50 2016
@@ -22,30 +22,22 @@ import static com.google.common.truth.Tr
import javax.xml.ws.BindingProvider;
-import org.apache.axiom.testutils.PortAllocator;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.databinding.axis2_5741.client.FiverxLinkService;
import org.apache.axis2.databinding.axis2_5741.client.FiverxLinkService_Service;
-import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.axis2.testutils.Axis2Server;
+import org.junit.ClassRule;
import org.junit.Test;
public class ServiceTest {
+ @ClassRule
+ public static Axis2Server server = new Axis2Server("target/repo/AXIS2-5741");
+
@Test
public void test() throws Exception {
- int port = PortAllocator.allocatePort();
- ConfigurationContext configurationContext =
- ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/repo/AXIS2-5741");
- SimpleHTTPServer server = new SimpleHTTPServer(configurationContext, port);
- server.start();
- try {
- FiverxLinkService client = new FiverxLinkService_Service().getFiverxLinkServicePort();
- ((BindingProvider)client).getRequestContext().put(
- BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/axis2/services/FiverxLinkService");
- assertThat(client.ladeRzVersion("test")).isEqualTo("test result");
- } finally {
- server.stop();
- }
+ FiverxLinkService client = new FiverxLinkService_Service().getFiverxLinkServicePort();
+ ((BindingProvider)client).getRequestContext().put(
+ BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:" + server.getPort() + "/axis2/services/FiverxLinkService");
+ assertThat(client.ladeRzVersion("test")).isEqualTo("test result");
}
}
Modified: axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5749/ServiceTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5749/ServiceTest.java?rev=1739595&r1=1739594&r2=1739595&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5749/ServiceTest.java (original)
+++ axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5749/ServiceTest.java Sun Apr 17 12:27:50 2016
@@ -22,33 +22,25 @@ import static com.google.common.truth.Tr
import javax.xml.ws.BindingProvider;
-import org.apache.axiom.testutils.PortAllocator;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.databinding.axis2_5749.client.Color;
import org.apache.axis2.databinding.axis2_5749.client.ColorService;
import org.apache.axis2.databinding.axis2_5749.client.ColorService_Service;
-import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.axis2.testutils.Axis2Server;
+import org.junit.ClassRule;
import org.junit.Test;
public class ServiceTest {
+ @ClassRule
+ public static Axis2Server server = new Axis2Server("target/repo/AXIS2-5749");
+
@Test
public void test() throws Exception {
- int port = PortAllocator.allocatePort();
- ConfigurationContext configurationContext =
- ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/repo/AXIS2-5749");
- SimpleHTTPServer server = new SimpleHTTPServer(configurationContext, port);
- server.start();
- try {
- ColorService client = new ColorService_Service().getColorServiceSOAP();
- ((BindingProvider)client).getRequestContext().put(
- BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/axis2/services/ColorService");
- Color color = new Color();
- color.setIn("RED");
- assertThat(client.test(color).getOut()).isEqualTo("Red is good!");
- } finally {
- server.stop();
- }
+ ColorService client = new ColorService_Service().getColorServiceSOAP();
+ ((BindingProvider)client).getRequestContext().put(
+ BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:" + server.getPort() + "/axis2/services/ColorService");
+ Color color = new Color();
+ color.setIn("RED");
+ assertThat(client.test(color).getOut()).isEqualTo("Red is good!");
}
}
Added: axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java?rev=1739595&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java (added)
+++ axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java Sun Apr 17 12:27:50 2016
@@ -0,0 +1,56 @@
+/*
+ * 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.axis2.testutils;
+
+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;
+ private int port = -1;
+ private SimpleHTTPServer server;
+
+ public Axis2Server(String repositoryPath) {
+ this.repositoryPath = repositoryPath;
+ }
+
+ public int getPort() {
+ if (port == -1) {
+ throw new IllegalStateException();
+ }
+ return port;
+ }
+
+ @Override
+ protected void before() throws Throwable {
+ port = PortAllocator.allocatePort();
+ ConfigurationContext configurationContext =
+ ConfigurationContextFactory.createConfigurationContextFromFileSystem(repositoryPath);
+ server = new SimpleHTTPServer(configurationContext, port);
+ server.start();
+ }
+
+ @Override
+ protected void after() {
+ port = -1;
+ server.stop();
+ }
+}
Propchange: axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java
------------------------------------------------------------------------------
svn:eol-style = native