KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > util > xml > test > NamespaceTest


1 package org.sapia.util.xml.test;
2
3 import junit.framework.TestCase;
4 import junit.textui.TestRunner;
5 import org.sapia.util.xml.Namespace;
6
7 /**
8  *
9  *
10  * @author Jean-Cedric Desrochers
11  *
12  * <dl>
13  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
14  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
15  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
16  * </dl>
17  */

18 public class NamespaceTest extends TestCase{
19
20   public static void main(String JavaDoc[] args) {
21     TestRunner.run(NamespaceTest.class);
22   }
23
24   public NamespaceTest(String JavaDoc aName) {
25     super(aName);
26   }
27
28   /**
29    *
30    */

31   public void testEmptyNamespace() throws Exception JavaDoc {
32     Namespace aNamespace = new Namespace();
33     assertNotNull(aNamespace);
34     assertNull(aNamespace.getURI());
35     assertNull(aNamespace.getPrefix());
36     assertTrue(aNamespace.hashCode() != 0);
37     assertEquals(aNamespace, new Namespace());
38   }
39
40   /**
41    *
42    */

43   public void testValidNamespace() throws Exception JavaDoc {
44     Namespace aNamespace = new Namespace();
45     aNamespace.setURI("http://schemas.sapia.org/");
46     aNamespace.setPrefix("A");
47     assertNotNull(aNamespace);
48     assertEquals("http://schemas.sapia.org/", aNamespace.getURI());
49     assertEquals("A", aNamespace.getPrefix());
50     assertTrue(aNamespace.hashCode() != 0);
51     assertTrue(!aNamespace.equals(new Namespace()));
52     assertEquals(aNamespace, new Namespace("http://schemas.sapia.org/", "A"));
53   }
54 }
55
Popular Tags