o Decoupled IT for MNG-3680 from production deps/plugins

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@734236 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-01-13 20:40:59 +00:00
parent ea82a49374
commit 2c44c15783
25 changed files with 158 additions and 287 deletions

View File

@ -20,46 +20,44 @@ package org.apache.maven.it;
*/ */
import java.io.File; import java.io.File;
import java.util.List;
import org.apache.maven.it.Verifier; import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor; import org.apache.maven.it.util.ResourceExtractor;
/** /**
* Verify that dependencies with invalid POMs can still be used without failing * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3680">MNG-3680</a>.
* the build.
* *
* @author jdcasey * @author jdcasey
*/ */
public class MavenITmng3680InvalidDependencyPOMTest public class MavenITmng3680InvalidDependencyPOMTest
extends AbstractMavenIntegrationTestCase extends AbstractMavenIntegrationTestCase
{ {
public MavenITmng3680InvalidDependencyPOMTest() public MavenITmng3680InvalidDependencyPOMTest()
{ {
super( "(2.0.9,)" ); super( "(2.0.9,)" );
} }
/**
* Verify that dependencies with invalid POMs can still be used without failing the build.
*/
public void testitMNG3680 () public void testitMNG3680 ()
throws Exception throws Exception
{ {
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3680" ); File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3680" );
File pluginDir = new File( testDir, "maven-mng3680-plugin" );
Verifier verifier = new Verifier( pluginDir.getAbsolutePath() );
verifier.executeGoal( "install" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
verifier = new Verifier( testDir.getAbsolutePath() );
verifier.deleteArtifact( "tests", "dep-L1", "1", "jar" );
verifier.deleteArtifact( "tests", "dep-L1", "1", "pom" );
verifier.deleteArtifact( "tests", "dep-L1", "1", "jar" );
verifier.deleteArtifact( "tests", "dep-L2", "1", "pom" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.deleteArtifacts( "org.apache.maven.its.mng3680" );
verifier.executeGoal( "validate" ); verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog(); verifier.verifyErrorFreeLog();
verifier.resetStreams(); verifier.resetStreams();
List artifacts = verifier.loadLines( "target/artifacts.txt", "UTF-8" );
assertTrue( artifacts.toString(), artifacts.contains( "org.apache.maven.its.mng3680:direct:jar:0.1" ) );
assertTrue( artifacts.toString(), artifacts.contains( "org.apache.maven.its.mng3680:transitive:jar:0.1" ) );
} }
} }

View File

@ -1,16 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tests</groupId>
<artifactId>dep-L2</artifactId>
<packaging>jar</packaging>
<version>1</version>
<name>dep-L2</name>
<distributionManagement>
<repository>
<id>dep-repo</id>
<url>file://${pom.basedir}/..</url>
</repository>
</distributionManagement>
</project>

View File

@ -1,13 +0,0 @@
package tests.level2;
/**
* Hello world!
*
*/
public class AppLevel2
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -1,28 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tests</groupId>
<artifactId>dep-L1</artifactId>
<packaging>jar</packaging>
<version>1</version>
<dependencies>
<dependency>
<groupId>tests</groupId>
<artifactId>dep-L2</artifactId>
<version>1</version>
</dependency>
</dependencies>
<!-- This is an invalid repositories section, which would trip up the model parser
if it were used in strict mode, or if the handling of the strict-mode flag
doesn't apply to association lists.
Dependency POMs should always be parsed in non-strict mode, so this
shouldn't prevent the inclusion of the above dependency.
-->
<repositories>
<id>imaginary-repo</id>
<url>http://repository.imaginary/</url>
</repositories>
</project>

View File

@ -1 +0,0 @@
624ade12bfc6d4f4b651626cf9009700

View File

@ -1 +0,0 @@
f4f142d0469c316b1ee67c05445415ec8ff38e4e

View File

@ -1,16 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tests</groupId>
<artifactId>dep-L2</artifactId>
<packaging>jar</packaging>
<version>1</version>
<name>dep-L2</name>
<distributionManagement>
<repository>
<id>dep-repo</id>
<url>file://${pom.basedir}/..</url>
</repository>
</distributionManagement>
</project>

View File

@ -1 +0,0 @@
980a7b547686732abf321a5c17c95fb1

View File

@ -1 +0,0 @@
cce03f3942f7aadaee9ed0e8f4cf384fa4fed319

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>tests</groupId>
<artifactId>dep-L2</artifactId>
<version>1</version>
<versioning>
<versions>
<version>1</version>
</versions>
<lastUpdated>20080725163900</lastUpdated>
</versioning>
</metadata>

View File

@ -1 +0,0 @@
daa840dd62763fc61fdf6d78ef6c7da3

View File

@ -1 +0,0 @@
3f10e68aeceeb95476ec0b0ba3ed2be3ab245be9

View File

@ -1,28 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3680</groupId>
<artifactId>maven-mng3680-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1</version>
<name>maven-mng3680-plugin Maven Mojo</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0.9</version>
</dependency>
</dependencies>
</project>

View File

@ -1,79 +0,0 @@
package plugin;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
/**
* Goal which touches a timestamp file.
*
* @goal check
* @requiresDependencyResolution compile
* @phase validate
*/
public class MyMojo
extends AbstractMojo
{
/**
* @parameter expression="${project.compileArtifacts}"
* @required
*/
private List artifacts;
public void execute()
throws MojoExecutionException
{
boolean foundL1 = false;
boolean foundL2 = false;
if ( artifacts != null )
{
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
{
Artifact artifact = (Artifact) it.next();
if ( !foundL1 && artifact.getArtifactId().equals( "dep-L1" ) )
{
foundL1 = true;
}
else if ( !foundL2 && artifact.getArtifactId().equals( "dep-L2" ) )
{
foundL2 = true;
}
if ( foundL1 && foundL2 )
{
break;
}
}
}
if ( !foundL1 || !foundL2 )
{
throw new MojoExecutionException( "Didn't find the following artifacts: " + ( foundL1 ? "" : "\n- dep-L1" )
+ ( foundL2 ? "" : "\n- dep-L2" ) );
}
}
}

View File

@ -1,45 +1,54 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3680</groupId> <groupId>org.apache.maven.its.mng3680</groupId>
<artifactId>mng-3680-invalidDependencyPOM</artifactId> <artifactId>test</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1</version> <version>1</version>
<name>mng-3680-invalidDependencyPOM</name>
<name>Maven Integration Test :: MNG-3680</name>
<description>
Verify that dependencies with invalid POMs can still be used without failing the build.
</description>
<repositories> <repositories>
<repository> <repository>
<id>dep-repo</id> <id>maven-core-it</id>
<url>file://${pom.basedir}/dep-repo</url> <url>file:///${basedir}/repo</url>
<releases>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <!-- This has a broken POM, yet it's dependencies should contribute to this build -->
<artifactId>junit</artifactId> <groupId>org.apache.maven.its.mng3680</groupId>
<version>3.8.1</version> <artifactId>direct</artifactId>
<scope>test</scope> <version>0.1</version>
</dependency>
<dependency>
<groupId>tests</groupId>
<artifactId>dep-L1</artifactId>
<version>1</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.its.mng3680</groupId> <groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-mng3680-plugin</artifactId> <artifactId>maven-it-plugin-dependency-resolution</artifactId>
<version>1</version> <version>2.1-SNAPSHOT</version>
<executions> <executions>
<execution> <execution>
<id>check-deps</id> <id>test</id>
<phase>validate</phase> <phase>validate</phase>
<configuration>
<testArtifacts>target/artifacts.txt</testArtifacts>
</configuration>
<goals> <goals>
<goal>check</goal> <goal>test</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3680</groupId>
<artifactId>direct</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng3680</groupId>
<artifactId>transitive</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
<!--
This is an invalid repositories section (missing <repository> element), which would trip up the model parser
if it were used in strict mode, or if the handling of the strict-mode flag
doesn't apply to association lists.
Dependency POMs should always be parsed in non-strict mode, so this
shouldn't prevent the inclusion of the above dependency.
-->
<repositories>
<id>imaginary-repo</id>
<url>http://repository.imaginary/</url>
</repositories>
<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>
</project>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?><metadata>
<groupId>org.apache.maven.its.mng3680</groupId>
<artifactId>direct</artifactId>
<version>0.1</version>
<versioning>
<versions>
<version>0.1</version>
</versions>
<lastUpdated>20090113200208</lastUpdated>
</versioning>
</metadata>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3680</groupId>
<artifactId>transitive</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>
</project>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?><metadata>
<groupId>org.apache.maven.its.mng3680</groupId>
<artifactId>transitive</artifactId>
<version>0.1</version>
<versioning>
<versions>
<version>0.1</version>
</versions>
<lastUpdated>20090113200129</lastUpdated>
</versioning>
</metadata>

View File

@ -1,15 +0,0 @@
package tests;
import tests.level2.AppLevel2;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -1,38 +0,0 @@
package tests;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}