コード例 #1
0
 @Test
 public void testURIs() throws URISyntaxException {
   @SuppressWarnings("resource")
   BlockheadClient client = new BlockheadClient(expectedWsUri);
   Assert.assertThat("Websocket URI", client.getWebsocketURI(), is(expectedWsUri));
   Assert.assertThat("Websocket URI", client.getHttpURI(), is(expectedHttpUri));
 }
コード例 #2
0
 /**
  * Test the requirement of responding with an http 400 when using a Sec-WebSocket-Version that is
  * unsupported.
  */
 @Test
 public void testRequestVersion29() throws Exception {
   @SuppressWarnings("resource")
   BlockheadClient client = new BlockheadClient(server.getServerUri());
   client.setVersion(29); // intentionally bad version
   try {
     client.connect();
     client.sendStandardRequest();
     HttpResponse response = client.readResponseHeader();
     Assert.assertThat("Response Status Code", response.getStatusCode(), is(400));
     Assert.assertThat(
         "Response Status Reason",
         response.getStatusReason(),
         containsString("Unsupported websocket version specification"));
     Assert.assertThat("Response Versions", response.getHeader("Sec-WebSocket-Version"), is("13"));
   } finally {
     client.disconnect();
   }
 }