You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2008/05/15 02:30:18 UTC
svn commit: r656471 - in
/ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2: Axis2TestBase.java
ServiceFaultCatchTest.java TestSimpleScenario.java
Author: mriou
Date: Wed May 14 17:30:18 2008
New Revision: 656471
URL: http://svn.apache.org/viewvc?rev=656471&view=rev
Log:
ODE-271 Axis2TestBase: centralize server management in base class
Modified:
ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/Axis2TestBase.java
ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/ServiceFaultCatchTest.java
ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/TestSimpleScenario.java
Modified: ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/Axis2TestBase.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/Axis2TestBase.java?rev=656471&r1=656470&r2=656471&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/Axis2TestBase.java (original)
+++ ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/Axis2TestBase.java Wed May 14 17:30:18 2008
@@ -2,13 +2,34 @@
import junit.framework.TestCase;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.engine.AxisServer;
+import org.apache.axis2.engine.MessageReceiver;
import org.apache.ode.tools.sendsoap.cline.HttpSoapSender;
+import org.apache.ode.bpel.compiler.wsdl.WSDLFactory4BPEL;
+import org.apache.ode.bpel.compiler.wsdl.WSDLFactoryBPEL20;
+import org.apache.ode.bpel.compiler.wsdl.Definition4BPEL;
+import org.apache.ode.bpel.compiler.DefaultResourceFinder;
+import org.apache.ode.bpel.compiler.WSDLLocatorImpl;
+import org.apache.ode.axis2.util.Axis2UriResolver;
+import org.apache.ode.axis2.util.Axis2WSDLLocator;
+import org.apache.ode.axis2.hooks.ODEAxisService;
+import org.apache.ode.axis2.hooks.ODEMessageReceiver;
import javax.servlet.ServletException;
+import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
import java.io.*;
import java.net.URL;
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Iterator;
/**
* @author Matthieu Riou <mr...@apache.org>
@@ -46,17 +67,56 @@
}
}
+ public void stop() throws AxisFault {
+ super.stop();
+ _ode.shutDown();
+ }
+
protected void deployProcess(String bundleName) {
_ode.getProcessStore().deploy(new File(getBundleDir(bundleName)));
}
protected void undeployProcess(String bundleName) {
_ode.getProcessStore().undeploy(new File(getBundleDir(bundleName)));
}
+ protected boolean isDeployed(String bundleName) {
+ return _ode.getProcessStore().getPackages().contains(bundleName);
+ }
+
+ /**
+ * Creates and deploys an Axis service based on a provided MessageReceiver. The receiver
+ * will be invoked for all invocations of that service.
+ */
+ protected void deployService(String bundleName, String defFile, QName serviceName, String port,
+ MessageReceiver receiver) throws WSDLException, IOException, URISyntaxException {
+ URI wsdlUri = new File(getBundleDir(bundleName) + "/" + defFile).toURI();
+
+ InputStream is = wsdlUri.toURL().openStream();
+ WSDL11ToAxisServiceBuilder serviceBuilder = new ODEAxisService.WSDL11ToAxisPatchedBuilder(is, serviceName, port);
+ serviceBuilder.setBaseUri(wsdlUri.toString());
+ serviceBuilder.setCustomResolver(new Axis2UriResolver());
+ serviceBuilder.setCustomWSLD4JResolver(new Axis2WSDLLocator(wsdlUri));
+ serviceBuilder.setServerSide(true);
+
+ AxisService axisService = serviceBuilder.populateService();
+ axisService.setName(serviceName.getLocalPart());
+ axisService.setWsdlFound(true);
+ axisService.setCustomWsdl(true);
+ axisService.setClassLoader(getConfigurationContext().getAxisConfiguration().getServiceClassLoader());
+
+ Iterator operations = axisService.getOperations();
+ while (operations.hasNext()) {
+ AxisOperation operation = (AxisOperation) operations.next();
+ if (operation.getMessageReceiver() == null) {
+ operation.setMessageReceiver(receiver);
+ }
+ }
+ getConfigurationContext().getAxisConfiguration().addService(axisService);
+ }
protected String sendRequestFile(String endpoint, String bundleName, String filename) {
try {
- return HttpSoapSender.doSend(new URL(endpoint), new FileInputStream(getBundleDir(bundleName)+"/" + filename),
- null, 0, null, null, null);
+ return HttpSoapSender.doSend(new URL(endpoint),
+ new FileInputStream(getBundleDir(bundleName)+"/" + filename), null, 0, null, null, null);
} catch (IOException e) {
throw new RuntimeException(e);
}
Modified: ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/ServiceFaultCatchTest.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/ServiceFaultCatchTest.java?rev=656471&r1=656470&r2=656471&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/ServiceFaultCatchTest.java (original)
+++ ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/ServiceFaultCatchTest.java Wed May 14 17:30:18 2008
@@ -1,10 +1,5 @@
package org.apache.ode.axis2;
-import org.apache.ode.tools.sendsoap.cline.HttpSoapSender;
-
-import java.net.URL;
-import java.io.FileInputStream;
-
/**
* Tests that a fault thrown by a called service can be caught and is properly
* structured so that an assign on a fault sub-element will succeed.
@@ -15,6 +10,9 @@
protected void setUp() throws Exception {
start();
}
+ protected void tearDown() throws Exception {
+ server.stop();
+ }
public void testSimpleFaultCatch() throws Exception {
String bundleName = "TestStructuredFault";
Modified: ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/TestSimpleScenario.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/TestSimpleScenario.java?rev=656471&r1=656470&r2=656471&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/TestSimpleScenario.java (original)
+++ ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/TestSimpleScenario.java Wed May 14 17:30:18 2008
@@ -5,6 +5,10 @@
protected void setUp() throws Exception {
start();
}
+ protected void tearDown() throws Exception {
+ server.stop();
+ }
+
public void testDynPartner() throws Exception {
String bundleName = "TestDynPartner";