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 2019/01/11 21:33:44 UTC

[maven] branch MNG-6558 created (now cebeef1)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch MNG-6558
in repository https://gitbox.apache.org/repos/asf/maven.git.


      at cebeef1  [MNG-6558] - ToolchainsBuildingResult event is not sent on EventSpy

This branch includes the following new commits:

     new cebeef1  [MNG-6558] - ToolchainsBuildingResult event is not sent on EventSpy

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven] 01/01: [MNG-6558] - ToolchainsBuildingResult event is not sent on EventSpy

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MNG-6558
in repository https://gitbox.apache.org/repos/asf/maven.git

commit cebeef122fd628ac6a6b3317bb7a9cba2db45935
Author: Guy Brand <gu...@guymas.ch>
AuthorDate: Fri Jan 11 09:08:42 2019 +0100

    [MNG-6558] - ToolchainsBuildingResult event is not sent on EventSpy
    
    Fixes #231
---
 .../main/java/org/apache/maven/cli/MavenCli.java   |  6 ++--
 .../java/org/apache/maven/cli/MavenCliTest.java    | 38 ++++++++++++++++++++++
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index f7ceda2..b99783d 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -596,7 +596,7 @@ public class MavenCli
         populateProperties( cliRequest.commandLine, cliRequest.systemProperties, cliRequest.userProperties );
     }
 
-    private PlexusContainer container( CliRequest cliRequest )
+    PlexusContainer container( CliRequest cliRequest )
         throws Exception
     {
         if ( cliRequest.classWorld == null )
@@ -1201,7 +1201,7 @@ public class MavenCli
         }
     }
 
-    private void toolchains( CliRequest cliRequest )
+    void toolchains( CliRequest cliRequest )
         throws Exception
     {
         File userToolchainsFile;
@@ -1265,7 +1265,7 @@ public class MavenCli
 
         ToolchainsBuildingResult toolchainsResult = toolchainsBuilder.build( toolchainsRequest );
 
-        eventSpyDispatcher.onEvent( toolchainsRequest );
+        eventSpyDispatcher.onEvent( toolchainsResult );
 
         executionRequestPopulator.populateFromToolchains( cliRequest.request,
                                                           toolchainsResult.getEffectiveToolchains() );
diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
index 433c949..5f4c5b6 100644
--- a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
+++ b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
@@ -24,14 +24,24 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
 
 import java.io.File;
 
 import org.apache.commons.cli.ParseException;
+import org.apache.maven.Maven;
+import org.apache.maven.eventspy.internal.EventSpyDispatcher;
 import org.apache.maven.shared.utils.logging.MessageUtils;
+import org.apache.maven.toolchain.building.ToolchainsBuildingRequest;
+import org.apache.maven.toolchain.building.ToolchainsBuildingResult;
+import org.codehaus.plexus.PlexusContainer;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.InOrder;
 
 public class MavenCliTest
 {
@@ -293,4 +303,32 @@ public class MavenCliTest
             // noop
         }
     }
+
+    /**
+     * Verifies MNG-6558
+     */
+    @Test
+    public void testToolchainsBuildingEvents() throws Exception {
+        final EventSpyDispatcher eventSpyDispatcherMock = mock(EventSpyDispatcher.class);
+        MavenCli customizedMavenCli = new MavenCli() {
+            @Override
+            protected void customizeContainer(PlexusContainer container) {
+                super.customizeContainer(container);
+                container.addComponent(eventSpyDispatcherMock, "org.apache.maven.eventspy.internal.EventSpyDispatcher");
+                container.addComponent(mock(Maven.class), "org.apache.maven.Maven");
+            }
+        };
+
+        CliRequest cliRequest = new CliRequest(new String[]{}, null);
+
+        customizedMavenCli.cli(cliRequest);
+        customizedMavenCli.logging(cliRequest);
+        customizedMavenCli.container(cliRequest);
+        customizedMavenCli.toolchains(cliRequest);
+
+        InOrder orderdEventSpyDispatcherMock = inOrder(eventSpyDispatcherMock);
+        orderdEventSpyDispatcherMock.verify(eventSpyDispatcherMock, times(1)).onEvent(any(ToolchainsBuildingRequest.class));
+        orderdEventSpyDispatcherMock.verify(eventSpyDispatcherMock, times(1)).onEvent(any(ToolchainsBuildingResult.class));
+    }
+
 }