KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > jmx > CruiseControlControllerJMXAdaptorTest


1 /*
2  * Created on Oct 1, 2005
3  *
4  * TODO To change the template for this generated file go to
5  * Window - Preferences - Java - Code Style - Code Templates
6  */

7 package net.sourceforge.cruisecontrol.jmx;
8
9 import junit.framework.TestCase;
10 import net.sourceforge.cruisecontrol.CruiseControlController;
11 import net.sourceforge.cruisecontrol.CruiseControlException;
12
13 /**
14  * @author alwick
15  */

16 public class CruiseControlControllerJMXAdaptorTest extends TestCase {
17
18     private CruiseControlControllerJMXAdaptor adaptor;
19
20     protected void setUp() throws Exception JavaDoc {
21         super.setUp();
22         
23         adaptor = new CruiseControlControllerJMXAdaptor(new CruiseControlController());
24     }
25
26     public void testInvalid() throws Exception JavaDoc {
27         try {
28             StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
29             sb.append("<cruisecontrol>");
30             sb.append("<project name=\"test\" foo=\"foo\"></project>");
31             sb.append("</cruisecontrol>");
32             
33             adaptor.validateConfig(sb.toString());
34             fail("No exception found");
35         } catch (CruiseControlException cce) {
36             // expected
37
}
38     }
39
40     public void testValid() throws Exception JavaDoc {
41         try {
42             StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
43             sb.append("<cruisecontrol>");
44             sb.append("<project name=\"test\">");
45             sb.append("<modificationset><cvs localworkingcopy=\".\"/></modificationset>");
46             sb.append("<schedule><ant/></schedule>");
47             sb.append("</project>");
48             sb.append("</cruisecontrol>");
49             
50             adaptor.validateConfig(sb.toString());
51
52         } catch (CruiseControlException cce) {
53             fail("Validation failed on valid config, reason: " + cce.getMessage());
54         }
55     }
56 }
57
Popular Tags