Source Code Cross Referenced for ProjectConfigTest.java in  » Build » cruisecontrol » net » sourceforge » cruisecontrol » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » cruisecontrol » net.sourceforge.cruisecontrol 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /********************************************************************************
002:         * CruiseControl, a Continuous Integration Toolkit
003:         * Copyright (c) 2005, 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;
037:
038:        import java.util.ArrayList;
039:        import java.util.List;
040:
041:        import junit.framework.TestCase;
042:        import net.sourceforge.cruisecontrol.labelincrementers.DefaultLabelIncrementer;
043:        import net.sourceforge.cruisecontrol.testutil.TestUtil;
044:
045:        import java.io.File;
046:
047:        public class ProjectConfigTest extends TestCase {
048:
049:            private final TestUtil.FilesToDelete filesToDelete = new TestUtil.FilesToDelete();
050:
051:            private ProjectConfig config;
052:
053:            protected void setUp() {
054:                config = new ProjectConfig();
055:                config.setName("test");
056:            }
057:
058:            protected void tearDown() {
059:                config = null;
060:
061:                filesToDelete.delete();
062:            }
063:
064:            public void testBuildAfterFailedShouldDefaultToTrue() {
065:                assertTrue(config.shouldBuildAfterFailed());
066:                config.setBuildAfterFailed(false);
067:                assertFalse(config.shouldBuildAfterFailed());
068:            }
069:
070:            public void testValidate_ScheduleRequired()
071:                    throws CruiseControlException {
072:                try {
073:                    config.validate();
074:                    fail("a schedule should have been required by ProjectConfig");
075:                } catch (CruiseControlException expected) {
076:                    assertEquals("project requires a schedule", expected
077:                            .getMessage());
078:                }
079:
080:                config.add(new MockSchedule());
081:                config.validate();
082:
083:                filesToDelete.add(new File(TestUtil.getTargetDir(), "logs"));
084:            }
085:
086:            public void testValidateCallsSubelementValidates()
087:                    throws CruiseControlException {
088:                MockSchedule schedule = new MockSchedule();
089:                config.add(schedule);
090:                MockBootstrappers bootstrappers = new MockBootstrappers();
091:                config.add(bootstrappers);
092:                MockModificationSet modificationSet = new MockModificationSet();
093:                config.add(modificationSet);
094:                MockListeners listeners = new MockListeners();
095:                config.add(listeners);
096:                MockPublishers publishers = new MockPublishers();
097:                config.add(publishers);
098:                MockLog log = new MockLog();
099:                config.add(log);
100:
101:                config.validate();
102:
103:                assertTrue(schedule.validateWasCalled());
104:                assertTrue(bootstrappers.validateWasCalled());
105:                assertTrue(modificationSet.validateWasCalled());
106:                assertTrue(listeners.validateWasCalled());
107:                assertTrue(publishers.validateWasCalled());
108:                assertTrue(log.validateWasCalled());
109:            }
110:
111:            public void testReadProject() {
112:                String tempDir = System.getProperty("java.io.tmpdir");
113:                ProjectConfig projectConfig = new ProjectConfig();
114:                Project project = projectConfig.readProject(tempDir);
115:                assertNotNull(project);
116:                assertTrue(project.getBuildForced());
117:            }
118:
119:            public void testShouldBeAbleToGetCommitMessage() throws Exception {
120:                MockModificationSet modificationSet = new MockModificationSet();
121:                config.add(new DefaultLabelIncrementer());
122:                config.add(modificationSet);
123:                config.configureProject();
124:                List modifications = config.getModifications();
125:
126:                assertEquals(2, modifications.size());
127:                for (int i = 0; i < 2; i++) {
128:                    Modification modification = (Modification) modifications
129:                            .get(i);
130:                    assertEquals("user" + i, modification.userName);
131:                    assertEquals("comment" + i, modification.comment);
132:                }
133:                assertTrue(modificationSet.getCurrentModificationsWasCalled);
134:            }
135:
136:            private static class MockBootstrappers extends
137:                    ProjectConfig.Bootstrappers {
138:
139:                private boolean validateWasCalled = false;
140:
141:                public void validate() throws CruiseControlException {
142:                    validateWasCalled = true;
143:                }
144:
145:                public boolean validateWasCalled() {
146:                    return validateWasCalled;
147:                }
148:
149:            }
150:
151:            private static class MockModificationSet extends ModificationSet {
152:
153:                private boolean validateWasCalled = false;
154:                private boolean getCurrentModificationsWasCalled = false;
155:
156:                public void validate() throws CruiseControlException {
157:                    validateWasCalled = true;
158:                }
159:
160:                public boolean validateWasCalled() {
161:                    return validateWasCalled;
162:                }
163:
164:                public List getCurrentModifications() {
165:                    getCurrentModificationsWasCalled = true;
166:                    List modications = new ArrayList();
167:                    Modification modification = new Modification();
168:                    modification.userName = "user0";
169:                    modification.comment = "comment0";
170:                    modications.add(modification);
171:                    modification = new Modification();
172:                    modification.userName = "user1";
173:                    modification.comment = "comment1";
174:                    modications.add(modification);
175:                    return modications;
176:                }
177:
178:            }
179:
180:            private static class MockListeners extends ProjectConfig.Listeners {
181:
182:                private boolean validateWasCalled = false;
183:
184:                public void validate() throws CruiseControlException {
185:                    validateWasCalled = true;
186:                }
187:
188:                public boolean validateWasCalled() {
189:                    return validateWasCalled;
190:                }
191:
192:            }
193:
194:            private static class MockPublishers extends
195:                    ProjectConfig.Publishers {
196:
197:                private boolean validateWasCalled = false;
198:
199:                public void validate() throws CruiseControlException {
200:                    validateWasCalled = true;
201:                }
202:
203:                public boolean validateWasCalled() {
204:                    return validateWasCalled;
205:                }
206:
207:            }
208:
209:            private static class MockLog extends Log {
210:
211:                private boolean validateWasCalled = false;
212:
213:                public void validate() throws CruiseControlException {
214:                    validateWasCalled = true;
215:                }
216:
217:                public boolean validateWasCalled() {
218:                    return validateWasCalled;
219:                }
220:
221:            }
222:
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.