Skip to content

Commit

Permalink
Update tests to JUnit 4.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentbrison committed Jun 27, 2015
1 parent 1d67ad7 commit 06b8084
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 13 deletions.
3 changes: 3 additions & 0 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android {
targetSdkVersion 20
versionCode 1
versionName project.VERSION_NAME
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

packagingOptions {
Expand All @@ -28,6 +29,8 @@ dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile 'com.jakewharton:disklrucache:2.0.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'

androidTestCompile 'com.android.support.test:runner:0.3'
}

android.libraryVariants.all { variant ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package com.vincentbrison.openlibraries.android.dualcache.lib;

import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.test.AndroidTestCase;

import com.vincentbrison.openlibraries.android.dualcache.lib.testobjects.AbstractVehicule;
import com.vincentbrison.openlibraries.android.dualcache.lib.testobjects.CoolBike;
import com.vincentbrison.openlibraries.android.dualcache.lib.testobjects.CoolCar;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public abstract class DualCacheTest extends AndroidTestCase {

protected static final int RAM_MAX_SIZE = 1000;
Expand All @@ -14,18 +22,22 @@ public abstract class DualCacheTest extends AndroidTestCase {
protected static final int TEST_APP_VERSION = 0;
protected DualCache<AbstractVehicule> mCache;

@Before
@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
setContext(InstrumentationRegistry.getTargetContext());
DualCacheContextUtils.setContext(getContext());
}

@After
@Override
protected void tearDown() throws Exception {
public void tearDown() throws Exception {
mCache.invalidate();
super.tearDown();
}

@Test
public void testBasicOperations() throws Exception {
CoolCar car = new CoolCar();
mCache.put("key", car);
Expand Down Expand Up @@ -67,6 +79,7 @@ public void testBasicOperations() throws Exception {
}
}

@Test
public void testBasicOperations2() throws Exception {
CoolCar car = new CoolCar();
mCache.put("key", car);
Expand Down Expand Up @@ -101,6 +114,7 @@ public void testBasicOperations2() throws Exception {
assertNull(mCache.get("bike"));
}

@Test
public void testLRUPolicy() {
mCache.invalidate();
CoolCar carToEvict = new CoolCar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class NoRamDiskCustomSerializer extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.noRam()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class NoRamDiskDefaultSerializer extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.noRam()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class RamCustomSerializerDiskCustomSerializer extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.useCustomSerializerInRam(RAM_MAX_SIZE, new SerializerForTesting())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class RamCustomSerializerDiskDefaultSerializer extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.useCustomSerializerInRam(RAM_MAX_SIZE, new SerializerForTesting())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class RamCustomSerializerNoDisk extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.useCustomSerializerInRam(RAM_MAX_SIZE, new SerializerForTesting())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class RamDefaultSerializerDiskCustomSerializer extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.useDefaultSerializerInRam(RAM_MAX_SIZE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class RamDefaultSerializerDiskDefaultSerializer extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.useDefaultSerializerInRam(RAM_MAX_SIZE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class RamDefaultSerializerNoDisk extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.useDefaultSerializerInRam(RAM_MAX_SIZE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class RamReferenceDiskCustomSerializer extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.useReferenceInRam(RAM_MAX_SIZE, new SizeOfVehiculeForTesting())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class RamReferenceDiskDefaultSerializer extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.useReferenceInRam(RAM_MAX_SIZE, new SizeOfVehiculeForTesting())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class RamReferenceNoDisk extends DualCacheTest {

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
mCache = new DualCacheBuilder<AbstractVehicule>(CACHE_NAME, TEST_APP_VERSION, AbstractVehicule.class)
.useReferenceInRam(RAM_MAX_SIZE, new SizeOfVehiculeForTesting())
Expand Down

0 comments on commit 06b8084

Please sign in to comment.