maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject [4/7] maven git commit: [MNG-6308] added unit test for "Building" message
Date Wed, 17 Jan 2018 18:16:29 GMT
[MNG-6308] added unit test for "Building" message

Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/98d2e197
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/98d2e197
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/98d2e197

Branch: refs/heads/MNG-6298
Commit: 98d2e197d111d4863d1e420a9f9c1548690bc7e1
Parents: 68a9d79
Author: Hervé Boutemy <hboutemy@apache.org>
Authored: Sat Jan 6 22:07:17 2018 +0100
Committer: Hervé Boutemy <hboutemy@apache.org>
Committed: Sat Jan 6 22:40:29 2018 +0100

----------------------------------------------------------------------
 maven-embedder/pom.xml                          |  4 +
 .../cli/event/ExecutionEventLoggerTest.java     | 78 ++++++++++++++++++++
 2 files changed, 82 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/98d2e197/maven-embedder/pom.xml
----------------------------------------------------------------------
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index d6576f9..cfc126f 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -139,6 +139,10 @@ under the License.
       <artifactId>commons-lang3</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.fusesource.jansi</groupId>
       <artifactId>jansi</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/maven/blob/98d2e197/maven-embedder/src/test/java/org/apache/maven/cli/event/ExecutionEventLoggerTest.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/event/ExecutionEventLoggerTest.java
b/maven-embedder/src/test/java/org/apache/maven/cli/event/ExecutionEventLoggerTest.java
new file mode 100644
index 0000000..515f9fe
--- /dev/null
+++ b/maven-embedder/src/test/java/org/apache/maven/cli/event/ExecutionEventLoggerTest.java
@@ -0,0 +1,78 @@
+package org.apache.maven.cli.event;
+
+/*
+ * 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 static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.maven.execution.ExecutionEvent;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.utils.logging.MessageUtils;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.InOrder;
+import org.slf4j.Logger;
+
+public class ExecutionEventLoggerTest
+{
+    private ExecutionEventLogger executionEventLogger;
+
+    @BeforeClass
+    public static void setUp() 
+    {
+        MessageUtils.setColorEnabled( false );
+    }
+
+    @AfterClass
+    public static void tearDown()
+    {
+        MessageUtils.setColorEnabled( true );
+    }
+
+    @Test
+    public void testProjectStarted()
+    {
+        // prepare
+        Logger logger = mock( Logger.class );
+        when( logger.isInfoEnabled() ).thenReturn( true );
+        executionEventLogger = new ExecutionEventLogger( logger );
+
+        ExecutionEvent event = mock( ExecutionEvent.class );
+        MavenProject project = mock( MavenProject.class );
+        when( project.getGroupId() ).thenReturn( "org.apache.maven" );
+        when( project.getArtifactId() ).thenReturn( "maven-embedder" );
+        when( project.getPackaging() ).thenReturn( "jar" );
+        when( project.getName() ).thenReturn( "Apache Maven Embedder" );
+        when( project.getVersion() ).thenReturn( "3.5.4-SNAPSHOT" );
+        when( event.getProject() ).thenReturn( project );
+
+        // execute
+        executionEventLogger.projectStarted( event );
+
+        // verify
+        InOrder inOrder = inOrder( logger );
+        inOrder.verify( logger ).info( "" );
+        inOrder.verify( logger ).info( "------------------------------------------------------------------------"
);
+        inOrder.verify( logger ).info( "Building Apache Maven Embedder 3.5.4-SNAPSHOT" );
+        inOrder.verify( logger ).info( "------------------------------------------------------------------------"
);
+    }
+}


Mime
View raw message