Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

Commit 0776db9

Browse files
committed
Replaced Easymock with Mockito
1 parent d654d5f commit 0776db9

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

‎src/test/java/name/pehl/taoki/paging/AbstractPagingResourceTest.java‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package name.pehl.taoki.paging;
22

33
import static junit.framework.Assert.*;
4-
import static org.easymock.EasyMock.*;
5-
import name.pehl.taoki.paging.AbstractPagingResource;
6-
import name.pehl.taoki.paging.PageInfo;
4+
import static org.mockito.Mockito.*;
75
import name.pehl.taoki.paging.parser.PageInfoParseException;
86
import name.pehl.taoki.paging.parser.PageInfoParser;
97

@@ -12,8 +10,7 @@
1210

1311
/**
1412
* @author $Author$
15-
* @version $Date$ $Revision: 99
16-
* $
13+
* @version $Date$ $Revision$
1714
*/
1815
public class AbstractPagingResourceTest
1916
{
@@ -29,24 +26,22 @@ public void getPageInfoWithNullParser()
2926
@Test
3027
public void getPageInfoWithNullInput() throws PageInfoParseException
3128
{
32-
PageInfoParser pip = createStrictMock(PageInfoParser.class);
33-
expect(pip.parse(null)).andReturn(null);
34-
replay(pip);
29+
PageInfoParser pip = mock(PageInfoParser.class);
30+
when(pip.parse(null)).thenReturn(null);
3531

3632
AbstractPagingResource underTest = new NullPagingResource(pip);
3733
PageInfo pageInfo = underTest.getPageInfo();
3834
assertNull(pageInfo);
39-
verify(pip);
35+
verify(pip).parse(null);
4036
}
4137

4238

4339
@Test
4440
public void getPageInfoWithInvalidInput() throws PageInfoParseException
4541
{
46-
PageInfoParser pip = createStrictMock(PageInfoParser.class);
47-
expect(pip.parse(FooPagingResource.FOO)).andThrow(
42+
PageInfoParser pip = mock(PageInfoParser.class);
43+
when(pip.parse(FooPagingResource.FOO)).thenThrow(
4844
new PageInfoParseException("Expected exception from junit test method"));
49-
replay(pip);
5045

5146
AbstractPagingResource underTest = new FooPagingResource(pip);
5247
PageInfo pageInfo = underTest.getPageInfo();
@@ -59,14 +54,13 @@ public void getPageInfoWithInvalidInput() throws PageInfoParseException
5954
public void getPageInfo() throws PageInfoParseException
6055
{
6156
PageInfo pageInfoFixture = new PageInfo(1, 2);
62-
PageInfoParser pip = createStrictMock(PageInfoParser.class);
63-
expect(pip.parse(FooPagingResource.FOO)).andReturn(pageInfoFixture);
64-
replay(pip);
57+
PageInfoParser pip = mock(PageInfoParser.class);
58+
when(pip.parse(FooPagingResource.FOO)).thenReturn(pageInfoFixture);
6559

6660
AbstractPagingResource underTest = new FooPagingResource(pip);
6761
PageInfo pageInfo = underTest.getPageInfo();
6862
assertEquals(pageInfoFixture, pageInfo);
69-
verify(pip);
63+
verify(pip).parse(FooPagingResource.FOO);
7064
}
7165

7266
// ---------------------------------------------------------- inner classes

0 commit comments

Comments
 (0)