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

The following examples show how to use org.apache.maven.it.Verifier#assertFilePresent() . 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: XtendCompilerMojoIT.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void readXtendPrefsUnused() throws Exception {
	Verifier verifier = MavenVerifierUtil.newVerifier(ROOT + "/xtend-prefs-unused");
	verifier.setDebug(true);
	verifier.executeGoal("test");
	verifier.verifyErrorFreeLog();
	String pomsOutputDir = "xtend-dir-from-pom";

	String xtendGenDir = verifier.getBasedir() + "/src/main/" + pomsOutputDir;
	verifier.assertFilePresent(xtendGenDir + "/test/XtendA.java");
	verifier.assertFilePresent(xtendGenDir + "/test/XtendC.java");

	String xtendTestGenDir = verifier.getBasedir() + "/src/test/" + pomsOutputDir;
	verifier.assertFilePresent(xtendTestGenDir + "/tests/XtendA.java");
	verifier.assertFilePresent(xtendTestGenDir + "/tests/XtendC.java");
}
 
Example 2
Source File: DeployMojoIntegrationTest.java    From app-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeployFlexible()
    throws IOException, VerificationException, CloudSdkNotFoundException,
        ProcessHandlerException {

  Verifier verifier = new FlexibleVerifier("testDeployFlexible");

  // execute with staging directory not present
  verifier.executeGoal("package");
  verifier.executeGoal("appengine:deploy");

  // verify
  verifier.verifyErrorFreeLog();
  verifier.verifyTextInLog("Detected App Engine flexible environment application");
  verifier.verifyTextInLog("GCLOUD: Deployed service");

  // verify debugger required file generation
  verifier.assertFilePresent(
      "target/flexible-project-1.0-SNAPSHOT/WEB-INF/classes/" + "source-context.json");

  // cleanup
  deleteService("flexible-project");
}
 
Example 3
Source File: YangToSourcesPluginTestIT.java    From yangtools with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testFindResourceOnCp() throws Exception {
    Verifier v1 = setUp("test-parent/GenerateTest1/", false);
    v1.executeGoal("clean");
    v1.executeGoal("package");

    String buildDir = getMavenBuildDirectory(v1);
    v1.assertFilePresent(buildDir + "/classes/META-INF/yang/[email protected]");
    v1.assertFilePresent(buildDir + "/classes/META-INF/yang/[email protected]");
    v1.assertFilePresent(buildDir + "/classes/META-INF/yang/[email protected]");

    Verifier v2 = setUp("test-parent/GenerateTest2/", false);
    v2.executeGoal("clean");
    v2.executeGoal("package");

    buildDir = getMavenBuildDirectory(v2);
    v2.assertFilePresent(buildDir + "/classes/META-INF/yang/[email protected]");
    v2.assertFileNotPresent(buildDir + "/classes/META-INF/yang/[email protected]");
    v2.assertFileNotPresent(buildDir + "/classes/META-INF/yang/[email protected]");
    v2.assertFileNotPresent(buildDir + "/classes/META-INF/yang/[email protected]");
}
 
Example 4
Source File: XtendCompilerMojoIT.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void readXtendPrefs() throws Exception {
	Verifier verifier = MavenVerifierUtil.newVerifier(ROOT + "/xtend-prefs");
	verifier.setDebug(true);
	verifier.executeGoal("test");
	verifier.verifyErrorFreeLog();
	String xtendOutputDirFromPrefs = "generated-sources/xtend-from-pref";

	String xtendGenDir = verifier.getBasedir() + "/src/main/" + xtendOutputDirFromPrefs;
	verifier.assertFilePresent(xtendGenDir + "/test/XtendA.java");
	verifier.assertFilePresent(xtendGenDir + "/test/XtendC.java");

	String xtendTestGenDir = verifier.getBasedir() + "/src/test/" + xtendOutputDirFromPrefs;
	verifier.assertFilePresent(xtendTestGenDir + "/tests/XtendA.java");
	verifier.assertFilePresent(xtendTestGenDir + "/tests/XtendC.java");
}
 
Example 5
Source File: Bug865Test.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void compile01() throws Exception {
	Verifier verifier = doCompile();

	Path path = FileSystems.getDefault().getPath(
			"src", "main", "generated-sources", "sarl",
			"io", "sarl", "maven", "bug865", "MyAgent.java");
	assertNotNull(path);
	verifier.assertFilePresent(path.toString());
	assertEquals(EXPECTED_MYAGENT, readFile(verifier, path));
}
 
Example 6
Source File: VertxMojoTestBase.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
void runPackage(Verifier verifier) throws VerificationException {
    verifier.setLogFileName("build-package.log");
    verifier.executeGoal("package", getEnv());

    verifier.assertFilePresent("target/vertx-demo-start-0.0.1.BUILD-SNAPSHOT.jar");
    verifier.resetStreams();
}
 
Example 7
Source File: Bug850Test.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void compile02() throws Exception {
	Verifier verifier = doCompile();

	Path path = FileSystems.getDefault().getPath(
			"src", "main", "generated-sources", "sarl",
			"io", "sarl", "maven", "bug850", "Agent2.java");
	assertNotNull(path);
	verifier.assertFilePresent(path.toString());
	assertEquals(EXPECTED_AGENT2, readFile(verifier, path));
}
 
Example 8
Source File: Bug850Test.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void compile04() throws Exception {
	Verifier verifier = doCompile();

	Path path = FileSystems.getDefault().getPath(
			"src", "main", "generated-sources", "sarl",
			"io", "sarl", "maven", "bug850", "Agent4.java");
	assertNotNull(path);
	verifier.assertFilePresent(path.toString());
	assertEquals(EXPECTED_AGENT4, readFile(verifier, path));
}
 
Example 9
Source File: XtendCompilerMojoTraceIT.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void traceEnabled() throws Exception {
	Verifier verifier = verifyErrorFreeLog(ROOT + "/trace_enabled");
	String xtendGenDir = verifier.getBasedir() + "/src/main/generated-sources/xtend/";
	verifier.assertFilePresent(xtendGenDir + "test/.XtendA.java._trace");
	verifier.assertFilePresent(xtendGenDir + "test/.XtendA2.java._trace");
	Assert.assertEquals("test/XtendA.xtend", loadTraceSourcePath(xtendGenDir + "test/.XtendA.java._trace"));
	Assert.assertEquals("test/XtendA.xtend", loadTraceSourcePath(xtendGenDir + "test/.XtendA2.java._trace"));
}
 
Example 10
Source File: XtendCompilerMojoIT.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public void assertFileDoesNotContain(Verifier verifier, String file, String contained) {
	verifier.assertFilePresent(file);
	try {
		String content = FileUtils.fileRead(new File(file), "UTF-8");
		if (content.contains(contained)) {
			Assert.fail("Content of " + file + " does contain " + contained + ", but it should not. Contents: " + content);
		}
	} catch (IOException e) {
		Assert.fail(e.getMessage());
	}
}
 
Example 11
Source File: XtendCompilerMojoIT.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public void assertFileContainsUTF16(Verifier verifier, String file, String contained) {
	verifier.assertFilePresent(file);
	try {
		String content = FileUtils.fileRead(new File(file), "UTF-16");
		if (!content.contains(contained)) {
			Assert.fail("Content of " + file + " does not contain " + contained + " but: " + content);
		}
	} catch (IOException e) {
		Assert.fail(e.getMessage());
	}
}
 
Example 12
Source File: Bug850Test.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void compile01() throws Exception {
	Verifier verifier = doCompile();

	Path path = FileSystems.getDefault().getPath(
			"src", "main", "generated-sources", "sarl",
			"io", "sarl", "maven", "bug850", "Agent1.java");
	assertNotNull(path);
	verifier.assertFilePresent(path.toString());
	assertEquals(EXPECTED_AGENT1, readFile(verifier, path));
}
 
Example 13
Source File: CompileMojoIT.java    From jspc-maven-plugin with Apache License 2.0 5 votes vote down vote up
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");
    }
 
Example 14
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 15
Source File: DeployAllMojoIntegrationTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeployAllFlexible()
    throws IOException, VerificationException, CloudSdkNotFoundException,
        ProcessHandlerException {

  Verifier verifier = new FlexibleVerifier("testDeployFlexible");

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

  // verify
  verifier.verifyErrorFreeLog();
  verifier.verifyTextInLog("Detected App Engine flexible environment application");
  verifier.verifyTextInLog("GCLOUD: Deployed service");
  verifier.verifyTextInLog("GCLOUD: Custom routings have been updated.");
  verifier.verifyTextInLog("GCLOUD: DoS protection has been updated.");
  verifier.verifyTextInLog("GCLOUD: Indexes are being rebuilt. This may take a moment.");
  verifier.verifyTextInLog("GCLOUD: Cron jobs have been updated.");
  verifier.verifyTextInLog("GCLOUD: Task queues have been updated.");

  // verify debugger required file generation
  verifier.assertFilePresent(
      "target/flexible-project-1.0-SNAPSHOT/WEB-INF/classes/source-context.json");

  // cleanup
  deleteService("flexible-project");
}
 
Example 16
Source File: AbstractMojoTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Read the content of the given file.
 *
 * @param verifier the Maven verifier to use for obtaining the context.
 * @param file the file to read, relatively to the context base dir.
 * @return the file content.
 * @throws VerificationException if the file cannot be loaded.
 * @since 0.7
 */
protected static String readFile(Verifier verifier, Path file) throws VerificationException {
	verifier.assertFilePresent(file.toString());
	StringBuilder buffer = new StringBuilder();
	for (final String line : verifier.loadFile(verifier.getBasedir(), file.toString(), false)) {
		buffer.append(line).append("\n"); //$NON-NLS-1$
	}
	return buffer.toString();
}
 
Example 17
Source File: VertxMojoTestBase.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
void runPackage(Verifier verifier) throws VerificationException {
    verifier.setLogFileName("build-package.log");
    verifier.executeGoal("package", getEnv());

    verifier.assertFilePresent("target/vertx-demo-start-0.0.1.BUILD-SNAPSHOT.jar");
    verifier.resetStreams();
}
 
Example 18
Source File: Bug850Test.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void compile03() throws Exception {
	Verifier verifier = doCompile();

	Path path = FileSystems.getDefault().getPath(
			"src", "main", "generated-sources", "sarl",
			"io", "sarl", "maven", "bug850", "Agent3.java");
	assertNotNull(path);
	verifier.assertFilePresent(path.toString());
	assertEquals(EXPECTED_AGENT3, readFile(verifier, path));
}
 
Example 19
Source File: VulasMavenPluginTests.java    From steady with Apache License 2.0 5 votes vote down vote up
public Verifier testPlugin(String pomFileName)
        throws Exception {

    // set the maven project to test
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/testproject");

    Verifier verifier = new Verifier(testDir.getAbsolutePath());

    // remove artifacts created by this test from the m2 repository
    verifier.deleteArtifact("foo.bar", "sampletest", "1.0.0", "pom");

    // execute the goals
    List cliOptions = new ArrayList();
    // pass the backendURL to the mvn invoke command
    Properties properties = new Properties();
    properties.setProperty(VulasConfiguration.getServiceUrlKey(Service.BACKEND), stubServer.getBackendURL());
    verifier.setSystemProperties(properties);

    // do not recurse into sub-projects
    cliOptions.add("-N");
    cliOptions.add("-f=" + pomFileName);
    verifier.setCliOptions(cliOptions);
    List goals = new ArrayList();
    goals.add("clean");
    goals.add("compile");
    goals.add("vulas:app");
    goals.add("test");

    verifier.executeGoals(goals);

    //check if vulas has been executed
    verifier.assertFilePresent("target/vulas/tmp");

    verifier.verifyErrorFreeLog();

    return verifier;


}
 
Example 20
Source File: Bug504Test.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void compile() throws Exception {
	Verifier verifier = executeMojo("bug504", "compile");
	Path path = FileSystems.getDefault().getPath(
			"src", "main", "generated-sources", "sarl",
			"io", "sarl", "elevatorsim", "SimulatorInteraction.java");
	assertNotNull(path);
	verifier.assertFilePresent(path.toString());
	File file = new File(verifier.getBasedir(), path.toString());
	String fileContent = FileUtils.fileRead(file);
	assertEquals(multilineString(
			"package io.sarl.elevatorsim;",
			"",
			"import io.sarl.elevatorsim.SimulatorPush;",
			"import io.sarl.elevatorsim.events.SendCarAction;",
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"import java.io.IOException;",
			"import org.eclipse.xtext.xbase.lib.Exceptions;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class SimulatorInteraction extends Skill implements SimulatorPush {",
			"  public void sendCar(final int a, final int b, final int c, final Object d, final Object e) {",
			"  }",
			"  ",
			"  @Override",
			"  public void pushSendCarAction(final SendCarAction action) {",
			"    try {",
			"      this.sendCar(action.car, action.floor, action.nextDirection, ",
			"        null, null);",
			"    } catch (final Throwable _t) {",
			"      if (_t instanceof IOException) {",
			"        final IOException e = (IOException)_t;",
			"        e.printStackTrace();",
			"      } else {",
			"        throw Exceptions.sneakyThrow(_t);",
			"      }",
			"    }",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public SimulatorInteraction() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public SimulatorInteraction(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}"), fileContent);
}