diff --git a/WHATSNEW b/WHATSNEW index 5a4cbb392..055e6cfaa 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -78,6 +78,9 @@ Other changes: * new rmdir action for that removes directories from a fileset. +* The SOS and VSS tasks will no longer unconditionally prepend a $ to + vsspath or projectpath. + Changes from Ant 1.5beta3 to Ant 1.5 ==================================== diff --git a/docs/manual/OptionalTasks/sos.html b/docs/manual/OptionalTasks/sos.html index 4b26f6a71..9cdc72a44 100644 --- a/docs/manual/OptionalTasks/sos.html +++ b/docs/manual/OptionalTasks/sos.html @@ -6,7 +6,7 @@ SOS Tasks - +

SourceOffSite Tasks User Manual

@@ -109,7 +109,7 @@ have been tested with Linux, Solaris & Windows2000.

projectpath - SourceSafe project path without the "$" + SourceSafe project path - eg. $/SourceRoot/Project1 Yes @@ -174,20 +174,21 @@ have been tested with Linux, Solaris & Windows2000.

Example

-<sosget verbose="true"
-        recursive="true"
-        username="build"
-        password="build"
-        localpath="tmp"
-        projectpath="/SourceRoot/project1"
-        sosserverpath="192.168.10.6:8888"
-        vssserverpath="d:\vss\srcsafe.ini"/>
+<sosget verbose="true"
+        recursive="true"
+        username="build"
+        password="build"
+        localpath="tmp"
+        projectpath="$/SourceRoot/project1"
+        sosserverpath="192.168.10.6:8888"
+        vssserverpath="d:\vss\srcsafe.ini"/>
 
Connects to a SourceOffsite server on 192.168.10.6:8888 with build,build as the username & password. The SourceSafe database resides on the same box as the SOS server & the VSS database is at -"d:\vss\srcsafe.ini" Does a recursive GetProject on $/SourceRoot/project1, -using tmp as the working directory.
+"d:\vss\srcsafe.ini" Does a recursive GetProject on +$/SourceRoot/project1, using tmp as the working +directory.


@@ -198,7 +199,7 @@ using tmp as the working directory.

Parameters

- + @@ -221,7 +222,7 @@ using tmp as the working directory.
- + @@ -254,19 +255,19 @@ using tmp as the working directory.

Example

-<soslabel username="build"
-          password="build"
-          label="test label"
-          projectpath="/SourceRoot/project1
-          sosserverpath="192.168.10.6:8888"
-          vssserverpath="d:\vss\srcsafe.ini"/>
+<soslabel username="build"
+          password="build"
+          label="test label"
+          projectpath="$/SourceRoot/project1"
+          sosserverpath="192.168.10.6:8888"
+          vssserverpath="d:\vss\srcsafe.ini"/>
 
Connects to a SourceOffsite server on 192.168.10.6:8888 with build,build as the username & password. The SourceSafe database resides on the same box as the SOS server & the VSS database is at -"d:\vss\srcsafe.ini". Labels the $/SourceRoot/project1 project with -"test label".
+"d:\vss\srcsafe.ini". Labels the $/SourceRoot/project1 +project with "test label".



@@ -301,7 +302,7 @@ on the same box as the SOS server & the VSS database is at - + @@ -349,7 +350,7 @@ on the same box as the SOS server & the VSS database is at - + @@ -358,21 +359,22 @@ on the same box as the SOS server & the VSS database is at

Example

-<soscheckin username="build"
-            password="build"
-            file="foobar.txt"
-            verbose="true"
-            comment="comment abc"
-            projectpath="/SourceRoot/project1"
-            sosserverpath="server1:8888"
-            vssserverpath="\\server2\vss\srcsafe.ini"/>
+<soscheckin username="build"
+            password="build"
+            file="foobar.txt"
+            verbose="true"
+            comment="comment abc"
+            projectpath="$/SourceRoot/project1"
+            sosserverpath="server1:8888"
+            vssserverpath="\\server2\vss\srcsafe.ini"/>
 
Connects to a SourceOffsite server on server1:8888 with build,build as the username & password. The SourceSafe database resides on a different -box (server2) & the VSS database is on a share called "vss". Checks-in -only the "foobar.txt" file adding a comment of "comment abc". Extra status -messages will be displayed on screen.
+box (server2) & the VSS database is on a share called +"vss". Checks-in only the "foobar.txt" file adding +a comment of "comment abc". Extra status messages will be +displayed on screen.


@@ -408,7 +410,7 @@ messages will be displayed on screen.
- + @@ -462,20 +464,21 @@ messages will be displayed on screen.

Example

-<soscheckout soscmd="/usr/local/bin"
-             verbose="true"
-             username="build"
-             password="build"
-             projectpath="/SourceRoot/project1"
-             sosserverpath="192.168.10.6:8888"
-             vssserverpath="\\server2\vss\srcsafe.ini"/>
+<soscheckout soscmd="/usr/local/bin"
+             verbose="true"
+             username="build"
+             password="build"
+             projectpath="$/SourceRoot/project1"
+             sosserverpath="192.168.10.6:8888"
+             vssserverpath="\\server2\vss\srcsafe.ini"/>
 
Connects to a SourceOffsite server on server1:8888 with build,build as the username & password. The SourceSafe database resides on a different -box (server2) & the VSS database is on a share called "vss". Checks-out -"project1", Only the "project1" directory will be locked as the recursive -option was not set. Extra status messages will be displayed on screen. The +box (server2) & the VSS database is on a share called +"vss". Checks-out "project1", Only the +"project1" directory will be locked as the recursive option +was not set. Extra status messages will be displayed on screen. The soscmd(.exe) file to be used resides in /usr/local/bin.


diff --git a/docs/manual/OptionalTasks/vss.html b/docs/manual/OptionalTasks/vss.html index 2e499e8a9..be7b1719e 100644 --- a/docs/manual/OptionalTasks/vss.html +++ b/docs/manual/OptionalTasks/vss.html @@ -93,8 +93,7 @@ label only one will be used in the order version, date, label.

+ perform the action on. @@ -164,7 +163,7 @@ label only one will be used in the order version, date, label.

recursive="true" label="Release1" login="me,mypassword" - vsspath="/source/aProject" + vsspath="$/source/aProject" writable="true"/> @@ -191,8 +190,7 @@ project.

+ perform the action on. @@ -240,7 +238,7 @@ project.

Examples

-<vsslabel vsspath="/source/aProject"
+<vsslabel vsspath="$/source/aProject"
           login="me,mypassword"
           label="Release1"/>
 
@@ -251,7 +249,7 @@ the label Release1 using the username me and the password

-<vsslabel vsspath="/source/aProject/myfile.txt"
+<vsslabel vsspath="$/source/aProject/myfile.txt"
           version="4"
           label="1.03.004"/>
 
@@ -277,8 +275,7 @@ Task to perform HISTORY commands to Microsoft Visual SourceSafe.
+ perform the action on. @@ -368,7 +365,7 @@ Task to perform HISTORY commands to Microsoft Visual SourceSafe.

Examples

-<vsshistory vsspath="/myProject" recursive="true"
+<vsshistory vsspath="$/myProject" recursive="true"
             fromLabel="Release1"
             toLabel="Release2"/>
 
@@ -377,7 +374,7 @@ Task to perform HISTORY commands to Microsoft Visual SourceSafe.
-<vsshistory vsspath="/myProject" recursive="true"
+<vsshistory vsspath="$/myProject" recursive="true"
             fromDate="01.01.2001"
             toDate="31.03.2001"/>
 
@@ -390,7 +387,7 @@ Task to perform HISTORY commands to Microsoft Visual SourceSafe. <format property="to.tstamp" pattern="M-d-yy;h:mma" /> </tstamp> -<vsshistory vsspath="/myProject" recursive="true" +<vsshistory vsspath="$/myProject" recursive="true" numDays="-14" dateFormat="M-d-yy;h:mma" toDate="${to.tstamp}"/> @@ -414,8 +411,7 @@ Task to perform CHECKIN commands to Microsoft Visual SourceSafe.
+ perform the action on. @@ -467,12 +463,12 @@ Task to perform CHECKIN commands to Microsoft Visual SourceSafe.

Examples

-<vsscheckin vsspath="/test/test*"
+<vsscheckin vsspath="$/test/test*"
             localpath="D:\build\"
             comment="Modified by automatic build"/>
 
-

Checks in the file(s) named test* in the project test using +

Checks in the file(s) named test* in the project $/test using the local directory D:\build.


@@ -493,8 +489,7 @@ label only one will be used in the order version, date, label.

+ perform the action on. @@ -549,13 +544,13 @@ label only one will be used in the order version, date, label.

Examples

-<vsscheckout vsspath="/test"
+<vsscheckout vsspath="$/test"
              localpath="D:\build"
              recursive="true"
              login="me,mypass"/>
 
-

Does a recursive checkout of the project test to the directory D:\build. +

Does a recursive checkout of the project $/test to the directory D:\build.


@@ -644,8 +639,7 @@ directory (see vsscp).

+ make the current project. @@ -672,7 +666,7 @@ directory (see vsscp).

Examples

-<vsscp vsspath="/Projects/ant"/>
+<vsscp vsspath="$/Projects/ant"/>
 

Sets the current VSS project to $/Projects/ant.

@@ -730,7 +724,7 @@ directory (see vsscp).

Examples

-<vsscreate vsspath="/existingProject/newProject"/>
+<vsscreate vsspath="$/existingProject/newProject"/>
 

Creates the VSS-Project $/existingProject/newProject.

diff --git a/src/etc/testcases/taskdefs/optional/sos/sos.xml b/src/etc/testcases/taskdefs/optional/sos/sos.xml new file mode 100644 index 000000000..23f1cb9fc --- /dev/null +++ b/src/etc/testcases/taskdefs/optional/sos/sos.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java index 5df7a77b6..99bcbaa46 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java @@ -175,7 +175,11 @@ public abstract class SOS extends Task { * @param projectpath The new projectPath value */ public final void setProjectPath(String projectpath) { - projectPath = SOSCmd.PROJECT_PREFIX + projectpath; + if (projectpath.startsWith(SOSCmd.PROJECT_PREFIX)) { + projectPath = projectpath; + } else { + projectPath = SOSCmd.PROJECT_PREFIX + projectpath; + } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java index e84225e0a..1031f0e85 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java @@ -143,10 +143,17 @@ public abstract class MSVSS extends Task { * @param vssPath */ public final void setVsspath(String vssPath) { + String projectPath; if (vssPath.startsWith("vss://")) { - m_vssPath = PROJECT_PREFIX + vssPath.substring(5); + projectPath = vssPath.substring(5); } else { - m_vssPath = PROJECT_PREFIX + vssPath; + projectPath = vssPath; + } + + if (projectPath.charAt(0) == '$') { + m_vssPath = projectPath; + } else { + m_vssPath = PROJECT_PREFIX + projectPath; } } diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java index 4b08e69ea..33de540c2 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java @@ -53,32 +53,29 @@ */ package org.apache.tools.ant.taskdefs.optional.sos; -import junit.framework.TestCase; -import junit.framework.AssertionFailedError; -import org.apache.tools.ant.Project; +import java.io.File; + import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileTest; +import org.apache.tools.ant.Project; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.taskdefs.optional.sos.*; -import java.io.File; /** - * Basic testcase to ensure that command line generation is ok - * @author Jesse Stockall + * Testcase to ensure that command line generation and required attributes are + * correct. + * + * @author Jesse Stockall */ -public class SOSTest extends TestCase { +public class SOSTest extends BuildFileTest { - private SOSGet sosGet; - private SOSCheckin sosCheckin; - private SOSCheckout sosCheckout; - private SOSLabel sosLabel; private Project project; private Commandline commandline; - private FileUtils fileUtils; private static final String VSS_SERVER_PATH = "\\\\server\\vss\\srcsafe.ini"; private static final String VSS_PROJECT_PATH = "/SourceRoot/Project"; + private static final String DS_VSS_PROJECT_PATH = "$/SourceRoot/Project"; private static final String SOS_SERVER_PATH = "192.168.0.1:8888"; private static final String SOS_USERNAME = "ant"; private static final String SOS_PASSWORD = "rocks"; @@ -89,41 +86,50 @@ public class SOSTest extends TestCase { private static final String SOS_HOME = "/home/user/.sos"; private static final String VERSION = "007"; + /** + * Constructor for the SOSTest object + * + * @param s Test name + */ public SOSTest(String s) { super(s); } - protected void setUp() throws Exception { - sosGet = new SOSGet(); - sosCheckin = new SOSCheckin(); - sosCheckout = new SOSCheckout(); - sosLabel = new SOSLabel(); + /** + * The JUnit setup method + * + * @throws Exception + */ + protected void setUp() + throws Exception { project = new Project(); project.setBasedir("."); - fileUtils = FileUtils.newFileUtils(); } - protected void tearDown() throws Exception { + /** + * The teardown method for JUnit + * + * @throws Exception + */ + protected void tearDown() + throws Exception { File file = new File(project.getBaseDir(), LOCAL_PATH); if (file.exists()) { file.delete(); } - } + } - /** - * Test SOSGetFile flags & commandline generation - */ + /** Test SOSGetFile flags & commandline generation */ public void testGetFileFlags() { - String[] sTestCmdLine = { "soscmd", "-command", "GetFile", "-file", - SRC_FILE, "-revision", "007", "-server", SOS_SERVER_PATH, "-name", - SOS_USERNAME, "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, - "-project", "$"+VSS_PROJECT_PATH, "-verbose", "-nocompress", - "-nocache", "-workdir", project.getBaseDir().getAbsolutePath() - + File.separator + LOCAL_PATH }; - - Path path = new Path(project, LOCAL_PATH); + String[] sTestCmdLine = {"soscmd", "-command", "GetFile", "-file", + SRC_FILE, "-revision", "007", "-server", SOS_SERVER_PATH, "-name", + SOS_USERNAME, "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, + "-project", DS_VSS_PROJECT_PATH, "-verbose", "-nocompress", + "-nocache", "-workdir", project.getBaseDir().getAbsolutePath() + + File.separator + LOCAL_PATH}; // Set up a SOSGet task + SOSGet sosGet = new SOSGet(); sosGet.setProject(project); sosGet.setVssServerPath(VSS_SERVER_PATH); sosGet.setSosServerPath(SOS_SERVER_PATH); @@ -132,46 +138,31 @@ public class SOSTest extends TestCase { sosGet.setUsername(SOS_USERNAME); sosGet.setPassword(SOS_PASSWORD); sosGet.setVersion(VERSION); - sosGet.setLocalPath(path); + sosGet.setLocalPath(new Path(project, LOCAL_PATH)); sosGet.setNoCache(true); sosGet.setNoCompress(true); sosGet.setVerbose(true); sosGet.setRecursive(true); commandline = sosGet.buildCmdLine(); - String[] sGeneratedCmdLine = commandline.getCommandline(); - int i = 0; - while (i < sTestCmdLine.length) { - try { - assertEquals("GetFile arg # " + String.valueOf(i), - sTestCmdLine[i], - sGeneratedCmdLine[i]); - i++; - } catch (ArrayIndexOutOfBoundsException aioob) { - fail("GetFile missing arg"); - } - } - if (sGeneratedCmdLine.length > sTestCmdLine.length) { - // We have extra elements - fail("GetFile extra args"); - } + checkCommandLines(sTestCmdLine, commandline.getCommandline()); } - /** - * Test SOSGetProject flags & commandline generation - */ + /** Test SOSGetProject flags & commandline generation */ public void testGetProjectFlags() { - String[] sTestCmdLine = { "soscmd", "-command", "GetProject", "-recursive", - "-label", SRC_LABEL, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, - "-password", "", "-database", VSS_SERVER_PATH , "-project", - "$"+VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", - project.getBaseDir().getAbsolutePath() }; + String[] sTestCmdLine = {"soscmd", "-command", "GetProject", "-recursive", + "-label", SRC_LABEL, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, + "-password", "", "-database", VSS_SERVER_PATH, "-project", + DS_VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", + project.getBaseDir().getAbsolutePath()}; + // Set up a SOSGet task + SOSGet sosGet = new SOSGet(); sosGet.setProject(project); sosGet.setVssServerPath(VSS_SERVER_PATH); sosGet.setSosServerPath(SOS_SERVER_PATH); - sosGet.setProjectPath(VSS_PROJECT_PATH); + sosGet.setProjectPath(DS_VSS_PROJECT_PATH); sosGet.setLabel(SRC_LABEL); sosGet.setUsername(SOS_USERNAME); sosGet.setSosHome(SOS_HOME); @@ -181,105 +172,30 @@ public class SOSTest extends TestCase { sosGet.setRecursive(true); commandline = sosGet.buildCmdLine(); - String[] sGeneratedCmdLine = commandline.getCommandline(); - int i = 0; - while (i < sTestCmdLine.length) { - try { - assertEquals("GetProject arg # " + String.valueOf(i), - sTestCmdLine[i], - sGeneratedCmdLine[i]); - i++; - } catch (ArrayIndexOutOfBoundsException aioob) { - fail("GetProject missing arg"); - } - - } - if (sGeneratedCmdLine.length > sTestCmdLine.length) { - // We have extra elements - fail("GetProject extra args"); - } + checkCommandLines(sTestCmdLine, commandline.getCommandline()); } - /** - * Test SOSGet required attributes 1 by 1 - */ + /** Tests SOSGet required attributes. */ public void testGetExceptions() { - boolean buildEx = false; - - // Set up a SOSGet task - sosGet.setProject(project); - // No options set - SosServerPath should fail - try { - commandline = sosGet.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("sosserverpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("GetException SosServerPath", buildEx); - buildEx = false; - - // Set SosServerPath - Username should fail - sosGet.setSosServerPath(SOS_SERVER_PATH); - try { - commandline = sosGet.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("username attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("GetException Username", buildEx); - buildEx = false; - - // Set Username - VssServerPath should fail - sosGet.setUsername(SOS_USERNAME); - try { - commandline = sosGet.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("vssserverpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("GetException VssServerPath", buildEx); - buildEx = false; - - // Set VssServerPath - ProjectPath should fail - sosGet.setVssServerPath(VSS_SERVER_PATH); - try { - commandline = sosGet.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("projectpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("GetException ProjectPath", buildEx); - - // Set ProjectPath - All required options set - sosGet.setProjectPath(VSS_PROJECT_PATH); - try { - commandline = sosGet.buildCmdLine(); - buildEx = true; - } catch (BuildException be) { - buildEx = false; - } - assertTrue("GetException All required options set", buildEx); + configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); + expectSpecificBuildException("sosget.1", "some cause", "sosserverpath attribute must be set!"); + expectSpecificBuildException("sosget.2", "some cause", "username attribute must be set!"); + expectSpecificBuildException("sosget.3", "some cause", "vssserverpath attribute must be set!"); + expectSpecificBuildException("sosget.4", "some cause", "projectpath attribute must be set!"); } - /** - * Test CheckInFile option flags - */ + /** Test CheckInFile option flags */ public void testCheckinFileFlags() { - String[] sTestCmdLine = { "soscmd", "-command", "CheckInFile", "-file", - SRC_FILE, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, - "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, "-project", - "$"+VSS_PROJECT_PATH, "-verbose", "-nocompress", "-nocache", - "-workdir", project.getBaseDir().getAbsolutePath() + File.separator - + LOCAL_PATH, "-log", SRC_COMMENT }; - - Path path = new Path(project, LOCAL_PATH); + String[] sTestCmdLine = {"soscmd", "-command", "CheckInFile", "-file", + SRC_FILE, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, + "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, "-project", + DS_VSS_PROJECT_PATH, "-verbose", "-nocompress", "-nocache", + "-workdir", project.getBaseDir().getAbsolutePath() + File.separator + + LOCAL_PATH, "-log", SRC_COMMENT}; // Set up a SOSCheckin task + SOSCheckin sosCheckin = new SOSCheckin(); sosCheckin.setProject(project); sosCheckin.setVssServerPath(VSS_SERVER_PATH); sosCheckin.setSosServerPath(SOS_SERVER_PATH); @@ -288,48 +204,31 @@ public class SOSTest extends TestCase { sosCheckin.setComment(SRC_COMMENT); sosCheckin.setUsername(SOS_USERNAME); sosCheckin.setPassword(SOS_PASSWORD); - sosCheckin.setLocalPath(path); + sosCheckin.setLocalPath(new Path(project, LOCAL_PATH)); sosCheckin.setNoCache(true); sosCheckin.setNoCompress(true); sosCheckin.setVerbose(true); sosCheckin.setRecursive(true); commandline = sosCheckin.buildCmdLine(); - String[] sGeneratedCmdLine = commandline.getCommandline(); - int i = 0; - while (i < sTestCmdLine.length) { - try { - assertEquals("CheckInFile arg # " + String.valueOf(i), - sTestCmdLine[i], - sGeneratedCmdLine[i]); - i++; - } catch (ArrayIndexOutOfBoundsException aioob) { - fail("CheckInFile missing arg"); - } - - } - if (sGeneratedCmdLine.length > sTestCmdLine.length) { - // We have extra elements - fail("CheckInFile extra args"); - } + checkCommandLines(sTestCmdLine, commandline.getCommandline()); } - /** - * Test CheckInProject option flags - */ + /** Test CheckInProject option flags */ public void testCheckinProjectFlags() { - String[] sTestCmdLine = { "soscmd", "-command", "CheckInProject", - "-recursive", "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, - "-password", "", "-database", VSS_SERVER_PATH , "-project", - "$"+VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", - project.getBaseDir().getAbsolutePath(), "-log", SRC_COMMENT, }; + String[] sTestCmdLine = {"soscmd", "-command", "CheckInProject", + "-recursive", "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, + "-password", "", "-database", VSS_SERVER_PATH, "-project", + DS_VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", + project.getBaseDir().getAbsolutePath(), "-log", SRC_COMMENT,}; // Set up a SOSCheckin task + SOSCheckin sosCheckin = new SOSCheckin(); sosCheckin.setProject(project); sosCheckin.setVssServerPath(VSS_SERVER_PATH); sosCheckin.setSosServerPath(SOS_SERVER_PATH); - sosCheckin.setProjectPath(VSS_PROJECT_PATH); + sosCheckin.setProjectPath(DS_VSS_PROJECT_PATH); sosCheckin.setComment(SRC_COMMENT); sosCheckin.setUsername(SOS_USERNAME); sosCheckin.setSosHome(SOS_HOME); @@ -339,150 +238,58 @@ public class SOSTest extends TestCase { sosCheckin.setRecursive(true); commandline = sosCheckin.buildCmdLine(); - String[] sGeneratedCmdLine = commandline.getCommandline(); - int i = 0; - while (i < sTestCmdLine.length) { - try { - assertEquals("CheckInProject arg # " + String.valueOf(i), - sTestCmdLine[i], - sGeneratedCmdLine[i]); - i++; - } catch (ArrayIndexOutOfBoundsException aioob) { - fail("CheckInProject missing arg"); - } - - } - if (sGeneratedCmdLine.length > sTestCmdLine.length) { - // We have extra elements - fail("CheckInProject extra args"); - } + checkCommandLines(sTestCmdLine, commandline.getCommandline()); } - /** - * Test SOSCheckIn required attributes 1 by 1 - */ + /** Test SOSCheckIn required attributes. */ public void testCheckinExceptions() { - boolean buildEx = false; - - // Set up a sosCheckin task - sosCheckin.setProject(project); - // No options set - SosServerPath should fail - try { - commandline = sosCheckin.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("sosserverpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("CheckinException SosServerPath", buildEx); - buildEx = false; - - // Set SosServerPath - Username should fail - sosCheckin.setSosServerPath(SOS_SERVER_PATH); - try { - commandline = sosCheckin.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("username attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("CheckinException Username", buildEx); - buildEx = false; - - // Set Username - VssServerPath should fail - sosCheckin.setUsername(SOS_USERNAME); - try { - commandline = sosCheckin.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("vssserverpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("CheckinException VssServerPath", buildEx); - buildEx = false; - - // Set VssServerPath - ProjectPath should fail - sosCheckin.setVssServerPath(VSS_SERVER_PATH); - try { - commandline = sosCheckin.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("projectpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("CheckinException ProjectPath", buildEx); - - // Set ProjectPath - All required options set - sosCheckin.setProjectPath(VSS_PROJECT_PATH); - try { - commandline = sosCheckin.buildCmdLine(); - buildEx = true; - } catch (BuildException be) { - buildEx = false; - } - assertTrue("CheckinException All required options set", buildEx); + configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); + expectSpecificBuildException("soscheckin.1", "some cause", "sosserverpath attribute must be set!"); + expectSpecificBuildException("soscheckin.2", "some cause", "username attribute must be set!"); + expectSpecificBuildException("soscheckin.3", "some cause", "vssserverpath attribute must be set!"); + expectSpecificBuildException("soscheckin.4", "some cause", "projectpath attribute must be set!"); } - /** - * Test CheckOutFile option flags - */ + /** Test CheckOutFile option flags */ public void testCheckoutFileFlags() { - String[] sTestCmdLine = { "soscmd", "-command", "CheckOutFile", "-file", - SRC_FILE, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, - "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, "-project", - "$"+VSS_PROJECT_PATH, "-verbose", "-nocompress", "-nocache", - "-workdir", project.getBaseDir().getAbsolutePath() - + File.separator + LOCAL_PATH }; - - Path path = new Path(project, LOCAL_PATH); + String[] sTestCmdLine = {"soscmd", "-command", "CheckOutFile", "-file", + SRC_FILE, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, + "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, "-project", + DS_VSS_PROJECT_PATH, "-verbose", "-nocompress", "-nocache", + "-workdir", project.getBaseDir().getAbsolutePath() + + File.separator + LOCAL_PATH}; // Set up a SOSCheckout task + SOSCheckout sosCheckout = new SOSCheckout(); sosCheckout.setProject(project); sosCheckout.setVssServerPath(VSS_SERVER_PATH); sosCheckout.setSosServerPath(SOS_SERVER_PATH); - sosCheckout.setProjectPath(VSS_PROJECT_PATH); + sosCheckout.setProjectPath(DS_VSS_PROJECT_PATH); sosCheckout.setFile(SRC_FILE); sosCheckout.setUsername(SOS_USERNAME); sosCheckout.setPassword(SOS_PASSWORD); - sosCheckout.setLocalPath(path); + sosCheckout.setLocalPath(new Path(project, LOCAL_PATH)); sosCheckout.setNoCache(true); sosCheckout.setNoCompress(true); sosCheckout.setVerbose(true); sosCheckout.setRecursive(true); commandline = sosCheckout.buildCmdLine(); - String[] sGeneratedCmdLine = commandline.getCommandline(); - int i = 0; - while (i < sTestCmdLine.length) { - try { - assertEquals("CheckOutFile arg # " + String.valueOf(i), - sTestCmdLine[i], - sGeneratedCmdLine[i]); - i++; - } catch (ArrayIndexOutOfBoundsException aioob) { - fail("CheckOutFile missing arg"); - } - - } - if (sGeneratedCmdLine.length > sTestCmdLine.length) { - // We have extra elements - fail("CheckOutFile extra args"); - } + checkCommandLines(sTestCmdLine, commandline.getCommandline()); } - /** - * Test CheckOutProject option flags - */ + /** Test CheckOutProject option flags */ public void testCheckoutProjectFlags() { - String[] sTestCmdLine = { "soscmd", "-command", "CheckOutProject", - "-recursive", "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, - "-password", "", "-database", VSS_SERVER_PATH , "-project", - "$"+VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", - project.getBaseDir().getAbsolutePath() }; + String[] sTestCmdLine = {"soscmd", "-command", "CheckOutProject", + "-recursive", "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, + "-password", "", "-database", VSS_SERVER_PATH, "-project", + DS_VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", + project.getBaseDir().getAbsolutePath()}; // Set up a sosCheckout task + SOSCheckout sosCheckout = new SOSCheckout(); sosCheckout.setProject(project); sosCheckout.setVssServerPath(VSS_SERVER_PATH); sosCheckout.setSosServerPath(SOS_SERVER_PATH); @@ -495,104 +302,31 @@ public class SOSTest extends TestCase { sosCheckout.setRecursive(true); commandline = sosCheckout.buildCmdLine(); - String[] sGeneratedCmdLine = commandline.getCommandline(); - int i = 0; - while (i < sTestCmdLine.length) { - try { - assertEquals("CheckOutProject arg # " + String.valueOf(i), - sTestCmdLine[i], - sGeneratedCmdLine[i]); - i++; - } catch (ArrayIndexOutOfBoundsException aioob) { - fail("CheckOutProject missing arg"); - } - - } - if (sGeneratedCmdLine.length > sTestCmdLine.length) { - // We have extra elements - fail("CheckOutProject extra args"); - } + checkCommandLines(sTestCmdLine, commandline.getCommandline()); } - /** - * Test SOSCheckout required attributes 1 by 1 - */ + /** Test SOSCheckout required attributes. */ public void testCheckoutExceptions() { - boolean buildEx = false; - - // Set up a sosCheckout task - sosCheckout.setProject(project); - // No options set - SosServerPath should fail - try { - commandline = sosCheckout.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("sosserverpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("CheckoutException SosServerPath", buildEx); - buildEx = false; - - // Set SosServerPath - Username should fail - sosCheckout.setSosServerPath(SOS_SERVER_PATH); - try { - commandline = sosCheckout.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("username attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("CheckoutException Username", buildEx); - buildEx = false; - - // Set Username - VssServerPath should fail - sosCheckout.setUsername(SOS_USERNAME); - try { - commandline = sosCheckout.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("vssserverpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("CheckoutException VssServerPath", buildEx); - buildEx = false; - - // Set VssServerPath - ProjectPath should fail - sosCheckout.setVssServerPath(VSS_SERVER_PATH); - try { - commandline = sosCheckout.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("projectpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("CheckoutException ProjectPath", buildEx); - - // Set ProjectPath - All required options set - sosCheckout.setProjectPath(VSS_PROJECT_PATH); - try { - commandline = sosCheckout.buildCmdLine(); - buildEx = true; - } catch (BuildException be) { - buildEx = false; - } - assertTrue("CheckoutException All required options set", buildEx); + configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); + expectSpecificBuildException("soscheckout.1", "some cause", "sosserverpath attribute must be set!"); + expectSpecificBuildException("soscheckout.2", "some cause", "username attribute must be set!"); + expectSpecificBuildException("soscheckout.3", "some cause", "vssserverpath attribute must be set!"); + expectSpecificBuildException("soscheckout.4", "some cause", "projectpath attribute must be set!"); } - /** - * Test Label option flags - */ + /** Test Label option flags */ public void testLabelFlags() { - String[] sTestCmdLine = { "soscmd", "-command", "AddLabel", "-server", - SOS_SERVER_PATH, "-name", SOS_USERNAME, "-password", "", "-database", - VSS_SERVER_PATH , "-project", "$"+VSS_PROJECT_PATH, "-label", - SRC_LABEL, "-verbose", "-log", SRC_COMMENT }; + String[] sTestCmdLine = {"soscmd", "-command", "AddLabel", "-server", + SOS_SERVER_PATH, "-name", SOS_USERNAME, "-password", "", "-database", + VSS_SERVER_PATH, "-project", DS_VSS_PROJECT_PATH, "-label", + SRC_LABEL, "-verbose", "-log", SRC_COMMENT}; // Set up a sosCheckout task + SOSLabel sosLabel = new SOSLabel(); sosLabel.setVssServerPath(VSS_SERVER_PATH); sosLabel.setSosServerPath(SOS_SERVER_PATH); - sosLabel.setProjectPath(VSS_PROJECT_PATH); + sosLabel.setProjectPath(DS_VSS_PROJECT_PATH); sosLabel.setUsername(SOS_USERNAME); sosLabel.setSosHome(SOS_HOME); sosLabel.setComment(SRC_COMMENT); @@ -602,100 +336,41 @@ public class SOSTest extends TestCase { sosLabel.setVerbose(true); commandline = sosLabel.buildCmdLine(); - String[] sGeneratedCmdLine = commandline.getCommandline(); - int i = 0; - while (i < sTestCmdLine.length) { - try { - assertEquals("AddLabel arg # " + String.valueOf(i), - sTestCmdLine[i], - sGeneratedCmdLine[i]); - i++; - } catch (ArrayIndexOutOfBoundsException aioob) { - fail("AddLabel missing arg"); - } + checkCommandLines(sTestCmdLine, commandline.getCommandline()); + } - } - if (sGeneratedCmdLine.length > sTestCmdLine.length) { - // We have extra elements - fail("AddLabel extra args"); - } + /** Test SOSLabel required attributes. */ + public void testLabelExceptions() { + configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); + expectSpecificBuildException("soslabel.1", "some cause", "sosserverpath attribute must be set!"); + expectSpecificBuildException("soslabel.2", "some cause", "username attribute must be set!"); + expectSpecificBuildException("soslabel.3", "some cause", "vssserverpath attribute must be set!"); + expectSpecificBuildException("soslabel.4", "some cause", "projectpath attribute must be set!"); + expectSpecificBuildException("soslabel.5", "some cause", "label attribute must be set!"); } /** - * Test SOSLabel required attributes 1 by 1 + * Iterate through the generated command line comparing it to reference + * one. + * + * @param sTestCmdLine The reference command line; + * @param sGeneratedCmdLine The generated command line; */ - public void testLabelExceptions() { - boolean buildEx = false; - - // Set up a sosLabel task - sosLabel.setProject(project); - // No options set - SosServerPath should fail - try { - commandline = sosLabel.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("sosserverpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("LabelException SosServerPath", buildEx); - buildEx = false; - - // Set SosServerPath - Username should fail - sosLabel.setSosServerPath(SOS_SERVER_PATH); - try { - commandline = sosLabel.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("username attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("LabelException Username", buildEx); - buildEx = false; - - // Set Username - VssServerPath should fail - sosLabel.setUsername(SOS_USERNAME); - try { - commandline = sosLabel.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("vssserverpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("LabelException VssServerPath", buildEx); - buildEx = false; - - // Set VssServerPath - ProjectPath should fail - sosLabel.setVssServerPath(VSS_SERVER_PATH); - try { - commandline = sosLabel.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("projectpath attribute must be set!") == 0) { - buildEx = true; - } - } - assertTrue("LabelException ProjectPath", buildEx); - - // Set ProjectPath - Label should fail - sosLabel.setProjectPath(VSS_PROJECT_PATH); - try { - commandline = sosLabel.buildCmdLine(); - } catch (BuildException be) { - if (be.getMessage().compareTo("label attribute must be set!") == 0) { - buildEx = true; + private void checkCommandLines(String[] sTestCmdLine, String[] sGeneratedCmdLine) { + int length = sTestCmdLine.length; + for (int i = 0; i < length; i++) { + try { + assertEquals("arg # " + String.valueOf(i), + sTestCmdLine[i], + sGeneratedCmdLine[i]); + } catch (ArrayIndexOutOfBoundsException aioob) { + fail("missing arg " + sTestCmdLine[i]); } } - assertTrue("LabelException Label", buildEx); - - // Set Label - All required options set - sosLabel.setLabel(SRC_LABEL); - try { - commandline = sosLabel.buildCmdLine(); - buildEx = true; - } catch (BuildException be) { - buildEx = false; + if (sGeneratedCmdLine.length > sTestCmdLine.length) { + // We have extra elements + fail("extra args"); } - assertTrue("LabelException All required options set", buildEx); } - }
Attribute Values Required
projectpathSourceSafe project path without the "$"SourceSafe project path - eg. $/SourceRoot/Project1 Yes
projectpathSourceSafe project path without the "$"SourceSafe project path - eg. $/SourceRoot/Project1 Yes
true or false - Status messages are displayed No
comment
comment A comment to be applied to all files being checked in No
projectpathSourceSafe project path without the "$"SourceSafe project path - eg. $/SourceRoot/Project1 Yes
vsspath SourceSafe path which specifies the project/file(s) you wish to - perform the action on. You should not specify the leading dollar-sign - - it is prepended by Ant automatically. Yes
vsspath SourceSafe path which specifies the project/file(s) you wish to - perform the action on. You should not specify the leading dollar-sign - - it is prepended by Ant automatically. Yes
vsspath SourceSafe path which specifies the project/file(s) you wish to - perform the action on. You should not specify the leading dollar-sign - - it is prepended by Ant automatically. Yes
vsspath SourceSafe path which specifies the project/file(s) you wish to - perform the action on. You should not specify the leading dollar-sign - - it is prepended by Ant automatically. Yes
vsspath SourceSafe path which specifies the project/file(s) you wish to - perform the action on. You should not specify the leading dollar-sign - - it is prepended by Ant automatically. Yes
vsspath SourceSafe path which specifies the project you wish to - make the current project. You should not specify the leading dollar-sign - - it is prepended by Ant automatically. Yes