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/10/01 12:49:13 UTC
svn commit: r1177956 [1/2] - in /webservices/commons/trunk/modules/axiom: ./
modules/axiom-dom-testsuite/ modules/axiom-dom-testsuite/src/
modules/axiom-dom-testsuite/src/main/
modules/axiom-dom-testsuite/src/main/java/
modules/axiom-dom-testsuite/src/...
Author: veithen
Date: Sat Oct 1 10:49:11 2011
New Revision: 1177956
URL: http://svn.apache.org/viewvc?rev=1177956&view=rev
Log:
AXIOM-311: Refactored the DOM tests so that they use the same pattern as the other reusable test suites.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/ (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestCase.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/builder/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/builder/TestWhitespaceAroundDocumentElement.java
- copied, changed from r1165002, webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestAllowedChildren.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateAttribute.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateElement.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateText.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestDocumentSiblings.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAppendChild.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes2.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes3.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes4.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagName.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameNS.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameRecursive.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithNamespaces.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithWildcard.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetNamespaceURIWithNoNamespace.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetTextContent.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveFirstChild.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveLastChild.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChild.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetTextContent.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitText.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/resources/
- copied from r1165002, webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/resources/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java (with props)
Removed:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMTestUtil.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/jaxp/
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/resources/
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/TextImplTest.java
webservices/commons/trunk/modules/axiom/pom.xml
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Oct 1 10:49:11 2011
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml Sat Oct 1 10:49:11 2011
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-parent</artifactId>
+ <version>1.2.13-SNAPSHOT</version>
+ <relativePath>../axiom-parent/pom.xml</relativePath>
+ </parent>
+ <artifactId>axiom-dom-testsuite</artifactId>
+ <name>Axiom DOM Test Suite</name>
+ <description>
+ DOM test suite. This test suite can be applied to any DOM implementation. It is validated against Apache Xerces.
+ </description>
+ <!-- This needs to be set explicitly because the project structure implies that the Maven calculated defaults are wrong -->
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite</developerConnection>
+ <url>http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite</url>
+ </scm>
+ <!-- This also needs to be set explicitly because the Maven calculated URL would point to nowhere -->
+ <url>http://ws.apache.org/axiom/</url>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axiom-testutils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axiom-api</artifactId>
+ <classifier>tests</classifier>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <!-- TODO: only used to get a test file; eliminate this -->
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axiom-jaxen-testsuite</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.9.1</version>
+ <scope>test</scope>
+ </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>
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestCase.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestCase.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,31 @@
+/*
+ * 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.dom;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.testutils.suite.TestCaseEx;
+
+public abstract class DOMTestCase extends TestCaseEx {
+ protected final DocumentBuilderFactory dbf;
+
+ public DOMTestCase(DocumentBuilderFactory dbf) {
+ this.dbf = dbf;
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java Sat Oct 1 10:49:11 2011
@@ -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.dom;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.testutils.suite.TestSuiteBuilder;
+
+public class DOMTestSuiteBuilder extends TestSuiteBuilder {
+ private final DocumentBuilderFactory dbf;
+
+ public DOMTestSuiteBuilder(DocumentBuilderFactory dbf) {
+ this.dbf = dbf;
+ }
+
+ protected void addTests() {
+ addTest(new org.apache.axiom.ts.dom.builder.TestWhitespaceAroundDocumentElement(dbf));
+ addTest(new org.apache.axiom.ts.dom.document.TestAllowedChildren(dbf));
+ addTest(new org.apache.axiom.ts.dom.document.TestCreateAttribute(dbf));
+ addTest(new org.apache.axiom.ts.dom.document.TestCreateElement(dbf));
+ addTest(new org.apache.axiom.ts.dom.document.TestCreateText(dbf));
+ addTest(new org.apache.axiom.ts.dom.document.TestDocumentSiblings(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestAppendChild(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestAttributes(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestAttributes2(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestAttributes3(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestAttributes4(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestGetElementsByTagName(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestGetElementsByTagNameNS(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestGetElementsByTagNameRecursive(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestGetElementsByTagNameWithNamespaces(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestGetElementsByTagNameWithWildcard(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestGetNamespaceURIWithNoNamespace(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestGetTextContent(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestRemoveFirstChild(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestRemoveLastChild(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestRemoveSingleChild(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestReplaceChild(dbf));
+ addTest(new org.apache.axiom.ts.dom.element.TestSetTextContent(dbf));
+ addTest(new org.apache.axiom.ts.dom.text.TestSplitText(dbf));
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/builder/TestWhitespaceAroundDocumentElement.java (from r1165002, webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderTest.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/builder/TestWhitespaceAroundDocumentElement.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/builder/TestWhitespaceAroundDocumentElement.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderTest.java&r1=1165002&r2=1177956&rev=1177956&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/builder/TestWhitespaceAroundDocumentElement.java Sat Oct 1 10:49:11 2011
@@ -16,40 +16,34 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-package org.apache.axiom.om.impl.dom.jaxp;
+package org.apache.axiom.ts.dom.builder;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilderFactory;
-import junit.framework.TestCase;
-
-import org.apache.axiom.om.impl.dom.DOMTestUtil;
+import org.apache.axiom.ts.dom.DOMTestCase;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
import org.xml.sax.InputSource;
-public class DocumentBuilderTest extends TestCase {
- /**
- * Test that whitespace around the document element is discarded.
- * Indeed, DOM doesn't allow text nodes as children of a document and we
- * need to check that the builder silently discards the corresponding
- * events received from the parser.
- *
- * @throws Exception
- */
- public void testWhitespaceAroundDocumentElement() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader("<!-- --> <root/> ")));
- Node child = doc.getFirstChild();
- do {
- assertFalse(child instanceof Text);
- child = child.getNextSibling();
- } while (child != null);
- }
- });
+/**
+ * Test that whitespace around the document element is discarded. Indeed, DOM doesn't allow text
+ * nodes as children of a document and we need to check that the builder silently discards the
+ * corresponding events received from the parser.
+ */
+public class TestWhitespaceAroundDocumentElement extends DOMTestCase {
+ public TestWhitespaceAroundDocumentElement(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader("<!-- --> <root/> ")));
+ Node child = doc.getFirstChild();
+ do {
+ assertFalse(child instanceof Text);
+ child = child.getNextSibling();
+ } while (child != null);
}
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestAllowedChildren.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestAllowedChildren.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestAllowedChildren.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestAllowedChildren.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.dom.document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+
+public class TestAllowedChildren extends DOMTestCase {
+ public TestAllowedChildren(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().newDocument();
+
+ doc.appendChild(doc.createComment("some comment"));
+ doc.appendChild(doc.createProcessingInstruction("pi", "data"));
+
+ // Document Object Model (DOM) Level 3 Core Specification, section 1.1.1
+ // says that text nodes are not allowed as children of a document.
+ try {
+ doc.appendChild(doc.createTextNode(" "));
+ fail("Expected DOMException");
+ } catch (DOMException ex) {
+ assertEquals(DOMException.HIERARCHY_REQUEST_ERR, ex.code);
+ }
+
+ doc.appendChild(doc.createElement("root1"));
+
+ // Multiple document elements are not allowed
+ try {
+ doc.appendChild(doc.createElement("root2"));
+ fail("Expected DOMException");
+ } catch (DOMException ex) {
+ assertEquals(DOMException.HIERARCHY_REQUEST_ERR, ex.code);
+ }
+
+ // PIs and comments after the document element are allowed
+ doc.appendChild(doc.createProcessingInstruction("pi", "data"));
+ doc.appendChild(doc.createComment("some comment"));
+
+ // Again, text nodes are not allowed
+ try {
+ doc.appendChild(doc.createTextNode(" "));
+ fail("Expected DOMException");
+ } catch (DOMException ex) {
+ assertEquals(DOMException.HIERARCHY_REQUEST_ERR, ex.code);
+ }
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestAllowedChildren.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateAttribute.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateAttribute.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateAttribute.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateAttribute.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.dom.document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+
+public class TestCreateAttribute extends DOMTestCase {
+ public TestCreateAttribute(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ String attrName = "attrIdentifier";
+ String attrValue = "attrValue";
+ String attrNs = "http://ws.apache.org/axis2/ns";
+ String attrNsPrefix = "axis2";
+
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Attr attr = doc.createAttribute(attrName);
+
+ assertEquals("Attr name mismatch", attrName, attr.getName());
+ assertNull("Namespace value should be null", attr.getNamespaceURI());
+
+
+ attr = doc.createAttributeNS(attrNs, attrNsPrefix + ":" + attrName);
+ assertEquals("Attr name mismatch", attrName, attr.getLocalName());
+ assertNotNull("Namespace value should not be null", attr.getNamespaceURI());
+ assertEquals("NamsspaceURI mismatch", attrNs, attr.getNamespaceURI());
+ assertEquals("namespace prefix mismatch", attrNsPrefix, attr.getPrefix());
+
+ attr.setValue(attrValue);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateElement.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateElement.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateElement.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,44 @@
+/*
+ * 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.dom.document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class TestCreateElement extends DOMTestCase {
+ public TestCreateElement(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ String tagName = "LocalName";
+ String namespace = "http://ws.apache.org/axis2/ns";
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Element elem = doc.createElement(tagName);
+
+ assertEquals("Local name misnatch", tagName, elem.getNodeName());
+
+ elem = doc.createElementNS(namespace, "axis2:" + tagName);
+ assertEquals("Local name misnatch", tagName, elem.getLocalName());
+ assertEquals("Namespace misnatch", namespace, elem.getNamespaceURI());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateText.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateText.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateText.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateText.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.dom.document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Text;
+
+public class TestCreateText extends DOMTestCase {
+ public TestCreateText(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ String textValue = "temp text value";
+
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Text txt = doc.createTextNode(textValue);
+
+ assertEquals("Text value mismatch", textValue, txt.getData());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateText.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestDocumentSiblings.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestDocumentSiblings.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestDocumentSiblings.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestDocumentSiblings.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,45 @@
+/*
+ * 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.dom.document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class TestDocumentSiblings extends DOMTestCase {
+ public TestDocumentSiblings(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Element elem = doc.createElement("test");
+ doc.appendChild(elem);
+
+ Node node = doc.getNextSibling();
+ assertNull("Document's next sibling has to be null", node);
+ Node node2 = doc.getPreviousSibling();
+ assertNull("Document's previous sibling has to be null", node2);
+ Node node3 = doc.getParentNode();
+ assertNull("Document's parent has to be null", node3);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestDocumentSiblings.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAppendChild.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAppendChild.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAppendChild.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAppendChild.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,57 @@
+/*
+ * 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.dom.element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+public class TestAppendChild extends DOMTestCase {
+ public TestAppendChild(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ String elementName = "TestElem";
+ String childElemName = "TestChildElem";
+ String childTextValue = "text value of the child text node";
+
+ //Apending am Element node
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Element elem = doc.createElement(elementName);
+ Element childElem = doc.createElement(childElemName);
+
+ elem.appendChild(childElem);
+
+ Element addedChild = (Element) elem.getFirstChild();
+ assertNotNull("Child Element node missing", addedChild);
+ assertEquals("Incorre node object", childElem, addedChild);
+
+ elem = doc.createElement(elementName);
+ Text text = doc.createTextNode(childTextValue);
+ elem.appendChild(text);
+
+ Text addedTextnode = (Text) elem.getFirstChild();
+ assertNotNull("Child Text node missing", addedTextnode);
+ assertEquals("Incorrect node object", text, addedTextnode);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAppendChild.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,78 @@
+/*
+ * 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.dom.element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+
+public class TestAttributes extends DOMTestCase {
+ public TestAttributes(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().parse(AbstractTestCase.getTestResource("attributetest.xml"));
+
+ // Check whether body has attributes
+ Element bodyElement = doc.getDocumentElement();
+ assertTrue(bodyElement.hasAttributes());
+
+ Element directionResponse = (Element)bodyElement.getElementsByTagName("GetDirectionsResponse").item(0);
+ assertTrue(directionResponse.hasAttributes());
+
+ NamedNodeMap attributes = directionResponse.getAttributes();
+ Attr attr = (Attr)attributes.item(0);
+ assertEquals("xmlns", attr.getName());
+ assertEquals("http://www.example.org/webservices/", attr.getValue());
+
+ Element directionResult = (Element)bodyElement.getElementsByTagName("GetDirectionsResult").item(0);
+ assertFalse(directionResult.hasAttributes());
+
+ Element drivingDirection = (Element)directionResult.getElementsByTagName("drivingdirections").item(0);
+ assertTrue(drivingDirection.hasAttributes());
+
+ attributes = drivingDirection.getAttributes();
+ attr = (Attr)attributes.item(0);
+ assertEquals("xmlns", attr.getName());
+ assertEquals("", attr.getValue());
+
+
+ Element route = (Element)drivingDirection.getElementsByTagName("route").item(0);
+ assertTrue(route.hasAttributes());
+
+ attributes = route.getAttributes();
+ attr = (Attr)attributes.item(0);
+ assertEquals("distanceToTravel", attr.getName());
+ assertEquals("500m", attr.getValue());
+
+ attr = (Attr)attributes.item(1);
+ assertEquals("finalStep", attr.getName());
+ assertEquals("false", attr.getValue());
+
+ attr = (Attr)attributes.item(2);
+ assertEquals("id", attr.getName());
+ assertEquals("0", attr.getValue());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes2.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes2.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes2.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes2.java Sat Oct 1 10:49:11 2011
@@ -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.dom.element;
+
+import java.io.StringReader;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.xml.sax.InputSource;
+
+public class TestAttributes2 extends DOMTestCase {
+ public TestAttributes2(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(
+ "<root><child xmlns=\"\"/></root>")));
+ Element element = (Element)doc.getDocumentElement().getFirstChild();
+ assertTrue(element.hasAttributes());
+ NamedNodeMap attributes = element.getAttributes();
+ assertEquals(1, attributes.getLength());
+ Attr attr = (Attr)attributes.item(0);
+ assertEquals("xmlns", attr.getName());
+ assertNull(attr.getPrefix());
+ assertEquals("xmlns", attr.getLocalName());
+ assertEquals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, attr.getNamespaceURI());
+ assertEquals("", attr.getValue());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes2.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes3.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes3.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes3.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes3.java Sat Oct 1 10:49:11 2011
@@ -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.dom.element;
+
+import java.io.StringReader;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.xml.sax.InputSource;
+
+public class TestAttributes3 extends DOMTestCase {
+ public TestAttributes3(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(
+ "<root><child xmlns:p=\"urn:ns1\"/></root>")));
+ Element element = (Element)doc.getDocumentElement().getFirstChild();
+ assertTrue(element.hasAttributes());
+ NamedNodeMap attributes = element.getAttributes();
+ assertEquals(1, attributes.getLength());
+ Attr attr = (Attr)attributes.item(0);
+ assertEquals("xmlns:p", attr.getName());
+ assertEquals("xmlns", attr.getPrefix());
+ assertEquals("p", attr.getLocalName());
+ assertEquals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, attr.getNamespaceURI());
+ assertEquals("urn:ns1", attr.getValue());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes3.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes4.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes4.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes4.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes4.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.dom.element;
+
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+public class TestAttributes4 extends DOMTestCase {
+ public TestAttributes4(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(
+ "<root><child/></root>")));
+ Element element = (Element)doc.getDocumentElement().getFirstChild();
+ assertFalse(element.hasAttributes());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestAttributes4.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagName.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagName.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagName.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagName.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,54 @@
+/*
+ * 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.dom.element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/** Testing the NodeList returned with the elements's children */
+public class TestGetElementsByTagName extends DOMTestCase {
+ public TestGetElementsByTagName(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ String childElementLN = "Child";
+
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Element docElem = doc.getDocumentElement();
+ assertNull("The document element shoudl be null", docElem);
+
+ docElem = doc.createElement("Test");
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+
+ NodeList list = docElem.getElementsByTagName(childElementLN);
+
+ assertEquals("Incorrect number of child elements", 7, list.getLength());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagName.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameNS.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameNS.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameNS.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameNS.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,56 @@
+/*
+ * 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.dom.element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class TestGetElementsByTagNameNS extends DOMTestCase {
+ public TestGetElementsByTagNameNS(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ String childElementQN = "test:Child";
+ String childElementLN = "Child";
+ String childElementNS = "http://ws.apache.org/ns/axis2/dom";
+
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Element docElem = doc.getDocumentElement();
+ assertNull("The document element shoudl be null", docElem);
+
+ docElem = doc.createElementNS("http://test.org", "test:Test");
+
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementQN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementQN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementQN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementQN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementQN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementQN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementQN));
+
+ NodeList list = docElem.getElementsByTagNameNS(childElementNS, childElementLN);
+
+ assertEquals("Incorrect number of child elements", 7, list.getLength());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameNS.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameRecursive.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameRecursive.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameRecursive.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameRecursive.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.dom.element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class TestGetElementsByTagNameRecursive extends DOMTestCase {
+ public TestGetElementsByTagNameRecursive(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc =
+ dbf.newDocumentBuilder().parse(AbstractTestCase.getTestResource("xml/numbers.xml"));
+ Element element = doc.getDocumentElement();
+ NodeList list = element.getElementsByTagName("nr");
+ assertEquals(10, list.getLength());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameRecursive.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithNamespaces.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithNamespaces.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithNamespaces.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithNamespaces.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.dom.element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class TestGetElementsByTagNameWithNamespaces extends DOMTestCase {
+ public TestGetElementsByTagNameWithNamespaces(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Element root = doc.createElementNS("urn:ns1", "ns1:root");
+ for (int i=0; i<3; i++) {
+ root.appendChild(doc.createElementNS("urn:ns2", "ns2:child"));
+ }
+ assertEquals(3, root.getElementsByTagName("ns2:child").getLength());
+ assertEquals(0, root.getElementsByTagName("child").getLength());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithNamespaces.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithWildcard.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithWildcard.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithWildcard.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithWildcard.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.dom.element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class TestGetElementsByTagNameWithWildcard extends DOMTestCase {
+ public TestGetElementsByTagNameWithWildcard(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Element root = doc.createElement("root");
+ for (int i=0; i<3; i++) {
+ root.appendChild(doc.createElement("child" + i));
+ }
+ assertEquals(3, root.getElementsByTagName("*").getLength());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetElementsByTagNameWithWildcard.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetNamespaceURIWithNoNamespace.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetNamespaceURIWithNoNamespace.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetNamespaceURIWithNoNamespace.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetNamespaceURIWithNoNamespace.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.dom.element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class TestGetNamespaceURIWithNoNamespace extends DOMTestCase {
+ public TestGetNamespaceURIWithNoNamespace(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Element element = doc.createElement("test");
+ assertNull(element.getNamespaceURI());
+ element = doc.createElementNS(null, "test");
+ assertNull(element.getNamespaceURI());
+ element = doc.createElementNS("", "test");
+ assertNull(element.getNamespaceURI());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetNamespaceURIWithNoNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetTextContent.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetTextContent.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetTextContent.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetTextContent.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,39 @@
+/*
+ * 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.dom.element;
+
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+public class TestGetTextContent extends DOMTestCase {
+ public TestGetTextContent(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().parse(new InputSource(
+ new StringReader("<a>1<!--c--><b>2</b>3</a>")));
+ assertEquals("123", doc.getDocumentElement().getTextContent());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestGetTextContent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveFirstChild.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveFirstChild.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveFirstChild.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveFirstChild.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,46 @@
+/*
+ * 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.dom.element;
+
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+// Regression test for WSCOMMONS-435
+public class TestRemoveFirstChild extends DOMTestCase {
+ public TestRemoveFirstChild(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ DocumentBuilder builder = dbf.newDocumentBuilder();
+ Element element = builder.parse(new InputSource(new StringReader(
+ "<root><a/><b/><c/></root>"))).getDocumentElement();
+ element.removeChild(element.getFirstChild());
+ Node firstChild = element.getFirstChild();
+ assertNotNull(firstChild);
+ assertEquals("b", firstChild.getNodeName());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveFirstChild.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveLastChild.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveLastChild.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveLastChild.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveLastChild.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,45 @@
+/*
+ * 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.dom.element;
+
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+public class TestRemoveLastChild extends DOMTestCase {
+ public TestRemoveLastChild(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ DocumentBuilder builder = dbf.newDocumentBuilder();
+ Element element = builder.parse(new InputSource(new StringReader(
+ "<root><a/><b/><c/></root>"))).getDocumentElement();
+ element.removeChild(element.getLastChild());
+ Node lastChild = element.getLastChild();
+ assertNotNull(lastChild);
+ assertEquals("b", lastChild.getNodeName());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveLastChild.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.dom.element;
+
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+public class TestRemoveSingleChild extends DOMTestCase {
+ public TestRemoveSingleChild(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ DocumentBuilder builder = dbf.newDocumentBuilder();
+ Element element = builder.parse(new InputSource(new StringReader(
+ "<root><a/></root>"))).getDocumentElement();
+ element.removeChild(element.getFirstChild());
+ assertNull(element.getFirstChild());
+ assertNull(element.getLastChild());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestRemoveSingleChild.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChild.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChild.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChild.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChild.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,50 @@
+/*
+ * 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.dom.element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class TestReplaceChild extends DOMTestCase {
+ public TestReplaceChild(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().newDocument();
+ Element parent = doc.createElementNS(null, "parent");
+ Element child1 = doc.createElementNS(null, "child1");
+ Element child2 = doc.createElementNS(null, "child2");
+ Element child3 = doc.createElementNS(null, "child3");
+ parent.appendChild(child1);
+ parent.appendChild(child2);
+ parent.appendChild(child3);
+ Element replacementChild = doc.createElementNS(null, "replacement");
+ parent.replaceChild(replacementChild, child2);
+ NodeList children = parent.getChildNodes();
+ assertEquals(3, children.getLength());
+ assertSame(child1, children.item(0));
+ assertSame(replacementChild, children.item(1));
+ assertSame(child3, children.item(2));
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChild.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetTextContent.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetTextContent.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetTextContent.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetTextContent.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,47 @@
+/*
+ * 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.dom.element;
+
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+
+public class TestSetTextContent extends DOMTestCase {
+ public TestSetTextContent(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document doc = dbf.newDocumentBuilder().parse(new InputSource(
+ new StringReader("<a>1<!--c--><b>2</b>3</a>")));
+ Element element = doc.getDocumentElement();
+ element.setTextContent("test");
+ Node firstChild = element.getFirstChild();
+ assertTrue(firstChild instanceof Text);
+ assertEquals("test", firstChild.getNodeValue());
+ assertNull(firstChild.getNextSibling());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetTextContent.java
------------------------------------------------------------------------------
svn:eol-style = native