You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ch...@apache.org on 2006/08/21 08:47:13 UTC

svn commit: r433177 - /webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java

Author: chinthaka
Date: Sun Aug 20 23:47:12 2006
New Revision: 433177

URL: http://svn.apache.org/viewvc?rev=433177&view=rev
Log:
Removing more System.out by actually testing what needs to be tested. - Take 2

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java?rev=433177&r1=433176&r2=433177&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/serializer/OMSerializerTest.java Sun Aug 20 23:47:12 2006
@@ -24,11 +24,8 @@
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPEnvelope;
 
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.*;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileReader;
 
@@ -51,17 +48,24 @@
 //        writer =
 //                XMLOutputFactory.newInstance().
 //                        createXMLStreamWriter(new FileOutputStream(tempFile));
-        writer =
-                XMLOutputFactory.newInstance().
-                        createXMLStreamWriter(System.out);
+
+
+
+
     }
 
     public void testRawSerializer() throws Exception {
         StreamingOMSerializer serializer = new StreamingOMSerializer();
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        writer =
+                XMLOutputFactory.newInstance().
+                        createXMLStreamWriter(byteArrayOutputStream);
         //serializer.setNamespacePrefixStack(new Stack());
         serializer.serialize(reader, writer);
         writer.flush();
 
+        String outputString = new String(byteArrayOutputStream.toByteArray());
+        assertTrue(outputString != null && !"".equals(outputString) && outputString.length() > 1);
 
     }
 
@@ -71,19 +75,34 @@
                 reader);
         SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
         StreamingOMSerializer serializer = new StreamingOMSerializer();
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        writer =
+                XMLOutputFactory.newInstance().
+                        createXMLStreamWriter(byteArrayOutputStream);
+
         serializer.serialize(env.getXMLStreamReaderWithoutCaching(), writer);
         writer.flush();
+
+        String outputString = new String(byteArrayOutputStream.toByteArray());
+        assertTrue(outputString != null && !"".equals(outputString) && outputString.length() > 1);
     }
 
     public void testElementPullStream1WithCacheOff() throws Exception {
         OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
                 OMAbstractFactory.getSOAP11Factory(),
                 reader);
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        writer =
+                XMLOutputFactory.newInstance().
+                        createXMLStreamWriter(byteArrayOutputStream);
 
         SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
         env.serializeAndConsume(writer);
         writer.flush();
 
+        String outputString = new String(byteArrayOutputStream.toByteArray());
+        assertTrue(outputString != null && !"".equals(outputString) && outputString.length() > 1);
+
         //now we should not be able to serilaize anything ! this should throw
         //an error
         try {
@@ -100,12 +119,20 @@
         OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
                 OMAbstractFactory.getSOAP11Factory(),
                 reader);
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        writer =
+                XMLOutputFactory.newInstance().
+                        createXMLStreamWriter(byteArrayOutputStream);
+
         SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
         SOAPBody body = env.getBody();
         StreamingOMSerializer serializer = new StreamingOMSerializer();
         serializer.serialize(body.getXMLStreamReaderWithoutCaching(),
                 writer);
         writer.flush();
+
+        String outputString = new String(byteArrayOutputStream.toByteArray());
+        assertTrue(outputString != null && !"".equals(outputString) && outputString.length() > 1);
     }
 
     protected void tearDown() throws Exception {



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