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/07/19 23:46:41 UTC
svn commit: r1611972 - in /webservices/axiom/trunk:
implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/
testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/d...
Author: veithen
Date: Sat Jul 19 21:46:41 2014
New Revision: 1611972
URL: http://svn.apache.org/r1611972
Log:
Fixed some DOOM issues.
Added:
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestAppendChildForbidden.java (with props)
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestInsertBeforeForbidden.java (with props)
Modified:
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1611972&r1=1611971&r2=1611972&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java Sat Jul 19 21:46:41 2014
@@ -398,16 +398,12 @@ public class DocumentImpl extends RootNo
}
public OMElement getOMDocumentElement() {
- return getOMDocumentElement(true);
- }
-
- OMElement getOMDocumentElement(boolean build) {
- OMNode child = build ? getFirstOMChild() : getFirstOMChildIfAvailable();
+ OMNode child = getFirstOMChild();
while (child != null) {
if (child instanceof OMElement) {
return (OMElement)child;
}
- child = build ? child.getNextOMSibling() : ((OMNodeEx)child).getNextOMSiblingIfAvailable();
+ child = child.getNextOMSibling();
}
return null;
}
Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?rev=1611972&r1=1611971&r2=1611972&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java (original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java Sat Jul 19 21:46:41 2014
@@ -108,7 +108,7 @@ public abstract class ParentNode extends
if (this instanceof Document) {
if (newDomChild instanceof ElementImpl) {
- if (((DocumentImpl) this).getOMDocumentElement(false) != null) {
+ if (((DocumentImpl) this).getOMDocumentElement() != null) {
// Throw exception since there cannot be two document elements
throw newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java?rev=1611972&r1=1611971&r2=1611972&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java Sat Jul 19 21:46:41 2014
@@ -36,9 +36,13 @@ public class OMDOMTestSuiteBuilder exten
protected void addTests() {
addTest(new org.apache.axiom.ts.omdom.attr.TestGetNamespaceNormalized(metaFactory));
+ addTest(new org.apache.axiom.ts.omdom.document.TestAppendChildForbidden(metaFactory, true));
+ addTest(new org.apache.axiom.ts.omdom.document.TestAppendChildForbidden(metaFactory, false));
addTest(new org.apache.axiom.ts.omdom.document.TestGetOMFactory1(metaFactory));
addTest(new org.apache.axiom.ts.omdom.document.TestGetOMFactory2(metaFactory));
addTest(new org.apache.axiom.ts.omdom.document.TestImportNode(metaFactory));
+ addTest(new org.apache.axiom.ts.omdom.document.TestInsertBeforeForbidden(metaFactory, true));
+ addTest(new org.apache.axiom.ts.omdom.document.TestInsertBeforeForbidden(metaFactory, false));
addTest(new org.apache.axiom.ts.omdom.element.TestAddAttributeReplace(metaFactory));
addTest(new org.apache.axiom.ts.omdom.element.TestAddChildFromForeignDocument(metaFactory));
addTest(new org.apache.axiom.ts.omdom.element.TestAppendChildIncomplete(metaFactory));
Added: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestAppendChildForbidden.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestAppendChildForbidden.java?rev=1611972&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestAppendChildForbidden.java (added)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestAppendChildForbidden.java Sat Jul 19 21:46:41 2014
@@ -0,0 +1,58 @@
+/*
+ * 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.omdom.document;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+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;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+
+public class TestAppendChildForbidden extends AxiomTestCase {
+ private final boolean build;
+
+ public TestAppendChildForbidden(OMMetaFactory metaFactory, boolean build) {
+ super(metaFactory);
+ this.build = build;
+ addTestParameter("build", build);
+ }
+
+ @Override
+ protected void runTest() throws Throwable {
+ OMDocument omDocument = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
+ new StringReader("<test/>")).getDocument();
+ if (build) {
+ omDocument.build();
+ }
+ Document document = (Document)omDocument;
+ try {
+ document.appendChild(document.createElementNS(null, "test"));
+ fail("Expected DOMException");
+ } catch (DOMException ex) {
+ assertThat(ex.code, is(equalTo(DOMException.HIERARCHY_REQUEST_ERR)));
+ }
+ }
+}
Propchange: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestAppendChildForbidden.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestInsertBeforeForbidden.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestInsertBeforeForbidden.java?rev=1611972&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestInsertBeforeForbidden.java (added)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestInsertBeforeForbidden.java Sat Jul 19 21:46:41 2014
@@ -0,0 +1,60 @@
+/*
+ * 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.omdom.document;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+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;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+
+public class TestInsertBeforeForbidden extends AxiomTestCase {
+ private final boolean build;
+
+ public TestInsertBeforeForbidden(OMMetaFactory metaFactory, boolean build) {
+ super(metaFactory);
+ this.build = build;
+ addTestParameter("build", build);
+ }
+
+ @Override
+ protected void runTest() throws Throwable {
+ OMDocument omDocument = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
+ new StringReader("<!--test--><test/>")).getDocument();
+ if (build) {
+ omDocument.build();
+ }
+ Document document = (Document)omDocument;
+ Comment comment = (Comment)document.getFirstChild();
+ try {
+ document.insertBefore(document.createElementNS(null, "test"), comment);
+ fail("Expected DOMException");
+ } catch (DOMException ex) {
+ assertThat(ex.code, is(equalTo(DOMException.HIERARCHY_REQUEST_ERR)));
+ }
+ }
+}
Propchange: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestInsertBeforeForbidden.java
------------------------------------------------------------------------------
svn:eol-style = native