You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/02/28 17:33:43 UTC

[GitHub] [maven-invoker-plugin] slawekjaranowski commented on a change in pull request #104: [MINVOKER-297] NPE when non-existing Maven Home

slawekjaranowski commented on a change in pull request #104:
URL: https://github.com/apache/maven-invoker-plugin/pull/104#discussion_r816106236



##########
File path: src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java
##########
@@ -120,26 +124,45 @@ public void testIsMatchingToolchain() throws Exception
         when( jdkMismatch.getType() ).thenReturn( "jdk" );
 
         when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) )
-                .thenReturn( new ToolchainPrivate[] { jdkMatching } );
+            .thenReturn( new ToolchainPrivate[] {jdkMatching} );
         assertTrue( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) );
 
         when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) )
-                .thenReturn( new ToolchainPrivate[] { jdkMismatch } );
+            .thenReturn( new ToolchainPrivate[] {jdkMismatch} );
         assertFalse( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) );
 
         when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) )
-                .thenReturn( new ToolchainPrivate[] { jdkMatching, jdkMismatch, jdkMatching } );
+            .thenReturn( new ToolchainPrivate[] {jdkMatching, jdkMismatch, jdkMatching} );
         assertTrue( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) );
 
         when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) )
-                .thenReturn( new ToolchainPrivate[0] );
+            .thenReturn( new ToolchainPrivate[0] );
         assertFalse( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) );
 
         when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) )
-                .thenReturn( new ToolchainPrivate[] { jdkMatching } );
+            .thenReturn( new ToolchainPrivate[] {jdkMatching} );
         when( toolchainPrivateManager.getToolchainPrivates( "maven" ) )
-                .thenReturn( new ToolchainPrivate[0] );
+            .thenReturn( new ToolchainPrivate[0] );
         assertFalse( SelectorUtils.isToolchain( toolchainPrivateManager, Arrays.asList( openJdk9, maven360 ) ) );
     }
 
+    @Test
+    public void mavenVersionForNotExistingMavenHomeThrowException()
+    {
+        File mavenHome = new File( "not-existing-path" );
+
+        assertThatCode( () -> SelectorUtils.getMavenVersion( mavenHome ) )
+            .isExactlyInstanceOf( IOException.class )

Review comment:
       fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org