KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > NewCommonL2ConfigObjectTest


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