Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Adapt tests to PR 47105, fix handling of implicit trunk "tags"
git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/svn/trunk@771731 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
bodewig committed May 5, 2009
1 parent 2d21696 commit 8e134a50e5d908378778343b73125aa008c5bb1d
Showing 2 changed files with 24 additions and 14 deletions.
@@ -91,6 +91,9 @@
*/
public class SvnTagDiff extends AbstractSvnTask {

private static final String TRUNK = "trunk";
private static final String TRUNK_SLASH = TRUNK + "/";

/**
* Used to create the temp file for svn log
*/
@@ -240,7 +243,8 @@ public void execute() throws BuildException {

// sort out whats tags and whats branches
this.fromCopy = fromTag !=null ? fromTag : fromBranch;
this.toCopy = toTag != null ? toTag : toBranch;
this.toCopy = toTag != null ? toTag
: toBranch != null ? toBranch : TRUNK;
this.fromName = fromTag != null ? "fromTag" : "fromBranch";
this.toName = toTag != null ? "toTag" : "toBranch";
this.fromDir = fromTag != null ? "tags/" : "branches/";
@@ -277,18 +281,17 @@ public void execute() throws BuildException {
}

private void addDiffArguments(){
if (fromCopy.equals("trunk") || fromCopy.equals("trunk/")) {
addSubCommandArgument(baseURL + "trunk/");
if (fromCopy.equals(TRUNK) || fromCopy.equals(TRUNK_SLASH)) {
addSubCommandArgument(baseURL + TRUNK_SLASH);
} else {
if (fromCopy.endsWith("/")) {
addSubCommandArgument(baseURL + fromDir + fromCopy);
} else {
addSubCommandArgument(baseURL + fromDir + fromCopy + "/");
}
}
if (toCopy == null || toCopy.equals("trunk")
|| toCopy.equals("trunk/")) {
addSubCommandArgument(baseURL + "trunk/");
if (toCopy.equals(TRUNK) || toCopy.equals(TRUNK_SLASH)) {
addSubCommandArgument(baseURL + TRUNK_SLASH);
} else {
if (toCopy.endsWith("/")) {
addSubCommandArgument(baseURL + toDir + toCopy);
@@ -49,16 +49,16 @@ public void testDiffWithTwoTags() throws IOException {

public void testDiffWithExplicitTrunk() throws IOException {
String log = executeTargetAndReadLogFully("diff-with-explicit-trunk");
assertDiffWithTrunk(log);
assertDiffWithTrunk(log, "toTag");
}

public void testDiffWithImplicitTrunk() throws IOException {
String log = executeTargetAndReadLogFully("diff-with-implicit-trunk");
assertDiffWithTrunk(log);
assertDiffWithTrunk(log, "toBranch");
}

private static void assertDiffWithTrunk(String log) {
assertAttributes(log, "10_BETA1", "trunk");
private static void assertDiffWithTrunk(String log, String tag2Name) {
assertAttributes(log, "10_BETA1", tag2Name, "trunk");
assertAdded(log);
assertModified(log);
assertDeleted(log);
@@ -78,14 +78,21 @@ private String executeTargetAndReadLogFully(String target)

private static final void assertAttributes(String log, String tag1,
String tag2) {
assertAttributes(log, tag1, "toTag", tag2);
}

private static final void assertAttributes(String log, String tag1,
String tag2Name, String tag2) {
int start = log.indexOf("<tagdiff");
Assert.assertTrue(start > -1);
int end = log.indexOf(">", start);
Assert.assertTrue(end > -1);
Assert.assertTrue(log.indexOf("tag1=\"" + tag1 + "\"", start) > -1);
Assert.assertTrue(log.indexOf("tag1=\"" + tag1 + "\"", start) < end);
Assert.assertTrue(log.indexOf("tag2=\"" + tag2 + "\"", start) > -1);
Assert.assertTrue(log.indexOf("tag2=\"" + tag2 + "\"", start) < end);
Assert.assertTrue(log.indexOf("fromTag=\"" + tag1 + "\"", start) > -1);
Assert.assertTrue(log.indexOf("fromTag=\"" + tag1 + "\"", start) < end);
Assert.assertTrue(log.indexOf(tag2Name + "=\"" + tag2 + "\"",
start) > -1);
Assert.assertTrue(log.indexOf(tag2Name + "=\"" + tag2 + "\"",
start) < end);
Assert.assertTrue(log.indexOf("svnurl=\"http://svn.apache.org/",
start) > -1);
Assert.assertTrue(log.indexOf("svnurl=\"http://svn.apache.org/",

0 comments on commit 8e134a5

Please sign in to comment.