// //// try reading images
for (RemoteImage ri : expectedImages) {
if (ri.getDigest() == null) {
// download should fail
try {
URLImageInputStream is = new URLImageInputStream(ch, ri.getTxId(),
1000);
is.getSize();
fail("Should fail here");
} catch (IOException e) {
LOG.info("Expected exception: ", e);
}
} else {
// the node should contain a valid image
URLImageInputStream stream = new URLImageInputStream(ch, ri.getTxId(), 1000);
// verify the digest
assertEquals(stream.getImageDigest(), digests.get(ri.getTxId()));
// verify size
assertEquals(stream.getSize(), content.get(ri.getTxId()).length);
// read the bytes
byte readBytes[] = new byte[(int) stream.getSize()];
stream.read(readBytes);
// assert contents
assertTrue(Arrays.equals(content.get(ri.getTxId()), readBytes));
}
}