View Javadoc
1   package emissary.util.shell;
2   
3   import org.apache.commons.io.IOUtils;
4   import org.junit.jupiter.api.Test;
5   
6   import java.io.ByteArrayOutputStream;
7   import java.io.InputStream;
8   import java.nio.charset.Charset;
9   
10  import static org.junit.jupiter.api.Assertions.assertArrayEquals;
11  import static org.junit.jupiter.api.Assertions.assertNotNull;
12  import static org.junit.jupiter.api.Assertions.fail;
13  
14  class ReadBinaryOutputBufferTest {
15  
16      @Test
17      void runImpl() {
18          try (InputStream is = IOUtils.toInputStream("Testing", Charset.defaultCharset())) {
19              ReadBinaryOutputBuffer buffer = new ReadBinaryOutputBuffer(is, new ByteArrayOutputStream());
20              buffer.runImpl();
21              buffer.finish();
22              assertArrayEquals("Testing".getBytes(), buffer.getBytes());
23              assertNotNull(buffer.getByteStream());
24          } catch (Exception e) {
25              fail(e);
26          }
27      }
28  }