public class InputStreamBlockReceiverTest extends TestCase {
public void testISBR() throws Exception {
byte[] ba1 = new byte[1000];
ByteArrayInputStream bais = new ByteArrayInputStream(ba1);
PartiallyReceivedBlock prb1 = new PartiallyReceivedBlock(100, 10);
InputStreamBlockReceiver isbr1 = new InputStreamBlockReceiver(prb1, bais);
isbr1.start();
assertTrue(prb1.allReceived());
byte[] ba2 = prb1.getBlock();
for(int x=0; x<ba2.length; x++) {
assertEquals(ba1[x], ba2[x]);
}
bais.reset();
PartiallyReceivedBlock prb2 = new PartiallyReceivedBlock(100, 11);
InputStreamBlockReceiver isbr2 = new InputStreamBlockReceiver(prb2, bais);
isbr2.start();
byte[] ba3 = prb2.getBlock();
for (int x=0; x<ba1.length; x++) {
assertEquals(ba1[x], ba3[x]);
}