KickJava   Java API By Example, From Geeks To Geeks.

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


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 net.sourceforge.jwebunit.WebTestCase;
40 import net.sourceforge.cruisecontrol.Configuration;
41
42 public class BootstrapperDetailsWebTest extends WebTestCase {
43     private static final String JavaDoc BASE = "/cruisecontrol/load-details.jspa?"
44             + "project=connectfour&pluginType=bootstrapper";
45
46     private static final String JavaDoc CVS_URL = BASE + "&pluginName=cvsbootstrapper";
47
48     private static final String JavaDoc SVN_URL = BASE + "&pluginName=svnbootstrapper";
49
50     private Configuration configuration;
51
52     private String JavaDoc contents;
53
54     protected void setUp() throws Exception JavaDoc {
55         super.setUp();
56
57         getTestContext().setBaseUrl("http://localhost:7854");
58
59         configuration = new Configuration("localhost", 7856);
60         contents = configuration.getConfiguration();
61     }
62
63     protected void tearDown() throws Exception JavaDoc {
64         super.tearDown();
65
66         configuration.setConfiguration(contents);
67     }
68
69     public void testShouldBeAccessibleFromBootstrappersPage() {
70         String JavaDoc pluginsUrl = "/cruisecontrol/plugins.jspa?project=connectfour&pluginType=bootstrapper";
71
72         beginAt(pluginsUrl);
73         assertLinkPresentWithText("cvsbootstrapper");
74     }
75
76     public void testShouldLoadCVSBootstrapperConfiguration() {
77         beginAt(CVS_URL);
78         assertFormPresent("cvsbootstrapper-details");
79         assertFormElementPresent("cvsroot");
80         assertFormElementPresent("file");
81         assertFormElementPresent("localWorkingCopy");
82         assertFormElementPresent("overwriteChanges");
83         assertFormElementPresent("resetStickyTags");
84     }
85
86     public void testShouldLoadSVNBootstrapperConfiguration() {
87         beginAt(SVN_URL);
88         assertFormPresent("svnbootstrapper-details");
89         assertFormElementPresent("file");
90         assertFormElementPresent("localWorkingCopy");
91         assertFormElementPresent("password");
92         assertFormElementPresent("username");
93     }
94
95     public void testShouldSaveCVSBootstrapperConfiguration() {
96         beginAt(CVS_URL);
97         setWorkingForm("cvsbootstrapper-details");
98         setFormElement("localWorkingCopy", "projects/jakarta-commons/cli");
99         submit();
100         assertTextPresent("Updated configuration.");
101         assertFormPresent("cvsbootstrapper-details");
102         assertFormElementPresent("localWorkingCopy");
103         assertTextPresent("projects/jakarta-commons/cli");
104     }
105
106     public void testShouldSaveSVNBootstrapperConfiguration() {
107         beginAt(SVN_URL);
108         setWorkingForm("svnbootstrapper-details");
109         setFormElement("localWorkingCopy", "repos/trunk/foobar");
110         submit();
111         assertTextPresent("Updated configuration.");
112         assertFormPresent("svnbootstrapper-details");
113         assertFormElementPresent("localWorkingCopy");
114         assertTextPresent("repos/trunk/foobar");
115     }
116
117     public void testShouldAllowUsersToClearCVSBootstrapperAttributes() {
118         String JavaDoc cvsroot = "/cvs/foo";
119
120         beginAt(CVS_URL);
121         setWorkingForm("cvsbootstrapper-details");
122         setFormElement("cvsroot", cvsroot);
123         submit();
124         assertTextPresent("Updated configuration.");
125         assertTextPresent(cvsroot);
126
127         gotoPage(CVS_URL);
128         assertTextPresent(cvsroot);
129         setWorkingForm("cvsbootstrapper-details");
130         setFormElement("cvsroot", "");
131         submit();
132         assertTextPresent("Updated configuration.");
133         assertTextNotPresent(cvsroot);
134
135         gotoPage(CVS_URL);
136         assertTextNotPresent(cvsroot);
137     }
138
139     public void testShouldAllowUsersToClearSVNBootstrapperAttributes() {
140         String JavaDoc localWorkingCopy = "/cvs/foo";
141
142         beginAt(SVN_URL);
143         setWorkingForm("svnbootstrapper-details");
144         setFormElement("localWorkingCopy", localWorkingCopy);
145         submit();
146         assertTextPresent("Updated configuration.");
147         assertTextPresent(localWorkingCopy);
148
149         gotoPage(SVN_URL);
150         assertTextPresent(localWorkingCopy);
151         setWorkingForm("svnbootstrapper-details");
152         setFormElement("localWorkingCopy", "");
153         submit();
154         assertTextPresent("Updated configuration.");
155         assertTextNotPresent(localWorkingCopy);
156
157         gotoPage(SVN_URL);
158         assertTextNotPresent(localWorkingCopy);
159     }
160 }
161
Popular Tags