use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testExtendsMixed.
@Test
public void testExtendsMixed() throws Exception {
// descriptor specifies that parent configurations and dependencies should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-extends-mixed.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was ignored.
assertEquals("", md.getDescription());
// verify that the parent and child configurations were merged together.
final Configuration[] expectedConfs = { new Configuration("default"), new Configuration("conf1"), new Configuration("conf2") };
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent and child dependencies were merged together.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(2, deps.length);
assertEquals(Collections.singletonList("default"), Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule1", dep.getModuleId().getName());
assertEquals("1.0", dep.getRevision());
assertEquals(Arrays.asList("conf1", "conf2"), Arrays.asList(deps[1].getModuleConfigurations()));
dep = deps[1].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testExtendsDependencies.
@Test
public void testExtendsDependencies() throws Exception {
// descriptor specifies that only parent dependencies should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-extends-dependencies.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was ignored.
assertEquals("", md.getDescription());
// verify that the parent configurations were ignored.
final Configuration[] expectedConfs = { new Configuration("default") };
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent dependencies were merged.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(2, deps.length);
assertEquals(Collections.singletonList("default"), Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule1", dep.getModuleId().getName());
assertEquals("1.0", dep.getRevision());
assertEquals(Collections.singletonList("default"), Arrays.asList(deps[1].getModuleConfigurations()));
dep = deps[1].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testExtendsDescription.
@Test
public void testExtendsDescription() throws Exception {
// descriptor specifies that only parent description should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-extends-description.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was merged.
assertEquals("Parent module description.", md.getDescription());
// verify that the parent configurations were ignored.
final Configuration[] expectedConfs = { new Configuration("default") };
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent dependencies were ignored.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(1, deps.length);
assertEquals(Collections.singletonList("default"), Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testImportConfigurations1.
@Test
public void testImportConfigurations1() throws Exception {
// import configurations
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-configurations-import1.xml"), true);
assertNotNull(md);
// should have imported configurations
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(new Configuration("conf1", PUBLIC, "", new String[0], true, null), new Configuration("conf2", PRIVATE, "", new String[0], true, null)), Arrays.asList(md.getConfigurations()));
DependencyDescriptor[] dependencies = md.getDependencies();
assertNotNull(dependencies);
assertEquals(2, dependencies.length);
// no conf def => defaults to defaultConf: *->*
DependencyDescriptor dd = getDependency(dependencies, "mymodule1");
assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getDependencyConfigurations("conf1")));
// confs def: conf1->*
dd = getDependency(dependencies, "mymodule2");
assertEquals(Collections.singletonList("conf1"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getDependencyConfigurations("conf1")));
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testSimple.
@Test
public void testSimple() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-simple.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
assertNotNull(md.getConfigurations());
assertEquals(Collections.singletonList(new Configuration("default")), Arrays.asList(md.getConfigurations()));
assertNotNull(md.getArtifacts("default"));
assertEquals(1, md.getArtifacts("default").length);
assertEquals("mymodule", md.getArtifacts("default")[0].getName());
assertEquals("jar", md.getArtifacts("default")[0].getType());
assertNotNull(md.getDependencies());
assertEquals(0, md.getDependencies().length);
}
Aggregations