01: package org.objectweb.celtix.bus.configuration.spring;
02:
03: import javax.xml.XMLConstants;
04: import javax.xml.namespace.QName;
05:
06: import junit.framework.TestCase;
07:
08: import org.objectweb.celtix.tools.generators.spring.SpringUtils;
09:
10: public class SpringUtilsTest extends TestCase {
11:
12: public void testGetBeanClassName() {
13: assertEquals(
14: "com.mycompany.a.b.c.myclass.spring.MyclassBean",
15: SpringUtils
16: .getBeanClassName("http://www.mycompany.com/a/b/c/MyClass"));
17:
18: assertEquals("myclass.spring.MyclassBean", SpringUtils
19: .getBeanClassName("MyClass"));
20: }
21:
22: public void testStringToQName() {
23: QName in = new QName(XMLConstants.XML_NS_URI, "abc");
24: QName out = SpringUtils.stringToQName(in.toString());
25: assertEquals(in.getNamespaceURI(), out.getNamespaceURI());
26: assertEquals(in.getLocalPart(), out.getLocalPart());
27:
28: in = new QName(XMLConstants.NULL_NS_URI, "abc");
29: out = SpringUtils.stringToQName(in.toString());
30: assertEquals(in.getNamespaceURI(), out.getNamespaceURI());
31: assertEquals(in.getLocalPart(), out.getLocalPart());
32:
33: try {
34: SpringUtils.stringToQName("{abc");
35: fail("Expected IllegalArgumentException not thrown.");
36: } catch (IllegalArgumentException ex) {
37: // ignore
38: }
39:
40: out = SpringUtils.stringToQName("{abc}");
41: assertEquals("abc", out.getNamespaceURI());
42: assertEquals("", out.getLocalPart());
43: }
44:
45: }
|