KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > repository > config > test > RepositoryConfigRegistryTest


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.repository.config.test;
8
9
10 import junit.framework.TestCase;
11
12 import com.inversoft.verge.repository.config.Config;
13 import com.inversoft.verge.repository.config.ItemConfig;
14 import com.inversoft.verge.repository.config.RepositoryConfigRegistry;
15 import com.inversoft.verge.util.ScopeConstants;
16
17
18 /**
19  * <p>
20  * This class contains the TestCases for the registry
21  * </p>
22  *
23  * @author Brian Pontarelli
24  * @since 1.0
25  * @version 1.0
26  */

27 public class RepositoryConfigRegistryTest extends TestCase {
28
29     /**
30      * Constructs a new <code>RepositoryConfigRegistryTest</code> TestCase instance
31      */

32     public RepositoryConfigRegistryTest(String JavaDoc name) {
33         super(name);
34     }
35
36
37     /**
38      * Tests that the registry correctly stores the config objects
39      */

40     public void testAll() {
41
42         try {
43             RegistryHelper registry = new RegistryHelper();
44             ItemConfig config1 = new ItemConfig("", ScopeConstants.PAGE_INT,
45                 RepositoryConfigRegistryTest.class);
46             ItemConfig config2 = new ItemConfig("", ScopeConstants.PAGE_INT,
47                 RepositoryConfigRegistryTest.class);
48             registry.register("test1", config1);
49             registry.register("test2", config2);
50
51             assertTrue("Should be 1", registry.lookup("test1") == config1);
52             assertTrue("Should be 2", registry.lookup("test2") == config2);
53         } catch (Exception JavaDoc e) {
54             fail(e.toString());
55         }
56     }
57
58     /**
59      * A simple adapter to help test the registry
60      */

61     public static class RegistryHelper extends RepositoryConfigRegistry {
62         protected void register(String JavaDoc id, Config config) {
63             super.register(id, config);
64         }
65     }
66 }
67
Popular Tags