KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.inversoft.config.component.ComponentConfigBuilderRegistry;
11 import com.inversoft.junit.WebTestCase;
12 import com.inversoft.verge.mvc.controller.actionflow.config.ActionFlowConfigBuilder;
13 import com.inversoft.verge.mvc.controller.actionflow.config.ActionFlowConfigRegistry;
14 import com.inversoft.verge.mvc.controller.actionflow.config.ActionHandlerNodeBuilder;
15 import com.inversoft.verge.mvc.controller.actionflow.config.BaseNamespace;
16 import com.inversoft.verge.mvc.controller.actionflow.config.BaseNamespaceBuilder;
17 import com.inversoft.verge.mvc.controller.actionflow.config.Constants;
18 import com.inversoft.verge.mvc.controller.actionflow.config.DefaultTypes;
19 import com.inversoft.verge.mvc.controller.actionflow.config.Namespace;
20 import com.inversoft.verge.mvc.controller.actionflow.config.PresentationNodeBuilder;
21
22
23 /**
24  * <p>
25  * This class contains the TestCases for the registry
26  * </p>
27  *
28  * @author Brian Pontarelli
29  * @since 1.0
30  * @version 1.0
31  */

32 public class ActionFlowConfigRegistryTest extends WebTestCase {
33
34     /**
35      * Constructs a new <code>ActionFlowConfigRegistryTest</code> TestCase instance
36      */

37     public ActionFlowConfigRegistryTest(String JavaDoc name) {
38         super(name);
39         setLocal(true);
40     }
41
42
43     /**
44      * Tests storing and then retrieving works
45      */

46     public void testAll() {
47         /*
48         BaseNode.BaseValues values = new BaseNode.BaseValues();
49         values.name = "test";
50         values.type = "test";
51         ActionHandlerNode action = new ActionHandlerNode(values, namespace);
52         */

53
54         RegistryAdapter registry = new RegistryAdapter();
55         RegistryAdapter.setInstance(registry);
56         try {
57             BaseNamespace namespace = new BaseNamespace("test", DefaultTypes.NAMESPACE);
58             registry.register(namespace);
59             assertTrue("Should be same namespace",
60                 ActionFlowConfigRegistry.getInstance(request).lookup("test") == namespace);
61         } catch (Exception JavaDoc e) {
62             fail(e.toString());
63         }
64     }
65     
66     /**
67      * Tests that the component builders are in the component builder registry
68      */

69     public void testComponents() {
70         try {
71             ComponentConfigBuilderRegistry builderRegistry =
72                 new ComponentConfigBuilderRegistry(ActionFlowConfigBuilder.BUILDERS_BUNDLE);
73             assertTrue("Should have ActionConfigBuilder",
74                 builderRegistry.lookup(ActionFlowConfigBuilder.NAMESPACE_PREFIX +
75                     Constants.NAMESPACE_BUILDER_NAME) != null &&
76                 builderRegistry.lookup(ActionFlowConfigBuilder.NAMESPACE_PREFIX +
77                     Constants.NAMESPACE_BUILDER_NAME) instanceof BaseNamespaceBuilder);
78             assertTrue("Should have FormConfigBuilder",
79                 builderRegistry.lookup(ActionFlowConfigBuilder.NODE_PREFIX +
80                     Constants.ACTION_HANDLER_BUILDER_NAME) != null &&
81                 builderRegistry.lookup(ActionFlowConfigBuilder.NODE_PREFIX +
82                     Constants.ACTION_HANDLER_BUILDER_NAME) instanceof ActionHandlerNodeBuilder);
83             assertTrue("Should have MappingConfigBuilder",
84                 builderRegistry.lookup(ActionFlowConfigBuilder.NODE_PREFIX +
85                     Constants.PRESENTATION_BUILDER_NAME) != null &&
86                 builderRegistry.lookup(ActionFlowConfigBuilder.NODE_PREFIX +
87                     Constants.PRESENTATION_BUILDER_NAME) instanceof PresentationNodeBuilder);
88         } catch (Exception JavaDoc e) {
89             fail(e.toString());
90         }
91     }
92
93     /**
94      * A simple adapter to help test the registry
95      */

96     public static class RegistryAdapter extends ActionFlowConfigRegistry {
97         protected static void setInstance(ActionFlowConfigRegistry instance) {
98             ActionFlowConfigRegistry.setInstance(instance);
99         }
100
101         protected Namespace register(Namespace namespace)
102         throws IllegalArgumentException JavaDoc {
103             return super.register(namespace);
104         }
105     }
106 }
Popular Tags