318319320321322323324325326327328
final FileChannel fchannel = testfile.getChannel(); encoder.transfer(fchannel, 0, 20); } finally { testfile.close(); } final String s = channel.dump(Consts.ASCII); Assert.assertTrue(encoder.isCompleted()); Assert.assertEquals("header\r\nstuff;more stuff", s); }
351352353354355356357358359360361
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); }
375376377378379380381382383384385
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
398399400401402403404405406407408
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
422423424425426427428429430431432
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
446447448449450451452453454455456
505506507508509510511512513514515
Assert.assertEquals(21, metrics.getBytesTransferred()); Assert.assertEquals(0, outbuf.length()); outbuf.flush(channel); final String s = channel.dump(Consts.ASCII); Assert.assertEquals("stuff-much more stuff", s); } @Test
534535536537538539540541542543544
Mockito.verify(outbuf, Mockito.times(4)).flush(channel); Assert.assertEquals(8, metrics.getBytesTransferred()); outbuf.flush(channel); final String s = channel.dump(Consts.ASCII); Assert.assertEquals("stuff---", s); Assert.assertEquals(3, outbuf.length()); }
559560561562563564565566567568569
Mockito.verify(outbuf, Mockito.times(1)).flush(channel); Assert.assertEquals(8, metrics.getBytesTransferred()); outbuf.flush(channel); final String s = channel.dump(Consts.ASCII); Assert.assertEquals("stuff--m", s); Assert.assertEquals(0, outbuf.length()); }
7475767778798081828384
Assert.assertTrue(encoder.isCompleted()); Assert.assertEquals(5, metrics.getBytesTransferred()); outbuf.flush(channel); final String s = channel.dump(Consts.ASCII); Assert.assertEquals("stuff", s); Assert.assertEquals("[identity; completed: true]", encoder.toString()); }