Support lazy determination of namespace.
diff --git a/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java b/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
index 7abc6ca..cd7eb74 100644
--- a/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
+++ b/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
@@ -315,14 +315,16 @@
                             readerLocalName + ", not the expected " + getLocalName());
                 }
             }
-            String readerURI = readerFromDS.getNamespaceURI();
-            readerURI = (readerURI == null) ? "" : readerURI;
-            String uri = (getNamespace() == null) ? "" : getNamespace().getNamespaceURI();
-            if (!readerURI.equals(uri)) {
-                log.error("forceExpand: expected element namespace " +
-                        getLocalName() + ", found " + uri);
-                throw new RuntimeException("Element namespace from data source is " +
-                        readerURI + ", not the expected " + uri);
+            if (definedNamespaceSet) {
+                String readerURI = readerFromDS.getNamespaceURI();
+                readerURI = (readerURI == null) ? "" : readerURI;
+                String uri = (getNamespace() == null) ? "" : getNamespace().getNamespaceURI();
+                if (!readerURI.equals(uri)) {
+                    log.error("forceExpand: expected element namespace " +
+                            getLocalName() + ", found " + uri);
+                    throw new RuntimeException("Element namespace from data source is " +
+                            readerURI + ", not the expected " + uri);
+                }
             }
 
             // Set the builder for this element. Note that the StAXOMBuilder constructor will also
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
index 4d4aa9c..473eb7d 100644
--- a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
@@ -31,6 +31,7 @@
 import org.apache.axiom.ts.om.container.SerializeToOutputStream;
 import org.apache.axiom.ts.om.factory.CreateOMElementParentSupplier;
 import org.apache.axiom.ts.om.factory.CreateOMElementVariant;
+import org.apache.axiom.ts.om.sourcedelement.OMSourcedElementVariant;
 import org.apache.axiom.ts.om.xpath.AXIOMXPathTestCase;
 import org.apache.axiom.ts.om.xpath.TestAXIOMXPath;
 
@@ -44,6 +45,11 @@
         new SerializeToOutputStream(true),
         new SerializeToOutputStream(false) };
     
+    private static final QName[] qnames = {
+        new QName("root"),
+        new QName("urn:test", "root", "p"),
+        new QName("urn:test", "root") };
+    
     private final OMMetaFactory metaFactory;
     private final boolean supportsOMSourcedElement;
     
@@ -324,16 +330,18 @@
         addTest(new org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnOrphan(metaFactory));
         addTest(new org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnSelf(metaFactory));
         if (supportsOMSourcedElement) {
+            for (int i=0; i<OMSourcedElementVariant.INSTANCES.length; i++) {
+                OMSourcedElementVariant variant = OMSourcedElementVariant.INSTANCES[i];
+                for (int j=0; j<qnames.length; j++) {
+                    QName qname = qnames[j];
+                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetLocalName(metaFactory, variant, qname));
+                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespace(metaFactory, variant, qname));
+                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetPrefix(metaFactory, variant, qname));
+                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceURI(metaFactory, variant, qname));
+                }
+            }
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestComplete(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestExpand(metaFactory));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetLocalNameFromExpansion(metaFactory));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetLocalNameFromQNameAwareOMDataSource(metaFactory));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceFromExpansion(metaFactory, new QName("root")));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceFromExpansion(metaFactory, new QName("urn:test", "root", "p")));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceFromExpansion(metaFactory, new QName("urn:test", "root")));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceFromQNameAwareOMDataSource(metaFactory, new QName("root")));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceFromQNameAwareOMDataSource(metaFactory, new QName("urn:test", "root", "p")));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceFromQNameAwareOMDataSource(metaFactory, new QName("urn:test", "root")));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceNormalized(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceNormalized2(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetTextAsStreamWithNonDestructiveOMDataSource(metaFactory));
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/LazyNameTestCase.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/LazyNameTestCase.java
new file mode 100644
index 0000000..d114be9
--- /dev/null
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/LazyNameTestCase.java
@@ -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.om.sourcedelement;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public abstract class LazyNameTestCase extends AxiomTestCase {
+    protected final OMSourcedElementVariant variant;
+    protected final QName qname;
+    
+    public LazyNameTestCase(OMMetaFactory metaFactory, OMSourcedElementVariant variant, QName qname) {
+        super(metaFactory);
+        this.variant = variant;
+        this.qname = qname;
+        addTestProperty("variant", variant.getName());
+        addTestProperty("prefix", qname.getPrefix());
+        addTestProperty("uri", qname.getNamespaceURI());
+    }
+    
+    protected final void runTest() throws Throwable {
+        runTest(variant.createOMSourcedElement(metaFactory.getOMFactory(), qname));
+    }
+
+    protected abstract void runTest(OMSourcedElement element) throws Throwable;
+}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/OMSourcedElementVariant.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/OMSourcedElementVariant.java
new file mode 100644
index 0000000..114a845
--- /dev/null
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/OMSourcedElementVariant.java
@@ -0,0 +1,77 @@
+/*
+ * 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.sourcedelement;
+
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromReader;
+
+public abstract class OMSourcedElementVariant {
+    public static final OMSourcedElementVariant[] INSTANCES = {
+        new OMSourcedElementVariant("qname-aware-source", false, false, false) {
+            public OMSourcedElement createOMSourcedElement(OMFactory factory, QName qname) {
+                return factory.createOMElement(new WrappedTextNodeOMDataSourceFromReader(qname, new StringReader("test")));
+            }
+        },
+        new OMSourcedElementVariant("unknown-name", true, true, true) {
+            public OMSourcedElement createOMSourcedElement(OMFactory factory, QName qname) {
+                // TODO: can't use createOMElement(QName) here because it would generate a prefix if the prefix in the QName is empty
+                OMElement orgElement = factory.createOMElement(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix());
+                return factory.createOMElement(new TestDataSource(orgElement.toString()));
+            }
+        }
+    };
+    
+    private final String name;
+    private final boolean localNameRequiresExpansion;
+    private final boolean namespaceURIRequiresExpansion;
+    private final boolean prefixRequiresExpansion;
+
+    public OMSourcedElementVariant(String name, boolean localNameRequiresExpansion,
+            boolean namespaceURIRequiresExpansion,
+            boolean prefixRequiresExpansion) {
+        this.name = name;
+        this.localNameRequiresExpansion = localNameRequiresExpansion;
+        this.namespaceURIRequiresExpansion = namespaceURIRequiresExpansion;
+        this.prefixRequiresExpansion = prefixRequiresExpansion;
+    }
+
+    public String getName() {
+        return name;
+    }
+    
+    public boolean isLocalNameRequiresExpansion() {
+        return localNameRequiresExpansion;
+    }
+
+    public boolean isNamespaceURIRequiresExpansion() {
+        return namespaceURIRequiresExpansion;
+    }
+
+    public boolean isPrefixRequiresExpansion() {
+        return prefixRequiresExpansion;
+    }
+
+    public abstract OMSourcedElement createOMSourcedElement(OMFactory factory, QName qname);
+}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetLocalName.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetLocalName.java
new file mode 100644
index 0000000..0ff06cc
--- /dev/null
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetLocalName.java
@@ -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.om.sourcedelement;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+
+public class TestGetLocalName extends LazyNameTestCase {
+    public TestGetLocalName(OMMetaFactory metaFactory, OMSourcedElementVariant variant, QName qname) {
+        super(metaFactory, variant, qname);
+    }
+
+    protected void runTest(OMSourcedElement element) throws Throwable {
+        assertEquals(qname.getLocalPart(), element.getLocalName());
+        if (variant.isLocalNameRequiresExpansion()) {
+            assertTrue(element.isExpanded());
+        } else {
+            assertFalse(element.isExpanded());
+        }
+    }
+}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetLocalNameFromExpansion.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetLocalNameFromExpansion.java
deleted file mode 100644
index b5bc5fe..0000000
--- a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetLocalNameFromExpansion.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.sourcedelement;
-
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMNamedInformationItem;
-import org.apache.axiom.om.OMSourcedElement;
-import org.apache.axiom.ts.AxiomTestCase;
-
-/**
- * Tests that {@link OMNamedInformationItem#getLocalName()} expands the element if the local name is
- * not known in advance.
- */
-public class TestGetLocalNameFromExpansion extends AxiomTestCase {
-    public TestGetLocalNameFromExpansion(OMMetaFactory metaFactory) {
-        super(metaFactory);
-    }
-
-    protected void runTest() throws Throwable {
-        OMFactory factory = metaFactory.getOMFactory();
-        OMSourcedElement element = factory.createOMElement(new TestDataSource("<root ns='urn:test'/>"));
-        assertEquals("root", element.getLocalName());
-        assertTrue(element.isExpanded());
-    }
-}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetLocalNameFromQNameAwareOMDataSource.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetLocalNameFromQNameAwareOMDataSource.java
deleted file mode 100644
index 00e9b42..0000000
--- a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetLocalNameFromQNameAwareOMDataSource.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.sourcedelement;
-
-import java.io.StringReader;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMNamedInformationItem;
-import org.apache.axiom.om.OMSourcedElement;
-import org.apache.axiom.om.QNameAwareOMDataSource;
-import org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromReader;
-import org.apache.axiom.ts.AxiomTestCase;
-
-/**
- * Tests that {@link OMNamedInformationItem#getLocalName()} behaves correctly on a
- * {@link OMSourcedElement} backed by a {@link QNameAwareOMDataSource}.
- */
-public class TestGetLocalNameFromQNameAwareOMDataSource extends AxiomTestCase {
-    public TestGetLocalNameFromQNameAwareOMDataSource(OMMetaFactory metaFactory) {
-        super(metaFactory);
-    }
-
-    protected void runTest() throws Throwable {
-        OMFactory factory = metaFactory.getOMFactory();
-        OMSourcedElement element = factory.createOMElement(
-                new WrappedTextNodeOMDataSourceFromReader(new QName("root"), new StringReader("test")));
-        assertEquals("root", element.getLocalName());
-        assertFalse(element.isExpanded());
-    }
-}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespace.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespace.java
new file mode 100644
index 0000000..05019e7
--- /dev/null
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespace.java
@@ -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.om.sourcedelement;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMSourcedElement;
+
+public class TestGetNamespace extends LazyNameTestCase {
+    public TestGetNamespace(OMMetaFactory metaFactory, OMSourcedElementVariant variant, QName qname) {
+        super(metaFactory, variant, qname);
+    }
+
+    protected void runTest(OMSourcedElement element) throws Throwable {
+        OMNamespace ns = element.getNamespace();
+        if (qname.getNamespaceURI().length() == 0) {
+            assertNull(ns);
+        } else {
+            assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
+            assertEquals(qname.getPrefix(), ns.getPrefix());
+        }
+        if (variant.isNamespaceURIRequiresExpansion() || variant.isPrefixRequiresExpansion()) {
+            assertTrue(element.isExpanded());
+        } else {
+            assertFalse(element.isExpanded());
+        }
+    }
+}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespaceFromExpansion.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespaceFromExpansion.java
deleted file mode 100644
index ff8be64..0000000
--- a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespaceFromExpansion.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.sourcedelement;
-
-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.OMNamedInformationItem;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMSourcedElement;
-import org.apache.axiom.ts.AxiomTestCase;
-
-/**
- * Tests that {@link OMNamedInformationItem#getNamespace()} expands the element if the namespace is
- * not known in advance.
- */
-public class TestGetNamespaceFromExpansion extends AxiomTestCase {
-    private final QName qname;
-
-    public TestGetNamespaceFromExpansion(OMMetaFactory metaFactory, QName qname) {
-        super(metaFactory);
-        this.qname = qname;
-        addTestProperty("qname", qname.toString());
-    }
-
-    protected void runTest() throws Throwable {
-        OMFactory factory = metaFactory.getOMFactory();
-        OMElement orgElement = factory.createOMElement(qname);
-        OMSourcedElement element = factory.createOMElement(new TestDataSource(orgElement.toString()));
-        OMNamespace ns = element.getNamespace();
-        if (qname.getNamespaceURI().length() == 0) {
-            assertNull(ns);
-        } else {
-            assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
-            assertEquals(qname.getPrefix(), ns.getPrefix());
-        }
-        assertTrue(element.isExpanded());
-    }
-}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespaceFromQNameAwareOMDataSource.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespaceFromQNameAwareOMDataSource.java
deleted file mode 100644
index 270fcb3..0000000
--- a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespaceFromQNameAwareOMDataSource.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.sourcedelement;
-
-import java.io.StringReader;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMNamedInformationItem;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMSourcedElement;
-import org.apache.axiom.om.QNameAwareOMDataSource;
-import org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromReader;
-import org.apache.axiom.ts.AxiomTestCase;
-
-/**
- * Tests that {@link OMNamedInformationItem#getNamespace()} behaves correctly on a
- * {@link OMSourcedElement} backed by a {@link QNameAwareOMDataSource}.
- */
-public class TestGetNamespaceFromQNameAwareOMDataSource extends AxiomTestCase {
-    private final QName qname;
-    
-    public TestGetNamespaceFromQNameAwareOMDataSource(OMMetaFactory metaFactory, QName qname) {
-        super(metaFactory);
-        this.qname = qname;
-        addTestProperty("qname", qname.toString());
-    }
-
-    protected void runTest() throws Throwable {
-        OMFactory factory = metaFactory.getOMFactory();
-        OMSourcedElement element = factory.createOMElement(
-                new WrappedTextNodeOMDataSourceFromReader(qname, new StringReader("test")));
-        OMNamespace ns = element.getNamespace();
-        if (qname.getNamespaceURI().length() == 0) {
-            assertNull(ns);
-        } else {
-            assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
-            assertEquals(qname.getPrefix(), ns.getPrefix());
-        }
-        assertFalse(element.isExpanded());
-    }
-}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespaceURI.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespaceURI.java
new file mode 100644
index 0000000..15498a7
--- /dev/null
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetNamespaceURI.java
@@ -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.om.sourcedelement;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+
+public class TestGetNamespaceURI extends LazyNameTestCase {
+    public TestGetNamespaceURI(OMMetaFactory metaFactory, OMSourcedElementVariant variant, QName qname) {
+        super(metaFactory, variant, qname);
+    }
+
+    protected void runTest(OMSourcedElement element) throws Throwable {
+        String uri = qname.getNamespaceURI();
+        if (uri.length() == 0) {
+            assertNull(element.getNamespaceURI());
+        } else {
+            assertEquals(uri, element.getNamespaceURI());
+        }
+        if (variant.isNamespaceURIRequiresExpansion()) {
+            assertTrue(element.isExpanded());
+        } else {
+            assertFalse(element.isExpanded());
+        }
+    }
+}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetPrefix.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetPrefix.java
new file mode 100644
index 0000000..15f477c
--- /dev/null
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetPrefix.java
@@ -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.om.sourcedelement;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+
+public class TestGetPrefix extends LazyNameTestCase {
+    public TestGetPrefix(OMMetaFactory metaFactory, OMSourcedElementVariant variant, QName qname) {
+        super(metaFactory, variant, qname);
+    }
+
+    protected void runTest(OMSourcedElement element) throws Throwable {
+        String prefix = qname.getPrefix();
+        if (prefix.length() == 0) {
+            assertNull(element.getPrefix());
+        } else {
+            assertEquals(prefix, element.getPrefix());
+        }
+        if (variant.isPrefixRequiresExpansion()) {
+            assertTrue(element.isExpanded());
+        } else {
+            assertFalse(element.isExpanded());
+        }
+    }
+}