Author: veithen
Date: Fri Apr  1 21:44:38 2011
New Revision: 1087909

URL: http://svn.apache.org/viewvc?rev=1087909&view=rev
Log:
* Increased the test coverage for OMFactory#createOMElement methods.
* Completed the Javadoc of OMFactory#createOMElement(String,String,String).
* Optimized the implementations of 
OMFactory#createOMElement(String,String,String) to avoid creating an 
OMNamespace object when this is not necessary.

Added:
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithDefaultNamespace.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithGeneratedPrefix.java
      - copied, changed from r1087882, 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithDefaultNamespace.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNonDefaultNamespace.java
      - copied, changed from r1087882, 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElement.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java
      - copied, changed from r1087882, 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithoutNamespace.java
Removed:
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElement.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithDefaultNamespace.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithNonDefaultNamespace.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithoutNamespace.java
Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/OMElementCreator.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java?rev=1087909&r1=1087908&r2=1087909&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
 Fri Apr  1 21:44:38 2011
@@ -95,21 +95,23 @@ public interface OMFactory {
     OMSourcedElement createOMElement(OMDataSource source, QName qname);
 
     /**
-     * Create an element with the given name.
+     * Create an element with the given name. If a namespace is given, a 
namespace declaration will
+     * be added automatically to the newly created element.
      * 
      * @param localName
      *            the local part of the name; must not be <code>null</code>
      * @param namespaceURI
-     *            the namespace URI, or the empty string if the element has no
-     *            namespace; must not be <code>null</code>
-     * @param namespacePrefix
+     *            the namespace URI, or the empty string if the element has no 
namespace; must not
+     *            be <code>null</code>
+     * @param prefix
+     *            the namespace prefix, or <code>null</code> if a prefix 
should be generated
      * @return the newly created OMElement.
      * @throws IllegalArgumentException
      *             if <code>namespaceURI</code> is <code>null</code>
      */
     OMElement createOMElement(String localName,
                                      String namespaceURI,
-                                     String namespacePrefix);
+                                     String prefix);
 
     /**
      * Create an OMElement with the given QName under the given parent.

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java?rev=1087909&r1=1087908&r2=1087909&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
 Fri Apr  1 21:44:38 2011
@@ -201,16 +201,14 @@ public class OMDOMFactory implements OMF
         throw new UnsupportedOperationException("Not supported for DOM");
     }
 
-    /**
-     * Creates an OMElement.
-     *
-     * @see org.apache.axiom.om.OMFactory#createOMElement(String, String,
-     *      String)
-     */
-    public OMElement createOMElement(String localName, String namespaceURI,
-                                     String namespacePrefix) {
-        NamespaceImpl ns = new NamespaceImpl(namespaceURI, namespacePrefix);
-        return this.createOMElement(localName, ns);
+    public OMElement createOMElement(String localName, String namespaceURI, 
String prefix) {
+        if (namespaceURI == null) {
+            throw new IllegalArgumentException("namespaceURI must not be 
null");
+        } else if (namespaceURI.length() == 0) {
+            return createOMElement(localName, null);
+        } else {
+            return createOMElement(localName, createOMNamespace(namespaceURI, 
prefix));
+        }
     }
 
     /**

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1087909&r1=1087908&r2=1087909&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
 Fri Apr  1 21:44:38 2011
@@ -26,7 +26,7 @@ import org.apache.axiom.ts.OMTestSuiteBu
 import 
org.apache.axiom.ts.om.element.TestGetXMLStreamReaderCDATAEventFromElement;
 import 
org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant;
 import org.apache.axiom.ts.om.element.TestSetTextQName;
-import 
org.apache.axiom.ts.om.factory.TestCreateOMElementFromQNameWithDefaultNamespace;
+import org.apache.axiom.ts.om.factory.TestCreateOMElementWithGeneratedPrefix;
 import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
 import org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnChild;
 
@@ -49,7 +49,7 @@ public class OMImplementationTest extend
         builder.exclude(TestInsertSiblingBeforeOnChild.class);
         
         // TODO: DOOM's behavior differs from LLOM's behavior in this case
-        
builder.exclude(TestCreateOMElementFromQNameWithDefaultNamespace.class);
+        builder.exclude(TestCreateOMElementWithGeneratedPrefix.class);
         
         // DOOM doesn't support CDATA sections
         builder.exclude(TestGetXMLStreamReaderCDATAEventFromElement.class);

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java?rev=1087909&r1=1087908&r2=1087909&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
 Fri Apr  1 21:44:38 2011
@@ -95,19 +95,14 @@ public class OMLinkedListImplFactory imp
                                  builder, this);
     }
 
-    /**
-     * Method createOMElement.
-     *
-     * @param localName
-     * @param namespaceURI
-     * @param namespacePrefix
-     * @return Returns OMElement.
-     */
-    public OMElement createOMElement(String localName, String namespaceURI,
-                                     String namespacePrefix) {
-        return this.createOMElement(localName,
-                                    this.createOMNamespace(namespaceURI,
-                                                           namespacePrefix));
+    public OMElement createOMElement(String localName, String namespaceURI, 
String prefix) {
+        if (namespaceURI == null) {
+            throw new IllegalArgumentException("namespaceURI must not be 
null");
+        } else if (namespaceURI.length() == 0) {
+            return createOMElement(localName, null);
+        } else {
+            return createOMElement(localName, createOMNamespace(namespaceURI, 
prefix));
+        }
     }
 
     /**

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java?rev=1087909&r1=1087908&r2=1087909&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
 Fri Apr  1 21:44:38 2011
@@ -131,11 +131,14 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.element.TestSetText(metaFactory));
         addTest(new 
org.apache.axiom.ts.om.element.TestSetTextQName(metaFactory));
         for (int i=0; i<OMElementCreator.INSTANCES.length; i++) {
-            addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMElement(metaFactory, 
OMElementCreator.INSTANCES[i]));
+            OMElementCreator creator = OMElementCreator.INSTANCES[i];
+            if (creator.isSupportsDefaultNamespace()) {
+                addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMElementWithDefaultNamespace(metaFactory,
 creator));
+            }
+            addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMElementWithGeneratedPrefix(metaFactory,
 creator));
+            addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMElementWithNonDefaultNamespace(metaFactory,
 creator));
+            addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMElementWithoutNamespace(metaFactory, 
creator));
         }
-        addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMElementFromQNameWithDefaultNamespace(metaFactory));
-        addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMElementFromQNameWithNonDefaultNamespace(metaFactory));
-        addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMElementFromQNameWithoutNamespace(metaFactory));
         addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMNamespace(metaFactory));
         addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMNamespaceWithNullURI(metaFactory));
         addTest(new 
org.apache.axiom.ts.om.factory.TestCreateOMText(metaFactory));

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/OMElementCreator.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/OMElementCreator.java?rev=1087909&r1=1087908&r2=1087909&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/OMElementCreator.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/OMElementCreator.java
 Fri Apr  1 21:44:38 2011
@@ -25,44 +25,62 @@ import org.apache.axiom.om.OMFactory;
 
 public abstract class OMElementCreator {
     public static final OMElementCreator[] INSTANCES = new OMElementCreator[] {
-        new OMElementCreator("QName") {
-            public OMElement createOMElement(OMFactory factory, QName qname) {
-                return factory.createOMElement(qname);
+        new OMElementCreator("QName", false) {
+            public OMElement createOMElement(OMFactory factory, String 
localName,
+                    String namespaceURI, String prefix) {
+                if (prefix == null) {
+                    prefix = "";
+                }
+                return factory.createOMElement(new QName(namespaceURI, 
localName, prefix));
             }
         },
-        new OMElementCreator("QName,OMContainer") {
-            public OMElement createOMElement(OMFactory factory, QName qname) {
-                return factory.createOMElement(qname, null);
+        new OMElementCreator("QName,OMContainer", false) {
+            public OMElement createOMElement(OMFactory factory, String 
localName,
+                    String namespaceURI, String prefix) {
+                if (prefix == null) {
+                    prefix = "";
+                }
+                return factory.createOMElement(new QName(namespaceURI, 
localName, prefix), null);
             }
         },
-        new OMElementCreator("String,OMNamespace") {
-            public OMElement createOMElement(OMFactory factory, QName qname) {
-                return factory.createOMElement(qname.getLocalPart(),
-                        factory.createOMNamespace(qname.getNamespaceURI(), 
qname.getPrefix()));
+        new OMElementCreator("String,OMNamespace", true) {
+            public OMElement createOMElement(OMFactory factory, String 
localName,
+                    String namespaceURI, String prefix) {
+                return factory.createOMElement(localName,
+                        namespaceURI.length() == 0 ? null : 
factory.createOMNamespace(namespaceURI, prefix));
             }
         },
-        new OMElementCreator("String,OMNamespace,OMContainer") {
-            public OMElement createOMElement(OMFactory factory, QName qname) {
-                return factory.createOMElement(qname.getLocalPart(),
-                        factory.createOMNamespace(qname.getNamespaceURI(), 
qname.getPrefix()), null);
+        new OMElementCreator("String,OMNamespace,OMContainer", true) {
+            public OMElement createOMElement(OMFactory factory, String 
localName,
+                    String namespaceURI, String prefix) {
+                return factory.createOMElement(localName,
+                        namespaceURI.length() == 0 ? null : 
factory.createOMNamespace(namespaceURI, prefix), null);
             }
         },
-        new OMElementCreator("String,String,String") {
-            public OMElement createOMElement(OMFactory factory, QName qname) {
-                return factory.createOMElement(qname.getLocalPart(), 
qname.getNamespaceURI(), qname.getPrefix());
+        new OMElementCreator("String,String,String", true) {
+            public OMElement createOMElement(OMFactory factory, String 
localName,
+                    String namespaceURI, String prefix) {
+                return factory.createOMElement(localName, namespaceURI, 
prefix);
             }
         },
     };
     
     private final String name;
+    private final boolean supportsDefaultNamespace;
     
-    public OMElementCreator(String name) {
+    public OMElementCreator(String name, boolean supportsDefaultNamespace) {
         this.name = name;
+        this.supportsDefaultNamespace = supportsDefaultNamespace;
     }
 
-    public String getName() {
+    public final String getName() {
         return name;
     }
 
-    protected abstract OMElement createOMElement(OMFactory factory, QName 
qname);
+    public final boolean isSupportsDefaultNamespace() {
+        return supportsDefaultNamespace;
+    }
+
+    public abstract OMElement createOMElement(OMFactory factory, String 
localName,
+            String namespaceURI, String prefix);
 }

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithDefaultNamespace.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithDefaultNamespace.java?rev=1087909&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithDefaultNamespace.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithDefaultNamespace.java
 Fri Apr  1 21:44:38 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.om.factory;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestCreateOMElementWithDefaultNamespace extends AxiomTestCase {
+    private final OMElementCreator variant;
+    
+    public TestCreateOMElementWithDefaultNamespace(OMMetaFactory metaFactory, 
OMElementCreator variant) {
+        super(metaFactory);
+        this.variant = variant;
+        addTestProperty("variant", variant.getName());
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement element = variant.createOMElement(factory, "test", "urn:ns", 
"");
+        assertTrue(element.isComplete());
+        assertEquals("test", element.getLocalName());
+        OMNamespace ns = factory.createOMNamespace("urn:ns", "");
+        assertEquals(ns, element.getNamespace());
+        Iterator it = element.getAllDeclaredNamespaces();
+        assertTrue(it.hasNext());
+        assertEquals(ns, it.next());
+        assertFalse(it.hasNext());
+    }
+}

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithDefaultNamespace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithGeneratedPrefix.java
 (from r1087882, 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithDefaultNamespace.java)
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithGeneratedPrefix.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithGeneratedPrefix.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithDefaultNamespace.java&r1=1087882&r2=1087909&rev=1087909&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithDefaultNamespace.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithGeneratedPrefix.java
 Fri Apr  1 21:44:38 2011
@@ -20,25 +20,28 @@ package org.apache.axiom.ts.om.factory;
 
 import java.util.Iterator;
 
-import javax.xml.namespace.QName;
-
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.ts.AxiomTestCase;
 
-public class TestCreateOMElementFromQNameWithDefaultNamespace extends 
AxiomTestCase {
-    public TestCreateOMElementFromQNameWithDefaultNamespace(OMMetaFactory 
metaFactory) {
+public class TestCreateOMElementWithGeneratedPrefix extends AxiomTestCase {
+    private final OMElementCreator variant;
+    
+    public TestCreateOMElementWithGeneratedPrefix(OMMetaFactory metaFactory, 
OMElementCreator variant) {
         super(metaFactory);
+        this.variant = variant;
+        addTestProperty("variant", variant.getName());
     }
 
     protected void runTest() throws Throwable {
-        QName qname = new QName("urn:test", "test");
-        OMElement element = metaFactory.getOMFactory().createOMElement(qname);
-        assertEquals(qname.getLocalPart(), element.getLocalName());
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement element = variant.createOMElement(factory, "test", 
"urn:test", null);
+        assertEquals("test", element.getLocalName());
         OMNamespace ns = element.getNamespace();
         assertNotNull(ns);
-        assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
+        assertEquals("urn:test", ns.getNamespaceURI());
         // Axiom auto-generates a prefix here
         assertTrue(ns.getPrefix().length() != 0);
         Iterator it = element.getAllDeclaredNamespaces();

Copied: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNonDefaultNamespace.java
 (from r1087882, 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElement.java)
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNonDefaultNamespace.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNonDefaultNamespace.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElement.java&r1=1087882&r2=1087909&rev=1087909&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElement.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithNonDefaultNamespace.java
 Fri Apr  1 21:44:38 2011
@@ -20,18 +20,16 @@ package org.apache.axiom.ts.om.factory;
 
 import java.util.Iterator;
 
-import javax.xml.namespace.QName;
-
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.ts.AxiomTestCase;
 
-public class TestCreateOMElement extends AxiomTestCase {
+public class TestCreateOMElementWithNonDefaultNamespace extends AxiomTestCase {
     private final OMElementCreator variant;
     
-    public TestCreateOMElement(OMMetaFactory metaFactory, OMElementCreator 
variant) {
+    public TestCreateOMElementWithNonDefaultNamespace(OMMetaFactory 
metaFactory, OMElementCreator variant) {
         super(metaFactory);
         this.variant = variant;
         addTestProperty("variant", variant.getName());
@@ -39,10 +37,10 @@ public class TestCreateOMElement extends
 
     protected void runTest() throws Throwable {
         OMFactory factory = metaFactory.getOMFactory();
-        OMNamespace ns = factory.createOMNamespace("urn:ns", "ns");
-        OMElement element = variant.createOMElement(factory, new 
QName("urn:ns", "test", "ns"));
+        OMElement element = variant.createOMElement(factory, "test", "urn:ns", 
"ns");
         assertTrue(element.isComplete());
         assertEquals("test", element.getLocalName());
+        OMNamespace ns = factory.createOMNamespace("urn:ns", "ns");
         assertEquals(ns, element.getNamespace());
         Iterator it = element.getAllDeclaredNamespaces();
         assertTrue(it.hasNext());

Copied: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java
 (from r1087882, 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithoutNamespace.java)
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithoutNamespace.java&r1=1087882&r2=1087909&rev=1087909&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementFromQNameWithoutNamespace.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java
 Fri Apr  1 21:44:38 2011
@@ -18,21 +18,24 @@
  */
 package org.apache.axiom.ts.om.factory;
 
-import javax.xml.namespace.QName;
-
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.ts.AxiomTestCase;
 
-public class TestCreateOMElementFromQNameWithoutNamespace extends 
AxiomTestCase {
-    public TestCreateOMElementFromQNameWithoutNamespace(OMMetaFactory 
metaFactory) {
+public class TestCreateOMElementWithoutNamespace extends AxiomTestCase {
+    private final OMElementCreator variant;
+    
+    public TestCreateOMElementWithoutNamespace(OMMetaFactory metaFactory, 
OMElementCreator variant) {
         super(metaFactory);
+        this.variant = variant;
+        addTestProperty("variant", variant.getName());
     }
 
     protected void runTest() throws Throwable {
-        QName qname = new QName("test");
-        OMElement element = metaFactory.getOMFactory().createOMElement(qname);
-        assertEquals(qname.getLocalPart(), element.getLocalName());
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement element = variant.createOMElement(factory, "test", "", "");
+        assertEquals("test", element.getLocalName());
         assertNull(element.getNamespace());
         assertFalse(element.getAllDeclaredNamespaces().hasNext());
     }


Reply via email to