Author: veithen Date: Fri May 27 21:46:16 2011 New Revision: 1128474 URL: http://svn.apache.org/viewvc?rev=1128474&view=rev Log: Added a basic unit test for the local transport.
Added: axis/axis2/java/core/trunk/modules/transport/local/test/ axis/axis2/java/core/trunk/modules/transport/local/test-resources/ axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/ axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/apache/ axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/apache/axis2/ axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/apache/axis2/transport/ axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/apache/axis2/transport/local/ axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/apache/axis2/transport/local/axis2.xml (with props) axis/axis2/java/core/trunk/modules/transport/local/test/org/ axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/ axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/ axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/ axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/ axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/EchoMessageReceiver.java (with props) axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/LocalTransportTest.java (with props) Modified: axis/axis2/java/core/trunk/modules/transport/local/pom.xml Modified: axis/axis2/java/core/trunk/modules/transport/local/pom.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/local/pom.xml?rev=1128474&r1=1128473&r2=1128474&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/transport/local/pom.xml (original) +++ axis/axis2/java/core/trunk/modules/transport/local/pom.xml Fri May 27 21:46:16 2011 @@ -39,6 +39,11 @@ <build> <sourceDirectory>src</sourceDirectory> <testSourceDirectory>test</testSourceDirectory> + <testResources> + <testResource> + <directory>test-resources</directory> + </testResource> + </testResources> <plugins> <plugin> <artifactId>maven-remote-resources-plugin</artifactId> @@ -95,5 +100,10 @@ <artifactId>axis2-kernel</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>xmlunit</groupId> + <artifactId>xmlunit</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> Added: axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/apache/axis2/transport/local/axis2.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/apache/axis2/transport/local/axis2.xml?rev=1128474&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/apache/axis2/transport/local/axis2.xml (added) +++ axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/apache/axis2/transport/local/axis2.xml Fri May 27 21:46:16 2011 @@ -0,0 +1,157 @@ +<?xml version="1.0"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<axisconfig name="AxisJava2.0"> + <parameter name="hotdeployment">false</parameter> + <parameter name="hotupdate">false</parameter> + <parameter name="enableMTOM">false</parameter> + <parameter name="disableREST">true</parameter> + + <messageReceivers> + <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" + class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/> + <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" + class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> + <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only" + class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/> + <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out" + class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> + </messageReceivers> + + <messageFormatters> + <messageFormatter contentType="application/x-www-form-urlencoded" + class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/> + <messageFormatter contentType="multipart/form-data" + class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/> + <messageFormatter contentType="application/xml" + class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/> + <messageFormatter contentType="text/xml" + class="org.apache.axis2.transport.http.SOAPMessageFormatter"/> + <messageFormatter contentType="application/soap+xml" + class="org.apache.axis2.transport.http.SOAPMessageFormatter"/> + </messageFormatters> + + <messageBuilders> + <messageBuilder contentType="application/xml" + class="org.apache.axis2.builder.ApplicationXMLBuilder"/> + <messageBuilder contentType="application/x-www-form-urlencoded" + class="org.apache.axis2.builder.XFormURLEncodedBuilder"/> + </messageBuilders> + + <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/> + + <!-- ================================================= --> + <!-- Phases --> + <!-- ================================================= --> + <phaseOrder type="InFlow"> + <!-- System pre-defined phases --> + <phase name="Transport"> + <handler name="RequestURIBasedDispatcher" + class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"> + <order phase="Transport"/> + </handler> + <handler name="SOAPActionBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"> + <order phase="Transport"/> + </handler> + </phase> + <phase name="Addressing"> + <handler name="AddressingBasedDispatcher" + class="org.apache.axis2.dispatchers.AddressingBasedDispatcher"> + <order phase="Addressing"/> + </handler> + </phase> + <phase name="Security"/> + <phase name="PreDispatch"/> + <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase"> + <handler name="RequestURIBasedDispatcher" + class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/> + <handler name="SOAPActionBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/> + <handler name="RequestURIOperationDispatcher" + class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/> + <handler name="SOAPMessageBodyBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/> + + <handler name="HTTPLocationBasedDispatcher" + class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/> + </phase> + <!-- System pre defined phases --> + <phase name="RMPhase"/> + <phase name="OpPhase"/> + <!-- After Postdispatch phase module author or or service author can add any phase he want --> + <phase name="OperationInPhase"/> + </phaseOrder> + <phaseOrder type="OutFlow"> + <phase name="RMPhase"/> + <phase name="OpPhase"/> + <!-- user can add his own phases to this area --> + <phase name="OperationOutPhase"/> + <!--system predefined phase--> + <!--these phase will run irrespective of the service--> + <phase name="PolicyDetermination"/> + <phase name="MessageOut"/> + <phase name="Security"/> + </phaseOrder> + <phaseOrder type="InFaultFlow"> + <phase name="Transport"> + <handler name="RequestURIBasedDispatcher" + class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"> + <order phase="Transport"/> + </handler> + <handler name="SOAPActionBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"> + <order phase="Transport"/> + </handler> + </phase> + <phase name="Addressing"> + <handler name="AddressingBasedDispatcher" + class="org.apache.axis2.dispatchers.AddressingBasedDispatcher"> + <order phase="Addressing"/> + </handler> + </phase> + <phase name="Security"/> + <phase name="PreDispatch"/> + <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase"> + <handler name="RequestURIBasedDispatcher" + class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/> + <handler name="SOAPActionBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/> + <handler name="RequestURIOperationDispatcher" + class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/> + <handler name="SOAPMessageBodyBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/> + + <handler name="HTTPLocationBasedDispatcher" + class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/> + </phase> + <phase name="RMPhase"/> + <phase name="OpPhase"/> + <!-- user can add his own phases to this area --> + <phase name="OperationInFaultPhase"/> + </phaseOrder> + <phaseOrder type="OutFaultFlow"> + <!-- user can add his own phases to this area --> + <phase name="OperationOutFaultPhase"/> + <phase name="RMPhase"/> + <phase name="PolicyDetermination"/> + <phase name="MessageOut"/> + <phase name="Security"/> + </phaseOrder> +</axisconfig> \ No newline at end of file Propchange: axis/axis2/java/core/trunk/modules/transport/local/test-resources/org/apache/axis2/transport/local/axis2.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/EchoMessageReceiver.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/EchoMessageReceiver.java?rev=1128474&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/EchoMessageReceiver.java (added) +++ axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/EchoMessageReceiver.java Fri May 27 21:46:16 2011 @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.axis2.transport.local; + +import org.apache.axiom.attachments.Attachments; +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.receivers.AbstractInOutMessageReceiver; + +public class EchoMessageReceiver extends AbstractInOutMessageReceiver { + @Override + public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage) + throws AxisFault { + + outMessage.setEnvelope(inMessage.getEnvelope()); + Attachments inAttachments = inMessage.getAttachmentMap(); + Attachments outAttachments = outMessage.getAttachmentMap(); + for (String contentId : inAttachments.getAllContentIDs()) { + if (!contentId.equals(inAttachments.getSOAPPartContentID())) { + outAttachments.addDataHandler(contentId, + inAttachments.getDataHandler(contentId)); + } + } + outMessage.setDoingSwA(inMessage.isDoingSwA()); + outMessage.setDoingMTOM(inMessage.isDoingMTOM()); + } +} Propchange: axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/EchoMessageReceiver.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/LocalTransportTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/LocalTransportTest.java?rev=1128474&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/LocalTransportTest.java (added) +++ axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/LocalTransportTest.java Fri May 27 21:46:16 2011 @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.axis2.transport.local; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +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.description.AxisOperation; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.InOutAxisOperation; +import org.custommonkey.xmlunit.XMLAssert; +import org.junit.Test; + +public class LocalTransportTest { + @Test + public void test() throws Exception { + ConfigurationContext configurationContext = + ConfigurationContextFactory.createConfigurationContextFromURIs( + LocalTransportTest.class.getResource("axis2.xml"), null); + + AxisService service = new AxisService("Echo"); + AxisOperation operation = new InOutAxisOperation(new QName("echo")); + operation.setMessageReceiver(new EchoMessageReceiver()); + service.addOperation(operation); + service.addParameter(AxisService.SUPPORT_SINGLE_OP, true); + configurationContext.getAxisConfiguration().addService(service); + + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement requestElement = factory.createOMElement("test", "urn:test", "t"); + requestElement.setText("Hi there!"); + + Options options = new Options(); + options.setTo(new EndpointReference("local://localhost/axis2/services/Echo")); + ServiceClient serviceClient = new ServiceClient(configurationContext, null); + serviceClient.setOptions(options); + OMElement responseElement = serviceClient.sendReceive(requestElement); + + XMLAssert.assertXMLEqual(requestElement.toString(), responseElement.toString()); + } +} Propchange: axis/axis2/java/core/trunk/modules/transport/local/test/org/apache/axis2/transport/local/LocalTransportTest.java ------------------------------------------------------------------------------ svn:eol-style = native