KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > model > actionflow > test > ActionFlowModelMetaDataTest


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.model.actionflow.test;
8
9
10 import com.inversoft.junit.WebTestCase;
11 import com.inversoft.verge.mvc.model.DefaultModelHandler;
12 import com.inversoft.verge.mvc.model.actionflow.ActionFlowModelMetaData;
13
14
15 /**
16  * <p>
17  * This class contains the TestCases for the action flow
18  * model meta data
19  * </p>
20  *
21  * @author Brian Pontarelli
22  * @since 2.0
23  * @version 2.0
24  */

25 public class ActionFlowModelMetaDataTest extends WebTestCase {
26
27     /**
28      * Constructs a new <code>ActionFlowModelMetaDataTest</code> TestCase instance
29      */

30     public ActionFlowModelMetaDataTest(String JavaDoc name) {
31         super(name);
32         setLocal(true);
33     }
34
35
36     /**
37      * Tests the meta data works correctly
38      */

39     public void testAll() {
40         try {
41             ActionFlowModelMetaData md = new ActionFlowModelMetaData("test.string1");
42             assertEquals("Should have an id of test", md.getID(), "test");
43             assertEquals("Should have an property of string1", md.getProperty(),
44                 "string1");
45             assertEquals("Should have an definition of test.string1", "test.string1",
46                 md.getDefinition());
47             assertNotNull("Should have model handler", md.getModelHandler());
48             assertTrue("Should have web model handler",
49                 md.getModelHandler() instanceof DefaultModelHandler);
50         } catch (Exception JavaDoc e) {
51             fail(e.toString());
52         }
53
54         try {
55             ActionFlowModelMetaData md = new ActionFlowModelMetaData("test",
56                 "string1");
57             assertEquals("Should have an id of test", md.getID(), "test");
58             assertEquals("Should have an property of string1", md.getProperty(),
59                 "string1");
60             assertEquals("Should be the same definition", "test.string1", md.getDefinition());
61             assertNotNull("Should have model handler", md.getModelHandler());
62             assertTrue("Should have web model handler",
63                 md.getModelHandler() instanceof DefaultModelHandler);
64         } catch (Exception JavaDoc e) {
65             fail(e.toString());
66         }
67
68         // Test that reusing the md and changing the property works
69
try {
70             ActionFlowModelMetaData md = new ActionFlowModelMetaData("item", null);
71             assertEquals("Should be item", "item", md.getID());
72             assertNull("Should be null", md.getProperty());
73             md.setProperty("string1");
74             assertEquals("Should have an property of string1", md.getProperty(),
75                 "string1");
76             assertEquals("item.string1", md.getDefinition());
77             md.setProperty("string2");
78             assertEquals("item.string2", md.getDefinition());
79             md.setProperty("foo");
80             assertEquals("item.foo", md.getDefinition());
81         } catch (Exception JavaDoc e) {
82             fail(e.toString());
83         }
84     }
85 }
86
Popular Tags