KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > webtest > PluginLocatorTest


1 /********************************************************************************
2  * CruiseControl, a Continuous Integration Toolkit
3  * Copyright (c) 2005 ThoughtWorks, Inc.
4  * 651 W Washington Ave. Suite 600
5  * Chicago, IL 60661 USA
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * + Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * + Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  *
20  * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
21  * names of its contributors may be used to endorse or promote
22  * products derived from this software without specific prior
23  * written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  ********************************************************************************/

37 package net.sourceforge.cruisecontrol.webtest;
38
39 import java.io.IOException JavaDoc;
40
41 import javax.management.AttributeNotFoundException JavaDoc;
42 import javax.management.InstanceNotFoundException JavaDoc;
43 import javax.management.MBeanException JavaDoc;
44 import javax.management.ReflectionException JavaDoc;
45
46 import org.jdom.JDOMException;
47
48 import junit.framework.TestCase;
49 import junit.framework.Assert;
50 import net.sourceforge.cruisecontrol.interceptor.PluginLocator;
51 import net.sourceforge.cruisecontrol.Configuration;
52 import net.sourceforge.cruisecontrol.PluginDetail;
53 import net.sourceforge.cruisecontrol.CruiseControlException;
54 import net.sourceforge.cruisecontrol.PluginType;
55
56 public class PluginLocatorTest extends TestCase {
57     private PluginLocator locator;
58
59     protected void setUp() throws Exception JavaDoc {
60         super.setUp();
61         Configuration configuration = new Configuration("localhost", 7856);
62         locator = new PluginLocator(configuration);
63     }
64
65     public void testGetAvailableBootstrappers() throws AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc,
66             MBeanException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc {
67         PluginDetail[] bootstrappers = locator.getAvailablePlugins("bootstrappers");
68         assertNotNull(bootstrappers);
69         assertTrue(0 < bootstrappers.length);
70     }
71
72     public void testGetAvailablePublishers() throws AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc,
73             MBeanException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc {
74         PluginDetail[] publishers = locator.getAvailablePlugins("publishers");
75         assertNotNull(publishers);
76         assertTrue(0 < publishers.length);
77     }
78
79     public void testGetAvailableSourceControls() throws AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc,
80             MBeanException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc {
81         PluginDetail[] sourceControls = locator.getAvailablePlugins("modificationset");
82         assertNotNull(sourceControls);
83         assertTrue(0 < sourceControls.length);
84     }
85
86     public void testGetConfiguredListeners() throws AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc,
87             MBeanException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc, CruiseControlException, JDOMException {
88         PluginDetail[] listeners = locator.getConfiguredPlugins("connectfour", "listener");
89         assertNotNull(listeners);
90         assertTrue(1 == listeners.length);
91     }
92
93     public void testGetConfiguredBootstrappers() throws AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc,
94             MBeanException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc, CruiseControlException, JDOMException {
95         PluginDetail[] bootstrappers = locator.getConfiguredPlugins("connectfour", "bootstrapper");
96         assertNotNull(bootstrappers);
97         assertTrue(1 == bootstrappers.length);
98     }
99
100     public void testGetConfiguredSourceControls() throws AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc,
101             MBeanException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc, CruiseControlException, JDOMException {
102         PluginDetail[] sourceControls = locator.getConfiguredPlugins("connectfour", "sourcecontrol");
103         assertNotNull(sourceControls);
104         assertTrue(1 == sourceControls.length);
105     }
106
107     public void testGetCVSDetail() throws AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc, MBeanException JavaDoc,
108             ReflectionException JavaDoc, IOException JavaDoc {
109         PluginDetail cvsDetail = locator.getPluginDetail("cvs", "sourcecontrol");
110         assertEquals("cvs", cvsDetail.getName());
111         assertEquals("sourcecontrol", cvsDetail.getType().getName());
112         Assert.assertEquals(PluginType.SOURCE_CONTROL, cvsDetail.getType());
113         assertEquals(6, cvsDetail.getRequiredAttributes().length);
114     }
115
116     public void testGetSVNDetail() throws AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc, MBeanException JavaDoc,
117             ReflectionException JavaDoc, IOException JavaDoc {
118         PluginDetail svnDetail = locator.getPluginDetail("svn", "sourcecontrol");
119         assertEquals("svn", svnDetail.getName());
120         assertEquals("sourcecontrol", svnDetail.getType().getName());
121         assertEquals(PluginType.SOURCE_CONTROL, svnDetail.getType());
122         assertEquals(6, svnDetail.getRequiredAttributes().length);
123     }
124 }
125
Popular Tags