Source Code Cross Referenced for ModificationTest.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) 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;
037:
038:        import java.text.SimpleDateFormat;
039:        import java.util.Date;
040:        import java.util.List;
041:
042:        import junit.framework.TestCase;
043:
044:        public class ModificationTest extends TestCase {
045:
046:            public void testToXml() {
047:                Date modifiedTime = new Date();
048:                SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
049:                Modification mod = new Modification();
050:
051:                Modification.ModifiedFile modfile = mod.createModifiedFile(
052:                        "File\"Name&", "Folder'Name");
053:                modfile.action = "checkin";
054:
055:                mod.modifiedTime = modifiedTime;
056:                mod.userName = "User<>Name";
057:                mod.comment = "Comment";
058:
059:                String base = "<modification type=\"unknown\">"
060:                        + "<file action=\"checkin\"><filename>File\"Name&amp;</filename>"
061:                        + "<project>Folder'Name</project></file>" + "<date>"
062:                        + formatter.format(modifiedTime) + "</date>"
063:                        + "<user>User&lt;&gt;Name</user>"
064:                        + "<comment><![CDATA[Comment]]></comment>";
065:                String closingTag = "</modification>";
066:                String expected = base + closingTag;
067:
068:                assertEquals(expected, mod.toXml(formatter));
069:
070:                String expectedWithEmail = base
071:                        + "<email>foo.bar@quuuux.quuux.quux.qux</email>"
072:                        + closingTag;
073:                mod.emailAddress = "foo.bar@quuuux.quuux.quux.qux";
074:
075:                assertEquals(expectedWithEmail, mod.toXml(formatter));
076:            }
077:
078:            public void testBadComment() {
079:                Date modifiedTime = new Date();
080:                SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
081:                Modification mod = new Modification();
082:
083:                Modification.ModifiedFile modfile = mod.createModifiedFile(
084:                        "File\"Name&", "Folder'Name");
085:                modfile.action = "checkin";
086:
087:                mod.modifiedTime = modifiedTime;
088:                mod.userName = "User<>Name";
089:                mod.comment = "Attempting to heal the wounded build.\0x18";
090:
091:                String base = "<modification type=\"unknown\">"
092:                        + "<file action=\"checkin\"><filename>File\"Name&amp;</filename>"
093:                        + "<project>Folder'Name</project></file>"
094:                        + "<date>"
095:                        + formatter.format(modifiedTime)
096:                        + "</date>"
097:                        + "<user>User&lt;&gt;Name</user>"
098:                        + "<comment><![CDATA[Unable to parse comment.  It contains illegal data.]]></comment>";
099:                String closingTag = "</modification>";
100:                String expected = base + closingTag;
101:
102:                assertEquals(expected, mod.toXml(formatter));
103:            }
104:
105:            public void testToElementAndBack() throws Exception {
106:                Date modifiedTime = new Date();
107:                SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
108:                Modification mod = new Modification();
109:
110:                Modification.ModifiedFile modfile = mod.createModifiedFile(
111:                        "File\"Name&", "Folder'Name");
112:                modfile.action = "checkin";
113:
114:                mod.modifiedTime = modifiedTime;
115:                mod.userName = "User<>Name";
116:                mod.comment = "Attempting to heal the wounded build.\0x18";
117:
118:                Modification modification = new Modification();
119:                modification.fromElement(mod.toElement(formatter), formatter);
120:                mod.equals(modification);
121:
122:                // Test getFullPath() of Modificaiton object.
123:                assertEquals("Folder'Name/File\"Name&", modification
124:                        .getFullPath());
125:            }
126:
127:            public void testGettingModifiedFiles() {
128:                Modification mod = new Modification();
129:
130:                // Test getting when no files are present
131:                assertNull(mod.getFileName());
132:                assertNull(mod.getFolderName());
133:                assertNotNull(mod.getModifiedFiles());
134:                assertEquals(0, mod.getModifiedFiles().size());
135:
136:                // Add first file
137:                final String filename1 = "filename-1";
138:                final String folder1 = "folder-1";
139:                Modification.ModifiedFile file1 = mod.createModifiedFile(
140:                        filename1, folder1);
141:
142:                assertEquals(filename1, file1.fileName);
143:                assertEquals(folder1, file1.folderName);
144:
145:                assertEquals(filename1, mod.getFileName());
146:                assertEquals(folder1, mod.getFolderName());
147:
148:                List modList = mod.getModifiedFiles();
149:                assertEquals(1, modList.size());
150:                assertSame(file1, modList.get(0));
151:
152:                // Add second file
153:                final String filename2 = "filename-2";
154:                final String folder2 = "folder-2";
155:                Modification.ModifiedFile file2 = mod.createModifiedFile(
156:                        filename2, folder2);
157:
158:                assertEquals(filename2, file2.fileName);
159:                assertEquals(folder2, file2.folderName);
160:
161:                assertEquals(filename1, mod.getFileName());
162:                assertEquals(folder1, mod.getFolderName());
163:
164:                modList = mod.getModifiedFiles();
165:                assertEquals(2, modList.size());
166:                assertSame(file1, modList.get(0));
167:                assertSame(file2, modList.get(1));
168:
169:                // Add third file
170:                final String filename3 = "filename-3";
171:                final String folder3 = "folder-3";
172:                Modification.ModifiedFile file3 = mod.createModifiedFile(
173:                        filename3, folder3);
174:
175:                assertEquals(filename3, file3.fileName);
176:                assertEquals(folder3, file3.folderName);
177:
178:                assertEquals(filename1, mod.getFileName());
179:                assertEquals(folder1, mod.getFolderName());
180:
181:                modList = mod.getModifiedFiles();
182:                assertEquals(3, modList.size());
183:                assertSame(file1, modList.get(0));
184:                assertSame(file2, modList.get(1));
185:                assertSame(file3, modList.get(2));
186:            }
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.