continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From batkin...@apache.org
Subject svn commit: r1659087 - /continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
Date Wed, 11 Feb 2015 21:27:47 GMT
Author: batkinson
Date: Wed Feb 11 21:27:47 2015
New Revision: 1659087

URL: http://svn.apache.org/r1659087
Log:
Converted continuum-core test to mockito.

Modified:
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java?rev=1659087&r1=1659086&r2=1659087&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
Wed Feb 11 21:27:47 2015
@@ -19,6 +19,7 @@ package org.apache.maven.continuum.core.
  * under the License.
  */
 
+import junit.framework.TestCase;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
@@ -32,16 +33,18 @@ import org.apache.maven.settings.Setting
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.console.ConsoleLogger;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
-import org.jmock.Mock;
-import org.jmock.MockObjectTestCase;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
+import java.io.IOException;
+import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
+import static org.mockito.Mockito.*;
+
 public class CreateProjectsFromMetadataTest
-    extends MockObjectTestCase
+    extends TestCase
 {
-
     private CreateProjectsFromMetadataAction action;
 
     private ContinuumProjectBuildingResult result;
@@ -53,32 +56,25 @@ public class CreateProjectsFromMetadataT
         action = new CreateProjectsFromMetadataAction();
         action.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "" ) );
 
-        recordBuildProjectFromHttp();
-    }
-
-    private void recordBuildProjectFromHttp()
-        throws Exception
-    {
         result = new ContinuumProjectBuildingResult();
-        Mock projectBuilderManagerMock = mock( ContinuumProjectBuilderManager.class );
-
-        action.setProjectBuilderManager( (ContinuumProjectBuilderManager) projectBuilderManagerMock.proxy()
);
+        ContinuumProjectBuilderManager projectBuilderManagerMock = mock( ContinuumProjectBuilderManager.class
);
+        action.setProjectBuilderManager( projectBuilderManagerMock );
         action.setUrlValidator( new ContinuumUrlValidator() );
 
-        Mock projectBuilder = mock( ContinuumProjectBuilder.class );
-
-        projectBuilderManagerMock.expects( once() ).method( "getProjectBuilder" ).will( returnValue(
-            projectBuilder.proxy() ) );
-        projectBuilder.expects( once() ).method( "buildProjectsFromMetadata" ).will( returnValue(
result ) );
-        projectBuilder.expects( once() ).method( "getDefaultBuildDefinitionTemplate" ).will(
returnValue(
-            getDefaultBuildDefinitionTemplate() ) );
+        ContinuumProjectBuilder projectBuilder = mock( ContinuumProjectBuilder.class );
+        when( projectBuilderManagerMock.getProjectBuilder( anyString() ) ).thenReturn( projectBuilder
);
+        when( projectBuilder.buildProjectsFromMetadata( any( URL.class ), anyString(), anyString(),
anyBoolean(),
+                                                        any( BuildDefinitionTemplate.class
), anyBoolean(),
+                                                        anyInt() ) ).thenReturn( result );
+        when( projectBuilder.getDefaultBuildDefinitionTemplate() ).thenReturn( getDefaultBuildDefinitionTemplate()
);
     }
 
     private void invokeBuildSettings()
+        throws IOException, XmlPullParserException
     {
-        Mock mavenSettingsBuilderMock = mock( MavenSettingsBuilder.class );
-        action.setMavenSettingsBuilder( (MavenSettingsBuilder) mavenSettingsBuilderMock.proxy()
);
-        mavenSettingsBuilderMock.expects( once() ).method( "buildSettings" ).will( returnValue(
new Settings() ) );
+        MavenSettingsBuilder mavenSettingsBuilderMock = mock( MavenSettingsBuilder.class
);
+        action.setMavenSettingsBuilder( mavenSettingsBuilderMock );
+        when( mavenSettingsBuilderMock.buildSettings() ).thenReturn( new Settings() );
     }
 
     private BuildDefinitionTemplate getDefaultBuildDefinitionTemplate()
@@ -144,7 +140,6 @@ public class CreateProjectsFromMetadataT
             result.hasErrors() );
     }
 
-
     public void testExecuteWithCheckoutProjectsInSingleDirectory()
         throws Exception
     {
@@ -195,7 +190,7 @@ public class CreateProjectsFromMetadataT
             result.hasErrors() );
         assertEquals( "Incorrect SCM Root Url for flat multi-module project.",
                       "scm:local:src/test-projects:flat-multi-module/", AbstractContinuumAction.getProjectScmRootUrl(
-            context, "" ) );
+                context, "" ) );
     }
 
     public void testExecuteFlatMultiModuleProjectThatStartsWithTheSameLetter()



Mime
View raw message