From 38e082770c5bf2112d0d210bb2860c3ca07f3e77 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Fri, 3 Oct 2008 19:36:31 +0000 Subject: [PATCH] o Decoupled it0043 from production plugin git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@701506 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/maven/it/MavenIT0043Test.java | 45 ++++++++++++++---- .../src/test/resources/it0043/child1/pom.xml | 13 ----- .../src/test/resources/it0043/child2/pom.xml | 44 ----------------- .../inheritance/RepositoryOverrideTest.java | 26 ---------- .../src/test/resources/it0043/pom.xml | 21 --------- .../src/test/resources/it0043/setup/pom.xml | 31 ++++++++++++ .../src/test/resources/it0043/test/pom.xml | 47 +++++++++++++++++++ 7 files changed, 115 insertions(+), 112 deletions(-) delete mode 100644 its/core-it-suite/src/test/resources/it0043/child1/pom.xml delete mode 100644 its/core-it-suite/src/test/resources/it0043/child2/pom.xml delete mode 100644 its/core-it-suite/src/test/resources/it0043/child2/src/test/java/org/apache/maven/project/inheritance/RepositoryOverrideTest.java delete mode 100644 its/core-it-suite/src/test/resources/it0043/pom.xml create mode 100644 its/core-it-suite/src/test/resources/it0043/setup/pom.xml create mode 100644 its/core-it-suite/src/test/resources/it0043/test/pom.xml diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0043Test.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0043Test.java index bb77bb69b4..f06809a22b 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0043Test.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0043Test.java @@ -23,6 +23,7 @@ import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; import java.io.File; +import java.util.Properties; public class MavenIT0043Test extends AbstractMavenIntegrationTestCase @@ -36,22 +37,50 @@ public class MavenIT0043Test { File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0043" ); - File child1 = new File( testDir, "child1" ); + // Phase 1: Ensure the test plugin is downloaded before the test cuts off access to central + File child1 = new File( testDir, "setup" ); Verifier verifier = new Verifier( child1.getAbsolutePath() ); - verifier.deleteArtifact( "org.apache.maven.plugins", "maven-help-plugin", "2.0.2", "jar" ); - - verifier.executeGoal( "org.apache.maven.plugins:maven-help-plugin:2.0.2:effective-pom" ); + verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-expression::eval" ); verifier.verifyErrorFreeLog(); verifier.resetStreams(); - File child2 = new File( testDir, "child2" ); + // Phase 2: Now run the test + File child2 = new File( testDir, "test" ); verifier = new Verifier( child2.getAbsolutePath() ); - verifier.executeGoal( "org.apache.maven.plugins:maven-help-plugin:2.0.2:effective-pom" ); + Properties systemProperties = new Properties(); + systemProperties.put( "expression.expressions", "project/repositories,project/pluginRepositories" ); + verifier.setSystemProperties( systemProperties ); + verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-expression::eval" ); verifier.verifyErrorFreeLog(); verifier.resetStreams(); - } -} + verifier.assertFilePresent( "target/expression.properties" ); + Properties props = verifier.loadProperties( "target/expression.properties" ); + int count = Integer.parseInt( props.getProperty( "project.repositories", "0" ) ); + assertTrue( count > 0 ); + for ( int i = 0; i < count; i++ ) + { + String key = "project.repositories." + i; + if ( "central".equals( props.getProperty( key + ".id" ) ) ) + { + assertEquals( "it0043", props.getProperty( key + ".name" ) ); + assertTrue( props.getProperty( key + ".url" ).endsWith( "/tmp/maven-core-it0043-repo" ) ); + } + } + + count = Integer.parseInt( props.getProperty( "project.pluginRepositories", "0" ) ); + for ( int i = 0; i < count; i++ ) + { + String key = "project.pluginRepositories." + i; + if ( "central".equals( props.getProperty( key + ".id" ) ) ) + { + assertEquals( "it0043", props.getProperty( key + ".name" ) ); + assertTrue( props.getProperty( key + ".url" ).endsWith( "/tmp/maven-core-it0043-repo" ) ); + } + } + } + +} diff --git a/its/core-it-suite/src/test/resources/it0043/child1/pom.xml b/its/core-it-suite/src/test/resources/it0043/child1/pom.xml deleted file mode 100644 index a7929ed2f2..0000000000 --- a/its/core-it-suite/src/test/resources/it0043/child1/pom.xml +++ /dev/null @@ -1,13 +0,0 @@ - - 4.0.0 - - org.apache.maven.its.it0043 - maven-it-it0043-parent - 1.0-SNAPSHOT - - - maven-it-it0043-child1 - Maven Integration Test :: it0043 Child1 - Test for repository inheritence - ensure using the same id overrides the defaults - - diff --git a/its/core-it-suite/src/test/resources/it0043/child2/pom.xml b/its/core-it-suite/src/test/resources/it0043/child2/pom.xml deleted file mode 100644 index 4fa3ceb9b7..0000000000 --- a/its/core-it-suite/src/test/resources/it0043/child2/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - 4.0.0 - - org.apache.maven.its.it0043 - maven-it-it0043-parent - 1.0-SNAPSHOT - - - maven-it-it0043-child2 - Maven Integration Test :: it0043 Child2 - Test for repository inheritence - ensure using the same id overrides the defaults - - - - central - Empty Repository - file:/tmp/emptyRepo - - - - - - central - Empty Repository - file:/tmp/emptyRepo - - - - - - - org.apache.maven.its.it0043 - maven-it-it0043-child1 - 1.0-SNAPSHOT - - - - junit - junit - 3.8.1 - - - diff --git a/its/core-it-suite/src/test/resources/it0043/child2/src/test/java/org/apache/maven/project/inheritance/RepositoryOverrideTest.java b/its/core-it-suite/src/test/resources/it0043/child2/src/test/java/org/apache/maven/project/inheritance/RepositoryOverrideTest.java deleted file mode 100644 index 1dcbd765d5..0000000000 --- a/its/core-it-suite/src/test/resources/it0043/child2/src/test/java/org/apache/maven/project/inheritance/RepositoryOverrideTest.java +++ /dev/null @@ -1,26 +0,0 @@ -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; - -import junit.framework.TestCase; - -public class RepositoryOverrideTest extends TestCase -{ - public void testPOM() throws Exception - { - - BufferedInputStream in = new BufferedInputStream( new FileInputStream("target/effective-pom.xml") ); - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - int rd = 0; - byte [] buffer = new byte[512]; - - while ( ( rd = in.read( buffer ) ) > 0 ) - { - out.write( buffer, 0, rd ); - } - - assertEquals( -1, out.toString().indexOf("repo1.maven.org") ); - } -} diff --git a/its/core-it-suite/src/test/resources/it0043/pom.xml b/its/core-it-suite/src/test/resources/it0043/pom.xml deleted file mode 100644 index 4ed97e4644..0000000000 --- a/its/core-it-suite/src/test/resources/it0043/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - 4.0.0 - Maven Integration Test :: it0043 Parent - org.apache.maven.its.it0043 - maven-it-it0043-parent - Test for repository inheritence - ensure using the same id overrides the defaults - 1.0-SNAPSHOT - pom - - - - - child1 - child2 - - - diff --git a/its/core-it-suite/src/test/resources/it0043/setup/pom.xml b/its/core-it-suite/src/test/resources/it0043/setup/pom.xml new file mode 100644 index 0000000000..d7c1a0c4b3 --- /dev/null +++ b/its/core-it-suite/src/test/resources/it0043/setup/pom.xml @@ -0,0 +1,31 @@ + + + + + + 4.0.0 + + org.apache.maven.its.it0043 + maven-it-it0043 + 1.0-SNAPSHOT + + Maven Integration Test :: it0043 setup + Preparation project with non-overriden URL to central for plugin download. + diff --git a/its/core-it-suite/src/test/resources/it0043/test/pom.xml b/its/core-it-suite/src/test/resources/it0043/test/pom.xml new file mode 100644 index 0000000000..14be9293a4 --- /dev/null +++ b/its/core-it-suite/src/test/resources/it0043/test/pom.xml @@ -0,0 +1,47 @@ + + + + + + 4.0.0 + + org.apache.maven.its.it0043 + maven-it-it0043 + 1.0-SNAPSHOT + + Maven Integration Test :: it0043 + Test for repository inheritence - ensure using the same id overrides the defaults + + + + central + it0043 + file:/tmp/maven-core-it0043-repo + + + + + + central + it0043 + file:/tmp/maven-core-it0043-repo + + +