mirror of https://github.com/apache/maven.git
[MNG-5716] IT to check ToolchainManagerPrivate.getToolchainsForType()
does not return toolchains that are not of expected type
This commit is contained in:
parent
08d65ae82b
commit
fb96423f46
|
@ -106,6 +106,7 @@ public class IntegrationTestSuite
|
|||
// -------------------------------------------------------------------------------------------------------------
|
||||
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
||||
|
||||
suite.addTestSuite( MavenITmng5716ToolchainsTypeTest.class );
|
||||
suite.addTestSuite( MavenITmng5663NestedImportScopePomResolutionTest.class );
|
||||
suite.addTestSuite( MavenITmng2562Timestamp322Test.class );
|
||||
suite.addTestSuite( MavenITmng2199ParentVersionRangeTest.class );
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
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 org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-5716">MNG-5716</a>.
|
||||
*
|
||||
* @author Hervé Boutemy
|
||||
*/
|
||||
public class MavenITmng5716ToolchainsTypeTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
public MavenITmng5716ToolchainsTypeTest()
|
||||
{
|
||||
super( "(3.2.3,)" );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void testitMNG5716()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5716-toolchains-type" );
|
||||
|
||||
File javaHome = new File( testDir, "javaHome" );
|
||||
javaHome.mkdirs();
|
||||
new File( javaHome, "bin" ).mkdirs();
|
||||
new File( javaHome, "bin/javac").createNewFile();
|
||||
new File( javaHome, "bin/javac.exe").createNewFile();
|
||||
|
||||
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
Properties properties = verifier.newDefaultFilterProperties();
|
||||
properties.setProperty( "@javaHome@", javaHome.getAbsolutePath() );
|
||||
|
||||
verifier.filterFile( "toolchains.xml", "toolchains.xml", "UTF-8", properties );
|
||||
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "target" );
|
||||
verifier.addCliOption( "--toolchains toolchains.xml" );
|
||||
verifier.executeGoal( "initialize" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
verifier.assertFilePresent( "target/toolchains.properties" );
|
||||
Properties results = verifier.loadProperties( "target/toolchains.properties" );
|
||||
assertNull( "javac tool should not be found for requested 'fake' toolchain", results.getProperty( "tool.1" ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?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.mng3714</groupId>
|
||||
<artifactId>test</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<name>Maven Integration Test :: MNG-5716</name>
|
||||
<description>Test Toolchain type returned by ToolchainManagerPrivate.getToolchainsForType()</description>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.its</groupId>
|
||||
<artifactId>core-it-toolchain</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-toolchain</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>select-toolchain</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>toolchain</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputFile>target/toolchains.properties</outputFile>
|
||||
<type>coreit</type><!-- no toolchain configured in toolchain.xml -->
|
||||
<selected>0</selected><!-- then selecting should not be ok -->
|
||||
<tool>javac</tool>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF8"?>
|
||||
|
||||
<toolchains>
|
||||
<toolchain>
|
||||
<type>jdk</type>
|
||||
<provides>
|
||||
<version>1.5</version>
|
||||
</provides>
|
||||
<configuration>
|
||||
<jdkHome>@javaHome@</jdkHome>
|
||||
</configuration>
|
||||
</toolchain>
|
||||
</toolchains>
|
||||
|
|
@ -32,7 +32,6 @@ import java.util.Properties;
|
|||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.toolchain.MisconfiguredToolchainException;
|
||||
import org.apache.maven.toolchain.ToolchainManagerPrivate;
|
||||
import org.apache.maven.toolchain.ToolchainPrivate;
|
||||
|
||||
|
@ -109,9 +108,9 @@ public class CoreItMojo
|
|||
Properties properties = new Properties();
|
||||
|
||||
int count = 1;
|
||||
for ( Iterator i = Arrays.asList( tcs ).iterator(); i.hasNext(); count++ )
|
||||
for ( Iterator<ToolchainPrivate> i = Arrays.<ToolchainPrivate>asList( tcs ).iterator(); i.hasNext(); count++ )
|
||||
{
|
||||
ToolchainPrivate toolchain = (ToolchainPrivate) i.next();
|
||||
ToolchainPrivate toolchain = i.next();
|
||||
|
||||
String foundTool = toolchain.findTool( tool );
|
||||
if ( foundTool != null )
|
||||
|
@ -150,7 +149,7 @@ public class CoreItMojo
|
|||
private ToolchainPrivate[] getToolchains()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
Class managerClass = toolchainManager.getClass();
|
||||
Class<? extends ToolchainManagerPrivate> managerClass = toolchainManager.getClass();
|
||||
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue