SimpleHttpPostRequestFuture extends HttpPostRequestFuture { public TLVElement getResult() throws KSIException { return parse(responseCode, responseMessage, new ByteArrayInputStream(response)); } SimpleHttpPostRequestFuture(HttpURLConnection connection); boolean isFinished(); TLVElement getResult();  }
@Test public void createSimpleHttpPostRequestFuture200() throws Exception { SimpleHttpPostRequestFuture future = new SimpleHttpPostRequestFuture(getHttpUrlConnection(200, "OK", new ByteArrayInputStream(new byte[] {0x0f, 33, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}))); TLVElement element = future.getResult(); ByteArrayOutputStream out = new ByteArrayOutputStream(); element.writeTo(out); Assert.assertEquals(out.toByteArray(), new byte[] {0x0f, 33, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); }
@Test(expectedExceptions = HttpProtocolException.class, expectedExceptionsMessageRegExp = "\\(400\\):BAD REQUEST") public void createSimpleHttpPostRequestFuture400() throws Exception { SimpleHttpPostRequestFuture future = new SimpleHttpPostRequestFuture( getHttpUrlConnection(400, "BAD REQUEST", new ByteArrayInputStream(new byte[] {1}))); future.getResult(); }
@Test(expectedExceptions = HttpProtocolException.class, expectedExceptionsMessageRegExp = "\\(500\\):INTERNAL SERVER ERROR") public void createSimpleHttpPostRequestFuture500() throws Exception { SimpleHttpPostRequestFuture future = new SimpleHttpPostRequestFuture(getHttpUrlConnection(500, "INTERNAL SERVER ERROR", null)); future.getResult(); }