Search in sources :

Example 21 with Configuration

use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.

the class XmlModuleDescriptorParserTest method testImportConfigurationsWithExtendOtherConfigs.

@Test
public void testImportConfigurationsWithExtendOtherConfigs() throws Exception {
    // import configurations and default mapping
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-configextendsothers2.xml"), true);
    assertNotNull(md);
    // has an 'all-public' configuration
    Configuration allPublic = md.getConfiguration("all-public");
    assertNotNull(allPublic);
    // 'all-public' extends all other public configurations
    String[] allPublicExt = allPublic.getExtends();
    assertEquals(Arrays.asList("default", "test", "extra"), Arrays.asList(allPublicExt));
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) Configuration(org.apache.ivy.core.module.descriptor.Configuration) Test(org.junit.Test)

Example 22 with Configuration

use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.

the class XmlModuleDescriptorParserTest method testNoArtifact.

@Test
public void testNoArtifact() throws Exception {
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-noartifact.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(0, md.getArtifacts("default").length);
    assertNotNull(md.getDependencies());
    assertEquals(0, md.getDependencies().length);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) Configuration(org.apache.ivy.core.module.descriptor.Configuration) Test(org.junit.Test)

Example 23 with Configuration

use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.

the class XmlModuleDescriptorParserTest method testBug60.

@Test
public void testBug60() throws Exception {
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-bug60.xml"), true);
    assertNotNull(md);
    assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
    assertEquals("mymodule", md.getModuleRevisionId().getName());
    assertEquals("myrev", md.getModuleRevisionId().getRevision());
    assertEquals("integration", md.getStatus());
    Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime();
    assertEquals(pubdate, md.getPublicationDate());
    assertEquals(Collections.singletonList(new Configuration("default")), Arrays.asList(md.getConfigurations()));
    assertArtifacts(md.getArtifacts("default"), new String[] { "myartifact1", "myartifact2" });
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) Configuration(org.apache.ivy.core.module.descriptor.Configuration) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) Test(org.junit.Test)

Example 24 with Configuration

use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.

the class XmlModuleDescriptorWriterTest method testTransitiveAttributeForNonTransitiveConfs.

/**
 * Test that the transitive attribute is written for non-transitive configurations.
 *
 * <code>&lt;conf ... transitive="false" ... /&gt;</code>
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1207">IVY-1207</a>
 */
@Test
public void testTransitiveAttributeForNonTransitiveConfs() throws Exception {
    // Given a ModuleDescriptor with a non-transitive configuration
    DefaultModuleDescriptor md = new DefaultModuleDescriptor(new ModuleRevisionId(new ModuleId("myorg", "myname"), "1.0"), "integration", new Date());
    Configuration conf = new Configuration("conf", PUBLIC, "desc", null, false, null);
    md.addConfiguration(conf);
    // When the ModuleDescriptor is written
    XmlModuleDescriptorWriter.write(md, LICENSE, dest);
    // Then the transitive attribute must be set to false
    String output = FileUtil.readEntirely(dest);
    String writtenConf = output.substring(output.indexOf("<configurations>") + 16, output.indexOf("</configurations>")).trim();
    assertTrue("Transitive attribute not set to false: " + writtenConf, writtenConf.contains("transitive=\"false\""));
}
Also used : ModuleId(org.apache.ivy.core.module.id.ModuleId) Configuration(org.apache.ivy.core.module.descriptor.Configuration) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) Date(java.util.Date) Test(org.junit.Test) PomModuleDescriptorParserTest(org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest)

Example 25 with Configuration

use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.

the class AbstractModuleDescriptorParserTester method assertConf.

protected void assertConf(ModuleDescriptor md, String name, String desc, Visibility visibility, String[] exts) {
    Configuration conf = md.getConfiguration(name);
    assertNotNull("configuration not found: " + name, conf);
    assertEquals(name, conf.getName());
    assertEquals(desc, conf.getDescription());
    assertEquals(visibility, conf.getVisibility());
    assertEquals(Arrays.asList(exts), Arrays.asList(conf.getExtends()));
}
Also used : Configuration(org.apache.ivy.core.module.descriptor.Configuration)

Aggregations

Configuration (org.apache.ivy.core.module.descriptor.Configuration)45 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)30 Test (org.junit.Test)29 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)17 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)16 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)15 Artifact (org.apache.ivy.core.module.descriptor.Artifact)10 Date (java.util.Date)9 URL (java.net.URL)7 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 IvySettings (org.apache.ivy.core.settings.IvySettings)6 BasicResource (org.apache.ivy.plugins.repository.BasicResource)6 File (java.io.File)5 Map (java.util.Map)4 ModuleId (org.apache.ivy.core.module.id.ModuleId)4 GregorianCalendar (java.util.GregorianCalendar)3 License (org.apache.ivy.core.module.descriptor.License)3 IOException (java.io.IOException)2