Java Code Examples for com.danikula.videocache.sourcestorage.SourceInfoStorageFactory#newSourceInfoStorage()
The following examples show how to use
com.danikula.videocache.sourcestorage.SourceInfoStorageFactory#newSourceInfoStorage() .
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 | 6 votes |
@Test public void testReuseSourceInfo() throws Exception { SourceInfoStorage sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(RuntimeEnvironment.application); HttpUrlSource source = new HttpUrlSource(HTTP_DATA_URL, sourceInfoStorage); File cacheFile = newCacheFile(); HttpProxyCache proxyCache = new HttpProxyCache(source, new FileCache(cacheFile)); processRequest(proxyCache, "GET /" + HTTP_DATA_URL + " HTTP/1.1"); HttpUrlSource notOpenableSource = ProxyCacheTestUtils.newNotOpenableHttpUrlSource(HTTP_DATA_URL, sourceInfoStorage); HttpProxyCache proxyCache2 = new HttpProxyCache(notOpenableSource, new FileCache(cacheFile)); Response response = processRequest(proxyCache2, "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("image/jpeg"); }
Example 2
Source File: HttpProxyCacheTest.java From AndroidVideoCache with Apache License 2.0 | 6 votes |
@Test public void testReuseSourceInfo() throws Exception { SourceInfoStorage sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(RuntimeEnvironment.application); HttpUrlSource source = new HttpUrlSource(HTTP_DATA_URL, sourceInfoStorage); File cacheFile = newCacheFile(); HttpProxyCache proxyCache = new HttpProxyCache(source, new FileCache(cacheFile)); processRequest(proxyCache, "GET /" + HTTP_DATA_URL + " HTTP/1.1"); HttpUrlSource notOpenableSource = ProxyCacheTestUtils.newNotOpenableHttpUrlSource(HTTP_DATA_URL, sourceInfoStorage); HttpProxyCache proxyCache2 = new HttpProxyCache(notOpenableSource, new FileCache(cacheFile)); Response response = processRequest(proxyCache2, "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("image/jpeg"); }
Example 3
Source File: HttpProxyCacheTest.java From AndriodVideoCache with Apache License 2.0 | 5 votes |
@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 AndriodVideoCache with Apache License 2.0 | 5 votes |
@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 5
Source File: HttpProxyCacheServer.java From AndriodVideoCache with Apache License 2.0 | 5 votes |
public Builder(Context context) { this.sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(context); this.cacheRoot = StorageUtils.getIndividualCacheDirectory(context); this.diskUsage = new TotalSizeLruDiskUsage(DEFAULT_MAX_SIZE); this.fileNameGenerator = new Md5FileNameGenerator(); this.headerInjector = new EmptyHeadersInjector(); }
Example 6
Source File: HttpProxyCacheServer.java From DKVideoPlayer with Apache License 2.0 | 5 votes |
public Builder(Context context) { this.sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(context); this.cacheRoot = StorageUtils.getIndividualCacheDirectory(context); this.diskUsage = new TotalSizeLruDiskUsage(DEFAULT_MAX_SIZE); this.fileNameGenerator = new Md5FileNameGenerator(); this.headerInjector = new EmptyHeadersInjector(); }
Example 7
Source File: HttpProxyCacheServer.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
public Builder(Context context) { this.sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(context); this.cacheRoot = StorageUtils.getIndividualCacheDirectory(context); this.diskUsage = new TotalSizeLruDiskUsage(DEFAULT_MAX_SIZE); this.fileNameGenerator = new Md5FileNameGenerator(); this.headerInjector = new EmptyHeadersInjector(); }
Example 8
Source File: HttpProxyCacheTest.java From AndroidVideoCache with Apache License 2.0 | 5 votes |
@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 9
Source File: HttpProxyCacheTest.java From AndroidVideoCache with Apache License 2.0 | 5 votes |
@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 10
Source File: HttpProxyCacheServer.java From AndroidVideoCache with Apache License 2.0 | 5 votes |
public Builder(Context context) { this.sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(context); this.cacheRoot = StorageUtils.getIndividualCacheDirectory(context); this.diskUsage = new TotalSizeLruDiskUsage(DEFAULT_MAX_SIZE); this.fileNameGenerator = new Md5FileNameGenerator(); this.headerInjector = new EmptyHeadersInjector(); }