KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > controller > actionflow > config > test > NamespaceBuilderTest


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.controller.actionflow.config.test;
8
9
10 import org.jdom.Element;
11
12 import com.inversoft.config.ConfigurationException;
13 import com.inversoft.junit.WebTestCase;
14 import com.inversoft.verge.mvc.controller.actionflow.config.BaseNamespaceBuilder;
15 import com.inversoft.verge.mvc.controller.actionflow.config.Namespace;
16 import com.inversoft.verge.mvc.controller.actionflow.config.NamespaceBuilder;
17
18
19 /**
20  * <p>
21  * This class stores the test for the namespace builder
22  * </p>
23  *
24  * @author Brian Pontarelli
25  * @since 2.0
26  * @version 2.0
27  */

28 public class NamespaceBuilderTest extends WebTestCase {
29
30     /**
31      * Constructor for NamespaceBuilderTest.
32      * @param name
33      */

34     public NamespaceBuilderTest(String JavaDoc name) {
35         super(name);
36         setLocal(true);
37     }
38
39     /**
40      * Tests the BaseNamespaceBuilder
41      */

42     public void testBaseNamespaceFactory() {
43
44         // Test success
45
NamespaceBuilder factory = new BaseNamespaceBuilder();
46
47         Element element = new Element("namespace");
48         element.setAttribute("name", "foo");
49
50         try {
51             Namespace namespace = factory.build(element);
52             assertTrue("Should have name of foo", namespace.getName().equals("foo"));
53         } catch (ConfigurationException be) {
54             fail(be.toString());
55         }
56
57         // Test failure
58
element = new Element("namespace");
59
60         try {
61             /*Namespace namespace =*/ factory.build(element);
62             fail("Should have failed because namespace has no name");
63         } catch (ConfigurationException be) {
64             assertTrue("There should be errors", !be.getErrors().isEmpty());
65             System.out.println(be.toString());
66         }
67     }
68 }
Popular Tags