hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r947510 - in /httpcomponents/httpclient/trunk: httpclient/pom.xml httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java pom.xml
Date Sun, 23 May 2010 22:20:44 GMT
Author: olegk
Date: Sun May 23 22:20:44 2010
New Revision: 947510

URL: http://svn.apache.org/viewvc?rev=947510&view=rev
Log:
HTTPCLIENT-941: Patch changing Mockito to EasyMock 
Contributed by Joe Campbell <joseph.r.campbell at gmail.com> 

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=947510&r1=947509&r2=947510&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/pom.xml (original)
+++ httpcomponents/httpclient/trunk/httpclient/pom.xml Sun May 23 22:20:44 2010
@@ -74,9 +74,15 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-all</artifactId>
-      <version>${mockito.version}</version>
+      <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>
       <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=947510&r1=947509&r2=947510&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
Sun May 23 22:20:44 2010
@@ -51,6 +51,7 @@ import org.apache.http.message.BasicHead
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
+
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSCredential;
 import org.ietf.jgss.GSSManager;
@@ -58,8 +59,8 @@ import org.ietf.jgss.GSSName;
 import org.ietf.jgss.Oid;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
+
+import org.easymock.classextension.EasyMock;
 
 /**
  * Tests for {@link NegotiateScheme}.
@@ -90,7 +91,6 @@ public class TestNegotiateScheme extends
         }
     }
 
-
     /**
      * NegotatieScheme with a custom GSSManager that does not require any Jaas or
      * Kerberos configuration.
@@ -98,28 +98,42 @@ public class TestNegotiateScheme extends
      */
     private static class NegotiateSchemeWithMockGssManager extends NegotiateScheme {
         
-        GSSManager manager = Mockito.mock(GSSManager.class);
-        GSSName name = Mockito.mock(GSSName.class);
-        GSSContext context = Mockito.mock(GSSContext.class);
-
+        GSSManager manager = EasyMock.createNiceMock(GSSManager.class);
+        GSSName name = EasyMock.createNiceMock(GSSName.class);
+        GSSContext context = EasyMock.createNiceMock(GSSContext.class);
+        
         NegotiateSchemeWithMockGssManager() throws Exception {
             super(null, true);
-            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);
+
+            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);
         }
 
         @Override
         protected GSSManager getManager() {
             return manager;
         }
+
+        public void verify() {
+            EasyMock.verify(context);
+            EasyMock.verify(name);
+            EasyMock.verify(manager);
+        }
         
     }
 
@@ -161,7 +175,9 @@ public class TestNegotiateScheme extends
 
         HttpHost target = new HttpHost("localhost", port);
         DefaultHttpClient client = new DefaultHttpClient();
+
         NegotiateSchemeFactory nsf = new NegotiateSchemeFactoryWithMockGssManager();
+
         client.getAuthSchemes().register(AuthPolicy.SPNEGO, nsf);
 
         Credentials use_jaas_creds = new UseJaasCredentials();
@@ -176,6 +192,9 @@ public class TestNegotiateScheme extends
         if (e != null) {
             e.consumeContent();
         }
+
+        ((NegotiateSchemeFactoryWithMockGssManager)nsf).scheme.verify();
+
         Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
     }
 
@@ -190,9 +209,9 @@ public class TestNegotiateScheme extends
 
         HttpHost target = new HttpHost("localhost", port);
         DefaultHttpClient client = new DefaultHttpClient();
+
         NegotiateSchemeFactoryWithMockGssManager nsf = new NegotiateSchemeFactoryWithMockGssManager();
-        Mockito.when(nsf.scheme.context.initSecContext(
-                Matchers.any(byte[].class), Matchers.anyInt(), Matchers.anyInt())).thenReturn(null);
+
         client.getAuthSchemes().register(AuthPolicy.SPNEGO, nsf);
 
         Credentials use_jaas_creds = new UseJaasCredentials();
@@ -207,6 +226,8 @@ public class TestNegotiateScheme extends
         if (e != null) {
             e.consumeContent();
         }
+
+        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=947510&r1=947509&r2=947510&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/pom.xml (original)
+++ httpcomponents/httpclient/trunk/pom.xml Sun May 23 22:20:44 2010
@@ -73,7 +73,6 @@
     <commons-codec.version>1.4</commons-codec.version>
     <junit.version>4.8.1</junit.version>
     <easymock.version>2.5.2</easymock.version>
-    <mockito.version>1.8.4</mockito.version>
   </properties>
 
   <modules>



Mime
View raw message