Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
use Ant site rather than an antlib for tests
  • Loading branch information
bodewig committed Jul 27, 2014
1 parent 2c2dfbb commit 21bb424ffdbce74f4b0552150aa88b3f423ffaf6
Showing 6 changed files with 72 additions and 73 deletions.
@@ -21,42 +21,42 @@
default="all" xmlns:svn="antlib:org.apache.ant.svn">

<property name="tmpdir" value="${java.io.tmpdir}/svnantlib"/>
<property name="trunkdir" value="${tmpdir}/trunk"/>
<property name="file" value="build.xml"/>
<property name="sitedir" value="${tmpdir}/svn"/>
<property name="file" value="index.xml"/>

<target name="setup">
<mkdir dir="${tmpdir}"/>
<svn:svn
svnURL="http://svn.apache.org/repos/asf/ant/antlibs/common/trunk/"
svnURL="http://svn.apache.org/repos/asf/ant/site/ant/sources/antlibs/svn/"
dest="${tmpdir}"/>
</target>

<target name="all" depends="setup">
<svn:svn failonerror="true" subcommand="status ${file}" dest="${trunkdir}"/>
<svn:svn failonerror="true" dest="${trunkdir}">
<svn:svn failonerror="true" subcommand="status ${file}" dest="${sitedir}"/>
<svn:svn failonerror="true" dest="${sitedir}">
<commandline>
<argument value="up"/>
<argument value="-r"/>
<argument value="161881"/>
<argument value="948574"/>
<argument value="${file}"/>
</commandline>
</svn:svn>
<svn:svn failonerror="true" subcommand="status ${file}" dest="${trunkdir}"/>
<svn:svn failonerror="true" dest="${trunkdir}">
<svn:svn failonerror="true" subcommand="status ${file}" dest="${sitedir}"/>
<svn:svn failonerror="true" dest="${sitedir}">
<commandline>
<argument line="up -r HEAD ${file}" />
</commandline>
</svn:svn>
<svn:svn failonerror="true" subcommand="status ${file}" dest="${trunkdir}"/>
<svn:svn failonerror="true" subcommand="status ${file}" dest="${sitedir}"/>
</target>

<target name="revision-attribute">
<mkdir dir="${tmpdir}" />
<svn:svn
svnURL="http://svn.apache.org/repos/asf/ant/antlibs/common/trunk/"
svnURL="http://svn.apache.org/repos/asf/ant/site/ant/sources/antlibs/svn/"
dest="${tmpdir}"
quiet="false"
revision="161881"/>
revision="948574"/>
</target>

<target name="cleanup">
@@ -21,46 +21,46 @@
default="log" xmlns:svn="antlib:org.apache.ant.svn">

<property name="tmpdir" value="${java.io.tmpdir}/svnantlib"/>
<property name="trunkdir" value="${tmpdir}/trunk"/>
<property name="sitedir" value="${tmpdir}/svn"/>

<target name="setup">
<mkdir dir="${tmpdir}"/>
<svn:svn
svnURL="http://svn.apache.org/repos/asf/ant/antlibs/svn/trunk"
svnURL="http://svn.apache.org/repos/asf/ant/site/ant/sources/antlibs/svn/"
dest="${tmpdir}"/>
</target>

<target name="log" depends="setup">
<svn:changelog failonerror="true" dest="${trunkdir}"
<svn:changelog failonerror="true" dest="${sitedir}"
destfile="${tmpdir}/log.xml" />
</target>

<target name="start" depends="setup">
<svn:changelog failonerror="true" dest="${trunkdir}"
destfile="${tmpdir}/log.xml" start="161500"/>
<svn:changelog failonerror="true" dest="${sitedir}"
destfile="${tmpdir}/log.xml" start="450000"/>
</target>

<target name="startDate" depends="setup">
<svn:changelog failonerror="true" dest="${trunkdir}"
destfile="${tmpdir}/log.xml" start="{2005-04-18}"/>
<svn:changelog failonerror="true" dest="${sitedir}"
destfile="${tmpdir}/log.xml" start="{2006-10-01}"/>
</target>

<target name="end" depends="setup">
<svn:changelog failonerror="true" dest="${trunkdir}"
destfile="${tmpdir}/log.xml" end="161500"/>
<svn:changelog failonerror="true" dest="${sitedir}"
destfile="${tmpdir}/log.xml" end="450000"/>
</target>

<target name="endDate" depends="setup">
<svn:changelog failonerror="true" dest="${trunkdir}"
destfile="${tmpdir}/log.xml" end="{2005-04-18}"/>
<svn:changelog failonerror="true" dest="${sitedir}"
destfile="${tmpdir}/log.xml" end="{2006-10-01}"/>
</target>

<target name="report" depends="start">
<xslt in="${tmpdir}/log.xml"
out="${tmpdir}/log.html"
style="src/etc/changelog.xsl">
<param name="title" expression="Ant SVN Antlib ChangeLog"/>
<param name="repo" expression="http://svn.apache.org/repos/ant/antlibs/svn"/>
<param name="title" expression="Ant SVN Antlib Site ChangeLog"/>
<param name="repo" expression="http://svn.apache.org/repos/asf/ant/site/ant/sources/antlibs/svn/"/>
</xslt>
</target>

@@ -21,35 +21,35 @@
default="diff" xmlns:svn="antlib:org.apache.ant.svn">

<property name="tmpdir" value="${java.io.tmpdir}/svnantlib"/>
<property name="trunkdir" value="${tmpdir}/trunk"/>
<property name="sitedir" value="${tmpdir}/svn"/>

<target name="dir-prep">
<mkdir dir="${tmpdir}"/>
</target>

<target name="setup" depends="dir-prep">
<svn:svn
svnURL="http://svn.apache.org/repos/asf/ant/antlibs/svn/trunk"
svnURL="http://svn.apache.org/repos/asf/ant/site/ant/sources/antlibs/svn/"
dest="${tmpdir}"/>
</target>

<target name="diff" depends="setup">
<svn:revisiondiff failonerror="true" dest="${trunkdir}"
destfile="${tmpdir}/diff.xml" start="161469" end="161885"/>
<svn:revisiondiff failonerror="true" dest="${sitedir}"
destfile="${tmpdir}/diff.xml" start="371996" end="439435"/>
</target>

<target name="diff-using-url" depends="dir-prep">
<svn:revisiondiff failonerror="true"
svnURL="http://svn.apache.org/repos/asf/ant/antlibs/svn/trunk"
destfile="${tmpdir}/diff.xml" start="161469" end="161885"/>
svnURL="http://svn.apache.org/repos/asf/ant/site/ant/sources/antlibs/svn/"
destfile="${tmpdir}/diff.xml" start="371996" end="439435"/>
</target>

<target name="report" depends="diff-using-url">
<style in="${tmpdir}/diff.xml"
out="${tmpdir}/diff.html"
style="src/etc/diff.xsl">
<param name="title" expression="svn Antlib diff report"/>
<param name="repo" expression="http://svn.apache.org/repos/asf/ant/antlibs/svn/trunk"/>
<param name="title" expression="svn Antlib Site diff report"/>
<param name="repo" expression="http://svn.apache.org/repos/asf/ant/site/ant/sources/antlibs/svn/"/>
</style>
</target>

@@ -47,7 +47,7 @@ public void testAbstractSvnTask() {

public void testRevisionAttribute() {
String tmpDir = getProject().getProperty("tmpdir");
File f = getProject().resolveFile(tmpDir + "/trunk/build.xml");
File f = getProject().resolveFile(tmpDir + "/svn/index.xml");
assertTrue("starting empty", !f.exists());

// used to be
@@ -56,9 +56,9 @@ public void testRevisionAttribute() {
// on the version of the command line client
executeTarget("revision-attribute");
String log = getLog();
int buildFileIndex = Math.max(log.indexOf("trunk/build.xml"),
log.indexOf("trunk\\build.xml"));
assertTrue("expected message about build.xml, log was: " + log,
int buildFileIndex = Math.max(log.indexOf("svn/index.xml"),
log.indexOf("svn\\index.xml"));
assertTrue("expected message about index.xml, log was: " + log,
buildFileIndex > -1);
for (int i = buildFileIndex - 1; i > -1; --i) {
char c = log.charAt(i);
@@ -67,7 +67,7 @@ public void testRevisionAttribute() {
break;
}
}
assertTrue("expected 'A' status for build.xml, log was:" +log,
assertTrue("expected 'A' status for index.xml, log was:" +log,
buildFileIndex > -1);

assertTrue("now it is there", f.exists());
@@ -43,33 +43,32 @@ public void tearDown() {

public void testLog() throws IOException {
String log = executeTargetAndReadLogFully("log");
assertRev161885(log);
assertRev161469(log);
assertRev482074(log);
assertRev371996(log);
}

public void testStart() throws IOException {
String log = executeTargetAndReadLogFully("start");
assertRev161885(log);
assertNoRev161469(log);
assertRev482074(log);
assertNoRev371996(log);
}

// moving the files in svn has broken date based history
public void XtestStartDate() throws IOException {
public void testStartDate() throws IOException {
String log = executeTargetAndReadLogFully("startDate");
assertRev161885(log);
assertNoRev161469(log);
assertRev482074(log);
assertNoRev371996(log);
}

public void testEnd() throws IOException {
String log = executeTargetAndReadLogFully("end");
assertNoRev161885(log);
assertRev161469(log);
assertNoRev482074(log);
assertRev371996(log);
}

public void testEndDate() throws IOException {
String log = executeTargetAndReadLogFully("endDate");
assertNoRev161885(log);
assertRev161469(log);
assertNoRev482074(log);
assertRev371996(log);
}

private String executeTargetAndReadLogFully(String target)
@@ -85,9 +84,9 @@ private String executeTargetAndReadLogFully(String target)
}
}

private static final void assertRev161885(String log) {
int rev = log.indexOf("<revision>161885</revision>");
Assert.assertTrue("Expected to find revision 161885, but log was "
private static final void assertRev482074(String log) {
int rev = log.indexOf("<revision>482074</revision>");
Assert.assertTrue("Expected to find revision 482074, but log was "
+ log, rev > -1);
int entryBeforeRev = log.lastIndexOf("<entry>", rev);
int entryAfterRev = log.indexOf("</entry>", rev);
@@ -99,20 +98,20 @@ private static final void assertRev161885(String log) {
.assertTrue(log.lastIndexOf("<author><![CDATA[bodewig]]></author>",
rev) > entryBeforeRev);
Assert
.assertTrue(log.indexOf("<name><![CDATA[/ant/sandbox/antlibs/"
+ "antunit/trunk]]></name>", rev)
.assertTrue(log.indexOf("<name><![CDATA[ant/site/ant/sources/"
+ "antlibs/svn]]></name>", rev)
< entryAfterRev);
Assert
.assertTrue(log.indexOf("<action>modified</action>", rev)
< entryAfterRev);
Assert
.assertTrue(log.indexOf("<message><![CDATA[Make sandboxes build"
+ "]]></message>", rev)
.assertTrue(log.indexOf("<message><![CDATA[linefeeds]]></message>",
rev)
< entryAfterRev);
}

private static final void assertRev161469(String log) {
int rev = log.indexOf("<revision>161469</revision>");
private static final void assertRev371996(String log) {
int rev = log.indexOf("<revision>371996</revision>");
Assert.assertTrue(rev > -1);
int entryBeforeRev = log.lastIndexOf("<entry>", rev);
int entryAfterRev = log.indexOf("</entry>", rev);
@@ -124,25 +123,25 @@ private static final void assertRev161469(String log) {
.assertTrue(log.lastIndexOf("<![CDATA[bodewig]]>", rev)
> entryBeforeRev);
Assert
.assertTrue(log.indexOf("<name><![CDATA[/ant/sandbox/antlibs/"
+ "antunit]]></name>", rev)
.assertTrue(log.indexOf("<name><![CDATA[ant/site/ant/sources/"
+ "antlibs/svn]]></name>", rev)
< entryAfterRev);
Assert
.assertTrue(log.indexOf("<action>added</action>", rev)
< entryAfterRev);
Assert
.assertTrue(log.indexOf("<message><![CDATA[Import sandbox antlibs"
+ "]]></message>", rev)
.assertTrue(log.indexOf("<message><![CDATA[Update Antlib status]]>"
+ "</message>", rev)
< entryAfterRev);
}

private static final void assertNoRev161885(String log) {
int rev = log.indexOf("<revision>161885</revision>");
private static final void assertNoRev482074(String log) {
int rev = log.indexOf("<revision>482074</revision>");
Assert.assertEquals(-1, rev);
}

private static final void assertNoRev161469(String log) {
int rev = log.indexOf("<revision>161469</revision>");
private static final void assertNoRev371996(String log) {
int rev = log.indexOf("<revision>371996</revision>");
Assert.assertEquals(-1, rev);
}
}
@@ -71,10 +71,10 @@ private static final void assertAttributes(String log) {
Assert.assertTrue(start > -1);
int end = log.indexOf(">", start);
Assert.assertTrue(end > -1);
Assert.assertTrue(log.indexOf("start=\"161469\"", start) > -1);
Assert.assertTrue(log.indexOf("start=\"161469\"", start) < end);
Assert.assertTrue(log.indexOf("end=\"161885\"", start) > -1);
Assert.assertTrue(log.indexOf("end=\"161885\"", start) < end);
Assert.assertTrue(log.indexOf("start=\"371996\"", start) > -1);
Assert.assertTrue(log.indexOf("start=\"371996\"", start) < end);
Assert.assertTrue(log.indexOf("end=\"439435\"", start) > -1);
Assert.assertTrue(log.indexOf("end=\"439435\"", start) < end);
}

private static final void assertAttributesNoURL(String log) {
@@ -87,17 +87,17 @@ private static final void assertAttributesWithURL(String log) {
int start = log.indexOf("<revisiondiff");
int end = log.indexOf(">", start);
Assert.assertTrue(log.indexOf("svnurl=\"http://svn.apache.org/repos/"
+ "asf/ant/antlibs/svn/trunk\"",
+ "asf/ant/site/ant/sources/antlibs/svn/\"",
start)
> -1);
Assert.assertTrue(log.indexOf("svnurl=\"http://svn.apache.org/repos/"
+ "asf/ant/antlibs/svn/trunk\"",
+ "asf/ant/site/ant/sources/antlibs/svn/\"",
start)
< end);
}

private static final void assertModified(String log) {
int name = log.indexOf("<name><![CDATA[build.xml]]></name>");
int name = log.indexOf("<name><![CDATA[index.xml]]></name>");
Assert.assertTrue(name > -1);

int pathAfterName = log.indexOf("</path>", name);

0 comments on commit 21bb424

Please sign in to comment.