axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chinth...@apache.org
Subject svn commit: r240057 - in /webservices/axis/trunk/java/modules/xml: src/org/apache/axis2/om/impl/llom/ test/org/apache/axis2/om/ test/org/apache/axis2/soap/impl/llom/
Date Thu, 25 Aug 2005 12:25:30 GMT
Author: chinthaka
Date: Thu Aug 25 05:24:43 2005
New Revision: 240057

URL: http://svn.apache.org/viewcvs?rev=240057&view=rev
Log:
- correcting OMDocument, PI serialization problem
- adding test cases for that
- moving SOAP specific tests to soap package
-

Added:
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMDocumentTest.java
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMElementTest.java
      - copied, changed from r240017, webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMElementTest.java
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMEnvelopeTest.java
      - copied, changed from r240017, webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMEnvelopeTest.java
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMHeaderBlockTest.java
      - copied, changed from r240017, webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMHeaderBlockTest.java
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMHeaderTest.java
      - copied, changed from r240017, webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMHeaderTest.java
Removed:
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMElementTest.java
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMEnvelopeTest.java
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMHeaderBlockTest.java
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMHeaderTest.java
Modified:
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMProcessingInstructionImpl.java

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java?rev=240057&r1=240056&r2=240057&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java
Thu Aug 25 05:24:43 2005
@@ -58,21 +58,20 @@
      * Dafult : UTF-8
      */
     protected String charSetEncoding = "UTF-8";
-    
+
     /**
      * Field xmlVersion
      */
     protected String xmlVersion = "1.0";
-    
 
-    
+
     /**
      * Default constructor
      */
     public OMDocumentImpl() {
-    	
+      this.done = true;
     }
-    
+
     /**
      * @param rootElement
      * @param parserWrapper
@@ -234,86 +233,99 @@
     public void setFirstChild(OMNode firstChild) {
         this.firstChild = firstChild;
     }
-    
-    
+
+
     /**
      * Returns the character set encoding scheme to be used
+     *
      * @return
      */
-	public String getCharsetEncoding() {
-		return charSetEncoding;
-	}
-	
-	/**
-	 * Set the character set encoding scheme
-	 * @param charSetEncoding
-	 */
-	public void setCharsetEncoding(String charEncoding) {
-		this.charSetEncoding = charEncoding;
-	}
-	
-	public String getXMLVersion() {
-		return xmlVersion;
-	}
-	public void setXMLVersion(String xmlVersion) {
-		this.xmlVersion = xmlVersion;
-	}
-	
-	/**
-	 * Serialize the docuement with/without the XML declaration
-	 */
-	public void serialize(OMOutputImpl omOutput, boolean includeXMLDeclaration) throws XMLStreamException
{
-		serialize(omOutput,false,includeXMLDeclaration);
-	}
-
-	/**
-	 * Serialize the document with the XML declaration
-	 * 
-	 * @see org.apache.axis2.om.OMDocument#serialize(org.apache.axis2.om.impl.OMOutputImpl,
-	 *      boolean)
-	 */
-	public void serialize(OMOutputImpl omOutput)
-			throws XMLStreamException {
-		serialize(omOutput, false, true);
-	}
-	
-
-	/**
-	 * Serialize the document with cache
-	 * @see org.apache.axis2.om.OMDocument#serializeWithCache(org.apache.axis2.om.impl.OMOutputImpl)
-	 */
-	public void serializeWithCache(OMOutputImpl omOutput) throws XMLStreamException {
-		serialize(omOutput, true, true);
-		
-	}
-
-	/**
-	 * Serialize the document with cache
-	 * @see org.apache.axis2.om.OMDocument#serializeWithCache(org.apache.axis2.om.impl.OMOutputImpl,
boolean)
-	 */
-	public void serializeWithCache(OMOutputImpl omOutput, boolean includeXMLDeclaration) throws
XMLStreamException {
-		serialize(omOutput,true,includeXMLDeclaration);
-		
-	}
-	
-	protected void serialize(OMOutputImpl omOutput, boolean cache, boolean includeXMLDeclaration)
throws XMLStreamException {
-		if (includeXMLDeclaration) {
-			//Check whether the OMOutput char encoding and OMDocument char
-			//encoding matches, if not use char encoding of OMOutput
-			String outputCharEncoding = omOutput.getCharSetEncoding();
-			if(!outputCharEncoding.equalsIgnoreCase(this.charSetEncoding)) {
-				this.charSetEncoding = outputCharEncoding;
-			}
-			omOutput.getXmlStreamWriter().writeStartDocument(charSetEncoding,
-					xmlVersion);
-		}
-
-		if (cache) {
-			this.rootElement.serializeWithCache(omOutput);
-		} else {
-			this.rootElement.serialize(omOutput);
-		}
-	}
+    public String getCharsetEncoding() {
+        return charSetEncoding;
+    }
+
+    /**
+     * Set the character set encoding scheme
+     *
+     * @param charSetEncoding
+     */
+    public void setCharsetEncoding(String charEncoding) {
+        this.charSetEncoding = charEncoding;
+    }
+
+    public String getXMLVersion() {
+        return xmlVersion;
+    }
+
+    public void setXMLVersion(String xmlVersion) {
+        this.xmlVersion = xmlVersion;
+    }
+
+    /**
+     * Serialize the docuement with/without the XML declaration
+     */
+    public void serialize(OMOutputImpl omOutput, boolean includeXMLDeclaration) throws XMLStreamException
{
+        serialize(omOutput, false, includeXMLDeclaration);
+    }
+
+    /**
+     * Serialize the document with the XML declaration
+     *
+     * @see org.apache.axis2.om.OMDocument#serialize(org.apache.axis2.om.impl.OMOutputImpl,
+     *      boolean)
+     */
+    public void serialize(OMOutputImpl omOutput)
+            throws XMLStreamException {
+        serialize(omOutput, false, true);
+    }
+
+
+    /**
+     * Serialize the document with cache
+     *
+     * @see org.apache.axis2.om.OMDocument#serializeWithCache(org.apache.axis2.om.impl.OMOutputImpl)
+     */
+    public void serializeWithCache(OMOutputImpl omOutput) throws XMLStreamException {
+        serialize(omOutput, true, true);
+
+    }
+
+    /**
+     * Serialize the document with cache
+     *
+     * @see org.apache.axis2.om.OMDocument#serializeWithCache(org.apache.axis2.om.impl.OMOutputImpl,
boolean)
+     */
+    public void serializeWithCache(OMOutputImpl omOutput, boolean includeXMLDeclaration)
throws XMLStreamException {
+        serialize(omOutput, true, includeXMLDeclaration);
+
+    }
+
+    protected void serialize(OMOutputImpl omOutput, boolean cache, boolean includeXMLDeclaration)
throws XMLStreamException {
+        if (includeXMLDeclaration) {
+            //Check whether the OMOutput char encoding and OMDocument char
+            //encoding matches, if not use char encoding of OMOutput
+            String outputCharEncoding = omOutput.getCharSetEncoding();
+            if (!outputCharEncoding.equalsIgnoreCase(this.charSetEncoding)) {
+                this.charSetEncoding = outputCharEncoding;
+            }
+            omOutput.getXmlStreamWriter().writeStartDocument(charSetEncoding,
+                    xmlVersion);
+        }
+
+        Iterator children = this.getChildren();
+
+        if (cache) {
+            while (children.hasNext()) {
+                OMNode omNode = (OMNode) children.next();
+                omNode.serializeWithCache(omOutput);
+            }
+        } else {
+            while (children.hasNext()) {
+                OMNode omNode = (OMNode) children.next();
+                omNode.serialize(omOutput);
+            }
+        }
+    }
+
 
-	
 }

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMProcessingInstructionImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMProcessingInstructionImpl.java?rev=240057&r1=240056&r2=240057&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMProcessingInstructionImpl.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMProcessingInstructionImpl.java
Thu Aug 25 05:24:43 2005
@@ -57,10 +57,6 @@
     public void serializeWithCache(org.apache.axis2.om.impl.OMOutputImpl omOutput) throws
XMLStreamException {
         XMLStreamWriter writer = omOutput.getXmlStreamWriter();
         writer.writeProcessingInstruction(this.target+" ", this.value);
-        OMNode nextSibling = this.getNextSibling();
-        if (nextSibling != null) {
-            nextSibling.serializeWithCache(omOutput);
-        }
     }
 
     /**

Added: webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMDocumentTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMDocumentTest.java?rev=240057&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMDocumentTest.java (added)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMDocumentTest.java Thu
Aug 25 05:24:43 2005
@@ -0,0 +1,87 @@
+package org.apache.axis2.om;
+
+import junit.framework.TestCase;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class OMDocumentTest extends TestCase {
+    private String sampleXML = "<?xml version='1.0' encoding='utf-8'?>\n" +
+            "<!--This is some comments at the start of the document-->\n" +
+            "<?PITarget PIData?>\n" +
+            "<Axis2>\n" +
+            "    <ProjectName>The Apache Web Sevices Project</ProjectName>\n"
+
+            "</Axis2>";
+
+     public void testOMDocument() throws XMLStreamException {
+         // read the string in to the builder
+         OMDocument omDocument = getSampleOMDocument(sampleXML);
+
+         // serialise it to a string
+         String outXML = "";
+         ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+         OMOutputImpl output = new OMOutputImpl(outStream, false);
+         omDocument.serialize(output);
+         output.flush();
+         outXML = new String(outStream.toByteArray());
+         System.out.println("outXML = " + outXML);
+
+         // again load that to another builder
+         OMDocument secondDocument = getSampleOMDocument(outXML);
+
+         // compare the intial one with the later one
+         assertTrue(secondDocument.getFirstChild() instanceof OMComment);
+         assertTrue(secondDocument.getFirstChild().getNextSibling() instanceof OMProcessingInstruction);
+
+
+     }
+
+    private OMDocument getSampleOMDocument(String xml) {
+        try {
+            XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(new
StringReader(xml));
+            StAXOMBuilder builder = new StAXOMBuilder(xmlStreamReader);
+            return builder.getDocument();
+        } catch (XMLStreamException e) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+//    private OMDocument getSampleOMDocument() {
+//        OMFactory omFactory = OMAbstractFactory.getOMFactory();
+//        OMDocument omDocument = omFactory.createOMDocument();
+//        omFactory.createOMComment(omDocument, "This is some comments at the start of the
document");
+//        omDocument.setCharsetEncoding("utf-8");
+//        omFactory.createOMProcessingInstruction(omDocument, "PITarget", "PIData");
+//
+//        OMElement documentElement = omFactory.createOMElement("Axis2", null, omDocument);
+//        omDocument.setDocumentElement(documentElement);
+//        omFactory.createOMElement("ProjectName", null, documentElement);
+//        documentElement.getFirstElement().setText("The Apache Web Sevices Project");
+//
+//        return omDocument;
+//    }
+
+}

Copied: webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMElementTest.java
(from r240017, webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMElementTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMElementTest.java?p2=webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMElementTest.java&p1=webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMElementTest.java&r1=240017&r2=240057&rev=240057&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMElementTest.java (original)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMElementTest.java
Thu Aug 25 05:24:43 2005
@@ -1,5 +1,6 @@
-package org.apache.axis2.om;
+package org.apache.axis2.soap.impl.llom;
 
+import org.apache.axis2.om.*;
 import org.apache.axis2.soap.SOAPEnvelope;
 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
 import org.apache.commons.logging.Log;

Copied: webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMEnvelopeTest.java
(from r240017, webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMEnvelopeTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMEnvelopeTest.java?p2=webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMEnvelopeTest.java&p1=webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMEnvelopeTest.java&r1=240017&r2=240057&rev=240057&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMEnvelopeTest.java (original)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMEnvelopeTest.java
Thu Aug 25 05:24:43 2005
@@ -13,12 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.axis2.om;
+package org.apache.axis2.soap.impl.llom;
 
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMTestCase;
+import org.apache.axis2.om.OMTestUtils;
 import org.apache.axis2.soap.SOAPBody;
 import org.apache.axis2.soap.SOAPEnvelope;
 import org.apache.axis2.soap.SOAPHeader;
-import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 

Copied: webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMHeaderBlockTest.java
(from r240017, webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMHeaderBlockTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMHeaderBlockTest.java?p2=webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMHeaderBlockTest.java&p1=webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMHeaderBlockTest.java&r1=240017&r2=240057&rev=240057&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMHeaderBlockTest.java
(original)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMHeaderBlockTest.java
Thu Aug 25 05:24:43 2005
@@ -13,8 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.axis2.om;
+package org.apache.axis2.soap.impl.llom;
 
+import org.apache.axis2.om.OMTestCase;
 import org.apache.axis2.soap.SOAPHeader;
 import org.apache.axis2.soap.SOAPHeaderBlock;
 

Copied: webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMHeaderTest.java
(from r240017, webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMHeaderTest.java)
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMHeaderTest.java?p2=webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMHeaderTest.java&p1=webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMHeaderTest.java&r1=240017&r2=240057&rev=240057&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMHeaderTest.java (original)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMHeaderTest.java
Thu Aug 25 05:24:43 2005
@@ -13,8 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.axis2.om;
+package org.apache.axis2.soap.impl.llom;
 
+import org.apache.axis2.om.OMTestCase;
 import org.apache.axis2.om.impl.llom.OMNamespaceImpl;
 import org.apache.axis2.soap.SOAPHeader;
 import org.apache.axis2.soap.SOAPHeaderBlock;



Mime
View raw message