Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #46 from luigi-agosti/master

possible improvement for issue #25 of using emma with powermock
  • Loading branch information...
commit 63b7bf59c1f1ed673898a4798c6b4e44c7faccbb 2 parents db3ac14 + 98f1e26
@luigi-agosti luigi-agosti authored
View
21 core/pom.xml
@@ -54,9 +54,30 @@
<version>1.4.12</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4-rule</artifactId>
+ <version>1.4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-classloading-objenesis</artifactId>
+ <version>1.4.12</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.sonatype.maven.plugin</groupId>
+ <artifactId>emma-maven-plugin</artifactId>
+ <version>1.2</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
View
29 core/src/test/java/com/novoda/imageloader/core/util/DirectLoaderTest.java
@@ -6,22 +6,23 @@
import java.io.InputStream;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.rule.PowerMockRule;
import android.graphics.Bitmap;
import com.novoda.imageloader.core.bitmap.BitmapUtil;
import com.novoda.imageloader.core.network.NetworkManager;
-//@RunWith(PowerMockRunner.class)
-//@PrepareForTest({ Bitmap.class })
+@PrepareForTest({ Bitmap.class })
public class DirectLoaderTest {
+ @Rule public PowerMockRule rule = new PowerMockRule();
+
private DirectLoader directLoader;
private NetworkManager networkManager;
private BitmapUtil bitmapUtil;
@@ -50,15 +51,15 @@ public void shouldReturnNullIfIsNotPossibleToGetAnInputStreamFromNetwrokResource
assertNull(directLoader.download(url));
}
-// @Test
-// public void shouldReturnBitmapFromHttpResource() {
-// String url = "http://www.google.com";
-// InputStream is = Mockito.mock(InputStream.class);
-// Mockito.when(networkManager.retrieveInputStream(url)).thenReturn(is);
-// Bitmap expectedBitmap = PowerMockito.mock(Bitmap.class);
-// PowerMockito.when(bitmapUtil.decodeInputStream(is)).thenReturn(expectedBitmap);
-// Bitmap actualBitmap = directLoader.download(url);
-// assertEquals(expectedBitmap, actualBitmap);
-// }
+ @Test
+ public void shouldReturnBitmapFromHttpResource() {
+ String url = "http://www.google.com";
+ InputStream is = Mockito.mock(InputStream.class);
+ Mockito.when(networkManager.retrieveInputStream(url)).thenReturn(is);
+ Bitmap expectedBitmap = PowerMockito.mock(Bitmap.class);
+ PowerMockito.when(bitmapUtil.decodeInputStream(is)).thenReturn(expectedBitmap);
+ Bitmap actualBitmap = directLoader.download(url);
+ assertEquals(expectedBitmap, actualBitmap);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.