You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by wo...@apache.org on 2008/03/03 19:48:24 UTC

svn commit: r633234 [10/24] - in /webservices/axis2/trunk/java: ./ modules/jaxws-integration/ modules/jaxws-integration/test/ modules/jaxws-integration/test/client/ modules/jaxws-integration/test/org/ modules/jaxws-integration/test/org/apache/ modules/...

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/MessageRPCTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/MessageRPCTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/MessageRPCTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/MessageRPCTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,317 @@
+/*
+ * 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.jaxws.message;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.jws.soap.SOAPBinding.Style;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
+import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.axis2.jaxws.TestLogger;
+import org.test.stock1.ObjectFactory;
+import org.test.stock1.StockPrice;
+
+/**
+ * MessageTests
+ * Tests to create and validate Message processing
+ * These are not client/server tests.  Instead the tests simulate the processing of a Message during
+ * client/server processing.
+ */
+public class MessageRPCTests extends TestCase {
+
+	// String test variables
+	private static final String soap11env = "http://schemas.xmlsoap.org/soap/envelope/";
+	private static final String soap12env = "http://www.w3.org/2003/05/soap-envelope";
+    private static final String sampleEnvelopeHead11 =
+        "<soapenv:Envelope xmlns:soapenv=\"" + soap11env + "\">" +
+        "<soapenv:Header /><soapenv:Body>";
+    
+    private static final String sampleEnvelopeHead12 =
+        "<soapenv:Envelope xmlns:soapenv=\"" + soap12env + "\">" +
+        "<soapenv:Header /><soapenv:Body>";
+    
+    private static final String sampleEnvelopeTail = 
+        "</soapenv:Body></soapenv:Envelope>";
+    
+    private static final String sampleText =
+        "<m:op xmlns:m='urn://sample'>" +
+		"<m:param xmlns:pre='urn://stock1.test.org' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='pre:StockPrice'>" +
+		"<price>100</price>" +
+		"</m:param>" +
+        "</m:op>";
+	
+    private static final String sampleEnvelope11 = 
+        sampleEnvelopeHead11 +
+        sampleText +
+        sampleEnvelopeTail;
+    
+    private static final String sampleEnvelope12 = 
+        sampleEnvelopeHead12 +
+        sampleText +
+        sampleEnvelopeTail;
+        
+	
+	private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+	
+	public MessageRPCTests() {
+		super();
+	}
+
+	public MessageRPCTests(String arg0) {
+		super(arg0);
+	}
+	
+	
+    
+    /**
+     * Create a JAXBBlock containing a JAX-B business object 
+     * and simulate a normal Proxy output flow
+     * @throws Exception
+     */
+    public void testJAXBOutflow() throws Exception {
+        // Create a SOAP 1.1 Message
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+        
+        // Indicate that the style is RPC, Indicate the Operation QName
+        m.setStyle(Style.RPC);
+        QName opQName = new QName("urn://sample", "op", "m");
+        m.setOperationElement(opQName);
+        
+        // Get the BlockFactory
+        JAXBBlockFactory bf = (JAXBBlockFactory)
+            FactoryRegistry.getFactory(JAXBBlockFactory.class);
+        
+        // Create the JAXBContext
+        JAXBBlockContext context = new JAXBBlockContext(StockPrice.class.getPackage().getName());
+        
+        // Create the JAX-B object
+        ObjectFactory of = new ObjectFactory();
+        StockPrice obj = of.createStockPrice();
+        obj.setPrice("100");
+        
+        // Create the JAX-B Element
+        QName paramQName = new QName("urn://sample", "param", "m");
+        JAXBElement e = new JAXBElement(paramQName, StockPrice.class, obj);
+        
+        // Create a JAXBBlock using the param object as the content.  This simulates
+        // what occurs on the outbound JAX-WS Proxy client
+        Block block = bf.createFrom(e, context, null);
+        
+        // Add the block to the message as normal body content.
+        m.setBodyBlock(block);
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "SPINE".equals(m.getXMLPartContentType()));
+        
+        // On an outbound flow, we need to convert the Message 
+        // to an OMElement, specifically an OM SOAPEnvelope, 
+        // so we can set it on the Axis2 MessageContext
+        org.apache.axiom.soap.SOAPEnvelope env = 
+            (org.apache.axiom.soap.SOAPEnvelope) m.getAsOMElement();
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "OM".equals(m.getXMLPartContentType()));
+        
+        // Serialize the Envelope using the same mechanism as the 
+        // HTTP client.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        env.serializeAndConsume(baos, new OMOutputFormat());
+        
+        // To check that the output is correct, get the String contents of the 
+        // reader
+        String newText = baos.toString();
+        TestLogger.logger.debug(newText);
+        assertTrue(newText.contains("m:op"));
+        assertTrue(newText.contains("m:param"));
+        assertTrue(newText.contains("100"));
+        assertTrue(newText.contains("Envelope"));
+        assertTrue(newText.contains("Body"));
+    }
+    
+    /**
+     * Create a JAXBBlock containing a JAX-B business object 
+     * and simulate a normal Proxy output flow
+     * @throws Exception
+     */
+    public void testJAXBOutflowPerf() throws Exception {
+        // Create a SOAP 1.1 Message
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+        
+        // Indicate that the style is RPC, Indicate the Operation QName
+        m.setStyle(Style.RPC);
+        QName opQName = new QName("urn://sample", "op", "m");
+        m.setOperationElement(opQName);
+        
+        // Get the BlockFactory
+        JAXBBlockFactory bf = (JAXBBlockFactory)
+            FactoryRegistry.getFactory(JAXBBlockFactory.class);
+        
+        // Create the JAXBContext
+        JAXBBlockContext context = new JAXBBlockContext(StockPrice.class.getPackage().getName());
+        
+        // Create the JAX-B object
+        ObjectFactory of = new ObjectFactory();
+        StockPrice obj = of.createStockPrice();
+        obj.setPrice("100");
+        
+        // Create the JAX-B Element
+        QName paramQName = new QName("urn://sample", "param", "m");
+        JAXBElement e = new JAXBElement(paramQName, StockPrice.class, obj);
+        
+        // Create a JAXBBlock using the param object as the content.  This simulates
+        // what occurs on the outbound JAX-WS Proxy client
+        Block block = bf.createFrom(e, context, null);
+        
+        // Add the block to the message as normal body content.
+        m.setBodyBlock(block);
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "SPINE".equals(m.getXMLPartContentType()));
+        
+        // On an outbound flow, we need to convert the Message 
+        // to an OMElement, specifically an OM SOAPEnvelope, 
+        // so we can set it on the Axis2 MessageContext
+        org.apache.axiom.soap.SOAPEnvelope env = 
+            (org.apache.axiom.soap.SOAPEnvelope) m.getAsOMElement();
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "OM".equals(m.getXMLPartContentType()));
+        
+        // PERFORMANCE CHECK:
+        // The param in the body should be an OMSourcedElement
+        OMElement o = env.getBody().getFirstElement().getFirstElement();
+        assertTrue(o instanceof OMSourcedElementImpl);
+        assertTrue(((OMSourcedElementImpl)o).isExpanded() == false);
+        
+        // Serialize the Envelope using the same mechanism as the 
+        // HTTP client.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        env.serializeAndConsume(baos, new OMOutputFormat());
+        
+        // To check that the output is correct, get the String contents of the 
+        // reader
+        String newText = baos.toString();
+        TestLogger.logger.debug(newText);
+        assertTrue(newText.contains("m:op"));
+        assertTrue(newText.contains("m:param"));
+        assertTrue(newText.contains("100"));
+        assertTrue(newText.contains("Envelope"));
+        assertTrue(newText.contains("Body"));
+    }
+    
+    
+    public void testJAXBInflow_soap11() throws Exception {
+		_testJAXBInflow(sampleEnvelope11);
+	}
+	public void testJAXBInflow_soap12() throws Exception {
+		_testJAXBInflow(sampleEnvelope12);
+	}
+	public void _testJAXBInflow(String sampleJAXBEnvelope) throws Exception {
+        // Create a SOAP OM out of the sample incoming XML.  This
+        // simulates what Axis2 will be doing with the inbound message. 
+        StringReader sr = new StringReader(sampleJAXBEnvelope);
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+        OMElement omElement = builder.getSOAPEnvelope();
+        
+        // Create a SOAP 1.1 Message from the sample incoming XML
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.createFrom(omElement, null);
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "OM".equals(m.getXMLPartContentType()));
+        
+        // Indicate that the message should be accessed as RPC
+        m.setStyle(Style.RPC);
+        
+        // Get the BlockFactory
+        JAXBBlockFactory bf = (JAXBBlockFactory)
+            FactoryRegistry.getFactory(JAXBBlockFactory.class);
+        
+        // Create the JAXBContext instance that will be used
+        // to deserialize the JAX-B object content in the message.
+        JAXBBlockContext context = new JAXBBlockContext(StockPrice.class.getPackage().getName());
+        
+        // Get the JAXBBlock that wraps the content
+        Block b = m.getBodyBlock(context, bf);
+     
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "SPINE".equals(m.getXMLPartContentType()));
+        
+        // Get the business object from the block, which should be a 
+        // JAX-B object
+        Object bo = b.getBusinessObject(true);
+        
+        // Check to make sure the right object was returned
+        assertNotNull(bo);
+        if (bo instanceof JAXBElement) {
+            bo = ((JAXBElement) bo).getValue();
+        }
+        assertTrue(bo instanceof StockPrice);
+        
+        
+        // Check to make sure the content of that object is correct
+        StockPrice obj = (StockPrice) bo;
+        assertNotNull(obj);
+        assertTrue(obj.getPrice().equals("100"));
+    }
+    
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/MessageTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/MessageTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/MessageTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/MessageTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,897 @@
+/*
+ * 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.jaxws.message;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
+import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.factory.SAAJConverterFactory;
+import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
+import org.apache.axis2.jaxws.message.util.SAAJConverter;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.axis2.jaxws.TestLogger;
+import test.EchoStringResponse;
+import test.ObjectFactory;
+
+/**
+ * MessageTests
+ * Tests to create and validate Message processing
+ * These are not client/server tests.  
+ * Instead the tests simulate the processing of a Message during client/server processing.
+ */
+public class MessageTests extends TestCase {
+
+	// String test variables
+	private static final String soap11env = "http://schemas.xmlsoap.org/soap/envelope/";
+	private static final String soap12env = "http://www.w3.org/2003/05/soap-envelope";
+    private static final String sampleEnvelopeHead11 =
+        "<soapenv:Envelope xmlns:soapenv=\"" + soap11env + "\">" +
+        "<soapenv:Header /><soapenv:Body>";
+    
+    private static final String sampleEnvelopeHead12 =
+        "<soapenv:Envelope xmlns:soapenv=\"" + soap12env + "\">" +
+        "<soapenv:Header /><soapenv:Body>";
+    
+    private static final String sampleEnvelopeTail = 
+        "</soapenv:Body></soapenv:Envelope>";
+    
+    private static final String sampleText =
+		"<pre:a xmlns:pre=\"urn://sample\">" +
+		"<b>Hello</b>" +
+		"<c>World</c>" +
+		"</pre:a>";
+    
+    private static final String sampleDouble =
+        "<pre:a xmlns:pre=\"urn://sample\">" +
+        "<b>Hello</b>" +
+        "<c>World</c>" +
+        "</pre:a>" +
+        "<pre:aa xmlns:pre=\"urn://sample\">" +
+        "<b>Hello</b>" +
+        "<c>World</c>" +
+        "</pre:aa>";
+	
+    private static final String sampleEnvelope11 = 
+        sampleEnvelopeHead11 +
+        sampleText +
+        sampleEnvelopeTail;
+    
+    private static final String sampleEnvelope12 = 
+        sampleEnvelopeHead12 +
+        sampleText +
+        sampleEnvelopeTail;
+        
+    private static final String sampleJAXBText = 
+        "<echoStringResponse xmlns=\"http://test\">" +
+        "<echoStringReturn>sample return value</echoStringReturn>" + 
+        "</echoStringResponse>";
+    
+    private static final String sampleJAXBEnvelope11 = 
+        sampleEnvelopeHead11 + 
+        sampleJAXBText + 
+        sampleEnvelopeTail;
+    
+    private static final String sampleJAXBEnvelope12 = 
+        sampleEnvelopeHead12 + 
+        sampleJAXBText + 
+        sampleEnvelopeTail;
+
+    private static final String sampleEnvelopeNoHeader11 =
+        "<soapenv:Envelope xmlns:soapenv=\""+ soap11env +"\">" +
+        "<soapenv:Body>" + 
+        sampleText + 
+        "</soapenv:Body></soapenv:Envelope>";
+    
+    private static final String sampleEnvelopeNoHeader12 =
+        "<soapenv:Envelope xmlns:soapenv=\""+ soap12env +"\">" +
+        "<soapenv:Body>" + 
+        sampleText + 
+        "</soapenv:Body></soapenv:Envelope>";
+    
+    
+    private static final QName sampleQName = new QName("urn://sample", "a");
+
+    private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+    public MessageTests() {
+        super();
+    }
+
+    public MessageTests(String arg0) {
+        super(arg0);
+    }
+
+    /**
+     * Create a Block representing an XMLString and simulate a normal Dispatch<String> flow. In
+     * addition the test makes sure that the XMLString block is not expanded during this process.
+     * (Expanding the block degrades performance).
+     * 
+     * @throws Exception
+     */
+    public void testStringOutflow() throws Exception {
+
+        // Create a SOAP 1.1 Message
+        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+
+        // Get the BlockFactory
+        XMLStringBlockFactory f =
+                (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+
+        // Create a Block using the sample string as the content. This simulates
+        // what occurs on the outbound JAX-WS dispatch<String> client
+        Block block = f.createFrom(sampleText, null, null);
+
+        // Add the block to the message as normal body content.
+        m.setBodyBlock(block);
+
+        // Check to see if the message is a fault. The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                   "SPINE".equals(m.getXMLPartContentType()));
+
+        // On an outbound flow, we need to convert the Message
+        // to an OMElement, specifically an OM SOAPEnvelope,
+        // so we can set it on the Axis2 MessageContext
+        org.apache.axiom.soap.SOAPEnvelope env =
+                (org.apache.axiom.soap.SOAPEnvelope) m.getAsOMElement();
+
+        // Check to see if the message is a fault. The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                   "OM".equals(m.getXMLPartContentType()));
+
+        // PERFORMANCE CHECK:
+        // The element in the body should be an OMSourcedElement
+        OMElement o = env.getBody().getFirstElement();
+        assertTrue(o instanceof OMSourcedElementImpl);
+        assertTrue(((OMSourcedElementImpl) o).isExpanded() == false);
+
+        // Serialize the Envelope using the same mechanism as the
+        // HTTP client.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        env.serializeAndConsume(baos, new OMOutputFormat());
+
+        String newText = baos.toString();
+        TestLogger.logger.debug(newText);
+        assertTrue(newText.contains(sampleText));
+        assertTrue(newText.contains("soap"));
+        assertTrue(newText.contains("Envelope"));
+        assertTrue(newText.contains("Body"));
+    }
+
+    /**
+     * Create a Block representing an XMLString and simulate a normal Dispatch<String> flow with an
+     * application handler.
+     * 
+     * @throws Exception
+     */
+    public void testStringOutflow2() throws Exception {
+
+        // Create a SOAP 1.1 Message
+        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+
+        // Get the BlockFactory
+        XMLStringBlockFactory f =
+                (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+
+        // Create a Block using the sample string as the content. This simulates
+        // what occurs on the outbound JAX-WS dispatch<String> client
+        Block block = f.createFrom(sampleText, null, null);
+
+        // Add the block to the message as normal body content.
+        m.setBodyBlock(block);
+
+        // If there is a JAX-WS handler, the Message is converted into a SOAPEnvelope
+        SOAPEnvelope soapEnvelope = m.getAsSOAPEnvelope();
+
+        // Check to see if the message is a fault. The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                   "SOAPENVELOPE".equals(m.getXMLPartContentType()));
+
+        // Normally the handler would not touch the body...but for our scenario, assume that it
+        // does.
+        String name = soapEnvelope.getBody().getFirstChild().getLocalName();
+        assertTrue("a".equals(name));
+
+        // The block should be consumed at this point
+        assertTrue(block.isConsumed());
+
+        // After the handler processing the message is obtained as an OM
+        OMElement om = m.getAsOMElement();
+
+        // Serialize the Envelope using the same mechanism as the
+        // HTTP client.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        om.serializeAndConsume(baos, new OMOutputFormat());
+
+        // To check that the output is correct, get the String contents of the
+        // reader
+        String newText = baos.toString();
+        TestLogger.logger.debug(newText);
+        assertTrue(newText.contains(sampleText));
+        assertTrue(newText.contains("soap"));
+        assertTrue(newText.contains("Envelope"));
+        assertTrue(newText.contains("Body"));
+
+    }
+    
+    /**
+     * Create a Block representing an empty XMLString and simulate a 
+     * normal Dispatch<String> flow with an application handler.
+     * @throws Exception
+     * 
+     * DISABLED THIS TEST. THE TEST IS NOT VALID BECAUSE AN ATTEMPT WAS 
+     * MADE TO ADD A BLOCK THAT IS NOT AN ELEMENT.
+     */
+    public void _testStringOutflowEmptyString() throws Exception {
+        
+        // Create a SOAP 1.1 Message
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+        
+        // Get the BlockFactory
+        XMLStringBlockFactory f = (XMLStringBlockFactory)
+            FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        
+        // Sample text is whitespace.  There is no element
+        
+        String whiteSpaceText = "<!-- Comment -->";
+        // Create a Block using the sample string as the content.  This simulates
+        // what occurs on the outbound JAX-WS dispatch<String> client
+        Block block = f.createFrom(whiteSpaceText, null, null);
+        
+        // Add the block to the message as normal body content.
+        m.setBodyBlock(block);
+        
+        // If there is a JAX-WS handler, the Message is converted into a SOAPEnvelope
+        SOAPEnvelope soapEnvelope = m.getAsSOAPEnvelope();
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "SOAPENVELOPE".equals(m.getXMLPartContentType()));
+        
+        // Normally the handler would not touch the body...but for our scenario, 
+        // assume that it does.
+        // The whitespace is not preserved, so there should be no first child in the body
+        assertTrue(soapEnvelope.getBody().getFirstChild() == null);
+        
+        // The block should be consumed at this point
+        assertTrue(block.isConsumed());
+        
+        // After the handler processing the message is obtained as an OM
+        OMElement om = m.getAsOMElement();
+                
+        // Serialize the Envelope using the same mechanism as the 
+        // HTTP client.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        om.serializeAndConsume(baos, new OMOutputFormat());
+        
+        // To check that the output is correct, get the String contents of the 
+        // reader
+        String newText = baos.toString();
+        TestLogger.logger.debug(newText);
+        assertTrue(newText.contains("soap"));
+        assertTrue(newText.contains("Envelope"));
+        assertTrue(newText.contains("Body"));
+        
+    }
+	
+    /**
+     * Create a Block representing an XMLString with 2 elements and simulate a 
+     * normal Dispatch<String> flow with an application handler.
+     * @throws Exception
+     * 
+     * @REVIEW This test is disabled because (a) it fails and (b) we don't believe this
+     * is allowed due by WSI.
+     */
+    public void _testStringOutflowDoubleElement() throws Exception {
+        
+        // Create a SOAP 1.1 Message
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+        
+        // Get the BlockFactory
+        XMLStringBlockFactory f = (XMLStringBlockFactory)
+            FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        
+        // Create a Block using the sample string as the content.  This simulates
+        // what occurs on the outbound JAX-WS dispatch<String> client
+        // In this case the sample string contains 2 elements a and aa
+        Block block = f.createFrom(this.sampleDouble, null, null);
+        
+        // Add the block to the message as normal body content.
+        m.setBodyBlock(block);
+        
+        // If there is a JAX-WS handler, the Message is converted into a SOAPEnvelope
+        SOAPEnvelope soapEnvelope = m.getAsSOAPEnvelope();
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "SOAPENVELOPE".equals(m.getXMLPartContentType()));
+        
+        // Normally the handler would not touch the body...but for our scenario, 
+        // assume that it does.
+        String name = soapEnvelope.getBody().getFirstChild().getLocalName();
+        assertTrue("a".equals(name));
+        name = soapEnvelope.getBody().getLastChild().getLocalName();
+        assertTrue("aa".equals(name));
+        
+        // The block should be consumed at this point
+        assertTrue(block.isConsumed());
+        
+        // After the handler processing the message is obtained as an OM
+        OMElement om = m.getAsOMElement();
+                
+        // Serialize the Envelope using the same mechanism as the 
+        // HTTP client.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        om.serializeAndConsume(baos, new OMOutputFormat());
+        
+        // To check that the output is correct, get the String contents of the 
+        // reader
+        String newText = baos.toString();
+        TestLogger.logger.debug(newText);
+        assertTrue(newText.contains(sampleText));
+        assertTrue(newText.contains("soap"));
+        assertTrue(newText.contains("Envelope"));
+        assertTrue(newText.contains("Body"));
+        
+    }
+    
+	/**
+     * Create a Block representing an XMLString and simulate a normal Dispatch<String> input flow
+     * 
+     * @throws Exception
+     */
+    public void testStringInflow_soap11() throws Exception {
+        _testStringInflow(sampleEnvelope11);
+    }
+
+    public void testStringInflow_soap12() throws Exception {
+        _testStringInflow(sampleEnvelope12);
+    }
+
+    public void _testStringInflow(String sampleEnvelope) throws Exception {
+
+        // On inbound, there will already be an OM
+        // which represents the message. The following code simulates the input
+        // OM
+        StringReader sr = new StringReader(sampleEnvelope);
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+        OMElement omElement = builder.getSOAPEnvelope();
+
+        // The JAX-WS layer creates a Message from the OM
+        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.createFrom(omElement, null);
+
+        // Check to see if the message is a fault. The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                   "OM".equals(m.getXMLPartContentType()));
+
+        // Assuming no handlers are installed, the next thing that will happen
+        // is the proxy code will ask for the business object (String).
+        XMLStringBlockFactory blockFactory =
+                (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        Block block = m.getBodyBlock(null, blockFactory);
+        Object bo = block.getBusinessObject(true);
+        assertTrue(bo instanceof String);
+
+        // The block should be consumed
+        assertTrue(block.isConsumed());
+
+        // Check the String for accuracy
+        assertTrue(sampleText.equals(bo.toString()));
+
+    }
+
+    /**
+     * Create a Block representing an XMLString and simulate a normal Dispatch<String> input flow
+     * with a JAX-WS Handler
+     * 
+     * @throws Exception
+     */
+    public void testStringInflow2_soap11() throws Exception {
+        _testStringInflow2(sampleEnvelope11);
+    }
+
+    public void testStringInflow2_soap12() throws Exception {
+        // Only run test if an SAAJ 1.3 MessageFactory is available
+        javax.xml.soap.MessageFactory mf = null;
+        try {
+            mf = getSAAJConverter().createMessageFactory(soap12env);
+        } catch (Exception e) {
+        }
+        if (mf != null) {
+            _testStringInflow2(sampleEnvelope12);
+        }
+    }
+
+    public void _testStringInflow2(String sampleEnvelope) throws Exception {
+
+        // On inbound, there will already be an OM
+        // which represents the message. The following code simulates the input
+        // OM
+        StringReader sr = new StringReader(sampleEnvelope);
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+        OMElement omElement = builder.getSOAPEnvelope();
+
+        // The JAX-WS layer creates a Message from the OM
+        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.createFrom(omElement, null);
+
+        // Check to see if the message is a fault. The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                   "OM".equals(m.getXMLPartContentType()));
+
+        // If there is a JAX-WS handler, the Message is converted into a SOAPEnvelope
+        SOAPEnvelope soapEnvelope = m.getAsSOAPEnvelope();
+
+        // Check to see if the message is a fault. The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                   "SOAPENVELOPE".equals(m.getXMLPartContentType()));
+
+        // Normally the handler would not touch the body...but for our scenario, assume that it
+        // does.
+        String name = soapEnvelope.getBody().getFirstChild().getLocalName();
+        assertTrue("a".equals(name));
+
+        // The next thing that will happen
+        // is the proxy code will ask for the business object (String).
+        XMLStringBlockFactory blockFactory =
+                (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        Block block = m.getBodyBlock(null, blockFactory);
+        Object bo = block.getBusinessObject(true);
+        assertTrue(bo instanceof String);
+
+        // The block should be consumed
+        assertTrue(block.isConsumed());
+
+        // Check the String for accuracy
+        assertTrue(sampleText.equals(bo.toString()));
+
+    }
+
+    /**
+     * Create a Block representing an XMLString and simulate a normal Dispatch<String> input flow
+     * with a JAX-WS Handler that needs the whole Message
+     * 
+     * @throws Exception
+     */
+    public void testStringInflow3_soap11() throws Exception {
+        _testStringInflow3(sampleEnvelope11);
+    }
+
+    public void testStringInflow3_soap12() throws Exception {
+        // Only run test if an SAAJ 1.3 MessageFactory is available
+        javax.xml.soap.MessageFactory mf = null;
+        try {
+            mf = getSAAJConverter().createMessageFactory(soap12env);
+        } catch (Exception e) {
+        }
+        if (mf != null) {
+            _testStringInflow3(sampleEnvelope12);
+        }
+    }
+
+    public void _testStringInflow3(String sampleEnvelope) throws Exception {
+
+        // On inbound, there will already be an OM
+        // which represents the message. The following code simulates the input
+        // OM
+        StringReader sr = new StringReader(sampleEnvelope);
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+        OMElement omElement = builder.getSOAPEnvelope();
+
+        // The JAX-WS layer creates a Message from the OM
+        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.createFrom(omElement, null);
+
+        // Check to see if the message is a fault. The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                   "OM".equals(m.getXMLPartContentType()));
+
+        // If there is a JAX-WS handler, the Message is converted into a SOAPEnvelope
+        SOAPMessage sm = m.getAsSOAPMessage();
+
+        // Check to see if the message is a fault. The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                   "SOAPENVELOPE".equals(m.getXMLPartContentType()));
+
+        // Normally the handler would not touch the body...but for our scenario, assume that it
+        // does.
+        String name = sm.getSOAPBody().getFirstChild().getLocalName();
+        assertTrue("a".equals(name));
+
+        // The next thing that will happen
+        // is the proxy code will ask for the business object (String).
+        XMLStringBlockFactory blockFactory =
+                (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        Block block = m.getBodyBlock(null, blockFactory);
+        Object bo = block.getBusinessObject(true);
+        assertTrue(bo instanceof String);
+
+        // The block should be consumed
+        assertTrue(block.isConsumed());
+
+        // Check the String for accuracy
+        assertTrue(sampleText.equals(bo.toString()));
+
+    }
+    
+    /**
+     * Create a Block representing an XMLString, but this time use one that
+     * doesn't have a &lt;soap:Header&gt; element in it.
+     * @throws Exception
+     */
+	public void testStringInflow4_soap11() throws Exception {
+		_testStringInflow4(sampleEnvelopeNoHeader11);
+	}
+	public void testStringInflow4_soap12() throws Exception {
+		_testStringInflow4(sampleEnvelopeNoHeader12);
+	}
+	public void _testStringInflow4(String sampleEnvelopeNoHeader) throws Exception {
+        // On inbound, there will already be an OM
+        // which represents the message.  The following code simulates the input
+        // OM
+        StringReader sr = new StringReader(sampleEnvelopeNoHeader);
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+        OMElement omElement = builder.getSOAPEnvelope();
+        
+        // The JAX-WS layer creates a Message from the OM
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.createFrom(omElement, null);
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "OM".equals(m.getXMLPartContentType()));
+        
+        // The next thing that will happen
+        // is the proxy code will ask for the business object (String).
+        XMLStringBlockFactory blockFactory = 
+            (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        Block block = m.getBodyBlock(null, blockFactory);
+        Object bo = block.getBusinessObject(true);
+        assertTrue(bo instanceof String);
+        
+        // The block should be consumed
+        assertTrue(block.isConsumed());
+        
+        // Check the String for accuracy
+        assertTrue(sampleText.equals(bo.toString()));
+        
+    }
+    
+    /**
+     * Create a JAXBBlock containing a JAX-B business object 
+     * and simulate a normal Dispatch<Object> output flow
+     * @throws Exception
+     */
+    public void testJAXBOutflow() throws Exception {
+        // Create a SOAP 1.1 Message
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+        
+        // Get the BlockFactory
+        JAXBBlockFactory bf = (JAXBBlockFactory)
+            FactoryRegistry.getFactory(JAXBBlockFactory.class);
+        
+        // Create the JAX-B object
+        ObjectFactory of = new ObjectFactory();
+        EchoStringResponse obj = of.createEchoStringResponse();
+        obj.setEchoStringReturn("sample return value");
+        
+        // Create the JAXBContext
+        JAXBBlockContext context = 
+            new JAXBBlockContext(EchoStringResponse.class.getPackage().getName());
+        
+        // Create a JAXBBlock using the Echo object as the content.  This simulates
+        // what occurs on the outbound JAX-WS Dispatch<Object> client
+        Block block = bf.createFrom(obj, context, null);
+        
+        // Add the block to the message as normal body content.
+        m.setBodyBlock(block);
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "SPINE".equals(m.getXMLPartContentType()));
+        
+        // On an outbound flow, we need to convert the Message 
+        // to an OMElement, specifically an OM SOAPEnvelope, 
+        // so we can set it on the Axis2 MessageContext
+        org.apache.axiom.soap.SOAPEnvelope env = 
+            (org.apache.axiom.soap.SOAPEnvelope) m.getAsOMElement();
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "OM".equals(m.getXMLPartContentType()));
+        
+        // Serialize the Envelope using the same mechanism as the 
+        // HTTP client.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        env.serializeAndConsume(baos, new OMOutputFormat());
+        
+        // To check that the output is correct, get the String contents of the 
+        // reader
+        String newText = baos.toString();
+        TestLogger.logger.debug(newText);
+        assertTrue(newText.contains(sampleJAXBText));
+        assertTrue(newText.contains("soap"));
+        assertTrue(newText.contains("Envelope"));
+        assertTrue(newText.contains("Body"));
+    }
+    
+    /**
+     * Same as JAXBOutputflow, but has an additional check
+     * to make sure that the JAXB serialization is deferrred
+     * until the actual serialization of the message.
+     * @throws Exception
+     */
+    public void testJAXBOutflowPerf() throws Exception {
+        // Create a SOAP 1.1 Message
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap11);
+        
+        // Get the BlockFactory
+        JAXBBlockFactory bf = (JAXBBlockFactory)
+            FactoryRegistry.getFactory(JAXBBlockFactory.class);
+        
+        // Create the JAX-B object
+        ObjectFactory of = new ObjectFactory();
+        EchoStringResponse obj = of.createEchoStringResponse();
+        obj.setEchoStringReturn("sample return value");
+        
+        // Create the JAXBContext
+        JAXBBlockContext context = 
+            new JAXBBlockContext(EchoStringResponse.class.getPackage().getName());
+       
+        // Create a JAXBBlock using the Echo object as the content.  This simulates
+        // what occurs on the outbound JAX-WS Dispatch<Object> client
+        Block block = bf.createFrom(obj, context, null);
+        
+        // Add the block to the message as normal body content.
+        m.setBodyBlock(block);
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "SPINE".equals(m.getXMLPartContentType()));
+        
+        // On an outbound flow, we need to convert the Message 
+        // to an OMElement, specifically an OM SOAPEnvelope, 
+        // so we can set it on the Axis2 MessageContext
+        org.apache.axiom.soap.SOAPEnvelope env = 
+            (org.apache.axiom.soap.SOAPEnvelope) m.getAsOMElement();
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "OM".equals(m.getXMLPartContentType()));
+        
+        // PERFORMANCE CHECK:
+        // The element in the body should be an OMSourcedElement
+        OMElement o = env.getBody().getFirstElement();
+        assertTrue(o instanceof OMSourcedElementImpl);
+        assertTrue(((OMSourcedElementImpl)o).isExpanded() == false);
+        
+        // Serialize the Envelope using the same mechanism as the 
+        // HTTP client.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        env.serializeAndConsume(baos, new OMOutputFormat());
+        
+        // To check that the output is correct, get the String contents of the 
+        // reader
+        String newText = baos.toString();
+        TestLogger.logger.debug(newText);
+        assertTrue(newText.contains(sampleJAXBText));
+        assertTrue(newText.contains("soap"));
+        assertTrue(newText.contains("Envelope"));
+        assertTrue(newText.contains("Body"));
+    }
+    
+    private final int NO_PERSIST       = 0;
+    private final int PERSIST         = 1;
+    private final int SAVE_AND_PERSIST = 2;
+    public void testJAXBInflow_soap11() throws Exception {
+		_testJAXBInflow(sampleJAXBEnvelope11, NO_PERSIST);
+	}
+	public void testJAXBInflow_soap12() throws Exception {
+		_testJAXBInflow(sampleJAXBEnvelope12, NO_PERSIST);
+	}
+    public void testJAXBInflow_soap11_withPersist() throws Exception {
+        _testJAXBInflow(sampleJAXBEnvelope11, PERSIST);
+    }
+    public void testJAXBInflow_soap12_withPersist() throws Exception {
+        _testJAXBInflow(sampleJAXBEnvelope12, PERSIST);
+    }
+    public void testJAXBInflow_soap11_withSaveAndPersist() throws Exception {
+        _testJAXBInflow(sampleJAXBEnvelope11, SAVE_AND_PERSIST);
+    }
+    public void testJAXBInflow_soap12_withSaveAndPersist() throws Exception {
+        _testJAXBInflow(sampleJAXBEnvelope12, SAVE_AND_PERSIST);
+    }
+	public void _testJAXBInflow(String sampleJAXBEnvelope, int persist) throws Exception {
+        // Create a SOAP OM out of the sample incoming XML.  This
+        // simulates what Axis2 will be doing with the inbound message. 
+        StringReader sr = new StringReader(sampleJAXBEnvelope);
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+        OMElement omElement = builder.getSOAPEnvelope();
+        
+        // Create a SOAP 1.1 Message from the sample incoming XML
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.createFrom(omElement, null);
+        
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        boolean isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "OM".equals(m.getXMLPartContentType()));
+        
+        String saveMsgText = "";
+        if (persist == SAVE_AND_PERSIST) {
+            // Simulate saving the message so that it can be fully rebuilt.
+            saveMsgText = m.getAsOMElement().toString();
+        }
+        
+        // Get the BlockFactory
+        JAXBBlockFactory bf = (JAXBBlockFactory)
+            FactoryRegistry.getFactory(JAXBBlockFactory.class);
+        
+        // Create the JAXBContext instance that will be used
+        // to deserialize the JAX-B object content in the message.
+        JAXBBlockContext context = 
+            new JAXBBlockContext(EchoStringResponse.class.getPackage().getName());
+        
+        // Get the JAXBBlock that wraps the content
+        Block b = m.getBodyBlock(context, bf);
+     
+        // Check to see if the message is a fault.  The client/server will always call this method.
+        // The Message must respond appropriately without doing a conversion.
+        isFault = m.isFault();
+        assertTrue(!isFault);
+        assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
+                    "SPINE".equals(m.getXMLPartContentType()));
+        
+        // Get the business object from the block, which should be a 
+        // JAX-B object
+        Object bo = b.getBusinessObject(false);
+        m.setPostPivot();
+        
+        // Simulate restoring the message
+        if (persist == SAVE_AND_PERSIST) {
+            sr = new StringReader(saveMsgText);
+            XMLStreamReader saveMsgReader = inputFactory.createXMLStreamReader(sr);
+            builder = new StAXSOAPModelBuilder(saveMsgReader, null);
+            omElement = builder.getSOAPEnvelope();
+            m = mf.createFrom(omElement, null);
+        } 
+        
+        
+        // Check to make sure the right object was returned
+        assertNotNull(bo);
+        assertTrue(bo instanceof EchoStringResponse);
+        
+        // Check to make sure the content of that object is correct
+        EchoStringResponse esr = (EchoStringResponse) bo;
+        assertNotNull(esr.getEchoStringReturn());
+        assertTrue(esr.getEchoStringReturn().equals("sample return value"));
+        
+        // Simulate outbound
+        if (persist == PERSIST) {
+            String persistMsg = m.getAsOMElement().toString();
+            // We should be able to persist the message, 
+            // and the persisted message WILL contain the echoStringResponse contents
+            assertTrue(persistMsg.contains("Body"));
+            assertTrue(persistMsg.contains("echoStringResponse"));
+            assertTrue(persistMsg.contains("sample return value"));
+            
+        } else if (persist == SAVE_AND_PERSIST) {
+            String persistMsg = m.getAsOMElement().toString();
+            // We should be able to persist the message, 
+            // and the persisted message WILL contain the echoStringResponse contents
+            assertTrue(persistMsg.contains("Body"));
+            assertTrue(persistMsg.contains("echoStringResponse"));
+            assertTrue(persistMsg.contains("sample return value"));
+        }
+        
+        // After persistance: Sandesha may inspect the body.  Make sure this does not cause an error
+        org.apache.axiom.soap.SOAPEnvelope env = (org.apache.axiom.soap.SOAPEnvelope) m.getAsOMElement();
+        QName qName = new QName("uri://fake", "fake");
+        env.getBody().getFirstChildWithName(qName);
+    }
+
+    SAAJConverter converter = null;
+
+    private SAAJConverter getSAAJConverter() {
+        if (converter == null) {
+            SAAJConverterFactory factory =
+                    (SAAJConverterFactory) FactoryRegistry.getFactory(SAAJConverterFactory.class);
+            converter = factory.getSAAJConverter();
+        }
+        return converter;
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/SAAJConverterTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/SAAJConverterTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/SAAJConverterTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/SAAJConverterTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,179 @@
+/*
+ * 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.jaxws.message;
+
+import java.io.StringReader;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+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.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.jaxws.message.factory.SAAJConverterFactory;
+import org.apache.axis2.jaxws.message.util.SAAJConverter;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+
+/**
+ * SAAJConverterTests
+ * 
+ * Test the basic functionality of the SAAJConverter.
+ * You can also use these tests to as sample code on how to use
+ * the converter.
+ *
+ */
+public class SAAJConverterTests extends TestCase {
+
+	private static final String sampleText =
+		"<pre:a xmlns:pre=\"urn://sample\">" +
+		"<b>Hello</b>" +
+		"<c>World</c>" +
+		"</pre:a>";
+	
+	private static final String sampleEnvelope = 
+		"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+		"<soapenv:Header /><soapenv:Body>" +
+		sampleText +
+		"</soapenv:Body></soapenv:Envelope>";
+	
+	private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+	
+	public SAAJConverterTests() {
+		super();
+	}
+
+	public SAAJConverterTests(String arg0) {
+		super(arg0);
+	}
+
+	/**
+	 * @testStrategy Tests conversions between SAAJ and OM SOAPEnvelopes
+	 */
+	public void test1() throws Exception {
+		
+		// Bootstrap: Create an OM SOAPEnvelope from the sample text
+		StringReader sr = new StringReader(sampleEnvelope);
+		XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+		StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+		org.apache.axiom.soap.SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
+		
+		// Step 1: Get the SAAJConverter object from the Factory
+		SAAJConverterFactory f = (SAAJConverterFactory) 
+			FactoryRegistry.getFactory(SAAJConverterFactory.class);
+		SAAJConverter converter = f.getSAAJConverter();
+		
+		// Step 2: Convert the OM SOAPEnvelope to an SAAJ SOAPEnvelope
+		SOAPEnvelope saajEnvelope = converter.toSAAJ(omEnvelope);
+		
+		// Step 2a: Simple assertion check to ensure correctness.
+		String name = saajEnvelope.getBody().getFirstChild().getLocalName();
+		assertTrue("a".equals(name));
+		
+		// Step 3: Convert the SAAJ SOAPEnvelope to an OM SOAPEnvelope
+		omEnvelope = converter.toOM(saajEnvelope);
+		
+		// Step 3a: Simple assertion check to ensure correctness
+		name = omEnvelope.getBody().getFirstElement().getLocalName();
+		assertTrue("a".equals(name));
+		
+		// Step 4: Rinse and repeat
+		saajEnvelope = converter.toSAAJ(omEnvelope);
+		name = saajEnvelope.getBody().getFirstChild().getLocalName();
+		assertTrue("a".equals(name));
+		omEnvelope = converter.toOM(saajEnvelope);
+		name = omEnvelope.getBody().getFirstElement().getLocalName();
+		assertTrue("a".equals(name));
+	}
+	
+	/**
+	 * @testStrategy Tests conversions between SAAJ and OM for normal element
+	 */
+	public void test2() throws Exception {
+		
+		// Bootstrap: Create an OM SOAPEnvelope from the sample text.
+		StringReader sr = new StringReader(sampleEnvelope);
+		XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+		StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+		org.apache.axiom.soap.SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
+		
+		// Bootstrap: Get an OMElement from the body
+		OMElement om = omEnvelope.getBody().getFirstElement();
+		
+		// Bootstrap: Get an SAAJ Body to hold the target SOAPElement
+		MessageFactory msgFactory = MessageFactory.newInstance();
+		SOAPMessage message = msgFactory.createMessage();
+		SOAPBody body = message.getSOAPBody();
+		
+		// Step 1: Get the SAAJConverter object from the Factory
+		SAAJConverterFactory f = (SAAJConverterFactory) 
+			FactoryRegistry.getFactory(SAAJConverterFactory.class);
+		SAAJConverter converter = f.getSAAJConverter();
+		
+		// Step 2: Convert OM to SAAJ
+		SOAPElement se = converter.toSAAJ(om, body);
+		
+		// Step 2a: Verify
+		assertTrue(se instanceof SOAPBodyElement);
+		assertTrue(se.getLocalName().equals("a"));
+		
+		// Step 3: Convert SAAJ to OM
+		om = converter.toOM(se);
+		
+		// Step 3a: Verify
+		assertTrue(om.getLocalName().equals("a"));
+		
+		// Step 4: Rinse and Repeat
+		se = converter.toSAAJ(om, body);
+		assertTrue(se instanceof SOAPBodyElement);
+		assertTrue(se.getLocalName().equals("a"));
+		om = converter.toOM(se);
+		assertTrue(om.getLocalName().equals("a"));
+	}
+	
+	/**
+	 * @testStrategy: Create an OMElement, without using a builder.  Verification of AXIS2-970
+	 */
+    public void test3() throws Exception {
+    	
+//    	 Step 1: Get the SAAJConverter object from the Factory
+		SAAJConverterFactory f = (SAAJConverterFactory) 
+			FactoryRegistry.getFactory(SAAJConverterFactory.class);
+		SAAJConverter converter = f.getSAAJConverter();
+		
+		// Stept 2: Create OM and parent SOAPElement
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace wrapNs = fac.createOMNamespace("namespace", "prefix");
+        OMElement ome = fac.createOMElement("localname", wrapNs);
+        SOAPFactory sf = SOAPFactory.newInstance();
+        SOAPElement se = sf.createElement("name");
+        
+        // Step 3: Do the conversion
+        converter.toSAAJ(ome, se, sf);
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/SOAP12Tests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/SOAP12Tests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/SOAP12Tests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/message/SOAP12Tests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,237 @@
+/*
+ * 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.jaxws.message;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
+import org.apache.axis2.jaxws.message.util.Reader2Writer;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.axis2.jaxws.TestLogger;
+
+/**
+ * This suite is used to test the creation of messages based on SOAP 1.2
+ * with both inbound and outbound simulations. 
+ *
+ */
+public class SOAP12Tests extends TestCase {
+
+    private static final String sampleText = 
+        "<echo>test string</echo>";
+    
+    private static final String sampleSoap12EnvelopeHead =
+        "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" +
+        "<soapenv:Header /><soapenv:Body>";
+    
+    private static final String sampleEnvelopeTail =
+        "</soapenv:Body></soapenv:Envelope>";    
+    
+    private static final String sampleSoap12Envelope = 
+        sampleSoap12EnvelopeHead + 
+        sampleText + 
+        sampleEnvelopeTail;
+    
+    private static final String SOAP12_NS_URI = 
+        "http://www.w3.org/2003/05/soap-envelope";
+    
+    public static final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+    
+    public SOAP12Tests(String name) {
+        super(name);
+    }
+    
+    /**
+     * Simulate creating a SOAP 1.2 message when the business object
+     * provided is just the payload. 
+     */
+    public void testCreateSoap12FromPayload() throws Exception {
+        // Create a SOAP 1.2 Message
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.create(Protocol.soap12);
+        
+        // Get the BlockFactory
+        XMLStringBlockFactory f = (XMLStringBlockFactory)
+            FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        
+        // Create a Block using the sample string as the content.  This simulates
+        // what occurs on the outbound JAX-WS dispatch<String> client
+        Block block = f.createFrom(sampleText, null, null);
+        
+        // Add the block to the message as normal body content.
+        m.setBodyBlock(block);
+        
+        // Assuming no handlers are installed, the next thing that will happen
+        // is a XMLStreamReader will be requested...to go to OM.   At this point the
+        // block should be consumed.
+        OMElement om = m.getAsOMElement();
+        
+        // The block should not be consumed yet...because the message has not been read
+        assertTrue(!block.isConsumed());
+        
+        // To check that the output is correct, get the String contents of the 
+        // reader
+        Reader2Writer r2w = new Reader2Writer(om.getXMLStreamReader());
+        String newText = r2w.getAsString();
+        TestLogger.logger.debug(newText);
+        assertTrue(newText.contains(sampleText));
+        assertTrue(newText.contains("soap"));
+        assertTrue(newText.contains("Envelope"));
+        assertTrue(newText.contains("Body"));
+        
+        assertTrue(m.getProtocol().equals(Protocol.soap12));
+        
+        SOAPEnvelope omSoapEnv = (SOAPEnvelope) m.getAsOMElement();
+        OMNamespace ns = omSoapEnv.getNamespace();
+        assertTrue(ns.getNamespaceURI().equals(SOAP12_NS_URI));
+        
+        // The block should be consumed at this point
+        assertTrue(block.isConsumed());
+    }
+    
+    /**
+     * Simulate creating a SOAP 1.2 message when the business object
+     * provided is the full message.
+     */
+    public void testCreateSoap12FromMessage() throws Exception {
+        // Create a SOAP 1.2 Message
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        
+        // Get the BlockFactory
+        XMLStringBlockFactory f = (XMLStringBlockFactory)
+            FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        
+        // Create a Block using the sample string as the content.  This simulates
+        // what occurs on the outbound JAX-WS dispatch<String> client
+        Block block = f.createFrom(sampleSoap12Envelope, null, null);
+        
+        // Create a Message with the full XML contents that we have
+        Message m = mf.createFrom(block.getXMLStreamReader(true), null);
+        
+        // Assuming no handlers are installed, the next thing that will happen
+        // is a XMLStreamReader will be requested...to go to OM.   At this point the
+        // block should be consumed.
+        OMElement om = m.getAsOMElement();
+        
+        // To check that the output is correct, get the String contents of the 
+        // reader
+        Reader2Writer r2w = new Reader2Writer(om.getXMLStreamReaderWithoutCaching());
+        String newText = r2w.getAsString();
+        TestLogger.logger.debug(newText);
+        assertTrue(newText.contains(sampleText));
+        assertTrue(newText.contains("soap"));
+        assertTrue(newText.contains("Envelope"));
+        assertTrue(newText.contains("Body"));
+        
+        assertTrue(m.getProtocol().equals(Protocol.soap12));
+        
+        SOAPEnvelope omSoapEnv = (SOAPEnvelope) m.getAsOMElement();
+        OMNamespace ns = omSoapEnv.getNamespace();
+        assertTrue(ns.getNamespaceURI().equals(SOAP12_NS_URI));
+        
+        // The block should be consumed at this point
+        assertTrue(block.isConsumed());
+    }
+    
+    public void testGetPayloadFromSoap12() throws Exception {
+        // On inbound, there will already be an OM
+        // which represents the message.  The following code simulates the input
+        // OM
+        StringReader sr = new StringReader(sampleSoap12Envelope);
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+        OMElement omElement = builder.getSOAPEnvelope();
+        
+        // The JAX-WS layer creates a Message from the OM
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.createFrom(omElement, null);
+        
+        // Make sure the right Protocol was set on the Message
+        assertTrue(m.getProtocol().equals(Protocol.soap12));
+        
+        // Check the SOAPEnvelope to make sure we've got the right
+        // protocol namespace there as well.
+        SOAPEnvelope soapEnv = (SOAPEnvelope) m.getAsOMElement();
+        OMNamespace ns = soapEnv.getNamespace();
+        assertTrue(ns.getNamespaceURI().equals(SOAP12_NS_URI));
+        
+        // Assuming no handlers are installed, the next thing that will happen
+        // is the proxy code will ask for the business object (String).
+        XMLStringBlockFactory blockFactory = 
+            (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        Block block = m.getBodyBlock(null, blockFactory);
+        Object bo = block.getBusinessObject(true);
+        assertTrue(bo instanceof String);
+        
+        // The block should be consumed
+        assertTrue(block.isConsumed());
+        
+        // Check the String for accuracy
+        assertTrue(sampleText.equals(bo));
+    }
+    
+    public void testGetMessageFromSoap12() throws Exception {
+        // On inbound, there will already be an OM
+        // which represents the message.  The following code simulates the input
+        // OM
+        StringReader sr = new StringReader(sampleSoap12Envelope);
+        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+        OMElement omElement = builder.getSOAPEnvelope();
+        
+        // The JAX-WS layer creates a Message from the OM
+        MessageFactory mf = (MessageFactory)
+            FactoryRegistry.getFactory(MessageFactory.class);
+        Message m = mf.createFrom(omElement, null);
+        
+        // Make sure the right Protocol was set on the Message
+        assertTrue(m.getProtocol().equals(Protocol.soap12));
+        
+        // Check the SOAPEnvelope to make sure we've got the right
+        // protocol namespace there as well.
+        SOAPEnvelope soapEnv = (SOAPEnvelope) m.getAsOMElement();
+        OMNamespace ns = soapEnv.getNamespace();
+        assertTrue(ns.getNamespaceURI().equals(SOAP12_NS_URI));
+        
+        // Assuming no handlers are installed, the next thing that will happen
+        // is the proxy code will ask for the business object (String).
+        XMLStringBlockFactory blockFactory = 
+            (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+        Block block = blockFactory.createFrom(m.getAsOMElement(), null, null);
+        Object bo = block.getBusinessObject(true);
+        assertTrue(bo instanceof String);
+        
+        // The block should be consumed
+        assertTrue(block.isConsumed());
+        
+        // Check the String for accuracy
+        assertTrue(((String)bo).contains("<soapenv:Body><echo>test string</echo></soapenv:Body>"));
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/ConvertUtilsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/ConvertUtilsTest.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/ConvertUtilsTest.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/ConvertUtilsTest.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.jaxws.misc;
+
+import org.apache.axis2.jaxws.utility.ConvertUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit Test for the ConvertUtils utility
+ */
+public class ConvertUtilsTest extends TestCase {
+
+    public void test() throws Exception {
+        Byte[] input = new Byte[3];
+        input[0] = new Byte((byte) 0);
+        input[1] = new Byte((byte) 1);
+        input[2] = new Byte((byte) 2);
+        
+        byte[] output = new byte[3];
+        
+        output = (byte[]) ConvertUtils.convert(input, 
+                                               output.getClass());
+        
+        assertTrue(output.length == 3);
+        assertTrue(output[0] == (byte) 0);
+        assertTrue(output[1] == (byte) 1);
+        assertTrue(output[2] == (byte) 2);
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,105 @@
+/*
+ * 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.jaxws.misc;
+
+import java.util.TreeSet;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.apache.axis2.jaxws.message.databinding.JAXBUtils;
+import org.apache.axis2.jaxws.utility.JavaUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests Namespace to Package Algorithmh
+ *
+ */
+public class JAXBContextTest extends TestCase {
+
+    /**
+     * Test basic functionality of JAXBUtils pooling
+     * @throws Exception
+     */
+    public void test01() throws JAXBException {
+        
+        // Get a JAXBContext
+        TreeSet<String> context1 = new TreeSet<String>();
+        context1.add("org.test.addnumbers");
+        context1.add("org.test.anytype");
+        
+        JAXBContext jaxbContext1 = JAXBUtils.getJAXBContext(context1);
+        
+        // Assert that the JAXBContext was found and the context contains the two valid packages
+        assertTrue(jaxbContext1 != null);
+        assertTrue(context1.contains("org.test.addnumbers"));
+        assertTrue(context1.contains("org.test.anytype"));
+        
+        // Repeat with the same packages
+        TreeSet<String> context2 = new TreeSet<String>();
+        context2.add("org.test.addnumbers");
+        context2.add("org.test.anytype");
+        
+        JAXBContext jaxbContext2 = JAXBUtils.getJAXBContext(context2);
+        
+        // The following assertion is probably true,but GC may have wiped out the weak reference
+        //assertTrue(jaxbContext2 == jaxbContext1);
+        assertTrue(jaxbContext2 != null);
+        assertTrue(jaxbContext2.toString().equals(jaxbContext1.toString()));
+        assertTrue(context2.contains("org.test.addnumbers"));
+        assertTrue(context2.contains("org.test.anytype"));
+        
+        // Repeat with the same packages + an invalid package
+        TreeSet<String> context3 = new TreeSet<String>();
+        context3.add("org.test.addnumbers");
+        context3.add("org.test.anytype");
+        context3.add("my.grandma.loves.jaxws");
+        
+        JAXBContext jaxbContext3 = JAXBUtils.getJAXBContext(context3);
+        
+        // The following assertion is probably true,but GC may have wiped out the weak reference
+        //assertTrue(jaxbContext3 == jaxbContext1);
+        assertTrue(jaxbContext3 != null);
+        assertTrue(jaxbContext1.toString().equals(jaxbContext1.toString()));
+        assertTrue(context3.contains("org.test.addnumbers"));
+        assertTrue(context3.contains("org.test.anytype")); 
+        // The invalid package should now be retained...this is due
+        // a minor semantic change to avoid this side effect.
+        assertTrue(context3.contains("my.grandma.loves.jaxws"));  
+        
+        // Repeat with a subset of packages
+        TreeSet<String> context4 = new TreeSet<String>();
+        context4.add("org.test.addnumbers");
+        
+        
+        JAXBContext jaxbContext4 = JAXBUtils.getJAXBContext(context4);
+        
+        assertTrue(jaxbContext4 != null);
+        assertTrue(jaxbContext4 != jaxbContext3);
+        assertTrue(context4.contains("org.test.addnumbers"));
+        
+       
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/NS2PkgTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/NS2PkgTest.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/NS2PkgTest.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/NS2PkgTest.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,58 @@
+/*
+ * 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.jaxws.misc;
+
+import org.apache.axis2.jaxws.utility.JavaUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests Namespace to Package Algorithm
+ *
+ */
+public class NS2PkgTest extends TestCase {
+
+    public void test01() throws Exception {
+        String ns1 = "http://example.org/NewBusiness/";
+        String expectedPkg1 = "org.example.newbusiness";
+        
+        String pkg = JavaUtils.getPackageFromNamespace(ns1);
+        assertTrue("Expected " + expectedPkg1 + "Received " +pkg, expectedPkg1.equals(pkg));
+    }
+    
+    public void test02() throws Exception {
+        String ns1 = "urn://example-org/NewBusiness";
+        String expectedPkg1 = "org.example";
+        
+        String pkg = JavaUtils.getPackageFromNamespace(ns1);
+        assertTrue("Expected " + expectedPkg1 + "Received " +pkg, expectedPkg1.equals(pkg));
+    }
+    
+    public void test03() throws Exception {
+        String ns1 = "";
+        String expectedPkg1 = "";
+        
+        String pkg = JavaUtils.getPackageFromNamespace(ns1);
+        assertTrue("Expected " + expectedPkg1 + "Received " +pkg, expectedPkg1.equals(pkg));
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/EchoMessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/EchoMessageImpl.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/EchoMessageImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/EchoMessageImpl.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,55 @@
+/*
+ * 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.jaxws.nonanonymous.complextype;
+
+import javax.jws.WebService;
+
+import org.apache.axis2.jaxws.nonanonymous.complextype.sei.EchoMessagePortType;
+import org.apache.axis2.jaxws.TestLogger;
+
+@WebService(serviceName="EchoMessageService",
+	 	targetNamespace="http://testApp.jaxws",
+        endpointInterface="org.apache.axis2.jaxws.nonanonymous.complextype.sei.EchoMessagePortType")
+
+public class EchoMessageImpl implements EchoMessagePortType {
+
+	/**
+	 * 
+	 */
+	public EchoMessageImpl() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.nonanonymous.complextype.sei.EchoMessagePortType#echoMessage(java.lang.String)
+	 */
+	public String echoMessage(String request) {
+		String response = null;
+        TestLogger.logger.debug("echoMessage received: " + request);
+        response = request.replaceAll("Server", "Client");
+        return response;
+
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/NonAnonymousComplexTypeTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/NonAnonymousComplexTypeTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/NonAnonymousComplexTypeTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/NonAnonymousComplexTypeTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,75 @@
+/*
+ * 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.jaxws.nonanonymous.complextype;
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.WebServiceException;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.nonanonymous.complextype.sei.EchoMessagePortType;
+import org.apache.axis2.jaxws.nonanonymous.complextype.sei.EchoMessageService;
+import org.apache.axis2.jaxws.sample.addnumbers.AddNumbersPortType;
+import org.apache.axis2.jaxws.sample.addnumbers.AddNumbersService;
+import org.apache.axis2.jaxws.TestLogger;
+
+public class NonAnonymousComplexTypeTests extends TestCase {
+
+    String axisEndpoint = "http://localhost:6060/axis2/services/EchoMessageService.EchoMessageImplPort";
+	
+	/**
+	 * 
+	 */
+	public NonAnonymousComplexTypeTests() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * @param arg0
+	 */
+	public NonAnonymousComplexTypeTests(String arg0) {
+		super(arg0);
+		// TODO Auto-generated constructor stub
+	}
+	public void testSimpleProxy() {
+        TestLogger.logger.debug("------------------------------");
+        TestLogger.logger.debug("Test : " + getName());
+		try {
+			String msg = "Hello Server";
+		    EchoMessagePortType myPort = (new EchoMessageService()).getEchoMessagePort();
+	        BindingProvider p = (BindingProvider) myPort;
+	        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+
+		    String response = myPort.echoMessage(msg);
+            TestLogger.logger.debug(response);
+            TestLogger.logger.debug("------------------------------");
+		} catch (WebServiceException webEx) {
+			webEx.printStackTrace();
+			fail();
+		}
+	}
+
+		    
+
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org