@Test public void testStagingMode() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); MemStagingHandler handler = new MemStagingHandler(baos, session); assertEquals(StagingMode.MEMORY, handler.getStagingMode()); }
@Test public void testFullyBuffered() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); MemStagingHandler handler = new MemStagingHandler(baos, session); assertTrue(handler.isFullyBuffered()); }
@Test public void closeTest() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); MemStagingHandler handler = new MemStagingHandler(baos, session); OutputStream spy = Mockito.spy(handler.getStagingOutputStream()); // to be able to spy on inner object handler.memoryTrackingStream = (TrackingOutputStream) spy; handler.close(); verify(spy, times(1)).close(); }
@Test public void completeTest() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); MemStagingHandler handler = new MemStagingHandler(baos, session); handler.getStagingOutputStream().write(TEST.getBytes()); assertTrue("complete was not called", new String(baos.toByteArray()).isEmpty()); handler.complete(); // trim string from tail 00 bytes... assertEquals("Write output only after complete", TEST, baos.toString().trim()); }