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 [2/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/...
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitText.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitText.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitText.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitText.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.text;
+
+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 TestSplitText extends DOMTestCase {
+ public TestSplitText(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ String textValue = "temp text value";
+
+ Document doc = dbf.newDocumentBuilder().newDocument();
+
+ Element element = doc.createElement("test");
+ Text txt = doc.createTextNode(textValue);
+ element.appendChild(txt);
+ txt.splitText(3);
+
+ assertNotNull("Text value missing in the original Text node", txt
+ .getNodeValue());
+
+ assertNotNull("Sibling missing after split", txt.getNextSibling());
+ assertNotNull("Text value missing in the new split Text node", txt
+ .getNextSibling().getNodeValue());
+
+ assertEquals("Incorrect split point", textValue.substring(0, 3), txt
+ .getNodeValue());
+ assertEquals("Incorrect split point", textValue.substring(3, textValue
+ .length()), txt.getNextSibling().getNodeValue());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitText.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,35 @@
+/*
+ * 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 junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl;
+
+public class XercesTest extends TestCase {
+ public static TestSuite suite() {
+ DocumentBuilderFactory dbf = new DocumentBuilderFactoryImpl();
+ dbf.setNamespaceAware(true);
+ DOMTestSuiteBuilder builder = new DOMTestSuiteBuilder(dbf);
+ return builder.build();
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml?rev=1177956&r1=1177955&r2=1177956&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml Sat Oct 1 10:49:11 2011
@@ -98,6 +98,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axiom-dom-testsuite</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
@@ -115,12 +121,6 @@
<version>1.4</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <version>2.9.1</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
<plugins>
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java?rev=1177956&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java Sat Oct 1 10:49:11 2011
@@ -0,0 +1,32 @@
+/*
+ * 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.om.impl.dom;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.axiom.om.impl.dom.jaxp.DOOMDocumentBuilderFactory;
+import org.apache.axiom.ts.dom.DOMTestSuiteBuilder;
+
+public class DOMImplementationTest extends TestCase {
+ public static TestSuite suite() {
+ DOMTestSuiteBuilder builder = new DOMTestSuiteBuilder(new DOOMDocumentBuilderFactory());
+ return builder.build();
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java?rev=1177956&r1=1177955&r2=1177956&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java Sat Oct 1 10:49:11 2011
@@ -16,137 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.axiom.om.impl.dom;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import org.apache.axiom.om.OMDocumentTestBase;
import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
public class DocumentImplTest extends OMDocumentTestBase {
public DocumentImplTest() {
super(new OMDOMMetaFactory());
}
-
- public void testCreateElement() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- public void testCreateAttribute() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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);
- }
- });
- }
-
- public void testCreateText() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- String textValue = "temp text value";
-
- Document doc = dbf.newDocumentBuilder().newDocument();
- Text txt = doc.createTextNode(textValue);
-
- assertEquals("Text value mismatch", textValue, txt.getData());
- }
- });
- }
-
- public void testDocumentSiblings() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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);
- }
- });
- }
-
- public void testAllowedChildren() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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);
- }
- }
- });
- }
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java?rev=1177956&r1=1177955&r2=1177956&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java Sat Oct 1 10:49:11 2011
@@ -16,29 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.axiom.om.impl.dom;
+import java.io.ByteArrayOutputStream;
+
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMElementTestBase;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.StringReader;
public class ElementImplTest extends OMElementTestBase {
public ElementImplTest() {
@@ -63,326 +50,4 @@ public class ElementImplTest extends OME
String xml = new String(baos.toByteArray());
assertEquals("Incorrect serialized xml", 0, xml.indexOf("<axis2:TestLocalName"));
}
-
- public void testAppendChild() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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);
- }
- });
- }
-
- public void testReplaceChild() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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));
- }
- });
- }
-
- public void testRemoveSingleChild() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- // Regression test for WSCOMMONS-435
- public void testRemoveFirstChild() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- public void testRemoveLastChild() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- /** Testing the NodeList returned with the elements's children */
- public void testGetElementsByTagName() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- public void testGetElementsByTagNameWithNamespaces() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- public void testGetElementsByTagNameWithWildcard() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- public void testGetElementsByTagNameNS() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- public void testGetElementsByTagNameRecursive() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- Document doc =
- dbf.newDocumentBuilder().parse(getTestResource("xml/numbers.xml"));
- Element element = doc.getDocumentElement();
- NodeList list = element.getElementsByTagName("nr");
- assertEquals(10, list.getLength());
- }
- });
- }
-
- public void testGetNamespaceURIWithNoNamespace() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- public void testGetTextContent() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- Document doc = dbf.newDocumentBuilder().parse(new InputSource(
- new StringReader("<a>1<!--c--><b>2</b>3</a>")));
- assertEquals("123", doc.getDocumentElement().getTextContent());
- }
- });
- }
-
- public void testSetTextContent() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- public void testAttributes() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- Document doc = dbf.newDocumentBuilder().parse(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());
- }
- });
- }
-
- public void testAttributes2() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- public void testAttributes3() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- 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());
- }
- });
- }
-
- public void testAttributes4() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(
- "<root><child/></root>")));
- Element element = (Element)doc.getDocumentElement().getFirstChild();
- assertFalse(element.hasAttributes());
- }
- });
- }
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/TextImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/TextImplTest.java?rev=1177956&r1=1177955&r2=1177956&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/TextImplTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/TextImplTest.java Sat Oct 1 10:49:11 2011
@@ -19,14 +19,10 @@
package org.apache.axiom.om.impl.dom;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import org.apache.axiom.om.AbstractTestCase;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
import org.w3c.dom.Text;
public class TextImplTest extends AbstractTestCase {
@@ -46,32 +42,4 @@ public class TextImplTest extends Abstra
assertEquals("Text value mismatch", tempText + textToAppend, textNode
.getText());
}
-
- public void testSplitText() throws Exception {
- DOMTestUtil.execute(new DOMTestUtil.Test() {
- public void execute(DocumentBuilderFactory dbf) throws Exception {
- String textValue = "temp text value";
-
- Document doc = dbf.newDocumentBuilder().newDocument();
-
- Element element = doc.createElement("test");
- Text txt = doc.createTextNode(textValue);
- element.appendChild(txt);
- txt.splitText(3);
-
- assertNotNull("Text value missing in the original Text node", txt
- .getNodeValue());
-
- assertNotNull("Sibling missing after split", txt.getNextSibling());
- assertNotNull("Text value missing in the new split Text node", txt
- .getNextSibling().getNodeValue());
-
- assertEquals("Incorrect split point", textValue.substring(0, 3), txt
- .getNodeValue());
- assertEquals("Incorrect split point", textValue.substring(3, textValue
- .length()), txt.getNextSibling().getNodeValue());
- }
- });
- }
-
}
Modified: webservices/commons/trunk/modules/axiom/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/pom.xml?rev=1177956&r1=1177955&r2=1177956&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/pom.xml Sat Oct 1 10:49:11 2011
@@ -548,6 +548,7 @@
<module>modules/axiom-buildutils</module>
<module>modules/axiom-testutils</module>
<module>modules/axiom-jaxen-testsuite</module>
+ <module>modules/axiom-dom-testsuite</module>
<module>modules/axiom-api</module>
<module>modules/axiom-testsuite</module>
<module>modules/axiom-common-impl</module>