Java Code Examples for com.danikula.videocache.sourcestorage.SourceInfoStorage#put()

The following examples show how to use com.danikula.videocache.sourcestorage.SourceInfoStorage#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpProxyCacheTest.java    From AndriodVideoCache with Apache License 2.0 5 votes vote down vote up
@Test(expected = ProxyCacheException.class)
public void testTouchSourceForExistedSourceInfoAndAbsentCache() throws Exception {
    SourceInfoStorage sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(RuntimeEnvironment.application);
    sourceInfoStorage.put(HTTP_DATA_URL, new SourceInfo(HTTP_DATA_URL, HTTP_DATA_SIZE, "image/jpg"));
    HttpUrlSource source = ProxyCacheTestUtils.newNotOpenableHttpUrlSource(HTTP_DATA_URL, sourceInfoStorage);
    HttpProxyCache proxyCache = new HttpProxyCache(source, new FileCache(newCacheFile()));
    processRequest(proxyCache, "GET /" + HTTP_DATA_URL + " HTTP/1.1");
    proxyCache.shutdown();
    fail("Angry source should throw error! There is no cache file");
}
 
Example 2
Source File: HttpProxyCacheTest.java    From AndriodVideoCache with Apache License 2.0 5 votes vote down vote up
@Test
public void testTouchSourceForExistedSourceInfoAndCache() throws Exception {
    SourceInfoStorage sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(RuntimeEnvironment.application);
    sourceInfoStorage.put(HTTP_DATA_URL, new SourceInfo(HTTP_DATA_URL, HTTP_DATA_SIZE, "cached/mime"));
    HttpUrlSource source = ProxyCacheTestUtils.newNotOpenableHttpUrlSource(HTTP_DATA_URL, sourceInfoStorage);
    File file = newCacheFile();
    IoUtils.saveToFile(loadAssetFile(ASSETS_DATA_NAME), file);
    HttpProxyCache proxyCache = new HttpProxyCache(source, new FileCache(file));
    Response response = processRequest(proxyCache, "GET /" + HTTP_DATA_URL + " HTTP/1.1");
    proxyCache.shutdown();
    assertThat(response.data).isEqualTo(loadAssetFile(ASSETS_DATA_NAME));
    assertThat(response.contentLength).isEqualTo(HTTP_DATA_SIZE);
    assertThat(response.contentType).isEqualTo("cached/mime");
}
 
Example 3
Source File: HttpProxyCacheTest.java    From AndroidVideoCache with Apache License 2.0 5 votes vote down vote up
@Test(expected = ProxyCacheException.class)
public void testTouchSourceForExistedSourceInfoAndAbsentCache() throws Exception {
    SourceInfoStorage sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(RuntimeEnvironment.application);
    sourceInfoStorage.put(HTTP_DATA_URL, new SourceInfo(HTTP_DATA_URL, HTTP_DATA_SIZE, "image/jpg"));
    HttpUrlSource source = ProxyCacheTestUtils.newNotOpenableHttpUrlSource(HTTP_DATA_URL, sourceInfoStorage);
    HttpProxyCache proxyCache = new HttpProxyCache(source, new FileCache(newCacheFile()));
    processRequest(proxyCache, "GET /" + HTTP_DATA_URL + " HTTP/1.1");
    proxyCache.shutdown();
    fail("Angry source should throw error! There is no cache file");
}
 
Example 4
Source File: HttpProxyCacheTest.java    From AndroidVideoCache with Apache License 2.0 5 votes vote down vote up
@Test
public void testTouchSourceForExistedSourceInfoAndCache() throws Exception {
    SourceInfoStorage sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(RuntimeEnvironment.application);
    sourceInfoStorage.put(HTTP_DATA_URL, new SourceInfo(HTTP_DATA_URL, HTTP_DATA_SIZE, "cached/mime"));
    HttpUrlSource source = ProxyCacheTestUtils.newNotOpenableHttpUrlSource(HTTP_DATA_URL, sourceInfoStorage);
    File file = newCacheFile();
    IoUtils.saveToFile(loadAssetFile(ASSETS_DATA_NAME), file);
    HttpProxyCache proxyCache = new HttpProxyCache(source, new FileCache(file));
    Response response = processRequest(proxyCache, "GET /" + HTTP_DATA_URL + " HTTP/1.1");
    proxyCache.shutdown();
    assertThat(response.data).isEqualTo(loadAssetFile(ASSETS_DATA_NAME));
    assertThat(response.contentLength).isEqualTo(HTTP_DATA_SIZE);
    assertThat(response.contentType).isEqualTo("cached/mime");
}