krysalis-update/src/test/java/org/apache/depot/update/ant AntTasksTests.java,NONE,1.1 anttasks.xml,NONE,1.1 build.xml,NONE,1.1 CachedArtifactSetTaskTest.java,NONE,1.1

Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:07:16 +0000
Newsgroups gmane.comp.krysalis.cvs
Message-ID <[email protected]>
Update of /cvsroot/krysalis/krysalis-update/src/test/java/org/apache/depot/update/ant
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/test/java/org/apache/depot/update/ant

Added Files:
	AntTasksTests.java anttasks.xml build.xml 
	CachedArtifactSetTaskTest.java 
Log Message:
Copied from the apache incubator.

--- NEW FILE: AntTasksTests.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.apache.depot.update.ant;

import org.apache.tools.ant.BuildFileTest;

/**
 * 
 * @author $Author: chalko $
 * @version $Revision: 1.1 $
 */
public class AntTasksTests extends BuildFileTest {

	/**
	 * Constructor for UpdateDependTaskTest.
	 * @param arg0
	 */
	public AntTasksTests(String arg0) {
		super(arg0);
	}

	public static void main(String[] args) {
		junit.textui.TestRunner.run(AntTasksTests.class);
	}

	public void setUp() throws Exception {
    	super.setUp();
		configureProject("src/test/org/apache/depot/update/ant/anttasks.xml");
	}

	public void test1() {
		executeTarget("typical");
	}
}

--- NEW FILE: build.xml ---
<!--
$HeadURL: http://svn.apache.org/repos/asf/incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/build.xml $
$LastChangedRevision: 22111 $

Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="updateModule-test" basedir="../../../../../../../" default="test1">
	<property name="localtest.dir" value="${basedir}/src/resources/test/repo" />



	<property name="depot.home" value="${basedir}/build/depot-home" />
	<property name="local.repository" value="${depot.home}/local-repository" />
	<property name="sandbox.dir" value="build/test/sandbox" />

	<path id="update.classpath">
		<fileset dir="lib">
			<include name="*.jar" />
		</fileset>
		<pathelement location="build/depot-update/classes" />
	</path>

	<typedef resource="depot-update-antlib.xml" classpathref="update.classpath" />
	<repository id="maven" url="http://www.ibiblio.org/maven/" remote="true" />
	<repository id="localtest" url="file:///${localtest.dir}" remote="true" />
	<target name="test1" depends="clean-jars">

		<!-- this test should find the 1.1 jar already in place. -->
		<copy toDir="${depot.home}/local-repository">
			<fileset dir="${localtest.dir}">
				<include name="**/*1.1*" />
			</fileset>
		</copy>
		<cachedset id="test1">
			<artifact name="helloworld" ext="jar" version="1.1" repository="localtest" />
		</cachedset>
		<copy toDir="${sandbox.dir}">
			<fileset refid="test1.fileset" />
		</copy>
	</target>
	<target name="test2" depends="clean-jars">
		<!-- Since the local repo is cleaned this test should return the 1.2 jar downloaded for localtest -->
		<cachedset id="test2">
			<artifact name="helloworld" ext="jar" version="1.2" repository="localtest" />
		</cachedset>
		<copy toDir="${sandbox.dir}">
			<fileset refid="test2.fileset" />
		</copy>
	</target>
	<target name="test3" depends="clean-jars">

		<!-- helloworld 1.3 does not exist this should fail. -->
		<cachedset id="test3">
			<artifact name="helloworld" ext="jar" version="1.3" repository="localtest" />
		</cachedset>
		<copy toDir="${sandbox.dir}">
			<fileset refid="test3.fileset" />
		</copy>
	</target>
	<target name="test4" depends="clean-jars">

		<!-- this test should find the 1.2 jar from localtest -->
		<copy toDir="${depot.home}/local-repository">
			<fileset dir="${localtest.dir}">
				<include name="**/*1.1*" />
			</fileset>
		</copy>
		<cachedset id="test4">
			<artifact name="helloworld" ext="jar" version="1.2" repository="localtest" />
		</cachedset>
		<copy toDir="${sandbox.dir}">
			<fileset refid="test4.fileset" />
		</copy>
	</target>


	<target name="test99">
		<!--cachedset id="foo">
			<project name="xalan" version="4" module="http://gump.apache.org/modules/xalan.xml" />
		</cachedset-->
	</target>
	<target name="testNotFound">
		<cachedset id="testNotFound">
			<artifact name="notfound" ext="jar" version="1.2" repository="localtest" />
		</cachedset>
		<!-- have to use the chaced set before it is used. -->
		<copy toDir="${sandbox.dir}">
			<fileset refid="testNotFound.fileset" />
		</copy>
	</target>


	<target name="testExport1" depends="test1">
		<delete file="build/test1-export.build.xml" />
		<path id="convert" location="${basedir}" />
		<pathconvert property="converted" refid="convert" targetos="unix" />
		<copy file="src/test/org/apache/depot/update/ant/test1-export.build.xml"
		      tofile="build/expected-test1-export.build.xml" overwrite="true">
			<filterset>
				<filter token="basedir" value="${converted}" />
			</filterset>
		</copy>
		<cachedsetexport refid="test1" toFile="build/test1-export.build.xml" />
	</target>

	<target name="clean-jars">
		<delete dir="${local.repository}" />
		<delete dir="${sandbox.dir}" />
	</target>
</project>

--- NEW FILE: CachedArtifactSetTaskTest.java ---
/*
 * ========================================================================
 * Copyright 2004 The Apache Software Foundation
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 * ========================================================================
 */
package org.apache.depot.update.ant;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.depot.common.log.Logger;
import org.apache.tools.ant.BuildFileTest;
import org.custommonkey.xmlunit.XMLAssert;
import org.xml.sax.SAXException;
/**
 * @author <a href="http://incubator.apache.org/depot" >The Apache Incubator
 *         Depot Project </a>
 * @version $LastChangedRevision: 9844 $
 */
public class CachedArtifactSetTaskTest extends BuildFileTest {
	private final String SANDBOX = "build/test/sandbox";
	/**
	 * Constructor for RuperDependTaskTest.
	 * 
	 * @param arg0
	 */
	public CachedArtifactSetTaskTest(String arg0) {
		super(arg0);
	}
	public static void main(String[] args) {
		junit.textui.TestRunner.run(CachedArtifactSetTaskTest.class);
	}
	public void setUp() {
		Logger.testInit();
		configureProject("src/test/org/apache/depot/update/ant/build.xml");
	}
	public void test1() {
		try {
			executeTarget("test1");
			File file = new File(SANDBOX
					+ "/helloworld/jars/helloworld-1.1.jar");
			assertTrue("Expected " + file + " to  exists", file.exists());
		} finally {
			System.out.println(getOutput());
		}
	}
	public void test2() {
		try {
			executeTarget("test2");
			File file = new File(SANDBOX
					+ "/helloworld/jars/helloworld-1.2.jar");
			assertTrue("Expected " + file + " to  exists", file.exists());
		} finally {
			System.out.println(getOutput());
		}
	}
	public void test3() {
		try {
			expectSpecificBuildException("test3",
					"Only helloworld 1.1 and 1.2 exist's",
					"Unable to find helloworld-1.3.jar@localtest");
		} finally {
			System.out.println(getOutput());
		}
	}
	public void test4() {
		try {
			executeTarget("test4");
			File file = new File(SANDBOX
					+ "/helloworld/jars/helloworld-1.2.jar");
			assertTrue("Expected " + file + " to  exists", file.exists());
		} finally {
			System.out.println(getOutput());
		}
	}
	public void testNotFound() {
		try {
			expectSpecificBuildException("testNotFound",
					"notfound does not exist",
					"Unable to find notfound-1.2.jar@localtest");
		} finally {
			System.out.println(getOutput());
		}
	}
	/**
	 * Test the exporting of cached set test1.
	 *  
	 */
	public void testExport1() throws FileNotFoundException, SAXException,
			IOException, ParserConfigurationException {
		try {
			executeTarget("testExport1");
			File generatedFile = new File("build/test1-export.build.xml");
			File expectedFile = new File(
					"build/expected-test1-export.build.xml");
			assertTrue("Expected " + generatedFile + " to  exists",
					generatedFile.exists());
			XMLAssert
					.assertXMLEqual("Exported cached set test1",
							new FileReader(expectedFile), new FileReader(
									generatedFile));
		} finally {
			System.out.println(getOutput());
		}
	}
}
--- NEW FILE: anttasks.xml ---
<?xml version="1.0"?>
<project name="update-repotool-test" basedir="." default="all">
	<taskdef resource="depot-update-antlib.xml"/>	
		
	<target name="typical">
		
		<reposync group="junit" />
		<reposync group="log4j" />
		<reposync group="jxpath" />
		
		<repotool repositories="lib"/>
	</target>
	
	<target name="all" depends="typical" />
</project>



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/