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.config.schema;
05:
06: import org.apache.xmlbeans.XmlObject;
07:
08: import com.terracottatech.config.Server;
09: import com.terracottatech.config.TcConfigDocument.TcConfig;
10:
11: import java.io.File;
12:
13: /**
14: * Unit/subsystem test for {@link NewCommonL2ConfigObject}.
15: */
16: public class NewCommonL2ConfigObjectTest extends ConfigObjectTestBase {
17:
18: private NewCommonL2ConfigObject object;
19:
20: public void setUp() throws Exception {
21: super .setUp(Server.class);
22: this .object = new NewCommonL2ConfigObject(context());
23: }
24:
25: protected XmlObject getBeanFromTcConfig(TcConfig domainConfig)
26: throws Exception {
27: return domainConfig.getServers().getServerArray(0);
28: }
29:
30: public void testConstruction() throws Exception {
31: try {
32: new NewCommonL2ConfigObject(null);
33: fail("Didn't get NPE on no context");
34: } catch (NullPointerException npe) {
35: // ok
36: }
37: }
38:
39: public void testDataPath() throws Exception {
40: addListeners(object.dataPath());
41:
42: assertEquals(new File("data"), object.dataPath().getFile());
43: checkNoListener();
44:
45: builder().getServers().getL2s()[0].setData("foobar");
46: setConfig();
47:
48: assertEquals(new File("foobar"), object.dataPath().getFile());
49: checkListener(new File("data"), new File("foobar"));
50: }
51:
52: public void testLogsPath() throws Exception {
53: addListeners(object.logsPath());
54:
55: assertEquals(new File("logs"), object.logsPath().getFile());
56: checkNoListener();
57:
58: builder().getServers().getL2s()[0].setLogs("foobar");
59: setConfig();
60:
61: assertEquals(new File("foobar"), object.logsPath().getFile());
62: checkListener(new File("logs"), new File("foobar"));
63: }
64:
65: public void testJmxPort() throws Exception {
66: addListeners(object.jmxPort());
67:
68: assertEquals(9520, object.jmxPort().getInt());
69: checkNoListener();
70:
71: builder().getServers().getL2s()[0].setJMXPort("3285");
72: setConfig();
73:
74: assertEquals(3285, object.jmxPort().getInt());
75: checkListener(new Integer(9520), new Integer(3285));
76: }
77:
78: }
|