예제 #1
0
 @Test
 public void diskLruCacheAsyncPut_whenEmpty_shouldReturnNull() throws Exception {
   CacheService.initialize(context);
   CacheService.putToDiskCacheAsync(key1, data1.getBytes());
   Thread.sleep(500);
   assertThat(CacheService.getFromDiskCache(key1)).isEqualTo(data1.getBytes());
 }
예제 #2
0
 @Test
 public void diskLruCachePut_withEmptyStringKey_shouldPutCorrectly() throws Exception {
   // this works because an empty string sha1 hashes to a valid key
   CacheService.initialize(context);
   CacheService.putToDiskCache("", data1.getBytes());
   assertThat(CacheService.getFromDiskCache("")).isEqualTo(data1.getBytes());
 }
예제 #3
0
 @Test
 public void diskLruCacheGet_whenEmpty_shouldReturnNull() throws Exception {
   CacheService.initialize(context);
   assertCachesAreEmpty();
   assertThat(CacheService.getFromDiskCache(key1)).isNull();
 }
예제 #4
0
 @Test
 public void diskLruCacheGet_whenPopulated_shouldReturnValue() throws Exception {
   CacheService.initialize(context);
   CacheService.putToDiskCache(key1, data1.getBytes());
   assertThat(CacheService.getFromDiskCache(key1)).isEqualTo(data1.getBytes());
 }