FileDocCategorySizeDatePackage
CacheTestUtils.javaAPI DocAndroid 5.1 API1316Thu Mar 12 22:22:56 GMT 2015com.android.volley.utils

CacheTestUtils

public class CacheTestUtils extends Object

Fields Summary
Constructors Summary
Methods Summary
public static Cache.EntrymakeRandomCacheEntry(byte[] data, boolean isExpired, boolean needsRefresh)
Makes a random cache entry.

param
data Data to use, or null to use random data
param
isExpired Whether the TTLs should be set such that this entry is expired
param
needsRefresh Whether the TTLs should be set such that this entry needs refresh

        Random random = new Random();
        Cache.Entry entry = new Cache.Entry();
        if (data != null) {
            entry.data = data;
        } else {
            entry.data = new byte[random.nextInt(1024)];
        }
        entry.etag = String.valueOf(random.nextLong());
        entry.serverDate = random.nextLong();
        entry.ttl = isExpired ? 0 : Long.MAX_VALUE;
        entry.softTtl = needsRefresh ? 0 : Long.MAX_VALUE;
        return entry;
    
public static Cache.EntrymakeRandomCacheEntry(byte[] data)
Like {@link #makeRandomCacheEntry(byte[], boolean, boolean)} but defaults to an unexpired entry.

        return makeRandomCacheEntry(data, false, false);