Modified: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/security/SecurityTest.java URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/security/SecurityTest.java?view=diff&rev=464827&r1=464826&r2=464827 ============================================================================== --- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/security/SecurityTest.java (original) +++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/security/SecurityTest.java Mon Oct 16 23:35:33 2006 @@ -1,118 +1,119 @@ -/* - * Copyright 2006 The Apache Software Foundation. - * Copyright 2006 International Business Machines Corp. - * - * 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.apache.sandesha2.security; - -import java.io.File; - -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.context.MessageContextConstants; -import org.apache.axis2.transport.http.SimpleHTTPServer; -import org.apache.sandesha2.Sandesha2Constants; -import org.apache.sandesha2.SandeshaException; -import org.apache.sandesha2.SandeshaTestCase; -import org.apache.sandesha2.client.SandeshaClient; -import org.apache.sandesha2.client.SandeshaClientConstants; -import org.apache.sandesha2.client.SequenceReport; -import org.apache.sandesha2.util.SandeshaUtil; - -/** - * Low-level testcases for the Security handling. This test mostly checks that the code can - * read and write the SecurityTokenReference elements that we expect to find within the create - * sequence messgaes. - */ -public class SecurityTest extends SandeshaTestCase { - - private int serverPort = DEFAULT_SERVER_TEST_PORT; - private SimpleHTTPServer httpServer; - - public SecurityTest(String name) { - super(name); - } - - public void setUp () throws Exception { - super.setUp(); - - String repoPath = "target" + File.separator + "repos" + File.separator + "secure-server"; - String axis2_xml = repoPath + File.separator + "server_axis2.xml"; - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - - String serverPortStr = getTestProperty("test.server.port"); - if(serverPortStr != null) serverPort = Integer.parseInt(serverPortStr); - - httpServer = new SimpleHTTPServer (configContext,serverPort); - httpServer.start(); - Thread.sleep(300); - - } - - public void tearDown () throws Exception { - if (httpServer!=null) { - httpServer.stop(); - httpServer = null; - } - - Thread.sleep(300); - super.tearDown(); - } - - // Test the create sequence flow for the 2 spec versions - public void testCreateSequence() - throws Exception - { - createSequence(Sandesha2Constants.SPEC_VERSIONS.v1_0); - createSequence(Sandesha2Constants.SPEC_VERSIONS.v1_1); - } - - // Check that we can send a create sequence that includes a token reference. - public void createSequence(String spec) throws Exception { - String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - - String repoPath = "target" + File.separator + "repos" + File.separator + "secure-client"; - String axis2_xml = repoPath + File.separator + "client_axis2.xml"; - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - ServiceClient serviceClient = new ServiceClient (configContext,null); - String sequenceKey = SandeshaUtil.getUUID(); - - Options clientOptions = new Options (); - - clientOptions.setTo(new EndpointReference (to)); - clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,to); - clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); - clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION, spec); - serviceClient.setOptions(clientOptions); - - SandeshaClient.createSequence(serviceClient,false); - - SequenceReport sequenceReport = null; - for(int i = 0; i < 15; i++) { - Thread.sleep(1000); - sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); - if(sequenceReport.getSequenceID() != null) break; - } - assertTrue(sequenceReport.isSecureSequence()); - - serviceClient.finalizeInvoke(); - } - -} +/* + * Copyright 2006 The Apache Software Foundation. + * Copyright 2006 International Business Machines Corp. + * + * 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.apache.sandesha2.security; + +import java.io.File; + +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.context.MessageContextConstants; +import org.apache.axis2.transport.http.SimpleHTTPServer; +import org.apache.sandesha2.Sandesha2Constants; +import org.apache.sandesha2.SandeshaException; +import org.apache.sandesha2.SandeshaTestCase; +import org.apache.sandesha2.client.SandeshaClient; +import org.apache.sandesha2.client.SandeshaClientConstants; +import org.apache.sandesha2.client.SequenceReport; +import org.apache.sandesha2.util.SandeshaUtil; + +/** + * Low-level testcases for the Security handling. This test mostly checks that the code can + * read and write the SecurityTokenReference elements that we expect to find within the create + * sequence messgaes. + */ +public class SecurityTest extends SandeshaTestCase { + + private int serverPort = DEFAULT_SERVER_TEST_PORT; + private SimpleHTTPServer httpServer; + + public SecurityTest(String name) { + super(name); + } + + public void setUp () throws Exception { + super.setUp(); + + String repoPath = "target" + File.separator + "repos" + File.separator + "secure-server"; + String axis2_xml = repoPath + File.separator + "server_axis2.xml"; + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + + String serverPortStr = getTestProperty("test.server.port"); + if(serverPortStr != null) serverPort = Integer.parseInt(serverPortStr); + + httpServer = new SimpleHTTPServer (configContext,serverPort); + httpServer.start(); + Thread.sleep(300); + + } + + public void tearDown () throws Exception { + if (httpServer!=null) { + httpServer.stop(); + httpServer = null; + } + + Thread.sleep(300); + super.tearDown(); + } + + // Test the create sequence flow for the 2 spec versions + public void testCreateSequence() + throws Exception + { + createSequence(Sandesha2Constants.SPEC_VERSIONS.v1_0); + createSequence(Sandesha2Constants.SPEC_VERSIONS.v1_1); + } + + // Check that we can send a create sequence that includes a token reference. + public void createSequence(String spec) throws Exception { + String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + + String repoPath = "target" + File.separator + "repos" + File.separator + "secure-client"; + String axis2_xml = repoPath + File.separator + "client_axis2.xml"; + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + ServiceClient serviceClient = new ServiceClient (configContext,null); + String sequenceKey = SandeshaUtil.getUUID(); + + Options clientOptions = new Options (); + + clientOptions.setTo(new EndpointReference (to)); + clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,to); + clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); + clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION, spec); + serviceClient.setOptions(clientOptions); + + SandeshaClient.createSequence(serviceClient,false); + + SequenceReport sequenceReport = null; + for(int i = 0; i < 15; i++) { + Thread.sleep(1000); + sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); + if(sequenceReport.getSequenceID() != null) break; + } + assertTrue(sequenceReport.isSecureSequence()); + + configContext.getListenerManager().stop(); + serviceClient.cleanup(); + } + +}
Modified: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java?view=diff&rev=464827&r1=464826&r2=464827 ============================================================================== --- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java (original) +++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java Mon Oct 16 23:35:33 2006 @@ -1,187 +1,189 @@ -/* - * 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.apache.sandesha2.versions; - -import java.io.File; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMNamespace; -import org.apache.axiom.soap.SOAP11Constants; -import org.apache.axis2.AxisFault; -import org.apache.axis2.addressing.AddressingConstants; -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.context.MessageContextConstants; -import org.apache.axis2.transport.http.SimpleHTTPServer; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.sandesha2.SandeshaException; -import org.apache.sandesha2.SandeshaTestCase; -import org.apache.sandesha2.client.SandeshaClient; -import org.apache.sandesha2.client.SandeshaClientConstants; -import org.apache.sandesha2.client.SequenceReport; - -public class AddressingVersionTest extends SandeshaTestCase { - - - SimpleHTTPServer httpServer = null; - private final String applicationNamespaceName = "http://tempuri.org/"; - private final String ping = "ping"; - private final String Text = "Text"; - int serverPort = DEFAULT_SERVER_TEST_PORT; - private Log log = LogFactory.getLog(getClass()); - - public AddressingVersionTest () { - super ("AddressingVersionTest"); - } - - public void setUp () throws AxisFault { - - String repoPath = "target" + File.separator + "repos" + File.separator + "server"; - String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml"; - - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - String serverPortStr = getTestProperty("test.server.port"); - if (serverPortStr!=null) { - - try { - serverPort = Integer.parseInt(serverPortStr); - } catch (NumberFormatException e) { - log.error(e); - } - } - - httpServer = new SimpleHTTPServer (configContext,serverPort); - httpServer.start(); - try { - Thread.sleep(300); - } catch (InterruptedException e) { - throw new SandeshaException ("sleep interupted"); - } - } - - public void tearDown () throws SandeshaException { - if (httpServer!=null) - httpServer.stop(); - - try { - Thread.sleep(300); - } catch (InterruptedException e) { - throw new SandeshaException ("sleep interupted"); - } - } - - public void testAddressingFinal () throws AxisFault,InterruptedException { - - String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - - String repoPath = "target" + File.separator + "repos" + File.separator + "client"; - String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - - //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); - Options clientOptions = new Options (); - clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); - - clientOptions.setTo(new EndpointReference (to)); - clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); - - String sequenceKey = "sequence1"; - clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); - - //setting the addressing version as Final - clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Final.WSA_NAMESPACE); - - ServiceClient serviceClient = new ServiceClient (configContext,null); - //serviceClient. - - serviceClient.setOptions(clientOptions); - - clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); - serviceClient.fireAndForget(getPingOMBlock("ping3")); - - Thread.sleep(10000); - - SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); - assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); - assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); - assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); - - serviceClient.finalizeInvoke(); - } - - public void testAddressingSubmission () throws AxisFault,InterruptedException { - - String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - - String repoPath = "target" + File.separator + "repos" + File.separator + "client"; - String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - - //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); - Options clientOptions = new Options (); - clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); - - clientOptions.setTo(new EndpointReference (to)); - clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); - - String sequenceKey = "sequence1"; - clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); - - //setting the addressing version as Submission - clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE); - - ServiceClient serviceClient = new ServiceClient (configContext,null); - //serviceClient. - - serviceClient.setOptions(clientOptions); - - clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); - serviceClient.fireAndForget(getPingOMBlock("ping3")); - - Thread.sleep(10000); - - SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); - assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); - assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); - assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); - - serviceClient.finalizeInvoke(); - } - - private OMElement getPingOMBlock(String text) { - OMFactory fac = OMAbstractFactory.getOMFactory(); - OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1"); - OMElement pingElem = fac.createOMElement(ping, namespace); - OMElement textElem = fac.createOMElement(Text, namespace); - - textElem.setText(text); - pingElem.addChild(textElem); - - return pingElem; - } -} +/* + * 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.apache.sandesha2.versions; + +import java.io.File; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.soap.SOAP11Constants; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.AddressingConstants; +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.context.MessageContextConstants; +import org.apache.axis2.transport.http.SimpleHTTPServer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.sandesha2.SandeshaException; +import org.apache.sandesha2.SandeshaTestCase; +import org.apache.sandesha2.client.SandeshaClient; +import org.apache.sandesha2.client.SandeshaClientConstants; +import org.apache.sandesha2.client.SequenceReport; + +public class AddressingVersionTest extends SandeshaTestCase { + + + SimpleHTTPServer httpServer = null; + private final String applicationNamespaceName = "http://tempuri.org/"; + private final String ping = "ping"; + private final String Text = "Text"; + int serverPort = DEFAULT_SERVER_TEST_PORT; + private Log log = LogFactory.getLog(getClass()); + + public AddressingVersionTest () { + super ("AddressingVersionTest"); + } + + public void setUp () throws AxisFault { + + String repoPath = "target" + File.separator + "repos" + File.separator + "server"; + String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml"; + + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + String serverPortStr = getTestProperty("test.server.port"); + if (serverPortStr!=null) { + + try { + serverPort = Integer.parseInt(serverPortStr); + } catch (NumberFormatException e) { + log.error(e); + } + } + + httpServer = new SimpleHTTPServer (configContext,serverPort); + httpServer.start(); + try { + Thread.sleep(300); + } catch (InterruptedException e) { + throw new SandeshaException ("sleep interupted"); + } + } + + public void tearDown () throws SandeshaException { + if (httpServer!=null) + httpServer.stop(); + + try { + Thread.sleep(300); + } catch (InterruptedException e) { + throw new SandeshaException ("sleep interupted"); + } + } + + public void testAddressingFinal () throws AxisFault,InterruptedException { + + String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + + String repoPath = "target" + File.separator + "repos" + File.separator + "client"; + String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + + //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); + Options clientOptions = new Options (); + clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); + + clientOptions.setTo(new EndpointReference (to)); + clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); + + String sequenceKey = "sequence1"; + clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); + + //setting the addressing version as Final + clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Final.WSA_NAMESPACE); + + ServiceClient serviceClient = new ServiceClient (configContext,null); + //serviceClient. + + serviceClient.setOptions(clientOptions); + + clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); + serviceClient.fireAndForget(getPingOMBlock("ping3")); + + Thread.sleep(10000); + + SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); + assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); + assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); + assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); + + configContext.getListenerManager().stop(); + serviceClient.cleanup(); + } + + public void testAddressingSubmission () throws AxisFault,InterruptedException { + + String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + + String repoPath = "target" + File.separator + "repos" + File.separator + "client"; + String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + + //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); + Options clientOptions = new Options (); + clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); + + clientOptions.setTo(new EndpointReference (to)); + clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); + + String sequenceKey = "sequence1"; + clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); + + //setting the addressing version as Submission + clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE); + + ServiceClient serviceClient = new ServiceClient (configContext,null); + //serviceClient. + + serviceClient.setOptions(clientOptions); + + clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); + serviceClient.fireAndForget(getPingOMBlock("ping3")); + + Thread.sleep(10000); + + SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); + assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); + assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); + assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); + + configContext.getListenerManager().stop(); + serviceClient.cleanup(); + } + + private OMElement getPingOMBlock(String text) { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1"); + OMElement pingElem = fac.createOMElement(ping, namespace); + OMElement textElem = fac.createOMElement(Text, namespace); + + textElem.setText(text); + pingElem.addChild(textElem); + + return pingElem; + } +} Modified: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/RMVersionTest.java URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/RMVersionTest.java?view=diff&rev=464827&r1=464826&r2=464827 ============================================================================== --- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/RMVersionTest.java (original) +++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/RMVersionTest.java Mon Oct 16 23:35:33 2006 @@ -1,190 +1,192 @@ -/* - * 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.apache.sandesha2.versions; - -import java.io.File; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMNamespace; -import org.apache.axiom.soap.SOAP11Constants; -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.context.ConfigurationContext; -import org.apache.axis2.context.ConfigurationContextFactory; -import org.apache.axis2.context.MessageContextConstants; -import org.apache.axis2.transport.http.SimpleHTTPServer; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.sandesha2.Sandesha2Constants; -import org.apache.sandesha2.SandeshaException; -import org.apache.sandesha2.SandeshaTestCase; -import org.apache.sandesha2.client.SandeshaClient; -import org.apache.sandesha2.client.SandeshaClientConstants; -import org.apache.sandesha2.client.SequenceReport; - -public class RMVersionTest extends SandeshaTestCase { - - - SimpleHTTPServer httpServer = null; - private final String applicationNamespaceName = "http://tempuri.org/"; - private final String ping = "ping"; - private final String Text = "Text"; - int serverPort = DEFAULT_SERVER_TEST_PORT; - private Log log = LogFactory.getLog(getClass()); - - public RMVersionTest () { - super ("RMVersionTest"); - } - - public void setUp () throws AxisFault { - - String repoPath = "target" + File.separator + "repos" + File.separator + "server"; - String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml"; - - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - String serverPortStr = getTestProperty("test.server.port"); - if (serverPortStr!=null) { - - try { - serverPort = Integer.parseInt(serverPortStr); - } catch (NumberFormatException e) { - log.error(e); - } - } - - httpServer = new SimpleHTTPServer (configContext,serverPort); - httpServer.start(); - try { - Thread.sleep(300); - } catch (InterruptedException e) { - throw new SandeshaException ("sleep interupted"); - } - } - - public void tearDown () throws SandeshaException { - if (httpServer!=null) - httpServer.stop(); - - try { - Thread.sleep(300); - } catch (InterruptedException e) { - throw new SandeshaException ("sleep interupted"); - } - } - - public void testRMSubmission () throws AxisFault,InterruptedException { - - String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - - String repoPath = "target" + File.separator + "repos" + File.separator + "client"; - String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - - //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); - Options clientOptions = new Options (); - clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); - - clientOptions.setTo(new EndpointReference (to)); - clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); - - String sequenceKey = "sequence1"; - clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); - - //setting the addressing version as submission - clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_0); - - ServiceClient serviceClient = new ServiceClient (configContext,null); - //serviceClient. - - serviceClient.setOptions(clientOptions); - - clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); - serviceClient.fireAndForget(getPingOMBlock("ping3")); - - Thread.sleep(10000); - - SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); - assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); - assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); - assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); - - serviceClient.finalizeInvoke(); - } - - public void testRMOASIS () throws AxisFault,InterruptedException { - - String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - - String repoPath = "target" + File.separator + "repos" + File.separator + "client"; - String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - - //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); - Options clientOptions = new Options (); - clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); - - clientOptions.setTo(new EndpointReference (to)); - clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); - - String sequenceKey = "sequence1"; - clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); - - //setting the RM version as OASIS. - clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1); - - ServiceClient serviceClient = new ServiceClient (configContext,null); - //serviceClient. - - serviceClient.setOptions(clientOptions); - - serviceClient.fireAndForget(getPingOMBlock("ping3")); - - Thread.sleep(5000); - - SandeshaClient.terminateSequence(serviceClient); - - Thread.sleep(5000); - - SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); - assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); - assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); - assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); - - serviceClient.finalizeInvoke(); - } - - private OMElement getPingOMBlock(String text) { - OMFactory fac = OMAbstractFactory.getOMFactory(); - OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1"); - OMElement pingElem = fac.createOMElement(ping, namespace); - OMElement textElem = fac.createOMElement(Text, namespace); - - textElem.setText(text); - pingElem.addChild(textElem); - - return pingElem; - } -} +/* + * 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.apache.sandesha2.versions; + +import java.io.File; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.soap.SOAP11Constants; +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.context.ConfigurationContext; +import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.axis2.context.MessageContextConstants; +import org.apache.axis2.transport.http.SimpleHTTPServer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.sandesha2.Sandesha2Constants; +import org.apache.sandesha2.SandeshaException; +import org.apache.sandesha2.SandeshaTestCase; +import org.apache.sandesha2.client.SandeshaClient; +import org.apache.sandesha2.client.SandeshaClientConstants; +import org.apache.sandesha2.client.SequenceReport; + +public class RMVersionTest extends SandeshaTestCase { + + + SimpleHTTPServer httpServer = null; + private final String applicationNamespaceName = "http://tempuri.org/"; + private final String ping = "ping"; + private final String Text = "Text"; + int serverPort = DEFAULT_SERVER_TEST_PORT; + private Log log = LogFactory.getLog(getClass()); + + public RMVersionTest () { + super ("RMVersionTest"); + } + + public void setUp () throws AxisFault { + + String repoPath = "target" + File.separator + "repos" + File.separator + "server"; + String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml"; + + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + String serverPortStr = getTestProperty("test.server.port"); + if (serverPortStr!=null) { + + try { + serverPort = Integer.parseInt(serverPortStr); + } catch (NumberFormatException e) { + log.error(e); + } + } + + httpServer = new SimpleHTTPServer (configContext,serverPort); + httpServer.start(); + try { + Thread.sleep(300); + } catch (InterruptedException e) { + throw new SandeshaException ("sleep interupted"); + } + } + + public void tearDown () throws SandeshaException { + if (httpServer!=null) + httpServer.stop(); + + try { + Thread.sleep(300); + } catch (InterruptedException e) { + throw new SandeshaException ("sleep interupted"); + } + } + + public void testRMSubmission () throws AxisFault,InterruptedException { + + String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + + String repoPath = "target" + File.separator + "repos" + File.separator + "client"; + String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + + //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); + Options clientOptions = new Options (); + clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); + + clientOptions.setTo(new EndpointReference (to)); + clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); + + String sequenceKey = "sequence1"; + clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); + + //setting the addressing version as submission + clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_0); + + ServiceClient serviceClient = new ServiceClient (configContext,null); + //serviceClient. + + serviceClient.setOptions(clientOptions); + + clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); + serviceClient.fireAndForget(getPingOMBlock("ping3")); + + Thread.sleep(10000); + + SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); + assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); + assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); + assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); + + configContext.getListenerManager().stop(); + serviceClient.cleanup(); + } + + public void testRMOASIS () throws AxisFault,InterruptedException { + + String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + + String repoPath = "target" + File.separator + "repos" + File.separator + "client"; + String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + + //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); + Options clientOptions = new Options (); + clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); + + clientOptions.setTo(new EndpointReference (to)); + clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); + + String sequenceKey = "sequence1"; + clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); + + //setting the RM version as OASIS. + clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1); + + ServiceClient serviceClient = new ServiceClient (configContext,null); + //serviceClient. + + serviceClient.setOptions(clientOptions); + + serviceClient.fireAndForget(getPingOMBlock("ping3")); + + Thread.sleep(5000); + + SandeshaClient.terminateSequence(serviceClient); + + Thread.sleep(5000); + + SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); + assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); + assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); + assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); + + configContext.getListenerManager().stop(); + serviceClient.cleanup(); + } + + private OMElement getPingOMBlock(String text) { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1"); + OMElement pingElem = fac.createOMElement(ping, namespace); + OMElement textElem = fac.createOMElement(Text, namespace); + + textElem.setText(text); + pingElem.addChild(textElem); + + return pingElem; + } +} Modified: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java?view=diff&rev=464827&r1=464826&r2=464827 ============================================================================== --- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java (original) +++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java Mon Oct 16 23:35:33 2006 @@ -1,184 +1,186 @@ -/* - * 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.apache.sandesha2.versions; - -import java.io.File; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMNamespace; -import org.apache.axiom.soap.SOAP11Constants; -import org.apache.axiom.soap.SOAP12Constants; -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.context.ConfigurationContext; -import org.apache.axis2.context.ConfigurationContextFactory; -import org.apache.axis2.context.MessageContextConstants; -import org.apache.axis2.transport.http.SimpleHTTPServer; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.sandesha2.SandeshaException; -import org.apache.sandesha2.SandeshaTestCase; -import org.apache.sandesha2.client.SandeshaClient; -import org.apache.sandesha2.client.SandeshaClientConstants; -import org.apache.sandesha2.client.SequenceReport; - -public class SOAPVersionTest extends SandeshaTestCase { - - - SimpleHTTPServer httpServer = null; - private final String applicationNamespaceName = "http://tempuri.org/"; - private final String ping = "ping"; - private final String Text = "Text"; - int serverPort = DEFAULT_SERVER_TEST_PORT; - private Log log = LogFactory.getLog(getClass()); - - public SOAPVersionTest () { - super ("SOAPVersionTest"); - } - - public void setUp () throws AxisFault { - - String repoPath = "target" + File.separator + "repos" + File.separator + "server"; - String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml"; - - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - String serverPortStr = getTestProperty("test.server.port"); - if (serverPortStr!=null) { - - try { - serverPort = Integer.parseInt(serverPortStr); - } catch (NumberFormatException e) { - log.error(e); - } - } - - httpServer = new SimpleHTTPServer (configContext,serverPort); - httpServer.start(); - try { - Thread.sleep(300); - } catch (InterruptedException e) { - throw new SandeshaException ("sleep interupted"); - } - } - - public void tearDown () throws SandeshaException { - if (httpServer!=null) - httpServer.stop(); - - try { - Thread.sleep(300); - } catch (InterruptedException e) { - throw new SandeshaException ("sleep interupted"); - } - } - - public void testSOAP11 () throws AxisFault,InterruptedException { - - String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - - String repoPath = "target" + File.separator + "repos" + File.separator + "client"; - String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - - Options clientOptions = new Options (); - - clientOptions.setTo(new EndpointReference (to)); - clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); - - String sequenceKey = "sequence1"; - clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); - - //setting the SOAP version as 1.1 - clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); - - ServiceClient serviceClient = new ServiceClient (configContext,null); - //serviceClient. - - serviceClient.setOptions(clientOptions); - - clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); - serviceClient.fireAndForget(getPingOMBlock("ping3")); - - Thread.sleep(10000); - - SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); - assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); - assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); - assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); - - serviceClient.finalizeInvoke(); - } - - public void testSOAP12 () throws AxisFault,InterruptedException { - - String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; - - String repoPath = "target" + File.separator + "repos" + File.separator + "client"; - String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; - - ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); - - Options clientOptions = new Options (); - clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); - - clientOptions.setTo(new EndpointReference (to)); - clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); - - String sequenceKey = "sequence1"; - clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); - - //setting the SOAP version as 1.2 - clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); - - ServiceClient serviceClient = new ServiceClient (configContext,null); - //serviceClient. - - serviceClient.setOptions(clientOptions); - - clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); - serviceClient.fireAndForget(getPingOMBlock("ping3")); - - Thread.sleep(10000); - - SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); - assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); - assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); - assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); - - serviceClient.finalizeInvoke(); - } - - private OMElement getPingOMBlock(String text) { - OMFactory fac = OMAbstractFactory.getOMFactory(); - OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1"); - OMElement pingElem = fac.createOMElement(ping, namespace); - OMElement textElem = fac.createOMElement(Text, namespace); - - textElem.setText(text); - pingElem.addChild(textElem); - - return pingElem; - } -} +/* + * 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.apache.sandesha2.versions; + +import java.io.File; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.soap.SOAP11Constants; +import org.apache.axiom.soap.SOAP12Constants; +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.context.ConfigurationContext; +import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.axis2.context.MessageContextConstants; +import org.apache.axis2.transport.http.SimpleHTTPServer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.sandesha2.SandeshaException; +import org.apache.sandesha2.SandeshaTestCase; +import org.apache.sandesha2.client.SandeshaClient; +import org.apache.sandesha2.client.SandeshaClientConstants; +import org.apache.sandesha2.client.SequenceReport; + +public class SOAPVersionTest extends SandeshaTestCase { + + + SimpleHTTPServer httpServer = null; + private final String applicationNamespaceName = "http://tempuri.org/"; + private final String ping = "ping"; + private final String Text = "Text"; + int serverPort = DEFAULT_SERVER_TEST_PORT; + private Log log = LogFactory.getLog(getClass()); + + public SOAPVersionTest () { + super ("SOAPVersionTest"); + } + + public void setUp () throws AxisFault { + + String repoPath = "target" + File.separator + "repos" + File.separator + "server"; + String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml"; + + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + String serverPortStr = getTestProperty("test.server.port"); + if (serverPortStr!=null) { + + try { + serverPort = Integer.parseInt(serverPortStr); + } catch (NumberFormatException e) { + log.error(e); + } + } + + httpServer = new SimpleHTTPServer (configContext,serverPort); + httpServer.start(); + try { + Thread.sleep(300); + } catch (InterruptedException e) { + throw new SandeshaException ("sleep interupted"); + } + } + + public void tearDown () throws SandeshaException { + if (httpServer!=null) + httpServer.stop(); + + try { + Thread.sleep(300); + } catch (InterruptedException e) { + throw new SandeshaException ("sleep interupted"); + } + } + + public void testSOAP11 () throws AxisFault,InterruptedException { + + String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + + String repoPath = "target" + File.separator + "repos" + File.separator + "client"; + String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + + Options clientOptions = new Options (); + + clientOptions.setTo(new EndpointReference (to)); + clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); + + String sequenceKey = "sequence1"; + clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); + + //setting the SOAP version as 1.1 + clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); + + ServiceClient serviceClient = new ServiceClient (configContext,null); + //serviceClient. + + serviceClient.setOptions(clientOptions); + + clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); + serviceClient.fireAndForget(getPingOMBlock("ping3")); + + Thread.sleep(10000); + + SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); + assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); + assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); + assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); + + configContext.getListenerManager().stop(); + serviceClient.cleanup(); + } + + public void testSOAP12 () throws AxisFault,InterruptedException { + + String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService"; + + String repoPath = "target" + File.separator + "repos" + File.separator + "client"; + String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml"; + + ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml); + + Options clientOptions = new Options (); + clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); + + clientOptions.setTo(new EndpointReference (to)); + clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo); + + String sequenceKey = "sequence1"; + clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey); + + //setting the SOAP version as 1.2 + clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); + + ServiceClient serviceClient = new ServiceClient (configContext,null); + //serviceClient. + + serviceClient.setOptions(clientOptions); + + clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); + serviceClient.fireAndForget(getPingOMBlock("ping3")); + + Thread.sleep(10000); + + SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); + assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1))); + assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED); + assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT); + + configContext.getListenerManager().stop(); + serviceClient.cleanup(); + } + + private OMElement getPingOMBlock(String text) { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1"); + OMElement pingElem = fac.createOMElement(ping, namespace); + OMElement textElem = fac.createOMElement(Text, namespace); + + textElem.setText(text); + pingElem.addChild(textElem); + + return pingElem; + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
