/** Test parse() with an esoteric token. */ public void testParseWithEsotericToken() { StringNamespace sns = (StringNamespace) StringNamespace.parse("org:!argouml:!m:odel", ":!"); assertEquals(sns.toString(), "org:!argouml:!m:odel"); sns.popNamespaceElement(); assertEquals(sns.toString(), "org:!argouml"); sns.popNamespaceElement(); assertEquals(sns.toString(), "org"); sns.popNamespaceElement(); assertEquals(sns.toString(), ""); assertTrue(sns.isEmpty()); }
/** Test parse() with a UML token. */ public void testParseWithUMLToken() { StringNamespace sns = (StringNamespace) StringNamespace.parse("org::argouml::model", Namespace.UML_NS_TOKEN); assertEquals(sns.toString(), "org::argouml::model"); sns.popNamespaceElement(); assertEquals(sns.toString(), "org::argouml"); sns.popNamespaceElement(); assertEquals(sns.toString(), "org"); sns.popNamespaceElement(); assertEquals(sns.toString(), ""); assertTrue(sns.isEmpty()); }
/** Test parse() with a Java token. */ public void testParseWithJavaToken() { StringNamespace sns = (StringNamespace) StringNamespace.parse("org.argouml.model.", Namespace.JAVA_NS_TOKEN); assertEquals(sns.toString(), "org.argouml.model"); sns.popNamespaceElement(); assertEquals(sns.toString(), "org.argouml"); sns.popNamespaceElement(); assertEquals(sns.toString(), "org"); sns.popNamespaceElement(); assertEquals(sns.toString(), ""); assertTrue(sns.isEmpty()); }
/** Class to test for String toString(String) */ public void testToString() { StringNamespace sns = new StringNamespace("::"); sns.pushNamespaceElement("org"); assertEquals(sns.toString(), "org"); sns.pushNamespaceElement("argouml"); assertEquals(sns.toString(), "org::argouml"); sns.popNamespaceElement(); assertEquals(sns.toString(), "org"); }
/** Test getCommonNamespace(). */ public void testGetCommonNamespace() { StringNamespace sns1 = new StringNamespace(new String[] {"org", "argouml", "model"}, Namespace.UML_NS_TOKEN); StringNamespace sns2 = new StringNamespace(new String[] {"org", "argouml", "model"}, Namespace.UML_NS_TOKEN); StringNamespace result = (StringNamespace) sns1.getCommonNamespace(sns2); assertEquals("org::argouml::model", result.toString()); sns1.popNamespaceElement(); result = (StringNamespace) sns1.getCommonNamespace(sns2); assertEquals("org::argouml", result.toString()); sns1.popNamespaceElement(); result = (StringNamespace) sns1.getCommonNamespace(sns2); assertEquals("org", result.toString()); sns1.popNamespaceElement(); result = (StringNamespace) sns1.getCommonNamespace(sns2); assertEquals("", result.toString()); }