Source Code Cross Referenced for SOSTest.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » sos » 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 » ANT » org.apache.tools.ant.taskdefs.optional.sos 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:        package org.apache.tools.ant.taskdefs.optional.sos;
019:
020:        import java.io.File;
021:
022:        import org.apache.tools.ant.BuildFileTest;
023:        import org.apache.tools.ant.Project;
024:        import org.apache.tools.ant.types.Commandline;
025:        import org.apache.tools.ant.types.Path;
026:
027:        /**
028:         *  Testcase to ensure that command line generation and required attributes are
029:         *  correct.
030:         *
031:         */
032:        public class SOSTest extends BuildFileTest {
033:
034:            private Commandline commandline;
035:
036:            private static final String VSS_SERVER_PATH = "\\\\server\\vss\\srcsafe.ini";
037:            private static final String VSS_PROJECT_PATH = "/SourceRoot/Project";
038:            private static final String DS_VSS_PROJECT_PATH = "$/SourceRoot/Project";
039:            private static final String SOS_SERVER_PATH = "192.168.0.1:8888";
040:            private static final String SOS_USERNAME = "ant";
041:            private static final String SOS_PASSWORD = "rocks";
042:            private static final String LOCAL_PATH = "testdir";
043:            private static final String SRC_FILE = "Class1.java";
044:            private static final String SRC_LABEL = "label1";
045:            private static final String SRC_COMMENT = "I fixed a bug";
046:            private static final String SOS_HOME = "/home/user/.sos";
047:            private static final String VERSION = "007";
048:
049:            /**
050:             *  Constructor for the SOSTest object
051:             *
052:             * @param  s  Test name
053:             */
054:            public SOSTest(String s) {
055:                super (s);
056:            }
057:
058:            /**
059:             *  The JUnit setup method
060:             *
061:             * @throws  Exception
062:             */
063:            protected void setUp() throws Exception {
064:                project = new Project();
065:                project.setBasedir(".");
066:            }
067:
068:            /**
069:             *  The teardown method for JUnit
070:             *
071:             * @throws  Exception
072:             */
073:            protected void tearDown() throws Exception {
074:                File file = new File(project.getBaseDir(), LOCAL_PATH);
075:                if (file.exists()) {
076:                    file.delete();
077:                }
078:            }
079:
080:            /**  Test SOSGetFile flags & commandline generation  */
081:            public void testGetFileFlags() {
082:                String[] sTestCmdLine = {
083:                        "soscmd",
084:                        "-command",
085:                        "GetFile",
086:                        "-file",
087:                        SRC_FILE,
088:                        "-revision",
089:                        "007",
090:                        "-server",
091:                        SOS_SERVER_PATH,
092:                        "-name",
093:                        SOS_USERNAME,
094:                        "-password",
095:                        SOS_PASSWORD,
096:                        "-database",
097:                        VSS_SERVER_PATH,
098:                        "-project",
099:                        DS_VSS_PROJECT_PATH,
100:                        "-verbose",
101:                        "-nocompress",
102:                        "-nocache",
103:                        "-workdir",
104:                        project.getBaseDir().getAbsolutePath() + File.separator
105:                                + LOCAL_PATH };
106:
107:                // Set up a SOSGet task
108:                SOSGet sosGet = new SOSGet();
109:                sosGet.setProject(project);
110:                sosGet.setVssServerPath(VSS_SERVER_PATH);
111:                sosGet.setSosServerPath(SOS_SERVER_PATH);
112:                sosGet.setProjectPath(VSS_PROJECT_PATH);
113:                sosGet.setFile(SRC_FILE);
114:                sosGet.setUsername(SOS_USERNAME);
115:                sosGet.setPassword(SOS_PASSWORD);
116:                sosGet.setVersion(VERSION);
117:                sosGet.setLocalPath(new Path(project, LOCAL_PATH));
118:                sosGet.setNoCache(true);
119:                sosGet.setNoCompress(true);
120:                sosGet.setVerbose(true);
121:                sosGet.setRecursive(true);
122:
123:                commandline = sosGet.buildCmdLine();
124:
125:                checkCommandLines(sTestCmdLine, commandline.getCommandline());
126:            }
127:
128:            /**  Test SOSGetProject flags & commandline generation  */
129:            public void testGetProjectFlags() {
130:                String[] sTestCmdLine = { "soscmd", "-command", "GetProject",
131:                        "-recursive", "-label", SRC_LABEL, "-server",
132:                        SOS_SERVER_PATH, "-name", SOS_USERNAME, "-password",
133:                        "", "-database", VSS_SERVER_PATH, "-project",
134:                        DS_VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME,
135:                        "-workdir", project.getBaseDir().getAbsolutePath() };
136:
137:                // Set up a SOSGet task
138:                SOSGet sosGet = new SOSGet();
139:                sosGet.setProject(project);
140:                sosGet.setVssServerPath(VSS_SERVER_PATH);
141:                sosGet.setSosServerPath(SOS_SERVER_PATH);
142:                sosGet.setProjectPath(DS_VSS_PROJECT_PATH);
143:                sosGet.setLabel(SRC_LABEL);
144:                sosGet.setUsername(SOS_USERNAME);
145:                sosGet.setSosHome(SOS_HOME);
146:                sosGet.setNoCache(true);
147:                sosGet.setNoCompress(false);
148:                sosGet.setVerbose(false);
149:                sosGet.setRecursive(true);
150:
151:                commandline = sosGet.buildCmdLine();
152:
153:                checkCommandLines(sTestCmdLine, commandline.getCommandline());
154:            }
155:
156:            /**  Tests SOSGet required attributes.  */
157:            public void testGetExceptions() {
158:                configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml");
159:                expectSpecificBuildException("sosget.1", "some cause",
160:                        "sosserverpath attribute must be set!");
161:                expectSpecificBuildException("sosget.2", "some cause",
162:                        "username attribute must be set!");
163:                expectSpecificBuildException("sosget.3", "some cause",
164:                        "vssserverpath attribute must be set!");
165:                expectSpecificBuildException("sosget.4", "some cause",
166:                        "projectpath attribute must be set!");
167:            }
168:
169:            /**  Test CheckInFile option flags  */
170:            public void testCheckinFileFlags() {
171:                String[] sTestCmdLine = {
172:                        "soscmd",
173:                        "-command",
174:                        "CheckInFile",
175:                        "-file",
176:                        SRC_FILE,
177:                        "-server",
178:                        SOS_SERVER_PATH,
179:                        "-name",
180:                        SOS_USERNAME,
181:                        "-password",
182:                        SOS_PASSWORD,
183:                        "-database",
184:                        VSS_SERVER_PATH,
185:                        "-project",
186:                        DS_VSS_PROJECT_PATH,
187:                        "-verbose",
188:                        "-nocompress",
189:                        "-nocache",
190:                        "-workdir",
191:                        project.getBaseDir().getAbsolutePath() + File.separator
192:                                + LOCAL_PATH, "-log", SRC_COMMENT };
193:
194:                // Set up a SOSCheckin task
195:                SOSCheckin sosCheckin = new SOSCheckin();
196:                sosCheckin.setProject(project);
197:                sosCheckin.setVssServerPath(VSS_SERVER_PATH);
198:                sosCheckin.setSosServerPath(SOS_SERVER_PATH);
199:                sosCheckin.setProjectPath(VSS_PROJECT_PATH);
200:                sosCheckin.setFile(SRC_FILE);
201:                sosCheckin.setComment(SRC_COMMENT);
202:                sosCheckin.setUsername(SOS_USERNAME);
203:                sosCheckin.setPassword(SOS_PASSWORD);
204:                sosCheckin.setLocalPath(new Path(project, LOCAL_PATH));
205:                sosCheckin.setNoCache(true);
206:                sosCheckin.setNoCompress(true);
207:                sosCheckin.setVerbose(true);
208:                sosCheckin.setRecursive(true);
209:
210:                commandline = sosCheckin.buildCmdLine();
211:
212:                checkCommandLines(sTestCmdLine, commandline.getCommandline());
213:            }
214:
215:            /**  Test CheckInProject option flags  */
216:            public void testCheckinProjectFlags() {
217:                String[] sTestCmdLine = { "soscmd", "-command",
218:                        "CheckInProject", "-recursive", "-server",
219:                        SOS_SERVER_PATH, "-name", SOS_USERNAME, "-password",
220:                        "", "-database", VSS_SERVER_PATH, "-project",
221:                        DS_VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME,
222:                        "-workdir", project.getBaseDir().getAbsolutePath(),
223:                        "-log", SRC_COMMENT, };
224:
225:                // Set up a SOSCheckin task
226:                SOSCheckin sosCheckin = new SOSCheckin();
227:                sosCheckin.setProject(project);
228:                sosCheckin.setVssServerPath(VSS_SERVER_PATH);
229:                sosCheckin.setSosServerPath(SOS_SERVER_PATH);
230:                sosCheckin.setProjectPath(DS_VSS_PROJECT_PATH);
231:                sosCheckin.setComment(SRC_COMMENT);
232:                sosCheckin.setUsername(SOS_USERNAME);
233:                sosCheckin.setSosHome(SOS_HOME);
234:                sosCheckin.setNoCache(true);
235:                sosCheckin.setNoCompress(false);
236:                sosCheckin.setVerbose(false);
237:                sosCheckin.setRecursive(true);
238:
239:                commandline = sosCheckin.buildCmdLine();
240:
241:                checkCommandLines(sTestCmdLine, commandline.getCommandline());
242:            }
243:
244:            /**  Test SOSCheckIn required attributes.  */
245:            public void testCheckinExceptions() {
246:                configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml");
247:                expectSpecificBuildException("soscheckin.1", "some cause",
248:                        "sosserverpath attribute must be set!");
249:                expectSpecificBuildException("soscheckin.2", "some cause",
250:                        "username attribute must be set!");
251:                expectSpecificBuildException("soscheckin.3", "some cause",
252:                        "vssserverpath attribute must be set!");
253:                expectSpecificBuildException("soscheckin.4", "some cause",
254:                        "projectpath attribute must be set!");
255:            }
256:
257:            /**  Test CheckOutFile option flags  */
258:            public void testCheckoutFileFlags() {
259:                String[] sTestCmdLine = {
260:                        "soscmd",
261:                        "-command",
262:                        "CheckOutFile",
263:                        "-file",
264:                        SRC_FILE,
265:                        "-server",
266:                        SOS_SERVER_PATH,
267:                        "-name",
268:                        SOS_USERNAME,
269:                        "-password",
270:                        SOS_PASSWORD,
271:                        "-database",
272:                        VSS_SERVER_PATH,
273:                        "-project",
274:                        DS_VSS_PROJECT_PATH,
275:                        "-verbose",
276:                        "-nocompress",
277:                        "-nocache",
278:                        "-workdir",
279:                        project.getBaseDir().getAbsolutePath() + File.separator
280:                                + LOCAL_PATH };
281:
282:                // Set up a SOSCheckout task
283:                SOSCheckout sosCheckout = new SOSCheckout();
284:                sosCheckout.setProject(project);
285:                sosCheckout.setVssServerPath(VSS_SERVER_PATH);
286:                sosCheckout.setSosServerPath(SOS_SERVER_PATH);
287:                sosCheckout.setProjectPath(DS_VSS_PROJECT_PATH);
288:                sosCheckout.setFile(SRC_FILE);
289:                sosCheckout.setUsername(SOS_USERNAME);
290:                sosCheckout.setPassword(SOS_PASSWORD);
291:                sosCheckout.setLocalPath(new Path(project, LOCAL_PATH));
292:                sosCheckout.setNoCache(true);
293:                sosCheckout.setNoCompress(true);
294:                sosCheckout.setVerbose(true);
295:                sosCheckout.setRecursive(true);
296:
297:                commandline = sosCheckout.buildCmdLine();
298:
299:                checkCommandLines(sTestCmdLine, commandline.getCommandline());
300:            }
301:
302:            /**  Test CheckOutProject option flags  */
303:            public void testCheckoutProjectFlags() {
304:                String[] sTestCmdLine = { "soscmd", "-command",
305:                        "CheckOutProject", "-recursive", "-server",
306:                        SOS_SERVER_PATH, "-name", SOS_USERNAME, "-password",
307:                        "", "-database", VSS_SERVER_PATH, "-project",
308:                        DS_VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME,
309:                        "-workdir", project.getBaseDir().getAbsolutePath() };
310:
311:                // Set up a sosCheckout task
312:                SOSCheckout sosCheckout = new SOSCheckout();
313:                sosCheckout.setProject(project);
314:                sosCheckout.setVssServerPath(VSS_SERVER_PATH);
315:                sosCheckout.setSosServerPath(SOS_SERVER_PATH);
316:                sosCheckout.setProjectPath(VSS_PROJECT_PATH);
317:                sosCheckout.setUsername(SOS_USERNAME);
318:                sosCheckout.setSosHome(SOS_HOME);
319:                sosCheckout.setNoCache(true);
320:                sosCheckout.setNoCompress(false);
321:                sosCheckout.setVerbose(false);
322:                sosCheckout.setRecursive(true);
323:
324:                commandline = sosCheckout.buildCmdLine();
325:
326:                checkCommandLines(sTestCmdLine, commandline.getCommandline());
327:            }
328:
329:            /**  Test SOSCheckout required attributes.  */
330:            public void testCheckoutExceptions() {
331:                configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml");
332:                expectSpecificBuildException("soscheckout.1", "some cause",
333:                        "sosserverpath attribute must be set!");
334:                expectSpecificBuildException("soscheckout.2", "some cause",
335:                        "username attribute must be set!");
336:                expectSpecificBuildException("soscheckout.3", "some cause",
337:                        "vssserverpath attribute must be set!");
338:                expectSpecificBuildException("soscheckout.4", "some cause",
339:                        "projectpath attribute must be set!");
340:            }
341:
342:            /**  Test Label option flags  */
343:            public void testLabelFlags() {
344:                String[] sTestCmdLine = { "soscmd", "-command", "AddLabel",
345:                        "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME,
346:                        "-password", "", "-database", VSS_SERVER_PATH,
347:                        "-project", DS_VSS_PROJECT_PATH, "-label", SRC_LABEL,
348:                        "-verbose", "-log", SRC_COMMENT };
349:
350:                // Set up a sosCheckout task
351:                SOSLabel sosLabel = new SOSLabel();
352:                sosLabel.setVssServerPath(VSS_SERVER_PATH);
353:                sosLabel.setSosServerPath(SOS_SERVER_PATH);
354:                sosLabel.setProjectPath(DS_VSS_PROJECT_PATH);
355:                sosLabel.setUsername(SOS_USERNAME);
356:                sosLabel.setSosHome(SOS_HOME);
357:                sosLabel.setComment(SRC_COMMENT);
358:                sosLabel.setLabel(SRC_LABEL);
359:                sosLabel.setNoCache(true);
360:                sosLabel.setNoCompress(false);
361:                sosLabel.setVerbose(true);
362:
363:                commandline = sosLabel.buildCmdLine();
364:
365:                checkCommandLines(sTestCmdLine, commandline.getCommandline());
366:            }
367:
368:            /**  Test SOSLabel required attributes.  */
369:            public void testLabelExceptions() {
370:                configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml");
371:                expectSpecificBuildException("soslabel.1", "some cause",
372:                        "sosserverpath attribute must be set!");
373:                expectSpecificBuildException("soslabel.2", "some cause",
374:                        "username attribute must be set!");
375:                expectSpecificBuildException("soslabel.3", "some cause",
376:                        "vssserverpath attribute must be set!");
377:                expectSpecificBuildException("soslabel.4", "some cause",
378:                        "projectpath attribute must be set!");
379:                expectSpecificBuildException("soslabel.5", "some cause",
380:                        "label attribute must be set!");
381:            }
382:
383:            /**
384:             *  Iterate through the generated command line comparing it to reference
385:             *  one.
386:             *
387:             * @param  sTestCmdLine       The reference command line;
388:             * @param  sGeneratedCmdLine  The generated command line;
389:             */
390:            private void checkCommandLines(String[] sTestCmdLine,
391:                    String[] sGeneratedCmdLine) {
392:                int length = sTestCmdLine.length;
393:                for (int i = 0; i < length; i++) {
394:                    try {
395:                        assertEquals("arg # " + String.valueOf(i),
396:                                sTestCmdLine[i], sGeneratedCmdLine[i]);
397:                    } catch (ArrayIndexOutOfBoundsException aioob) {
398:                        fail("missing arg " + sTestCmdLine[i]);
399:                    }
400:                }
401:                if (sGeneratedCmdLine.length > sTestCmdLine.length) {
402:                    // We have extra elements
403:                    fail("extra args");
404:                }
405:            }
406:        }
w__w_w_.j_a___v___a___2s.___c__o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.