View Javadoc

1   /*
2    * $Id: QNamePropertyEditorTestCase.java 22377 2011-07-11 12:41:42Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.junit4.AbstractMuleTestCase;
14  
15  import javax.xml.namespace.QName;
16  
17  import org.junit.Test;
18  
19  import static org.junit.Assert.assertEquals;
20  import static org.junit.Assert.assertNotNull;
21  
22  public class QNamePropertyEditorTestCase extends AbstractMuleTestCase
23  {
24  
25      @Test
26      public void testFullQNameString()
27      {
28          QName name = QNamePropertyEditor.convert("qname{e:echo:http://muleumo.org/echo}");
29          assertNotNull(name);
30          assertEquals("e", name.getPrefix());
31          assertEquals("echo", name.getLocalPart());
32          assertEquals("http://muleumo.org/echo", name.getNamespaceURI());
33      }
34  
35      @Test
36      public void testFullQNameStringWithColonsInNamespace()
37      {
38          QName name = QNamePropertyEditor.convert("qname{e:echo:urn:muleumo:echo}");
39          assertNotNull(name);
40          assertEquals("e", name.getPrefix());
41          assertEquals("echo", name.getLocalPart());
42          assertEquals("urn:muleumo:echo", name.getNamespaceURI());
43      }
44  
45      @Test
46      public void testNameAndNamespace()
47      {
48          QName name = QNamePropertyEditor.convert("qname{echo:http://muleumo.org/echo}");
49          assertNotNull(name);
50          assertEquals("http://muleumo.org/echo", name.getNamespaceURI());
51          assertEquals("echo", name.getLocalPart());
52          assertEquals("", name.getPrefix());
53      }
54  
55      @Test
56      public void testNameOnly()
57      {
58          QName name = QNamePropertyEditor.convert("qname{echo}");
59          assertNotNull(name);
60          assertEquals("", name.getNamespaceURI());
61          assertEquals("echo", name.getLocalPart());
62          assertEquals("", name.getPrefix());
63      }
64  
65      @Test
66      public void testNameOnlyWithoutBraces()
67      {
68          QName name = QNamePropertyEditor.convert("echo");
69          assertNotNull(name);
70          assertEquals("", name.getNamespaceURI());
71          assertEquals("echo", name.getLocalPart());
72          assertEquals("", name.getPrefix());
73      }
74  
75  }