krysalis-update/src/test/java/org/apache/depot/update/ant/cache test2-export.build.xml,NONE,1.1 build.xml,NONE,1.1 CachedResourceSetTaskTest.java,NONE,1.1 test1-export.build.xml,NONE,1.1
Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:06:38 +0000
| Newsgroups | gmane.comp.krysalis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/krysalis/krysalis-update/src/test/java/org/apache/depot/update/ant/cache
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/test/java/org/apache/depot/update/ant/cache
Added Files:
test2-export.build.xml build.xml
CachedResourceSetTaskTest.java test1-export.build.xml
Log Message:
Copied from the apache incubator.
--- NEW FILE: test2-export.build.xml ---
<?xml version="1.0"?>
<!DOCTYPE cachedartifactset PUBLIC "-//APACHE//DTD CachedArtifact V0.1//EN" "http://incubator.apache.org/depot/dtd/cachedartifact-v01.dtd">
<cachedartifactset id="test2">
<artifact name="helloworld"
group="helloworld"
version="1.2"
href="file://@basedir@/src/resources/test/repo/helloworld/jars/helloworld-1.2.jar"/>
</cachedartifactset>
--- NEW FILE: CachedResourceSetTaskTest.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.cache;
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 CachedResourceSetTaskTest extends BuildFileTest {
private final String SANDBOX = "build/test/sandbox";
/**
* Constructor for RuperDependTaskTest.
*
* @param arg0
*/
public CachedResourceSetTaskTest(String arg0) {
super(arg0);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(CachedResourceSetTaskTest.class);
}
public void setUp() {
Logger.testInit();
configureProject("src/test/org/apache/depot/update/ant/cache/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());
}
}
/**
* Test the exporting of cached set test1.
*
*/
public void testExport2() throws FileNotFoundException, SAXException,
IOException, ParserConfigurationException {
try {
executeTarget("testExport2");
File generatedFile = new File("build/test2-export.build.xml");
File expectedFile = new File(
"build/expected-test2-export.build.xml");
assertTrue("Expected " + generatedFile + " to exists",
generatedFile.exists());
XMLAssert
.assertXMLEqual("Exported cached set test2",
new FileReader(expectedFile), new FileReader(
generatedFile));
} finally {
System.out.println(getOutput());
}
}
}
--- NEW FILE: build.xml ---
<!--
$HeadURL: https://svn.apache.org/repos/asf/incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/build.xml $
$LastChangedRevision: 10556 $
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/cache/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="testExport2" depends="test2">
<delete file="build/test2-export.build.xml" />
<path id="convert" location="${basedir}" />
<pathconvert property="converted" refid="convert" targetos="unix" />
<copy file="src/test/org/apache/depot/update/ant/cache/test2-export.build.xml"
tofile="build/expected-test2-export.build.xml"
overwrite="true">
<filterset>
<filter token="basedir" value="${converted}" />
</filterset>
</copy>
<cachedsetexport refid="test2" toFile="build/test2-export.build.xml" />
</target>
<target name="clean-jars">
<delete dir="${local.repository}" />
<delete dir="${sandbox.dir}" />
</target>
</project>
--- NEW FILE: test1-export.build.xml ---
<?xml version="1.0"?>
<!DOCTYPE cachedartifactset PUBLIC "-//APACHE//DTD CachedArtifact V0.1//EN" "http://incubator.apache.org/depot/dtd/cachedartifact-v01.dtd">
<cachedartifactset id="test1">
<artifact name="helloworld"
group="helloworld"
version="1.2"
href="file://@basedir@/src/resources/test/repo/helloworld/jars/helloworld-1.2.jar"/>
</cachedartifactset>
-------------------------------------------------------
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/