continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From batkin...@apache.org
Subject svn commit: r1659094 - in /continuum/trunk: ./ continuum-buildagent/continuum-buildagent-webdav/ continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/
Date Wed, 11 Feb 2015 21:28:16 GMT
Author: batkinson
Date: Wed Feb 11 21:28:16 2015
New Revision: 1659094

URL: http://svn.apache.org/r1659094
Log:
Converted webdav-buildagent tests from easymock to mockito.

Modified:
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/pom.xml
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceFactoryTest.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavSessionProviderTest.java
    continuum/trunk/pom.xml

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/pom.xml?rev=1659094&r1=1659093&r2=1659094&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/pom.xml (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/pom.xml Wed Feb 11 21:28:16
2015
@@ -85,9 +85,8 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>easymock</groupId>
-      <artifactId>easymock</artifactId>
-      <scope>test</scope>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
     </dependency>
   </dependencies>
   <build>

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceFactoryTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceFactoryTest.java?rev=1659094&r1=1659093&r2=1659094&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceFactoryTest.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceFactoryTest.java
Wed Feb 11 21:28:16 2015
@@ -22,27 +22,23 @@ package org.apache.continuum.webdav;
 import org.apache.commons.io.FileUtils;
 import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
 import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletRequest;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
-import org.easymock.MockControl;
 
 import java.io.File;
 
+import static org.mockito.Mockito.*;
+
 public class ContinuumBuildAgentDavResourceFactoryTest
     extends PlexusInSpringTestCase
 {
-    private MockControl requestControl;
-
     private DavServletRequest request;
 
-    private MockControl responseControl;
-
     private DavServletResponse response;
 
-    private MockControl buildAgentConfigurationServiceControl;
-
     private BuildAgentConfigurationService buildAgentConfigurationService;
 
     private ContinuumBuildAgentDavResourceFactory resourceFactory;
@@ -55,17 +51,9 @@ public class ContinuumBuildAgentDavResou
     {
         super.setUp();
 
-        requestControl = MockControl.createControl( DavServletRequest.class );
-        request = (DavServletRequest) requestControl.getMock();
-
-        responseControl = MockControl.createControl( DavServletResponse.class );
-        response = (DavServletResponse) responseControl.getMock();
-        responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
-
-        buildAgentConfigurationServiceControl = MockControl.
-            createControl( BuildAgentConfigurationService.class );
-        buildAgentConfigurationService =
-            (BuildAgentConfigurationService) buildAgentConfigurationServiceControl.getMock();
+        request = mock( DavServletRequest.class );
+        response = mock( DavServletResponse.class );
+        buildAgentConfigurationService = mock( BuildAgentConfigurationService.class );
 
         resourceFactory = new ContinuumBuildAgentDavResourceFactory();
         resourceFactory.setBuildAgentConfigurationService( buildAgentConfigurationService
);
@@ -101,18 +89,14 @@ public class ContinuumBuildAgentDavResou
 
         try
         {
-            requestControl.expectAndReturn( request.getMethod(), "GET" );
-            buildAgentConfigurationServiceControl.
-                expectAndReturn( buildAgentConfigurationService.getWorkingDirectory( 1 ),
getWorkingDirectory( 1 ) );
-            requestControl.expectAndReturn( request.getDavSession(), new ContinuumBuildAgentDavSession()
);
+            when( request.getMethod() ).thenReturn( "GET" );
+            when( buildAgentConfigurationService.getWorkingDirectory( 1 ) ).thenReturn( getWorkingDirectory(
1 ) );
+            when( request.getDavSession() ).thenReturn( new ContinuumBuildAgentDavSession()
);
 
-            requestControl.replay();
-            buildAgentConfigurationServiceControl.replay();
+            DavResource resource = resourceFactory.createResource( locator, request, response
);
 
-            resourceFactory.createResource( locator, request, response );
-
-            requestControl.verify();
-            buildAgentConfigurationServiceControl.verify();
+            assertNotNull( resource );
+            assertEquals( locator.getRepositoryPath(), locator.getRepositoryPath() );
         }
         catch ( DavException e )
         {
@@ -130,18 +114,11 @@ public class ContinuumBuildAgentDavResou
 
         try
         {
-            requestControl.expectAndReturn( request.getMethod(), "GET", 1 );
-            buildAgentConfigurationServiceControl.
-                expectAndReturn( buildAgentConfigurationService.getWorkingDirectory( 1 ),
getWorkingDirectory( 1 ) );
-
-            requestControl.replay();
-            buildAgentConfigurationServiceControl.replay();
+            when( request.getMethod() ).thenReturn( "GET" );
+            when( buildAgentConfigurationService.getWorkingDirectory( 1 ) ).thenReturn( getWorkingDirectory(
1 ) );
 
             resourceFactory.createResource( locator, request, response );
 
-            requestControl.verify();
-            buildAgentConfigurationServiceControl.verify();
-
             fail( "A DavException with 404 error code should have been thrown." );
         }
         catch ( DavException e )

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavSessionProviderTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavSessionProviderTest.java?rev=1659094&r1=1659093&r2=1659094&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavSessionProviderTest.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavSessionProviderTest.java
Wed Feb 11 21:28:16 2015
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.webdav.DavS
 import org.apache.jackrabbit.webdav.WebdavRequest;
 import org.apache.jackrabbit.webdav.WebdavRequestImpl;
 import org.codehaus.plexus.util.Base64;
-import org.easymock.MockControl;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -45,6 +44,7 @@ import java.util.Map;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.*;
 
 public class ContinuumBuildAgentDavSessionProviderTest
 {
@@ -52,26 +52,18 @@ public class ContinuumBuildAgentDavSessi
 
     private WebdavRequest request;
 
-    private MockControl buildAgentConfigurationServiceControl;
-
     private BuildAgentConfigurationService buildAgentConfigurationService;
 
     @Before
     public void setUp()
         throws Exception
     {
-        buildAgentConfigurationServiceControl = MockControl.createControl( BuildAgentConfigurationService.class
);
-        buildAgentConfigurationService =
-            (BuildAgentConfigurationService) buildAgentConfigurationServiceControl.getMock();
+        buildAgentConfigurationService = mock( BuildAgentConfigurationService.class );
 
         sessionProvider = new ContinuumBuildAgentDavSessionProvider( buildAgentConfigurationService
);
         request = new WebdavRequestImpl( new HttpServletRequestMock(), null );
 
-        buildAgentConfigurationServiceControl.expectAndReturn( buildAgentConfigurationService.getSharedSecretPassword(),
-                                                               "secret", 2 );
-
-        buildAgentConfigurationServiceControl.replay();
-
+        when( buildAgentConfigurationService.getSharedSecretPassword() ).thenReturn( "secret"
);
     }
 
     @Test
@@ -82,8 +74,6 @@ public class ContinuumBuildAgentDavSessi
 
         sessionProvider.attachSession( request );
 
-        buildAgentConfigurationServiceControl.verify();
-
         assertNotNull( request.getDavSession() );
     }
 
@@ -95,8 +85,6 @@ public class ContinuumBuildAgentDavSessi
 
         sessionProvider.attachSession( request );
 
-        buildAgentConfigurationServiceControl.verify();
-
         assertNotNull( request.getDavSession() );
 
         sessionProvider.releaseSession( request );

Modified: continuum/trunk/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/pom.xml?rev=1659094&r1=1659093&r2=1659094&view=diff
==============================================================================
--- continuum/trunk/pom.xml (original)
+++ continuum/trunk/pom.xml Wed Feb 11 21:28:16 2015
@@ -1573,18 +1573,6 @@
         </exclusions>
       </dependency>
       <dependency>
-        <groupId>easymock</groupId>
-        <artifactId>easymock</artifactId>
-        <version>1.2_Java1.3</version>
-        <scope>test</scope>
-      </dependency>
-      <dependency>
-        <groupId>easymock</groupId>
-        <artifactId>easymockclassextension</artifactId>
-        <version>1.2</version>
-        <scope>test</scope>
-      </dependency>
-      <dependency>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-action</artifactId>
         <version>1.0-alpha-6</version>



Mime
View raw message