mirror of https://github.com/apache/ant-ivy
Setup of the unit tests of the OSGi mapping
git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@1036863 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9e71529c37
commit
e0091b3f6f
|
|
@ -426,8 +426,13 @@
|
|||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="test-internal" depends="build-test, init-tests" unless="skip.test">
|
||||
|
||||
<target name="prepare-test" depends="resolve" unless="skip.test">
|
||||
<ant dir="${basedir}/test/test-repo" target="generate-bundles" />
|
||||
<ant dir="${basedir}/test/test-bundles" target="build-all" />
|
||||
</target>
|
||||
|
||||
<target name="test-internal" depends="build-test, init-tests" unless="skip.test">
|
||||
<mkdir dir="${test.xml.dir}" />
|
||||
|
||||
<junit
|
||||
|
|
|
|||
5
ivy.xml
5
ivy.xml
|
|
@ -57,12 +57,13 @@
|
|||
<dependency org="junit" name="junit" rev="3.8.2" conf="test->default" />
|
||||
<dependency org="commons-lang" name="commons-lang" rev="[1.0,3.0[" conf="test->default" />
|
||||
<dependency org="org.apache.ant" name="ant-testutil" rev="1.7.0" conf="test->default" transitive="false" />
|
||||
<dependency org="ant" name="ant-launcher" rev="1.6.2" conf="test->default" transitive="false"/>
|
||||
<dependency org="ant" name="ant-launcher" rev="1.6.2" conf="test->default" transitive="false"/>
|
||||
<dependency org="ant-contrib" name="ant-contrib" rev="1.0b3" conf="test->default" transitive="false"/>
|
||||
|
||||
<!-- This dependency is necessary for having validation in junit tests when running with JDK1.4 -->
|
||||
<dependency org="xerces" name="xercesImpl" rev="2.6.2" conf="test->default" />
|
||||
<dependency org="xerces" name="xmlParserAPIs" rev="2.6.2" conf="test->default" />
|
||||
|
||||
|
||||
<!-- Global exclude for junit -->
|
||||
<exclude org="junit" module="junit" conf="core,default,httpclient,oro,vfs,sftp,standalone,ant" />
|
||||
</dependencies>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.apache.ivy.plugins.parser.AbstractModuleDescriptorParserTester;
|
|||
public class IvyIntegrationTest extends AbstractModuleDescriptorParserTester {
|
||||
|
||||
private URL getTestResource(String resource) throws MalformedURLException {
|
||||
return new File("java/test-ivy/" + resource).toURI().toURL();
|
||||
return new File("test/test-ivy/" + resource).toURI().toURL();
|
||||
}
|
||||
|
||||
public void testAcmeResolveAlpha() throws Exception {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class JarHandlingRepositoryTest extends TestCase {
|
|||
|
||||
public void test() throws IOException {
|
||||
final JarEntryResource resource = new JarEntryResource(
|
||||
"java/test-bundles/jars/com.acme.alpha-1.0.0.20080101.jar!META-INF/MANIFEST.MF");
|
||||
"test/test-bundles/jars/com.acme.alpha-1.0.0.20080101.jar!META-INF/MANIFEST.MF");
|
||||
assertNotNull(resource.openStream());
|
||||
assertTrue(resource.isLocal());
|
||||
assertTrue(resource.exists());
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ public class OsgiIvyParserTest extends TestCase {
|
|||
|
||||
public void testSimple() throws Exception {
|
||||
IvySettings settings = new IvySettings();
|
||||
settings.load(new File("java/test-ivy/include/ivysettings.xml"));
|
||||
settings.load(new File("test/test-ivy/include/ivysettings.xml"));
|
||||
|
||||
URLResource includingResource = new URLResource(
|
||||
new File("java/test-ivy/include/ivy.xml").toURL());
|
||||
new File("test/test-ivy/include/ivy.xml").toURL());
|
||||
ModuleDescriptorParser includingParser = ModuleDescriptorParserRegistry.getInstance()
|
||||
.getParser(includingResource);
|
||||
assertTrue(includingParser instanceof OsgiIvyParser);
|
||||
|
|
@ -47,7 +47,7 @@ public class OsgiIvyParserTest extends TestCase {
|
|||
assertNotNull(includingMd);
|
||||
|
||||
URLResource resultResource = new URLResource(new File(
|
||||
"java/test-ivy/include/ivy-result.xml").toURL());
|
||||
"test/test-ivy/include/ivy-result.xml").toURL());
|
||||
ModuleDescriptorParser resultParser = ModuleDescriptorParserRegistry.getInstance()
|
||||
.getParser(resultResource);
|
||||
ModuleDescriptor resultMd = resultParser.parseDescriptor(settings, resultResource.getURL(),
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import org.apache.ivy.util.FileUtil;
|
|||
public class OsgiManifestParserTest extends AbstractModuleDescriptorParserTester {
|
||||
|
||||
private URL getTestResource(String resource) throws MalformedURLException {
|
||||
return new File("java/test-ivy/" + resource).toURI().toURL();
|
||||
return new File("test/test-ivy/" + resource).toURI().toURL();
|
||||
}
|
||||
|
||||
public void testAccept() throws Exception {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class OBRParserTest extends TestCase {
|
|||
|
||||
public void testParse() throws Exception {
|
||||
BundleRepo repo = OBRXMLParser
|
||||
.parse(new FileInputStream(new File("java/test-obr/obr.xml")));
|
||||
.parse(new FileInputStream(new File("test/test-obr/obr.xml")));
|
||||
assertNotNull(repo);
|
||||
System.out.println(repo.getBundles().size() + " bundles successfully parsed, "
|
||||
+ Message.getProblems().size() + " errors");
|
||||
|
|
|
|||
|
|
@ -93,14 +93,14 @@ public class BundleRepoResolverTest extends TestCase {
|
|||
settings = new IvySettings();
|
||||
|
||||
bundleResolver = new BundleRepoResolver();
|
||||
bundleResolver.setRepoXmlFile(new File("java/test-repo/bundlerepo/repo.xml")
|
||||
bundleResolver.setRepoXmlFile(new File("test/test-repo/bundlerepo/repo.xml")
|
||||
.getAbsolutePath());
|
||||
bundleResolver.setName("bundle");
|
||||
bundleResolver.setSettings(settings);
|
||||
settings.addResolver(bundleResolver);
|
||||
|
||||
bundleUrlResolver = new BundleRepoResolver();
|
||||
bundleUrlResolver.setRepoXmlURL(new File("java/test-repo/bundlerepo/repo.xml").toURI()
|
||||
bundleUrlResolver.setRepoXmlURL(new File("test/test-repo/bundlerepo/repo.xml").toURI()
|
||||
.toURL().toExternalForm());
|
||||
bundleUrlResolver.setName("bundleurl");
|
||||
bundleUrlResolver.setSettings(settings);
|
||||
|
|
@ -108,12 +108,12 @@ public class BundleRepoResolverTest extends TestCase {
|
|||
|
||||
dualResolver = new DualResolver();
|
||||
BundleRepoResolver resolver = new BundleRepoResolver();
|
||||
resolver.setRepoXmlFile("java/test-repo/ivyrepo/repo.xml");
|
||||
resolver.setRepoXmlFile("test/test-repo/ivyrepo/repo.xml");
|
||||
resolver.setName("dual-bundle");
|
||||
resolver.setSettings(settings);
|
||||
dualResolver.add(resolver);
|
||||
dualResolver.setName("dual");
|
||||
File ivyrepo = new File("java/test-repo/ivyrepo");
|
||||
File ivyrepo = new File("test/test-repo/ivyrepo");
|
||||
FileSystemResolver fileSystemResolver = new FileSystemResolver();
|
||||
fileSystemResolver.addIvyPattern(ivyrepo.getAbsolutePath()
|
||||
+ "/[organisation]/[module]/[revision]/ivy.xml");
|
||||
|
|
@ -270,7 +270,7 @@ public class BundleRepoResolverTest extends TestCase {
|
|||
|
||||
private void genericTestResolve(String jarName, String conf, ModuleRevisionId[] expectedMrids)
|
||||
throws Exception {
|
||||
JarInputStream in = new JarInputStream(new FileInputStream("java/test-repo/bundlerepo/"
|
||||
JarInputStream in = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
|
||||
+ jarName));
|
||||
BundleInfo bundleInfo = ManifestParser.parseManifest(in.getManifest());
|
||||
DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo, null);
|
||||
|
|
@ -291,7 +291,7 @@ public class BundleRepoResolverTest extends TestCase {
|
|||
}
|
||||
|
||||
private void genericTestFailingResolve(String jarName, String conf) throws Exception {
|
||||
JarInputStream in = new JarInputStream(new FileInputStream("java/test-repo/bundlerepo/"
|
||||
JarInputStream in = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
|
||||
+ jarName));
|
||||
BundleInfo bundleInfo = ManifestParser.parseManifest(in.getManifest());
|
||||
DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo, null);
|
||||
|
|
|
|||
|
|
@ -42,24 +42,24 @@ import org.xml.sax.SAXException;
|
|||
public class BundleRepoTest extends TestCase {
|
||||
|
||||
public void testFS() throws Exception {
|
||||
FSManifestIterable it = new FSManifestIterable(new File("java/test-repo/bundlerepo"), "");
|
||||
FSManifestIterable it = new FSManifestIterable(new File("test/test-repo/bundlerepo"), "");
|
||||
BundleRepo repo = new BundleRepo();
|
||||
repo.populate(it);
|
||||
|
||||
BundleRepo repo2 = OBRXMLParser.parse(new FileInputStream(
|
||||
"java/test-repo/bundlerepo/repo.xml"));
|
||||
"test/test-repo/bundlerepo/repo.xml"));
|
||||
|
||||
assertEquals(repo, repo2);
|
||||
}
|
||||
|
||||
public void testFileRepo() throws Exception {
|
||||
RepositoryManifestIterable it = new RepositoryManifestIterable(new FileRepository(new File(
|
||||
"java/test-repo/bundlerepo")));
|
||||
"test/test-repo/bundlerepo")));
|
||||
BundleRepo repo = new BundleRepo();
|
||||
repo.populate(it);
|
||||
|
||||
BundleRepo repo2 = OBRXMLParser.parse(new FileInputStream(
|
||||
"java/test-repo/bundlerepo/repo.xml"));
|
||||
"test/test-repo/bundlerepo/repo.xml"));
|
||||
|
||||
assertEquals(repo, repo2);
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ public class BundleRepoTest extends TestCase {
|
|||
public void testResolver() throws Exception {
|
||||
FileSystemResolver fileSystemResolver = new FileSystemResolver();
|
||||
fileSystemResolver.setName("test");
|
||||
File ivyrepo = new File("java/test-repo/ivyrepo");
|
||||
File ivyrepo = new File("test/test-repo/ivyrepo");
|
||||
fileSystemResolver.addIvyPattern(ivyrepo.getAbsolutePath()
|
||||
+ "/[organisation]/[module]/[revision]/ivy.xml");
|
||||
fileSystemResolver.addArtifactPattern(ivyrepo.getAbsolutePath()
|
||||
|
|
@ -78,13 +78,13 @@ public class BundleRepoTest extends TestCase {
|
|||
repo.populate(it);
|
||||
|
||||
BundleRepo repo2 = OBRXMLParser
|
||||
.parse(new FileInputStream("java/test-repo/ivyrepo/repo.xml"));
|
||||
.parse(new FileInputStream("test/test-repo/ivyrepo/repo.xml"));
|
||||
|
||||
assertEquals(repo, repo2);
|
||||
}
|
||||
|
||||
public void testXMLSerialisation() throws SAXException, ParseException, IOException {
|
||||
FSManifestIterable it = new FSManifestIterable(new File("java/test-repo/bundlerepo"), "");
|
||||
FSManifestIterable it = new FSManifestIterable(new File("test/test-repo/bundlerepo"), "");
|
||||
BundleRepo repo = new BundleRepo();
|
||||
repo.populate(it);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ import junit.framework.TestCase;
|
|||
public class ArtifactTokensTest extends TestCase {
|
||||
|
||||
public void testGoodMatching() {
|
||||
final String repoResource = "java/test-ivy/osgi/eclipse/plugins/org.eclipse.datatools.connectivity.ui_1.0.1.v200808121010";
|
||||
final String repoResource = "test/test-ivy/osgi/eclipse/plugins/org.eclipse.datatools.connectivity.ui_1.0.1.v200808121010";
|
||||
final ArtifactTokens tokens = new ArtifactTokens(repoResource);
|
||||
assertEquals("java/test-ivy/osgi/eclipse/plugins/", tokens.prefix);
|
||||
assertEquals("test/test-ivy/osgi/eclipse/plugins/", tokens.prefix);
|
||||
assertEquals("org.eclipse.datatools.connectivity.ui", tokens.module);
|
||||
assertEquals("1.0.1", tokens.version.numbersAsString());
|
||||
assertEquals("v200808121010", tokens.version.qualifier());
|
||||
|
|
@ -32,9 +32,9 @@ public class ArtifactTokensTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testGoodMatching2() {
|
||||
final String repoResource = "java/test-ivy/osgi/eclipse/plugins/org.eclipse.datatools.connectivity.ui_1.0.1";
|
||||
final String repoResource = "test/test-ivy/osgi/eclipse/plugins/org.eclipse.datatools.connectivity.ui_1.0.1";
|
||||
final ArtifactTokens tokens = new ArtifactTokens(repoResource);
|
||||
assertEquals("java/test-ivy/osgi/eclipse/plugins/", tokens.prefix);
|
||||
assertEquals("test/test-ivy/osgi/eclipse/plugins/", tokens.prefix);
|
||||
assertEquals("org.eclipse.datatools.connectivity.ui", tokens.module);
|
||||
assertEquals("1.0.1", tokens.version.numbersAsString());
|
||||
assertEquals("", tokens.version.qualifier());
|
||||
|
|
@ -42,9 +42,9 @@ public class ArtifactTokensTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testGoodMatching3() {
|
||||
final String repoResource = "java/test-ivy/osgi/eclipse/plugins/org.myorg.module.one_3.21.100.v20070530";
|
||||
final String repoResource = "test/test-ivy/osgi/eclipse/plugins/org.myorg.module.one_3.21.100.v20070530";
|
||||
final ArtifactTokens tokens = new ArtifactTokens(repoResource);
|
||||
assertEquals("java/test-ivy/osgi/eclipse/plugins/", tokens.prefix);
|
||||
assertEquals("test/test-ivy/osgi/eclipse/plugins/", tokens.prefix);
|
||||
assertEquals("org.myorg.module.one", tokens.module);
|
||||
assertEquals("3.21.100", tokens.version.numbersAsString());
|
||||
assertEquals("v20070530", tokens.version.qualifier());
|
||||
|
|
@ -52,11 +52,11 @@ public class ArtifactTokensTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testGoodMatching4() {
|
||||
final String repoResource = "java/test-ivy/osgi/eclipse/plugins/org.eclipse.mylyn.tasks.ui_3.0.1.v20080721-2100-e33.jar";
|
||||
final String repoResource = "test/test-ivy/osgi/eclipse/plugins/org.eclipse.mylyn.tasks.ui_3.0.1.v20080721-2100-e33.jar";
|
||||
// String repoResource =
|
||||
// "java/test-ivy/osgi/eclipse/plugins/org.eclipse.mylyn.tasks.ui_3.0.1.v20080721.jar";
|
||||
// "test/test-ivy/osgi/eclipse/plugins/org.eclipse.mylyn.tasks.ui_3.0.1.v20080721.jar";
|
||||
final ArtifactTokens tokens = new ArtifactTokens(repoResource);
|
||||
assertEquals("java/test-ivy/osgi/eclipse/plugins/", tokens.prefix);
|
||||
assertEquals("test/test-ivy/osgi/eclipse/plugins/", tokens.prefix);
|
||||
assertEquals("org.eclipse.mylyn.tasks.ui", tokens.module);
|
||||
assertEquals("3.0.1", tokens.version.numbersAsString());
|
||||
assertEquals("v20080721-2100-e33", tokens.version.qualifier());
|
||||
|
|
@ -64,7 +64,7 @@ public class ArtifactTokensTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testBadMatching() {
|
||||
final String repoResource = "java/test-ivy/osgi/eclipse/plugins/fake";
|
||||
final String repoResource = "test/test-ivy/osgi/eclipse/plugins/fake";
|
||||
final ArtifactTokens tokens = new ArtifactTokens(repoResource);
|
||||
assertNull(tokens.prefix);
|
||||
assertNull(tokens.module);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
<property name="bundle.bin" value="${bundle.dir}/bin" />
|
||||
<property name="bundle.manifest" value="${bundle.dir}/META-INF/MANIFEST.MF" />
|
||||
|
||||
<mkdir dir="${bundle.bin}" />
|
||||
<javac destdir="${bundle.bin}" srcdir="${bundle.src}" />
|
||||
|
||||
<jar destfile="${jars.dir}/com.acme.${bundle.name}-${bundle.version}.jar" basedir="${bundle.bin}" manifest="${bundle.manifest}" />
|
||||
|
|
@ -85,13 +86,14 @@
|
|||
|
||||
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant">
|
||||
<classpath>
|
||||
<pathelement location="${basedir}/../../lib/ivy*.jar"/>
|
||||
<pathelement location="${basedir}/../../build/classes/core" />
|
||||
<pathelement location="${basedir}/../../build/classes/bootstrap" />
|
||||
</classpath>
|
||||
</taskdef>
|
||||
|
||||
<target name="ivy">
|
||||
<ivy:settings file="${basedir}/../test-ivy/acme-ivysettings.xml" />
|
||||
<ivy:resolve file="${basedir}/../test-ivy/acme-ivy.xml" />
|
||||
<ivy:retrieve pattern="${basedir}/../../target/test-data/bundles/[artifact]-[revision].[ext]"/>
|
||||
<ivy:retrieve pattern="${basedir}/../../build/test-data/bundles/[artifact]-[revision].[ext]"/>
|
||||
</target>
|
||||
</project>
|
||||
|
|
@ -18,11 +18,9 @@
|
|||
-->
|
||||
<project basedir="." default="generate-bundles" name="ivy-osgi-test-repo">
|
||||
|
||||
<echo message="${basedir}"/>
|
||||
|
||||
<!-- Need ant contrib ! -->
|
||||
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
|
||||
<classpath location="${basedir}/../../lib/test/ant-contrib.jar"/>
|
||||
<classpath location="${basedir}/../../lib/ant-contrib.jar"/>
|
||||
</taskdef>
|
||||
|
||||
<target name="generate-bundles">
|
||||
|
|
|
|||
Loading…
Reference in New Issue