Skip to content

Commit 5753951

Browse files
author
stefanhen83
committed
Introduce Mockito instead of EasyMock.
1 parent 993a550 commit 5753951

5 files changed

Lines changed: 31 additions & 37 deletions

File tree

.classpath

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
<classpathentry kind="src" path="src/main/resources/dll" including="**/*.dll" excluding="**/*.java"/>
55
<classpathentry kind="src" path="src/main/resources/images" including="**/*.*" excluding="**/*.java"/>
66
<classpathentry kind="output" path="target/classes"/>
7-
<classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.2/cglib-nodep-2.2.jar"/>
8-
<classpathentry kind="var" path="M2_REPO/org/easymock/easymock/2.5.2/easymock-2.5.2.jar"/>
9-
<classpathentry kind="var" path="M2_REPO/org/easymock/easymockclassextension/2.5.2/easymockclassextension-2.5.2.jar"/>
7+
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
108
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/hiero/1.1/hiero-1.1.jar"/>
119
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/ibxm/1.1/ibxm-1.1.jar"/>
1210
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/jinput/1.1/jinput-1.1.jar"/>
@@ -15,10 +13,11 @@
1513
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/jorbis-0.0.15/1.1/jorbis-0.0.15-1.1.jar"/>
1614
<classpathentry kind="var" path="M2_REPO/junit/junit/4.7/junit-4.7.jar"/>
1715
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/lwjgl/1.1/lwjgl-1.1.jar"/>
16+
<classpathentry kind="var" path="M2_REPO/org/mockito/mockito-core/1.8.5/mockito-core-1.8.5.jar"/>
1817
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/natives-linux/1.1/natives-linux-1.1.jar"/>
1918
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/natives-mac/1.1/natives-mac-1.1.jar"/>
2019
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/natives-win32/1.1/natives-win32-1.1.jar"/>
21-
<classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.2/objenesis-1.2.jar"/>
20+
<classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.0/objenesis-1.0.jar"/>
2221
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/packulike/1.1/packulike-1.1.jar"/>
2322
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/pedigree/1.1/pedigree-1.1.jar"/>
2423
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/scalar/1.1/scalar-1.1.jar"/>

.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Sun Mar 27 20:27:24 CEST 2011
1+
#Sun Mar 27 21:11:42 CEST 2011
22
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
33
eclipse.preferences.version=1
44
org.eclipse.jdt.core.compiler.source=1.5

pom.xml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@
5252
</plugins>
5353

5454
<resources>
55-
<!-- native libraries -->
55+
<!-- native libraries -->
5656
<resource>
5757
<directory>src\main\resources\dll</directory>
5858
<includes>
5959
<include>**/*.dll</include>
6060
</includes>
6161
</resource>
6262

63-
<!-- other -->
63+
<!-- other -->
6464
<resource>
6565
<directory>src\main\resources\images</directory>
6666
<includes>
@@ -74,35 +74,23 @@
7474

7575
<dependencies>
7676

77-
<!-- unit testing -->
77+
<!-- unit testing -->
7878
<dependency>
7979
<groupId>junit</groupId>
8080
<artifactId>junit</artifactId>
8181
<version>4.7</version>
8282
<scope>test</scope>
8383
</dependency>
8484

85-
<!-- easymock class extension makes it easier to unit test behavior -->
8685
<dependency>
87-
<groupId>org.easymock</groupId>
88-
<artifactId>easymockclassextension</artifactId>
89-
<version>2.5.2</version>
90-
<scope>test</scope>
86+
<groupId>org.mockito</groupId>
87+
<artifactId>mockito-core</artifactId>
88+
<version>1.8.5</version>
9189
</dependency>
9290

93-
<!-- log4j for loggin purposes -->
94-
<!--
95-
<dependency>
96-
<groupId>log4j</groupId>
97-
<artifactId>log4j</artifactId>
98-
<version>1.2.15</version>
99-
</dependency>
100-
-->
101-
102-
<!--
103-
slick and its dependencies, installed using the install.bat
104-
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
105-
-->
91+
<!-- log4j for loggin purposes -->
92+
93+
<!-- slick and its dependencies, installed using the install.bat http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html -->
10694
<dependency>
10795
<groupId>com.cokeandcode</groupId>
10896
<artifactId>hiero</artifactId>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.fundynamic.dune2themaker.stubs.slick;
2+
3+
import org.newdawn.slick.Image;
4+
5+
public class ImageStub extends Image {
6+
7+
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.fundynamic.dune2themaker.system.drawers;
22

3-
import org.easymock.classextension.EasyMock;
43
import org.junit.Test;
4+
import org.mockito.Mockito;
55
import org.newdawn.slick.Graphics;
66
import org.newdawn.slick.Image;
77
import org.newdawn.slick.SlickException;
88

9+
import com.fundynamic.dune2themaker.stubs.slick.ImageStub;
910
import com.fundynamic.dune2themaker.system.repositories.ImageRepository;
1011

1112
public class ImageDrawerTest {
@@ -22,16 +23,15 @@ public void mustThrowIllegalArgumentExceptionImageRepositoryIsNull() {
2223

2324
@Test
2425
public void mustDrawWithProperDrawMethodFromCanvas() throws SlickException {
25-
final Image myImage = EasyMock.createMock(Image.class);
26-
Graphics stub = new Graphics() {
27-
public void drawImage(Image image, float x, float y) {
28-
if (!(x == 1 && y == 1 && image == myImage)) {
29-
throw new IllegalArgumentException("Call failed");
30-
}
31-
}
32-
};
33-
ImageDrawer drawer = new ImageDrawer(stub, new ImageRepository());
34-
drawer.drawImage(myImage, 1, 1);
26+
Image image = new ImageStub();
27+
Graphics graphics = Mockito.mock(Graphics.class);
28+
ImageDrawer drawer = new ImageDrawer(graphics, new ImageRepository());
29+
30+
// Act
31+
drawer.drawImage(image, 1, 1);
32+
33+
// Verify
34+
Mockito.verify(graphics).drawImage(image, 1, 1);
3535
}
3636

3737
}

0 commit comments

Comments
 (0)