KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > repository > test > RepositoryBeanTest


1 package com.inversoft.verge.repository.test;
2
3
4 import java.util.ResourceBundle JavaDoc;
5
6 import com.inversoft.beans.BeanException;
7 import com.inversoft.config.ConfigFactoryRegistry;
8 import com.inversoft.junit.WebTestCase;
9 import com.inversoft.verge.config.VergeConfigConstants;
10 import com.inversoft.verge.config.VergeConfigMediator;
11 import com.inversoft.verge.repository.RepositoryBean;
12 import com.inversoft.verge.repository.config.Config;
13 import com.inversoft.verge.repository.config.RepositoryConfigRegistry;
14
15
16 /**
17  * <p>
18  * This class tests the RepositoryBean object.
19  * </p>
20  *
21  * @author Brian Pontarelli
22  */

23 public class RepositoryBeanTest extends WebTestCase {
24
25     /**
26      * Constructs a new <code>RepositoryBeanTest</code>.
27      */

28     public RepositoryBeanTest(String JavaDoc name) {
29         super(name);
30         setLocal(true);
31     }
32
33
34     /**
35      * Test that the repository bean can be found
36      */

37     public void testLookup() {
38         // Add the initParameter for local testing
39
if (isLocal()) {
40             getContext().setInitParameter(VergeConfigConstants.CONTEXT_PARAM,
41                 "src/com/inversoft/verge/repository/test/test-config.xml");
42         }
43
44         try {
45             ResourceBundle JavaDoc bundle = ResourceBundle.getBundle(
46                 "com.inversoft.verge.config.ConfigFactories");
47             ConfigFactoryRegistry.load(bundle);
48             new VergeConfigMediator().mediate(context);
49             //Repository.initialize();
50
} catch (Exception JavaDoc e) {
51             fail(e.toString());
52         }
53
54         try {
55             RepositoryBean bean = new RepositoryBean("item1", request);
56             Object JavaDoc item1 = bean.getInstance(request);
57             assertNotNull(item1);
58             assertEquals(SimpleItem.class, item1.getClass());
59         } catch (BeanException be) {
60             fail(be.toString());
61         }
62
63         try {
64             RepositoryBean bean = new RepositoryBean("user", request);
65             Object JavaDoc user = bean.getInstance(request);
66             assertNotNull(user);
67             assertEquals(SimpleItem.class, user.getClass());
68         } catch (BeanException be) {
69             fail(be.toString());
70         }
71
72         try {
73             Config config =
74                 RepositoryConfigRegistry.getInstance(request).lookup("common");
75             RepositoryBean bean = new RepositoryBean(config);
76             Object JavaDoc user = bean.getInstance(request);
77             assertNotNull(user);
78             assertEquals(SimpleItem2.class, user.getClass());
79         } catch (BeanException be) {
80             fail(be.toString());
81         }
82     }
83 }
Popular Tags