### Question:
AbstractFileCache { public synchronized InputStream getAsInputStream(K key) throws CacheException { if (this.containsKey(key)) { try { return new FileInputStream(this.getCacheFile(key)); } catch (FileNotFoundException e) { String message = Messages.getString("AbstractFileCache.Exception.FileNotFoundShouldNotHappen"); LOGGER.error(message, e); throw new CacheException(message, e); } } else { return null; } } protected  AbstractFileCache(File cacheDirectory, String prefix, String suffix, final int maxAgeInSeconds); synchronized void clear(); synchronized boolean containsKey(K key); synchronized byte[] get(K key); synchronized InputStream getAsInputStream(K key); File getCacheDirectory(); File getCacheFile(K key); synchronized void purge(); synchronized void put(K key, byte[] value); synchronized void putFile(K key, File file, boolean move); synchronized void remove(K key);  }### Answer:
@Test public void testGetAsInputStream() throws CacheException, IOException { byte[] testBytes = "test".getBytes(StandardCharsets.US_ASCII); underTest.put("test", testBytes); try (InputStream input = underTest.getAsInputStream("test")) { for (int i = 0; i < testBytes.length; i++) { assertEquals(input.read(), testBytes[i]); } assertEquals(-1, input.read()); } }
@Test public void testGetAsInputStreamNull() throws CacheException, IOException { assertNull(underTest.getAsInputStream("test")); }