public void testitMNG3746_UsingCLIProperty() throws Exception {
    // The testdir is computed from the location of this
    // file.
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-3746");
    File pluginDir = new File(testDir, "maven-mng3746-plugin");
    File projectDir = new File(testDir, "project");

    Verifier verifier;

    verifier = newVerifier(pluginDir.getAbsolutePath(), "remote");
    verifier.setLogFileName("log-cli.txt");
    verifier.executeGoal("install");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    verifier = newVerifier(projectDir.getAbsolutePath());
    verifier.setLogFileName("log-cli.txt");

    verifier.getCliOptions().add("-Dtest.verification=cli");
    verifier.getCliOptions().add("-Dtest.usingCliValue=true");
    verifier.getCliOptions().add("-Djava.version=cli");

    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();
  }
  /**
   * Verify that dependency resolution prefers newer local snapshots over outdated remote snapshots
   * that use the new metadata format.
   */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4955");

    Verifier verifier = newVerifier(new File(testDir, "dep").getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.deleteArtifacts("org.apache.maven.its.mng4955");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.addCliOption("-s");
    verifier.addCliOption("settings.xml");
    verifier.filterFile(
        "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    List<String> classpath = verifier.loadLines("target/classpath.txt", "UTF-8");

    File jarFile = new File(classpath.get(1).toString());
    assertEquals("eeff09b1b80e823eeb2a615b1d4b09e003e86fd3", ItUtils.calcHash(jarFile, "SHA-1"));
  }
  /**
   * Verify that overriding a transitive compile time dependency as provided in a WAR ensures it is
   * not included.
   */
  public void testitMNG1233() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-1233");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.deleteArtifacts("org.apache.maven.its.it0083");
    verifier.filterFile(
        "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
    verifier.addCliOption("--settings");
    verifier.addCliOption("settings.xml");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Collection<String> compileArtifacts = verifier.loadLines("target/compile.txt", "UTF-8");
    assertTrue(
        compileArtifacts.toString(),
        compileArtifacts.contains("org.apache.maven.its.it0083:direct-dep:jar:0.1"));
    assertTrue(
        compileArtifacts.toString(),
        compileArtifacts.contains("org.apache.maven.its.it0083:trans-dep:jar:0.1"));

    Collection<String> runtimeArtifacts = verifier.loadLines("target/runtime.txt", "UTF-8");
    assertTrue(
        runtimeArtifacts.toString(),
        runtimeArtifacts.contains("org.apache.maven.its.it0083:direct-dep:jar:0.1"));
    assertFalse(
        runtimeArtifacts.toString(),
        runtimeArtifacts.contains("org.apache.maven.its.it0083:trans-dep:jar:0.1"));
  }
  /** Test support of "@requiresDependencyResolution compile+runtime". */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4293");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.deleteArtifacts("org.apache.maven.its.mng4293");
    Properties filterProps = verifier.newDefaultFilterProperties();
    verifier.filterFile("pom-template.xml", "pom.xml", "UTF-8", filterProps);
    verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", filterProps);
    verifier.getCliOptions().add("--settings");
    verifier.getCliOptions().add("settings.xml");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    List compileClassPath = verifier.loadLines("target/compile-cp.txt", "UTF-8");
    assertTrue(compileClassPath.toString(), compileClassPath.contains("system-0.1.jar"));
    assertTrue(compileClassPath.toString(), compileClassPath.contains("provided-0.1.jar"));
    assertTrue(compileClassPath.toString(), compileClassPath.contains("compile-0.1.jar"));
    assertFalse(compileClassPath.toString(), compileClassPath.contains("test-0.1.jar"));

    List runtimeClassPath = verifier.loadLines("target/runtime-cp.txt", "UTF-8");
    assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("compile-0.1.jar"));
    assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("runtime-0.1.jar"));
    assertFalse(runtimeClassPath.toString(), runtimeClassPath.contains("test-0.1.jar"));
  }
  /**
   * Test that POM interpolation uses the property values from the dominant profile source (POM vs.
   * profiles.xml vs. settings.xml). This boils down to the proper order of profile injection and
   * interpolation, i.e. interpolate after profiles from all sources are injected.
   */
  public void testitMNG4107() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4107");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.addCliOption("--settings");
    verifier.addCliOption("settings.xml");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Properties props = verifier.loadProperties("target/pom.properties");

    assertEquals("applied", props.getProperty("project.properties.pomProfile"));
    assertEquals("applied", props.getProperty("project.properties.settingsProfile"));
    assertEquals("settings", props.getProperty("project.properties.pomVsSettings"));
    assertEquals("settings", props.getProperty("project.properties.pomVsSettingsInterpolated"));

    if (matchesVersionRange("(,3.0-alpha-1)")) {
      // MNG-4060, profiles.xml support dropped
      assertEquals("applied", props.getProperty("project.properties.profilesProfile"));
      assertEquals("profiles", props.getProperty("project.properties.pomVsProfiles"));
      assertEquals("profiles", props.getProperty("project.properties.pomVsProfilesInterpolated"));
      assertEquals("settings", props.getProperty("project.properties.profilesVsSettings"));
      assertEquals(
          "settings", props.getProperty("project.properties.profilesVsSettingsInterpolated"));
    }
  }
  /**
   * Verify that a project-level plugin dependency class/resource can be loaded from both the plugin
   * classloader and the context classloader available to the plugin.
   */
  public void testit0087() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/it0087");
    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.deleteArtifacts("org.apache.maven.its.it0087");
    verifier.filterFile(
        "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
    verifier.addCliOption("--settings");
    verifier.addCliOption("settings.xml");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Properties pclProps = verifier.loadProperties("target/pcl.properties");
    assertNotNull(pclProps.getProperty("org.apache.maven.plugin.coreit.ClassA"));
    assertNotNull(pclProps.getProperty("org.apache.maven.plugin.coreit.ClassB"));
    assertNotNull(pclProps.getProperty("org.apache.maven.its.it0087.IT0087"));
    assertNotNull(pclProps.getProperty("src/main/java/org/apache/maven/its/it0087/IT0087.java"));
    assertEquals(
        "1", pclProps.getProperty("src/main/java/org/apache/maven/its/it0087/IT0087.java.count"));

    Properties tcclProps = verifier.loadProperties("target/tccl.properties");
    assertEquals(pclProps, tcclProps);
  }
  /** Test that the CLI parameter -l can be used to direct logging to a file. */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-3183");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.addCliOption("-l");
    verifier.addCliOption("maven.log");
    verifier.setLogFileName("stdout.txt");
    new File(testDir, "stdout.txt").delete();
    new File(testDir, "maven.log").delete();
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    List<String> stdout = verifier.loadLines("stdout.txt", "UTF-8");

    for (Iterator<String> it = stdout.iterator(); it.hasNext(); ) {
      String line = it.next();
      if (line.startsWith("+") || line.startsWith("EMMA")) {
        it.remove();
      }
    }

    assertEquals(Collections.EMPTY_LIST, stdout);

    List<String> log = verifier.loadLines("maven.log", "UTF-8");

    assertFalse(log.isEmpty());
  }
コード例 #8
0
  public void run() {
    status = "started";
    File mavenProject = getTestFile("pom.xml").getParentFile();

    System.setProperty("maven.home", TestProperties.getString("maven.instance"));
    Verifier verifier;
    try {
      verifier = new Verifier(mavenProject.getAbsolutePath(), false);
      status = "verifierCreated";
    } catch (VerificationException e) {
      status = "failCreation" + e.getMessage();
      return;
    }

    File mavenRepository = new File(TestProperties.getString("maven.local.repo"));
    verifier.setLocalRepo(mavenRepository.getAbsolutePath());

    verifier.resetStreams();

    List<String> options = new ArrayList<String>();
    options.add("-X");
    options.add("-Dmaven.repo.local=" + mavenRepository.getAbsolutePath());
    options.add("-s " + getOverridableFile("settings.xml"));
    verifier.setCliOptions(options);

    status = "pre-execute";
    try {
      verifier.executeGoal("dependency:resolve");
      status = "executed";
    } catch (VerificationException e) {
      status = "failExecute" + e.getMessage();
    }
  }
  public void testitSameValueAcrossModules() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-2562/reactor");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.deleteDirectory("child-1/target");
    verifier.deleteDirectory("child-2/target");
    verifier.deleteDirectory("child-3/target");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Properties props = verifier.loadProperties("target/pom.properties");
    String timestamp = props.getProperty("project.properties.timestamp", "");

    Properties props1 = verifier.loadProperties("child-1/target/pom.properties");
    String timestamp1 = props1.getProperty("project.properties.timestamp", "");

    Properties props2 = verifier.loadProperties("child-2/target/pom.properties");
    String timestamp2 = props2.getProperty("project.properties.timestamp", "");

    Properties props3 = verifier.loadProperties("child-3/target/pom.properties");
    String timestamp3 = props3.getProperty("project.properties.timestamp", "");

    assertEquals(timestamp, timestamp1);
    assertEquals(timestamp, timestamp2);
    assertEquals(timestamp, timestamp3);
  }
コード例 #10
0
  /**
   * Creates a Verifier against passed in {@link MavenDeployment}.
   *
   * @param mavenDeployment
   * @return
   * @throws VerificationException
   * @throws IOException
   */
  public Verifier createMavenVerifier(final MavenDeployment mavenDeployment)
      throws VerificationException, IOException {
    System.setProperty("maven.home", mavenDeployment.getMavenHomeFile().getAbsolutePath());
    Verifier verifier =
        new Verifier(mavenDeployment.getMavenProjectFile().getAbsolutePath()) {
          @Override
          public void executeGoals(List<String> goals, Map envVars) throws VerificationException {
            try {
              super.executeGoals(goals, envVars);
            } catch (VerificationException e) {
              // HACK: Strip out the entire log which is included in the message by default! :-(
              File logFile = new File(getBasedir(), getLogFileName());
              throw new VerificationException(
                  "Goals execution failed: "
                      + goals
                      + "; see log for more details: "
                      + logFile.getAbsolutePath(),
                  e.getCause());
            }
          }
        };
    verifier.setLogFileName(mavenDeployment.getLogFileName());
    verifier.setLocalRepo(mavenDeployment.getLocalRepositoryFile().getAbsolutePath());
    verifier.resetStreams();

    List<String> options = new ArrayList<String>();
    options.add("-X");
    options.add("-Dmaven.repo.local=" + mavenDeployment.getLocalRepositoryFile().getAbsolutePath());
    options.add("-s " + mavenDeployment.getSettingsXmlFile().getAbsolutePath());
    verifier.setCliOptions(options);
    return verifier;
  }
コード例 #11
0
  private void doExecute(ProcessorTestCase child, Description description) throws Exception {
    File destination = extractTest(child, description);
    PrintStream originalOut = System.out;

    final Verifier verifier;
    if (Boolean.getBoolean(SYS_PROP_DEBUG)) {
      if (child.processor.getToolchain() == null) {
        // when not using toolchains for a test, then the compiler is executed within the Maven JVM.
        // So make
        // sure we fork a new JVM for that, and let that new JVM use the command 'mvnDebug' instead
        // of 'mvn'
        verifier = new Verifier(destination.getCanonicalPath(), null, true, true);
        verifier.setDebugJvm(true);
      } else {
        verifier = new Verifier(destination.getCanonicalPath());
        verifier.addCliOption("-Pdebug-forked-javac");
      }
    } else {
      verifier = new Verifier(destination.getCanonicalPath());
    }

    List<String> goals = new ArrayList<String>(3);

    goals.add("clean");

    try {
      configureToolchains(child, verifier, goals, originalOut);
      configureProcessor(child, verifier);

      verifier.addCliOption(
          "-Dcompiler-source-target-version=" + child.processor.getSourceTargetVersion());

      if ("1.8".equals(child.processor.getSourceTargetVersion())
          || "1.9".equals(child.processor.getSourceTargetVersion())) {
        verifier.addCliOption("-Dmapstruct-artifact-id=mapstruct-jdk8");
      } else {
        verifier.addCliOption("-Dmapstruct-artifact-id=mapstruct");
      }

      if (Boolean.getBoolean(SYS_PROP_DEBUG)) {
        originalOut.print("Processor Integration Test: ");
        originalOut.println("Listening for transport dt_socket at address: 8000 (in some seconds)");
      }

      goals.add("test");

      addAdditionalCliArguments(child, verifier);

      originalOut.println("executing " + child.processor.name().toLowerCase());

      verifier.executeGoals(goals);
      verifier.verifyErrorFreeLog();
    } finally {
      verifier.resetStreams();
    }
  }
 /** Test that snapshot repositories are checked for ranges with snapshot boundaries. */
 public void testit() throws Exception {
   File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-2994");
   Verifier verifier = newVerifier(testDir.getAbsolutePath());
   verifier.deleteArtifacts("org.apache.maven.its.mng2994");
   verifier.filterFile(
       "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
   verifier.getCliOptions().add("--settings");
   verifier.getCliOptions().add("settings.xml");
   verifier.executeGoal("validate");
   verifier.verifyErrorFreeLog();
   verifier.resetStreams();
 }
  /**
   * Tests that the DeleteSolrCoreMojo deletes the desired Solr core.
   *
   * @throws Exception If the test fails as a result of an exception
   */
  @Test
  public void testDeleteSolrCoreMojo() throws Exception {
    Verifier verifier = getVerifier("mojo-tests-project");
    Properties properties = verifier.getSystemProperties();

    properties.put("solr.core.name", GENERATED_CORE);

    verifier.displayStreamBuffers();
    verifier.executeGoal("info.freelibrary:solr-jetty-maven:delete-core");
    verifier.resetStreams();
    verifier.verifyErrorFreeLog();
    verifier.assertFileNotPresent(GENERATED_SCHEMA);
  }
  /**
   * Verify that default plugin executions contributed by the packaging are executed before
   * user-defined executions from the POM's build section, regardless whether the executions are
   * defined in the regular plugins section or the plugin management section.
   */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4332");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.executeGoal("process-resources");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    List<String> lines = verifier.loadLines("target/resources-resources.txt", "UTF-8");
    assertEquals(Arrays.asList(new String[] {"default", "test-1", "test-2"}), lines);
  }
  /**
   * Verify that aggregator-only projects (i.e. not used as parent for inheritance) get built after
   * their modules.
   */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4618");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    List mods = verifier.loadLines("target/log.txt", "UTF-8");
    assertEquals(Arrays.asList(new String[] {"mod-a", "mod-b", "mod-c", "aggregator"}), mods);
  }
  /** Verify that active collections of core components are properly injected into plugins. */
  public void testitMNG3422() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-3422");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Properties props = verifier.loadProperties("target/layout.properties");
    assertFalse("0".equals(props.getProperty("layouts", "0")));
    assertFalse("".equals(props.getProperty("layouts.default", "")));
  }
  public void testitMNG3485() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-3485");

    Verifier verifier;

    verifier = newVerifier(testDir.getAbsolutePath(), "remote");

    verifier.executeGoal("deploy");

    verifier.assertFilePresent("target/wagon.properties");
    verifier.verifyErrorFreeLog();

    verifier.resetStreams();
  }
  /**
   * Test that wagon providers pulled in via transitive dependencies of Maven core artifacts get
   * excluded from plugin realms (in favor of potentially newer wagons bundled with the core). This
   * requirement is mostly a hack to compensate for the historic slip of Maven core artifacts
   * depending on wagon providers. Those old wagon providers conflict with the usually newer wagons
   * bundled with the core distro and cause grief under a class loader hierarchy where wagons are
   * loaded from the plugin realm (if available) like in Maven 3.
   */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4528");

    Verifier verifier = newVerifier(testDir.getAbsolutePath(), "remote");
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Properties props = verifier.loadProperties("target/wagon.properties");
    String version = props.getProperty("version", "");
    assertFalse("Bad wagon version used: " + version, version.equals("1.0-alpha-6"));
  }
  /** Test that exclusions defined on a dependency apply to its transitive dependencies as well. */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4208");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.addCliOption("-DtestProperty=PASSED");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Properties props = verifier.loadProperties("target/pom.properties");
    assertEquals("PASSED", props.getProperty("project.properties.interpolatedProperty"));
  }
  /**
   * Verify that a dependency's optional flag is not subject to dependency management. This part of
   * the test checks the effective model.
   */
  public void testitModel() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4600/model");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Properties props = verifier.loadProperties("target/pom.properties");
    assertEquals("dep", props.getProperty("project.dependencies.0.artifactId"));
    assertEquals("false", props.getProperty("project.dependencies.0.optional"));
  }
  /**
   * Tests that the CreateSolrCoreMojo creates the desired Solr core.
   *
   * @throws Exception If the test fails as a result of an exception
   */
  @Test
  public void testCreateSolrCoreMojo() throws Exception {
    Verifier verifier = getVerifier("mojo-tests-project");
    Properties properties = verifier.getSystemProperties();
    List<String> goals =
        Arrays.asList(
            new String[] {"resources:resources", "info.freelibrary:solr-jetty-maven:create-core"});

    properties.put("solr.core.name", GENERATED_CORE);

    verifier.displayStreamBuffers();
    verifier.executeGoals(goals);
    verifier.resetStreams();
    verifier.verifyErrorFreeLog();
    verifier.assertFilePresent(GENERATED_SCHEMA);
  }
  /**
   * Test that plugin executions are properly merged during inheritance, even if the child plugin
   * section has no version.
   */
  public void testitMNG3916() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-3916");

    Verifier verifier = newVerifier(new File(testDir, "sub").getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    List<String> executions = verifier.loadLines("target/exec.log", "UTF-8");
    // NOTE: Ordering of executions is another issue (MNG-3887), so ignore/normalize order
    Collections.sort(executions);
    List<String> expected = Arrays.asList(new String[] {"child-1", "child-default", "parent-1"});
    assertEquals(expected, executions);
  }
  /** Tests context passing between mojos in the same plugin. */
  public void testitMNG0823() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-0823");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    List<String> goals =
        Arrays.asList(
            new String[] {
              "org.apache.maven.its.plugins:maven-it-plugin-context-passing:throw",
              "org.apache.maven.its.plugins:maven-it-plugin-context-passing:catch"
            });
    verifier.executeGoals(goals);
    verifier.assertFilePresent("target/thrown-value");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();
  }
  /**
   * Test that unreadable metadata from one repository does not fail the entire dependency
   * resolution.
   */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4498");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.deleteArtifacts("org.apache.maven.its.mng4498");
    verifier.filterFile(
        "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
    verifier.addCliOption("--settings");
    verifier.addCliOption("settings.xml");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    List<String> classpath = verifier.loadLines("target/classpath.txt", "UTF-8");
    assertTrue(classpath.toString(), classpath.contains("dep-0.1-SNAPSHOT.jar"));
  }
  public void testitCustomFormat() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-2562/custom");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Date now = new Date();

    Properties props = verifier.loadProperties("target/pom.properties");

    String timestamp1 = props.getProperty("project.properties.timestamp", "");
    Date date = new SimpleDateFormat("mm:HH dd-MM-yyyy").parse(timestamp1);
    assertTrue(now + " vs " + date, Math.abs(now.getTime() - date.getTime()) < 24 * 60 * 60 * 1000);
  }
  /**
   * Verify that the implicit default repo (central) is tried after explicitly declared repos during
   * parent POM resolution.
   */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4401");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.deleteArtifacts("org.apache.maven.its.mng4401");
    verifier.filterFile(
        "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
    verifier.getCliOptions().add("-s");
    verifier.getCliOptions().add("settings.xml");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    verifier.assertFilePresent("target/passed.txt");
    verifier.assertFileNotPresent("target/failed.txt");
  }
  /**
   * Verify that repositories which have both releases and snapshots disabled aren't touched when
   * looking for plugin prefix mappings.
   */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4771");

    final List<String> requestedUris = Collections.synchronizedList(new ArrayList<String>());

    AbstractHandler logHandler =
        new AbstractHandler() {
          public void handle(
              String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
              throws IOException, ServletException {
            requestedUris.add(request.getRequestURI());
          }
        };

    HandlerList handlerList = new HandlerList();
    handlerList.addHandler(logHandler);
    handlerList.addHandler(new DefaultHandler());

    Server server = new Server(0);
    server.setHandler(handlerList);
    server.start();

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    try {
      verifier.setAutoclean(false);
      verifier.deleteDirectory("target");
      Properties filterProps = verifier.newDefaultFilterProperties();
      filterProps.setProperty("@port@", Integer.toString(server.getConnectors()[0].getLocalPort()));
      verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", filterProps);
      verifier.addCliOption("-U");
      verifier.addCliOption("-s");
      verifier.addCliOption("settings.xml");
      verifier.executeGoal("mng4771:touch");
      verifier.verifyErrorFreeLog();
      fail("Build should have failed to resolve unknown prefix");
    } catch (VerificationException e) {
      assertTrue(true);
    } finally {
      verifier.resetStreams();
      server.stop();
    }

    assertTrue(requestedUris.toString(), requestedUris.isEmpty());
  }
  /** Tests that hex digits of checksums are compared without regard to case. */
  public void testitMNG2744() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-2744");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteArtifacts("org.apache.maven.its.mng2744");
    verifier.filterFile(
        "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
    verifier.addCliOption("--settings");
    verifier.addCliOption("settings.xml");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    verifier.assertArtifactPresent("org.apache.maven.its.mng2744", "a", "1", "jar");
    verifier.assertArtifactPresent("org.apache.maven.its.mng2744", "a", "1", "pom");
    verifier.assertArtifactPresent("org.apache.maven.its.mng2744", "b", "1", "jar");
    verifier.assertArtifactPresent("org.apache.maven.its.mng2744", "b", "1", "pom");
  }
  /**
   * Verify that plugin dependencies defined by plugin management of a parent profile are not lost
   * when the parent's main plugin management section is also present.
   */
  public void testitMNG2174() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-2174");

    Verifier verifier = newVerifier(new File(testDir, "sub").getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.deleteArtifacts("org.apache.maven.its.mng2174");
    verifier.filterFile(
        "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
    verifier.addCliOption("--settings");
    verifier.addCliOption("settings.xml");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    Properties props = verifier.loadProperties("target/pcl.properties");
    assertEquals("1", props.getProperty("mng-2174.properties.count"));
    assertNotNull(props.getProperty("mng-2174.properties"));
  }
  /**
   * Verify that dependency resolution by an aggregator before the build has actually produced any
   * artifacts doesn't prevent later resolution of project artifacts from the reactor if the
   * aggregator originally resolved them from the remote repo.
   */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4814");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("consumer/target");
    verifier.deleteArtifacts("org.apache.maven.its.mng4814");
    verifier.addCliOption("-s");
    verifier.addCliOption("settings.xml");
    verifier.filterFile(
        "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties());
    List<String> goals = new ArrayList<String>();
    goals.add(
        "org.apache.maven.its.plugins:maven-it-plugin-dependency-resolution:2.1-SNAPSHOT:aggregate-test");
    goals.add("validate");
    verifier.executeGoals(goals);
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    List<String> compile = verifier.loadLines("consumer/target/compile.txt", "UTF-8");

    assertFalse(compile.toString(), compile.contains("0.1-SNAPSHOT/producer-0.1-SNAPSHOT.jar"));
    assertTrue(compile.toString(), compile.contains("producer/pom.xml"));
  }