[wsas-java-dev] svn commit r1113 - in
branches/wsas/java/standalone-tomcat/java/modules: core
integration integration/test-resources
integration/test-resources/META-INF integration/test/org/wso2
integration/test/org/wso2/codegen/service
integration/test/org/wso2/codegen/service/ajax
integration/test/org/wso2/codegen/service/java
integration/test/org/wso2/tracer/service
integration/test/org/wso2/wsas/rest
standalone-edition/test/org/wso2/wsas
svn at wso2.org
svn at wso2.org
Fri Mar 2 15:35:13 PST 2007
Author: saminda
Date: Fri Mar 2 15:34:43 2007
New Revision: 1113
Added:
branches/wsas/java/standalone-tomcat/java/modules/integration/test-resources/
branches/wsas/java/standalone-tomcat/java/modules/integration/test-resources/META-INF/
branches/wsas/java/standalone-tomcat/java/modules/integration/test-resources/META-INF/integration-services.xml
branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/IntegrationTestSuite.java
Modified:
branches/wsas/java/standalone-tomcat/java/modules/core/pom.xml
branches/wsas/java/standalone-tomcat/java/modules/integration/pom.xml
branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/WSDLInfoServiceTest.java
branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/ajax/AjaxClientGeneratorServiceTest.java
branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/java/JavaClientGeneratorServiceTest.java
branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/tracer/service/TracerServiceIntegrationTest.java
branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/wsas/rest/RestSupportTest.java
branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/wsas/rest/RestWithSchemasTest.java
branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/AbstractTestCase.java
Log:
partially fixed the integration tests
Modified: branches/wsas/java/standalone-tomcat/java/modules/core/pom.xml
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/core/pom.xml (original)
+++ branches/wsas/java/standalone-tomcat/java/modules/core/pom.xml Fri Mar 2 15:34:43 2007
@@ -40,6 +40,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<inherited>true</inherited>
<configuration>
+ <!--<forkMode>pertest</forkMode>-->
+ <argLine>-enableassertions</argLine>
<testFailureIgnore>false</testFailureIgnore>
<skip>false</skip>
<excludes>
@@ -161,9 +163,10 @@
<fileset dir="conf/hibernate"/>
</copy>
<delete file="target/test-classes/wso2wsas.hibernate.cfg.xml"/>
- <copy tofile="target/test-classes/wso2wsas.hibernate.cfg.xml">
- <fileset file="conf/hibernate/test-hibernate.cfg.xml"/>
- </copy>
+ <copy file="conf/hibernate/test-hibernate.cfg.xml"
+ tofile="target/test-classes/wso2wsas.hibernate.cfg.xml"/>
+ <copy file="conf/log4j.properties"
+ tofile="target/test-classes/log4j.properties"/>
</tasks>
</configuration>
Modified: branches/wsas/java/standalone-tomcat/java/modules/integration/pom.xml
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/integration/pom.xml (original)
+++ branches/wsas/java/standalone-tomcat/java/modules/integration/pom.xml Fri Mar 2 15:34:43 2007
@@ -124,49 +124,20 @@
<artifactId>maven-surefire-plugin</artifactId>
<inherited>false</inherited>
<configuration>
+ <forkMode>pertest</forkMode>
+ <argLine>-enableassertions</argLine>
<testFailureIgnore>false</testFailureIgnore>
<skip>false</skip>
- <excludes>
- <exclude>**/*Abstract*.java</exclude>
- <exclude>**/*JavaClientGeneratorServiceTest.java</exclude>
- <exclude>**/*TraderServiceIntegrationTest.java</exclude>
- <exclude>**/*CommodityQuoteServiceIntegrationTest.java</exclude>
- </excludes>
+ <forkMode>pertest</forkMode>
+ <argLine>-enableassertions</argLine>
<includes>
- <include>**/*Test.java</include>
+ <include>**/*IntegrationTestSuite.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.0-alpha-1-SNAPSHOT</version>
- <executions>
- <execution>
- <id>copy</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.axis2</groupId>
- <artifactId>addressing</artifactId>
- <version>${addressing.version}</version>
- <type>mar</type>
- <overWrite>true</overWrite>
- <outputDirectory>target/repository/modules</outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
@@ -175,56 +146,34 @@
<phase>generate-test-resources</phase>
<configuration>
<tasks>
- <!-- 1. Generate key -->
- <delete file="conf/wso2wsas.jks" failonerror="false"/>
- <genkey alias="wso2wsas" storepass="wso2wsas" keyalg="RSA"
- keystore="conf/wso2wsas.jks"
- validity="99999">
- <dname>
- <param name="CN" value="WSO2WSAS"/>
- <param name="OU" value=""/>
- <param name="O" value="WSO2"/>
- <param name="C" value="LK"/>
- </dname>
- </genkey>
- <!--2. Test cases related repository -->
<mkdir dir="target/test-classes"/>
- <mkdir dir="target/repository"/>
+ <mkdir dir="target/tmp/service"/>
- <copy tofile="target/test-classes/wso2wsas.hibernate.cfg.xml">
- <fileset file="../core/conf/hibernate/test-hibernate.cfg.xml"/>
- </copy>
+ <copy file="test-resources/META-INF/integration-services.xml"
+ tofile="target/tmp/service/META-INF/services.xml"/>
+ <jar jarfile="target/wso2wsas-test-integration.aar"
+ basedir="target/tmp/service">
+ <include name="**"/>
+ </jar>
+
+ <delete dir="target/tmp"/>
+
+ <copy file="../core/conf/hibernate/test-hibernate.cfg.xml"
+ tofile="target/test-classes/wso2wsas.hibernate.cfg.xml"/>
+ <copy file="../standalone-edition/test-resources/wso2wsas.properties"
+ tofile="target/test-classes/wso2wsas.properties"/>
+ <copy file="../core/conf/log4j.properties"
+ tofile="target/test-classes/log4j.properties"/>
- <copy todir="target/repository">
- <fileset file="../core/test-resources/axis2.xml"/>
- </copy>
- <copy todir="target/test-classes">
- <fileset dir="../core/conf/hibernate"/>
- </copy>
- <copy todir="target/repository/modules">
- <fileset
- file="../admin/target/wso2wsas-admin-${wso2wsas.version}.mar"/>
- </copy>
- <copy tofile="target/test-classes/wso2wsas.hibernate.cfg.xml">
- <fileset file="../core/conf/hibernate/test-hibernate.cfg.xml"/>
+ <copy todir="target/tomcat_test">
+ <fileset dir="../standalone-edition/target/tomcat_test"/>
</copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>populate_repo</id>
- <phase>process-test-resources</phase>
- <configuration>
- <tasks>
- <!-- 1. Processing Hibernate config and hbm xmls to test cases. Should find a
- better way to do this.
- -->
+ <copy todir="target/tomcat_test/repository/modules"
+ file="../admin/target/wso2wsas-admin-${wso2wsas.version}.mar"/>
+ <copy file="target/wso2wsas-test-integration.aar"
+ tofile="target/tomcat_test/repository/services/wso2wsas-test-integration.aar"/>
</tasks>
</configuration>
Added: branches/wsas/java/standalone-tomcat/java/modules/integration/test-resources/META-INF/integration-services.xml
==============================================================================
--- (empty file)
+++ branches/wsas/java/standalone-tomcat/java/modules/integration/test-resources/META-INF/integration-services.xml Fri Mar 2 15:34:43 2007
@@ -0,0 +1,63 @@
+<serviceGroup>
+ <service name="WSDLInfoService" scope="transportsession">
+ <schema schemaNamespace="http://org.apache.axis2/xsd" elementFormDefaultQualified="false"/>
+ <transports>
+ <transport>http</transport>
+ </transports>
+ <description>
+ This service will give WSDL binding information
+ </description>
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
+ </messageReceivers>
+ <parameter name="ServiceClass">
+ org.wso2.codegen.service.WSDLInfoService</parameter>
+ </service>
+ <service name="JavaClientGeneratorService" scope="transportsession">
+ <transports>
+ <transport>http</transport>
+ </transports>
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.wso2.codegen.service.java.JavaClientGeneratorServiceMessageReceiverInOut"/>
+ </messageReceivers>
+ <parameter locked="false" name="ServiceClass">
+ org.wso2.codegen.service.java.JavaClientGeneratorService</parameter>
+ <operation name="generate" mep="http://www.w3.org/2004/08/wsdl/in-out">
+ <actionMapping>generate</actionMapping>
+ </operation>
+ </service>
+ <service name="AjaxClientGeneratorService" scope="transportsession">
+ <transports>
+ <transport>http</transport>
+ </transports>
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.wso2.codegen.service.ajax.AjaxClientGeneratorServiceMessageReceiverInOut"/>
+ </messageReceivers>
+ <parameter locked="false" name="ServiceClass">
+ org.wso2.codegen.service.ajax.AjaxClientGeneratorService</parameter>
+ <operation name="generateAjaxClient"
+ mep="http://www.w3.org/2004/08/wsdl/in-out">
+ <actionMapping>generateAjaxClient</actionMapping>
+ </operation>
+ </service>
+
+ <service name="Calculator" scope="transportsession">
+ <schema schemaNamespace="http://org.apache.axis2/xsd" elementFormDefaultQualified="false"/>
+ <transports>
+ <transport>http</transport>
+ </transports>
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
+ </messageReceivers>
+ <parameter locked="false" name="ServiceClass">org.wso2.wsas.util.Calculator</parameter>
+ <operation name="add"
+ mep="http://www.w3.org/2004/08/wsdl/in-out">
+ <actionMapping>add</actionMapping>
+ </operation>
+ </service>
+
+</serviceGroup>
\ No newline at end of file
Added: branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/IntegrationTestSuite.java
==============================================================================
--- (empty file)
+++ branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/IntegrationTestSuite.java Fri Mar 2 15:34:43 2007
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.wso2;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.framework.TestCase;
+import junit.extensions.TestSetup;
+import org.wso2.codegen.service.ajax.AjaxClientGeneratorServiceTest;
+import org.wso2.codegen.service.java.JavaClientGeneratorServiceTest;
+import org.wso2.codegen.service.WSDLInfoServiceTest;
+import org.wso2.tracer.service.TracerServiceIntegrationTest;
+import org.wso2.wsas.rest.RestSupportTest;
+import org.wso2.wsas.rest.RestWithSchemasTest;
+import org.wso2.wsas.sample.commodityquote.CommodityQuoteServiceIntegrationTest;
+import org.wso2.wsas.sample.trader.TraderServiceIntegrationTest;
+import org.wso2.wsas.ServerConstants;
+import org.wso2.wsas.util.ServerUtils;
+import org.wso2.utils.ServerConfiguration;
+/*
+ *
+ */
+
+public class IntegrationTestSuite extends TestCase {
+
+ private static ServerUtils serverUtils;
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Integration Tests");
+
+ suite.addTestSuite(AjaxClientGeneratorServiceTest.class);
+ suite.addTestSuite(WSDLInfoServiceTest.class);
+// suite.addTestSuite(RestSupportTest.class);
+// suite.addTestSuite(RestWithSchemasTest.class);
+
+ /*suite.addTestSuite(JavaClientGeneratorServiceTest.class);
+ suite.addTestSuite(CommodityQuoteServiceIntegrationTest.class);
+ suite.addTestSuite(TracerServiceIntegrationTest.class);*/
+
+
+
+ return new TestSetup(suite) {
+ protected void setUp() throws Exception {
+ System.setProperty(ServerConstants.DERBY_HOME, "conf");
+ System.setProperty(ServerConstants.WSO2WSAS_ADMIN_PASSWORD, "abc");
+ System.setProperty(org.apache.axis2.Constants.AXIS2_CONF,
+ "target/tomcat_test/conf/axis2.xml");
+ System.setProperty(ServerConstants.WSO2WSAS_HOME, "target/tomcat_test");
+ ServerConfiguration.configurationXMLLocation = "target/tomcat_test/conf/server.xml";
+
+ serverUtils = new ServerUtils();
+ serverUtils.startServer();
+ }
+
+ protected void tearDown() throws Exception {
+ }
+
+
+ };
+
+
+ }
+
+ public void testEmpty() throws Exception{
+ // This is only to get the Maven2 build going. Please dont remove this methd.
+ }
+}
Modified: branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/WSDLInfoServiceTest.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/WSDLInfoServiceTest.java (original)
+++ branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/WSDLInfoServiceTest.java Fri Mar 2 15:34:43 2007
@@ -17,6 +17,7 @@
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
+import org.apache.axis2.addressing.EndpointReference;
import org.wso2.wsas.ServerConstants;
import org.wso2.wsas.TestConstants;
import org.wso2.wsas.AbstractTestCase;
@@ -27,30 +28,17 @@
public class WSDLInfoServiceTest extends AbstractTestCase {
- private WSDLInfoServiceStub client;
-
- protected void setUp() {
- try {
- super.setUp("../standalone-edition/conf/server.xml");
-
- ConfigurationContext configContext = getConfigContext();
- configContext.setProperty(ServerConstants.FILE_RESOURCE_MAP,
- new Hashtable());
-
- ServerUtils.deployService(configContext,
- WSDLInfoService.class.getName(), RPCMessageReceiver.class,
- "http://org.apache.axis2/xsd", "http://org.apache.axis2/xsd");
+ public void testListServicesAndPorts() throws Exception {
- client = new WSDLInfoServiceStub("http://" +
+ EndpointReference epr = new EndpointReference("http://" +
NetworkUtils.getLocalHostname() + ":" +
(TestConstants.TESTING_PORT) + "/soap/" +
"WSDLInfoService");
- } catch (Exception e) {
- fail("Unexpected Exception " + e);
- }
- }
+ testConnect(epr);
+ removeProperties();
+
+ WSDLInfoServiceStub client = new WSDLInfoServiceStub(null,epr.getAddress());
- public void testListServicesAndPorts() throws Exception {
WSDLInfoServiceStub.ListServicesAndPorts req = new WSDLInfoServiceStub.ListServicesAndPorts();
req.setServiceName("WSDLInfoService");
Modified: branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/ajax/AjaxClientGeneratorServiceTest.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/ajax/AjaxClientGeneratorServiceTest.java (original)
+++ branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/ajax/AjaxClientGeneratorServiceTest.java Fri Mar 2 15:34:43 2007
@@ -19,6 +19,7 @@
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
+import org.apache.axis2.addressing.EndpointReference;
import org.wso2.wsas.ServerConstants;
import org.wso2.wsas.TestConstants;
import org.wso2.wsas.AbstractTestCase;
@@ -31,52 +32,27 @@
import java.util.Hashtable;
public class AjaxClientGeneratorServiceTest extends AbstractTestCase {
- private AjaxClientGeneratorServiceStub client;
-
- protected void setUp() {
- try {
- ServerConfiguration.configurationXMLLocation = "../standalone-edition/conf/server.xml";
- super.setUp();
-
- ConfigurationContext configContext = getConfigContext();
- configContext.setProperty(ServerConstants.FILE_RESOURCE_MAP,
- new Hashtable());
-
- System.setProperty("org.apache.axis2.codegen.config",
- "/codegen-config.properties");
- ConfigPropertyFileLoader.reload();
-
- ServerUtils.deployService(configContext,
- AjaxClientGeneratorService.class.getName(),
- AjaxClientGeneratorServiceMessageReceiverInOut.class);
- ServerUtils.deployService(configContext, Version.class.getName(),
- RPCMessageReceiver.class);
-
- AjaxClientGeneratorService.testCodegenOutputDirectory = "target/work" +
- File.separator + "codegen";
-
- client = new AjaxClientGeneratorServiceStub("http://" +
- NetworkUtils.getLocalHostname() + ":" +
- (TestConstants.TESTING_PORT) + "/soap/" +
- "AjaxClientGeneratorService");
-
- AxisConfiguration axisConfig = getConfigContext()
- .getAxisConfiguration();
- System.out.println("axisConfig = " + axisConfig);
- } catch (Exception e) {
- fail("Unexpected Exception " + e);
- }
- }
public void testListServicesAndPorts() throws Exception {
+
+ EndpointReference epr = new EndpointReference("http://" +
+ NetworkUtils.getLocalHostname() + ":" +
+ (TestConstants.TESTING_PORT) + "/soap/" +
+ "AjaxClientGeneratorService");
+ testConnect(epr);
+ removeProperties();
+
+
+ AjaxClientGeneratorServiceStub client =
+ new AjaxClientGeneratorServiceStub(null, epr.getAddress());
+
AjaxClientGeneratorServiceStub.GenerateAjaxClient req =
new AjaxClientGeneratorServiceStub.GenerateAjaxClient();
- req.setServiceName("Version");
+ req.setServiceName("version");
AjaxClientGeneratorServiceStub.GenerateAjaxClientResponse response =
client.generateAjaxClient(req);
assertNotNull(response);
- System.out.println("Response :" + response.toString());
}
}
Modified: branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/java/JavaClientGeneratorServiceTest.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/java/JavaClientGeneratorServiceTest.java (original)
+++ branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/codegen/service/java/JavaClientGeneratorServiceTest.java Fri Mar 2 15:34:43 2007
@@ -45,7 +45,7 @@
final QName operationName = new QName("generate");
- ConfigurationContext configContext = getConfigContext();
+ ConfigurationContext configContext = null;
configContext.setProperty(ServerConstants.FILE_RESOURCE_MAP,
new Hashtable());
Modified: branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/tracer/service/TracerServiceIntegrationTest.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/tracer/service/TracerServiceIntegrationTest.java (original)
+++ branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/tracer/service/TracerServiceIntegrationTest.java Fri Mar 2 15:34:43 2007
@@ -53,7 +53,7 @@
persistenceMgr = new PersistenceManager(hbConfig);
serviceName = new QName("TracerService");
- ConfigurationContext configContext = getConfigContext();
+ ConfigurationContext configContext = null;
CircularBuffer circularBuffer = new CircularBuffer();
for (int i = 0; i < 4; i++) {
Modified: branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/wsas/rest/RestSupportTest.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/wsas/rest/RestSupportTest.java (original)
+++ branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/wsas/rest/RestSupportTest.java Fri Mar 2 15:34:43 2007
@@ -21,17 +21,12 @@
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.engine.Phase;
-import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
import org.apache.axis2.transport.http.HTTPConstants;
+import org.wso2.utils.NetworkUtils;
+import org.wso2.wsas.AbstractTestCase;
import org.wso2.wsas.ServerConstants;
import org.wso2.wsas.TestConstants;
-import org.wso2.wsas.AbstractTestCase;
-import org.wso2.wsas.util.MessageExposeHandler;
-import org.wso2.wsas.util.ServerUtils;
-import org.wso2.utils.NetworkUtils;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
@@ -39,60 +34,46 @@
import javax.xml.stream.XMLStreamReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
public class RestSupportTest extends AbstractTestCase {
QName serviceName = new QName("Calculator");
QName operationName = new QName("add");
- private String eprString;
- private MessageExposeHandler handler;
+ private EndpointReference epr;
protected void setUp() throws Exception {
- super.setUp();
- String hostAddress = NetworkUtils.getLocalHostname();
- eprString = "http://" + hostAddress + ":"
- + (TestConstants.TESTING_PORT)
- + "/rest/" + serviceName.getLocalPart() + "/" + operationName.getLocalPart();
-
- ConfigurationContext configContext = getConfigContext();
- ServerUtils.deployService(configContext,
- org.wso2.wsas.util.Calculator.class.getName(),
- RPCMessageReceiver.class,
- "http://org.apache.axis2/xsd",
- "http://org.apache.axis2/xsd");
-
- // add handler to IN path to intercept the message
- handler = new MessageExposeHandler();
- ArrayList inPhasesUptoAndIncludingPostDispatch =
- configContext.getAxisConfiguration().getGlobalInFlow();
- Phase phaseOne = (Phase) inPhasesUptoAndIncludingPostDispatch.get(0);
- phaseOne.addHandler(handler);
+ epr = new EndpointReference("http://" + NetworkUtils.getLocalHostname() + ":"
+ + (TestConstants.TESTING_PORT)
+ + "/rest/" + serviceName.getLocalPart() + "/" +
+ operationName.getLocalPart());
+ testConnect(epr);
+ removeProperties();
+
}
+
public void testRESTGetInvocationWithAllParamsInURL() throws IOException {
OMElement data = getRequestOMElement();
Options options = new Options();
- options.setTo(new EndpointReference(eprString));
+ options.setTo(epr);
options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
options.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTP);
options.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE,
ServerConstants.HTTPConstants.MEDIA_TYPE_X_WWW_FORM);
options.setProperty(org.apache.axis2.Constants.Configuration.HTTP_METHOD,
org.apache.axis2.Constants.Configuration.HTTP_METHOD_GET);
- options.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_REST,Boolean.TRUE);
+ options.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_REST, Boolean.TRUE);
ServiceClient sender =
new ServiceClient(ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(null,null),null);
+ createConfigurationContextFromFileSystem(null, null), null);
sender.setOptions(options);
OMElement response = sender.sendReceive(data);
response.build();
- verifySOAPEnvelopeContentUsingHandler();
+ verifySOAPEnvelopeContentUsingHandler(response);
assertTrue("25".equals(response.getFirstElement().getText()));
}
@@ -101,7 +82,7 @@
OMElement data = getRequestOMElement();
Options options = new Options();
- options.setTo(new EndpointReference(eprString));
+ options.setTo(epr);
options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
options.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTP);
options.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE,
@@ -118,12 +99,12 @@
ServiceClient sender =
new ServiceClient(ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(null,null),null);
+ createConfigurationContextFromFileSystem(null, null), null);
sender.setOptions(options);
OMElement response = sender.sendReceive(data);
response.build();
- verifySOAPEnvelopeContentUsingHandler();
+ verifySOAPEnvelopeContentUsingHandler(response);
assertTrue("25".equals(response.getFirstElement().getText()));
}
@@ -132,7 +113,7 @@
OMElement data = getRequestOMElement();
Options options = new Options();
- options.setTo(new EndpointReference(eprString));
+ options.setTo(epr);
options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
options.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTP);
options.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE,
@@ -145,12 +126,12 @@
ServiceClient sender =
new ServiceClient(ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(null,null),null);
+ createConfigurationContextFromFileSystem(null, null), null);
sender.setOptions(options);
OMElement response = sender.sendReceive(data);
response.build();
- verifySOAPEnvelopeContentUsingHandler();
+ verifySOAPEnvelopeContentUsingHandler(response);
assertTrue("25".equals(response.getFirstElement().getText()));
}
@@ -159,7 +140,7 @@
OMElement data = getRequestOMElement();
Options options = new Options();
- options.setTo(new EndpointReference(eprString));
+ options.setTo(epr);
options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
options.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTP);
options.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE,
@@ -176,12 +157,12 @@
ServiceClient sender =
new ServiceClient(ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(null,null),null);
+ createConfigurationContextFromFileSystem(null, null), null);
sender.setOptions(options);
OMElement response = sender.sendReceive(data);
response.build();
- verifySOAPEnvelopeContentUsingHandler();
+ verifySOAPEnvelopeContentUsingHandler(response);
assertTrue("25".equals(response.getFirstElement().getText()));
}
@@ -190,7 +171,7 @@
OMElement data = getRequestOMElement();
Options options = new Options();
- options.setTo(new EndpointReference(eprString));
+ options.setTo(epr);
options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
options.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTP);
options.setProperty(HTTPConstants.HEADER_CONTENT_TYPE,
@@ -202,7 +183,7 @@
ServiceClient sender =
new ServiceClient(ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(null,null),null);
+ createConfigurationContextFromFileSystem(null, null), null);
sender.setOptions(options);
OMElement response = sender.sendReceive(data);
response.build();
@@ -211,22 +192,6 @@
}
- private void verifySOAPEnvelopeContentUsingHandler() {
- Iterator elementIter =
- handler.getSoapEnvelope().getBody().getFirstElement().getChildElements();
- int index = 1;
- while (elementIter.hasNext()) {
- OMElement omElement = (OMElement) elementIter.next();
- if (index++ == 1) {
- assertTrue((omElement != null) && "firstNumber".equals(omElement.getLocalName()));
- } else if (index++ == 2) {
- assertTrue((omElement != null) && "secondNumber".equals(omElement.getLocalName()));
- } else if (index++ == 3) {
- assertTrue((omElement != null) && "thirdNumber".equals(omElement.getLocalName()));
- }
- }
- }
-
public OMElement getRequestOMElement() {
String xml =
"<ns:add xmlns:ns=\"http://org.apache.axis2/xsd\">" +
Modified: branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/wsas/rest/RestWithSchemasTest.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/wsas/rest/RestWithSchemasTest.java (original)
+++ branches/wsas/java/standalone-tomcat/java/modules/integration/test/org/wso2/wsas/rest/RestWithSchemasTest.java Fri Mar 2 15:34:43 2007
@@ -16,18 +16,11 @@
*/
package org.wso2.wsas.rest;
-import org.wso2.wsas.ServerConstants;
-import org.wso2.wsas.TestConstants;
-import org.wso2.wsas.AbstractTestCase;
-import org.wso2.wsas.util.MessageExposeHandler;
-import org.wso2.utils.NetworkUtils;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.engine.Phase;
-import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
+import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethodBase;
@@ -35,6 +28,10 @@
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
+import org.wso2.utils.NetworkUtils;
+import org.wso2.wsas.AbstractTestCase;
+import org.wso2.wsas.ServerConstants;
+import org.wso2.wsas.TestConstants;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
@@ -46,44 +43,27 @@
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
public class RestWithSchemasTest extends AbstractTestCase {
QName serviceName = new QName("Calculator");
QName operationName = new QName("add");
- private String eprString;
- private ConfigurationContext configContext;
- private MessageExposeHandler handler;
+ private EndpointReference epr;
protected void setUp() throws Exception {
- super.setUp();
- String hostAddress = NetworkUtils.getLocalHostname();
- eprString = "http://" + hostAddress + ":"
- + (TestConstants.TESTING_PORT)
- + "/rest/" + serviceName.getLocalPart() + "/" + operationName.getLocalPart();
-
- configContext = getConfigContext();
- serverUtils.deployService(configContext,
- org.wso2.wsas.util.Calculator.class.getName(),
- RPCMessageReceiver.class,
- "http://org.apache.axis2/xsd",
- "http://org.apache.axis2/xsd");
-
- // add handler to IN path to intercept the message
- handler = new MessageExposeHandler();
- ArrayList inPhasesUptoAndIncludingPostDispatch = configContext.getAxisConfiguration().getGlobalInFlow();
- Phase phaseOne = (Phase) inPhasesUptoAndIncludingPostDispatch.get(0);
- phaseOne.addHandler(handler);
-
+ epr = new EndpointReference("http://" + NetworkUtils.getLocalHostname() + ":"
+ + (TestConstants.TESTING_PORT)
+ + "/rest/" + serviceName.getLocalPart() + "/" +
+ operationName.getLocalPart());
+ testConnect(epr);
+ removeProperties();
}
public void testRESTGetInvocationWithAllParamsInURL() throws IOException {
URL url = null;
try {
- url = new URL(eprString);
+ url = new URL(epr.getAddress());
} catch (MalformedURLException e) {
fail("Malformed EPR " + e);
}
@@ -95,11 +75,12 @@
GetMethod getMethod = new GetMethod(url.toString());
executeWithAllParamsInURL(url, nameValuePairs, getMethod);
- verifySOAPEnvelopeContentUsingHandler();
try {
- OMElement documentElement = new StAXOMBuilder(getMethod.getResponseBodyAsStream()).getDocumentElement();
+ OMElement documentElement =
+ new StAXOMBuilder(getMethod.getResponseBodyAsStream()).getDocumentElement();
documentElement.build();
+ verifySOAPEnvelopeContentUsingHandler(documentElement);
assertTrue("25".equals(documentElement.getFirstElement().getText()));
} catch (XMLStreamException e) {
e.printStackTrace();
@@ -109,7 +90,7 @@
public void testRESTPostInvocationWithAllParamsInURL() throws IOException {
URL url = null;
try {
- url = new URL(eprString);
+ url = new URL(epr.getAddress());
} catch (MalformedURLException e) {
fail("Malformed EPR " + e);
}
@@ -121,11 +102,11 @@
PostMethod postMethod = new PostMethod(url.toString());
executeWithAllParamsInURL(url, nameValuePairs, postMethod);
- verifySOAPEnvelopeContentUsingHandler();
-
try {
- OMElement documentElement = new StAXOMBuilder(postMethod.getResponseBodyAsStream()).getDocumentElement();
+ OMElement documentElement =
+ new StAXOMBuilder(postMethod.getResponseBodyAsStream()).getDocumentElement();
documentElement.build();
+ verifySOAPEnvelopeContentUsingHandler(documentElement);
assertTrue("25".equals(documentElement.getFirstElement().getText()));
} catch (XMLStreamException e) {
e.printStackTrace();
@@ -135,7 +116,7 @@
public void testRESTPostInvocationWithAllParamsInBody() throws IOException {
URL url = null;
try {
- url = new URL(eprString);
+ url = new URL(epr.getAddress());
} catch (MalformedURLException e) {
fail("Malformed EPR " + e);
}
@@ -146,12 +127,11 @@
PostMethod postMethod = new PostMethod(url.toString());
executePostWithAllParamsInBody(url, NameValuePairs, postMethod);
- verifySOAPEnvelopeContentUsingHandler();
-
try {
- OMElement documentElement = new StAXOMBuilder(postMethod.getResponseBodyAsStream()).getDocumentElement();
+ OMElement documentElement =
+ new StAXOMBuilder(postMethod.getResponseBodyAsStream()).getDocumentElement();
documentElement.build();
-
+ verifySOAPEnvelopeContentUsingHandler(documentElement);
assertTrue("25".equals(documentElement.getFirstElement().getText()));
} catch (XMLStreamException e) {
e.printStackTrace();
@@ -161,7 +141,7 @@
public void testRESTPostInvocationWithParamsInUrlAndBody() throws IOException {
URL url = null;
try {
- url = new URL(eprString);
+ url = new URL(epr.getAddress());
} catch (MalformedURLException e) {
fail("Malformed EPR " + e);
}
@@ -173,12 +153,11 @@
PostMethod postMethod = new PostMethod(url.toString());
executePostWithParamsInUrlAndBody(url, urlNameValuePairs, bodyNameValuePairs, postMethod);
- verifySOAPEnvelopeContentUsingHandler();
-
try {
- OMElement documentElement = new StAXOMBuilder(postMethod.getResponseBodyAsStream()).getDocumentElement();
+ OMElement documentElement =
+ new StAXOMBuilder(postMethod.getResponseBodyAsStream()).getDocumentElement();
documentElement.build();
-
+ verifySOAPEnvelopeContentUsingHandler(documentElement);
assertTrue("25".equals(documentElement.getFirstElement().getText()));
} catch (XMLStreamException e) {
e.printStackTrace();
@@ -188,7 +167,7 @@
public void testRESTPostInvocationAsTextXML() {
URL url = null;
try {
- url = new URL(eprString);
+ url = new URL(epr.getAddress());
} catch (MalformedURLException e) {
fail("Malformed EPR " + e);
}
@@ -239,27 +218,11 @@
OMElement responseElement = responseBuilder.getDocumentElement();
responseElement.build();
- verifySOAPEnvelopeContentUsingHandler();
+ verifySOAPEnvelopeContentUsingHandler(responseElement);
assertTrue("25".equals(responseElement.getFirstElement().getText()));
}
- private void verifySOAPEnvelopeContentUsingHandler() {
- Iterator elementIter =
- handler.getSoapEnvelope().getBody().getFirstElement().getChildElements();
- int index = 1;
- while (elementIter.hasNext()) {
- OMElement omElement = (OMElement) elementIter.next();
- if (index++ == 1) {
- assertTrue((omElement != null) && "firstNumber".equals(omElement.getLocalName()));
- } else if (index++ == 2) {
- assertTrue((omElement != null) && "secondNumber".equals(omElement.getLocalName()));
- } else if (index++ == 3) {
- assertTrue((omElement != null) && "thirdNumber".equals(omElement.getLocalName()));
- }
- }
- }
-
private HttpMethodBase executeWithAllParamsInURL(URL url,
NameValuePair[] nameValuePairs,
HttpMethodBase method) {
Modified: branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/AbstractTestCase.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/AbstractTestCase.java (original)
+++ branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/AbstractTestCase.java Fri Mar 2 15:34:43 2007
@@ -28,6 +28,7 @@
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Iterator;
public class AbstractTestCase extends XMLTestCase {
@@ -96,4 +97,19 @@
System.getProperties().remove(org.apache.axis2.Constants.AXIS2_CONF);
}
+ public void verifySOAPEnvelopeContentUsingHandler(OMElement element) {
+ int index = 1;
+ for (Iterator iterator = element.getChildElements(); iterator.hasNext();) {
+ OMElement omElement = (OMElement) iterator.next();
+ if (index++ == 1) {
+ assertTrue((omElement != null) && "firstNumber".equals(omElement.getLocalName()));
+ } else if (index++ == 2) {
+ assertTrue((omElement != null) && "secondNumber".equals(omElement.getLocalName()));
+ } else if (index++ == 3) {
+ assertTrue((omElement != null) && "thirdNumber".equals(omElement.getLocalName()));
+ }
+
+ }
+ }
+
}
More information about the Wsas-java-dev
mailing list