@Test public void testWriteWithChunkSize() throws Exception { final CryptoVault vault = this.getVault(); final ByteArrayOutputStream cipherText = new ByteArrayOutputStream(); final FileHeader header = vault.getFileHeaderCryptor().create(); final CryptoOutputStream<?> stream = new CryptoOutputStream<>(new StatusOutputStream<Void>(cipherText) { @Override public Void getStatus() { return null; } }, vault.getFileContentCryptor(), header, new RandomNonceGenerator(), 0); final byte[] cleartext = RandomUtils.nextBytes(vault.getFileContentCryptor().cleartextChunkSize()); stream.write(cleartext, 0, cleartext.length); stream.close(); final byte[] read = new byte[cleartext.length]; final CryptoInputStream cryptoInputStream = new CryptoInputStream(new ByteArrayInputStream(cipherText.toByteArray()), vault.getFileContentCryptor(), header, 0); assertEquals(cleartext.length, cryptoInputStream.read(read)); cryptoInputStream.close(); assertArrayEquals(cleartext, read); }
@Override public void write(final int b) throws IOException { throw new IOException(new UnsupportedOperationException()); }
CryptoOutputStream extends StatusOutputStream<Reply> { @Override public void write(final int b) throws IOException { throw new IOException(new UnsupportedOperationException()); } }
CryptoOutputStream extends StatusOutputStream<Reply> { @Override public void write(final int b) throws IOException { throw new IOException(new UnsupportedOperationException()); } CryptoOutputStream(final StatusOutputStream<Reply> proxy, final FileContentCryptor cryptor, final FileHeader header,
                              final NonceGenerator nonces, final long chunkIndexOffset); }
CryptoOutputStream extends StatusOutputStream<Reply> { @Override public void write(final int b) throws IOException { throw new IOException(new UnsupportedOperationException()); } CryptoOutputStream(final StatusOutputStream<Reply> proxy, final FileContentCryptor cryptor, final FileHeader header,
                              final NonceGenerator nonces, final long chunkIndexOffset); @Override void write(final int b); @Override Reply getStatus(); @Override void write(final byte[] b); }
CryptoOutputStream extends StatusOutputStream<Reply> { @Override public void write(final int b) throws IOException { throw new IOException(new UnsupportedOperationException()); } CryptoOutputStream(final StatusOutputStream<Reply> proxy, final FileContentCryptor cryptor, final FileHeader header,
                              final NonceGenerator nonces, final long chunkIndexOffset); @Override void write(final int b); @Override Reply getStatus(); @Override void write(final byte[] b);  }