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 sc...@apache.org on 2006/07/21 23:15:30 UTC
svn commit: r424457 - in /webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java
test/org/apache/axis2/jaxws/DOMSourceDispatch.java
test/org/apache/axis2/jaxws/message/BlockTests.java
Author: scheu
Date: Fri Jul 21 14:15:30 2006
New Revision: 424457
URL: http://svn.apache.org/viewvc?rev=424457&view=rev
Log:
AXIS2-912
More unit tests and corrected DOMSource processing
Contributors: Nick Gallardo & Rich Scheuerle
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DOMSourceDispatch.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java?rev=424457&r1=424456&r2=424457&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java Fri Jul 21 14:15:30 2006
@@ -134,6 +134,18 @@
@Override
protected XMLStreamReader _getReaderFromBO(Object busObj, Object busContext) throws XMLStreamException {
// TODO not sure if this is always the most performant way to do this.
+ if (busObj instanceof DOMSource) {
+ // Let's use our own DOMReader for now...
+ Element element = (Element) ((DOMSource)busObj).getNode();
+
+ // We had some problems with testers producing DOMSources w/o Namespaces.
+ // It's easy to catch this here.
+ if (element.getLocalName() == null) {
+ // TODO NLS
+ throw new XMLStreamException(ExceptionFactory.makeMessageException("The DOMSource must be Namespace Aware"));
+ }
+ return new DOMReader((Element) ((DOMSource)busObj).getNode());
+ }
return inputFactory.createXMLStreamReader((Source) busObj);
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DOMSourceDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DOMSourceDispatch.java?rev=424457&r1=424456&r2=424457&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DOMSourceDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DOMSourceDispatch.java Fri Jul 21 14:15:30 2006
@@ -62,6 +62,7 @@
Map<String, Object> requestContext = dispatch.getRequestContext();
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
+ domFactory.setNamespaceAware(true);
Document domTree = domBuilder.parse(stream);
DOMSource srcStream = new DOMSource(domTree);
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java?rev=424457&r1=424456&r2=424457&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java Fri Jul 21 14:15:30 2006
@@ -16,17 +16,23 @@
*/
package org.apache.axis2.jaxws.message;
+import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.io.StringWriter;
+import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBIntrospector;
import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import org.apache.axiom.om.OMElement;
@@ -37,6 +43,9 @@
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.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
import test.EchoString;
import test.ObjectFactory;
@@ -887,4 +896,90 @@
assertTrue(sampleText.equals(newText));
}
+
+ /**
+ * Create a Block representing a DOMSource instance and simulate an
+ * outbound flow
+ * @throws Exception
+ */
+ public void testDOMSourceOutflow() throws Exception {
+ // Get the BlockFactory
+ SourceBlockFactory f = (SourceBlockFactory)
+ FactoryRegistry.getFactory(SourceBlockFactory.class);
+
+ // Turn the content into a stream
+ ByteArrayInputStream bais = new ByteArrayInputStream(sampleText.getBytes());
+
+ // Create a DOM tree from the sample text
+ DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
+ domFactory.setNamespaceAware(true);
+ DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
+ Document domTree = domBuilder.parse(bais);
+ Node node = domTree.getDocumentElement();
+ System.out.println(node.toString());
+
+ // Create a DOMSource object from the DOM tree
+ DOMSource ds = new DOMSource(node);
+ node = ds.getNode();
+
+ // Create a Block using the sample string as the content. This simulates
+ // what occurs on the outbound JAX-WS dispatch<Source> client
+ Block block = f.createFrom(ds, null, null);
+
+ // We didn't pass in a qname, so the following should return false
+ assertTrue(!block.isQNameAvailable());
+
+ // 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.
+ XMLStreamReader reader = block.getXMLStreamReader(true);
+
+ // The block should be consumed
+ assertTrue(block.isConsumed());
+
+ // To check that the output is correct, get the String contents of the
+ // reader
+ Reader2Writer r2w = new Reader2Writer(reader);
+ String newText = r2w.getAsString();
+ assertTrue(sampleText.equals(newText));
+ }
+
+ /**
+ * Create a Block representing a SAXSource instance and simulate an
+ * outbound flow
+ * @throws Exception
+ */
+ public void testSAXSourceOutflow() throws Exception {
+ // Get the BlockFactory
+ SourceBlockFactory f = (SourceBlockFactory)
+ FactoryRegistry.getFactory(SourceBlockFactory.class);
+
+ // Create a SAXSource from the sample text
+ byte[] bytes = sampleText.getBytes();
+ ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+ InputSource input = new InputSource(stream);
+ SAXSource ss = new SAXSource(input);
+
+ // Create a Block using the sample string as the content. This simulates
+ // what occurs on the outbound JAX-WS dispatch<Source> client
+ Block block = f.createFrom(ss, null, null);
+
+ // We didn't pass in a qname, so the following should return false
+ assertTrue(!block.isQNameAvailable());
+
+ // 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.
+ XMLStreamReader reader = block.getXMLStreamReader(true);
+
+ // The block should be consumed
+ assertTrue(block.isConsumed());
+
+ // To check that the output is correct, get the String contents of the
+ // reader
+ Reader2Writer r2w = new Reader2Writer(reader);
+ String newText = r2w.getAsString();
+ assertTrue(sampleText.equals(newText));
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org
Re: svn commit: r424457 - in
/webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java
test/org/apache/axis2/jaxws/DOMSourceDispatch.java
test/org/apache/axis2/jaxws/message/BlockTests.java
Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Fri, 2006-07-21 at 21:15 +0000, scheu@apache.org wrote:
> Author: scheu
> Date: Fri Jul 21 14:15:30 2006
> New Revision: 424457
>
> URL: http://svn.apache.org/viewvc?rev=424457&view=rev
> Log:
> AXIS2-912
> More unit tests and corrected DOMSource processing
> Contributors: Nick Gallardo & Rich Scheuerle
Folks, please have people who are doing the work submit the patches
themselves. Otherwise its impossible to evaluate the person when it
comes to being nominated for committer roles.
Thanks,
Sanjiva.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org
Re: svn commit: r424457 - in
/webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java
test/org/apache/axis2/jaxws/DOMSourceDispatch.java
test/org/apache/axis2/jaxws/message/BlockTests.java
Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Fri, 2006-07-21 at 21:15 +0000, scheu@apache.org wrote:
> Author: scheu
> Date: Fri Jul 21 14:15:30 2006
> New Revision: 424457
>
> URL: http://svn.apache.org/viewvc?rev=424457&view=rev
> Log:
> AXIS2-912
> More unit tests and corrected DOMSource processing
> Contributors: Nick Gallardo & Rich Scheuerle
Folks, please have people who are doing the work submit the patches
themselves. Otherwise its impossible to evaluate the person when it
comes to being nominated for committer roles.
Thanks,
Sanjiva.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org