001: /********************************************************************************
002: * CruiseControl, a Continuous Integration Toolkit
003: * Copyright (c) 2007, ThoughtWorks, Inc.
004: * 200 E. Randolph, 25th Floor
005: * Chicago, IL 60601 USA
006: * All rights reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * + Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * + Redistributions in binary form must reproduce the above
016: * copyright notice, this list of conditions and the following
017: * disclaimer in the documentation and/or other materials provided
018: * with the distribution.
019: *
020: * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
021: * names of its contributors may be used to endorse or promote
022: * products derived from this software without specific prior
023: * written permission.
024: *
025: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
026: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
027: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
028: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
029: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
030: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
031: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
032: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
033: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
034: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
035: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
036: ********************************************************************************/package net.sourceforge.cruisecontrol.dashboard.jwebunittests;
037:
038: import org.apache.commons.lang.StringUtils;
039:
040: public class BuildDetailTest extends BaseFunctionalTest {
041:
042: public void testShouldShowArtifactsForFailedBuild() {
043: tester.beginAt("/tab/build/detail/project1/20051209122104");
044: tester.assertTextPresent("Artifacts");
045: tester.assertTextPresent("Merged Check Style");
046: tester.assertTextPresent("Line has trailing spaces.");
047: tester.assertLinkPresentWithExactText("#123");
048: }
049:
050: public void testShouldNotShowArtifactsIfNoPublishersInConfigFile()
051: throws Exception {
052: tester
053: .beginAt("/tab/build/detail/projectWithoutPublishers/20060704155755");
054: tester.assertLinkNotPresentWithText("artifact.txt");
055: }
056:
057: public void testShouldNotShowArtifactsForProjectsWithoutConfiguration()
058: throws Exception {
059: tester
060: .beginAt("/tab/build/detail/projectWithoutConfiguration/20060704155710");
061: tester.assertLinkNotPresentWithText("artifact.txt");
062: }
063:
064: public void testShouldBeAbleToOpenProjectNameWithSpace()
065: throws Exception {
066: tester.beginAt("/tab/build/detail/project%20space");
067: tester.assertTextPresent("project space");
068: }
069:
070: public void testShouldShowDurationFromLastSuccessfulBuild()
071: throws Exception {
072: tester
073: .beginAt("/tab/build/detail/projectWithoutConfiguration/20060704160010");
074: tester.assertTextPresent("Previous successful build");
075: tester.assertTextPresent("minutes");
076: tester.assertTextPresent("ago");
077: }
078:
079: public void testShouldShowErrorsAndWarningTabAndBuildErrorMessages()
080: throws Exception {
081: tester.beginAt("/tab/build/detail/project1/20051209122104");
082: tester.assertTextPresent("Errors and Warnings");
083: tester.assertTextPresent("Detected OS: Windows XP");
084: tester.assertTextPresent("Cannot find something");
085: String projectsFolder = "'C:\\pdj\\src\\cruisecontrol\\target\\webtest\\cruisecontrol-bin-2.4.0-dev\\projects";
086: tester
087: .assertTextPresent("Compilation arguments: " + "'-d' "
088: + projectsFolder
089: + "\\connectfour\\target\\classes' "
090: + "'-classpath' "
091: + projectsFolder
092: + "\\connectfour\\target\\classes;"
093: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-launcher.jar;"
094: + "C:\\Program Files\\Java\\jre1.5.0_05\\lib\\ext\\QTJava.zip;"
095: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-antlr.jar;"
096: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-apache-bcel.jar;"
097: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-apache-bsf.jar;"
098: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-apache-log4j.jar;"
099: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-apache-oro.jar;"
100: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-apache-regexp.jar;"
101: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-apache-resolver.jar;"
102: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-commons-logging.jar;"
103: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-commons-net.jar;"
104: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-icontract.jar;"
105: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-jai.jar;"
106: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-javamail.jar;"
107: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-jdepend.jar;"
108: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-jmf.jar;"
109: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-jsch.jar;"
110: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-junit.jar;"
111: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-netrexx.jar;"
112: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-nodeps.jar;"
113: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-starteam.jar;"
114: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-stylebook.jar;"
115: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-swing.jar;"
116: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-trax.jar;"
117: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-vaj.jar;"
118: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-weblogic.jar;"
119: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-xalan1.jar;"
120: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant-xslp.jar;"
121: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\ant.jar;"
122: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\junit-3.8.1.jar;"
123: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\xercesImpl.jar;"
124: + "C:\\pdj\\java\\apache-ant-1.6.5\\lib\\xml-apis.jar;"
125: + "C:\\pdj\\java\\j2sdk1.4.2_09\\lib\\tools.jar' "
126: + "'-sourcepath' "
127: + projectsFolder
128: + "\\connectfour\\src' "
129: + "'-g:none' "
130: + "The ' characters around the executable and arguments are "
131: + "not part of the command.");
132:
133: tester.assertTextPresent("Build Error Message");
134: tester.assertTextPresent("This is my error message");
135:
136: tester.assertTextPresent("Stacktrace");
137: tester.assertTextPresent("This is my stacktrace");
138: }
139:
140: public void testShouldEscapeSpecialCharacterInJUnitMessages()
141: throws Exception {
142: tester.beginAt("/tab/build/detail/project1/20051209122104");
143: assertTrue(StringUtils.contains(tester.getPageSource(),
144: "expected:<1> but was:<2>"));
145: }
146:
147: public void testShouldEscapeSpecialCharacterinCommitMessages()
148: throws Exception {
149: tester.beginAt("/tab/build/detail/project1/20051209122104");
150: String pageSource = tester.getPageSource();
151: assertTrue(StringUtils.contains(pageSource,
152: "project name changed to <b>cache</b>"));
153: assertTrue(StringUtils.contains(pageSource, "[rev. 1.2]"));
154: assertTrue(StringUtils.contains(pageSource, "modified"));
155: assertTrue(StringUtils.contains(pageSource, "cc-build.xml"));
156: }
157:
158: public void testShouldShowDefaultMessagewhenNoErrors()
159: throws Exception {
160: tester.beginAt("/tab/build/detail/project1/20051209122103");
161: tester.assertTextPresent("No error message");
162: tester.assertTextPresent("No stacktrace");
163: tester.assertTextPresent("No errors or warnings");
164: }
165:
166: public void testShouldListGZippedLogs() throws Exception {
167: tester.beginAt("/tab/build/detail/project3");
168: tester.assertTextPresent(convertedTime("20070209122100"));
169: tester.assertTextPresent(convertedTime("20061209122100"));
170: tester.assertTextPresent("build.489");
171: tester.assertTextPresent(convertedTime("20061109122100"));
172: tester.assertTextPresent(convertedTime("20051209122100"));
173: }
174:
175: public void testShouldShowModifications() throws Exception {
176: tester.beginAt("/tab/build/detail/project2");
177: String pageSource = tester.getPageSource();
178:
179: assertTrue(StringUtils.contains(pageSource, "[rev. 1.2]"));
180: assertTrue(StringUtils.contains(pageSource, "build.xml"));
181: assertTrue(StringUtils.contains(pageSource, "cc-build.xml"));
182: assertTrue(StringUtils.contains(pageSource,
183: "cc-build-deleted.xml"));
184: }
185: }
|