KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > simulator > app > DSOApplicationBuilderTest


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

4 package com.tc.simulator.app;
5
6 import com.tc.config.schema.SettableConfigItem;
7 import com.tc.config.schema.setup.L1TVSConfigurationSetupManager;
8 import com.tc.config.schema.setup.L2TVSConfigurationSetupManager;
9 import com.tc.config.schema.setup.TestTVSConfigurationSetupManagerFactory;
10 import com.tc.object.BaseDSOTestCase;
11 import com.tc.object.bytecode.hook.impl.PreparedComponentsFromL2Connection;
12 import com.tc.object.config.DSOClientConfigHelper;
13 import com.tc.server.TCServerImpl;
14 import com.tc.simulator.listener.MockListenerProvider;
15 import com.tcsimulator.SimpleApplicationConfig;
16
17 public class DSOApplicationBuilderTest extends BaseDSOTestCase {
18
19   private DSOApplicationBuilder builder;
20   private SimpleApplicationConfig applicationConfig;
21   private TCServerImpl server;
22
23   public void setUp() throws Exception JavaDoc {
24     TestTVSConfigurationSetupManagerFactory factory = super.configFactory();
25     L2TVSConfigurationSetupManager manager = factory.createL2TVSConfigurationSetupManager(null);
26
27     // minor hack to make server listen on an OS assigned port
28
((SettableConfigItem) factory.l2DSOConfig().listenPort()).setValue(0);
29
30     server = new TCServerImpl(manager);
31     server.start();
32
33     DSOClientConfigHelper configHelper = configHelper();
34
35     configHelper.addExcludePattern(SimpleApplicationConfig.class.getName());
36
37     makeClientUsePort(server.getDSOListenPort());
38
39     this.applicationConfig = new SimpleApplicationConfig();
40
41     L1TVSConfigurationSetupManager configManager = factory.createL1TVSConfigurationSetupManager();
42     PreparedComponentsFromL2Connection components = new PreparedComponentsFromL2Connection(configManager);
43
44     this.builder = new DSOApplicationBuilder(configHelper, this.applicationConfig, components);
45   }
46
47   public void testNewApplication() throws Exception JavaDoc {
48     Application application = this.builder.newApplication("test", new MockListenerProvider());
49     assertEquals(this.applicationConfig.getApplicationClassname(), application.getClass().getName());
50   }
51
52 }
53
Popular Tags