@Test public void testContent() throws Exception { final byte[] bytes = "Message content".getBytes(StandardCharsets.US_ASCII); final InputStream content = new ByteArrayInputStream(bytes); final BasicHttpEntity httpentity = new BasicHttpEntity(); try { httpentity.getContent(); Assert.fail("IllegalStateException should have been thrown"); } catch (final IllegalStateException ex) { // expected } httpentity.setContent(content); Assert.assertEquals(content, httpentity.getContent()); httpentity.setContent(null); try { httpentity.getContent(); Assert.fail("IllegalStateException should have been thrown"); } catch (final IllegalStateException ex) { // expected } }