KickJava   Java API By Example, From Geeks To Geeks.

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


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