Java Code Examples for org.apache.maven.it.Verifier#setAutoclean()

The following examples show how to use org.apache.maven.it.Verifier#setAutoclean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlatformJarArchetypeIT.java    From alfresco-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void whenGenerateProjectFromArchetypeThenAProperProjectIsCreated() throws Exception {
    generateProjectFromArchetype(LOGGER);

    LOGGER.info("---------------------------------------------------------------------");
    LOGGER.info("Building the generated project {}", archetypeProperties.getProjectArtifactId());
    LOGGER.info("---------------------------------------------------------------------");

    // Since creating the archetype was successful, we now want to actually build the generated project executing the integration tests
    // Execute a purge to ensure old data don't make the test fail
    ProcessBuilder purge = getProcessBuilder("purge");
    purge.start().waitFor();
    ProcessBuilder pb = getProcessBuilder("build_test");
    pb.start().waitFor();

    // Verify the execution of the integration tests of the project were successful
    Verifier verifier = new Verifier(projectPath);
    verifier.setAutoclean(false);
    verifier.setLogFileName(LOG_FILENAME);
    printVerifierLog("PROJECT BUILD", verifier, LOGGER);
    verifier.verifyErrorFreeLog();
    verifier.verifyTextInLog("Tests run: 5, Failures: 0, Errors: 0, Skipped: 0");
}
 
Example 2
Source File: AllInOneArchetypeIT.java    From alfresco-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void whenGenerateProjectFromArchetypeThenAProperProjectIsCreated() throws Exception {

    generateProjectFromArchetype(LOGGER);

    LOGGER.info("---------------------------------------------------------------------");
    LOGGER.info("Building the generated project {}", archetypeProperties.getProjectArtifactId());
    LOGGER.info("---------------------------------------------------------------------");

    // Since creating the archetype was successful, we now want to actually build the generated project executing the integration tests
    // Execute a purge to ensure old data don't make the test fail
    ProcessBuilder purge = getProcessBuilder("purge");
    purge.start().waitFor();
    ProcessBuilder pb = getProcessBuilder("build_test");
    pb.start().waitFor();

    // Verify the execution of the integration tests of the project were successful
    Verifier verifier = new Verifier(projectPath);
    verifier.setAutoclean(false);
    verifier.setLogFileName(LOG_FILENAME);
    printVerifierLog("PROJECT BUILD", verifier, LOGGER);
    verifier.verifyErrorFreeLog();
    verifier.verifyTextInLog("Tests run: 5, Failures: 0, Errors: 0, Skipped: 0");
}
 
Example 3
Source File: StopMojoIntegrationTest.java    From app-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testStopStandard() throws IOException, VerificationException, InterruptedException {

  Verifier verifier = new StandardVerifier("testStopStandard_start");

  verifier.setSystemProperty("app.devserver.port", Integer.toString(serverPort));

  // start dev app server
  verifier.executeGoals(Arrays.asList("package", "appengine:start"));

  // verify dev app server is up
  verifier.verifyErrorFreeLog();
  assertNotNull(UrlUtils.getUrlContentWithRetries(getServerUrl(), 60000, 100));

  // stop dev app server
  verifier.setLogFileName("testStopStandard.txt");
  verifier.setAutoclean(false);
  verifier.executeGoal("appengine:stop");

  // verify dev app server is down
  verifier.verifyErrorFreeLog();
  // wait up to 5 seconds for the server to stop
  assertTrue(UrlUtils.isUrlDownWithRetries(getServerUrl(), 5000, 100));
}
 
Example 4
Source File: SetupIT.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void initVerifier(File root) throws VerificationException {
    verifier = new Verifier(root.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.setDebug(true);
    verifier.setForkJvm(true);
    verifier.setMavenDebug(true);
    installPluginToLocalRepository(verifier.getLocalRepository());
}
 
Example 5
Source File: PitMojoIT.java    From pitest with Apache License 2.0 5 votes vote down vote up
private File prepare(String testPath) throws IOException,
    VerificationException {
  String path = ResourceExtractor.extractResourcePath(getClass(), testPath,
      testFolder.getRoot(), true).getAbsolutePath();

  verifier = new Verifier(path);
  verifier.setAutoclean(false);
  verifier.setDebug(true);
  verifier.getCliOptions().add("-Dpit.version=" + VERSION);
  verifier.getCliOptions().add(
      "-Dthreads=" + (Runtime.getRuntime().availableProcessors()));

  return new File(testFolder.getRoot().getAbsolutePath() + testPath);
}
 
Example 6
Source File: ShareJarArchetypeIT.java    From alfresco-sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void whenGenerateProjectFromArchetypeThenAProperProjectIsCreated() throws Exception {
    generateProjectFromArchetype(LOGGER);

    LOGGER.info("---------------------------------------------------------------------");
    LOGGER.info("Building the generated project {}", archetypeProperties.getProjectArtifactId());
    LOGGER.info("---------------------------------------------------------------------");

    // Since creating the archetype was successful, we now want to actually build the generated project
    Verifier verifier = new Verifier(projectPath);
    verifier.setAutoclean(false);
    verifier.executeGoal("install");
    printVerifierLog("PROJECT BUILD", verifier, LOGGER);
    verifier.verifyErrorFreeLog();
}
 
Example 7
Source File: AbstractArchetypeIT.java    From alfresco-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * Generate a new project from an archetype and verify the generation was successful.
 */
protected void generateProjectFromArchetype(final Logger logger) throws Exception {
    LOG.info("---------------------------------------------------------------------");
    LOG.info("Generating a new project from the archetype {}:{}:{}", archetypeProperties.getArchetypeGroupId(), archetypeProperties.getArchetypeArtifactId(),
            archetypeProperties.getArchetypeVersion());
    LOG.info("---------------------------------------------------------------------");
    Verifier verifier = new Verifier(ROOT.getAbsolutePath());
    verifier.setSystemProperties(archetypeProperties.getSystemProperties());
    verifier.setAutoclean(false);
    verifier.executeGoal("archetype:generate");
    printVerifierLog("PROJECT GENERATION", verifier, logger);
    verifier.verifyErrorFreeLog();
}
 
Example 8
Source File: AbstractMojoTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Execute a Mojo.
 *
 * @param projectName the name of the project to test for the unit test.
 * @param goalName the goal to run.
 * @return the verifier.
 * @throws Exception any exception.
 */
protected Verifier executeMojo(String projectName, String goalName) throws Exception {
	String tempDirPath = System.getProperty("maven.test.tmpdir", //$NON-NLS-1$
			System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
	File tempDir = new File(tempDirPath);
	File baseDir = new File(tempDir, projectName);
	assertNotNull(baseDir);

	FileUtils.deleteDirectory(baseDir);

	URL url = getClass().getResource("/projects/" + projectName); //$NON-NLS-1$
	if (url == null) {
		throw new IllegalArgumentException("Resource not found: " + projectName); //$NON-NLS-1$
	}
	File resourceFile = new File(new URI(url.toExternalForm()));
	assertTrue(resourceFile.isDirectory());
	FileUtils.copyDirectoryStructure(resourceFile, baseDir);

	assertTrue(baseDir.exists());
	assertTrue(baseDir.isDirectory());

	recursiveDeleteOnShutdownHook(baseDir);

	Verifier verifier = new Verifier(baseDir.getAbsolutePath());
	verifier.setAutoclean(false);
	verifier.setDebug(false);
	final String m2home = findDefaultMavenHome();
	if (m2home != null && !m2home.isEmpty()) {
		verifier.setForkJvm(false);
		verifier.getSystemProperties().put("maven.multiModuleProjectDirectory", m2home); //$NON-NLS-1$
		verifier.getVerifierProperties().put("use.mavenRepoLocal", Boolean.FALSE.toString()); //$NON-NLS-1$
	}
	verifier.executeGoals(Arrays.asList("clean", goalName)); //$NON-NLS-1$
	return verifier;
}
 
Example 9
Source File: AbstractStageMojoIntegrationTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testStageStandard() throws IOException, VerificationException {

  String projectDir =
      ResourceExtractor.simpleExtractResources(getClass(), "/projects/standard-project")
          .getAbsolutePath();

  Verifier verifier = new StandardVerifier("testStageStandard");

  // execute with staging directory not present
  verifier.executeGoals(Arrays.asList("package", "appengine:stage"));

  // verify
  verifier.verifyErrorFreeLog();
  verifier.verifyTextInLog("Detected App Engine standard environment application");
  verifier.verifyTextInLog("GCLOUD: ");
  verifier.assertFilePresent("target/appengine-staging");
  verifier.assertFilePresent("target/appengine-staging/WEB-INF");
  verifier.assertFilePresent("target/appengine-staging/WEB-INF/web.xml");
  verifier.assertFilePresent("target/appengine-staging/app.yaml");
  verifier.assertFileMatches(
      projectDir + "/target/appengine-staging/app.yaml", "(?s).*service: 'standard-project'.*");

  // repeat with staging directory present
  verifier.setLogFileName("testStageStandard_repeat.txt");
  verifier.setAutoclean(false);
  verifier.executeGoal("appengine:stage");
  verifier.verifyTextInLog("Deleting the staging directory");
}
 
Example 10
Source File: TestPlugin.java    From minikube-build-tools-for-java with Apache License 2.0 5 votes vote down vote up
@Override
protected void before() throws IOException, XmlPullParserException, VerificationException {
  // Installs the plugin for use in tests.
  Verifier verifier = new Verifier(".", true);
  verifier.setAutoclean(false);
  verifier.addCliOption("-DskipTests");
  verifier.executeGoal("install");

  // Reads the project version.
  MavenXpp3Reader reader = new MavenXpp3Reader();
  Model model = reader.read(new FileReader("pom.xml"));
  pluginVersion = model.getVersion();
}
 
Example 11
Source File: MinikubeVerifier.java    From minikube-build-tools-for-java with Apache License 2.0 5 votes vote down vote up
/** Sets up the a verifier on the {@link TestProject}. */
MinikubeVerifier(TestProject testProject)
    throws VerificationException, IOException, URISyntaxException {
  // Sets the minikube executable to fakeminikube.
  testProject.replaceInPom("@@MinikubePath@@", FakeMinikube.getPath().toString());

  verifier = new Verifier(testProject.getProjectRoot().toString());
  verifier.setAutoclean(false);
}
 
Example 12
Source File: SetupIT.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void initVerifier(File root) throws VerificationException {
    verifier = new Verifier(root.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.setDebug(true);
    verifier.setForkJvm(true);
    verifier.setMavenDebug(true);
    installPluginToLocalRepository(verifier.getLocalRepository());
}
 
Example 13
Source File: PackagingIT.java    From vertx-maven-plugin with Apache License 2.0 4 votes vote down vote up
private void initVerifier(File root) throws VerificationException {
    verifier = new Verifier(root.getAbsolutePath());
    verifier.setAutoclean(false);
    installPluginToLocalRepository(verifier.getLocalRepository());
}
 
Example 14
Source File: StartStopMojoIT.java    From vertx-maven-plugin with Apache License 2.0 4 votes vote down vote up
public void initVerifier(File root) throws VerificationException {
    verifier = new Verifier(root.getAbsolutePath());
    verifier.setAutoclean(false);

    installPluginToLocalRepository(verifier.getLocalRepository());
}
 
Example 15
Source File: ExtraManifestInfoIT.java    From vertx-maven-plugin with Apache License 2.0 4 votes vote down vote up
public void initVerifier(File root) throws VerificationException {
    verifier = new Verifier(root.getAbsolutePath());
    verifier.setAutoclean(false);

    installPluginToLocalRepository(verifier.getLocalRepository());
}
 
Example 16
Source File: PackagingIT.java    From vertx-maven-plugin with Apache License 2.0 4 votes vote down vote up
private void initVerifier(File root) throws VerificationException {
    verifier = new Verifier(root.getAbsolutePath());
    verifier.setAutoclean(false);
    installPluginToLocalRepository(verifier.getLocalRepository());
}
 
Example 17
Source File: StartStopMojoIT.java    From vertx-maven-plugin with Apache License 2.0 4 votes vote down vote up
private void initVerifier(File root) throws VerificationException {
    verifier = new Verifier(root.getAbsolutePath());
    verifier.setAutoclean(false);

    installPluginToLocalRepository(verifier.getLocalRepository());
}
 
Example 18
Source File: ExtraManifestInfoIT.java    From vertx-maven-plugin with Apache License 2.0 4 votes vote down vote up
public void initVerifier(File root) throws VerificationException {
    verifier = new Verifier(root.getAbsolutePath());
    verifier.setAutoclean(false);

    installPluginToLocalRepository(verifier.getLocalRepository());
}