introduce offline target in build.xml allowing to disable tests requiring internet resources

git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/trunk@484460 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Xavier Hanin 2006-08-21 04:44:00 +00:00
parent 02194a6a82
commit 1cc2024ab5
9 changed files with 90 additions and 18 deletions

View File

@ -24,6 +24,8 @@
<delete dir="${test.build.dir}"/>
<delete dir="${artifacts.build.dir}"/>
<delete dir="${test.report.dir}"/>
<delete dir="${javadoc.build.dir}"/>
<delete dir="${doc.build.dir}"/>
<delete dir="${build.dir}"/>
</target>
@ -39,9 +41,14 @@
<target name="clean-all" depends="clean, clean-lib, clean-examples"/>
<target name="noresolve">
<target name="noresolve" description="use to skip dependency resolution">
<property name="no.resolve" value="true"/>
</target>
<target name="offline" depends="noresolve" description="use to indicate no internet connection is available">
<property name="offline" value="true" />
</target>
<target name="resolve" depends="prepare" unless="no.resolve">
<ivy:retrieve/>
@ -81,8 +88,27 @@
</javadoc>
</target>
<target name="init-tests-offline" if="offline">
<fileset id="test.fileset" dir="${test.dir}">
<include name="**/*Test.java"/>
<contains text="junit"/>
<not><contains text="remote.test"/></not>
</fileset>
</target>
<target name="test" depends="jar">
<target name="init-tests-online" unless="offline">
<fileset id="test.fileset" dir="${test.dir}">
<include name="**/*Test.java"/>
<contains text="junit"/>
</fileset>
</target>
<target name="init-tests" depends="init-tests-offline, init-tests-online" >
<property name="test.fileset.property" refid="test.fileset"/>
<echo message="${test.fileset.property}"/>
</target>
<target name="test" depends="jar, init-tests">
<path id="run.classpath">
<path refid="build.classpath"/>
<pathelement location="${artifacts.build.dir}/ivy.jar"/>
@ -107,13 +133,19 @@
</classpath>
<formatter type="xml"/>
<batchtest todir="${test.report.dir}">
<fileset dir="${test.dir}">
<include name="**/*Test.java"/>
<contains text="junit"/>
</fileset>
<fileset refid="test.fileset" />
</batchtest>
</junit>
</target>
<target name="test-report" depends="test">
<junitreport>
<fileset dir="${test.report.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${test.report.dir}" />
</junitreport>
</target>
<target name="install" depends="jar" if="env.ANT_HOME">
<copy file="${artifacts.build.dir}/ivy.jar" todir="${env.ANT_HOME}/lib"/>

View File

@ -30,7 +30,9 @@ import fr.jayasoft.ivy.report.DownloadStatus;
*
*/
public class IBiblioResolverTest extends TestCase {
private File _cache;
// remote.test
private File _cache;
private ResolveData _data;
private Ivy _ivy;

View File

@ -28,6 +28,8 @@ import fr.jayasoft.ivy.report.DownloadStatus;
*
*/
public class IvyRepResolverTest extends TestCase {
// remote.test
private File _cache;
private ResolveData _data;
private Ivy _ivy;

View File

@ -32,6 +32,7 @@ import fr.jayasoft.ivy.report.DownloadStatus;
*
*/
public class URLResolverTest extends TestCase {
// remote.test
private File _cache;
private ResolveData _data;
private Ivy _ivy = new Ivy();

View File

@ -19,6 +19,7 @@ import java.util.List;
* @author <a href="johnmshields@yahoo.com">John M. Shields</a>
*/
public class ApacheURLListerTest extends TestCase {
// remote.test
//~ Methods ----------------------------------------------------------------
/**

View File

@ -14,6 +14,7 @@ import junit.framework.TestCase;
* Test BasicURLHandler
*/
public class BasicURLHandlerTest extends TestCase {
// remote.test
public void testIsReachable() throws Exception {
URLHandler handler = new BasicURLHandler();
assertTrue(handler.isReachable(new URL("http://www.google.fr/")));

View File

@ -13,6 +13,7 @@ import junit.framework.TestCase;
* Test HttpClientHandler
*/
public class HttpclientURLHandlerTest extends TestCase {
// remote.test
public void testIsReachable() throws Exception {
URLHandler handler = new HttpClientHandler();
assertTrue(handler.isReachable(new URL("http://www.google.fr/")));

View File

@ -0,0 +1,43 @@
/*
* This file is subject to the license found in LICENCE.TXT in the root directory of the project.
*
* #SNAPSHOT#
*/
package fr.jayasoft.ivy.xml;
import java.net.URL;
import junit.framework.TestCase;
import fr.jayasoft.ivy.DependencyResolver;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.resolver.IvyRepResolver;
import fr.jayasoft.ivy.url.URLHandler;
import fr.jayasoft.ivy.url.URLHandlerDispatcher;
import fr.jayasoft.ivy.url.URLHandlerRegistry;
/**
* split from XmlIvyConfigurationParserTest due to dependency on network resource
*/
public class OnlineXmlIvyConfigurationParserTest extends TestCase {
// remote.test
public void testIncludeHttpUrl() throws Exception {
configureURLHandler();
Ivy ivy = new Ivy();
XmlIvyConfigurationParser parser = new XmlIvyConfigurationParser(ivy);
parser.parse(new URL("http://www.jayasoft.org/misc/ivy/test/ivyconf-include-http-url.xml"));
DependencyResolver resolver = ivy.getResolver("ivyrep");
assertNotNull(resolver);
assertTrue(resolver instanceof IvyRepResolver);
}
private void configureURLHandler() {
URLHandlerDispatcher dispatcher = new URLHandlerDispatcher();
URLHandler httpHandler = URLHandlerRegistry.getHttp();
dispatcher.setDownloader("http", httpHandler);
dispatcher.setDownloader("https", httpHandler);
URLHandlerRegistry.setDefault(dispatcher);
}
}

View File

@ -291,17 +291,6 @@ public class XmlIvyConfigurationParserTest extends TestCase {
assertEquals("included/myrep/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]", ivyPatterns.get(0));
}
public void testIncludeHttpUrl() throws Exception {
configureURLHandler();
Ivy ivy = new Ivy();
XmlIvyConfigurationParser parser = new XmlIvyConfigurationParser(ivy);
parser.parse(new URL("http://www.jayasoft.org/misc/ivy/test/ivyconf-include-http-url.xml"));
DependencyResolver resolver = ivy.getResolver("ivyrep");
assertNotNull(resolver);
assertTrue(resolver instanceof IvyRepResolver);
}
public void testParser() throws Exception {
Ivy ivy = new Ivy();
XmlIvyConfigurationParser parser = new XmlIvyConfigurationParser(ivy);