Author: veithen
Date: Mon May 2 13:06:23 2016
New Revision: 1741977
URL: http://svn.apache.org/viewvc?rev=1741977&view=rev
Log:
Use the new Axis2Server rule.
Modified:
axis/axis2/java/core/trunk/modules/json/pom.xml
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/JSONXMLStreamAPITest.java
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/rpc/JSONRPCIntegrationTest.java
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java
Modified: axis/axis2/java/core/trunk/modules/json/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/pom.xml?rev=1741977&r1=1741976&r2=1741977&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/json/pom.xml Mon May 2 13:06:23 2016
@@ -156,6 +156,33 @@
</executions>
</plugin>
<plugin>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axis2-repo-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <id>json-repo</id>
+ <goals>
+ <goal>create-test-repository</goal>
+ </goals>
+ <configuration>
+
<inputDirectory>test-repository/json</inputDirectory>
+
<outputDirectory>${project.build.directory}/repo/json</outputDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>gson-repo</id>
+ <goals>
+ <goal>create-test-repository</goal>
+ </goals>
+ <configuration>
+
<inputDirectory>test-repository/gson</inputDirectory>
+
<outputDirectory>${project.build.directory}/repo/gson</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
@@ -165,12 +192,9 @@
<goal>copy-resources</goal>
</goals>
<configuration>
-
<outputDirectory>${project.build.directory}/repo</outputDirectory>
+
<outputDirectory>${project.build.directory}/repo/gson</outputDirectory>
<resources>
<resource>
- <directory>src/test/repo</directory>
- </resource>
- <resource>
<directory>${project.build.directory}/gen/resources</directory>
<targetPath>services/json_adb_test.aar/META-INF</targetPath>
</resource>
Modified:
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java?rev=1741977&r1=1741976&r2=1741977&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java
(original)
+++
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java
Mon May 2 13:06:23 2016
@@ -27,12 +27,10 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
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.testutils.UtilServer;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.apache.axis2.testutils.Axis2Server;
+import org.junit.ClassRule;
import org.junit.Test;
import java.io.BufferedReader;
@@ -46,22 +44,8 @@ public class JSONIntegrationTest impleme
private String expectedString;
- private static EndpointReference echoTargetEPR;
- private static String pojoUri;
-
- @BeforeClass
- public static void startServer() throws Exception {
- UtilServer.start("test-repository/json",
"test-repository/json/axis2.xml");
- echoTargetEPR = new EndpointReference(
- "http://127.0.0.1:" + UtilServer.TESTING_PORT
- + "/axis2/services/EchoXMLService/echoOM");
- pojoUri = "http://127.0.0.1:" + UtilServer.TESTING_PORT +
"/axis2/services/POJOService";
- }
-
- @AfterClass
- public static void stopServer() throws Exception {
- UtilServer.stop();
- }
+ @ClassRule
+ public static Axis2Server server = new Axis2Server("target/repo/json");
protected OMElement createEnvelope() throws Exception {
OMFactory fac = OMAbstractFactory.getOMFactory();
@@ -81,15 +65,14 @@ public class JSONIntegrationTest impleme
private void doEchoOM(String messageType, String httpMethod) throws
Exception{
OMElement payload = createEnvelope();
Options options = new Options();
- options.setTo(echoTargetEPR);
+ options.setTo(server.getEndpointReference("EchoXMLService"));
options.setProperty(Constants.Configuration.MESSAGE_TYPE, messageType);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setProperty(Constants.Configuration.HTTP_METHOD, httpMethod);
// ConfigurationContext clientConfigurationContext =
ConfigurationContextFactory.createDefaultConfigurationContext();
- ServiceClient sender = new
ServiceClient(UtilServer.getConfigurationContext(), null);
+ ServiceClient sender = new
ServiceClient(server.getConfigurationContext(), null);
options.setAction(null);
sender.setOptions(options);
- options.setTo(echoTargetEPR);
OMElement result = sender.sendReceive(payload);
OMElement ele = (OMElement)result.getFirstOMChild();
compareWithCreatedOMText(ele.getText());
@@ -112,7 +95,7 @@ public class JSONIntegrationTest impleme
@Test
public void testPOJOServiceWithJSONBadgerfish() throws Exception {
- HttpURLConnection conn = (HttpURLConnection)new
URL(pojoUri).openConnection();
+ HttpURLConnection conn = (HttpURLConnection)new
URL(server.getEndpoint("POJOService")).openConnection();
conn.setDoOutput(true);
conn.addRequestProperty("Content-Type", "application/json/badgerfish");
Writer out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
@@ -128,7 +111,7 @@ public class JSONIntegrationTest impleme
@Test
public void testPOJOServiceWithJSONMapped() throws Exception {
- HttpURLConnection conn = (HttpURLConnection)new
URL(pojoUri).openConnection();
+ HttpURLConnection conn = (HttpURLConnection)new
URL(server.getEndpoint("POJOService")).openConnection();
conn.setDoOutput(true);
conn.addRequestProperty("Content-Type", "application/json");
Writer out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
Modified:
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/JSONXMLStreamAPITest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/JSONXMLStreamAPITest.java?rev=1741977&r1=1741976&r2=1741977&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/JSONXMLStreamAPITest.java
(original)
+++
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/JSONXMLStreamAPITest.java
Mon May 2 13:06:23 2016
@@ -19,30 +19,19 @@
package org.apache.axis2.json.gson;
-import org.apache.axis2.testutils.UtilServer;
-import org.junit.After;
+import org.apache.axis2.testutils.Axis2Server;
import org.junit.Assert;
-import org.junit.Before;
+import org.junit.ClassRule;
import org.junit.Test;
public class JSONXMLStreamAPITest {
-
- @Before
- public void setUp()throws Exception {
- UtilServer.start("target/repo", "test-repository/gson/axis2.xml");
-
- }
-
- @After
- public void tearDown()throws Exception {
- UtilServer.stop();
-
- }
+ @ClassRule
+ public static Axis2Server server = new Axis2Server("target/repo/gson");
@Test
public void xmlStreamAPITest()throws Exception{
- String getLibURL = "http://localhost:" + UtilServer.TESTING_PORT
+"/axis2/services/LibraryService/getLibrary";
- String echoLibURL = "http://localhost:" + UtilServer.TESTING_PORT
+"/axis2/services/LibraryService/echoLibrary";
+ String getLibURL = server.getEndpoint("LibraryService") + "getLibrary";
+ String echoLibURL = server.getEndpoint("LibraryService") +
"echoLibrary";
String contentType = "application/json";
String charSet = "UTF-8";
Modified:
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/rpc/JSONRPCIntegrationTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/rpc/JSONRPCIntegrationTest.java?rev=1741977&r1=1741976&r2=1741977&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/rpc/JSONRPCIntegrationTest.java
(original)
+++
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/rpc/JSONRPCIntegrationTest.java
Mon May 2 13:06:23 2016
@@ -19,31 +19,23 @@
package org.apache.axis2.json.gson.rpc;
-import junit.framework.Assert;
import org.apache.axis2.json.gson.UtilTest;
-import org.apache.axis2.testutils.UtilServer;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.apache.axis2.testutils.Axis2Server;
+import org.junit.Assert;
+import org.junit.ClassRule;
import org.junit.Test;
public class JSONRPCIntegrationTest {
+ @ClassRule
+ public static Axis2Server server = new Axis2Server("target/repo/gson");
+
String contentType = "application/json";
String charSet = "UTF-8";
- @BeforeClass
- public static void startTestServer() throws Exception {
- UtilServer.start("test-repository/gson",
"test-repository/gson/axis2.xml");
- }
-
- @AfterClass
- public static void stopTestServer() throws Exception {
- UtilServer.stop();
- }
-
@Test
public void testJsonRpcMessageReceiver() throws Exception {
String jsonRequest =
"{\"echoPerson\":[{\"arg0\":{\"name\":\"Simon\",\"age\":\"35\",\"gender\":\"male\"}}]}";
- String echoPersonUrl = "http://localhost:" + UtilServer.TESTING_PORT
+"/axis2/services/JSONPOJOService/echoPerson";
+ String echoPersonUrl = server.getEndpoint("JSONPOJOService") +
"echoPerson";
String expectedResponse =
"{\"response\":{\"name\":\"Simon\",\"age\":\"35\",\"gender\":\"male\"}}";
String response = UtilTest.post(jsonRequest, echoPersonUrl,
contentType, charSet);
Assert.assertNotNull(response);
@@ -53,7 +45,7 @@ public class JSONRPCIntegrationTest {
@Test
public void testJsonInOnlyRPCMessageReceiver() throws Exception {
String jsonRequest =
"{\"ping\":[{\"arg0\":{\"name\":\"Simon\",\"age\":\"35\",\"gender\":\"male\"}}]}";
- String echoPersonUrl = "http://localhost:" + UtilServer.TESTING_PORT
+"/axis2/services/JSONPOJOService/ping";
+ String echoPersonUrl = server.getEndpoint("JSONPOJOService") + "ping";
String response = UtilTest.post(jsonRequest, echoPersonUrl,
contentType, charSet);
Assert.assertEquals("", response);
}
Modified:
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=1741977&r1=1741976&r2=1741977&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java
(original)
+++
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/Axis2Server.java
Mon May 2 13:06:23 2016
@@ -19,6 +19,7 @@
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;
@@ -41,11 +42,19 @@ public class Axis2Server extends Externa
return port;
}
- public String getEndpoint(String serviceName) throws AxisFault {
+ public ConfigurationContext getConfigurationContext() {
if (configurationContext == null) {
throw new IllegalStateException();
}
- return
configurationContext.getAxisConfiguration().getService(serviceName).getEPRs()[0];
+ return configurationContext;
+ }
+
+ public String getEndpoint(String serviceName) throws AxisFault {
+ return
getConfigurationContext().getAxisConfiguration().getService(serviceName).getEPRs()[0];
+ }
+
+ public EndpointReference getEndpointReference(String serviceName) throws
AxisFault {
+ return new EndpointReference(getEndpoint(serviceName));
}
@Override