use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleDescriptorWriterTest method testTransitiveAttributeNotWrittenForTransitiveConfs.
/**
* Test that the transitive attribute is not written when the configuration IS transitive.
*
* This is the default and writing it will only add noise and cause a deviation from the known
* behavior (before fixing IVY-1207).
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1207">IVY-1207</a>
*/
@Test
public void testTransitiveAttributeNotWrittenForTransitiveConfs() throws Exception {
// Given a ModuleDescriptor with a 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, true, null);
md.addConfiguration(conf);
// When the ModuleDescriptor is written
XmlModuleDescriptorWriter.write(md, LICENSE, dest);
// Then the transitive attribute must NOT be written
String output = FileUtil.readEntirely(dest);
String writtenConf = output.substring(output.indexOf("<configurations>") + 16, output.indexOf("</configurations>")).trim();
assertFalse("Transitive attribute set: " + writtenConf, writtenConf.contains("transitive="));
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testUpdateWithExcludeConfigurations3.
@Test
public void testUpdateWithExcludeConfigurations3() throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-update-excludedconfs3.xml").toURI().toURL();
XmlModuleDescriptorUpdater.update(settingsUrl, buffer, getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] { "myconf2", "conf2" }));
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
// test the number of configurations
Configuration[] configs = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configs);
assertEquals("Number of configurations incorrect", 4, configs.length);
// test that the correct configuration has been removed
assertNull("myconf2 hasn't been removed", updatedMd.getConfiguration("myconf2"));
assertNull("conf2 hasn't been removed", updatedMd.getConfiguration("conf2"));
// test that the other configurations aren't removed
assertNotNull("conf1 has been removed", updatedMd.getConfiguration("conf1"));
assertNotNull("myconf1 has been removed", updatedMd.getConfiguration("myconf1"));
assertNotNull("myconf3 has been removed", updatedMd.getConfiguration("myconf3"));
assertNotNull("myconf4 has been removed", updatedMd.getConfiguration("myconf4"));
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testMergedUpdateWithExtendsAndDefaultConfMappings.
/**
* Test case for IVY-1420.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1420">IVY-1420</a>
*/
@Test
public void testMergedUpdateWithExtendsAndDefaultConfMappings() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-extends-configurations-defaultconfmapping.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer, getUpdateOptions("release", "mynewrev").setMerge(true).setMergedDescriptor(md));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
Configuration[] configurations = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configurations);
assertEquals("Number of configurations is incorrect", 3, configurations.length);
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains("configurations defaultconfmapping=\"conf1,default->@()\""));
assertTrue(updatedXml.contains("dependencies defaultconfmapping=\"conf1,default->@()\""));
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testMergedUpdateWithIncludeAndExcludedConf.
/**
* Test case for IVY-1419.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1419">IVY-1419</a>
*/
@Test
public void testMergedUpdateWithIncludeAndExcludedConf() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-update-excludedconfs6.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer, getUpdateOptions("release", "mynewrev").setMerge(true).setMergedDescriptor(md).setConfsToExclude(new String[] { "conf1" }));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
Configuration[] configurations = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configurations);
assertEquals("Number of configurations is incorrect", 5, configurations.length);
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains("dependencies/"));
}
use of org.apache.ivy.core.module.descriptor.Configuration in project ant-ivy by apache.
the class AbstractWorkspaceResolver method createWorkspaceMd.
protected WorkspaceModuleDescriptor createWorkspaceMd(ModuleDescriptor md) {
DefaultWorkspaceModuleDescriptor newMd = new DefaultWorkspaceModuleDescriptor(md.getModuleRevisionId(), "release", null, true);
newMd.addConfiguration(new Configuration(ModuleDescriptor.DEFAULT_CONFIGURATION));
newMd.setLastModified(System.currentTimeMillis());
newMd.setDescription(md.getDescription());
newMd.setHomePage(md.getHomePage());
newMd.setLastModified(md.getLastModified());
newMd.setPublicationDate(md.getPublicationDate());
newMd.setResolvedPublicationDate(md.getResolvedPublicationDate());
newMd.setStatus(md.getStatus());
Configuration[] allConfs = md.getConfigurations();
for (Artifact af : createWorkspaceArtifacts(md)) {
if (allConfs.length == 0) {
newMd.addArtifact(ModuleDescriptor.DEFAULT_CONFIGURATION, af);
} else {
for (Configuration conf : allConfs) {
newMd.addConfiguration(conf);
newMd.addArtifact(conf.getName(), af);
}
}
}
for (DependencyDescriptor dependency : md.getDependencies()) {
newMd.addDependency(dependency);
}
for (ExcludeRule excludeRule : md.getAllExcludeRules()) {
newMd.addExcludeRule(excludeRule);
}
newMd.getExtraInfos().addAll(md.getExtraInfos());
for (License license : md.getLicenses()) {
newMd.addLicense(license);
}
return newMd;
}
Aggregations