hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1074493 - in /httpcomponents/httpclient/trunk: httpclient/pom.xml httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java pom.xml
Date Fri, 25 Feb 2011 12:13:17 GMT
Author: olegk
Date: Fri Feb 25 12:13:16 2011
New Revision: 1074493

URL: http://svn.apache.org/viewvc?rev=1074493&view=rev
Log:
Ahhh, I just can't go back to EasyMock after having used Mockito

Modified:
    httpcomponents/httpclient/trunk/httpclient/pom.xml
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java
    httpcomponents/httpclient/trunk/pom.xml

Modified: httpcomponents/httpclient/trunk/httpclient/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/pom.xml?rev=1074493&r1=1074492&r2=1074493&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/pom.xml (original)
+++ httpcomponents/httpclient/trunk/httpclient/pom.xml Fri Feb 25 12:13:16 2011
@@ -66,15 +66,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.easymock</groupId>
-      <artifactId>easymock</artifactId>
-      <version>${easymock.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.easymock</groupId>
-      <artifactId>easymockclassextension</artifactId>
-      <version>${easymock.version}</version>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <version>${mockito.version}</version>
       <scope>test</scope>
     </dependency>
   </dependencies>

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java?rev=1074493&r1=1074492&r2=1074493&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java
Fri Feb 25 12:13:16 2011
@@ -58,8 +58,8 @@ import org.ietf.jgss.Oid;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-
-import org.easymock.classextension.EasyMock;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
 
 /**
  * Tests for {@link NegotiateScheme}.
@@ -97,30 +97,22 @@ public class TestNegotiateScheme extends
      */
     private static class NegotiateSchemeWithMockGssManager extends NegotiateScheme {
 
-        GSSManager manager = EasyMock.createNiceMock(GSSManager.class);
-        GSSName name = EasyMock.createNiceMock(GSSName.class);
-        GSSContext context = EasyMock.createNiceMock(GSSContext.class);
+        GSSManager manager = Mockito.mock(GSSManager.class);
+        GSSName name = Mockito.mock(GSSName.class);
+        GSSContext context = Mockito.mock(GSSContext.class);
 
         NegotiateSchemeWithMockGssManager() throws Exception {
             super(null, true);
-
-            EasyMock.expect(context.initSecContext(EasyMock.<byte[]>anyObject(),
-                    EasyMock.anyInt(), EasyMock.anyInt())).andReturn("12345678".getBytes());
-
-            EasyMock.expect(manager.createName(EasyMock.isA(String.class),
-                    EasyMock.<Oid>anyObject())).andReturn(name);
-
-            EasyMock.expect(manager.createContext(
-                    EasyMock.isA(GSSName.class),EasyMock.isA(Oid.class),
-                    EasyMock.<GSSCredential>anyObject(), EasyMock.anyInt()))
-                    .andReturn(context);
-
-            EasyMock.expect(name.canonicalize(EasyMock.isA(Oid.class)))
-                    .andReturn(name);
-
-            EasyMock.replay(context);
-            EasyMock.replay(name);
-            EasyMock.replay(manager);
+            Mockito.when(context.initSecContext(
+                    Matchers.any(byte[].class), Matchers.anyInt(), Matchers.anyInt()))
+                    .thenReturn("12345678".getBytes());
+            Mockito.when(manager.createName(
+                    Matchers.any(String.class), Matchers.any(Oid.class)))
+                    .thenReturn(name);
+            Mockito.when(manager.createContext(
+                    Matchers.any(GSSName.class), Matchers.any(Oid.class),
+                    Matchers.any(GSSCredential.class), Matchers.anyInt()))
+                    .thenReturn(context);
         }
 
         @Override
@@ -128,12 +120,6 @@ public class TestNegotiateScheme extends
             return manager;
         }
 
-        public void verify() {
-            EasyMock.verify(context);
-            EasyMock.verify(name);
-            EasyMock.verify(manager);
-        }
-
     }
 
     private static class UseJaasCredentials implements Credentials {
@@ -189,8 +175,6 @@ public class TestNegotiateScheme extends
         HttpResponse response = client.execute(httpget);
         EntityUtils.consume(response.getEntity());
 
-        ((NegotiateSchemeFactoryWithMockGssManager)nsf).scheme.verify();
-
         Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
     }
 
@@ -220,7 +204,6 @@ public class TestNegotiateScheme extends
         HttpResponse response = client.execute(httpget);
         EntityUtils.consume(response.getEntity());
 
-        nsf.scheme.verify();
         Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
     }
 

Modified: httpcomponents/httpclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/pom.xml?rev=1074493&r1=1074492&r2=1074493&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/pom.xml (original)
+++ httpcomponents/httpclient/trunk/pom.xml Fri Feb 25 12:13:16 2011
@@ -75,6 +75,7 @@
     <slf4j.version>1.5.11</slf4j.version>
     <junit.version>4.8.2</junit.version>
     <easymock.version>2.5.2</easymock.version>
+    <mockito.version>1.8.5</mockito.version>
     <comparisonVersion>4.0</comparisonVersion>
   </properties>
 



Mime
View raw message