public void testUpdateWithExcludeConfigurations4() throws Exception {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    URL settingsUrl =
        new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-update-excludedconfs4.xml")
            .toURL();
    XmlModuleDescriptorUpdater.update(
        settingsUrl,
        buffer,
        getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] {"myconf2"}));

    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
    Artifact[] artifacts = updatedMd.getAllArtifacts();
    assertNotNull("Published artifacts shouldn't be null", artifacts);
    assertEquals("Number of published artifacts incorrect", 4, artifacts.length);

    // test that the correct configuration has been removed
    for (int i = 0; i < artifacts.length; i++) {
      Artifact current = artifacts[i];
      List currentConfs = Arrays.asList(current.getConfigurations());
      assertTrue(
          "myconf2 hasn't been removed for artifact " + current.getName(),
          !currentConfs.contains("myconf2"));
    }
  }
  public void testUpdateWithExcludeConfigurations5() throws Exception {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    URL settingsUrl =
        new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-update-excludedconfs5.xml")
            .toURL();
    XmlModuleDescriptorUpdater.update(
        settingsUrl,
        buffer,
        getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] {"myconf2"}));

    XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
    ModuleDescriptor updatedMd =
        parser.parseDescriptor(
            new IvySettings(),
            new ByteArrayInputStream(buffer.toByteArray()),
            new BasicResource("test", false, 0, 0, false),
            true);

    DependencyDescriptor[] deps = updatedMd.getDependencies();
    assertNotNull("Dependencies shouldn't be null", deps);
    assertEquals("Number of dependencies is incorrect", 8, deps.length);

    // check that none of the dependencies contains myconf2
    for (int i = 0; i < deps.length; i++) {
      String name = deps[i].getDependencyId().getName();
      assertFalse(
          "Dependency " + name + " shouldn't have myconf2 as module configuration",
          Arrays.asList(deps[i].getModuleConfigurations()).contains("myconf2"));
      assertEquals(
          "Dependency " + name + " shouldn't have a dependency artifact for configuration myconf2",
          0,
          deps[i].getDependencyArtifacts("myconf2").length);
    }
  }
  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")
            .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"));
  }
  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").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);
  }