use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testWithPlugins.
/**
* Test case for IVY-417.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-417">IVY-417</a>
*/
@Test
public void testWithPlugins() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("mule-1.3.3.pom"), false);
assertNotNull(md);
assertEquals(ModuleRevisionId.newInstance("org.mule", "mule", "1.3.3"), md.getModuleRevisionId());
DependencyDescriptor[] dds = md.getDependencies();
assertNotNull(dds);
assertEquals(0, dds.length);
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testDependenciesWithClassifier.
@Test
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<String, String> 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());
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testDependencies.
@Test
public void testDependencies() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-dependencies.pom"), false);
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());
assertEquals("There is no special artifact when there is no classifier", 0, dds[0].getAllDependencyArtifacts().length);
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testVariables.
/**
* Test case for IVY-425.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-425">IVY-425</a>
*/
@Test
public void testVariables() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("spring-hibernate3-2.0.2.pom"), false);
assertNotNull(md);
assertEquals(ModuleRevisionId.newInstance("org.springframework", "spring-hibernate3", "2.0.2"), md.getModuleRevisionId());
DependencyDescriptor[] dds = md.getDependencies();
assertNotNull(dds);
assertEquals(11, dds.length);
assertEquals(ModuleRevisionId.newInstance("org.springframework", "spring-web", "2.0.2"), dds[10].getDependencyRevisionId());
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testPropertiesDefinedInProfiles.
/**
* Tests that the {@code properties} setup in the Maven {@code profiles} that are conditionally activated,
* become available to the module being parsed and such properties can be used as references within the pom
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1577">IVY-1577</a> for more details
*/
@Test
public void testPropertiesDefinedInProfiles() throws Exception {
final String[] packagingTypesToTest = new String[] { "bundle", "jar" };
for (final String expectedPackagingType : packagingTypesToTest) {
String sysPropToSet = null;
switch(expectedPackagingType) {
case "bundle":
{
sysPropToSet = "PomModuleDescriptorParserTest.some-other-test-prop";
break;
}
case "jar":
{
sysPropToSet = "PomModuleDescriptorParserTest.some-test-prop";
break;
}
default:
{
fail("Unexpected packaging type");
}
}
// activate the relevant profile, based on a system property
System.setProperty(sysPropToSet, "foo");
try {
// now parse the pom
final ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-properties-in-profile.pom"), false);
assertNotNull("Parsed module descriptor was null", md);
assertEquals("Unexpected module descriptor", ModuleRevisionId.newInstance("org.apache", "test", "5.0.1"), md.getModuleRevisionId());
final Artifact[] artifacts = md.getAllArtifacts();
assertNotNull("No artifacts found for module", artifacts);
assertEquals("Unexpected number of artifacts for module", 1, artifacts.length);
final Artifact mainArtifact = artifacts[0];
// make sure that the main artifact which references a conditionally set property (via a Maven profile)
// is indeed using the right value
assertEquals("Unexpected artifact type", expectedPackagingType, mainArtifact.getType());
// some other basic tests
final DependencyDescriptor[] dds = md.getDependencies();
assertNotNull(dds);
assertEquals(1, dds.length);
assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"), dds[0].getDependencyRevisionId());
} finally {
if (sysPropToSet != null) {
// reset the system prop that we had set
System.clearProperty(sysPropToSet);
}
}
}
}
Aggregations