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();
  }
 private Verifier getVerifier(String project, File baselineRepo) throws Exception {
   Verifier verifier = getVerifier("/packaging.reproducibleArtifacts/" + project, false);
   verifier
       .getCliOptions()
       .add("-De342-repo=" + ResourceUtil.P2Repositories.ECLIPSE_342.toString());
   verifier.getCliOptions().add("-Dbaseline-repo=" + baselineRepo.toURI().toString());
   return verifier;
 }
 @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 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
 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 testBaselineDisable() throws Exception {
    Verifier verifier = getVerifier("contentchanged", baselineRepo);

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

    verifier.executeGoals(Arrays.asList("clean", "package"));
    verifier.verifyErrorFreeLog();
  }
  /**
   * 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 requestedUris = Collections.synchronizedList(new ArrayList());

    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.getCliOptions().add("-U");
      verifier.getCliOptions().add("-s");
      verifier.getCliOptions().add("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());
  }
  @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");
  }
  /**
   * Checks the quick-start archetype with the emulator parameter.
   *
   * @throws IOException a file cannot be read
   * @throws VerificationException the maven launch failed
   */
  @Test
  public void testQuickStartWithEmulator() throws VerificationException, IOException {

    File root = Helper.prepareDirectory("quickstart-default");

    Verifier verifier = new Verifier(root.getAbsolutePath(), false);
    verifier.setAutoclean(false);

    verifier.displayStreamBuffers();

    @SuppressWarnings("unchecked")
    List<String> cli = verifier.getCliOptions();
    cli.add("-DarchetypeArtifactId=android-quickstart");
    cli.add("-DarchetypeGroupId=de.akquinet.android.archetypes");
    cli.add("-DarchetypeVersion=" + System.getProperty("archetype.version"));
    cli.add("-DgroupId=" + Constants.TEST_GROUP_ID);
    cli.add("-DartifactId=" + Constants.TEST_ARTIFACT_ID);
    cli.add("-DinteractiveMode=false");
    cli.add("-DarchetypeCatalog=local");
    cli.add("-DarchetypeRepository=local");
    cli.add("-Demulator=test");
    cli.add("-Dandroid-plugin-version=3.0.0-alpha-2");
    verifier.executeGoal("org.apache.maven.plugins:maven-archetype-plugin:2.0:generate");

    // Check folder create.
    verifier.assertFilePresent("android-test");
    verifier.assertFilePresent("android-test/AndroidManifest.xml");
    verifier.assertFilePresent("android-test/pom.xml");
    verifier.assertFilePresent("android-test/res/values/strings.xml");
    verifier.assertFilePresent("android-test/res/layout/main.xml");
    verifier.assertFilePresent("android-test/assets");
    verifier.assertFilePresent(
        "android-test/src/main/java/android/archetypes/test/HelloAndroidActivity.java");

    Helper.assertContains(
        new File("target/it/quickstart-default/android-test/pom.xml"),
        "<artifactId>maven-android-plugin</artifactId>");
    Helper.assertContains(
        new File("target/it/quickstart-default/android-test/pom.xml"), "<platform>7</platform>");
    Helper.assertContains(
        new File("target/it/quickstart-default/android-test/AndroidManifest.xml"),
        "<activity android:name=\".HelloAndroidActivity\">");
    Helper.assertContains(
        new File("target/it/quickstart-default/android-test/AndroidManifest.xml"),
        "package=\"android.archetypes.test\"");

    // Check that the Eclipse file is created (default.properties)
    Helper.assertContains(
        new File("target/it/quickstart-default/android-test/default.properties"),
        "target=android-7");

    // Check the emulator part
    Helper.assertContains(
        new File("target/it/quickstart-default/android-test/pom.xml"), "<avd>test</avd>");
  }
  @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");
  }
  @SuppressWarnings("unchecked")
  protected Verifier getVerifier(String test, boolean setTargetPlatform, File userSettings)
      throws Exception {
    /*
    Test JVM can be started in debug mode by passing the following
    env to execute(...) methods.

          java.util.Map<String, String> env = new java.util.HashMap<String, String>();
          env.put("MAVEN_OPTS", "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000");
     */

    // oddly enough, Verifier uses this system property to locate maven install
    System.setProperty("maven.home", getMavenHome());

    File testDir = getBasedir(test);

    Verifier verifier = new Verifier(testDir.getAbsolutePath());
    verifier.getCliOptions().add("-Dmaven.home=" + getMavenHome());
    verifier.getCliOptions().add("-Dtycho-version=" + getTychoVersion());
    if (setTargetPlatform) {
      verifier.getCliOptions().add("-Dtycho.targetPlatform=" + getTargetPlatforn());
    }
    verifier.getCliOptions().add("-X");
    verifier.getCliOptions().add("-s " + userSettings.getCanonicalPath());
    verifier.getVerifierProperties().put("use.mavenRepoLocal", "true");
    verifier.setLocalRepo(EnvironmentUtil.getLocalRepo());

    String customOptions = System.getProperty("it.cliOptions");
    if (customOptions != null && customOptions.trim().length() > 0) {
      verifier.getCliOptions().add(customOptions);
    }

    String m2eState = System.getProperty("m2eclipse.workspace.state");
    String m2eResolver = System.getProperty("m2eclipse.workspace.resolver");

    if (m2eState != null && m2eResolver != null) {
      verifier.getVerifierProperties().put("m2eclipse.workspace.state", m2eState);
    }

    return verifier;
  }
 /** 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();
 }
  @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 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 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");
  }
  /**
   * Checks the quick-start archetype with the <tt>platform</tt> and <tt>package</tt> parameters.
   *
   * @throws VerificationException
   * @throws IOException
   */
  @Test
  public void testQuickStartWithPlatformAndPackage() throws VerificationException, IOException {

    File root = Helper.prepareDirectory("quickstart-with-platform-and-package");

    Verifier verifier = new Verifier(root.getAbsolutePath(), false);
    verifier.setAutoclean(false);

    verifier.displayStreamBuffers();

    @SuppressWarnings("unchecked")
    List<String> cli = verifier.getCliOptions();
    cli.add("-DarchetypeArtifactId=android-quickstart");
    cli.add("-DarchetypeGroupId=de.akquinet.android.archetypes");
    cli.add("-DarchetypeVersion=" + System.getProperty("archetype.version"));
    cli.add("-DgroupId=" + Constants.TEST_GROUP_ID);
    cli.add("-DartifactId=" + Constants.TEST_ARTIFACT_ID);
    cli.add("-DinteractiveMode=false");
    cli.add("-DarchetypeCatalog=local");
    cli.add("-DarchetypeRepository=local");
    cli.add("-Dplatform=4");
    cli.add("-Dpackage=foo");

    verifier.executeGoal("org.apache.maven.plugins:maven-archetype-plugin:2.0:generate");

    // Check folder create.
    verifier.assertFilePresent("android-test");
    verifier.assertFilePresent("android-test/AndroidManifest.xml");
    verifier.assertFilePresent("android-test/pom.xml");
    verifier.assertFilePresent("android-test/res/values/strings.xml");
    verifier.assertFilePresent("android-test/res/layout/main.xml");
    verifier.assertFilePresent("android-test/assets");
    verifier.assertFilePresent("android-test/src/main/java/foo/HelloAndroidActivity.java");

    Helper.assertContains(
        new File("target/it/quickstart-with-platform-and-package/android-test/pom.xml"),
        "<artifactId>maven-android-plugin</artifactId>");
    Helper.assertContains(
        new File("target/it/quickstart-with-platform-and-package/android-test/pom.xml"),
        "<platform>4</platform>");
    Helper.assertContains(
        new File("target/it/quickstart-with-platform-and-package/android-test/pom.xml"),
        "1.6_r2"); // Android lib version
    Helper.assertContains(
        new File("target/it/quickstart-with-platform-and-package/android-test/AndroidManifest.xml"),
        "<activity android:name=\".HelloAndroidActivity\">");
    Helper.assertContains(
        new File("target/it/quickstart-with-platform-and-package/android-test/AndroidManifest.xml"),
        "package=\"foo\"");
  }
  private void deployWithMavenExpectFailure(File mavenProject, String targetRepoId)
      throws VerificationException, IOException {
    // deploy using maven
    Verifier verifier = this.createVerifier(mavenProject);
    try {
      verifier
          .getCliOptions()
          .add("-DaltDeploymentRepository=repo::default::" + createUrl(targetRepoId));
      verifier.executeGoal("deploy");

      verifier.verifyErrorFreeLog();

      Assert.fail("Should return 401 error");
    } catch (VerificationException e) {
      // expect error
    }
  }
  /**
   * 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");
  }
  @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();
  }
  private void deployWithMavenExpectSuccess(File mavenProject, String targetRepoId)
      throws VerificationException, IOException {
    // deploy using maven
    Verifier verifier = this.createVerifier(mavenProject);
    try {
      verifier
          .getCliOptions()
          .add("-DaltDeploymentRepository=repo::default::" + createUrl(targetRepoId));
      verifier.executeGoal("deploy");
      verifier.verifyErrorFreeLog();
    } catch (VerificationException e) {
      File logs = new File(nexusLogDir);
      File bkp = new File("./target/logs/nexus2351-bkp");
      bkp.mkdirs();

      FileUtils.copyDirectory(logs, bkp);

      failTest(verifier);
    }
  }
Exemplo n.º 23
0
  /**
   * tests the goal "convert-phar"
   *
   * @throws Exception
   */
  public void testGoal() throws Exception {
    final Verifier verifierDep1 = this.getPhpMavenVerifier("mojos-phar/phar-with-dep1-folders");

    // delete the pom from previous runs
    verifierDep1.deleteArtifact("org.phpmaven.test", "phar-with-dep1-folders", "0.0.1", "pom");
    verifierDep1.deleteArtifact("org.phpmaven.test", "phar-with-dep1-folders", "0.0.1", "phar");

    // execute testing
    verifierDep1.executeGoal("package");

    // verify no error was thrown
    verifierDep1.verifyErrorFreeLog();

    // reset the streams
    verifierDep1.resetStreams();

    final File phar =
        new File(new File(verifierDep1.getBasedir()), "target/phar-with-dep1-folders-0.0.1.phar");
    assertTrue(phar.exists());

    verifierDep1.setAutoclean(false);

    // to zip
    verifierDep1.addCliOption("-Dfrom=" + phar.getAbsolutePath());
    verifierDep1.addCliOption(
        "-Dto=" + phar.getAbsolutePath().substring(0, phar.getAbsolutePath().length() - 4) + "zip");

    verifierDep1.executeGoal("org.phpmaven:maven-php-plugin:convert-phar");

    // verify no error was thrown
    verifierDep1.verifyErrorFreeLog();

    // reset the streams
    verifierDep1.resetStreams();

    verifierDep1.assertFilePresent("target/phar-with-dep1-folders-0.0.1.zip");

    // to jar
    verifierDep1.getCliOptions().clear();
    verifierDep1.addCliOption(
        "-Dfrom="
            + phar.getAbsolutePath().substring(0, phar.getAbsolutePath().length() - 4)
            + "zip");
    verifierDep1.addCliOption(
        "-Dto=" + phar.getAbsolutePath().substring(0, phar.getAbsolutePath().length() - 4) + "jar");

    verifierDep1.executeGoal("org.phpmaven:maven-php-plugin:convert-phar");

    // verify no error was thrown
    verifierDep1.verifyErrorFreeLog();

    // reset the streams
    verifierDep1.resetStreams();

    verifierDep1.assertFilePresent("target/phar-with-dep1-folders-0.0.1.jar");

    // to phar
    verifierDep1.getCliOptions().clear();
    verifierDep1.addCliOption(
        "-Dfrom="
            + phar.getAbsolutePath().substring(0, phar.getAbsolutePath().length() - 4)
            + "jar");
    verifierDep1.addCliOption(
        "-Dto="
            + phar.getAbsolutePath().substring(0, phar.getAbsolutePath().length() - 4)
            + "2.phar");

    verifierDep1.executeGoal("org.phpmaven:maven-php-plugin:convert-phar");

    // verify no error was thrown
    verifierDep1.verifyErrorFreeLog();

    // reset the streams
    verifierDep1.resetStreams();

    verifierDep1.assertFilePresent("target/phar-with-dep1-folders-0.0.1.2.phar");

    verifierDep1.getCliOptions().clear();
    verifierDep1.addCliOption("-Dphar=target/phar-with-dep1-folders-0.0.1.2.phar");
    verifierDep1.executeGoal("org.phpmaven:maven-php-plugin:list-phar-files");
    @SuppressWarnings("unchecked")
    final List<String> lines =
        verifierDep1.loadFile(verifierDep1.getBasedir(), verifierDep1.getLogFileName(), false);
    boolean found1 = false;
    boolean found2 = false;
    for (final String line : lines) {
      if (line.startsWith(
          "[INFO] " + File.separatorChar + "folderA" + File.separatorChar + "MyClassA.php")) {
        found1 = true;
      }
      if (line.startsWith(
          "[INFO] " + File.separatorChar + "folderB" + File.separatorChar + "MyClassB.php")) {
        found2 = true;
      }
    }

    // verify no error was thrown
    verifierDep1.verifyErrorFreeLog();

    // reset the streams
    verifierDep1.resetStreams();

    assertTrue(found1);
    assertTrue(found2);
  }
  /**
   * Checks the with-test archetype with the <tt>platform</tt> parameter bellow 7 for correct
   * constructor.
   *
   * @throws VerificationException
   * @throws IOException
   */
  @Test
  public void testWithTestConstructorCorrectness() throws VerificationException, IOException {

    File root = Helper.prepareDirectory("with-test-with-platform");

    Verifier verifier = new Verifier(root.getAbsolutePath(), false);
    verifier.setAutoclean(false);

    verifier.displayStreamBuffers();

    @SuppressWarnings("unchecked")
    List<String> cli = verifier.getCliOptions();
    cli.add("-DarchetypeArtifactId=android-with-test");
    cli.add("-DarchetypeGroupId=de.akquinet.android.archetypes");
    cli.add("-DarchetypeVersion=" + System.getProperty("archetype.version"));
    cli.add("-DgroupId=" + Constants.TEST_GROUP_ID);
    cli.add("-DartifactId=" + Constants.TEST_ARTIFACT_ID);
    cli.add("-DinteractiveMode=false");
    cli.add("-Dplatform=7");
    cli.add("-DarchetypeCatalog=local");
    cli.add("-DarchetypeRepository=local");

    verifier.executeGoal("org.apache.maven.plugins:maven-archetype-plugin:2.0:generate");

    // Check folder create.
    verifier.assertFilePresent("android-test/" + Constants.TEST_ARTIFACT_ID);
    verifier.assertFilePresent("android-test/" + Constants.TEST_ARTIFACT_ID + "-it");
    verifier.assertFilePresent(
        "android-test/" + Constants.TEST_ARTIFACT_ID + "/AndroidManifest.xml");
    verifier.assertFilePresent(
        "android-test/" + Constants.TEST_ARTIFACT_ID + "-it/AndroidManifest.xml");
    verifier.assertFilePresent("android-test/pom.xml");
    verifier.assertFilePresent("android-test/" + Constants.TEST_ARTIFACT_ID + "/pom.xml");
    verifier.assertFilePresent("android-test/" + Constants.TEST_ARTIFACT_ID + "-it/pom.xml");

    verifier.assertFilePresent(
        "android-test/" + Constants.TEST_ARTIFACT_ID + "/res/values/strings.xml");
    verifier.assertFilePresent(
        "android-test/" + Constants.TEST_ARTIFACT_ID + "/res/layout/main.xml");
    verifier.assertFilePresent("android-test/" + Constants.TEST_ARTIFACT_ID + "/assets");
    verifier.assertFilePresent(
        "android-test/"
            + Constants.TEST_ARTIFACT_ID
            + "/src/main/java/android/archetypes/test/HelloAndroidActivity.java");
    verifier.assertFilePresent(
        "android-test/"
            + Constants.TEST_ARTIFACT_ID
            + "-it/src/main/java/android/archetypes/test/test/HelloAndroidActivityTest.java");

    Helper.assertContains(
        new File(
            "target/it/with-test-with-platform/android-test/"
                + Constants.TEST_ARTIFACT_ID
                + "/pom.xml"),
        "<artifactId>android-maven-plugin</artifactId>");
    Helper.assertContains(
        new File(
            "target/it/with-test-with-platform/android-test/"
                + Constants.TEST_ARTIFACT_ID
                + "/pom.xml"),
        "<platform>7</platform>");
    Helper.assertContains(
        new File(
            "target/it/with-test-with-platform/android-test/"
                + Constants.TEST_ARTIFACT_ID
                + "/AndroidManifest.xml"),
        "<activity android:name=\".HelloAndroidActivity\">");
    Helper.assertContains(
        new File(
            "target/it/with-test-with-platform/android-test/"
                + Constants.TEST_ARTIFACT_ID
                + "/AndroidManifest.xml"),
        "package=\"android.archetypes.test\"");

    Helper.assertContains(
        new File(
            "target/it/with-test-with-platform/android-test/"
                + Constants.TEST_ARTIFACT_ID
                + "-it/pom.xml"),
        "<artifactId>android-maven-plugin</artifactId>");
    Helper.assertContains(
        new File(
            "target/it/with-test-with-platform/android-test/"
                + Constants.TEST_ARTIFACT_ID
                + "-it/pom.xml"),
        "<platform>7</platform>");
    Helper.assertContains(
        new File(
            "target/it/with-test-with-platform/android-test/"
                + Constants.TEST_ARTIFACT_ID
                + "-it/AndroidManifest.xml"),
        "<uses-library android:name=\"android.test.runner\" />");
    Helper.assertContains(
        new File(
            "target/it/with-test-with-platform/android-test/"
                + Constants.TEST_ARTIFACT_ID
                + "-it/AndroidManifest.xml"),
        "<instrumentation android:targetPackage=\"android.archetypes.test\"");

    Helper.assertContains(
        new File(
            "target/it/with-test-with-platform/android-test/"
                + Constants.TEST_ARTIFACT_ID
                + "-it/src/main/java/android/archetypes/test/test/HelloAndroidActivityTest.java"),
        "super(\"android.archetypes.test\", HelloAndroidActivity.class);");
  }