Source Code Cross Referenced for AllFusionHarvestTest.java in  » Build » cruisecontrol » net » sourceforge » cruisecontrol » sourcecontrols » 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.sourcecontrols 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /********************************************************************************
002:         * CruiseControl, a Continuous Integration Toolkit
003:         * Copyright (c) 2001-2003, ThoughtWorks, Inc.
004:         * 651 W Washington Ave. Suite 600
005:         * Chicago, IL 60661 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.sourcecontrols;
037:
038:        import com.trinem.harvest.hsdkwrap.hutils.JCaAttrKeyWrap;
039:        import com.trinem.harvest.hsdkwrap.hutils.JCaContainerWrap;
040:        import com.trinem.harvest.hsdkwrap.hutils.JCaTimeStampWrap;
041:
042:        import net.sourceforge.cruisecontrol.CruiseControlException;
043:        import net.sourceforge.cruisecontrol.Modification;
044:
045:        import junit.framework.TestCase;
046:
047:        import java.util.ArrayList;
048:        import java.util.Calendar;
049:        import java.util.GregorianCalendar;
050:
051:        public class AllFusionHarvestTest extends TestCase {
052:
053:            private static Calendar gc = GregorianCalendar.getInstance();
054:
055:            protected void setUp() throws Exception {
056:                super .setUp();
057:            }
058:
059:            protected void tearDown() throws Exception {
060:                super .tearDown();
061:            }
062:
063:            public void testValidate() {
064:
065:                // Nothing set
066:                AllFusionHarvest harvest = new AllFusionHarvest();
067:                try {
068:                    harvest.validate();
069:                    fail("AllFusionHarvest should throw exceptions when required attributes are not set.");
070:                } catch (CruiseControlException expected) {
071:                }
072:
073:                // Only Username set
074:                try {
075:                    harvest = new AllFusionHarvest();
076:                    harvest.setUsername("username");
077:                    harvest.validate();
078:                    fail("AllFusionHarvest should throw exceptions when required attributes are not set.");
079:                } catch (CruiseControlException expected) {
080:                }
081:
082:                // Only Password set
083:                try {
084:                    harvest = new AllFusionHarvest();
085:                    harvest.setPassword("password");
086:                    harvest.validate();
087:                    fail("AllFusionHarvest should throw exceptions when required attributes are not set.");
088:                } catch (CruiseControlException expected) {
089:                }
090:
091:                // Only Broker set
092:                try {
093:                    harvest = new AllFusionHarvest();
094:                    harvest.setBroker("broker");
095:                    harvest.validate();
096:                    fail("AllFusionHarvest should throw exceptions when required attributes are not set.");
097:                } catch (CruiseControlException expected) {
098:                }
099:
100:                // Only State set
101:                try {
102:                    harvest = new AllFusionHarvest();
103:                    harvest.setState("state");
104:                    harvest.validate();
105:                    fail("AllFusionHarvest should throw exceptions when required attributes are not set.");
106:                } catch (CruiseControlException expected) {
107:                }
108:
109:                // Only Project set
110:                try {
111:                    harvest = new AllFusionHarvest();
112:                    harvest.setProject("project");
113:                    harvest.validate();
114:                    fail("AllFusionHarvest should throw exceptions when required attributes are not set.");
115:                } catch (CruiseControlException expected) {
116:                }
117:
118:                try {
119:                    harvest = new AllFusionHarvest();
120:                    harvest.setUsername("username");
121:                    harvest.setPassword("password");
122:                    harvest.setBroker("broker");
123:                    harvest.setState("state");
124:                    harvest.setProject("project");
125:                    harvest.validate();
126:                } catch (CruiseControlException e) {
127:                    fail("AllFusionHarvest should not throw exceptions when required attributes are set.");
128:                }
129:            }
130:
131:            public void testGetVersionsInRange() {
132:
133:                // Setup some data to use in testing
134:                String[][] data = {
135:                        { "0", "foo.java", "/test", "added", "N", "testuser",
136:                                "testuser@foobar.com", "Added version" },
137:                        { "1", "bar.java", "/test", "modified", "N",
138:                                "testuser", "testuser@foobar.com",
139:                                "Modified version" },
140:                        { "2", "bat.java", "/test", "reserved", "R",
141:                                "testuser", "testuser@foobar.com",
142:                                "Reserved version" } };
143:
144:                int[][] dates = { { 2007, Calendar.JANUARY, 7, 12, 34, 56, 0 },
145:                        { 2007, Calendar.JANUARY, 7, 12, 33, 44, 0 },
146:                        { 2007, Calendar.JANUARY, 7, 12, 44, 55, 0 } };
147:
148:                ArrayList reference = new ArrayList();
149:                JCaContainerWrap versionList = new JCaContainerWrap();
150:
151:                // Test to see whether the JHSDK is present
152:                if (versionList.getRealObject() == null) {
153:                    return;
154:                }
155:
156:                // Copy the test data into some reference objects and a data source
157:                for (int d = 0; d < data.length; d++) {
158:
159:                    // Only put non-reserved tagged versions into the expected results
160:                    if (!data[d][4].equals("R")) {
161:                        Modification ref = new Modification("harvest");
162:                        ref.revision = data[d][0];
163:                        Modification.ModifiedFile modfile = ref
164:                                .createModifiedFile(data[d][1], data[d][2]);
165:                        modfile.action = data[d][3];
166:                        modfile.revision = ref.revision;
167:                        gc.set(dates[d][0], dates[d][1], dates[d][2],
168:                                dates[d][3], dates[d][4], dates[d][5]);
169:                        gc.set(Calendar.MILLISECOND, dates[d][6]);
170:                        ref.modifiedTime = gc.getTime();
171:                        ref.userName = data[d][5];
172:                        ref.emailAddress = data[d][6];
173:                        ref.comment = data[d][7];
174:                        reference.add(ref);
175:                    }
176:
177:                    versionList.setString(
178:                            JCaAttrKeyWrap.CA_ATTRKEY_MAPPED_VERSION_NAME,
179:                            data[d][0], d);
180:                    versionList.setString(JCaAttrKeyWrap.CA_ATTRKEY_NAME,
181:                            data[d][1], d);
182:                    versionList.setString(
183:                            JCaAttrKeyWrap.CA_ATTRKEY_FULL_PATH_NAME,
184:                            data[d][2], d);
185:                    versionList.setTimeStamp(
186:                            JCaAttrKeyWrap.CA_ATTRKEY_MODIFIED_TIME,
187:                            new JCaTimeStampWrap(dates[d][0], dates[d][1] + 1,
188:                                    dates[d][2], dates[d][3], dates[d][4],
189:                                    dates[d][5], dates[d][6]), d);
190:                    versionList.setString(
191:                            JCaAttrKeyWrap.CA_ATTRKEY_VERSION_STATUS,
192:                            data[d][4], d);
193:                    versionList.setString(
194:                            JCaAttrKeyWrap.CA_ATTRKEY_MODIFIER_NAME,
195:                            data[d][5], d);
196:                    versionList.setString(
197:                            JCaAttrKeyWrap.CA_ATTRKEY_DESCRIPTION, data[d][7],
198:                            d);
199:                }
200:
201:                // Now setup the sourcecontrol and test - this code is based on getVersionsInRange()
202:                AllFusionHarvest test = new AllFusionHarvest();
203:                test.setEmailAddress(data[0][5], data[0][6]);
204:
205:                ArrayList list = new ArrayList();
206:
207:                // This test is critical, as sometimes the count throws an exception
208:                int numVers = versionList.isEmpty() ? 0 : versionList
209:                        .getKeyElementCount(JCaAttrKeyWrap.CA_ATTRKEY_NAME);
210:
211:                for (int n = 0; n < numVers; n++) {
212:                    String status = versionList.getString(
213:                            JCaAttrKeyWrap.CA_ATTRKEY_VERSION_STATUS, n);
214:
215:                    // Don't add reserved tagged files - the file hasn't actually changed
216:                    if (!status.equals("R")) {
217:                        list.add(test
218:                                .transformJCaVersionContainerToModification(
219:                                        versionList, n));
220:                    }
221:                }
222:
223:                // Check the results
224:                if (list.size() != reference.size()) {
225:                    fail("AllFusionHarvest should return " + reference.size()
226:                            + " modification(s)");
227:                }
228:
229:                Object[] refArray = reference.toArray();
230:                Object[] retArray = list.toArray();
231:
232:                for (int m = 0; m < retArray.length; m++) {
233:                    Modification mod = (Modification) retArray[m];
234:                    Modification ref = (Modification) refArray[m];
235:
236:                    if (!ref.equals(mod)) {
237:                        fail("AllFusionHarvest does not return expected result for modification #"
238:                                + m);
239:                    }
240:
241:                    Object[] refFiles = ref.files.toArray();
242:                    Object[] modFiles = mod.files.toArray();
243:
244:                    if (refFiles.length != modFiles.length) {
245:                        fail("AllFusionHarvest should return "
246:                                + refFiles.length + " files for modification #"
247:                                + m);
248:                    }
249:
250:                    for (int f = 0; f < refFiles.length; f++) {
251:                        if (!refFiles[f].equals(modFiles[f])) {
252:                            fail("AllFusionHarvest does not return expected result for file #"
253:                                    + f + " in modification #" + m);
254:                        }
255:                    }
256:                }
257:            }
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.