You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2014/06/23 18:24:03 UTC

svn commit: r1604857 - in /webservices/axiom/trunk/modules: axiom-api/src/test/java/org/apache/axiom/om/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/ axiom-testsuite/src/main/java/o...

Author: veithen
Date: Mon Jun 23 16:24:02 2014
New Revision: 1604857

URL: http://svn.apache.org/r1604857
Log:
AXIOM-311: Refactored some OMDocument tests.

Added:
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestMalformedDocument.java   (with props)
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestBuild.java   (with props)
Modified:
    webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java

Modified: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java?rev=1604857&r1=1604856&r2=1604857&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java Mon Jun 23 16:24:02 2014
@@ -19,8 +19,6 @@
 
 package org.apache.axiom.om;
 
-import org.apache.commons.io.input.CountingInputStream;
-
 import javax.xml.stream.XMLStreamException;
 import java.io.ByteArrayOutputStream;
 import java.io.StringReader;
@@ -83,20 +81,6 @@ public class OMDocumentTestBase extends 
         assertTrue(commentFound && piFound);
     }
 
-    /**
-     * Test that a document that is not well formed triggers an appropriate error.
-     */
-    public void testMalformedDocument() {
-        OMDocument document = getSampleOMDocument("<Root><Child attr='a' attr='a'/></Root>");
-        try {
-            document.serialize(new ByteArrayOutputStream());
-            fail("Expected exception");
-        } catch (Exception ex) {
-            // We expect an exception here
-        }
-        document.close(false);
-    }
-
     private OMDocument getSampleOMDocument(String xml) {
         return OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(), new StringReader(xml)).getDocument();
     }
@@ -115,21 +99,4 @@ public class OMDocumentTestBase extends 
 //
 //        return omDocument;
 //    }
-
-    public void testBuild() throws Exception {
-        CountingInputStream in = new CountingInputStream(getTestResource(
-                TestConstants.REALLY_BIG_MESSAGE));
-        OMDocument doc = OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(), in).getDocument();
-        assertFalse(doc.isComplete());
-        int countBeforeBuild = in.getCount();
-        doc.build();
-        assertTrue(doc.isComplete());
-        int countAfterBuild = in.getCount();
-        assertTrue(countAfterBuild > countBeforeBuild);
-        OMNode node = doc.getFirstOMChild();
-        while (node != null) {
-            node = node.getNextOMSibling();
-        }
-        assertEquals(countAfterBuild, in.getCount());
-    }
 }

Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1604857&r1=1604856&r2=1604857&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Mon Jun 23 16:24:02 2014
@@ -136,6 +136,7 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElementWithIllFormedDocument(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestInvalidXML(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestIOExceptionInGetText(metaFactory));
+        addTest(new org.apache.axiom.ts.om.builder.TestMalformedDocument(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestNextBeforeGetDocumentElement(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestReadAttachmentBeforeRootPartComplete(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestRootPartStreaming(metaFactory));
@@ -163,6 +164,7 @@ public class OMTestSuiteBuilder extends 
         }
         addTest(new org.apache.axiom.ts.om.document.TestAddChildIncomplete(metaFactory));
         addTest(new org.apache.axiom.ts.om.document.TestAddChildWithExistingDocumentElement(metaFactory));
+        addTest(new org.apache.axiom.ts.om.document.TestBuild(metaFactory));
         for (int i=0; i<conformanceFiles.length; i++) {
             addTest(new org.apache.axiom.ts.om.document.TestClone(metaFactory, conformanceFiles[i]));
         }

Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestMalformedDocument.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestMalformedDocument.java?rev=1604857&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestMalformedDocument.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestMalformedDocument.java Mon Jun 23 16:24:02 2014
@@ -0,0 +1,49 @@
+/*
+ * 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.axiom.ts.om.builder;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Test that a document that is not well formed triggers an appropriate error.
+ */
+public class TestMalformedDocument extends AxiomTestCase {
+    public TestMalformedDocument(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    @Override
+    protected void runTest() throws Throwable {
+        OMDocument document = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
+                new StringReader("<Root><Child attr='a' attr='a'/></Root>")).getDocument();
+        try {
+            document.serialize(new ByteArrayOutputStream());
+            fail("Expected exception");
+        } catch (Exception ex) {
+            // We expect an exception here
+        }
+        document.close(false);
+    }
+}

Propchange: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestMalformedDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestBuild.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestBuild.java?rev=1604857&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestBuild.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestBuild.java Mon Jun 23 16:24:02 2014
@@ -0,0 +1,52 @@
+/*
+ * 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.axiom.ts.om.document;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.apache.commons.io.input.CountingInputStream;
+
+public class TestBuild extends AxiomTestCase {
+    public TestBuild(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    @Override
+    protected void runTest() throws Throwable {
+        CountingInputStream in = new CountingInputStream(AbstractTestCase.getTestResource(
+                TestConstants.REALLY_BIG_MESSAGE));
+        OMDocument doc = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), in).getDocument();
+        assertFalse(doc.isComplete());
+        int countBeforeBuild = in.getCount();
+        doc.build();
+        assertTrue(doc.isComplete());
+        int countAfterBuild = in.getCount();
+        assertTrue(countAfterBuild > countBeforeBuild);
+        OMNode node = doc.getFirstOMChild();
+        while (node != null) {
+            node = node.getNextOMSibling();
+        }
+        assertEquals(countAfterBuild, in.getCount());
+    }
+}

Propchange: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestBuild.java
------------------------------------------------------------------------------
    svn:eol-style = native