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 2011/07/25 19:37:53 UTC

svn commit: r1150800 - in /webservices/commons/trunk/modules/axiom/modules: axiom-tests/src/test/java/org/apache/axiom/om/ axiom-tests/src/test/resources/ axiom-testsuite/ axiom-testsuite/src/main/java/org/apache/axiom/ts/ axiom-testsuite/src/main/java...

Author: veithen
Date: Mon Jul 25 17:37:52 2011
New Revision: 1150800

URL: http://svn.apache.org/viewvc?rev=1150800&view=rev
Log:
AXIOM-311: Refactored the test case for AXIOM-299, taking into account the new API defined by AXIOM-353.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestStandaloneConfiguration.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/web_w_dtd2.xml
      - copied unchanged from r1149334, webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/resources/web_w_dtd2.xml
Removed:
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/resources/web_w_dtd2.xml
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMDTDTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/pom.xml
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMDTDTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMDTDTest.java?rev=1150800&r1=1150799&r2=1150800&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMDTDTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMDTDTest.java Mon Jul 25 17:37:52 2011
@@ -19,14 +19,9 @@
 
 package org.apache.axiom.om;
 
-import org.apache.axiom.om.util.StAXUtils;
-
 import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 
 import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.util.Iterator;
 
 public class OMDTDTest extends AbstractTestCase {
 
@@ -60,45 +55,4 @@ public class OMDTDTest extends AbstractT
             fail("Bug in serializing OMDocuments which have DTDs, text and a document element");
         }
     }
-    
-    public void testDTDInWebXML() throws Exception{
-        
-        // The JSR 173 (StAX) Specification did not do a very good job
-        // of defining how DOCTYPE entities are processed.  According
-        // to the reference implementation, the external entities of the DOCTYPE
-        // are always followed.  This is wrong for a number of reasons.
-        //   a) You cannot read the file unless you are network attached ...which
-        //      might not be the case.
-        //   b) You incur an expensive network access even though in many cases
-        //      the DOCTYPE contents are unimportant.
-        //  
-        // StAX should have allowed the caller to process the DOCTYPE as information
-        // only and allow the caller to request external information.  Perhaps this
-        // will be addressed in future versions of the specification.
-        //
-        // For now, we have a work-around.  A "network detached" XMLStreamReader
-        // can be obtained from StAXUtils and used to process configuration files
-        // (like a web.xml) that may contain DTD information.
-        //
-        // The following test reads an XML file that has a DTD with a system ID
-        // that intentionally points to a non existing URL. With a network
-        // detached reader this should not produce errors.
-        
-        InputStream is = getTestResource("web_w_dtd2.xml");
-        XMLStreamReader reader = StAXUtils.createNetworkDetachedXMLStreamReader(is);
-        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(reader);
-        OMElement root = builder.getDocumentElement();
-        assertTrue(root.getLocalName().equals("web-app"));
-        OMDocument document = builder.getDocument();
-        Iterator i = document.getChildren();
-        OMDocType docType = null;
-        while (docType == null && i.hasNext()) {
-           Object obj = i.next();
-           if (obj instanceof OMDocType) {
-               docType = (OMDocType) obj;
-           }
-        }
-        assertTrue(docType != null);
-        root.close(false);
-    }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/pom.xml?rev=1150800&r1=1150799&r2=1150800&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/pom.xml Mon Jul 25 17:37:52 2011
@@ -78,4 +78,19 @@
             <version>2.7.1</version>
         </dependency>
     </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <!-- src/main/resources contains test files and they obviously cannot
+                             all contain a valid license header -->
+                        <exclude>src/main/resources/**</exclude>
+                    </excludes>
+                </configuration> 
+            </plugin>
+        </plugins>
+    </build>
 </project>

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java?rev=1150800&r1=1150799&r2=1150800&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java Mon Jul 25 17:37:52 2011
@@ -53,6 +53,7 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElementWithDiscardDocument(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.TestStandaloneConfiguration(metaFactory));
         for (int i=0; i<conformanceFiles.length; i++) {
             for (int j=0; j<containerFactories.length; j++) {
                 addTest(new org.apache.axiom.ts.om.container.TestGetSAXSource(metaFactory, conformanceFiles[i], containerFactories[j], true));

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestStandaloneConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestStandaloneConfiguration.java?rev=1150800&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestStandaloneConfiguration.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestStandaloneConfiguration.java Mon Jul 25 17:37:52 2011
@@ -0,0 +1,62 @@
+/*
+ * 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.InputStream;
+import java.util.Iterator;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMDocType;
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.util.StAXParserConfiguration;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests the behavior of
+ * {@link OMXMLBuilderFactory#createOMBuilder(StAXParserConfiguration, InputStream)} with
+ * {@link StAXParserConfiguration#STANDALONE}.
+ */
+public class TestStandaloneConfiguration extends AxiomTestCase {
+    public TestStandaloneConfiguration(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        InputStream is = AbstractTestCase.getTestResource("web_w_dtd2.xml");
+        OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
+                StAXParserConfiguration.STANDALONE, is);
+        OMElement root = builder.getDocumentElement();
+        assertTrue(root.getLocalName().equals("web-app"));
+        OMDocument document = builder.getDocument();
+        Iterator i = document.getChildren();
+        OMDocType docType = null;
+        while (docType == null && i.hasNext()) {
+           Object obj = i.next();
+           if (obj instanceof OMDocType) {
+               docType = (OMDocType) obj;
+           }
+        }
+        assertTrue(docType != null);
+        root.close(false);
+    }
+}

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