Source Code Cross Referenced for VssJournalTest.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, 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.sourcecontrols;
037:
038:        import java.text.ParseException;
039:        import java.text.SimpleDateFormat;
040:        import java.util.ArrayList;
041:        import java.util.Date;
042:        import java.util.List;
043:        import java.util.Locale;
044:
045:        import junit.framework.TestCase;
046:        import net.sourceforge.cruisecontrol.CruiseControlException;
047:        import net.sourceforge.cruisecontrol.Modification;
048:
049:        /**
050:         * @author Eli Tucker
051:         * @author Simon Brandhof
052:         */
053:        public class VssJournalTest extends TestCase {
054:            private static final String SS_DIR = "/";
055:            private static final String PROPERTY_ON_DELETE = "deletedfiles";
056:
057:            private VssJournal element;
058:
059:            public VssJournalTest(String name) {
060:                super (name);
061:            }
062:
063:            protected void setUp() {
064:                // Set up so that this element will match all tests.
065:                element = new VssJournal();
066:                element.setSsDir(SS_DIR);
067:                element.setLastBuildDate(new Date(0));
068:                element.setPropertyOnDelete(PROPERTY_ON_DELETE);
069:            }
070:
071:            public void testValidate() {
072:                VssJournal vj = new VssJournal();
073:
074:                try {
075:                    vj.validate();
076:                    fail("VssJournal should throw exceptions when required attributes are not set.");
077:                } catch (CruiseControlException e) {
078:                    assertTrue(true);
079:                }
080:
081:                vj.setJournalFile("journalfile");
082:                vj.setSsDir("ssdir");
083:
084:                try {
085:                    vj.validate();
086:                    assertTrue(true);
087:                } catch (CruiseControlException e) {
088:                    fail("VssJournal should not throw exceptions when required attributes are set.");
089:                }
090:            }
091:
092:            public void testSubstringToLastSlash() {
093:                assertTrue("$/Eclipse/src/main/com/itxc"
094:                        .equals(element
095:                                .substringToLastSlash("$/Eclipse/src/main/com/itxc/eclipse")));
096:            }
097:
098:            public void testSubstringFromLastSlash() {
099:                assertTrue("eclipse"
100:                        .equals(element
101:                                .substringFromLastSlash("$/Eclipse/src/main/com/itxc/eclipse")));
102:            }
103:
104:            public void testIsInSsDir() {
105:                VssJournal element1 = new VssJournal();
106:                element1.setSsDir("/somedir");
107:                assertTrue(element1.isInSsDir("$/somedir"));
108:                assertTrue(element1.isInSsDir("$/somedir/Hello/There"));
109:                assertFalse(element1
110:                        .isInSsDir("$/somedir2/Another/Directory/page.htm"));
111:                // Should be case insensitive
112:                assertTrue(element1
113:                        .isInSsDir("$/SomeDir/Another/Directory/page.htm"));
114:
115:                element1.setSsDir("/somedir/");
116:                assertTrue(element1.isInSsDir("$/somedir"));
117:                assertTrue(element1.isInSsDir("$/somedir/Hello/There"));
118:                assertFalse(element1
119:                        .isInSsDir("$/somedir2/Another/Directory/page.htm"));
120:
121:                element1.setSsDir("/");
122:                assertTrue(element1
123:                        .isInSsDir("$/anythingCouldBeHere/Blah/blah"));
124:                assertTrue(element1.isInSsDir("$/"));
125:
126:                element1.setSsDir("$/");
127:                assertTrue(element1
128:                        .isInSsDir("$/anythingCouldBeHere/Blah/blah"));
129:                assertTrue(element1.isInSsDir("$/"));
130:
131:                element1.setSsDir("$/somedir/");
132:                assertTrue(element1.isInSsDir("$/somedir"));
133:                assertTrue(element1.isInSsDir("$/somedir/Hello/There"));
134:                assertFalse(element1
135:                        .isInSsDir("$/somedir2/Another/Directory/page.htm"));
136:            }
137:
138:            public void testIsBeforeLastBuild() {
139:                VssJournal element1 = new VssJournal();
140:                long beforeTime = System.currentTimeMillis();
141:                long afterTime = beforeTime + 50000;
142:
143:                element1.setLastBuildDate(new Date(beforeTime));
144:                assertTrue(!element1.isBeforeLastBuild(new Date(afterTime)));
145:            }
146:
147:            public void testHandleEntryCheckin() {
148:                List entry = new ArrayList();
149:                entry.add("$/AutoBuild/conf/cruisecontrol.properties");
150:                entry.add("Version: 5");
151:                entry.add("User: Etucker         Date:  7/06/01  Time:  2:11p");
152:                entry.add("Checked in");
153:                entry.add("Comment: Making cc email users when build failed");
154:
155:                Modification mod = element.handleEntry(entry);
156:                assertEquals(mod.getFileName(), "cruisecontrol.properties");
157:                assertEquals(mod.getFolderName(), "$/AutoBuild/conf");
158:                assertEquals(mod.comment,
159:                        "Comment: Making cc email users when build failed");
160:                assertEquals(mod.userName, "Etucker");
161:                assertEquals(mod.type, "vss");
162:
163:                Modification.ModifiedFile modfile = (Modification.ModifiedFile) mod.files
164:                        .get(0);
165:                assertEquals(modfile.action, "checkin");
166:                assertNull(element.getProperties().get(PROPERTY_ON_DELETE));
167:            }
168:
169:            public void testHandleEntryRename() {
170:                List entry = new ArrayList();
171:                entry.add("$/WILD/Client/English");
172:                entry.add("Version: 15");
173:                entry.add("User: Ddavis          Date:  7/10/01  Time: 10:41a");
174:                entry.add("body3.htm renamed to step3.htm ");
175:
176:                Modification mod = element.handleEntry(entry);
177:                assertEquals(mod.getFileName(), "body3.htm");
178:                assertEquals(mod.getFolderName(), "$/WILD/Client/English");
179:                assertEquals(mod.comment, "");
180:                assertEquals(mod.userName, "Ddavis");
181:                assertEquals(mod.type, "vss");
182:
183:                Modification.ModifiedFile modfile = (Modification.ModifiedFile) mod.files
184:                        .get(0);
185:                assertEquals(modfile.action, "delete");
186:                assertNotNull(element.getProperties().get(PROPERTY_ON_DELETE));
187:            }
188:
189:            public void testHandleEntryLabel() {
190:                List entry = new ArrayList();
191:                entry.add("$/ThirdPartyComponents/jakarta-ant-1.3/lib");
192:                entry.add("Version: 7");
193:                entry.add("User: Etucker         Date:  7/06/01  Time: 10:28a");
194:                entry.add("Labeled test_label");
195:                entry
196:                        .add("Comment: Just testing to see what all gets put in the log file");
197:
198:                Modification mod = element.handleEntry(entry);
199:
200:                assertEquals("Label entry added. Labels shouldn't be added.",
201:                        null, mod);
202:                assertNull(element.getProperties().get(PROPERTY_ON_DELETE));
203:            }
204:
205:            public void testParseDate() throws ParseException {
206:                Date date = element
207:                        .parseDate("User: Etucker         Date:  7/25/01  Time:  2:11p");
208:                SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy hh:mm",
209:                        Locale.US);
210:                assertEquals(sdf.parse("07/25/01 14:11"), date);
211:
212:                element.setDateFormat("d.MM.yy");
213:                element.setTimeFormat("hh:mm");
214:                date = element
215:                        .parseDate("User: Brandhof        Date: 15.11.05  Time:  16:54");
216:                assertEquals(sdf.parse("11/15/05 16:54"), date);
217:            }
218:
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.