--- /dev/null 2015-03-31 02:29:39.396799728 -0700 +++ new/test/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java 2015-03-30 19:51:29.392566818 -0700 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.astro; + +import static javax.xml.XMLConstants.DEFAULT_NS_PREFIX; +import static javax.xml.XMLConstants.NULL_NS_URI; +import static org.testng.Assert.assertEquals; + +import javax.xml.namespace.QName; + +import jaxp.library.JAXPBaseTest; + +import org.testng.annotations.Test; + +/* + * @summary javax.xml.namespace.QName tests + */ +public class NamespaceContextTest extends JAXPBaseTest { + private static final String PREFIX = "astro"; + private static final String LOCAL_PART = "stardb"; + private static final String NS_URI = "http://www.astro.com"; + + @Test + public void testQNameConstructor() { + QName qname = new QName(NS_URI, LOCAL_PART, PREFIX); + assertEquals(qname.getNamespaceURI(), NS_URI); + assertEquals(qname.getLocalPart(), LOCAL_PART); + assertEquals(qname.getPrefix(), PREFIX); + } + + @Test + public void testDefaultFields() { + QName qname = new QName(LOCAL_PART); // just the local part specified + assertEquals(qname.getNamespaceURI(), NULL_NS_URI); + assertEquals(qname.getLocalPart(), LOCAL_PART); + assertEquals(qname.getPrefix(), DEFAULT_NS_PREFIX); + } + + @Test + public void testDefaultPrefix() { + QName qname = new QName(NS_URI, LOCAL_PART); // no pref + assertEquals(qname.getNamespaceURI(), NS_URI); + assertEquals(qname.getLocalPart(), LOCAL_PART); + assertEquals(qname.getPrefix(), DEFAULT_NS_PREFIX); + } + + @Test + public void testQNameString() { + QName qname = new QName(NS_URI, LOCAL_PART, PREFIX); + assertEquals(QName.valueOf(qname.toString()), qname); + } +} \ No newline at end of file