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"); }
@Test public void buildUberjarAndRunTests() throws IOException, VerificationException, InterruptedException { String goal = "package"; if (testingProject.canRunTests()) { goal = "verify"; // a lot of these fail because of SWARM-873 if (testingProject.additionalDependency == AdditionalDependency.USING_JAVA_EE) { goal = "package"; } } try { verifier.executeGoal(goal); } catch (VerificationException e) { if (testingProject.dependencies == Dependencies.JAVA_EE_APIS && testingProject.autodetection == Autodetection.NEVER) { // the only situation when build failure is expected String log = new String(Files.readAllBytes(logPath), StandardCharsets.UTF_8); assertThat(log).contains("No WildFly Swarm Bootstrap fraction found"); return; } throw e; } verifier.assertFilePresent( "target/testing-project." + testingProject.packaging.fileExtension()); verifier.assertFilePresent("target/testing-project-swarm.jar"); String log = new String(Files.readAllBytes(logPath), StandardCharsets.UTF_8); assertThat(log).doesNotContain("[ERROR]"); assertThat(log).doesNotContain("[WARNING]"); assertThat(log).contains("BUILD SUCCESS"); checkFractionAutodetection(log); File uberjarFile = new File(verifier.getBasedir(), "target/testing-project-swarm.jar"); Archive uberjar = ShrinkWrap.createFromZipFile(GenericArchive.class, uberjarFile); checkFractionsPresent(uberjar); checkMainClass(uberjar); }
/** * 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>"); }
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(); }
/** * 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\""); }
/** * 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(); }
/** * 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"); }
/** * 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"); }
/** * 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);"); }
/** * 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); }