From 51ef77e7f22149809cbe0b24c011a1c0c36b0722 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Fri, 25 Feb 2011 12:13:16 +0000 Subject: [PATCH] Ahhh, I just can't go back to EasyMock after having used Mockito git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1074493 13f79535-47bb-0310-9956-ffa450edef68 --- httpclient/pom.xml | 12 ++--- .../http/impl/auth/TestNegotiateScheme.java | 47 ++++++------------- pom.xml | 1 + 3 files changed, 19 insertions(+), 41 deletions(-) diff --git a/httpclient/pom.xml b/httpclient/pom.xml index bd5a4aaa4..765387037 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -66,15 +66,9 @@ test - org.easymock - easymock - ${easymock.version} - test - - - org.easymock - easymockclassextension - ${easymock.version} + org.mockito + mockito-core + ${mockito.version} test diff --git a/httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java b/httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java index da43412bc..010225982 100644 --- a/httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java +++ b/httpclient/src/test/java/org/apache/http/impl/auth/TestNegotiateScheme.java @@ -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 BasicServerTestBase { */ 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.anyObject(), - EasyMock.anyInt(), EasyMock.anyInt())).andReturn("12345678".getBytes()); - - EasyMock.expect(manager.createName(EasyMock.isA(String.class), - EasyMock.anyObject())).andReturn(name); - - EasyMock.expect(manager.createContext( - EasyMock.isA(GSSName.class),EasyMock.isA(Oid.class), - EasyMock.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 BasicServerTestBase { 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 BasicServerTestBase { 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 BasicServerTestBase { HttpResponse response = client.execute(httpget); EntityUtils.consume(response.getEntity()); - nsf.scheme.verify(); Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode()); } diff --git a/pom.xml b/pom.xml index d8d24bd7f..44c4a36f0 100644 --- a/pom.xml +++ b/pom.xml @@ -75,6 +75,7 @@ 1.5.11 4.8.2 2.5.2 + 1.8.5 4.0