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/09/26 23:33:31 UTC
svn commit: r1176073 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/om/
axiom-testsuite/src/main/java/org/apache/axiom/ts/
axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/
Author: veithen
Date: Mon Sep 26 21:33:31 2011
New Revision: 1176073
URL: http://svn.apache.org/viewvc?rev=1176073&view=rev
Log:
Clarified the documentation of OMXMLParserWrapper#getDocumentElement() and added a test case.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithIllFormedDocument.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java
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-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java?rev=1176073&r1=1176072&r2=1176073&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLParserWrapper.java Mon Sep 26 21:33:31 2011
@@ -77,8 +77,15 @@ public interface OMXMLParserWrapper {
* Get the document element, i.e. the root element of the document. Using this method is
* equivalent to using {@link OMDocument#getOMDocumentElement()} on the document returned by
* {@link #getDocument()}.
+ * <p>
+ * Note that this method will never return <code>null</code> (except in the very special case
+ * where the document has been requested before and the document element has been removed
+ * explicitly): if the document being parsed has no document element, then this will result in a
+ * parser error, i.e. an {@link OMException} will be thrown.
*
* @return the document element
+ * @throws OMException
+ * if a parse error occurs
*/
OMElement getDocumentElement();
@@ -95,6 +102,8 @@ public interface OMXMLParserWrapper {
* @param discardDocument
* specifies whether the document should be discarded
* @return the document element
+ * @throws OMException
+ * if a parse error occurs
*/
OMElement getDocumentElement(boolean discardDocument);
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=1176073&r1=1176072&r2=1176073&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 Sep 26 21:33:31 2011
@@ -63,6 +63,7 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.builder.TestCreateStAXOMBuilderNamespaceRepairing(metaFactory));
addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElement(metaFactory));
addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElementWithDiscardDocument(metaFactory));
+ 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.TestStandaloneConfiguration(metaFactory));
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithIllFormedDocument.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithIllFormedDocument.java?rev=1176073&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithIllFormedDocument.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithIllFormedDocument.java Mon Sep 26 21:33:31 2011
@@ -0,0 +1,48 @@
+/*
+ * 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.StringReader;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMXMLParserWrapper#getDocumentElement()} throws an exception (instead of
+ * returning <code>null</code>) if the input document has no document element.
+ */
+public class TestGetDocumentElementWithIllFormedDocument extends AxiomTestCase {
+ public TestGetDocumentElementWithIllFormedDocument(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
+ new StringReader("<!--comment1-->"));
+ try {
+ builder.getDocumentElement();
+ fail("Expected OMException");
+ } catch (OMException ex) {
+ // Expected
+ }
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestGetDocumentElementWithIllFormedDocument.java
------------------------------------------------------------------------------
svn:eol-style = native