KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > PluginTypeTest


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;
38
39 import junit.framework.TestCase;
40 import net.sourceforge.cruisecontrol.bootstrappers.CVSBootstrapper;
41 import net.sourceforge.cruisecontrol.builders.AntBuilder;
42 import net.sourceforge.cruisecontrol.buildloggers.MergeLogger;
43 import net.sourceforge.cruisecontrol.labelincrementers.DefaultLabelIncrementer;
44 import net.sourceforge.cruisecontrol.listeners.CurrentBuildStatusListener;
45 import net.sourceforge.cruisecontrol.publishers.FTPPublisher;
46 import net.sourceforge.cruisecontrol.publishers.email.EmailMapping;
47 import net.sourceforge.cruisecontrol.publishers.email.PropertiesMapper;
48 import net.sourceforge.cruisecontrol.sourcecontrols.ConcurrentVersionsSystem;
49
50 public class PluginTypeTest extends TestCase {
51
52     public void testGettingTypeForPlugin() {
53         PluginType type = PluginType.find(CVSBootstrapper.class);
54         assertSame(PluginType.BOOTSTRAPPER, type);
55         type = PluginType.find(ProjectConfig.Bootstrappers.class);
56         assertSame(PluginType.BOOTSTRAPPERS, type);
57
58         type = PluginType.find(AntBuilder.class);
59         assertSame(PluginType.BUILDER, type);
60
61         type = PluginType.find(CCDateFormat.class);
62         assertSame(PluginType.DATE_FORMAT, type);
63
64         type = PluginType.find(DefaultLabelIncrementer.class);
65         assertSame(PluginType.LABEL_INCREMENTER, type);
66
67         type = PluginType.find(CurrentBuildStatusListener.class);
68         assertSame(PluginType.LISTENER, type);
69         type = PluginType.find(ProjectConfig.Listeners.class);
70         assertSame(PluginType.LISTENERS, type);
71
72         type = PluginType.find(Log.class);
73         assertSame(PluginType.LOG, type);
74
75         type = PluginType.find(EmailMapping.class);
76         assertSame(PluginType.MAP, type);
77
78         type = PluginType.find(MergeLogger.class);
79         assertSame(PluginType.MERGE_LOGGER, type);
80
81         type = PluginType.find(ModificationSet.class);
82         assertSame(PluginType.MODIFICATION_SET, type);
83
84         type = PluginType.find(ProjectConfig.class);
85         assertSame(PluginType.PROJECT, type);
86
87         type = PluginType.find(PropertiesMapper.class);
88         assertSame(PluginType.EMAIL_MAPPER, type);
89
90         type = PluginType.find(FTPPublisher.class);
91         assertSame(PluginType.PUBLISHER, type);
92         type = PluginType.find(ProjectConfig.Publishers.class);
93         assertSame(PluginType.PUBLISHERS, type);
94
95         type = PluginType.find(Schedule.class);
96         assertSame(PluginType.SCHEDULE, type);
97
98         type = PluginType.find(ConcurrentVersionsSystem.class);
99         assertSame(PluginType.SOURCE_CONTROL, type);
100     }
101
102     public void testExceptions() {
103         try {
104             PluginType.find(Object JavaDoc.class);
105             fail("Should not be able to find plugin type for Object.");
106         } catch (IllegalArgumentException JavaDoc expected) {
107             assertEquals("class java.lang.Object is not a CruiseControl plugin.", expected.getMessage());
108         }
109
110         try {
111             PluginType.find((Class JavaDoc) null);
112             fail("Should not be able to find plugin type for null.");
113         } catch (IllegalArgumentException JavaDoc expected) {
114             assertEquals("null is not a CruiseControl plugin.", expected.getMessage());
115         }
116
117         try {
118             PluginType.find((String JavaDoc) null);
119             fail("Should not be able to find plugin type for null.");
120         } catch (IllegalArgumentException JavaDoc expected) {
121             assertEquals("null is not a CruiseControl plugin.", expected.getMessage());
122         }
123     }
124
125     public void testGettingTypes() {
126         PluginType[] types = PluginType.getTypes();
127
128         assertNotNull(types);
129         assertTrue(0 < types.length);
130     }
131
132     public void testGettingNameForPlugin() {
133         PluginType type = PluginType.find(CVSBootstrapper.class);
134         assertEquals("bootstrapper", type.getName());
135
136         type = PluginType.find(FTPPublisher.class);
137         assertEquals("publisher", type.getName());
138
139         type = PluginType.find(ConcurrentVersionsSystem.class);
140         assertEquals("sourcecontrol", type.getName());
141     }
142
143     public void testEquals() {
144         assertFalse(PluginType.BOOTSTRAPPER.equals(null));
145         assertFalse(PluginType.BOOTSTRAPPER.equals(new Object JavaDoc()));
146         assertFalse(PluginType.BOOTSTRAPPER.equals(PluginType.SOURCE_CONTROL));
147         assertTrue(PluginType.BOOTSTRAPPER.equals(PluginType.BOOTSTRAPPER));
148     }
149
150     public void testToString() {
151         assertEquals("bootstrapper", PluginType.BOOTSTRAPPER.toString());
152         assertEquals("publisher", PluginType.PUBLISHER.toString());
153         assertEquals("sourcecontrol", PluginType.SOURCE_CONTROL.toString());
154     }
155 }
156
Popular Tags