@Test
 public void requireBundle() throws Exception {
   Verifier verifier = getVerifier("/compiler.optionalDependencies/require-bundle", false);
   verifier.getCliOptions().add("-De342-repo=" + P2Repositories.ECLIPSE_342.toString());
   verifier.executeGoals(Arrays.asList("clean", "verify"));
   verifier.verifyErrorFreeLog();
 }
 @Test
 public void test() throws Exception {
   Verifier verifier = getVerifier("/363331_extraTargetPlatformRequirements", false);
   verifier.getCliOptions().add("-De342-repo=" + P2Repositories.ECLIPSE_342.toString());
   verifier.getCliOptions().add("-De352-repo=" + P2Repositories.ECLIPSE_352.toString());
   verifier.executeGoals(Arrays.asList("clean", "install"));
   verifier.verifyErrorFreeLog();
 }
  @Test
  public void testBaselineRepositoryDoesNotExist() throws Exception {
    // likely initial state is when baseline repository url points at empty or garbage location
    File notARepository = new File("baseline/src").getCanonicalFile();
    Verifier verifier = getVerifier("baseline/src", notARepository);

    verifier.executeGoals(Arrays.asList("clean", "package"));
    verifier.verifyErrorFreeLog();
  }
  @Test
  public void testBaselineDisable() throws Exception {
    Verifier verifier = getVerifier("contentchanged", baselineRepo);

    verifier.getCliOptions().add("-Dtycho.baseline=disable");

    verifier.executeGoals(Arrays.asList("clean", "package"));
    verifier.verifyErrorFreeLog();
  }
  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
  public void testBaselineWarn() throws Exception {
    Verifier verifier = getVerifier("contentchanged", baselineRepo);

    verifier.getCliOptions().add("-Dtycho.baseline=warn");

    verifier.executeGoals(Arrays.asList("clean", "package"));
    verifier.verifyTextInLog(
        "baseline and build artifacts have same version but different contents");
  }
  @Test
  public void testBaselineFailCommon_newAttachedArtifact() throws Exception {
    Verifier verifier = getVerifier("newattachedartifact", baselineRepo);

    verifier.getCliOptions().add("-Dtycho.baseline=failCommon");

    verifier.executeGoals(Arrays.asList("clean", "package"));

    verifier.verifyTextInLog(
        "baseline and build artifacts have same version but different contents");
  }
  @Test
  public void testContentChangedStrict() throws Exception {
    Verifier verifier = getVerifier("contentchanged", baselineRepo);

    try {
      verifier.executeGoals(Arrays.asList("clean", "package"));
    } catch (VerificationException expected) {
      //
    }
    verifier.verifyTextInLog(
        "baseline and build artifacts have same version but different contents");
  }
  @Test
  public void testRepository() throws Exception {
    String url = server.addServer("foo", new File("repositories/e342"));

    Verifier verifier =
        getVerifier(
            "/TYCHO319passwordProtectedP2Repository",
            false,
            new File("projects/TYCHO319passwordProtectedP2Repository/settings.xml"));
    verifier.getCliOptions().add("-P=repository");
    verifier.executeGoals(Arrays.asList("package", "-Dp2.repo=" + url));
    verifier.verifyErrorFreeLog();
  }
  @Test
  public void testRebuildOfTheSameCodebase() throws Exception {
    Verifier verifier = getVerifier("baseline/src", baselineRepo);

    verifier.executeGoals(Arrays.asList("clean", "package"));
    verifier.verifyErrorFreeLog();

    File repository = new File(verifier.getBasedir(), "repository/target/repository");

    assertBaselineContents(repository, "features/baseline.feature01_1.0.0.1.jar");
    assertBaselineContents(repository, "plugins/baseline.bundle01_1.0.0.1.jar");
    assertBaselineContents(repository, "plugins/baseline.bundle01.source_1.0.0.1.jar");
  }
  @Test
  public void testBaselineWarn_changedAttachedArtifact() throws Exception {
    Verifier verifier = getVerifier("changedattachedartifact", baselineRepo);

    verifier.getCliOptions().add("-Dtycho.baseline=warn");

    verifier.executeGoals(Arrays.asList("clean", "package"));
    verifier.verifyTextInLog(
        "baseline and build artifacts have same version but different contents");

    File repository = new File(verifier.getBasedir(), "repository/target/repository");
    assertBaselineContents(repository, "plugins/baseline.bundle01.source_1.0.0.1.jar");
  }
  @Test
  public void testBaselineFail_changedAttachedArtifact() throws Exception {
    Verifier verifier = getVerifier("changedattachedartifact", baselineRepo);

    verifier.getCliOptions().add("-Dtycho.baseline=fail");

    try {
      verifier.executeGoals(Arrays.asList("clean", "package"));
    } catch (VerificationException expected) {
      //
    }
    verifier.verifyTextInLog(
        "baseline and build artifacts have same version but different contents");
  }
  /**
   * 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);
  }
  /** 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
  public void testNewVersion() throws Exception {
    Verifier verifier = getVerifier("baseline/src", baselineRepo);
    verifier.getCliOptions().add("-DversionQualifier=2");

    verifier.executeGoals(Arrays.asList("clean", "package"));
    verifier.verifyErrorFreeLog();

    File repository = new File(verifier.getBasedir(), "repository/target/repository");

    assertFileDoesNotExist(repository, "features/baseline.feature01_1.0.0.1.jar");
    assertFileDoesNotExist(repository, "plugins/baseline.bundle01_1.0.0.1.jar");
    assertFileDoesNotExist(repository, "plugins/baseline.bundle01.source_1.0.0.1.jar");

    assertFileExists(repository, "features/baseline.feature01_1.0.0.2.jar");
    assertFileExists(repository, "plugins/baseline.bundle01_1.0.0.2.jar");
    assertFileExists(repository, "plugins/baseline.bundle01.source_1.0.0.2.jar");
  }
  @Test
  public void testReplaceCommon() throws Exception {
    Verifier verifier = getVerifier("newattachedartifact", baselineRepo);

    verifier.getCliOptions().add("-Dtycho.baseline=warn");
    verifier.getCliOptions().add("-Dtycho.baseline.replace=common");

    verifier.executeGoals(Arrays.asList("clean", "package"));
    verifier.verifyTextInLog(
        "baseline and build artifacts have same version but different contents");

    File repository = new File(verifier.getBasedir(), "repository/target/repository");
    assertBaselineContents(repository, "features/baseline.feature02_1.0.0.1.jar");

    File basedir = new File(verifier.getBasedir());
    assertFileExists(basedir, "feature02/target/baseline.feature02_root-1.0.0.1-root.zip");
    assertFileDoesNotExist(
        basedir, "repository/target/repository/binary/baseline.feature02_root_1.0.0.1");
  }
  @Test
  public void testTargetDefinition() throws Exception {
    String url = server.addServer("foo", new File("repositories/e342"));

    Verifier verifier =
        getVerifier(
            "/TYCHO319passwordProtectedP2Repository",
            false,
            new File("projects/TYCHO319passwordProtectedP2Repository/settings.xml"));

    File platformFile = new File(verifier.getBasedir(), "platform.target");
    Target platform = Target.read(platformFile);
    platform.getLocations().get(0).setRepositoryLocation(url);
    Target.write(platform, platformFile);

    verifier.getCliOptions().add("-P=target-definition");
    verifier.executeGoals(Arrays.asList("package", "-Dp2.repo=" + url));
    verifier.verifyErrorFreeLog();
  }
  /**
   * 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"));
  }
 @Test
 public void requireBundleIgnore() throws Exception {
   Verifier verifier = getVerifier("/compiler.optionalDependencies/require-bundle-ignore", false);
   verifier.executeGoals(Arrays.asList("clean", "verify"));
   verifier.verifyErrorFreeLog();
 }