assertEquals("There is no special artifact when there is no classifier", 0,
dds[0].getAllDependencyArtifacts().length);
}
public void testDependenciesWithClassifier() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-dependencies-with-classifier.pom"), true);
assertNotNull(md);
assertEquals(ModuleRevisionId.newInstance("org.apache", "test", "1.0"),
md.getModuleRevisionId());
DependencyDescriptor[] dds = md.getDependencies();
assertNotNull(dds);
assertEquals(1, dds.length);
assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"),
dds[0].getDependencyRevisionId());
Map extraAtt = Collections.singletonMap("classifier", "asl");
assertEquals(1, dds[0].getAllDependencyArtifacts().length);
assertEquals(extraAtt, dds[0].getAllDependencyArtifacts()[0].getExtraAttributes());
// now we verify the conversion to an Ivy file
PomModuleDescriptorParser.getInstance().toIvyFile(
getClass().getResource("test-dependencies-with-classifier.pom").openStream(),
new URLResource(getClass().getResource("test-dependencies-with-classifier.pom")), dest,
md);
assertTrue(dest.exists());
// the converted Ivy file should be parsable with validate=true
ModuleDescriptor md2 = XmlModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), dest.toURI().toURL(), true);
// and the parsed module descriptor should be similar to the original
assertNotNull(md2);
assertEquals(md.getModuleRevisionId(), md2.getModuleRevisionId());
dds = md2.getDependencies();
assertEquals(1, dds[0].getAllDependencyArtifacts().length);
assertEquals(extraAtt, dds[0].getAllDependencyArtifacts()[0].getExtraAttributes());
}