Code example for BasicHttpEntity

Methods: setContentsetContentLength

0
        assertNull(bytes);
    } 
 
    public void testMaxIntContentToByteArray() throws Exception { 
        byte[] content = "Message content".getBytes("ISO-8859-1");
        BasicHttpEntity httpentity = new BasicHttpEntity();
        httpentity.setContent(new ByteArrayInputStream(content));
        httpentity.setContentLength(Integer.MAX_VALUE + 100L);
        try { 
            EntityUtils.toByteArray(httpentity);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected 
        } 
    } 
 
    public void testUnknownLengthContentToByteArray() throws Exception { 
        byte[] bytes = "Message content".getBytes("ISO-8859-1");
        BasicHttpEntity httpentity = new BasicHttpEntity();
        httpentity.setContent(new ByteArrayInputStream(bytes));
Stop searching for code, let great code find you!  Add Codota to your java IDE