Source Code Cross Referenced for ConcurrentVersionsSystemTest.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) 


0001:        /********************************************************************************
0002:         * CruiseControl, a Continuous Integration Toolkit
0003:         * Copyright (c) 2001, ThoughtWorks, Inc.
0004:         * 200 E. Randolph, 25th Floor
0005:         * Chicago, IL 60601 USA
0006:         * All rights reserved.
0007:         *
0008:         * Redistribution and use in source and binary forms, with or without
0009:         * modification, are permitted provided that the following conditions
0010:         * are met:
0011:         *
0012:         *     + Redistributions of source code must retain the above copyright
0013:         *       notice, this list of conditions and the following disclaimer.
0014:         *
0015:         *     + Redistributions in binary form must reproduce the above
0016:         *       copyright notice, this list of conditions and the following
0017:         *       disclaimer in the documentation and/or other materials provided
0018:         *       with the distribution.
0019:         *
0020:         *     + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
0021:         *       names of its contributors may be used to endorse or promote
0022:         *       products derived from this software without specific prior
0023:         *       written permission.
0024:         *
0025:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0026:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0027:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0028:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
0029:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0030:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0031:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
0032:         * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0033:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0034:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0035:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0036:         ********************************************************************************/package net.sourceforge.cruisecontrol.sourcecontrols;
0037:
0038:        import java.io.BufferedInputStream;
0039:        import java.io.ByteArrayInputStream;
0040:        import java.io.IOException;
0041:        import java.io.InputStream;
0042:        import java.io.PipedInputStream;
0043:        import java.io.PipedOutputStream;
0044:        import java.text.ParseException;
0045:        import java.text.SimpleDateFormat;
0046:        import java.util.Collections;
0047:        import java.util.Date;
0048:        import java.util.GregorianCalendar;
0049:        import java.util.Hashtable;
0050:        import java.util.List;
0051:        import java.util.Map;
0052:        import java.util.TimeZone;
0053:
0054:        import junit.framework.TestCase;
0055:        import net.sourceforge.cruisecontrol.CruiseControlException;
0056:        import net.sourceforge.cruisecontrol.Modification;
0057:        import net.sourceforge.cruisecontrol.util.CVSDateUtil;
0058:        import net.sourceforge.cruisecontrol.util.Commandline;
0059:        import net.sourceforge.cruisecontrol.util.MockCommandline;
0060:
0061:        /**
0062:         * @author Robert Watkins
0063:         * @author <a href="mailto:jcyip@thoughtworks.com">Jason Yip</a>
0064:         */
0065:        public class ConcurrentVersionsSystemTest extends TestCase {
0066:
0067:            private TimeZone originalTimeZone;
0068:
0069:            private static final String[] CVS_VERSION_COMMANDLINE = new String[] {
0070:                    "cvs", "version" };
0071:
0072:            protected void setUp() throws Exception {
0073:                originalTimeZone = TimeZone.getDefault();
0074:            }
0075:
0076:            protected void tearDown() throws Exception {
0077:                TimeZone.setDefault(originalTimeZone);
0078:                originalTimeZone = null;
0079:            }
0080:
0081:            public void testParseStream() throws IOException, ParseException {
0082:                // ensure CVS version and simulated outputs are in sync
0083:                final String cvsVersion = "1.11.16";
0084:                ConcurrentVersionsSystem cvs = new SpecificVersionCVS(
0085:                        getOfficialCVSVersion(cvsVersion));
0086:                Hashtable emailAliases = new Hashtable();
0087:                emailAliases.put("alden", "alden@users.sourceforge.net");
0088:                emailAliases.put("tim", "tim@tim.net");
0089:                cvs.setMailAliases(emailAliases);
0090:
0091:                BufferedInputStream input = new BufferedInputStream(
0092:                        loadTestLog("cvslog1-11.txt"));
0093:                List modifications = cvs.parseStream(input);
0094:                input.close();
0095:                Collections.sort(modifications);
0096:
0097:                assertEquals("Should have returned 5 modifications.", 5,
0098:                        modifications.size());
0099:
0100:                Modification mod1 = new Modification("cvs");
0101:                Modification.ModifiedFile mod1file = mod1.createModifiedFile(
0102:                        "log4j.properties", null);
0103:                mod1file.action = "modified";
0104:                mod1.revision = "1.2";
0105:                mod1.modifiedTime = parseLogDateFormat("2002/03/13 13:45:50 GMT-6:00");
0106:                mod1.userName = "alden";
0107:                mod1.comment = "Shortening ConversionPattern so we don't use up all of the available screen space.";
0108:                mod1.emailAddress = "alden@users.sourceforge.net";
0109:
0110:                Modification mod2 = new Modification("cvs");
0111:                Modification.ModifiedFile mod2file = mod2.createModifiedFile(
0112:                        "build.xml", null);
0113:                mod2file.action = "modified";
0114:                mod2.revision = "1.41";
0115:                mod2.modifiedTime = parseLogDateFormat("2002/03/13 19:56:34 GMT-6:00");
0116:                mod2.userName = "alden";
0117:                mod2.comment = "Added target to clean up test results.";
0118:                mod2.emailAddress = "alden@users.sourceforge.net";
0119:
0120:                Modification mod3 = new Modification("cvs");
0121:                Modification.ModifiedFile mod3file = mod3.createModifiedFile(
0122:                        "build.xml", "main");
0123:                mod3file.action = "modified";
0124:                mod3.revision = "1.42";
0125:                mod3.modifiedTime = parseLogDateFormat("2002/03/15 13:20:28 GMT-6:00");
0126:                mod3.userName = "alden";
0127:                mod3.comment = "enabled debug info when compiling tests.";
0128:                mod3.emailAddress = "alden@users.sourceforge.net";
0129:
0130:                Modification mod4 = new Modification("cvs");
0131:                Modification.ModifiedFile mod4file = mod4.createModifiedFile(
0132:                        "kungfu.xml", "main");
0133:                mod4file.action = "deleted";
0134:                mod4.revision = "1.2";
0135:                mod4.modifiedTime = parseLogDateFormat("2002/03/13 13:45:42 GMT-6:00");
0136:                mod4.userName = "alden";
0137:                mod4.comment = "Hey, look, a deleted file.";
0138:                mod4.emailAddress = "alden@users.sourceforge.net";
0139:
0140:                Modification mod5 = new Modification("cvs");
0141:                Modification.ModifiedFile mod5file = mod5.createModifiedFile(
0142:                        "stuff.xml", "main");
0143:                mod5file.action = "deleted";
0144:                mod5.revision = "1.4";
0145:                mod5.modifiedTime = parseLogDateFormat("2002/03/13 13:38:42 GMT-6:00");
0146:                mod5.userName = "alden";
0147:                mod5.comment = "Hey, look, another deleted file.";
0148:                mod5.emailAddress = "alden@users.sourceforge.net";
0149:
0150:                assertEquals(mod5, modifications.get(0));
0151:                assertEquals(mod4, modifications.get(1));
0152:                assertEquals(mod1, modifications.get(2));
0153:                assertEquals(mod2, modifications.get(3));
0154:                assertEquals(mod3, modifications.get(4));
0155:            }
0156:
0157:            public void testParseStreamRemote() throws IOException,
0158:                    ParseException {
0159:                // ensure CVS version and simulated outputs are in sync
0160:                final String cvsVersion = "1.11.16";
0161:                ConcurrentVersionsSystem cvs = new SpecificVersionCVS(
0162:                        getOfficialCVSVersion(cvsVersion));
0163:                cvs.setModule("cruisecontrol");
0164:                cvs
0165:                        .setCvsRoot(":pserver:anonymous@cvs.sourceforge.net:/cvsroot/cruisecontrol");
0166:                Hashtable emailAliases = new Hashtable();
0167:                emailAliases.put("alden", "alden@users.sourceforge.net");
0168:                emailAliases.put("tim", "tim@tim.net");
0169:                cvs.setMailAliases(emailAliases);
0170:
0171:                BufferedInputStream input = new BufferedInputStream(
0172:                        loadTestLog("cvslog1-11-remote.txt"));
0173:                List modifications = cvs.parseStream(input);
0174:                input.close();
0175:                Collections.sort(modifications);
0176:
0177:                assertEquals("Should have returned 5 modifications.", 5,
0178:                        modifications.size());
0179:
0180:                Modification mod1 = new Modification("cvs");
0181:                Modification.ModifiedFile mod1file = mod1.createModifiedFile(
0182:                        "log4j.properties", null);
0183:                mod1file.action = "modified";
0184:                mod1.revision = "1.2";
0185:                mod1.modifiedTime = parseLogDateFormat("2002/03/13 13:45:50 GMT-6:00");
0186:                mod1.userName = "alden";
0187:                mod1.comment = "Shortening ConversionPattern so we don't use up all of the available screen space.";
0188:                mod1.emailAddress = "alden@users.sourceforge.net";
0189:
0190:                Modification mod2 = new Modification("cvs");
0191:                Modification.ModifiedFile mod2file = mod2.createModifiedFile(
0192:                        "build.xml", null);
0193:                mod2file.action = "modified";
0194:                mod2.revision = "1.41";
0195:                mod2.modifiedTime = parseLogDateFormat("2002/03/13 19:56:34 GMT-6:00");
0196:                mod2.userName = "alden";
0197:                mod2.comment = "Added target to clean up test results.";
0198:                mod2.emailAddress = "alden@users.sourceforge.net";
0199:
0200:                Modification mod3 = new Modification("cvs");
0201:                Modification.ModifiedFile mod3file = mod3.createModifiedFile(
0202:                        "build.xml", "main");
0203:                mod3file.action = "modified";
0204:                mod3.revision = "1.42";
0205:                mod3.modifiedTime = parseLogDateFormat("2002/03/15 13:20:28 GMT-6:00");
0206:                mod3.userName = "alden";
0207:                mod3.comment = "enabled debug info when compiling tests.";
0208:                mod3.emailAddress = "alden@users.sourceforge.net";
0209:
0210:                Modification mod4 = new Modification("cvs");
0211:                Modification.ModifiedFile mod4file = mod4.createModifiedFile(
0212:                        "kungfu.xml", "main");
0213:                mod4file.action = "deleted";
0214:                mod4.revision = "1.2";
0215:                mod4.modifiedTime = parseLogDateFormat("2002/03/13 13:45:42 GMT-6:00");
0216:                mod4.userName = "alden";
0217:                mod4.comment = "Hey, look, a deleted file.";
0218:                mod4.emailAddress = "alden@users.sourceforge.net";
0219:
0220:                Modification mod5 = new Modification("cvs");
0221:                Modification.ModifiedFile mod5file = mod5.createModifiedFile(
0222:                        "stuff.xml", "main");
0223:                mod5file.action = "deleted";
0224:                mod5.revision = "1.4";
0225:                mod5.modifiedTime = parseLogDateFormat("2002/03/13 13:38:42 GMT-6:00");
0226:                mod5.userName = "alden";
0227:                mod5.comment = "Hey, look, another deleted file.";
0228:                mod5.emailAddress = "alden@users.sourceforge.net";
0229:
0230:                assertEquals(mod5, modifications.get(0));
0231:                assertEquals(mod4, modifications.get(1));
0232:                assertEquals(mod1, modifications.get(2));
0233:                assertEquals(mod2, modifications.get(3));
0234:                assertEquals(mod3, modifications.get(4));
0235:            }
0236:
0237:            public void testParseStreamSlashDateFormat() throws IOException,
0238:                    ParseException {
0239:                ConcurrentVersionsSystem cvs = new SpecificVersionCVS(
0240:                        getOfficialCVSVersion("1.12.9"));
0241:                Hashtable emailAliases = new Hashtable();
0242:                emailAliases.put("bar", "bar@mailinator.com");
0243:                cvs.setMailAliases(emailAliases);
0244:
0245:                BufferedInputStream input = new BufferedInputStream(
0246:                        loadTestLog("cvslog1-12-9slashdate.txt"));
0247:                List modifications = cvs.parseStream(input);
0248:                input.close();
0249:                Collections.sort(modifications);
0250:
0251:                assertEquals("Should have returned 1 modification.", 1,
0252:                        modifications.size());
0253:
0254:                Modification mod1 = new Modification("cvs");
0255:                Modification.ModifiedFile mod1file = mod1.createModifiedFile(
0256:                        "makefile", null);
0257:                mod1file.action = "modified";
0258:                mod1.revision = "1.1";
0259:                mod1.modifiedTime = CVSDateUtil
0260:                        .parseCVSDate("2006-11-30 20:57:14 GMT");
0261:                mod1.userName = "bar";
0262:                mod1.comment = "compiles...doubt it works";
0263:                mod1.emailAddress = "bar@mailinator.com";
0264:
0265:                assertEquals(mod1, modifications.get(0));
0266:            }
0267:
0268:            public void testParseStreamNewFormat() throws IOException,
0269:                    ParseException {
0270:                ConcurrentVersionsSystem cvs = new SpecificVersionCVS(
0271:                        getOfficialCVSVersion("1.12.9"));
0272:                Hashtable emailAliases = new Hashtable();
0273:                emailAliases.put("jerome", "jerome@coffeebreaks.org");
0274:                cvs.setMailAliases(emailAliases);
0275:
0276:                BufferedInputStream input = new BufferedInputStream(
0277:                        loadTestLog("cvslog1-12.txt"));
0278:                List modifications = cvs.parseStream(input);
0279:                input.close();
0280:                Collections.sort(modifications);
0281:
0282:                assertEquals("Should have returned 1 modification.", 1,
0283:                        modifications.size());
0284:
0285:                Modification mod1 = new Modification("cvs");
0286:                Modification.ModifiedFile mod1file = mod1.createModifiedFile(
0287:                        "log4j.properties", null);
0288:                mod1file.action = "modified";
0289:                mod1.revision = "1.1";
0290:                mod1.modifiedTime = CVSDateUtil
0291:                        .parseCVSDate("2004-03-25 00:58:49 GMT");
0292:                mod1.userName = "jerome";
0293:                mod1.comment = "initial checkin";
0294:                mod1.emailAddress = "jerome@coffeebreaks.org";
0295:
0296:                assertEquals(mod1, modifications.get(0));
0297:            }
0298:
0299:            public void testParseStreamBranch() throws IOException,
0300:                    ParseException {
0301:                // ensure CVS version and simulated outputs are in sync
0302:                ConcurrentVersionsSystem cvs = new SpecificVersionCVS(
0303:                        getOfficialCVSVersion("1.11.16"));
0304:                Hashtable emailAliases = new Hashtable();
0305:                emailAliases.put("alden", "alden@users.sourceforge.net");
0306:                cvs.setMailAliases(emailAliases);
0307:
0308:                cvs.setTag("BRANCH_TEST_BUILD");
0309:                BufferedInputStream input = new BufferedInputStream(
0310:                        loadTestLog("cvslog1-11branch.txt"));
0311:                List modifications = cvs.parseStream(input);
0312:                input.close();
0313:                Collections.sort(modifications);
0314:
0315:                assertEquals("Should have returned 4 modifications.", 4,
0316:                        modifications.size());
0317:
0318:                Modification mod1 = new Modification("cvs");
0319:                mod1.revision = "1.1.2.4";
0320:                mod1.modifiedTime = parseLogDateFormat("2002/10/03 16:05:23 GMT");
0321:                mod1.userName = "tim";
0322:                mod1.comment = "Test commit once more";
0323:                Modification.ModifiedFile mod1file = mod1.createModifiedFile(
0324:                        "test.version", null);
0325:                mod1file.action = "modified";
0326:                mod1file.revision = mod1.revision;
0327:
0328:                Modification mod2 = new Modification("cvs");
0329:                mod2.revision = "1.1.2.3";
0330:                mod2.modifiedTime = parseLogDateFormat("2002/10/03 14:24:17 GMT");
0331:                mod2.userName = "tim";
0332:                mod2.comment = "Test commit";
0333:                Modification.ModifiedFile mod2file = mod2.createModifiedFile(
0334:                        "test.version", null);
0335:                mod2file.action = "modified";
0336:                mod2file.revision = mod2.revision;
0337:
0338:                Modification mod3 = new Modification("cvs");
0339:                mod3.revision = "1.1.2.2";
0340:                mod3.modifiedTime = parseLogDateFormat("2002/10/02 21:54:44 GMT");
0341:                mod3.userName = "tim";
0342:                mod3.comment = "Update parameters for test";
0343:                Modification.ModifiedFile mod3file = mod3.createModifiedFile(
0344:                        "test.version", null);
0345:                mod3file.action = "modified";
0346:                mod3file.revision = mod3.revision;
0347:
0348:                Modification mod4 = new Modification("cvs");
0349:                mod4.revision = "1.1.2.1";
0350:                mod4.modifiedTime = parseLogDateFormat("2002/10/02 21:49:31 GMT");
0351:                mod4.userName = "tim";
0352:                mod4.comment = "Add parameters for test";
0353:                Modification.ModifiedFile mod4file = mod4.createModifiedFile(
0354:                        "test.version", null);
0355:                mod4file.action = "modified";
0356:                mod4file.revision = mod4.revision;
0357:
0358:                assertEquals(mod4, modifications.get(0));
0359:                assertEquals(mod3, modifications.get(1));
0360:                assertEquals(mod2, modifications.get(2));
0361:                assertEquals(mod1, modifications.get(3));
0362:            }
0363:
0364:            public void testParseStreamTagNoBranch() throws IOException,
0365:                    ParseException {
0366:                // ensure CVS version and simulated outputs are in sync
0367:                ConcurrentVersionsSystem cvs = new SpecificVersionCVS(
0368:                        getOfficialCVSVersion("1.12.9"));
0369:                Hashtable emailAliases = new Hashtable();
0370:                cvs.setMailAliases(emailAliases);
0371:
0372:                cvs.setTag("TEST");
0373:                BufferedInputStream input = new BufferedInputStream(
0374:                        loadTestLog("cvslog1-12tagnobranch.txt"));
0375:                List modifications = cvs.parseStream(input);
0376:                input.close();
0377:                Collections.sort(modifications);
0378:
0379:                assertEquals("Should have returned 1 modification.", 1,
0380:                        modifications.size());
0381:
0382:                Modification mod1 = new Modification("cvs");
0383:                mod1.revision = "1.49";
0384:                mod1.modifiedTime = parseLogDateFormat("2005/08/22 17:28:13 GMT");
0385:                mod1.userName = "jerome";
0386:                mod1.comment = "Test commit";
0387:                Modification.ModifiedFile mod1file = mod1.createModifiedFile(
0388:                        "test.version", null);
0389:                mod1file.action = "modified";
0390:                mod1file.revision = mod1.revision;
0391:
0392:                assertEquals(mod1, modifications.get(0));
0393:            }
0394:
0395:            public void testGetProperties() throws IOException {
0396:                // ensure CVS version and simulated outputs are in sync
0397:                ConcurrentVersionsSystem cvs = new SpecificVersionCVS(
0398:                        getOfficialCVSVersion("1.11.16"));
0399:                cvs.setMailAliases(new Hashtable());
0400:                cvs.setProperty("property");
0401:                cvs.setPropertyOnDelete("propertyOnDelete");
0402:
0403:                String logName = "cvslog1-11.txt";
0404:                BufferedInputStream input = new BufferedInputStream(
0405:                        loadTestLog(logName));
0406:                cvs.parseStream(input);
0407:                input.close();
0408:
0409:                Map table = cvs.getProperties();
0410:                assertNotNull("Table of properties shouldn't be null.", table);
0411:
0412:                assertEquals("Should be two properties.", 2, table.size());
0413:
0414:                assertTrue("Property was not set.", table
0415:                        .containsKey("property"));
0416:                assertTrue("PropertyOnDelete was not set.", table
0417:                        .containsKey("propertyOnDelete"));
0418:
0419:                // negative test
0420:                // ensure CVS version and simulated outputs are in sync
0421:                ConcurrentVersionsSystem cvs2 = new SpecificVersionCVS(
0422:                        getOfficialCVSVersion("1.11.16"));
0423:                cvs2.setMailAliases(new Hashtable());
0424:                input = new BufferedInputStream(loadTestLog(logName));
0425:                cvs2.parseStream(input);
0426:                input.close();
0427:
0428:                table = cvs2.getProperties();
0429:                assertNotNull("Table of properties shouldn't be null.", table);
0430:
0431:                assertEquals("Shouldn't be any properties.", 0, table.size());
0432:            }
0433:
0434:            public void testGetPropertiesNoModifications() throws IOException {
0435:                ConcurrentVersionsSystem cvs = new SpecificVersionCVS(
0436:                        getOfficialCVSVersion("1.11.16"));
0437:                cvs.setMailAliases(new Hashtable());
0438:                cvs.setProperty("property");
0439:                cvs.setPropertyOnDelete("propertyOnDelete");
0440:                String logName = "cvslog1-11noMods.txt";
0441:                BufferedInputStream input = new BufferedInputStream(
0442:                        loadTestLog(logName));
0443:                cvs.parseStream(input);
0444:                input.close();
0445:
0446:                Map table = cvs.getProperties();
0447:                assertNotNull("Table of properties shouldn't be null.", table);
0448:
0449:                assertEquals("Shouldn't be any properties.", 0, table.size());
0450:            }
0451:
0452:            public void testGetPropertiesOnlyModifications() throws IOException {
0453:                // ensure CVS version and simulated outputs are in sync
0454:                ConcurrentVersionsSystem cvs = new SpecificVersionCVS(
0455:                        getOfficialCVSVersion("1.11.16"));
0456:                cvs.setMailAliases(new Hashtable());
0457:                cvs.setProperty("property");
0458:                cvs.setPropertyOnDelete("propertyOnDelete");
0459:                String logName = "cvslog1-11mods.txt";
0460:                BufferedInputStream input = new BufferedInputStream(
0461:                        loadTestLog(logName));
0462:                cvs.parseStream(input);
0463:                input.close();
0464:
0465:                Map table = cvs.getProperties();
0466:                assertNotNull("Table of properties shouldn't be null.", table);
0467:
0468:                assertEquals("Should be one property.", 1, table.size());
0469:                assertTrue("Property was not set.", table
0470:                        .containsKey("property"));
0471:
0472:                // negative test
0473:                // ensure CVS version and simulated outputs are in sync
0474:                ConcurrentVersionsSystem cvs2 = new SpecificVersionCVS(
0475:                        getOfficialCVSVersion("1.11.16"));
0476:                cvs2.setMailAliases(new Hashtable());
0477:                cvs2.setPropertyOnDelete("propertyOnDelete");
0478:                input = new BufferedInputStream(loadTestLog(logName));
0479:                cvs2.parseStream(input);
0480:                input.close();
0481:
0482:                table = cvs2.getProperties();
0483:                assertNotNull("Table of properties shouldn't be null.", table);
0484:
0485:                assertEquals("Shouldn't be any properties.", 0, table.size());
0486:            }
0487:
0488:            public void testGetPropertiesOnlyDeletions() throws IOException {
0489:                // ensure CVS version and simulated outputs are in sync
0490:                ConcurrentVersionsSystem cvs = new SpecificVersionCVS(
0491:                        getOfficialCVSVersion("1.11.16"));
0492:                cvs.setMailAliases(new Hashtable());
0493:                cvs.setPropertyOnDelete("propertyOnDelete");
0494:                String logName = "cvslog1-11del.txt";
0495:                BufferedInputStream input = new BufferedInputStream(
0496:                        loadTestLog(logName));
0497:                cvs.parseStream(input);
0498:                input.close();
0499:
0500:                Map table = cvs.getProperties();
0501:                assertNotNull("Table of properties shouldn't be null.", table);
0502:
0503:                assertEquals("Should be one property.", 1, table.size());
0504:                assertTrue("PropertyOnDelete was not set.", table
0505:                        .containsKey("propertyOnDelete"));
0506:
0507:                // negative test
0508:                // ensure CVS version and simulated outputs are in sync
0509:                ConcurrentVersionsSystem cvs2 = new SpecificVersionCVS(
0510:                        getOfficialCVSVersion("1.11.16"));
0511:                cvs2.setMailAliases(new Hashtable());
0512:                input = new BufferedInputStream(loadTestLog(logName));
0513:                cvs2.parseStream(input);
0514:                input.close();
0515:
0516:                table = cvs2.getProperties();
0517:                assertNotNull("Table of properties shouldn't be null.", table);
0518:
0519:                assertEquals("Shouldn't be any properties.", 0, table.size());
0520:            }
0521:
0522:            public void testBuildHistoryCommand() throws CruiseControlException {
0523:                Date checkTime = new Date();
0524:                long tenMinutes = 10 * 60 * 1000;
0525:                Date lastBuildTime = new Date(checkTime.getTime() - tenMinutes);
0526:
0527:                ConcurrentVersionsSystem cvs = new ConcurrentVersionsSystem();
0528:                cvs.setCvsRoot("cvsroot");
0529:                cvs.setLocalWorkingCopy(".");
0530:
0531:                String[] expectedCommand = {
0532:                        "cvs",
0533:                        "-d",
0534:                        "cvsroot",
0535:                        "-q",
0536:                        "log",
0537:                        "-N",
0538:                        "-d"
0539:                                + ConcurrentVersionsSystem
0540:                                        .formatCVSDate(lastBuildTime)
0541:                                + "<"
0542:                                + ConcurrentVersionsSystem
0543:                                        .formatCVSDate(checkTime), "-b" };
0544:
0545:                String[] noTagCommand = cvs.buildHistoryCommand(lastBuildTime,
0546:                        checkTime).getCommandline();
0547:                assertCommandsEqual(expectedCommand, noTagCommand);
0548:
0549:                cvs.setTag("");
0550:                String[] emptyStringTagCommand = cvs.buildHistoryCommand(
0551:                        lastBuildTime, checkTime).getCommandline();
0552:                assertCommandsEqual(expectedCommand, emptyStringTagCommand);
0553:
0554:                cvs.setTag("HEAD");
0555:                String[] headTagCommand = cvs.buildHistoryCommand(
0556:                        lastBuildTime, checkTime).getCommandline();
0557:                assertCommandsEqual(expectedCommand, headTagCommand);
0558:
0559:                cvs.setReallyQuiet(true);
0560:                expectedCommand[3] = "-Q";
0561:                String[] reallyQuietCommand = cvs.buildHistoryCommand(
0562:                        lastBuildTime, checkTime).getCommandline();
0563:                assertCommandsEqual(expectedCommand, reallyQuietCommand);
0564:            }
0565:
0566:            /**
0567:             * @param expectedCommand
0568:             * @param actualCommand
0569:             */
0570:            private void assertCommandsEqual(String[] expectedCommand,
0571:                    String[] actualCommand) {
0572:                assertEquals("Mismatched lengths!", expectedCommand.length,
0573:                        actualCommand.length);
0574:                for (int i = 0; i < expectedCommand.length; i++) {
0575:                    assertEquals(expectedCommand[i], actualCommand[i]);
0576:                }
0577:            }
0578:
0579:            public void testBuildHistoryCommandWithTag()
0580:                    throws CruiseControlException {
0581:                Date lastBuildTime = new Date();
0582:
0583:                ConcurrentVersionsSystem element = new ConcurrentVersionsSystem();
0584:                element.setCvsRoot("cvsroot");
0585:                element.setLocalWorkingCopy(".");
0586:                element.setTag("sometag");
0587:
0588:                String[] expectedCommand = new String[] {
0589:                        "cvs",
0590:                        "-d",
0591:                        "cvsroot",
0592:                        "-q",
0593:                        "log",
0594:                        "-d"
0595:                                + ConcurrentVersionsSystem
0596:                                        .formatCVSDate(lastBuildTime)
0597:                                + "<"
0598:                                + ConcurrentVersionsSystem
0599:                                        .formatCVSDate(lastBuildTime),
0600:                        "-rsometag" };
0601:
0602:                String[] actualCommand = element.buildHistoryCommand(
0603:                        lastBuildTime, lastBuildTime).getCommandline();
0604:
0605:                assertCommandsEqual(expectedCommand, actualCommand);
0606:            }
0607:
0608:            public void testHistoryCommandNullLocal()
0609:                    throws CruiseControlException {
0610:                Date lastBuildTime = new Date();
0611:
0612:                ConcurrentVersionsSystem element = new ConcurrentVersionsSystem();
0613:                element.setCvsRoot("cvsroot");
0614:                element.setModule("module");
0615:                element.setLocalWorkingCopy(null);
0616:
0617:                String[] expectedCommand = new String[] {
0618:                        "cvs",
0619:                        "-d",
0620:                        "cvsroot",
0621:                        "-q",
0622:                        "rlog",
0623:                        "-N",
0624:                        "-d"
0625:                                + ConcurrentVersionsSystem
0626:                                        .formatCVSDate(lastBuildTime)
0627:                                + "<"
0628:                                + ConcurrentVersionsSystem
0629:                                        .formatCVSDate(lastBuildTime), "-b",
0630:                        "module" };
0631:
0632:                String[] actualCommand = element.buildHistoryCommand(
0633:                        lastBuildTime, lastBuildTime).getCommandline();
0634:
0635:                assertCommandsEqual(expectedCommand, actualCommand);
0636:            }
0637:
0638:            public void testHistoryCommandWithCompression()
0639:                    throws CruiseControlException {
0640:                Date lastBuildTime = new Date();
0641:
0642:                ConcurrentVersionsSystem element = new ConcurrentVersionsSystem();
0643:                element.setLocalWorkingCopy(".");
0644:                element.setCompression("9");
0645:
0646:                String[] expectedCommand = new String[] {
0647:                        "cvs",
0648:                        "-z9",
0649:                        "-q",
0650:                        "log",
0651:                        "-N",
0652:                        "-d"
0653:                                + ConcurrentVersionsSystem
0654:                                        .formatCVSDate(lastBuildTime)
0655:                                + "<"
0656:                                + ConcurrentVersionsSystem
0657:                                        .formatCVSDate(lastBuildTime), "-b" };
0658:
0659:                String[] actualCommand = element.buildHistoryCommand(
0660:                        lastBuildTime, lastBuildTime).getCommandline();
0661:                assertCommandsEqual(expectedCommand, actualCommand);
0662:            }
0663:
0664:            public void testHistoryCommandNullCVSROOT()
0665:                    throws CruiseControlException {
0666:                Date lastBuildTime = new Date();
0667:
0668:                ConcurrentVersionsSystem element = new ConcurrentVersionsSystem();
0669:                element.setCvsRoot(null);
0670:                element.setLocalWorkingCopy(".");
0671:
0672:                String[] expectedCommand = new String[] {
0673:                        "cvs",
0674:                        "-q",
0675:                        "log",
0676:                        "-N",
0677:                        "-d"
0678:                                + ConcurrentVersionsSystem
0679:                                        .formatCVSDate(lastBuildTime)
0680:                                + "<"
0681:                                + ConcurrentVersionsSystem
0682:                                        .formatCVSDate(lastBuildTime), "-b" };
0683:
0684:                String[] actualCommand = element.buildHistoryCommand(
0685:                        lastBuildTime, lastBuildTime).getCommandline();
0686:                assertCommandsEqual(expectedCommand, actualCommand);
0687:            }
0688:
0689:            public void testParseLogDate() throws ParseException {
0690:                TimeZone tz = TimeZone.getDefault();
0691:                Date may18SixPM2001 = new GregorianCalendar(2001, 4, 18, 18, 0,
0692:                        0).getTime();
0693:                assertEquals(may18SixPM2001, new SimpleDateFormat(
0694:                        ConcurrentVersionsSystem.LOG_DATE_FORMAT)
0695:                        .parse("2001/05/18 18:00:00 "
0696:                                + tz.getDisplayName(tz
0697:                                        .inDaylightTime(may18SixPM2001),
0698:                                        TimeZone.SHORT)));
0699:            }
0700:
0701:            public void testFormatCVSDateGMTPlusZero() {
0702:                TimeZone.setDefault(TimeZone.getTimeZone("GMT+0:00"));
0703:                Date mayEighteenSixPM2001 = new GregorianCalendar(2001, 4, 18,
0704:                        18, 0, 0).getTime();
0705:                assertEquals("2001-05-18 18:00:00 GMT",
0706:                        ConcurrentVersionsSystem
0707:                                .formatCVSDate(mayEighteenSixPM2001));
0708:            }
0709:
0710:            public void testFormatCVSDateGMTPlusTen() {
0711:                TimeZone.setDefault(TimeZone.getTimeZone("GMT+10:00"));
0712:
0713:                Date mayEighteenSixPM2001 = new GregorianCalendar(2001, 4, 18,
0714:                        18, 0, 0).getTime();
0715:                assertEquals("2001-05-18 08:00:00 GMT",
0716:                        ConcurrentVersionsSystem
0717:                                .formatCVSDate(mayEighteenSixPM2001));
0718:                Date may18EightAM2001 = new GregorianCalendar(2001, 4, 18, 8,
0719:                        0, 0).getTime();
0720:                assertEquals("2001-05-17 22:00:00 GMT",
0721:                        ConcurrentVersionsSystem
0722:                                .formatCVSDate(may18EightAM2001));
0723:            }
0724:
0725:            public void testFormatCVSDateGMTMinusTen() {
0726:                TimeZone.setDefault(TimeZone.getTimeZone("GMT-10:00"));
0727:                Date may18SixPM2001 = new GregorianCalendar(2001, 4, 18, 18, 0,
0728:                        0).getTime();
0729:                assertEquals("2001-05-19 04:00:00 GMT",
0730:                        ConcurrentVersionsSystem.formatCVSDate(may18SixPM2001));
0731:                Date may18EightAM2001 = new GregorianCalendar(2001, 4, 18, 8,
0732:                        0, 0).getTime();
0733:                assertEquals("2001-05-18 18:00:00 GMT",
0734:                        ConcurrentVersionsSystem
0735:                                .formatCVSDate(may18EightAM2001));
0736:            }
0737:
0738:            public void testAddAliasToMap() {
0739:                ConcurrentVersionsSystem cvs = new ConcurrentVersionsSystem();
0740:                Hashtable aliasMap = new Hashtable();
0741:                cvs.setMailAliases(aliasMap);
0742:                String userline = "roberto:'Roberto DaMana <damana@cs.unipr.it>'";
0743:                cvs.addAliasToMap(userline);
0744:                userline = "hill:hill@cs.unipr.it";
0745:                cvs.addAliasToMap(userline);
0746:                userline = "zolo:zolo";
0747:                cvs.addAliasToMap(userline);
0748:                assertEquals("'Roberto DaMana <damana@cs.unipr.it>'", aliasMap
0749:                        .get("roberto"));
0750:                assertEquals("hill@cs.unipr.it", aliasMap.get("hill"));
0751:                assertEquals("zolo", aliasMap.get("zolo"));
0752:
0753:                userline = "me";
0754:                cvs.addAliasToMap(userline);
0755:                assertNull(aliasMap.get("me"));
0756:            }
0757:
0758:            public void testGetCvsServerVersionDifferingClientServerVersions()
0759:                    throws IOException {
0760:                String logName = "cvslog1-1xversion.txt";
0761:                final BufferedInputStream input = new BufferedInputStream(
0762:                        loadTestLog(logName));
0763:
0764:                final ConcurrentVersionsSystem cvs = new InputBasedCommandLineMockCVS(
0765:                        input, CVS_VERSION_COMMANDLINE, null);
0766:                assertEquals("differing client & server version",
0767:                        getOfficialCVSVersion("1.11.16"), cvs
0768:                                .getCvsServerVersion());
0769:                assertEquals("differing client & server version", false, cvs
0770:                        .isCvsNewOutputFormat());
0771:                input.close();
0772:            }
0773:
0774:            public void testGetCvsServerVersionIdenticalClientServerVersions1()
0775:                    throws IOException {
0776:                String logName = "cvslog1-11version.txt";
0777:                final BufferedInputStream input = new BufferedInputStream(
0778:                        loadTestLog(logName));
0779:
0780:                final ConcurrentVersionsSystem cvs = new InputBasedCommandLineMockCVS(
0781:                        input, CVS_VERSION_COMMANDLINE, null);
0782:                assertEquals("identical client & server version 1.11.16",
0783:                        getOfficialCVSVersion("1.11.16"), cvs
0784:                                .getCvsServerVersion());
0785:                assertEquals("old output format", false, cvs
0786:                        .isCvsNewOutputFormat());
0787:                input.close();
0788:            }
0789:
0790:            public void testGetCvsServerVersionIdenticalClientServerVersions2()
0791:                    throws IOException {
0792:                String logName = "cvslog1-12version.txt";
0793:                final BufferedInputStream input = new BufferedInputStream(
0794:                        loadTestLog(logName));
0795:
0796:                final ConcurrentVersionsSystem cvs = new InputBasedCommandLineMockCVS(
0797:                        input, CVS_VERSION_COMMANDLINE, null);
0798:                assertEquals("identical client & server version 1.12.9",
0799:                        getOfficialCVSVersion("1.12.9"), cvs
0800:                                .getCvsServerVersion());
0801:                assertEquals("new output format", true, cvs
0802:                        .isCvsNewOutputFormat());
0803:                input.close();
0804:            }
0805:
0806:            public void testGetCvsNTServerVersionDifferingClientServerVersions()
0807:                    throws IOException {
0808:                String logName = "cvsntlog2-0xversion.txt";
0809:                final BufferedInputStream input = new BufferedInputStream(
0810:                        loadTestLog(logName));
0811:
0812:                final ConcurrentVersionsSystem cvs = new InputBasedCommandLineMockCVS(
0813:                        input, CVS_VERSION_COMMANDLINE, null);
0814:                assertEquals(
0815:                        "differing client & server version",
0816:                        new ConcurrentVersionsSystem.Version("CVSNT", "2.0.14"),
0817:                        cvs.getCvsServerVersion());
0818:                assertEquals("differing client & server version", false, cvs
0819:                        .isCvsNewOutputFormat());
0820:                input.close();
0821:            }
0822:
0823:            public void testIsCVSNewVersion() {
0824:
0825:                Object[] array = new Object[] {
0826:                        new SpecificVersionCVS(getOfficialCVSVersion("1.11.16")),
0827:                        Boolean.FALSE,
0828:                        new SpecificVersionCVS(getOfficialCVSVersion("1.12.8")),
0829:                        Boolean.FALSE,
0830:                        new SpecificVersionCVS(getOfficialCVSVersion("1.12.9")),
0831:                        Boolean.TRUE,
0832:                        new SpecificVersionCVS(getOfficialCVSVersion("1.12.81")),
0833:                        Boolean.TRUE,
0834:                        new SpecificVersionCVS(
0835:                                new ConcurrentVersionsSystem.Version("cvsnt",
0836:                                        "2.0.14")), Boolean.FALSE };
0837:
0838:                for (int i = 0; i < array.length; i += 2) {
0839:                    SpecificVersionCVS cvs = (SpecificVersionCVS) array[i];
0840:                    Boolean b = (Boolean) array[i + 1];
0841:                    assertEquals("output format " + cvs.getCvsServerVersion()
0842:                            + " is new?", b.booleanValue(), cvs
0843:                            .isCvsNewOutputFormat());
0844:                }
0845:            }
0846:
0847:            /**
0848:             * on 1.10 version, "version" argument doesn't exist hence the output is empty.
0849:             */
0850:            public void testGetCvsServerVersion1_10version() throws IOException {
0851:
0852:                String logContent = "";
0853:                final InputStream input = new ByteArrayInputStream(logContent
0854:                        .getBytes());
0855:
0856:                final ConcurrentVersionsSystem cvs = new InputBasedCommandLineMockCVS(
0857:                        input, CVS_VERSION_COMMANDLINE, null);
0858:                assertEquals("assuming default cvs version upon empty output",
0859:                        ConcurrentVersionsSystem.DEFAULT_CVS_SERVER_VERSION,
0860:                        cvs.getCvsServerVersion());
0861:                assertEquals("assuming old format upon empty output", false,
0862:                        cvs.isCvsNewOutputFormat());
0863:                input.close();
0864:            }
0865:
0866:            /**
0867:             * What if the output is broken? This can happen for various reasons. It is simulated here by truncating the output.
0868:             */
0869:            public void testGetCvsServerVersion_brokenOutput()
0870:                    throws IOException {
0871:
0872:                String logContent = "Server: Concurrent Versions System (CVS) ";
0873:                final InputStream input = new ByteArrayInputStream(logContent
0874:                        .getBytes());
0875:
0876:                final ConcurrentVersionsSystem cvs = new InputBasedCommandLineMockCVS(
0877:                        input, CVS_VERSION_COMMANDLINE, null);
0878:                assertEquals("assuming default cvs version upon broken output",
0879:                        ConcurrentVersionsSystem.DEFAULT_CVS_SERVER_VERSION,
0880:                        cvs.getCvsServerVersion());
0881:                assertEquals("assuming old format upon broken output", false,
0882:                        cvs.isCvsNewOutputFormat());
0883:                input.close();
0884:            }
0885:
0886:            public void testUseHead() {
0887:                ConcurrentVersionsSystem cvs = new ConcurrentVersionsSystem();
0888:                assertTrue(cvs.useHead());
0889:                cvs.setTag("");
0890:                assertTrue(cvs.useHead());
0891:                cvs.setTag(null);
0892:                assertTrue(cvs.useHead());
0893:                cvs.setTag("HEAD");
0894:                assertTrue(cvs.useHead());
0895:                cvs.setTag("tagName");
0896:                assertFalse(cvs.useHead());
0897:            }
0898:
0899:            public void testCompressionValidation() {
0900:                ConcurrentVersionsSystem cvs = new ConcurrentVersionsSystem();
0901:                cvs.setCvsRoot("bar");
0902:                cvs.setModule("foo");
0903:
0904:                assertCompressionLevelInvalid("A", cvs);
0905:                assertCompressionLevelInvalid("-1", cvs);
0906:                assertCompressionLevelInvalid("1.1", cvs);
0907:                assertCompressionLevelInvalid("10", cvs);
0908:                assertCompressionLevelInvalid("", cvs);
0909:                assertCompressionLevelInvalid("   ", cvs);
0910:                assertCompressionLevelInvalid("\n\n\t\r", cvs);
0911:                assertCompressionLevelValid("1", cvs);
0912:                assertCompressionLevelValid("2", cvs);
0913:                assertCompressionLevelValid("3", cvs);
0914:                assertCompressionLevelValid("4", cvs);
0915:                assertCompressionLevelValid("5", cvs);
0916:                assertCompressionLevelValid("6", cvs);
0917:                assertCompressionLevelValid("7", cvs);
0918:                assertCompressionLevelValid("8", cvs);
0919:                assertCompressionLevelValid("9", cvs);
0920:                assertCompressionLevelValid(null, cvs);
0921:            }
0922:
0923:            private void assertCompressionLevelValid(String candidate,
0924:                    ConcurrentVersionsSystem cvs) {
0925:                cvs.setCompression(candidate);
0926:                try {
0927:                    cvs.validate();
0928:                } catch (CruiseControlException e) {
0929:                    e.printStackTrace();
0930:                    fail("validate() should NOT throw exception on '"
0931:                            + candidate + "' compression value.");
0932:                }
0933:            }
0934:
0935:            private void assertCompressionLevelInvalid(String candidate,
0936:                    ConcurrentVersionsSystem cvs) {
0937:                cvs.setCompression(candidate);
0938:                try {
0939:                    cvs.validate();
0940:                    fail("validate() should throw exception on '" + candidate
0941:                            + "' compression value.");
0942:                } catch (CruiseControlException e) {
0943:                }
0944:            }
0945:
0946:            private InputStream loadTestLog(String name) {
0947:                InputStream testStream = getClass().getResourceAsStream(name);
0948:                assertNotNull("failed to load resource " + name + " in class "
0949:                        + getClass().getName(), testStream);
0950:                return testStream;
0951:            }
0952:
0953:            private Date parseLogDateFormat(String dateString)
0954:                    throws ParseException {
0955:                return new SimpleDateFormat(
0956:                        ConcurrentVersionsSystem.LOG_DATE_FORMAT)
0957:                        .parse(dateString);
0958:            }
0959:
0960:            private static class SpecificVersionCVS extends
0961:                    ConcurrentVersionsSystem {
0962:                private final Version vers;
0963:
0964:                public SpecificVersionCVS(Version cvsVersion) {
0965:                    this .vers = cvsVersion;
0966:                }
0967:
0968:                protected Version getCvsServerVersion() {
0969:                    return vers;
0970:                }
0971:            }
0972:
0973:            private ConcurrentVersionsSystem.Version getOfficialCVSVersion(
0974:                    final String cvsVersion) {
0975:                return new ConcurrentVersionsSystem.Version(
0976:                        ConcurrentVersionsSystem.OFFICIAL_CVS_NAME, cvsVersion);
0977:            }
0978:
0979:            /**
0980:             * Overrides the getCommandLine() method by returnning a MockCommandLine whose process input stream will read its
0981:             * contents from the specific input stream.
0982:             */
0983:            private static class InputBasedCommandLineMockCVS extends
0984:                    ConcurrentVersionsSystem {
0985:                private final InputStream inputStream;
0986:                private final String[] expectedCommandline;
0987:                private final String expectedWorkingDirectory;
0988:
0989:                public InputBasedCommandLineMockCVS(
0990:                        final InputStream inputStream,
0991:                        final String[] expectedCommandLine,
0992:                        final String expectedWorkingDirectory) {
0993:                    this .inputStream = inputStream;
0994:                    expectedCommandline = expectedCommandLine;
0995:                    this .expectedWorkingDirectory = expectedWorkingDirectory;
0996:                }
0997:
0998:                // factory method for mock...
0999:                protected Commandline getCommandline() {
1000:                    final MockCommandline mockCommandline = new MockCommandline();
1001:                    mockCommandline.setExpectedCommandline(expectedCommandline);
1002:                    mockCommandline
1003:                            .setExpectedWorkingDirectory(expectedWorkingDirectory);
1004:                    mockCommandline
1005:                            .setProcessErrorStream(new PipedInputStream());
1006:                    mockCommandline.setProcessInputStream(inputStream);
1007:                    mockCommandline
1008:                            .setProcessOutputStream(new PipedOutputStream());
1009:                    return mockCommandline;
1010:                }
1011:            }
1012:
1013:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.