Improve test failure on truncated Draft0 handshake read.

+ If a truncated response occurs, attempt to have the test case produce
  a meaningful response message indicating where/how the truncation
  occured, instead of just a 'read timeout'.
This commit is contained in:
Joakim Erdfelt 2012-02-13 11:46:20 -07:00
parent e7608eafae
commit 4caf662182
1 changed files with 13 additions and 5 deletions

View File

@ -125,11 +125,19 @@ public class SafariD00
// Read expected handshake hixie bytes
byte hixieHandshakeExpected[] = TypeUtil.fromHexString("c7438d956cf611a6af70603e6fa54809");
byte hixieHandshake[] = new byte[hixieHandshakeExpected.length];
Assert.assertThat("Hixie handshake buffer size", hixieHandshake.length, is(16));
Assert.assertThat("Hixie handshake buffer size",hixieHandshake.length,is(16));
LOG.debug("Reading hixie handshake bytes");
int readLen = in.read(hixieHandshake,0,hixieHandshake.length);
Assert.assertThat("Read hixie handshake bytes",readLen,is(hixieHandshake.length));
int bytesRead = 0;
while (bytesRead < hixieHandshake.length)
{
int val = in.read();
if (val >= 0)
{
hixieHandshake[bytesRead++] = (byte)val;
}
}
Assert.assertThat("Read hixie handshake bytes",bytesRead,is(hixieHandshake.length));
}
public void sendMessage(String... msgs) throws IOException