/** Basic upload through the channel. */ @Test public void testBasic() throws Exception { long txid = 101; int iterations = 10; HttpImageUploadChannel channel = new HttpImageUploadChannel(httpAddress, journalId, FAKE_NSINFO, txid, 0, 100); channel.start(); ByteArrayOutputStream bos = genBos(); for (int i = 0; i < iterations; i++) { channel.send(bos); } channel.close(); // validate // the file should exist File uploaded = journal.getImageStorage().getCheckpointImageFile(txid); assertTrue(uploaded.exists()); assertEquals(iterations * randomBytes.length, uploaded.length()); // assert contents of the uploaded file InputStream is = new FileInputStream(uploaded); byte[] contents = new byte[randomBytes.length]; for (int i = 0; i < iterations; i++) { is.read(contents); assertTrue(Arrays.equals(randomBytes, contents)); } is.close(); }