use of com.vodafone360.people.tests.service.transport.tcp.conn_less.hb_tests.MockTcpConnectionThread in project 360-Engine-for-Android by 360.
the class ResponseReaderThreadTest method testSetInputstream.
@MediumTest
public void testSetInputstream() {
DecoderThread decoder = new DecoderThread();
MockTcpConnectionThread mockThread = new MockTcpConnectionThread(decoder, null);
MockResponseReaderThread respReader = new MockResponseReaderThread(mockThread, decoder, // QUICKFIX: Not sure about this value
null);
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[] { 1, 2, 3, 4, 5 });
respReader.setInputStream(new BufferedInputStream(bais));
DataInputStream dis = (DataInputStream) respReader.getInputStream();
assertNotNull(dis);
// let's test all the bytes...
if (null != dis) {
boolean areBytesCorrect = true;
for (int i = 1; i < 6; i++) {
try {
int j = dis.readByte();
if (-1 == j) {
fail("Unexpected end of the DataInputStream");
areBytesCorrect = false;
} else if (i != j) {
fail("Characters differ: i: " + i + " vs. j: " + j);
areBytesCorrect = false;
}
} catch (IOException e) {
}
}
assertTrue(areBytesCorrect);
}
respReader.setInputStream(null);
assertNull(respReader.getInputStream());
}
Aggregations