01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.simulator.app;
05:
06: import com.tc.config.schema.setup.L1TVSConfigurationSetupManager;
07: import com.tc.config.schema.setup.L2TVSConfigurationSetupManager;
08: import com.tc.config.schema.setup.TestTVSConfigurationSetupManagerFactory;
09: import com.tc.object.BaseDSOTestCase;
10: import com.tc.object.bytecode.hook.impl.PreparedComponentsFromL2Connection;
11: import com.tc.object.config.DSOClientConfigHelper;
12: import com.tc.server.TCServerImpl;
13: import com.tc.simulator.listener.MockListenerProvider;
14: import com.tcsimulator.SimpleApplicationConfig;
15:
16: public class DSOApplicationBuilderTest extends BaseDSOTestCase {
17:
18: private DSOApplicationBuilder builder;
19: private SimpleApplicationConfig applicationConfig;
20: private TCServerImpl server;
21:
22: public void setUp() throws Exception {
23: TestTVSConfigurationSetupManagerFactory factory = super
24: .configFactory();
25: L2TVSConfigurationSetupManager manager = factory
26: .createL2TVSConfigurationSetupManager(null);
27:
28: // minor hack to make server listen on an OS assigned port
29: // ((SettableConfigItem) factory.l2DSOConfig().listenPort()).setValue(0);
30:
31: server = new TCServerImpl(manager);
32: server.start();
33:
34: DSOClientConfigHelper configHelper = configHelper();
35:
36: configHelper.addExcludePattern(SimpleApplicationConfig.class
37: .getName());
38:
39: makeClientUsePort(server.getDSOListenPort());
40:
41: this .applicationConfig = new SimpleApplicationConfig();
42:
43: L1TVSConfigurationSetupManager configManager = factory
44: .createL1TVSConfigurationSetupManager();
45: PreparedComponentsFromL2Connection components = new PreparedComponentsFromL2Connection(
46: configManager);
47:
48: this .builder = new DSOApplicationBuilder(configHelper,
49: this .applicationConfig, components);
50: }
51:
52: public void testNewApplication() throws Exception {
53: Application application = this .builder.newApplication("test",
54: new MockListenerProvider());
55: assertEquals(this.applicationConfig.getApplicationClassname(),
56: application.getClass().getName());
57: }
58:
59: }
|