Source Code Cross Referenced for ClearCaseTest.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 junit.framework.TestCase;
039:        import net.sourceforge.cruisecontrol.CruiseControlException;
040:        import org.jdom.Document;
041:        import org.jdom.Element;
042:        import org.jdom.JDOMException;
043:        import org.jdom.input.SAXBuilder;
044:
045:        import java.io.BufferedInputStream;
046:        import java.io.File;
047:        import java.io.IOException;
048:        import java.io.InputStream;
049:        import java.text.SimpleDateFormat;
050:        import java.util.Iterator;
051:        import java.util.List;
052:        import java.util.Vector;
053:
054:        /**
055:         * @author Eric Lefevre
056:         */
057:        public class ClearCaseTest extends TestCase {
058:
059:            private static final String WINDOWS_LOG = "clearcase-history.txt";
060:            private static final String UNIX_LOG = "clearcase-history-alt.txt";
061:            private static final String WINDOWS_XML = "clearcase-history.xml";
062:            private static final String UNIX_XML = "clearcase-history-alt.xml";
063:
064:            public static final SimpleDateFormat DATE_FMT = new SimpleDateFormat(
065:                    "yyyy/MM/dd HH:mm:ss");
066:
067:            private ClearCase clearCase;
068:            private List mods;
069:
070:            private InputStream loadTestLog(String name) {
071:                InputStream testStream = getClass().getResourceAsStream(name);
072:                assertNotNull("failed to load resource " + name + " in class "
073:                        + getClass().getName(), testStream);
074:                return testStream;
075:            }
076:
077:            protected void setUp() throws JDOMException, IOException {
078:                // Initialize our ClearCase element
079:                clearCase = new ClearCase();
080:                mods = new Vector();
081:
082:                String testXML;
083:                if (File.separatorChar == '\\') {
084:                    testXML = WINDOWS_XML;
085:                } else {
086:                    testXML = UNIX_XML;
087:                }
088:
089:                // Set up the modification list to match against
090:                SAXBuilder parser = new SAXBuilder();
091:                Document doc = parser.build(loadTestLog(testXML));
092:                List elts = doc.getRootElement().getChildren();
093:
094:                Iterator it = elts.iterator();
095:                while (it.hasNext()) {
096:                    Element elt = (Element) it.next();
097:                    ClearCaseModification mod = new ClearCaseModification();
098:                    mod.fromElement(elt, DATE_FMT);
099:                    mods.add(mod);
100:                }
101:            }
102:
103:            /**
104:             * Tests the streams of bytes that can be returned by the ClearCase server.
105:             */
106:            public void testClearCaseStream() throws IOException {
107:                String testLog;
108:                if (File.separatorChar == '\\') {
109:                    testLog = WINDOWS_LOG;
110:                } else {
111:                    testLog = UNIX_LOG;
112:                }
113:                BufferedInputStream stream = new BufferedInputStream(
114:                        loadTestLog(testLog));
115:
116:                List list = clearCase.parseStream(stream);
117:                assertEquals(mods.size(), list.size());
118:
119:                for (int i = 0; i < list.size(); i++) {
120:                    ClearCaseModification a = (ClearCaseModification) mods
121:                            .get(i);
122:                    ClearCaseModification b = (ClearCaseModification) list
123:                            .get(i);
124:
125:                    assertEquals(a.type, b.type);
126:                    assertEquals(a.modifiedTime, b.modifiedTime);
127:                    assertEquals(a.userName, b.userName);
128:                    assertEquals(a.emailAddress, b.emailAddress);
129:                    assertEquals(a.revision, b.revision);
130:                    assertEquals(a.labels, b.labels);
131:                    assertEquals(a.attributes, b.attributes);
132:
133:                    assertEquals(a.files.size(), b.files.size());
134:                    for (int j = 0; j < b.files.size(); j++) {
135:                        ClearCaseModification.ModifiedFile af = (ClearCaseModification.ModifiedFile) a.files
136:                                .get(j);
137:                        ClearCaseModification.ModifiedFile bf = (ClearCaseModification.ModifiedFile) b.files
138:                                .get(j);
139:                        assertEquals(af.action, bf.action);
140:                        assertEquals(af.fileName, bf.fileName);
141:                        assertEquals(af.folderName, bf.folderName);
142:                        assertEquals(af.revision, bf.revision);
143:                    }
144:
145:                    StringBuffer bc = new StringBuffer(b.comment);
146:                    for (int j = 0; j < bc.length(); j++) {
147:                        if (bc.charAt(j) == 13) {
148:                            bc.deleteCharAt(j);
149:                        }
150:                    }
151:                    assertEquals(a.comment, bc.toString());
152:
153:                    System.out.println("Record " + i + " OK");
154:                }
155:            }
156:
157:            public void testValidate() {
158:                ClearCase cc = new ClearCase();
159:
160:                try {
161:                    cc.validate();
162:                    fail("ClearCase should throw exceptions when required attributes are not set.");
163:                } catch (CruiseControlException e) {
164:                    assertTrue(true);
165:                }
166:
167:                cc.setViewpath("path");
168:
169:                try {
170:                    cc.validate();
171:                    assertTrue(true);
172:                } catch (CruiseControlException e) {
173:                    fail("ClearCase should not throw exceptions when required attributes are set.");
174:                }
175:            }
176:
177:            public void testRecursiveAndAll() {
178:                ClearCase cc = new ClearCase();
179:                cc.setViewpath("path");
180:                cc.setBranch("branch");
181:
182:                // test setting just 'all'
183:                cc.setAll(true);
184:                try {
185:                    cc.validate();
186:                    assertTrue(true);
187:                } catch (CruiseControlException e) {
188:                    fail("ClearCase should not throw exceptions when only the 'all' attribute is set.");
189:                }
190:
191:                // test 'recursive' together with 'all'
192:                cc.setRecursive(true);
193:                try {
194:                    cc.validate();
195:                    fail("ClearCase should throw an exception when both 'recursive' and 'all' are set.");
196:                } catch (CruiseControlException e) {
197:                    assertTrue(true);
198:                }
199:
200:                // reset object to make sure we are testing with defaults
201:                cc = new ClearCase();
202:                cc.setViewpath("path");
203:                cc.setBranch("branch");
204:
205:                // test setting just 'recursive'
206:                cc.setRecursive(true);
207:                try {
208:                    cc.validate();
209:                    assertTrue(true);
210:                } catch (CruiseControlException e) {
211:                    fail("ClearCase should not throw an exception when only the 'all' attribute is set.");
212:                }
213:            }
214:
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.