KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > model > test > ModelMetaDataTest


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.test;
8
9
10 import junit.framework.TestCase;
11
12 import com.inversoft.verge.mvc.model.ModelMVCInfo;
13
14
15 /**
16  * <p>
17  * This class stores the tests for the model meta data.
18  * </p>
19  *
20  * @author Brian Pontarelli
21  * @since 2.0
22  * @version 2.0
23  */

24 public class ModelMetaDataTest extends TestCase {
25
26     /**
27      * Constructs a new <code>ModelMetaDataTest</code>
28      *
29      * @param name
30      */

31     public ModelMetaDataTest(String JavaDoc name) {
32         super(name);
33     }
34
35
36     /**
37      * tests that the model meta data works
38      */

39     public void testAll() {
40         try {
41             String JavaDoc encoded = "testName|testSystem|testDefinition";
42             ModelMVCInfo md = new ModelMVCInfo(encoded);
43             assertEquals("testName", md.getInputName());
44             assertEquals("testSystem", md.getModelSystem());
45             assertEquals("testDefinition", md.getModelDefinition());
46             String JavaDoc newEncoded = md.encode();
47             assertTrue("should be equal", newEncoded.equals(encoded));
48
49             encoded = "testName|testSystem|testDefinition|param1=value1|param2=value2";
50             String JavaDoc altEncoded = "testName|testSystem|testDefinition|param2=value2|param1=value1";
51             md = new ModelMVCInfo(encoded);
52             assertEquals("testName", md.getInputName());
53             assertEquals("testSystem", md.getModelSystem());
54             assertEquals("testDefinition", md.getModelDefinition());
55             assertTrue("should have param1", md.getExtraParams().get("param1") != null &&
56                 md.getExtraParams().get("param1").equals("value1"));
57             assertTrue("should have param2", md.getExtraParams().get("param2") != null &&
58                 md.getExtraParams().get("param2").equals("value2"));
59             newEncoded = md.encode();
60             assertTrue("should be equal", newEncoded.equals(encoded) ||
61                 newEncoded.equals(altEncoded));
62         } catch (Exception JavaDoc e) {
63             fail(e.toString());
64         }
65     }
66 }
Popular Tags