KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > config > ConfigLoaderTest


1 /*
2  * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.config;
5
6 import org.apache.xmlbeans.XmlException;
7
8 import com.tc.config.Loader;
9 import com.tc.config.schema.setup.ConfigurationSetupException;
10 import com.tc.logging.NullTCLogger;
11 import com.tc.logging.TCLogger;
12 import com.terracottatech.config.Application;
13 import com.terracottatech.config.TcConfigDocument;
14 import com.terracottatech.config.TcConfigDocument.TcConfig;
15
16 import java.io.IOException JavaDoc;
17 import java.lang.reflect.InvocationHandler JavaDoc;
18 import java.lang.reflect.Method JavaDoc;
19 import java.lang.reflect.Proxy JavaDoc;
20
21 import junit.framework.TestCase;
22
23 public class ConfigLoaderTest extends TestCase {
24
25   public void testEmptyConfig() throws Exception JavaDoc {
26     test("empty-tc-config.xml");
27     test("tc-config-dso.xml");
28     test("tc-config-chatter.xml");
29     test("tc-config-coordination.xml");
30     test("tc-config-inventory.xml");
31     
32     test("tc-config-jtable.xml");
33     test("tc-config-l2.xml");
34     test("tc-config-scoordination.xml");
35     test("tc-config-sevents.xml");
36     test("tc-config-sharededitor.xml");
37     test("tc-config-sharedqueue.xml");
38     test("tc-config-sjmx.xml");
39     test("tc-config-swebflow.xml");
40     
41     test("anothersingleton-tc-config.xml");
42     test("aop-tc-config.xml");
43     test("app-ctx-matching-tc-config.xml");
44     test("appctxdef-tc-config.xml");
45     test("customscoped-tc-config.xml");
46     test("empty-tc-config.xml");
47     test("event-tc-config.xml");
48     test("hibernate-tc-config.xml");
49     test("init2-tc-config.xml");
50     test("interceptor-via-postprocessor-tc-config.xml");
51     test("lifecycle-tc-config.xml");
52     test("multibeandef-tc-config.xml");
53     test("multicontext-tc-config.xml");
54     test("multifile-context-tc-config.xml");
55     test("parent-child-tc-config.xml");
56     test("proxiedbean-tc-config.xml");
57     test("redeployment-tc-config.xml");
58     test("referenceandreplication-tc-config.xml");
59     test("scopedbeans-tc-config.xml");
60     test("sellitem-tc-config.xml");
61     test("sessionscoped-tc-config.xml");
62     test("sharedlock-tc-config.xml");
63     test("singleton-parent-child-tc-config.xml");
64     test("thread-coordination-tc-config.xml");
65     test("webflow-tc-config.xml");
66   }
67
68
69   private void test(String JavaDoc name) throws XmlException, IOException JavaDoc, ConfigurationSetupException {
70     TcConfigDocument tcConfigDocument = new Loader().parse(getClass().getResourceAsStream(name));
71     TcConfig tcConfig = tcConfigDocument.getTcConfig();
72     Application application = tcConfig.getApplication();
73     
74     if(application!=null) {
75       TCLogger logger = new NullTCLogger();
76
77       DSOClientConfigHelper config = (DSOClientConfigHelper) Proxy
78           .newProxyInstance(getClass().getClassLoader(), new Class JavaDoc[] { DSOClientConfigHelper.class },
79                             new InvocationHandler JavaDoc() {
80                               public Object JavaDoc invoke(Object JavaDoc proxy, Method JavaDoc method, Object JavaDoc[] args) throws Throwable JavaDoc {
81                                 return null;
82                               }
83                             });
84     
85       ConfigLoader loader = new ConfigLoader(config, logger);
86       loader.loadDsoConfig(application.getDso());
87       loader.loadSpringConfig(application.getSpring());
88     }
89   }
90
91 }
92
93
Popular Tags