/** 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")); }
/** * 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); }
/** * 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")); }
/** * 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 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(); }
/** * Test that unreadable metadata from one repository does not fail the entire dependency * resolution. */ public void testit() throws Exception { File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4498"); Verifier verifier = newVerifier(testDir.getAbsolutePath()); verifier.setAutoclean(false); verifier.deleteDirectory("target"); verifier.deleteArtifacts("org.apache.maven.its.mng4498"); 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(); List<String> classpath = verifier.loadLines("target/classpath.txt", "UTF-8"); assertTrue(classpath.toString(), classpath.contains("dep-0.1-SNAPSHOT.jar")); }
/** * 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"); }
/** * Verify that plugin dependencies defined by plugin management of a parent profile are not lost * when the parent's main plugin management section is also present. */ public void testitMNG2174() throws Exception { File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-2174"); Verifier verifier = newVerifier(new File(testDir, "sub").getAbsolutePath()); verifier.setAutoclean(false); verifier.deleteDirectory("target"); verifier.deleteArtifacts("org.apache.maven.its.mng2174"); 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 props = verifier.loadProperties("target/pcl.properties"); assertEquals("1", props.getProperty("mng-2174.properties.count")); assertNotNull(props.getProperty("mng-2174.properties")); }
/** Tests that hex digits of checksums are compared without regard to case. */ public void testitMNG2744() throws Exception { File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-2744"); Verifier verifier = newVerifier(testDir.getAbsolutePath()); verifier.setAutoclean(false); verifier.deleteArtifacts("org.apache.maven.its.mng2744"); 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(); verifier.assertArtifactPresent("org.apache.maven.its.mng2744", "a", "1", "jar"); verifier.assertArtifactPresent("org.apache.maven.its.mng2744", "a", "1", "pom"); verifier.assertArtifactPresent("org.apache.maven.its.mng2744", "b", "1", "jar"); verifier.assertArtifactPresent("org.apache.maven.its.mng2744", "b", "1", "pom"); }
/** * Verify that dependency resolution by an aggregator before the build has actually produced any * artifacts doesn't prevent later resolution of project artifacts from the reactor if the * aggregator originally resolved them from the remote repo. */ public void testit() throws Exception { File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4814"); Verifier verifier = newVerifier(testDir.getAbsolutePath()); verifier.setAutoclean(false); verifier.deleteDirectory("consumer/target"); verifier.deleteArtifacts("org.apache.maven.its.mng4814"); verifier.addCliOption("-s"); verifier.addCliOption("settings.xml"); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties()); List<String> goals = new ArrayList<String>(); goals.add( "org.apache.maven.its.plugins:maven-it-plugin-dependency-resolution:2.1-SNAPSHOT:aggregate-test"); goals.add("validate"); verifier.executeGoals(goals); verifier.verifyErrorFreeLog(); verifier.resetStreams(); List<String> compile = verifier.loadLines("consumer/target/compile.txt", "UTF-8"); assertFalse(compile.toString(), compile.contains("0.1-SNAPSHOT/producer-0.1-SNAPSHOT.jar")); assertTrue(compile.toString(), compile.contains("producer/pom.xml")); }