@Override public boolean isClosed() { return delegatee.isClosed(); }
@Override public boolean isClosed() { return this.cacheWriter.isClosed(); }
@Override public boolean isClosed() { return delegatee.isClosed(); }
@Override public boolean isClosed() { return this.cacheWriter.isClosed(); }
@Test public void testReadAndWriteStreamByPush() throws Exception { ContentWriter writer = getWriter(); String content = "Some Random Content"; // get the content output stream OutputStream os = writer.getContentOutputStream(); os.write(content.getBytes()); assertFalse("Stream has not been closed", writer.isClosed()); // close the stream and check again os.close(); assertTrue("Stream close not detected", writer.isClosed()); // pull the content from a stream ContentReader reader = writer.getReader(); InputStream is = reader.getContentInputStream(); byte[] buffer = new byte[100]; int count = is.read(buffer); assertEquals("No content read", content.length(), count); is.close(); String check = new String(buffer, 0, count); assertEquals("Write out of and read into files failed", content, check); }
@Test public void testReadAndWriteStreamByPull() throws Exception { ContentWriter writer = getWriter(); String content = "ABC"; // put the content using a stream InputStream is = new ByteArrayInputStream(content.getBytes()); writer.putContent(is); assertTrue("Stream close not detected", writer.isClosed()); // get the content using a stream ByteArrayOutputStream os = new ByteArrayOutputStream(100); ContentReader reader = writer.getReader(); reader.getContent(os); byte[] bytes = os.toByteArray(); String check = new String(bytes); assertEquals("Write out and read in using streams failed", content, check); }
assertTrue("Stream close not detected", writer.isClosed());
/** * The simplest test. Write a string and read it again, checking that we receive the same values. * If the resource accessed by {@link #getReader(String)} and {@link #getWriter()} is not the same, then * values written and read won't be the same. */ @Test public void testWriteAndReadString() throws Exception { ContentWriter writer = getWriter(); String content = "ABC"; writer.putContent(content); assertTrue("Stream close not detected", writer.isClosed()); ContentReader reader = writer.getReader(); String check = reader.getContentString(); assertTrue("Read and write may not share same resource", check.length() > 0); assertEquals("Write and read didn't work", content, check); }
assertTrue("Stream close not detected", writer.isClosed());
assertTrue("Writer not closed", writer.isClosed());