Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests for various JIRA issues. #20

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
849a1bd
[MNG-5359] Declared execution in PluginMgmt gets bound to lifecycle (…
ChristianSchulte Dec 20, 2015
d6d0e05
[MNG-4463] Dependency management import should support version ranges.
ChristianSchulte Jan 30, 2016
b440c1c
[MNG-5527] Dependency management import should support relocations.
ChristianSchulte Jun 22, 2016
d02d27f
[MNG-5600] Dependency management import should support exclusions.
ChristianSchulte Jun 19, 2016
33dbd8c
[MNG-5971] Imported dependencies should be available to inheritance p…
ChristianSchulte Feb 20, 2016
f6c0cc8
[MNG-6079] 3.4 regression: cannot override version of a dependencyMan…
ChristianSchulte Aug 13, 2016
0f2a207
[MNG-5227] The 'optional' flag of a dependency should be manageable.
ChristianSchulte Jan 27, 2016
cda6c80
[MNG-5761] Dependency management is not transitive.
ChristianSchulte Dec 13, 2016
3d0045f
[MNG-6135] Maven plugins and core extensions are not dependencies, th…
ChristianSchulte Dec 19, 2016
c22eddb
MNG-6210 shortened test project file names
ifedorenko May 7, 2017
8015782
[MNG-6223] support -f path/to/dir when detecting .mvn
hboutemy May 6, 2017
ac1deaf
[MNG-6229] Write out optionality in Core IT Plugins for collection an…
michael-o May 9, 2017
12d35b1
[MNG-5935] Optional true getting lost in managed dependencies when tr…
michael-o May 9, 2017
2081280
Expect fail for MNG-947 with Maven 3.0.5
michael-o May 13, 2017
a1f2b33
Remove superfluous Eclipse configuration files
michael-o May 24, 2017
b9c8632
[MNG-6084] Support JSR 250 annotations
Sep 12, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,23 @@ public static Test suite()
// -------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137

suite.addTestSuite( MavenITmng5227DependencyOptionalFlagManagementTest.class );
suite.addTestSuite( MavenITmng6079DependencyManagementImportInterpolationTest.class );
suite.addTestSuite( MavenITmng5971HierarchicalImportScopeTest.class );
suite.addTestSuite( MavenITmng5600DependencyManagementImportExclusionsTest.class );
suite.addTestSuite( MavenITmng5527DependencyManagementImportRelocationsTest.class );
suite.addTestSuite( MavenITmng4463DependencyManagementImportVersionRanges.class );
suite.addTestSuite( MavenITmng5359CleanPluginExecutionDeclarationInPluginMgmtTest.class );
suite.addTestSuite( MavenITmng6223FindBasedir.class );
suite.addTestSuite( MavenITmng6189SiteReportPluginsWarningTest.class );
suite.addTestSuite( MavenITmng6057CheckReactorOrderTest.class );
suite.addTestSuite( MavenITmng5895CIFriendlyUsageWithPropertyTest.class );
suite.addTestSuite( MavenITmng6090CIFriendlyTest.class );
suite.addTestSuite( MavenITmng6084Jsr250PluginTest.class );
suite.addTestSuite( MavenITmng6173GetProjectsAndDependencyGraphTest.class );
suite.addTestSuite( MavenITmng6173GetAllProjectsInReactorTest.class );
suite.addTestSuite( MavenITmng5958LifecyclePhaseBinaryCompat.class );
suite.addTestSuite( MavenITmng5935OptionalLostInTranstiveManagedDependenciesTest.class );
suite.addTestSuite( MavenITmng5898BuildMultimoduleWithEARFailsToResolveWARTest.class );
suite.addTestSuite( MavenITmng5889FindBasedir.class );
suite.addTestSuite( MavenITmng5840ParentVersionRanges.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-947">MNG-947</a>.
*
*
* @author Benjamin Bentmann
*/
public class MavenITmng0947OptionalDependencyTest
Expand All @@ -46,6 +46,8 @@ public MavenITmng0947OptionalDependencyTest()
public void testit()
throws Exception
{
failingMavenVersions( "(,3.1.0-alpha-1)" );

File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0947" );

Verifier verifier = newVerifier( testDir.getAbsolutePath() );
Expand All @@ -60,20 +62,20 @@ public void testit()
verifier.resetStreams();

List<String> compile = verifier.loadLines( "target/compile.txt", "UTF-8" );
assertTrue( compile.toString(), compile.contains( "org.apache.maven.its.mng0947:d:jar:0.1" ) );
assertTrue( compile.toString(), compile.contains( "org.apache.maven.its.mng0947:e:jar:0.1" ) );
assertTrue( compile.toString(), compile.contains( "org.apache.maven.its.mng0947:d:jar:0.1 (optional)" ) );
assertTrue( compile.toString(), compile.contains( "org.apache.maven.its.mng0947:e:jar:0.1 (optional)" ) );
assertEquals( 2, compile.size() );

List<String> runtime = verifier.loadLines( "target/runtime.txt", "UTF-8" );
assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:c:jar:0.1" ) );
assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:d:jar:0.1" ) );
assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:e:jar:0.1" ) );
assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:d:jar:0.1 (optional)" ) );
assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:e:jar:0.1 (optional)" ) );
assertEquals( 3, runtime.size() );

List<String> test = verifier.loadLines( "target/test.txt", "UTF-8" );
assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:c:jar:0.1" ) );
assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:d:jar:0.1" ) );
assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:e:jar:0.1" ) );
assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:d:jar:0.1 (optional)" ) );
assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:e:jar:0.1 (optional)" ) );
assertEquals( 3, test.size() );
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright 2016 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.
*/
package org.apache.maven.it;

import java.io.File;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.maven.it.util.ResourceExtractor;
import static junit.framework.Assert.assertTrue;

/**
* Integration tests for <a href="https://issues.apache.org/jira/browse/MNG-4463">MNG-4463</a>.
*
* @author Christian Schulte
*/
public class MavenITmng4463DependencyManagementImportVersionRanges
extends AbstractMavenIntegrationTestCase
{

public MavenITmng4463DependencyManagementImportVersionRanges()
{
super( "[3.4.0,)" );
}

public void testInclusiveUpperBoundResolvesToHighestVersion()
throws Exception
{
final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4463/inclusive-upper-bound" );
final Verifier verifier = newVerifier( testDir.getAbsolutePath(), "remote" );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();

final List<String> artifacts = verifier.loadLines( "target/compile.txt", "UTF-8" );
assertTrue( artifacts.toString(), artifacts.contains( "org.apache.maven:maven-plugin-api:jar:3.0" ) );
}

public void testExclusiveUpperBoundResolvesToHighestVersion()
throws Exception
{
final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4463/exclusive-upper-bound" );
final Verifier verifier = newVerifier( testDir.getAbsolutePath(), "remote" );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();

List<String> artifacts = verifier.loadLines( "target/compile.txt", "UTF-8" );
assertTrue( artifacts.toString(), artifacts.contains( "org.apache.maven:maven-plugin-api:jar:3.0" ) );
}

public void testFailureWithoutUpperBound()
throws Exception
{
final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4463/no-upper-bound" );
final Verifier verifier = newVerifier( testDir.getAbsolutePath(), "remote" );

try
{
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
fail( "Expected 'VerificationException' not thrown." );
}
catch ( final VerificationException e )
{
final List<String> lines = verifier.loadFile( new File( testDir, "log.txt" ), false );
assertTrue( "Expected error message not found.",
indexOf( lines, ".*dependency version range.*does not specify an upper bound.*" ) >= 0 );
}
finally
{
verifier.resetStreams();
}
}

private static int indexOf( final List<String> logLines, final String regex )
{
final Pattern pattern = Pattern.compile( regex );

for ( int i = 0, l0 = logLines.size(); i < l0; i++ )
{
if ( pattern.matcher( logLines.get( i ) ).matches() )
{
return i;
}
}

return -1;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public MavenITmng4600DependencyOptionalFlagManagementTest()
public void testitModel()
throws Exception
{
failingMavenVersions( "[3.4.0-alpha,)" );

File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4600/model" );

Verifier verifier = newVerifier( testDir.getAbsolutePath() );
Expand All @@ -68,6 +70,8 @@ public void testitModel()
public void testitResolution()
throws Exception
{
failingMavenVersions( "[3.4.0-alpha,)" );

File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4600/resolution" );

Verifier verifier = newVerifier( testDir.getAbsolutePath() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4720">MNG-4720</a>.
*
*
* @author Benjamin Bentmann
*/
public class MavenITmng4720DependencyManagementExclusionMergeTest
Expand All @@ -43,9 +43,11 @@ public MavenITmng4720DependencyManagementExclusionMergeTest()
* Verify the effective exclusions applied during transitive dependency resolution when both the regular
* dependency section and dependency management declare exclusions for a particular dependency.
*/
public void testit()
public void testitMaven2Compat()
throws Exception
{
// Gave up on Maven 2 compat in 3.4.
failingMavenVersions( "[3.4.0,)" );
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4720" );

Verifier verifier = newVerifier( testDir.getAbsolutePath() );
Expand All @@ -65,8 +67,37 @@ public void testit()

assertFalse( classpath.toString(), classpath.contains( "b-0.1.jar" ) );

// should better have been excluded as well, now it's a matter of backward-compat
// This comment is obsolete as of 3.6: should better have been excluded as well, now it's a matter of backward-compat
assertTrue( classpath.toString(), classpath.contains( "d-0.1.jar" ) );
}

/**
* Verify the effective exclusions applied during transitive dependency resolution when both the regular
* dependency section and dependency management declare exclusions for a particular dependency.
*/
public void testitMaven340()
throws Exception
{
failingMavenVersions( "(,3.4.0)" );
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4720" );

Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteArtifacts( "org.apache.maven.its.mng4720" );
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" );

assertTrue( classpath.toString(), classpath.contains( "a-0.1.jar" ) );
assertTrue( classpath.toString(), classpath.contains( "c-0.1.jar" ) );

assertFalse( classpath.toString(), classpath.contains( "b-0.1.jar" ) );
assertFalse( classpath.toString(), classpath.contains( "d-0.1.jar" ) );
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package org.apache.maven.it;

/*
* 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.
*/

import java.io.File;
import java.util.List;
import java.util.Properties;
import org.apache.maven.it.util.ResourceExtractor;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;

/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-5227">MNG-5227</a>.
*
* @author Christian Schulte
*/
public class MavenITmng5227DependencyOptionalFlagManagementTest
extends AbstractMavenIntegrationTestCase
{

public MavenITmng5227DependencyOptionalFlagManagementTest()
{
super( "[3.4.0,)" );
}

/**
* Verify that a dependency's optional flag is subject to dependency management. This part of the test checks
* the effective model.
*/
public void testitModel()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5227/model" );

Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();

Properties props = verifier.loadProperties( "target/pom.properties" );
assertEquals( "dep", props.getProperty( "project.dependencies.0.artifactId" ) );
assertEquals( "true", props.getProperty( "project.dependencies.0.optional" ) );
}

/**
* Verify that a transitive dependency's optional flag is subject to dependency management of the root artifat.
* This part of the test checks the artifact collector.
*/
public void testitResolution()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5227/resolution" );

Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.deleteArtifacts( "org.apache.maven.its.mng5227" );
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( "direct-0.2.jar" ) );
assertFalse( classpath.toString(), classpath.contains( "transitive-0.1.jar" ) );
}

}
Loading