KickJava   Java API By Example, From Geeks To Geeks.

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


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 PublisherDetailsWebTest extends WebTestCase {
43     private static final String JavaDoc BASE = "/cruisecontrol/load-details.jspa?"
44         + "project=connectfour&pluginType=publisher";
45     private static final String JavaDoc FTP_URL = BASE + "&pluginName=ftppublisher";
46     private static final String JavaDoc XSLT_URL = BASE + "&pluginName=xsltlogpublisher";
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 testShouldBeAccessibleFromPublishersPage() {
67         String JavaDoc pluginsUrl = "/cruisecontrol/plugins.jspa?project=connectfour&pluginType=publisher";
68
69         beginAt(pluginsUrl);
70         assertLinkPresentWithText("onsuccess");
71     }
72
73     public void testShouldLoadFTPPublisherConfiguration() {
74         beginAt(FTP_URL);
75         assertFormPresent("ftppublisher-details");
76         assertFormElementPresent("deleteArtifacts");
77         assertFormElementPresent("destDir");
78         assertFormElementPresent("srcDir");
79     }
80
81     public void testShouldLoadXSLTLogPublisherConfiguration() {
82         beginAt(XSLT_URL);
83         assertFormPresent("xsltlogpublisher-details");
84         assertFormElementPresent("directory");
85         assertFormElementPresent("outFileName");
86         assertFormElementPresent("publishOnFail");
87         assertFormElementPresent("xsltFile");
88     }
89
90     public void testShouldSaveFTPPublisherConfiguration() {
91         beginAt(FTP_URL);
92         setWorkingForm("ftppublisher-details");
93         setFormElement("destDir", "/tmp");
94         submit();
95         assertTextPresent("Updated configuration.");
96         assertFormPresent("ftppublisher-details");
97         assertFormElementPresent("destDir");
98         assertTextPresent("/tmp");
99     }
100
101     public void testShouldSaveXSLTLogPublisherConfiguration() {
102         beginAt(XSLT_URL);
103         setWorkingForm("xsltlogpublisher-details");
104         setFormElement("xsltFile", "templates/foobar.xslt");
105         submit();
106         assertTextPresent("Updated configuration.");
107         assertFormPresent("xsltlogpublisher-details");
108         assertFormElementPresent("xsltFile");
109         assertTextPresent("templates/foobar.xslt");
110     }
111
112     public void testShouldAllowUsersToClearFTPPublisherAttributes() {
113         String JavaDoc destDir = "/tmp";
114
115         beginAt(FTP_URL);
116         setWorkingForm("ftppublisher-details");
117         setFormElement("destDir", destDir);
118         submit();
119         assertTextPresent("Updated configuration.");
120         assertTextPresent(destDir);
121
122         gotoPage(FTP_URL);
123         assertTextPresent(destDir);
124         setWorkingForm("ftppublisher-details");
125         setFormElement("destDir", "");
126         submit();
127         assertTextPresent("Updated configuration.");
128         assertTextNotPresent(destDir);
129
130         gotoPage(FTP_URL);
131         assertTextNotPresent(destDir);
132     }
133
134     public void testShouldAllowUsersToClearXSLTLogPublisherAttributes() {
135         String JavaDoc xsltFile = "templates/foo.xslt";
136
137         beginAt(XSLT_URL);
138         setWorkingForm("xsltlogpublisher-details");
139         setFormElement("xsltFile", xsltFile);
140         submit();
141         assertTextPresent("Updated configuration.");
142         assertTextPresent(xsltFile);
143
144         gotoPage(XSLT_URL);
145         assertTextPresent(xsltFile);
146         setWorkingForm("xsltlogpublisher-details");
147         setFormElement("xsltFile", "");
148         submit();
149         assertTextPresent("Updated configuration.");
150         assertTextNotPresent(xsltFile);
151
152         gotoPage(XSLT_URL);
153         assertTextNotPresent(xsltFile);
154     }
155 }
156
Popular Tags