You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2009/06/17 00:18:19 UTC
svn commit: r785430 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/test/java/org/apache/axiom/om/
axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/
axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/
Author: veithen
Date: Tue Jun 16 22:18:19 2009
New Revision: 785430
URL: http://svn.apache.org/viewvc?rev=785430&view=rev
Log:
Use the same pattern for implementation independent test cases everywhere.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.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-impl/src/test/java/org/apache/axiom/om/impl/llom/OMElementTest.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java?rev=785430&r1=785429&r2=785430&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java Tue Jun 16 22:18:19 2009
@@ -27,10 +27,14 @@
import org.apache.axiom.om.util.AXIOMUtil;
public abstract class OMElementTestBase extends AbstractTestCase {
- protected abstract OMFactory getOMFactory();
+ protected final OMMetaFactory omMetaFactory;
+
+ public OMElementTestBase(OMMetaFactory omMetaFactory) {
+ this.omMetaFactory = omMetaFactory;
+ }
public void testSetText() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
String localName = "TestLocalName";
String namespace = "http://ws.apache.org/axis2/ns";
String prefix = "axis2";
@@ -44,7 +48,7 @@
}
public void testCDATA() throws Exception {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
OMElement omElement = factory.createOMElement("TestElement", null);
final String text = "this is <some> text in a CDATA";
factory.createOMText(omElement, text, XMLStreamConstants.CDATA);
@@ -59,7 +63,7 @@
}
public void testAddChild() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
String localName = "TestLocalName";
String childLocalName = "TestChildLocalName";
String namespace = "http://ws.apache.org/axis2/ns";
@@ -85,7 +89,7 @@
// Regression test for WSCOMMONS-337
public void testInsertSiblingAfterLastChild() throws Exception {
- OMFactory fac = getOMFactory();
+ OMFactory fac = omMetaFactory.getOMFactory();
OMNamespace ns = fac.createOMNamespace("http://www.testuri.com","ns");
OMElement parent = fac.createOMElement("parent", ns);
@@ -105,7 +109,7 @@
}
private void testDetach(boolean build) throws Exception {
- OMElement root = AXIOMUtil.stringToOM(getOMFactory(), "<root><a/><b/><c/></root>");
+ OMElement root = AXIOMUtil.stringToOM(omMetaFactory.getOMFactory(), "<root><a/><b/><c/></root>");
if (build) {
root.build();
} else {
@@ -133,7 +137,7 @@
public void testFindNamespaceByPrefix() throws Exception {
OMElement root =
- AXIOMUtil.stringToOM(getOMFactory(), "<a:root xmlns:a='urn:a'><child/></a:root>");
+ AXIOMUtil.stringToOM(omMetaFactory.getOMFactory(), "<a:root xmlns:a='urn:a'><child/></a:root>");
OMNamespace ns = root.getFirstElement().findNamespace(null, "a");
assertNotNull(ns);
assertEquals("urn:a", ns.getNamespaceURI());
@@ -144,7 +148,7 @@
* already owned by another element will clone the attribute.
*/
public void testAddAttributeAlreadyOwnedByOtherElement() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
OMElement element1 = factory.createOMElement(new QName("test"));
OMElement element2 = factory.createOMElement(new QName("test"));
OMAttribute att1 = element1.addAttribute("test", "test", null);
@@ -159,7 +163,7 @@
* already owned by the element is a no-op.
*/
public void testAddAttributeAlreadyOwnedByElement() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
OMElement element = factory.createOMElement(new QName("test"));
OMAttribute att = element.addAttribute("test", "test", null);
OMAttribute result = element.addAttribute(att);
@@ -176,7 +180,7 @@
* with the same name and namespace URI already exists.
*/
public void testAddAttributeReplace() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
// Use same namespace URI but different prefixes
OMNamespace ns1 = factory.createOMNamespace("urn:ns", "p1");
OMNamespace ns2 = factory.createOMNamespace("urn:ns", "p2");
@@ -194,7 +198,7 @@
}
public void testAddAttributeWithoutExistingNamespaceDeclaration() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
OMElement element = factory.createOMElement(new QName("test"));
OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
OMAttribute att = factory.createOMAttribute("test", ns, "test");
@@ -211,7 +215,7 @@
* a corresponding declaration already exists on the element.
*/
public void testAddAttributeWithExistingNamespaceDeclarationOnSameElement() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
OMElement element = factory.createOMElement(new QName("test"));
OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
element.declareNamespace(ns);
@@ -228,7 +232,7 @@
* a corresponding declaration is already in scope.
*/
public void testAddAttributeWithExistingNamespaceDeclarationInScope() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
OMElement root = factory.createOMElement(new QName("test"));
OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
root.declareNamespace(ns);
@@ -257,7 +261,7 @@
* Note that because of WSTX-202, Axiom will not be able to serialize the resulting XML.
*/
public void testAddAttributeWithMaskedNamespaceDeclaration() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
OMNamespace ns1 = factory.createOMNamespace("urn:ns1", "p");
OMNamespace ns2 = factory.createOMNamespace("urn:ns2", "p");
OMElement element1 = factory.createOMElement(new QName("a"));
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=785430&r1=785429&r2=785430&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 Tue Jun 16 22:18:19 2009
@@ -21,9 +21,9 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMElementTestBase;
-import org.apache.axiom.om.OMFactory;
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.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -38,8 +38,8 @@
import java.io.StringReader;
public class ElementImplTest extends OMElementTestBase {
- protected OMFactory getOMFactory() {
- return new OMDOMFactory();
+ public ElementImplTest() {
+ super(new OMDOMMetaFactory());
}
public void testSerialize() throws Exception {
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMElementTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMElementTest.java?rev=785430&r1=785429&r2=785430&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMElementTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMElementTest.java Tue Jun 16 22:18:19 2009
@@ -27,19 +27,19 @@
import org.apache.axiom.om.OMElementTestBase;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
+import org.apache.axiom.om.impl.llom.factory.OMLinkedListMetaFactory;
public class OMElementTest extends OMElementTestBase {
private static final String AXIS2_NS_URI = "http://ws.apache.org/axis2";
private static final String AXIS2_NS_PREFIX = "axis2";
private static final String SOME_TEXT = "Some Text";
- protected OMFactory getOMFactory() {
- return new OMLinkedListImplFactory();
+ public OMElementTest() {
+ super(new OMLinkedListMetaFactory());
}
public void testTextQNames() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
OMElement omElement = factory.createOMElement("TestElement", null);
omElement.setText(new QName(AXIS2_NS_URI, SOME_TEXT, AXIS2_NS_PREFIX));
@@ -63,7 +63,7 @@
}
public void testTextQNamesWithoutQNames() {
- OMFactory factory = getOMFactory();
+ OMFactory factory = omMetaFactory.getOMFactory();
OMElement omElement = factory.createOMElement("TestElement", null);
omElement.setText(SOME_TEXT);