public void test_from_SupplierExceptionOnRead() { CheckedSupplier<InputStream> supplier = () -> { return new InputStream() { @Override public int read() throws IOException { throw new IOException(); } }; }; assertThrows(UncheckedIOException.class, () -> ArrayByteSource.from(supplier)); }
public void test_from_SupplierExceptionOnCreate() { CheckedSupplier<InputStream> supplier = () -> { throw new IOException(); }; assertThrows(UncheckedIOException.class, () -> ArrayByteSource.from(supplier)); }
public void test_from_ByteSource_alreadyArrayByteSource() { ArrayByteSource base = ArrayByteSource.copyOf(new byte[] {1, 2, 3}); ArrayByteSource test = ArrayByteSource.from(base); assertSame(test, base); }
public void test_from_ByteSource() { ByteSource source = ByteSource.wrap(new byte[] {1, 2, 3}); ArrayByteSource test = ArrayByteSource.from(source); assertEquals(test.size(), 3); assertEquals(test.read()[0], 1); assertEquals(test.read()[1], 2); assertEquals(test.read()[2], 3); }
public void test_from_Supplier() { ByteSource source = ByteSource.wrap(new byte[] {1, 2, 3}); ArrayByteSource test = ArrayByteSource.from(() -> source.openStream()); assertEquals(test.size(), 3); assertEquals(test.read()[0], 1); assertEquals(test.read()[1], 2); assertEquals(test.read()[2], 3); }