Code example for ByteArrayOutputStream

Methods: toByteArray

0
        inputStreamCacheManager.saveDataToCacheAndReturnData(new ByteArrayInputStream("coucou".getBytes()), TEST_CACHE_KEY);
 
        File cachedFile = inputStreamCacheManager.getCacheFile(TEST_CACHE_KEY);
        assertTrue(cachedFile.exists());
 
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        IOUtils.copy(new FileInputStream(cachedFile), bos);
        assertTrue(Arrays.equals("coucou".getBytes(), bos.toByteArray()));
    } 
 
    public void testLoadDataFromCache_no_expiracy() throws Exception { 
        File cachedFile = inputStreamCacheManager.getCacheFile(TEST_CACHE_KEY);
        IOUtils.write("coucou", new FileOutputStream(cachedFile));
 
        InputStream inputStream = inputStreamCacheManager.loadDataFromCache(TEST_CACHE_KEY, DurationInMillis.ALWAYS);
        byte[] actual = IOUtils.toByteArray(inputStream);
        assertTrue(Arrays.equals("coucou".getBytes(), actual));
    } 
 
    public void testLoadDataFromCache_not_expired() throws Exception { 
        File cachedFile = inputStreamCacheManager.getCacheFile(TEST_CACHE_KEY);