1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.xml.namespace;
18
19 import javax.xml.namespace.QName;
20
21 import junit.framework.TestCase;
22
23 public class QNameEditorTest extends TestCase {
24
25 private QNameEditor editor;
26
27 protected void setUp() throws Exception {
28 editor = new QNameEditor();
29 }
30
31 public void testNamespaceLocalPartPrefix() throws Exception {
32 QName qname = new QName("namespace", "localpart", "prefix");
33 doTest(qname);
34 }
35
36 public void testNamespaceLocalPart() throws Exception {
37 QName qname = new QName("namespace", "localpart");
38 doTest(qname);
39 }
40
41 public void testLocalPart() throws Exception {
42 QName qname = new QName("localpart");
43 doTest(qname);
44 }
45
46 private void doTest(QName qname) {
47 editor.setValue(qname);
48 String text = editor.getAsText();
49 assertNotNull("getAsText returns null", text);
50 editor.setAsText(text);
51 QName result = (QName) editor.getValue();
52 assertNotNull("getValue returns null", result);
53 assertEquals("Parsed QName local part is not equal to original", qname.getLocalPart(), result.getLocalPart());
54 assertEquals("Parsed QName prefix is not equal to original", qname.getPrefix(), result.getPrefix());
55 assertEquals("Parsed QName namespace is not equal to original", qname.getNamespaceURI(),
56 result.getNamespaceURI());
57 }
58 }