KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > model > repository > test > RepositoryMetaDataTest


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

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

30     public RepositoryMetaDataTest(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             RepositoryMetaData md = new RepositoryMetaData("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("definition != test.string1", md.getDefinition(),
46                 "test.string1");
47             assertNotNull("Should have model handler", md.getModelHandler());
48             assertTrue("Should be repository model handler",
49                 md.getModelHandler() instanceof RepositoryModelHandler);
50         } catch (Exception JavaDoc e) {
51             fail(e.toString());
52         }
53
54         try {
55             RepositoryMetaData md = new RepositoryMetaData("test", "string1");
56             assertEquals("Should have an id of test", md.getID(), "test");
57             assertEquals("Should have an property of string1", md.getProperty(),
58                 "string1");
59             assertEquals("definition != test.string1", md.getDefinition(),
60                 "test.string1");
61             assertNotNull("Should have model handler", md.getModelHandler());
62             assertTrue("Should be repository model handler",
63                 md.getModelHandler() instanceof RepositoryModelHandler);
64         } catch (Exception JavaDoc e) {
65             fail(e.toString());
66         }
67
68         try {
69             RepositoryMetaData md = new RepositoryMetaData("item", null);
70             assertEquals("Should be item", "item", md.getID());
71             assertNull("Should be null", md.getProperty());
72             md.setID("test");
73             assertEquals("Should have an id of test", md.getID(), "test");
74             md.setProperty("string1");
75             assertEquals("Should have an property of string1", md.getProperty(),
76                 "string1");
77             assertNotNull("Should have model handler", md.getModelHandler());
78             assertTrue("Should be repository model handler",
79                 md.getModelHandler() instanceof RepositoryModelHandler);
80         } catch (Exception JavaDoc e) {
81             fail(e.toString());
82         }
83
84         // Tests reuse and changing the property value
85
try {
86             RepositoryMetaData md = new RepositoryMetaData("item", null);
87             assertEquals("Should be item", "item", md.getID());
88             assertNull("Should be null", md.getProperty());
89             md.setProperty("string1");
90             assertEquals("Should have an property of string1", md.getProperty(),
91                 "string1");
92             assertEquals("item.string1", md.getDefinition());
93             md.setProperty("string2");
94             assertEquals("item.string2", md.getDefinition());
95             md.setProperty("foo");
96             assertEquals("item.foo", md.getDefinition());
97         } catch (Exception JavaDoc e) {
98             fail(e.toString());
99         }
100     }
101 }
102
Popular Tags