CVS: junit-ant-tests/src/org/junit/tests/antfile JUnitBuildXmlTest.java, NONE, 1.1

David Saff <[email protected]> Thu, 05 Jul 2007 13:58:28 -0700
Newsgroups gmane.comp.java.junit.devel
Message-ID <[email protected]>
Update of /cvsroot/junit/junit-ant-tests/src/org/junit/tests/antfile
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3239/src/org/junit/tests/antfile

Added Files:
	JUnitBuildXmlTest.java 
Log Message:
initial check-in

--- NEW FILE: JUnitBuildXmlTest.java ---
package org.junit.tests.antfile;

import static net.saff.ant.FileMatchers.nameOfExistingFile;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;

import java.io.IOException;

import net.saff.ant.BuildFile;

import org.apache.tools.ant.Project;
import org.junit.Test;
import org.junit.build.JUnitBuildTarget;

public class JUnitBuildXmlTest {
	private static final String JUNIT_DIR = "../junit-4.4";
	
	public static final String ANT_DIST = "temp-dist-directory-for-junit-ant-tests";

	private static final String ANT_DIST_DIR = JUNIT_DIR + "/" + ANT_DIST;

	public static final String TEST_SRC_JAR_FILE = "junit-test.version-src.jar";

	private static final String SRC_JAR_FILE = ANT_DIST_DIR + "/"
			+ TEST_SRC_JAR_FILE;

	public static final String TEST_JAVA_DOC_ZIP = "new-england-javadoc.zip";

	public static final String TEST_HAMCREST_SRC = ANT_DIST
			+ "/temp-hamcrest-for-ant-unit";

	public static final String TEST_JAR_FILE = "junit-test.version.jar";

	private final Project project = BuildFile
			.fromFile("../junit-4.4/build.xml").parse();

	@Test
	public void populateGeneratesSrcJar() throws IOException {
		buildTarget("populate-dist");
		assertThat(SRC_JAR_FILE, nameOfExistingFile());
	}

	@Test
	public void populateGeneratesDistDir() throws IOException {
		buildTarget("populate-dist");
		assertThat(ANT_DIST_DIR, nameOfExistingFile());
	}

	@Test
	public void jarsGeneratesDistDir() throws IOException {
		buildTarget("jars");
		assertThat(ANT_DIST_DIR, nameOfExistingFile());
	}

	@Test
	public void jarsMentionsDistDirInLog() throws IOException {
		JUnitBuildTarget target = JUnitBuildTarget
				.createTarget(project, "jars");
		target.run();
		assertThat(target.getLog(), containsString(ANT_DIST));
	}

	@Test
	public void noSrcJarAfterClean() throws IOException {
		buildTarget("clean");
		assertThat(SRC_JAR_FILE, not(nameOfExistingFile()));
	}

	private void buildTarget(String targetName) throws IOException {
		JUnitBuildTarget.createTarget(project, targetName).run();
	}
}


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/