Search in sources :

Example 11 with BasicResource

use of org.apache.ivy.plugins.repository.BasicResource in project ant-ivy by apache.

the class XmlModuleUpdaterTest method testUpdateWithComments.

@Test
public void testUpdateWithComments() throws Exception {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-with-comments.xml").toURI().toURL();
    XmlModuleDescriptorUpdater.update(settingsUrl, new BufferedOutputStream(buffer, 1024), getUpdateOptions("release", "mynewrev"));
    XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
    ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
    DependencyDescriptor[] dependencies = updatedMd.getDependencies();
    assertNotNull(dependencies);
    assertEquals(3, dependencies.length);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ByteArrayInputStream(java.io.ByteArrayInputStream) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) IvySettings(org.apache.ivy.core.settings.IvySettings) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BasicResource(org.apache.ivy.plugins.repository.BasicResource) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) URL(java.net.URL) Test(org.junit.Test)

Example 12 with BasicResource

use of org.apache.ivy.plugins.repository.BasicResource 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/"));
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) Configuration(org.apache.ivy.core.module.descriptor.Configuration) ByteArrayInputStream(java.io.ByteArrayInputStream) IvySettings(org.apache.ivy.core.settings.IvySettings) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BasicResource(org.apache.ivy.plugins.repository.BasicResource) URL(java.net.URL) Test(org.junit.Test)

Aggregations

BasicResource (org.apache.ivy.plugins.repository.BasicResource)12 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)11 Test (org.junit.Test)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 URL (java.net.URL)10 IvySettings (org.apache.ivy.core.settings.IvySettings)10 File (java.io.File)6 Configuration (org.apache.ivy.core.module.descriptor.Configuration)6 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)4 Artifact (org.apache.ivy.core.module.descriptor.Artifact)2 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Date (java.util.Date)1 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)1 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)1 ModuleId (org.apache.ivy.core.module.id.ModuleId)1 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)1