You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/02/22 15:33:23 UTC
[maven-invoker-plugin] branch master updated: [MINVOKER-257] Test
code should meet checkstyle requirements
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 808d2d2 [MINVOKER-257] Test code should meet checkstyle requirements
808d2d2 is described below
commit 808d2d20f16771aa18ee87a53b52e70b031d53a0
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Sun Feb 16 12:08:39 2020 +0100
[MINVOKER-257] Test code should meet checkstyle requirements
Closes #13
---
pom.xml | 7 +++++
.../plugins/invoker/ExtendedMavenProjectStub.java | 3 ++-
.../maven/plugins/invoker/InterpolationTest.java | 2 --
.../maven/plugins/invoker/InvokerMojoTest.java | 28 ++++++++-----------
.../plugins/invoker/InvokerPropertiesTest.java | 31 ++++++++++++++--------
.../apache/maven/plugins/invoker/SelectorTest.java | 5 ++--
.../maven/plugins/invoker/SelectorUtilsTest.java | 22 +++++++++------
7 files changed, 57 insertions(+), 41 deletions(-)
diff --git a/pom.xml b/pom.xml
index 6dfe162..e00e084 100644
--- a/pom.xml
+++ b/pom.xml
@@ -261,6 +261,13 @@ under the License.
</excludes>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ </configuration>
+ </plugin>
</plugins>
</pluginManagement>
diff --git a/src/test/java/org/apache/maven/plugins/invoker/ExtendedMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/invoker/ExtendedMavenProjectStub.java
index 70397b5..50c6245 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/ExtendedMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/ExtendedMavenProjectStub.java
@@ -1,3 +1,5 @@
+package org.apache.maven.plugins.invoker;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.plugins.invoker;
import org.apache.maven.model.Scm;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
diff --git a/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java b/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java
index 6f1ceaa..1edcdb1 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java
@@ -29,8 +29,6 @@ import java.util.Properties;
import org.apache.maven.model.Scm;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.apache.maven.plugins.invoker.CompositeMap;
-import org.apache.maven.plugins.invoker.InvokerMojo;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java
index 41034ee..77656f4 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java
@@ -32,26 +32,24 @@ import org.apache.maven.settings.Settings;
* @author Olivier Lamy
* @since 18 nov. 07
*/
-public class InvokerMojoTest
- extends AbstractMojoTestCase
+public class InvokerMojoTest extends AbstractMojoTestCase
{
private MavenProject getMavenProject()
{
MavenProject mavenProject = new MavenProject();
- mavenProject.setFile(new File("target/foo.txt"));
+ mavenProject.setFile( new File( "target/foo.txt" ) );
return mavenProject;
}
- public void testSingleInvokerTest()
- throws Exception
+ public void testSingleInvokerTest() throws Exception
{
InvokerMojo invokerMojo = new InvokerMojo();
String dirPath = getBasedir() + "/src/test/resources/unit";
List<String> goals = invokerMojo.getGoals( new File( dirPath ) );
assertEquals( 1, goals.size() );
setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) );
- setVariableValueToObject( invokerMojo, "invokerPropertiesFile", "invoker.properties");
+ setVariableValueToObject( invokerMojo, "invokerPropertiesFile", "invoker.properties" );
setVariableValueToObject( invokerMojo, "project", getMavenProject() );
setVariableValueToObject( invokerMojo, "invokerTest", "*dummy*" );
setVariableValueToObject( invokerMojo, "settings", new Settings() );
@@ -59,15 +57,14 @@ public class InvokerMojoTest
assertEquals( 1, poms.size() );
}
- public void testMultiInvokerTest()
- throws Exception
+ public void testMultiInvokerTest() throws Exception
{
InvokerMojo invokerMojo = new InvokerMojo();
String dirPath = getBasedir() + "/src/test/resources/unit";
List<String> goals = invokerMojo.getGoals( new File( dirPath ) );
assertEquals( 1, goals.size() );
setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) );
- setVariableValueToObject( invokerMojo, "invokerPropertiesFile", "invoker.properties");
+ setVariableValueToObject( invokerMojo, "invokerPropertiesFile", "invoker.properties" );
setVariableValueToObject( invokerMojo, "project", getMavenProject() );
setVariableValueToObject( invokerMojo, "invokerTest", "*dummy*,*terpolatio*" );
setVariableValueToObject( invokerMojo, "settings", new Settings() );
@@ -75,15 +72,14 @@ public class InvokerMojoTest
assertEquals( 2, poms.size() );
}
- public void testFullPatternInvokerTest()
- throws Exception
+ public void testFullPatternInvokerTest() throws Exception
{
InvokerMojo invokerMojo = new InvokerMojo();
String dirPath = getBasedir() + "/src/test/resources/unit";
List<String> goals = invokerMojo.getGoals( new File( dirPath ) );
assertEquals( 1, goals.size() );
setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) );
- setVariableValueToObject( invokerMojo, "invokerPropertiesFile", "invoker.properties");
+ setVariableValueToObject( invokerMojo, "invokerPropertiesFile", "invoker.properties" );
setVariableValueToObject( invokerMojo, "project", getMavenProject() );
setVariableValueToObject( invokerMojo, "invokerTest", "*" );
setVariableValueToObject( invokerMojo, "settings", new Settings() );
@@ -92,17 +88,15 @@ public class InvokerMojoTest
}
public void testAlreadyCloned()
- throws Exception
{
assertFalse( AbstractInvokerMojo.alreadyCloned( "dir", Collections.<String>emptyList() ) );
assertTrue( AbstractInvokerMojo.alreadyCloned( "dir", Collections.singletonList( "dir" ) ) );
assertTrue( AbstractInvokerMojo.alreadyCloned( "dir" + File.separator + "sub",
- Collections.singletonList( "dir" ) ) );
+ Collections.singletonList( "dir" ) ) );
assertFalse( AbstractInvokerMojo.alreadyCloned( "dirs", Collections.singletonList( "dir" ) ) );
}
- public void testParallelThreadsSettings()
- throws IllegalAccessException
+ public void testParallelThreadsSettings() throws IllegalAccessException
{
Object[][] testValues = {
{"4", 4},
@@ -112,7 +106,7 @@ public class InvokerMojoTest
InvokerMojo invokerMojo = new InvokerMojo();
- for ( Object[] testValue: testValues )
+ for ( Object[] testValue : testValues )
{
String parallelThreads = (String) testValue[0];
int expectedParallelThreads = (Integer) testValue[1];
diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
index b58766c..a492168 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
@@ -1,13 +1,22 @@
package org.apache.maven.plugins.invoker;
/*
- * 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.
+ * 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;
@@ -15,9 +24,9 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Properties;
-import org.apache.maven.plugins.invoker.InvokerProperties;
import org.apache.maven.shared.invoker.DefaultInvocationRequest;
import org.apache.maven.shared.invoker.InvocationRequest;
+import org.apache.maven.shared.invoker.InvocationRequest.ReactorFailureBehavior;
import junit.framework.TestCase;
@@ -196,11 +205,11 @@ public class InvokerPropertiesTest
InvocationRequest request = new DefaultInvocationRequest();
- request.setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailAtEnd );
+ request.setReactorFailureBehavior( ReactorFailureBehavior.FailAtEnd );
facade.configureInvocation( request, 0 );
- assertEquals( InvocationRequest.ReactorFailureBehavior.FailAtEnd, request.getReactorFailureBehavior() );
+ assertEquals( ReactorFailureBehavior.FailAtEnd, request.getReactorFailureBehavior() );
- props.setProperty( "invoker.failureBehavior", InvocationRequest.ReactorFailureBehavior.FailNever.getLongOption() );
+ props.setProperty( "invoker.failureBehavior", ReactorFailureBehavior.FailNever.getLongOption() );
facade.configureInvocation( request, 0 );
assertEquals( "fail-never", request.getReactorFailureBehavior().getLongOption() );
}
diff --git a/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java b/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java
index bd79a5a..8efa496 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java
@@ -22,10 +22,11 @@ package org.apache.maven.plugins.invoker;
import static org.junit.Assert.assertEquals;
import java.util.Properties;
-import org.apache.maven.plugins.invoker.InvokerProperties;
-import org.apache.maven.plugins.invoker.Selector;
import org.junit.Test;
+/**
+ * Test for {@link Selector}.
+ */
public class SelectorTest
{
@Test
diff --git a/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java b/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java
index 785f974..bdeff50 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java
@@ -114,25 +114,31 @@ public class SelectorUtilsTest
ToolchainPrivateManager toolchainPrivateManager = mock( ToolchainPrivateManager.class );
ToolchainPrivate jdkMatching = mock( ToolchainPrivate.class );
when( jdkMatching.matchesRequirements( isA( Map.class ) ) ).thenReturn( true );
- when( jdkMatching.getType() ).thenReturn( "jdk");
+ when( jdkMatching.getType() ).thenReturn( "jdk" );
ToolchainPrivate jdkMismatch = mock( ToolchainPrivate.class );
- when( jdkMismatch.getType() ).thenReturn( "jdk");
+ when( jdkMismatch.getType() ).thenReturn( "jdk" );
- when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) ).thenReturn( new ToolchainPrivate[] { jdkMatching } );
+ when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) )
+ .thenReturn( new ToolchainPrivate[] { jdkMatching } );
assertTrue( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) );
- when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) ).thenReturn( new ToolchainPrivate[] { jdkMismatch } );
+ when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) )
+ .thenReturn( new ToolchainPrivate[] { jdkMismatch } );
assertFalse( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) );
- when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) ).thenReturn( new ToolchainPrivate[] { jdkMatching, jdkMismatch, jdkMatching } );
+ when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) )
+ .thenReturn( new ToolchainPrivate[] { jdkMatching, jdkMismatch, jdkMatching } );
assertTrue( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) );
- when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) ).thenReturn( new ToolchainPrivate[0] );
+ when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) )
+ .thenReturn( new ToolchainPrivate[0] );
assertFalse( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) );
- when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) ).thenReturn( new ToolchainPrivate[] { jdkMatching } );
- when( toolchainPrivateManager.getToolchainPrivates( "maven" ) ).thenReturn( new ToolchainPrivate[0] );
+ when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) )
+ .thenReturn( new ToolchainPrivate[] { jdkMatching } );
+ when( toolchainPrivateManager.getToolchainPrivates( "maven" ) )
+ .thenReturn( new ToolchainPrivate[0] );
assertFalse( SelectorUtils.isToolchain( toolchainPrivateManager, Arrays.asList( openJdk9, maven360 ) ) );
}