/** * 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")); }
@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"); }
@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()); }
/** 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")); }
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 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 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")); } }
/** * 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")); }
@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 testBaselineRepositoryDoesNotExist() throws Exception { // likely initial state is when baseline repository url points at empty or garbage location File notARepository = new File("baseline/src").getCanonicalFile(); Verifier verifier = getVerifier("baseline/src", notARepository); verifier.executeGoals(Arrays.asList("clean", "package")); verifier.verifyErrorFreeLog(); }
@Test public void dependencyDownload() throws Exception { try { verifier.executeGoal("dependency:resolve"); verifier.verifyErrorFreeLog(); } catch (VerificationException e) { failTest(verifier); } }
@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(); }
private void doExecute(ProcessorTestCase child, Description description) throws Exception { File destination = extractTest(child, description); PrintStream originalOut = System.out; final Verifier verifier; if (Boolean.getBoolean(SYS_PROP_DEBUG)) { if (child.processor.getToolchain() == null) { // when not using toolchains for a test, then the compiler is executed within the Maven JVM. // So make // sure we fork a new JVM for that, and let that new JVM use the command 'mvnDebug' instead // of 'mvn' verifier = new Verifier(destination.getCanonicalPath(), null, true, true); verifier.setDebugJvm(true); } else { verifier = new Verifier(destination.getCanonicalPath()); verifier.addCliOption("-Pdebug-forked-javac"); } } else { verifier = new Verifier(destination.getCanonicalPath()); } List<String> goals = new ArrayList<String>(3); goals.add("clean"); try { configureToolchains(child, verifier, goals, originalOut); configureProcessor(child, verifier); verifier.addCliOption( "-Dcompiler-source-target-version=" + child.processor.getSourceTargetVersion()); if ("1.8".equals(child.processor.getSourceTargetVersion()) || "1.9".equals(child.processor.getSourceTargetVersion())) { verifier.addCliOption("-Dmapstruct-artifact-id=mapstruct-jdk8"); } else { verifier.addCliOption("-Dmapstruct-artifact-id=mapstruct"); } if (Boolean.getBoolean(SYS_PROP_DEBUG)) { originalOut.print("Processor Integration Test: "); originalOut.println("Listening for transport dt_socket at address: 8000 (in some seconds)"); } goals.add("test"); addAdditionalCliArguments(child, verifier); originalOut.println("executing " + child.processor.name().toLowerCase()); verifier.executeGoals(goals); verifier.verifyErrorFreeLog(); } finally { verifier.resetStreams(); } }
@Test public void buildExecutable() throws VerificationException { Verifier verifier = new Verifier(getRoot().getAbsolutePath()); verifier.setAutoclean(false); verifier.setMavenDebug(true); verifier.executeGoal("package"); verifier.verifyErrorFreeLog(); }
// 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(); }
@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(); }
/** * 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); }
@Test public void dependencyDownloadPrivateServer() throws Exception { // Disable anonymous disableUser("anonymous"); try { verifier.executeGoal("dependency:resolve"); verifier.verifyErrorFreeLog(); failTest(verifier); } catch (VerificationException e) { // Expected exception } }
/** * 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); }
@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 testRebuildOfTheSameCodebase() throws Exception { Verifier verifier = getVerifier("baseline/src", baselineRepo); verifier.executeGoals(Arrays.asList("clean", "package")); verifier.verifyErrorFreeLog(); File repository = new File(verifier.getBasedir(), "repository/target/repository"); assertBaselineContents(repository, "features/baseline.feature01_1.0.0.1.jar"); assertBaselineContents(repository, "plugins/baseline.bundle01_1.0.0.1.jar"); assertBaselineContents(repository, "plugins/baseline.bundle01.source_1.0.0.1.jar"); }
/** * 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); }
/** * 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")); }
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(); }
/** 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", ""))); }