You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2009/06/19 07:46:02 UTC

svn commit: r786379 - in /servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test: java/org/apache/servicemix/soap/ java/org/apache/servicemix/soap/handlers/addressing/ java/org/apache/servicemix/soap/handlers/dom/ resources/org/apache/...

Author: ffang
Date: Fri Jun 19 05:46:02 2009
New Revision: 786379

URL: http://svn.apache.org/viewvc?rev=786379&view=rev
Log:
[SMXCOMP-521]Improve test coverage - ServiceMix :: SOAP

Added:
    servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTestSupport.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapFaultTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/dom/
    servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/dom/DomHandlerTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/resources/org/apache/servicemix/soap/HelloWorld-DOC.wsdl   (with props)
Modified:
    servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/addressing/AddressingHandlerTest.java

Added: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTest.java?rev=786379&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTest.java Fri Jun 19 05:46:02 2009
@@ -0,0 +1,111 @@
+/*
+ * 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.servicemix.soap;
+
+import java.util.List;
+
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.common.DefaultComponent;
+import org.apache.servicemix.common.ServiceUnit;
+import org.springframework.core.io.ClassPathResource;
+
+import junit.framework.TestCase;
+
+public class SoapEndpointTest extends TestCase {
+
+    private SoapEndpointTestSupport mySoapEndpoint;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        mySoapEndpoint = new SoapEndpointTestSupport();
+        mySoapEndpoint.setSoap(true);
+    }
+
+    protected void tearDown() throws Exception {
+        mySoapEndpoint = null;
+        super.tearDown();
+    }
+
+    // test setRoleAsString for "consumer"
+    public void testSetRoleAsStringConsumer() throws Exception {
+        mySoapEndpoint.setRoleAsString("consumer");
+        assertTrue("setRoleAsString() should succeed with role of consumer", 
+                mySoapEndpoint.getRole() == Role.CONSUMER);
+    }
+
+    // test setRoleAsString for "provider"
+    public void testSetRoleAsStringProvider() throws Exception {
+        mySoapEndpoint.setRoleAsString("provider");
+        assertTrue("setRoleAsString() should succeed with role of provider", 
+                mySoapEndpoint.getRole() == Role.PROVIDER);
+    }
+
+    // test setRoleAsString with invalid role
+    public void testSetRoleAsStringInvalid() throws Exception {
+        try {
+            mySoapEndpoint.setRoleAsString("invalid");
+            fail("setRoleAsString() should fail for invalid role");
+        } catch (IllegalArgumentException iae) {
+            // test succeeds
+        }
+    }
+
+    // test setRoleAsString with null role
+    public void testSetRoleAsStringNull() throws Exception {
+        try {
+            mySoapEndpoint.setRoleAsString(null);
+            fail("setRoleAsString() should fail for null role");
+        } catch (IllegalArgumentException iae) {
+            // test succeeds
+        }
+    }
+
+    // test loadWsdl when wsdlResource is set and role is provider.
+    public void testLoadWsdlAsProvider() throws Exception {
+        MyServiceUnit httpSu = new MyServiceUnit();
+        ClassPathResource cpResource = new ClassPathResource("org/apache/servicemix/soap/HelloWorld-DOC.wsdl");
+        mySoapEndpoint.setServiceUnit(httpSu);
+        mySoapEndpoint.setRole(Role.PROVIDER);
+        mySoapEndpoint.setWsdlResource(cpResource);
+        mySoapEndpoint.setLocationURI("http://localhost:8080/hello");
+        mySoapEndpoint.setEndpoint("HelloPortSoap11");
+        mySoapEndpoint.setService(new QName("uri:HelloWorld", "HelloService"));
+
+        mySoapEndpoint.loadWsdl();
+
+        assertFalse("getWsdls() should not return an empty list", mySoapEndpoint.getWsdls().isEmpty());
+    }
+
+    // Support class needed for HttpEndpoint tests.
+    public class MyServiceUnit extends ServiceUnit {
+        public MyServiceUnit() {
+            super(new TestComponent());
+        }
+    }
+
+    public class TestComponent extends DefaultComponent {
+        public List getConfiguredEndpoints() {
+            return null;
+        }
+
+        public Class[] getEndpointClasses() {
+            return null;
+        }
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTestSupport.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTestSupport.java?rev=786379&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTestSupport.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTestSupport.java Fri Jun 19 05:46:02 2009
@@ -0,0 +1,53 @@
+/*
+ * 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.servicemix.soap;
+
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.wsdl.Definition;
+
+import org.apache.servicemix.common.ExchangeProcessor;
+
+public class SoapEndpointTestSupport extends SoapEndpoint {
+
+    private String locationURI;
+    
+    @Override
+    protected ExchangeProcessor createConsumerProcessor() {
+        return null;
+    }
+
+    @Override
+    protected ServiceEndpoint createExternalEndpoint() {
+        return null;
+    }
+
+    @Override
+    protected ExchangeProcessor createProviderProcessor() {
+        return null;
+    }
+
+    @Override
+    protected void overrideDefinition(Definition def) throws Exception {
+        definition = def;
+
+    }
+
+    public void setLocationURI(String locationUri) {
+        this.locationURI = locationUri;
+    }
+
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapEndpointTestSupport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapFaultTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapFaultTest.java?rev=786379&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapFaultTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapFaultTest.java Fri Jun 19 05:46:02 2009
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+/*
+ * 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.servicemix.soap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.soap.marshalers.SoapMarshaler;
+
+import junit.framework.TestCase;
+
+public class SoapFaultTest extends TestCase {
+
+    private SoapFault soapFault;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    // test translateCodeTo11() when code is null
+    public void testTranslateCodeTo11CodeNull() throws Exception {
+        soapFault = new SoapFault(null, null);
+
+        soapFault.translateCodeTo11();
+
+        assertTrue("translateCodeTo11() should return \"Server\" for null code",
+                soapFault.getCode().equals(SoapMarshaler.SOAP_11_CODE_SERVER));
+    }
+
+    // test translateCodeTo11() when both code and subcode are set.
+    public void testTranslateCodeTo11CodeAndSubcodeSet() throws Exception {
+        QName subcode = new QName("http://test/service", "Memory");
+        soapFault = new SoapFault(SoapMarshaler.SOAP_12_CODE_SENDER, 
+                subcode, "Out of Memory");
+
+        soapFault.translateCodeTo11();
+
+        assertTrue("code should be set to subcode", soapFault.getCode().equals(subcode));
+    }
+
+    // test translateCodeTo11() with code set but subcode is null.
+    public void testTranslateCodeTo11CodeSet() throws Exception {
+        soapFault = new SoapFault(SoapMarshaler.SOAP_12_CODE_DATAENCODINGUNKNOWN, 
+                "unknown encoding type");
+
+        soapFault.translateCodeTo11();
+
+        assertTrue("code should have a code of Client", soapFault.getCode().equals(SoapMarshaler.SOAP_11_CODE_CLIENT));
+    }
+
+    // test translateCodeTo12() when code is null
+    public void testTranslateCodeTo12CodeNull() throws Exception {
+        soapFault = new SoapFault(null, null);
+
+        soapFault.translateCodeTo12();
+
+        assertTrue("null code for SOAP 1.2 should be set to Receiver",
+                soapFault.getCode().equals(SoapMarshaler.SOAP_12_CODE_RECEIVER));
+    }
+
+    // test translateCodeTo12() when code is Server.
+    public void testTranslateCodeTo12CodeServer() throws Exception {
+        soapFault = new SoapFault(SoapMarshaler.SOAP_11_CODE_SERVER, "test reason");
+
+        soapFault.translateCodeTo12();
+
+        assertTrue("code should be changed to Receiver",
+                soapFault.getCode().equals(SoapMarshaler.SOAP_12_CODE_RECEIVER));
+    }
+
+    // test translateCodeTo12() when code is Client.
+    public void testTranslateCodeTo12CodeClient() throws Exception {
+        soapFault = new SoapFault(SoapMarshaler.SOAP_11_CODE_CLIENT, "test reason");
+
+        soapFault.translateCodeTo12();
+
+        assertTrue("code should be changed to Sender", 
+                soapFault.getCode().equals(SoapMarshaler.SOAP_12_CODE_SENDER));
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapFaultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/SoapFaultTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/addressing/AddressingHandlerTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/addressing/AddressingHandlerTest.java?rev=786379&r1=786378&r2=786379&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/addressing/AddressingHandlerTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/addressing/AddressingHandlerTest.java Fri Jun 19 05:46:02 2009
@@ -18,89 +18,131 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.util.DOMUtil;
 import org.apache.servicemix.jbi.util.WSAddressingConstants;
 import org.apache.servicemix.soap.Context;
 import org.apache.servicemix.soap.marshalers.SoapMessage;
+import org.w3c.dom.Document;
 import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
 
 import junit.framework.TestCase;
 
 public class AddressingHandlerTest extends TestCase {
 
 
-	private AddressingHandler handler;
+    private AddressingHandler handler;
+    private static final String WSA_NS = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
 
-	public AddressingHandlerTest(String name) {
-		super(name);
-	}
-
-	protected void setUp() throws Exception {
-		this.handler = new AddressingHandler();
-	}
-	
-	public void testCreateHeader() throws Exception {
-		QName messageIdQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_MESSAGE_ID, WSAddressingConstants.WSA_PREFIX);
-		String messageId = "uuid:1234567890";
-		DocumentFragment wsaMessageId = this.handler.createHeader(messageIdQN, messageId);
-
-		assertNotNull("DocumentFragment is null", wsaMessageId);
-		assertEquals("messageId", messageId, wsaMessageId.getTextContent());
-		
-	}
-	
-	public void testWSAEmptyPrefix() throws Exception {
-		// setup
-		QName messageIdQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_MESSAGE_ID, "");
-		QName relatesToQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_RELATES_TO, "");
-
-		
-		// create messages and add them to the context
-		Context msgContext = new Context();
-		SoapMessage inMessage = new SoapMessage();
-		SoapMessage outMessage = new SoapMessage();
-		msgContext.setInMessage(inMessage);
-		msgContext.setOutMessage(outMessage);
-		
-		// add wsa MessageID header to in message
-		String messageId = "uuid:1234567890";
-		DocumentFragment wsaMessageId = this.handler.createHeader(messageIdQN, messageId);
-		inMessage.addHeader(messageIdQN, wsaMessageId);
-		
-		// run handler
-		this.handler.onReply(msgContext);
-		
-		// verify relates-to
-		DocumentFragment wsaRelatesTo = (DocumentFragment) outMessage.getHeaders().get(relatesToQN);
-		assertNotNull("No RelatesTo header", wsaRelatesTo);
-		assertEquals("Value", messageId, wsaRelatesTo.getTextContent());
-	}
-	
-	public void testWSAPrefix() throws Exception {
-		// setup
-		QName messageIdQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_MESSAGE_ID, WSAddressingConstants.WSA_PREFIX);
-		QName relatesToQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_RELATES_TO, WSAddressingConstants.WSA_PREFIX);
-
-		
-		// create messages and add them to the context
-		Context msgContext = new Context();
-		SoapMessage inMessage = new SoapMessage();
-		SoapMessage outMessage = new SoapMessage();
-		msgContext.setInMessage(inMessage);
-		msgContext.setOutMessage(outMessage);
-		
-		// add wsa MessageID header to in message
-		String messageId = "uuid:1234567890";
-		DocumentFragment wsaMessageId = this.handler.createHeader(messageIdQN, messageId);
-		inMessage.addHeader(messageIdQN, wsaMessageId);
-		
-		// run handler
-		this.handler.onReply(msgContext);
-		
-		// verify relates-to
-		DocumentFragment wsaRelatesTo = (DocumentFragment) outMessage.getHeaders().get(relatesToQN);
-		assertNotNull("No RelatesTo header", wsaRelatesTo);
-		assertEquals("Value", messageId, wsaRelatesTo.getTextContent());
-	}
-	
+    public AddressingHandlerTest(String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        this.handler = new AddressingHandler();
+    }
+
+    public void testCreateHeader() throws Exception {
+        QName messageIdQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_MESSAGE_ID, WSAddressingConstants.WSA_PREFIX);
+        String messageId = "uuid:1234567890";
+        DocumentFragment wsaMessageId = this.handler.createHeader(messageIdQN, messageId);
+
+        assertNotNull("DocumentFragment is null", wsaMessageId);
+        assertEquals("messageId", messageId, wsaMessageId.getTextContent());
+
+    }
+
+    public void testWSAEmptyPrefix() throws Exception {
+        // setup
+        QName messageIdQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_MESSAGE_ID, "");
+        QName relatesToQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_RELATES_TO, "");
+
+
+        // create messages and add them to the context
+        Context msgContext = new Context();
+        SoapMessage inMessage = new SoapMessage();
+        SoapMessage outMessage = new SoapMessage();
+        msgContext.setInMessage(inMessage);
+        msgContext.setOutMessage(outMessage);
+
+        // add wsa MessageID header to in message
+        String messageId = "uuid:1234567890";
+        DocumentFragment wsaMessageId = this.handler.createHeader(messageIdQN, messageId);
+        inMessage.addHeader(messageIdQN, wsaMessageId);
+
+        // run handler
+        this.handler.onReply(msgContext);
+
+        // verify relates-to
+        DocumentFragment wsaRelatesTo = (DocumentFragment) outMessage.getHeaders().get(relatesToQN);
+        assertNotNull("No RelatesTo header", wsaRelatesTo);
+        assertEquals("Value", messageId, wsaRelatesTo.getTextContent());
+    }
+
+    public void testWSAPrefix() throws Exception {
+        // setup
+        QName messageIdQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_MESSAGE_ID, WSAddressingConstants.WSA_PREFIX);
+        QName relatesToQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_RELATES_TO, WSAddressingConstants.WSA_PREFIX);
+
+
+        // create messages and add them to the context
+        Context msgContext = new Context();
+        SoapMessage inMessage = new SoapMessage();
+        SoapMessage outMessage = new SoapMessage();
+        msgContext.setInMessage(inMessage);
+        msgContext.setOutMessage(outMessage);
+
+        // add wsa MessageID header to in message
+        String messageId = "uuid:1234567890";
+        DocumentFragment wsaMessageId = this.handler.createHeader(messageIdQN, messageId);
+        inMessage.addHeader(messageIdQN, wsaMessageId);
+
+        // run handler
+        this.handler.onReply(msgContext);
+    
+        // verify relates-to
+        DocumentFragment wsaRelatesTo = (DocumentFragment) outMessage.getHeaders().get(relatesToQN);
+        assertNotNull("No RelatesTo header", wsaRelatesTo);
+        assertEquals("Value", messageId, wsaRelatesTo.getTextContent());
+    }
+
+    // test onReceive() when wsa:Action and wsa:To are set on the incoming message.
+    // The appropriate parts of the Context that is passed in should be set.
+    public void testOnReceiveActionAndTo() throws Exception {
+        Context msgContext = new Context();
+        SoapMessage soapMessage = new SoapMessage();
+        soapMessage.setBodyName(new QName("http://test.org", "echo"));
+        soapMessage.addHeader(new QName(WSA_NS, "To"), 
+                createDocumentFragment("To", "http://localhost:8192/Services/EchoService"));
+        soapMessage.addHeader(new QName(WSA_NS, "Action"), 
+                createDocumentFragment("Action", "http://test.org/Echo/EchoService"));
+        soapMessage.setSource(new StringSource(
+                "<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" +" +
+                "<env:Body><ns1:EchoRequest xmlns:ns1=\"http://test.org\"><echo>this string</echo>" +
+                "</ns1:EchoRequest></env:Body></env:Envelope>"));
+
+        msgContext.setInMessage(soapMessage);
+
+        this.handler.onReceive(msgContext);
+
+        assertNotNull("Endpoint on Context should be set", msgContext.getProperty(Context.ENDPOINT));
+        assertNotNull("Service on Context should be set", msgContext.getProperty(Context.SERVICE));
+        assertNotNull("Operation on Context should be set", msgContext.getProperty(Context.OPERATION));
+        assertNotNull("Interface on Context should be set", msgContext.getProperty(Context.INTERFACE));
+    }
+
+    private DocumentFragment createDocumentFragment(String headerName, String headerValue) throws Exception {
+        DocumentFragment df = null;
+        Document doc = DOMUtil.newDocument();
+        df = doc.createDocumentFragment();
+        //Element e = doc.createElementNS(WSA_NS, headerName);
+        Element e = doc.createElement(headerName);
+        Text t = doc.createTextNode(headerValue);
+        e.appendChild(t);
+        df.appendChild(e);
+        return df;
+    }
 
 }

Added: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/dom/DomHandlerTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/dom/DomHandlerTest.java?rev=786379&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/dom/DomHandlerTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/dom/DomHandlerTest.java Fri Jun 19 05:46:02 2009
@@ -0,0 +1,56 @@
+/*
+ * 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.servicemix.soap.handlers.dom;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import junit.framework.TestCase;
+
+public class DomHandlerTest extends TestCase {
+
+    private DomHandler domHandler;
+    private static transient Log log = LogFactory.getLog(DomHandlerTest.class);
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        domHandler = new DomHandler();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testIsRequired() {
+        assertFalse("isRequired should return false", domHandler.isRequired());
+    }
+
+    public void testSetRequired() {
+        try {
+            domHandler.setRequired(true);
+            fail("setRequired to true should throw an UnsupportedOperationException");
+        } catch (UnsupportedOperationException uoe) {
+            // test passes
+            log.info("setRequired method threw the expected exception.");
+        }
+    }
+
+    public void testRequireDOM() {
+        assertTrue("requireDOM should return true", domHandler.requireDOM());
+    }
+
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/dom/DomHandlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/dom/DomHandlerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/resources/org/apache/servicemix/soap/HelloWorld-DOC.wsdl
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/resources/org/apache/servicemix/soap/HelloWorld-DOC.wsdl?rev=786379&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/resources/org/apache/servicemix/soap/HelloWorld-DOC.wsdl (added)
+++ servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/resources/org/apache/servicemix/soap/HelloWorld-DOC.wsdl Fri Jun 19 05:46:02 2009
@@ -0,0 +1,125 @@
+<?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.
+
+-->
+<definitions name="Hello"
+        targetNamespace="uri:HelloWorld"
+        xmlns:tns="uri:HelloWorld"
+        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+        xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+        xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+    <types>
+        <schema targetNamespace="uri:HelloWorld"
+                xmlns="http://www.w3.org/2000/10/XMLSchema">
+            <element name="HelloRequest">
+                <complexType>
+                    <all>
+                        <element name="text" type="string"/>
+                    </all>
+                </complexType>
+            </element>
+            <element name="HelloResponse">
+                <complexType>
+                    <all>
+                        <element name="text" type="string"/>
+                    </all>
+                </complexType>
+            </element>
+            <element name="HelloHeader">
+                <complexType>
+                    <all>
+                        <element name="id" type="string"/>
+                    </all>
+                </complexType>
+            </element>
+            <element name="HelloFault">
+                <complexType>
+                    <all>
+                        <element name="id" type="string"/>
+                    </all>
+                </complexType>
+            </element>
+        </schema>
+    </types>
+
+    <message name="HelloRequest">
+        <part name="body" element="tns:HelloRequest"/>
+        <part name="header1" element="tns:HelloHeader"/>
+    </message>
+
+    <message name="HelloResponse">
+        <part name="body" element="tns:HelloResponse"/>
+    </message>
+
+    <message name="HelloFault">
+        <part name="body" element="tns:HelloFault"/>
+    </message>
+
+    <portType name="HelloPortType">
+        <operation name="Hello">
+            <input message="tns:HelloRequest"/>
+            <output message="tns:HelloResponse"/>
+            <fault name="fault" message="tns:HelloFault" />
+        </operation>
+    </portType>
+
+    <binding name="HelloSoap11Binding" type="tns:HelloPortType">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <operation name="Hello">
+            <soap:operation soapAction=""/>
+            <input>
+                <soap:body use="literal" parts="body"/>
+                <soap:header use="literal" message="tns:HelloRequest" part="header1"/>
+            </input>
+            <output>
+                <soap:body use="literal" parts="body"/>
+            </output>
+            <fault name="fault">
+                <soap:fault name="fault" use="literal" />
+            </fault>
+        </operation>
+    </binding>
+
+    <binding name="HelloSoap12Binding" type="tns:HelloPortType">
+        <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <operation name="Hello">
+            <soap12:operation soapAction=""/>
+            <input>
+                <soap12:body use="literal" parts="body"/>
+                <soap12:header use="literal" message="tns:HelloRequest" part="header1"/>
+            </input>
+            <output>
+                <soap12:body use="literal" parts="body"/>
+            </output>
+            <fault name="fault">
+                <soap12:fault name="fault" use="literal" />
+            </fault>
+        </operation>
+    </binding>
+
+    <service name="HelloService">
+        <port name="HelloPortSoap11" binding="tns:HelloSoap11Binding">
+            <soap:address location="http://localhost:8080/hello"/>
+        </port>
+        <port name="HelloPortSoap12" binding="tns:HelloSoap12Binding">
+            <soap12:address location="http://localhost:8080/hello"/>
+        </port>
+    </service>
+
+</definitions>

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/resources/org/apache/servicemix/soap/HelloWorld-DOC.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/resources/org/apache/servicemix/soap/HelloWorld-DOC.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap/src/test/resources/org/apache/servicemix/soap/HelloWorld-DOC.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml