checks ivy files data consistency with asked info (org, module name and revision)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/trunk@483994 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Xavier Hanin 2005-06-20 18:13:18 +00:00
parent b92f81e2f6
commit 6847003b33
10 changed files with 73 additions and 0 deletions

View File

@ -3,6 +3,7 @@
- new type filtering in cachepath task
- new cachefileset task: builds an ant fileset of artifacts in cache
- publish task now uses srcivypattern for ivy files finding and for delivery
- FIX: checks ivy files data consistency with asked info (org, module name and revision)
- FIX: use AUTH configuration for configuration file
version 1.1 - 2005-06-13

View File

@ -249,6 +249,18 @@ public abstract class BasicResolver extends AbstractResolver {
try {
md = XmlModuleDescriptorParser.parseDescriptor(data.getIvy(), cachedIvyURL, ivyRef.getResource(), doValidate(data));
Message.debug("\t"+getName()+": parsed downloaded ivy file for "+mrid+" parsed="+md.getModuleRevisionId());
// check descriptor data is in sync with resource revision and names
if (!mrid.getOrganisation().equals(md.getModuleRevisionId().getOrganisation())) {
throw new IllegalStateException("bad organisation found in "+ivyRef.getResource()+": expected="+mrid.getOrganisation()+" found="+md.getModuleRevisionId().getOrganisation());
}
if (!mrid.getName().equals(md.getModuleRevisionId().getName())) {
throw new IllegalStateException("bad module name found in "+ivyRef.getResource()+": expected="+mrid.getName()+" found="+md.getModuleRevisionId().getName());
}
if (ivyRef.getRevision() != null && md.getModuleRevisionId().getRevision() != null &&
!ivyRef.getRevision().equals(md.getModuleRevisionId().getRevision())) {
throw new IllegalStateException("bad revision found in "+ivyRef.getResource()+": expected="+ivyRef.getRevision()+" found="+md.getModuleRevisionId().getRevision());
}
} catch (IOException ex) {
Message.warn("io problem while parsing ivy file: "+ivyRef.getResource()+": "+ex.getMessage());
return null;

View File

@ -713,4 +713,29 @@ public class ResolveTest extends TestCase {
assertTrue(new File("build/cache/idautomation/barcode/ivy-4.10.xml").exists());
assertTrue(new File("build/cache/idautomation/barcode/jars/LinearBarCode-4.10.jar").exists());
}
public void testBadFiles() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/badfile/ivyconf.xml"));
try {
ivy.resolve(new File("test/repositories/badfile/ivys/ivy-badorg.xml").toURL(), null, new String[] {"*"}, new File("build/cache"), null, true);
fail("bad org should have raised an exception !");
} catch (Exception ex) {
// OK, it raised an exception
}
try {
ivy.resolve(new File("test/repositories/badfile/ivys/ivy-badmodule.xml").toURL(), null, new String[] {"*"}, new File("build/cache"), null, true);
fail("bad module should have raised an exception !");
} catch (Exception ex) {
// OK, it raised an exception
}
try {
ivy.resolve(new File("test/repositories/badfile/ivys/ivy-badrevision.xml").toURL(), null, new String[] {"*"}, new File("build/cache"), null, true);
fail("bad revision should have raised an exception !");
} catch (Exception ex) {
// OK, it raised an exception
}
}
}

View File

@ -0,0 +1,8 @@
<ivyconf>
<conf defaultResolver="test"/>
<resolvers>
<filesystem name="test">
<ivy pattern="${ivy.conf.dir}/[organisation]/[module]/ivy-[revision].xml"/>
</filesystem>
</resolvers>
</ivyconf>

View File

@ -0,0 +1,6 @@
<ivy-module version="1.0">
<info organisation="jayasoft" name="test-badorg"/>
<dependencies>
<dependency org="myorg" name="mymodule" rev="badorg"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,6 @@
<ivy-module version="1.0">
<info organisation="jayasoft" name="test-badorg"/>
<dependencies>
<dependency org="myorg" name="mymodule" rev="badorg"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,6 @@
<ivy-module version="1.0">
<info organisation="jayasoft" name="test-badorg"/>
<dependencies>
<dependency org="myorg" name="mymodule" rev="badorg"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,3 @@
<ivy-module version="1.1">
<info organisation="myorg" name="badmodule" revision="badmodule"/>
</ivy-module>

View File

@ -0,0 +1,3 @@
<ivy-module version="1.1">
<info organisation="badorg" name="mymodule" revision="badorg"/>
</ivy-module>

View File

@ -0,0 +1,3 @@
<ivy-module version="1.1">
<info organisation="myorg" name="mymodule" revision="1.0"/>
</ivy-module>