Author: veithen
Date: Mon Dec 25 12:34:49 2017
New Revision: 1819246
URL: http://svn.apache.org/viewvc?rev=1819246&view=rev
Log:
Rewrite MapServiceTest to use the Axis2Server rule.
Added:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AxisServiceFactory.java
(with props)
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/SimpleAxisServiceFactory.java
(with props)
Modified:
axis/axis2/java/core/trunk/modules/integration/pom.xml
axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/map/MapServiceTest.java
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/Axis2Server.java
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/JettyServer.java
Modified: axis/axis2/java/core/trunk/modules/integration/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/integration/pom.xml?rev=1819246&r1=1819245&r2=1819246&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/integration/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/integration/pom.xml Mon Dec 25 12:34:49
2017
@@ -129,6 +129,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-testutils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope>
Modified:
axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/map/MapServiceTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/map/MapServiceTest.java?rev=1819246&r1=1819245&r2=1819246&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/map/MapServiceTest.java
(original)
+++
axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/map/MapServiceTest.java
Mon Dec 25 12:34:49 2017
@@ -19,8 +19,10 @@
package org.apache.axis2.engine.map;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.stream.XMLStreamException;
-import junit.framework.TestCase;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
@@ -31,33 +33,19 @@ import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.AxisServer;
+import org.apache.axis2.testutils.Axis2Server;
+import org.apache.axis2.testutils.SimpleAxisServiceFactory;
+import org.junit.ClassRule;
+import org.junit.Test;
/**
* The Class MapServiceTest.
*/
-public class MapServiceTest extends TestCase {
- private AxisServer server;
+public class MapServiceTest {
+ @ClassRule
+ public static Axis2Server server = new Axis2Server(null,
+ new SimpleAxisServiceFactory(MapService.class));
- /** The service. */
- protected AxisService service;
-
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- server = new AxisServer();
- server.deployService(MapService.class.getName());
- }
-
- @Override
- protected void tearDown() throws Exception {
- server.stop();
- }
-
/**
* Test string generics map service.
*
@@ -66,9 +54,10 @@ public class MapServiceTest extends Test
* @throws AxisFault
* the axis fault
*/
+ @Test
public void testStringGenericsMapService() throws XMLStreamException,
AxisFault {
- String epr =
"http://localhost:6060/axis2/services/MapService/stringGenericsMapService";
+ String epr = server.getEndpoint("MapService") +
"/stringGenericsMapService";
Options options = new Options();
options.setTo(new EndpointReference(epr));
ServiceClient sender = new ServiceClient();
@@ -94,10 +83,11 @@ public class MapServiceTest extends Test
* @throws AxisFault
* the axis fault
*/
+ @Test
public void testStringGenericsTreeMapService() throws XMLStreamException,
AxisFault {
- String epr =
"http://localhost:6060/axis2/services/MapService/stringGenericsTreeMapService";
+ String epr = server.getEndpoint("MapService") +
"/stringGenericsTreeMapService";
Options options = new Options();
options.setTo(new EndpointReference(epr));
ServiceClient sender = new ServiceClient();
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=1819246&r1=1819245&r2=1819246&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
Mon Dec 25 12:34:49 2017
@@ -24,17 +24,17 @@ 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;
+ private final AxisServiceFactory[] serviceFactories;
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 AbstractAxis2Server(String repositoryPath, AxisServiceFactory...
serviceFactories) {
this.repositoryPath = repositoryPath;
+ this.serviceFactories = serviceFactories;
}
final String getRepositoryPath() {
@@ -52,6 +52,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);
}
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=1819246&r1=1819245&r2=1819246&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 Dec 25 12:34:49 2017
@@ -29,8 +29,8 @@ public class Axis2Server extends Abstrac
private int port = -1;
private SimpleHTTPServer server;
- public Axis2Server(String repositoryPath) {
- super(repositoryPath);
+ public Axis2Server(String repositoryPath, AxisServiceFactory...
axisServiceFactories) {
+ super(repositoryPath, axisServiceFactories);
}
@Override
Added:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AxisServiceFactory.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AxisServiceFactory.java?rev=1819246&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AxisServiceFactory.java
(added)
+++
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AxisServiceFactory.java
Mon Dec 25 12:34:49 2017
@@ -0,0 +1,26 @@
+/*
+ * 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.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+
+public interface AxisServiceFactory {
+ AxisService createService(AxisConfiguration axisConfiguration) throws
Exception;
+}
Propchange:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/AxisServiceFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/JettyServer.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/JettyServer.java?rev=1819246&r1=1819245&r2=1819246&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/JettyServer.java
(original)
+++
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/JettyServer.java
Mon Dec 25 12:34:49 2017
@@ -85,8 +85,8 @@ public class JettyServer extends Abstrac
* @param secure
* Whether to enable HTTPS.
*/
- public JettyServer(String repositoryPath, boolean secure) {
- super(repositoryPath);
+ public JettyServer(String repositoryPath, boolean secure,
AxisServiceFactory... axisServiceFactories) {
+ super(repositoryPath, axisServiceFactories);
this.secure = secure;
}
Added:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/SimpleAxisServiceFactory.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/SimpleAxisServiceFactory.java?rev=1819246&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/SimpleAxisServiceFactory.java
(added)
+++
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/SimpleAxisServiceFactory.java
Mon Dec 25 12:34:49 2017
@@ -0,0 +1,35 @@
+/*
+ * 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.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+
+public class SimpleAxisServiceFactory implements AxisServiceFactory {
+ private final Class<?> implClass;
+
+ public SimpleAxisServiceFactory(Class<?> implClass) {
+ this.implClass = implClass;
+ }
+
+ @Override
+ public AxisService createService(AxisConfiguration axisConfiguration)
throws Exception {
+ return AxisService.createService(implClass.getName(),
axisConfiguration);
+ }
+}
Propchange:
axis/axis2/java/core/trunk/modules/testutils/src/main/java/org/apache/axis2/testutils/SimpleAxisServiceFactory.java
------------------------------------------------------------------------------
svn:eol-style = native