Browse Source

Remove magic that prepends a $ to vsspath and projectpath in VSS and

SOS tasks.

PR: 10201
Submitted by:	Jesse Stockall <jesse at cryptocard.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273365 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
04408cb596
7 changed files with 332 additions and 538 deletions
  1. +3
    -0
      WHATSNEW
  2. +49
    -46
      docs/manual/OptionalTasks/sos.html
  3. +18
    -24
      docs/manual/OptionalTasks/vss.html
  4. +108
    -0
      src/etc/testcases/taskdefs/optional/sos/sos.xml
  5. +5
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java
  6. +9
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
  7. +140
    -465
      src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java

+ 3
- 0
WHATSNEW View File

@@ -78,6 +78,9 @@ Other changes:


* new rmdir action for <ftp> that removes directories from a fileset. * new rmdir action for <ftp> 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 Changes from Ant 1.5beta3 to Ant 1.5
==================================== ====================================




+ 49
- 46
docs/manual/OptionalTasks/sos.html View File

@@ -6,7 +6,7 @@
<title>SOS Tasks</title> <title>SOS Tasks</title>


</head> </head>
<body>
<body>


<div align="center"> <div align="center">
<h1>SourceOffSite Tasks User Manual</h1> <h1>SourceOffSite Tasks User Manual</h1>
@@ -109,7 +109,7 @@ have been tested with Linux, Solaris &amp; Windows2000.</p>
</tr> </tr>
<tr> <tr>
<td>projectpath</td> <td>projectpath</td>
<td>SourceSafe project path without the "$"</td>
<td>SourceSafe project path - eg. $/SourceRoot/Project1</td>
<td>Yes</td> <td>Yes</td>
</tr> </tr>
<tr> <tr>
@@ -174,20 +174,21 @@ have been tested with Linux, Solaris &amp; Windows2000.</p>
<h3>Example</h3> <h3>Example</h3>


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


<hr width="100%" size="2"> <hr width="100%" size="2">
@@ -198,7 +199,7 @@ using tmp as the working directory. </small><br>
<h3>Parameters</h3> <h3>Parameters</h3>


<table border="1"> <table border="1">
<tr>
<tbody><tr>
<th>Attribute</th> <th>Attribute</th>
<th>Values</th> <th>Values</th>
<th>Required</th> <th>Required</th>
@@ -221,7 +222,7 @@ using tmp as the working directory. </small><br>
</tr> </tr>
<tr> <tr>
<td>projectpath</td> <td>projectpath</td>
<td>SourceSafe project path without the "$"</td>
<td>SourceSafe project path - eg. $/SourceRoot/Project1</td>
<td>Yes</td> <td>Yes</td>
</tr> </tr>
<tr> <tr>
@@ -254,19 +255,19 @@ using tmp as the working directory. </small><br>


<h3>Example</h3> <h3>Example</h3>
<pre> <pre>
&lt;soslabel username="build"
password="build"
label="test label"
projectpath="/SourceRoot/project1
sosserverpath="192.168.10.6:8888"
vssserverpath="d:\vss\srcsafe.ini"/&gt;
&lt;soslabel username=&quot;build&quot;
password=&quot;build&quot;
label=&quot;test label&quot;
projectpath=&quot;$/SourceRoot/project1&quot;
sosserverpath=&quot;192.168.10.6:8888&quot;
vssserverpath=&quot;d:\vss\srcsafe.ini&quot;/&gt;
</pre> </pre>


<small>Connects to a SourceOffsite server on 192.168.10.6:8888 with <small>Connects to a SourceOffsite server on 192.168.10.6:8888 with
build,build as the username &amp; password. The SourceSafe database resides build,build as the username &amp; password. The SourceSafe database resides
on the same box as the SOS server &amp; the VSS database is at on the same box as the SOS server &amp; the VSS database is at
"d:\vss\srcsafe.ini". Labels the $/SourceRoot/project1 project with
"test label".</small><br>
&quot;d:\vss\srcsafe.ini&quot;. Labels the $/SourceRoot/project1
project with &quot;test label&quot;.</small><br>
<br> <br>


<hr width="100%" size="2"><br> <hr width="100%" size="2"><br>
@@ -301,7 +302,7 @@ on the same box as the SOS server &amp; the VSS database is at
</tr> </tr>
<tr> <tr>
<td>projectpath</td> <td>projectpath</td>
<td>SourceSafe project path without the "$"</td>
<td>SourceSafe project path - eg. $/SourceRoot/Project1</td>
<td>Yes</td> <td>Yes</td>
</tr> </tr>
<tr> <tr>
@@ -349,7 +350,7 @@ on the same box as the SOS server &amp; the VSS database is at
<td>true or false - Status messages are displayed</td> <td>true or false - Status messages are displayed</td>
<td>No</td> <td>No</td>
</tr> </tr>
<td>comment</td>
<tr><td>comment</td>
<td>A comment to be applied to all files being checked in</td> <td>A comment to be applied to all files being checked in</td>
<td>No</td> <td>No</td>
</tr> </tr>
@@ -358,21 +359,22 @@ on the same box as the SOS server &amp; the VSS database is at


<h3>Example</h3> <h3>Example</h3>
<pre> <pre>
&lt;soscheckin username="build"
password="build"
file="foobar.txt"
verbose="true"
comment="comment abc"
projectpath="/SourceRoot/project1"
sosserverpath="server1:8888"
vssserverpath="\\server2\vss\srcsafe.ini"/&gt;
&lt;soscheckin username=&quot;build&quot;
password=&quot;build&quot;
file=&quot;foobar.txt&quot;
verbose=&quot;true&quot;
comment=&quot;comment abc&quot;
projectpath=&quot;$/SourceRoot/project1&quot;
sosserverpath=&quot;server1:8888&quot;
vssserverpath=&quot;\\server2\vss\srcsafe.ini&quot;/&gt;
</pre> </pre>


<small>Connects to a SourceOffsite server on server1:8888 with build,build as <small>Connects to a SourceOffsite server on server1:8888 with build,build as
the username &amp; password. The SourceSafe database resides on a different the username &amp; password. The SourceSafe database resides on a different
box (server2) &amp; 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.</small><br>
box (server2) &amp; the VSS database is on a share called
&quot;vss&quot;. Checks-in only the &quot;foobar.txt&quot; file adding
a comment of &quot;comment abc&quot;. Extra status messages will be
displayed on screen.</small><br>
<br> <br>


<hr width="100%" size="2"> <hr width="100%" size="2">
@@ -408,7 +410,7 @@ messages will be displayed on screen.</small><br>
</tr> </tr>
<tr> <tr>
<td>projectpath</td> <td>projectpath</td>
<td>SourceSafe project path without the "$"</td>
<td>SourceSafe project path - eg. $/SourceRoot/Project1</td>
<td>Yes</td> <td>Yes</td>
</tr> </tr>
<tr> <tr>
@@ -462,20 +464,21 @@ messages will be displayed on screen.</small><br>


<h3>Example</h3> <h3>Example</h3>
<pre> <pre>
&lt;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"/&gt;
&lt;soscheckout soscmd=&quot;/usr/local/bin&quot;
verbose=&quot;true&quot;
username=&quot;build&quot;
password=&quot;build&quot;
projectpath=&quot;$/SourceRoot/project1&quot;
sosserverpath=&quot;192.168.10.6:8888&quot;
vssserverpath=&quot;\\server2\vss\srcsafe.ini&quot;/&gt;
</pre> </pre>


<small>Connects to a SourceOffsite server on server1:8888 with build,build as <small>Connects to a SourceOffsite server on server1:8888 with build,build as
the username &amp; password. The SourceSafe database resides on a different the username &amp; password. The SourceSafe database resides on a different
box (server2) &amp; 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) &amp; the VSS database is on a share called
&quot;vss&quot;. Checks-out &quot;project1&quot;, Only the
&quot;project1&quot; 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.</small><br> soscmd(.exe) file to be used resides in /usr/local/bin.</small><br>
<br> <br>
<hr> <hr>


+ 18
- 24
docs/manual/OptionalTasks/vss.html View File

@@ -93,8 +93,7 @@ label only one will be used in the order version, date, label.</p>
<tr> <tr>
<td>vsspath</td> <td>vsspath</td>
<td>SourceSafe path which specifies the project/file(s) you wish to <td>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.</td>
perform the action on.</td>
<td>Yes</td> <td>Yes</td>
</tr> </tr>
<tr> <tr>
@@ -164,7 +163,7 @@ label only one will be used in the order version, date, label.</p>
recursive=&quot;true&quot; recursive=&quot;true&quot;
label=&quot;Release1&quot; label=&quot;Release1&quot;
login=&quot;me,mypassword&quot; login=&quot;me,mypassword&quot;
vsspath=&quot;/source/aProject&quot;
vsspath=&quot;$/source/aProject&quot;
writable=&quot;true&quot;/&gt; writable=&quot;true&quot;/&gt;
</pre> </pre>
</blockquote> </blockquote>
@@ -191,8 +190,7 @@ project.</p>
<tr> <tr>
<td>vsspath</td> <td>vsspath</td>
<td>SourceSafe path which specifies the project/file(s) you wish to <td>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.</td>
perform the action on.</td>
<td>Yes</td> <td>Yes</td>
</tr> </tr>
<tr> <tr>
@@ -240,7 +238,7 @@ project.</p>
<h3>Examples</h3> <h3>Examples</h3>
<blockquote> <blockquote>
<pre> <pre>
&lt;vsslabel vsspath=&quot;/source/aProject&quot;
&lt;vsslabel vsspath=&quot;$/source/aProject&quot;
login=&quot;me,mypassword&quot; login=&quot;me,mypassword&quot;
label=&quot;Release1&quot;/&gt; label=&quot;Release1&quot;/&gt;
</pre> </pre>
@@ -251,7 +249,7 @@ the label <i>Release1</i> using the username <i>me</i> and the password
</p> </p>
<blockquote> <blockquote>
<pre> <pre>
&lt;vsslabel vsspath=&quot;/source/aProject/myfile.txt&quot;
&lt;vsslabel vsspath=&quot;$/source/aProject/myfile.txt&quot;
version=&quot;4&quot; version=&quot;4&quot;
label=&quot;1.03.004&quot;/&gt; label=&quot;1.03.004&quot;/&gt;
</pre> </pre>
@@ -277,8 +275,7 @@ Task to perform HISTORY commands to Microsoft Visual SourceSafe.
<tr> <tr>
<td>vsspath</td> <td>vsspath</td>
<td>SourceSafe path which specifies the project/file(s) you wish to <td>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.</td>
perform the action on.</td>
<td>Yes</td> <td>Yes</td>
</tr> </tr>
<tr> <tr>
@@ -368,7 +365,7 @@ Task to perform HISTORY commands to Microsoft Visual SourceSafe.
<h3>Examples</h3> <h3>Examples</h3>
<blockquote> <blockquote>
<pre> <pre>
&lt;vsshistory vsspath=&quot;/myProject&quot; recursive=&quot;true&quot;
&lt;vsshistory vsspath=&quot;$/myProject&quot; recursive=&quot;true&quot;
fromLabel=&quot;Release1&quot; fromLabel=&quot;Release1&quot;
toLabel=&quot;Release2&quot;/&gt; toLabel=&quot;Release2&quot;/&gt;
</pre> </pre>
@@ -377,7 +374,7 @@ Task to perform HISTORY commands to Microsoft Visual SourceSafe.


<blockquote> <blockquote>
<pre> <pre>
&lt;vsshistory vsspath=&quot;/myProject&quot; recursive=&quot;true&quot;
&lt;vsshistory vsspath=&quot;$/myProject&quot; recursive=&quot;true&quot;
fromDate=&quot;01.01.2001&quot; fromDate=&quot;01.01.2001&quot;
toDate=&quot;31.03.2001&quot;/&gt; toDate=&quot;31.03.2001&quot;/&gt;
</pre> </pre>
@@ -390,7 +387,7 @@ Task to perform HISTORY commands to Microsoft Visual SourceSafe.
&lt;format property=&quot;to.tstamp&quot; pattern=&quot;M-d-yy;h:mma&quot; /&gt; &lt;format property=&quot;to.tstamp&quot; pattern=&quot;M-d-yy;h:mma&quot; /&gt;
&lt;/tstamp&gt; &lt;/tstamp&gt;


&lt;vsshistory vsspath=&quot;/myProject&quot; recursive=&quot;true&quot;
&lt;vsshistory vsspath=&quot;$/myProject&quot; recursive=&quot;true&quot;
numDays=&quot;-14&quot; numDays=&quot;-14&quot;
dateFormat=&quot;M-d-yy;h:mma&quot; dateFormat=&quot;M-d-yy;h:mma&quot;
toDate=&quot;${to.tstamp}&quot;/&gt; toDate=&quot;${to.tstamp}&quot;/&gt;
@@ -414,8 +411,7 @@ Task to perform CHECKIN commands to Microsoft Visual SourceSafe.
<tr> <tr>
<td>vsspath</td> <td>vsspath</td>
<td>SourceSafe path which specifies the project/file(s) you wish to <td>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.</td>
perform the action on.</td>
<td>Yes</td> <td>Yes</td>
</tr> </tr>
<tr> <tr>
@@ -467,12 +463,12 @@ Task to perform CHECKIN commands to Microsoft Visual SourceSafe.
<h3>Examples</h3> <h3>Examples</h3>
<blockquote> <blockquote>
<pre> <pre>
&lt;vsscheckin vsspath=&quot;/test/test*&quot;
&lt;vsscheckin vsspath=&quot;$/test/test*&quot;
localpath=&quot;D:\build\&quot; localpath=&quot;D:\build\&quot;
comment=&quot;Modified by automatic build&quot;/&gt; comment=&quot;Modified by automatic build&quot;/&gt;
</pre> </pre>
</blockquote> </blockquote>
<p>Checks in the file(s) named <i>test*</i> in the project <i>test</i> using
<p>Checks in the file(s) named <i>test*</i> in the project <i>$/test</i> using
the local directory <i>D:\build</i>.</p> the local directory <i>D:\build</i>.</p>
<hr> <hr>


@@ -493,8 +489,7 @@ label only one will be used in the order version, date, label.</p>
<tr> <tr>
<td>vsspath</td> <td>vsspath</td>
<td>SourceSafe path which specifies the project/file(s) you wish to <td>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.</td>
perform the action on.</td>
<td>Yes</td> <td>Yes</td>
</tr> </tr>
<tr> <tr>
@@ -549,13 +544,13 @@ label only one will be used in the order version, date, label.</p>
<h3>Examples</h3> <h3>Examples</h3>
<blockquote> <blockquote>
<pre> <pre>
&lt;vsscheckout vsspath=&quot;/test&quot;
&lt;vsscheckout vsspath=&quot;$/test&quot;
localpath=&quot;D:\build&quot; localpath=&quot;D:\build&quot;
recursive=&quot;true&quot; recursive=&quot;true&quot;
login=&quot;me,mypass&quot;/&gt; login=&quot;me,mypass&quot;/&gt;
</pre> </pre>
</blockquote> </blockquote>
<p>Does a recursive checkout of the project test to the directory D:\build.
<p>Does a recursive checkout of the project <i>$/test</i> to the directory D:\build.
</p> </p>
<hr> <hr>


@@ -644,8 +639,7 @@ directory (see vsscp).</p>
<tr> <tr>
<td>vsspath</td> <td>vsspath</td>
<td>SourceSafe path which specifies the project you wish to <td>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.</td>
make the current project.</td>
<td>Yes</td> <td>Yes</td>
</tr> </tr>
<tr> <tr>
@@ -672,7 +666,7 @@ directory (see vsscp).</p>
<h3>Examples</h3> <h3>Examples</h3>
<blockquote> <blockquote>
<pre> <pre>
&lt;vsscp vsspath=&quot;/Projects/ant&quot;/&gt;
&lt;vsscp vsspath=&quot;$/Projects/ant&quot;/&gt;
</pre> </pre>
</blockquote> </blockquote>
<p>Sets the current VSS project to <i>$/Projects/ant</i>.</p> <p>Sets the current VSS project to <i>$/Projects/ant</i>.</p>
@@ -730,7 +724,7 @@ directory (see vsscp).</p>
<h3>Examples</h3> <h3>Examples</h3>
<blockquote> <blockquote>
<pre> <pre>
&lt;vsscreate vsspath=&quot;/existingProject/newProject&quot;/&gt;
&lt;vsscreate vsspath=&quot;$/existingProject/newProject&quot;/&gt;
</pre> </pre>
</blockquote> </blockquote>
<p>Creates the VSS-Project <i>$/existingProject/newProject</i>.</p> <p>Creates the VSS-Project <i>$/existingProject/newProject</i>.</p>


+ 108
- 0
src/etc/testcases/taskdefs/optional/sos/sos.xml View File

@@ -0,0 +1,108 @@
<?xml version="1.0"?>

<project name="sos-test" basedir="." default="sosget.1">

<!--
===========================================================================
Test SOSGet missing attributes
===========================================================================
-->
<target name="sosget.1">
<sosget/>
</target>

<target name="sosget.2">
<sosget sosserverpath="192.168.0.1:8888"/>
</target>

<target name="sosget.3">
<sosget sosserverpath="192.168.0.1:8888"
username="ant"/>
</target>

<target name="sosget.4">
<sosget sosserverpath="192.168.0.1:8888"
username="ant"
vssserverpath="\\server\vss\srcsafe.ini"/>
</target>

<!--
===========================================================================
Test SOSCheckin missing attributes
===========================================================================
-->
<target name="soscheckin.1">
<soscheckin/>
</target>

<target name="soscheckin.2">
<soscheckin sosserverpath="192.168.0.1:8888"/>
</target>

<target name="soscheckin.3">
<soscheckin sosserverpath="192.168.0.1:8888"
username="ant"/>
</target>

<target name="soscheckin.4">
<soscheckin sosserverpath="192.168.0.1:8888"
username="ant"
vssserverpath="\\server\vss\srcsafe.ini"/>
</target>

<!--
===========================================================================
Test SOSCheckout missing attributes
===========================================================================
-->
<target name="soscheckout.1">
<soscheckout/>
</target>

<target name="soscheckout.2">
<soscheckout sosserverpath="192.168.0.1:8888"/>
</target>

<target name="soscheckout.3">
<soscheckout sosserverpath="192.168.0.1:8888"
username="ant"/>
</target>

<target name="soscheckout.4">
<soscheckout sosserverpath="192.168.0.1:8888"
username="ant"
vssserverpath="\\server\vss\srcsafe.ini"/>
</target>

<!--
===========================================================================
Test SOSLabel missing attributes
===========================================================================
-->
<target name="soslabel.1">
<soslabel/>
</target>

<target name="soslabel.2">
<soslabel sosserverpath="192.168.0.1:8888"/>
</target>

<target name="soslabel.3">
<soslabel sosserverpath="192.168.0.1:8888"
username="ant"/>
</target>

<target name="soslabel.4">
<soslabel sosserverpath="192.168.0.1:8888"
username="ant"
vssserverpath="\\server\vss\srcsafe.ini"/>
</target>

<target name="soslabel.5">
<soslabel sosserverpath="192.168.0.1:8888"
username="ant"
vssserverpath="\\server\vss\srcsafe.ini"
projectpath="/SourceRoot/Project"/>
</target>

</project>

+ 5
- 1
src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java View File

@@ -175,7 +175,11 @@ public abstract class SOS extends Task {
* @param projectpath The new projectPath value * @param projectpath The new projectPath value
*/ */
public final void setProjectPath(String projectpath) { 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;
}
} }






+ 9
- 2
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java View File

@@ -143,10 +143,17 @@ public abstract class MSVSS extends Task {
* @param vssPath * @param vssPath
*/ */
public final void setVsspath(String vssPath) { public final void setVsspath(String vssPath) {
String projectPath;
if (vssPath.startsWith("vss://")) { if (vssPath.startsWith("vss://")) {
m_vssPath = PROJECT_PREFIX + vssPath.substring(5);
projectPath = vssPath.substring(5);
} else { } else {
m_vssPath = PROJECT_PREFIX + vssPath;
projectPath = vssPath;
}

if (projectPath.charAt(0) == '$') {
m_vssPath = projectPath;
} else {
m_vssPath = PROJECT_PREFIX + projectPath;
} }
} }




+ 140
- 465
src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java View File

@@ -53,32 +53,29 @@
*/ */
package org.apache.tools.ant.taskdefs.optional.sos; 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.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.Commandline;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils; 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 <a href="mailto:jesse@cryptocard.com">Jesse Stockall</a>
* Testcase to ensure that command line generation and required attributes are
* correct.
*
* @author <a href="mailto:jesse@cryptocard.com">Jesse Stockall</a>
*/ */
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 Project project;
private Commandline commandline; private Commandline commandline;
private FileUtils fileUtils;


private static final String VSS_SERVER_PATH = "\\\\server\\vss\\srcsafe.ini"; private static final String VSS_SERVER_PATH = "\\\\server\\vss\\srcsafe.ini";
private static final String VSS_PROJECT_PATH = "/SourceRoot/Project"; 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_SERVER_PATH = "192.168.0.1:8888";
private static final String SOS_USERNAME = "ant"; private static final String SOS_USERNAME = "ant";
private static final String SOS_PASSWORD = "rocks"; 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 SOS_HOME = "/home/user/.sos";
private static final String VERSION = "007"; private static final String VERSION = "007";


/**
* Constructor for the SOSTest object
*
* @param s Test name
*/
public SOSTest(String s) { public SOSTest(String s) {
super(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 = new Project();
project.setBasedir("."); 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); File file = new File(project.getBaseDir(), LOCAL_PATH);
if (file.exists()) { if (file.exists()) {
file.delete(); file.delete();
} }
}
}


/**
* Test SOSGetFile flags & commandline generation
*/
/** Test SOSGetFile flags & commandline generation */
public void testGetFileFlags() { 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 // Set up a SOSGet task
SOSGet sosGet = new SOSGet();
sosGet.setProject(project); sosGet.setProject(project);
sosGet.setVssServerPath(VSS_SERVER_PATH); sosGet.setVssServerPath(VSS_SERVER_PATH);
sosGet.setSosServerPath(SOS_SERVER_PATH); sosGet.setSosServerPath(SOS_SERVER_PATH);
@@ -132,46 +138,31 @@ public class SOSTest extends TestCase {
sosGet.setUsername(SOS_USERNAME); sosGet.setUsername(SOS_USERNAME);
sosGet.setPassword(SOS_PASSWORD); sosGet.setPassword(SOS_PASSWORD);
sosGet.setVersion(VERSION); sosGet.setVersion(VERSION);
sosGet.setLocalPath(path);
sosGet.setLocalPath(new Path(project, LOCAL_PATH));
sosGet.setNoCache(true); sosGet.setNoCache(true);
sosGet.setNoCompress(true); sosGet.setNoCompress(true);
sosGet.setVerbose(true); sosGet.setVerbose(true);
sosGet.setRecursive(true); sosGet.setRecursive(true);


commandline = sosGet.buildCmdLine(); 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() { 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 // Set up a SOSGet task
SOSGet sosGet = new SOSGet();
sosGet.setProject(project); sosGet.setProject(project);
sosGet.setVssServerPath(VSS_SERVER_PATH); sosGet.setVssServerPath(VSS_SERVER_PATH);
sosGet.setSosServerPath(SOS_SERVER_PATH); sosGet.setSosServerPath(SOS_SERVER_PATH);
sosGet.setProjectPath(VSS_PROJECT_PATH);
sosGet.setProjectPath(DS_VSS_PROJECT_PATH);
sosGet.setLabel(SRC_LABEL); sosGet.setLabel(SRC_LABEL);
sosGet.setUsername(SOS_USERNAME); sosGet.setUsername(SOS_USERNAME);
sosGet.setSosHome(SOS_HOME); sosGet.setSosHome(SOS_HOME);
@@ -181,105 +172,30 @@ public class SOSTest extends TestCase {
sosGet.setRecursive(true); sosGet.setRecursive(true);


commandline = sosGet.buildCmdLine(); 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() { 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() { 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 // Set up a SOSCheckin task
SOSCheckin sosCheckin = new SOSCheckin();
sosCheckin.setProject(project); sosCheckin.setProject(project);
sosCheckin.setVssServerPath(VSS_SERVER_PATH); sosCheckin.setVssServerPath(VSS_SERVER_PATH);
sosCheckin.setSosServerPath(SOS_SERVER_PATH); sosCheckin.setSosServerPath(SOS_SERVER_PATH);
@@ -288,48 +204,31 @@ public class SOSTest extends TestCase {
sosCheckin.setComment(SRC_COMMENT); sosCheckin.setComment(SRC_COMMENT);
sosCheckin.setUsername(SOS_USERNAME); sosCheckin.setUsername(SOS_USERNAME);
sosCheckin.setPassword(SOS_PASSWORD); sosCheckin.setPassword(SOS_PASSWORD);
sosCheckin.setLocalPath(path);
sosCheckin.setLocalPath(new Path(project, LOCAL_PATH));
sosCheckin.setNoCache(true); sosCheckin.setNoCache(true);
sosCheckin.setNoCompress(true); sosCheckin.setNoCompress(true);
sosCheckin.setVerbose(true); sosCheckin.setVerbose(true);
sosCheckin.setRecursive(true); sosCheckin.setRecursive(true);


commandline = sosCheckin.buildCmdLine(); 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() { 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 // Set up a SOSCheckin task
SOSCheckin sosCheckin = new SOSCheckin();
sosCheckin.setProject(project); sosCheckin.setProject(project);
sosCheckin.setVssServerPath(VSS_SERVER_PATH); sosCheckin.setVssServerPath(VSS_SERVER_PATH);
sosCheckin.setSosServerPath(SOS_SERVER_PATH); sosCheckin.setSosServerPath(SOS_SERVER_PATH);
sosCheckin.setProjectPath(VSS_PROJECT_PATH);
sosCheckin.setProjectPath(DS_VSS_PROJECT_PATH);
sosCheckin.setComment(SRC_COMMENT); sosCheckin.setComment(SRC_COMMENT);
sosCheckin.setUsername(SOS_USERNAME); sosCheckin.setUsername(SOS_USERNAME);
sosCheckin.setSosHome(SOS_HOME); sosCheckin.setSosHome(SOS_HOME);
@@ -339,150 +238,58 @@ public class SOSTest extends TestCase {
sosCheckin.setRecursive(true); sosCheckin.setRecursive(true);


commandline = sosCheckin.buildCmdLine(); 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() { 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() { 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 // Set up a SOSCheckout task
SOSCheckout sosCheckout = new SOSCheckout();
sosCheckout.setProject(project); sosCheckout.setProject(project);
sosCheckout.setVssServerPath(VSS_SERVER_PATH); sosCheckout.setVssServerPath(VSS_SERVER_PATH);
sosCheckout.setSosServerPath(SOS_SERVER_PATH); sosCheckout.setSosServerPath(SOS_SERVER_PATH);
sosCheckout.setProjectPath(VSS_PROJECT_PATH);
sosCheckout.setProjectPath(DS_VSS_PROJECT_PATH);
sosCheckout.setFile(SRC_FILE); sosCheckout.setFile(SRC_FILE);
sosCheckout.setUsername(SOS_USERNAME); sosCheckout.setUsername(SOS_USERNAME);
sosCheckout.setPassword(SOS_PASSWORD); sosCheckout.setPassword(SOS_PASSWORD);
sosCheckout.setLocalPath(path);
sosCheckout.setLocalPath(new Path(project, LOCAL_PATH));
sosCheckout.setNoCache(true); sosCheckout.setNoCache(true);
sosCheckout.setNoCompress(true); sosCheckout.setNoCompress(true);
sosCheckout.setVerbose(true); sosCheckout.setVerbose(true);
sosCheckout.setRecursive(true); sosCheckout.setRecursive(true);


commandline = sosCheckout.buildCmdLine(); 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() { 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 // Set up a sosCheckout task
SOSCheckout sosCheckout = new SOSCheckout();
sosCheckout.setProject(project); sosCheckout.setProject(project);
sosCheckout.setVssServerPath(VSS_SERVER_PATH); sosCheckout.setVssServerPath(VSS_SERVER_PATH);
sosCheckout.setSosServerPath(SOS_SERVER_PATH); sosCheckout.setSosServerPath(SOS_SERVER_PATH);
@@ -495,104 +302,31 @@ public class SOSTest extends TestCase {
sosCheckout.setRecursive(true); sosCheckout.setRecursive(true);


commandline = sosCheckout.buildCmdLine(); 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() { 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() { 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 // Set up a sosCheckout task
SOSLabel sosLabel = new SOSLabel();
sosLabel.setVssServerPath(VSS_SERVER_PATH); sosLabel.setVssServerPath(VSS_SERVER_PATH);
sosLabel.setSosServerPath(SOS_SERVER_PATH); sosLabel.setSosServerPath(SOS_SERVER_PATH);
sosLabel.setProjectPath(VSS_PROJECT_PATH);
sosLabel.setProjectPath(DS_VSS_PROJECT_PATH);
sosLabel.setUsername(SOS_USERNAME); sosLabel.setUsername(SOS_USERNAME);
sosLabel.setSosHome(SOS_HOME); sosLabel.setSosHome(SOS_HOME);
sosLabel.setComment(SRC_COMMENT); sosLabel.setComment(SRC_COMMENT);
@@ -602,100 +336,41 @@ public class SOSTest extends TestCase {
sosLabel.setVerbose(true); sosLabel.setVerbose(true);


commandline = sosLabel.buildCmdLine(); 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);
} }

} }

Loading…
Cancel
Save