01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.xs.bindings;
17:
18: import javax.xml.namespace.QName;
19:
20: import junit.framework.TestCase;
21:
22: import org.geotools.xml.impl.NamespaceSupportWrapper;
23: import org.xml.sax.helpers.NamespaceSupport;
24:
25: public class XSQNameBindingTest extends TestCase {
26: XSQNameBinding binding;
27:
28: protected void setUp() throws Exception {
29: NamespaceSupport ns = new NamespaceSupport();
30: ns.declarePrefix("foo", "http://foo");
31:
32: binding = new XSQNameBinding(new NamespaceSupportWrapper(ns));
33: }
34:
35: public void testWithPrefix() throws Exception {
36: QName qName = (QName) binding.parse(null, "foo:bar");
37: assertNotNull(qName);
38:
39: assertEquals("foo", qName.getPrefix());
40: assertEquals("http://foo", qName.getNamespaceURI());
41: assertEquals("bar", qName.getLocalPart());
42: }
43:
44: public void testWithNoPrefix() throws Exception {
45: QName qName = (QName) binding.parse(null, "bar:foo");
46: assertNotNull(qName);
47:
48: assertEquals("bar", qName.getPrefix());
49: assertEquals("", qName.getNamespaceURI());
50: assertEquals("foo", qName.getLocalPart());
51: }
52: }
|