1   /*
2    * $Id: QNamePropertyEditorTestCase.java 12126 2008-06-23 09:14:24Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.config.spring.editors;
12  
13  import org.mule.tck.AbstractMuleTestCase;
14  
15  import javax.xml.namespace.QName;
16  
17  public class QNamePropertyEditorTestCase extends AbstractMuleTestCase
18  {
19  
20      public void testFullQNameString()
21      {
22          QName name = QNamePropertyEditor.convert("qname{e:echo:http://muleumo.org/echo}");
23          assertNotNull(name);
24          assertEquals("e", name.getPrefix());
25          assertEquals("echo", name.getLocalPart());
26          assertEquals("http://muleumo.org/echo", name.getNamespaceURI());
27      }
28  
29      public void testFullQNameStringWithColonsInNamespace()
30      {
31          QName name = QNamePropertyEditor.convert("qname{e:echo:urn:muleumo:echo}");
32          assertNotNull(name);
33          assertEquals("e", name.getPrefix());
34          assertEquals("echo", name.getLocalPart());
35          assertEquals("urn:muleumo:echo", name.getNamespaceURI());
36      }
37  
38      public void testNameAndNamespace()
39      {
40          QName name = QNamePropertyEditor.convert("qname{echo:http://muleumo.org/echo}");
41          assertNotNull(name);
42          assertEquals("http://muleumo.org/echo", name.getNamespaceURI());
43          assertEquals("echo", name.getLocalPart());
44          assertEquals("", name.getPrefix());
45      }
46  
47      public void testNameOnly()
48      {
49          QName name = QNamePropertyEditor.convert("qname{echo}");
50          assertNotNull(name);
51          assertEquals("", name.getNamespaceURI());
52          assertEquals("echo", name.getLocalPart());
53          assertEquals("", name.getPrefix());
54      }
55  
56      public void testNameOnlyWithoutBraces()
57      {
58          QName name = QNamePropertyEditor.convert("echo");
59          assertNotNull(name);
60          assertEquals("", name.getNamespaceURI());
61          assertEquals("echo", name.getLocalPart());
62          assertEquals("", name.getPrefix());
63      }
64  
65  }