continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From batkin...@apache.org
Subject svn commit: r1659090 - in /continuum/trunk/continuum-base/continuum-scm: pom.xml src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java
Date Wed, 11 Feb 2015 21:27:58 GMT
Author: batkinson
Date: Wed Feb 11 21:27:58 2015
New Revision: 1659090

URL: http://svn.apache.org/r1659090
Log:
Converted continuum-scm tests to mockito.

Modified:
    continuum/trunk/continuum-base/continuum-scm/pom.xml
    continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java

Modified: continuum/trunk/continuum-base/continuum-scm/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/pom.xml?rev=1659090&r1=1659089&r2=1659090&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/pom.xml (original)
+++ continuum/trunk/continuum-base/continuum-scm/pom.xml Wed Feb 11 21:27:58 2015
@@ -90,29 +90,8 @@
       <artifactId>commons-lang</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.jmock</groupId>
-      <artifactId>jmock</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.jmock</groupId>
-      <artifactId>jmock-junit3</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.hamcrest</groupId>
-      <artifactId>hamcrest-core</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>cglib</groupId>
-      <artifactId>cglib-nodep</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.objenesis</groupId>
-      <artifactId>objenesis</artifactId>
-      <scope>test</scope>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
     </dependency>
   </dependencies>
   <build>

Modified: continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java?rev=1659090&r1=1659089&r2=1659090&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java
(original)
+++ continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java
Wed Feb 11 21:27:58 2015
@@ -23,39 +23,46 @@ import org.apache.continuum.scm.manager.
 import org.apache.maven.scm.ScmBranch;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmVersion;
+import org.apache.maven.scm.manager.NoSuchScmProviderException;
+import org.apache.maven.scm.provider.ScmProviderRepository;
 import org.apache.maven.scm.repository.ScmRepository;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.integration.junit3.JUnit3Mockery;
-import org.jmock.lib.legacy.ClassImposteriser;
+import org.apache.maven.scm.repository.ScmRepositoryException;
 import org.junit.Before;
 import org.junit.Test;
 
 import java.io.File;
 import java.util.Date;
 
+import static org.mockito.Mockito.*;
+
 public class DefaultContinuumScmTest
 {
     private ScmManager scmManager;
 
-    private DefaultContinuumScm continuumScm;
+    private ScmRepository scmRepository;
 
-    private Mockery context;
+    private ScmProviderRepository scmProviderRepository;
+
+    private DefaultContinuumScm continuumScm;
 
     private ContinuumScmConfiguration config;
 
     @Before
     public void setUp()
+        throws ScmRepositoryException, NoSuchScmProviderException
     {
-        context = new JUnit3Mockery();
-        context.setImposteriser( ClassImposteriser.INSTANCE );
+        config = new ContinuumScmConfiguration();
+        config.setWorkingDirectory( new File( "1" ) );
+        config.setUrl( "scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-clean-plugin"
);
 
-        scmManager = context.mock( ScmManager.class );
+        scmManager = mock( ScmManager.class );
+        scmRepository = mock( ScmRepository.class );
+        scmProviderRepository = mock( ScmProviderRepository.class );
+        when( scmManager.makeScmRepository( config.getUrl() ) ).thenReturn( scmRepository
);
+        when( scmRepository.getProviderRepository() ).thenReturn( scmProviderRepository );
 
         continuumScm = new DefaultContinuumScm();
         continuumScm.setScmManager( scmManager );
-
-        config = getScmConfiguration();
     }
 
     @Test
@@ -64,18 +71,10 @@ public class DefaultContinuumScmTest
     {
         config.setTag( "1.0-SNAPSHOT" );
 
-        context.checking( new Expectations()
-        {
-            {
-                one( scmManager ).makeScmRepository( config.getUrl() );
-                one( scmManager ).changeLog( with( any( ScmRepository.class ) ), with( any(
ScmFileSet.class ) ), with(
-                    any( ScmVersion.class ) ), with( any( ScmVersion.class ) ) );
-            }
-        } );
-
         continuumScm.changeLog( config );
 
-        context.assertIsSatisfied();
+        verify( scmManager ).changeLog( any( ScmRepository.class ), any( ScmFileSet.class
), any( ScmVersion.class ),
+                                        any( ScmVersion.class ) );
     }
 
     @Test
@@ -84,26 +83,10 @@ public class DefaultContinuumScmTest
     {
         config.setTag( "" );
 
-        context.checking( new Expectations()
-        {
-            {
-                one( scmManager ).makeScmRepository( config.getUrl() );
-                one( scmManager ).changeLog( with( any( ScmRepository.class ) ), with( any(
ScmFileSet.class ) ), with(
-                    any( Date.class ) ), with( aNull( Date.class ) ), with( equal( 0 ) ),
with( aNull(
-                    ScmBranch.class ) ), with( aNull( String.class ) ) );
-            }
-        } );
-
         continuumScm.changeLog( config );
-        context.assertIsSatisfied();
-    }
-
-    private ContinuumScmConfiguration getScmConfiguration()
-    {
-        ContinuumScmConfiguration config = new ContinuumScmConfiguration();
-        config.setWorkingDirectory( new File( "1" ) );
-        config.setUrl( "scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-clean-plugin"
);
 
-        return config;
+        verify( scmManager ).changeLog( any( ScmRepository.class ), any( ScmFileSet.class
), any( Date.class ),
+                                        isNull( Date.class ), eq( 0 ), isNull( ScmBranch.class
),
+                                        isNull( String.class ) );
     }
-}
+}
\ No newline at end of file



Mime
View raw message