Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentbrison committed Dec 24, 2016
1 parent 8f6400a commit fa19c78
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ before_script:

script:
- ./gradlew clean
- ./gradlew dualcache-library:connectedAndroidTest -Ptravis --stacktrace
#- ./gradlew dualcache-library:connectedAndroidTest -Ptravis --stacktrace
- ./gradlew dualcache:check -Ptravis --stacktrace
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
compileSdkVersion = 25
buildToolsVersion = '25.0.1'
minSdkVersion = 9
minSdkVersion = 12
targetSdkVersion = 25

javaVersion = 1.7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.vincentbrison.openlibraries.android.dualcache.lib;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.test.AndroidTestCase;
import android.util.Log;

import com.vincentbrison.openlibraries.android.dualcache.CacheSerializer;
Expand All @@ -23,29 +23,34 @@
import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;

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

protected static final int RAM_MAX_SIZE = 1000;
protected static final int DISK_MAX_SIZE = 20 * RAM_MAX_SIZE;
protected static final String CACHE_NAME = "test";
protected static final int TEST_APP_VERSION = 0;
protected DualCache<AbstractVehicule> cache;
protected CacheSerializer<AbstractVehicule> defaultCacheSerializer;
private Context context;

protected Context getContext() {
return context;
}

@Before
@Override
public void setUp() throws Exception {
super.setUp();
defaultCacheSerializer = new JsonSerializer<>(AbstractVehicule.class);
setContext(InstrumentationRegistry.getTargetContext());
context = InstrumentationRegistry.getTargetContext();
}

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

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
package com.vincentbrison.openlibraries.android.dualcache.lib;

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

import com.vincentbrison.openlibraries.android.dualcache.Builder;
import com.vincentbrison.openlibraries.android.dualcache.CacheSerializer;
import com.vincentbrison.openlibraries.android.dualcache.DualCache;
import com.vincentbrison.openlibraries.android.dualcache.Builder;
import com.vincentbrison.openlibraries.android.dualcache.JsonSerializer;

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

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertFalse;

/**
* Test issue 11.
*/
public class TestIssue11 extends AndroidTestCase {
@RunWith(AndroidJUnit4.class)
public class TestIssue11 {
private static final int CACHE_SIZE = 10 * 1024 * 1024; // 10 MB
private static final int CACHE_RAM_ENTRIES = 25;
protected static final String CACHE_NAME = "test";
protected static final int TEST_APP_VERSION = 0;
protected DualCache<String> mCache;

@Before
@Override
public void setUp() throws Exception {
super.setUp();
setContext(InstrumentationRegistry.getTargetContext());
File cacheDir = new File(mContext.getCacheDir(), CACHE_NAME);
Context context = InstrumentationRegistry.getTargetContext();
File cacheDir = new File(context.getCacheDir(), CACHE_NAME);
CacheSerializer<String> jsonSerializer = new JsonSerializer<>(String.class);
mCache = new Builder<String>(CACHE_NAME, 0)
.enableLog()
Expand All @@ -41,10 +44,8 @@ public void setUp() throws Exception {
}

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

@Test
Expand Down

0 comments on commit fa19c78

Please sign in to comment.