RuleDatabaseItemUpdateRunnable implements Runnable { void copyStream(InputStream inStream, OutputStream outStream) throws IOException { byte[] buffer = new byte[4096]; int read; while ((read = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, read); } } RuleDatabaseItemUpdateRunnable(@NonNull RuleDatabaseUpdateTask parentTask, @NonNull Context context, @NonNull Configuration.Item item); @Override void run();  }
@Test public void testCopyStream() throws Exception { RuleDatabaseItemUpdateRunnable itemUpdateRunnable = new RuleDatabaseItemUpdateRunnable(realTask, mockContext, mock(Configuration.Item.class)); byte[] bar = new byte[]{'h', 'a', 'l', 'l', 'o'}; ByteArrayInputStream bis = new ByteArrayInputStream(bar); ByteArrayOutputStream bos = new ByteArrayOutputStream(); itemUpdateRunnable.copyStream(bis, bos); assertArrayEquals(bar, bos.toByteArray()); }