我想测试我写到OutputStream
(文件输出流)的字节与我从同一InputStream
(文件输入流)读取的字节是否相同。
测试看起来像:
@Test
public void testStreamBytes() throws PersistenceException, IOException, ClassNotFoundException {
String uniqueId = "TestString";
final OutputStream outStream = fileService.getOutputStream(uniqueId);
new ObjectOutputStream(outStream).write(uniqueId.getBytes());
final InputStream inStream = fileService.getInputStream(uniqueId);
}
我意识到
InputStream
没有getBytes()
方法。
我该如何测试类似于
assertEquals(inStream.getBytes(), uniqueId.getBytes())
谢谢你。