96979899100101102103104105106
encoder.write(empty); encoder.write(null); encoder.complete(); outbuf.flush(channel); final String s = channel.dump(Consts.ASCII); Assert.assertTrue(encoder.isCompleted()); Assert.assertEquals("stuff", s); }
170171172173174175176177178179180
encoder.transfer(fchannel, 0, 20); } finally { testfile.close(); } final String s = channel.dump(Consts.ASCII); Assert.assertFalse(encoder.isCompleted()); Assert.assertEquals("stuff;more stuff", s); }
199200201202203204205206207208209
encoder.write(CodecTestUtils.wrap("more stuff")); } finally { testfile.close(); } final String s = channel.dump(Consts.ASCII); Assert.assertFalse(encoder.isCompleted()); Assert.assertEquals("stuff;more stuff", s); }
229230231232233234235236237238239
final FileChannel fchannel = testfile.getChannel(); encoder.transfer(fchannel, 0, 20); } finally { testfile.close(); } final String s = channel.dump(Consts.ASCII); Assert.assertFalse(encoder.isCompleted()); Assert.assertEquals("stuff;more stuff", s); }
261262263264265266267268269270271
final FileChannel fchannel = testfile.getChannel(); encoder.transfer(fchannel, 0, 20); } finally { testfile.close(); } final String s = channel.dump(Consts.ASCII); Assert.assertFalse(encoder.isCompleted()); Assert.assertEquals("header\r\nstuff;more stuff", s); }
293294295296297298299300301302303
encoder.transfer(fchannel, 0, 20); encoder.transfer(fchannel, 0, 20); } finally { testfile.close(); } final String s = channel.dump(Consts.ASCII); Assert.assertFalse(encoder.isCompleted()); Assert.assertEquals("head", s); }
316317318319320321322323324325326
Mockito.verify(outbuf, Mockito.times(1)).flush(channel); Assert.assertEquals(13, metrics.getBytesTransferred()); outbuf.flush(channel); final String s = channel.dump(Consts.ASCII); Assert.assertEquals("header\r\nstuff", s); } @Test
338339340341342343344345346347348
Mockito.verify(outbuf, Mockito.never()).flush(channel); Assert.assertEquals(0, metrics.getBytesTransferred()); outbuf.flush(channel); final String s = channel.dump(Consts.ASCII); Assert.assertEquals("header\r\nstuff", s); } @Test
361362363364365366367368369370371
Mockito.verify(outbuf, Mockito.never()).flush(channel); Assert.assertEquals(0, metrics.getBytesTransferred()); outbuf.flush(channel); final String s = channel.dump(Consts.ASCII); Assert.assertEquals("stuff-more stuff", s); } @Test
383384385386387388389390391392393
Mockito.verify(outbuf, Mockito.times(1)).flush(channel); Assert.assertEquals(13, metrics.getBytesTransferred()); outbuf.flush(channel); final String s = channel.dump(Consts.ASCII); Assert.assertEquals("header\r\nstuff", s); } @Test public void testCodingFragmentBufferingTinyFragments() throws Exception {