@Test(groups = SECURITY)
  public void deployRepeatly() throws Exception {
    File mavenProject1 = getTestFile("maven-project-1");

    File settings1 = getTestFile("settings1.xml");

    Verifier verifier1 = null;

    try {
      verifier1 = createVerifier(mavenProject1, settings1);

      verifier1.executeGoal("deploy");

      verifier1.verifyErrorFreeLog();
    } catch (VerificationException e) {
      failTest(verifier1);
    }

    try {
      verifier1.executeGoal("deploy");

      verifier1.verifyErrorFreeLog();

      Assert.fail("Should return 401 error");
    } catch (VerificationException e) {
      // 401 error
    }
  }
  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();
  }
  /**
   * tests the goal "package" after installing the archetype.
   *
   * @throws Exception
   */
  public void testPackage() throws Exception {
    final Verifier verifier = this.getPhpMavenVerifier("archetypes/doctrine");
    this.installArchetypes();

    verifier.addCliOption("-DarchetypeGroupId=org.phpmaven");
    verifier.addCliOption("-DarchetypeArtifactId=php5-doctrine-archetype");
    verifier.addCliOption("-DarchetypeVersion=2.0-SNAPSHOT");
    verifier.addCliOption("-DgroupId=org.sample");
    verifier.addCliOption("-DartifactId=my-app");
    verifier.addCliOption("-Dversion=0.0.1-SNAPSHOT");
    verifier.addCliOption("-DinteractiveMode=false");

    verifier.executeGoal("archetype:generate");
    verifier.verifyErrorFreeLog();

    verifier.assertFilePresent("my-app/pom.xml");
    verifier.assertFilePresent("my-app/src/main/php/MyApp/Entities/MyModel.php");
    verifier.assertFilePresent("my-app/src/main/php/bootstrap_doctrine.php");
    verifier.assertFilePresent("my-app/src/main/php/bootstrap.php");
    verifier.assertFilePresent("my-app/src/main/php/cli-config.php");
    verifier.assertFilePresent("my-app/src/main/php/cli-tools.php");
    verifier.assertFilePresent("my-app/src/main/php/my-app.php");
    verifier.assertFilePresent("my-app/src/main/resources/config/doctrine.ini");
    verifier.assertFilePresent("my-app/src/site/apt/index.apt");
    verifier.assertFilePresent("my-app/src/site/site.xml");

    final Verifier verifier2 = this.getVerifierWithoutPrepare("archetypes/doctrine");
    verifier2.executeGoal("package");
    verifier2.verifyErrorFreeLog();
    verifier2.assertFilePresent("my-app/target/my-app-0.0.1-SNAPSHOT.phar");
  }
  /**
   * 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"));
  }
  protected void testJspc(File testDir) throws VerificationException {
    Verifier verifier = new Verifier(testDir.getAbsolutePath());
    verifier.setLogFileName("verifier.log");

    //        verifier.setDebug(true);
    //        verifier.setMavenDebug(true);

    verifier.executeGoal("clean");
    verifier.executeGoal("package");

    verifier.verifyErrorFreeLog();

    verifier.assertFilePresent("target/jspweb.xml");
    verifier.assertFilePresent("target/classes/jsp/index_jsp.class");
  }
  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);
  }
  /**
   * 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"));
    }
  }
  @Test
  public void testPomlessBuildExtension() throws Exception {
    Verifier verifier = getVerifier("testsetversionpomless", false);
    String newVersion = "2.0.0";
    verifier.addCliOption("-DnewVersion=" + newVersion);
    verifier.executeGoal(
        "org.eclipse.tycho:tycho-versions-plugin:" + getTychoVersion() + ":set-version");
    verifier.verifyErrorFreeLog();
    File baseDir = new File(verifier.getBasedir());

    PomFile rootPom = PomFile.read(new File(baseDir, "pom.xml"), false);
    Assert.assertEquals(newVersion, rootPom.getVersion());

    DefaultBundleReader reader = new DefaultBundleReader();
    OsgiManifest bundleManifest =
        reader.loadManifest(new File(baseDir, "bundle1/META-INF/MANIFEST.MF"));
    Assert.assertEquals(newVersion, bundleManifest.getBundleVersion());

    OsgiManifest testBundleManifest =
        reader.loadManifest(new File(baseDir, "bundle1.tests/META-INF/MANIFEST.MF"));
    Assert.assertEquals(newVersion, testBundleManifest.getBundleVersion());

    Feature feature = Feature.read(new File(baseDir, "feature/feature.xml"));
    Assert.assertEquals(newVersion, feature.getVersion());
  }
  /**
   * 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());
  }
  /**
   * 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"));
  }
  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();
    }
  }
  /** 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"));
  }
  private void download() throws Exception {

    Verifier v =
        AbstractMavenNexusIT.createMavenVerifier(
            getTestFile("project"), getOverridableFile("settings.xml"), getTestId());

    v.executeGoal("install");
  }
 @Test
 public void dependencyDownload() throws Exception {
   try {
     verifier.executeGoal("dependency:resolve");
     verifier.verifyErrorFreeLog();
   } catch (VerificationException e) {
     failTest(verifier);
   }
 }
  @Test
  public void buildExecutable() throws VerificationException {
    Verifier verifier = new Verifier(getRoot().getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.setMavenDebug(true);

    verifier.executeGoal("package");

    verifier.verifyErrorFreeLog();
  }
  /**
   * 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>");
  }
Beispiel #18
0
  @Test
  public void should_app_generated_executes_maven_well() throws IOException, VerificationException {
    RestxShell shell = prepareRestxShell();

    AppShellCommand.NewAppCommandRunner appCommandRunner =
        new AppShellCommand().new NewAppCommandRunner();
    Path appPath = appCommandRunner.generateApp(descriptor, shell);

    Verifier mavenVerifier = new Verifier(appPath.toString());
    mavenVerifier.executeGoal("package");
    mavenVerifier.verifyErrorFreeLog();
  }
 /** 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();
 }
  // Depends on nexus-508
  @Test
  public void dependencyDownloadProtectedServer() throws Exception {
    // Disable anonymous
    disableUser("anonymous");

    File mavenProject = getTestFile("maven-project");
    File settings = getTestFile("repositoriesWithAuthentication.xml");

    Verifier verifier = createVerifier(mavenProject, settings);
    verifier.executeGoal("dependency:resolve");
    verifier.verifyErrorFreeLog();
  }
  /**
   * 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);
  }
  /**
   * @param archetypeVersion
   * @throws ComponentLookupException
   * @throws PlexusContainerException
   */
  private void executeCreateArchetype(Model model) throws Exception {
    log.info("Creating project from Archetype: " + model);
    String goal = "org.apache.maven.plugins:maven-archetype-plugin:2.2:generate";
    Properties properties = new Properties();
    properties.put("archetypeGroupId", model.getGroupId());
    properties.put("archetypeArtifactId", model.getArtifactId());
    properties.put("archetypeVersion", model.getVersion());
    properties.put("groupId", "org.jboss.as.quickstarts");
    String artifactId =
        System.currentTimeMillis() + "-" + model.toString().replaceAll("[^a-zA-Z_0-9]", "");
    properties.put("artifactId", artifactId);
    properties.put("version", "0.0.1-SNAPSHOT");
    Verifier verifier = new org.apache.maven.it.Verifier(outputDir);
    verifier.setAutoclean(false);
    verifier.setSystemProperties(properties);
    verifier.setLogFileName(artifactId + "-generate.txt");

    verifier.executeGoal(goal);

    log.info("Building project from Archetype: " + model);
    Verifier buildVerifier = new Verifier(outputDir + File.separator + artifactId);
    if (onlyMavenCentral) {
      buildVerifier.addCliOption(
          "-s " + testOutputDirectory + File.separator + "settings-clear.xml");
    }
    buildVerifier.executeGoal("compile"); // buildVerifier log is inside each project
    String functionalTestsFolder =
        outputDir + File.separator + artifactId + File.separator + "functional-tests";
    if (new File(functionalTestsFolder).exists()) {
      log.info("Building functional-tests from: " + functionalTestsFolder);
      Verifier functionalTestsVerifier = new Verifier(functionalTestsFolder);
      functionalTestsVerifier.setAutoclean(cleanArchetypes);
      if (onlyMavenCentral) {
        functionalTestsVerifier.addCliOption(
            "-s " + testOutputDirectory + File.separator + "settings-clear.xml");
      }
      functionalTestsVerifier.executeGoal("compile");
    }
  }
  /**
   * @param baseDir
   * @param model
   * @throws VerificationException
   */
  private void installArchetype(File baseDir, Model model) throws VerificationException {
    log.info("Installing Archetype *****: " + model);
    Verifier installer = new Verifier(baseDir.getAbsolutePath());
    if (onlyMavenCentral) {
      installer.addCliOption("-s " + testOutputDirectory + File.separator + "settings-clear.xml");
    }
    installer.setLogFileName("install.log");
    installer.setAutoclean(cleanArchetypes);
    installer.executeGoal("install");

    // Remove install.log from inside archetype
    new File(baseDir, "install.log").delete();
  }
  @Test
  public void dependencyDownloadPrivateServer() throws Exception {
    // Disable anonymous
    disableUser("anonymous");

    try {
      verifier.executeGoal("dependency:resolve");
      verifier.verifyErrorFreeLog();
      failTest(verifier);
    } catch (VerificationException e) {
      // Expected exception
    }
  }
  /**
   * 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 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"));
  }
  /**
   * 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\"");
  }