List of usage examples for org.apache.http.entity BasicHttpEntity setContent
public void setContent(InputStream inputStream)
From source file:org.apache.hadoop.gateway.dispatch.CappedBufferHttpEntityTest.java
@Test public void testB_C1_FC_OB__C2_AC__EE() throws Exception { String data = "0123456789"; BasicHttpEntity basic; CappedBufferHttpEntity replay;//from w w w . j a va 2 s .com basic = new BasicHttpEntity(); basic.setContent(new ByteArrayInputStream(data.getBytes(UTF8))); replay = new CappedBufferHttpEntity(basic, 5); String output; try { output = blockRead(replay.getContent(), UTF8, -1, 3); fail("Expected IOException"); } catch (IOException e) { // Expected. } }
From source file:org.apache.hadoop.gateway.dispatch.CappedBufferHttpEntityTest.java
@Test public void testWriteTo() throws Exception { String input = "0123456789"; BasicHttpEntity basic; CappedBufferHttpEntity replay;//from w ww .java 2 s .co m basic = new BasicHttpEntity(); basic.setContent(new ByteArrayInputStream(input.getBytes(UTF8))); replay = new CappedBufferHttpEntity(basic, 5); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try { replay.writeTo(buffer); fail("expected IOException"); } catch (IOException e) { // expected } }
From source file:org.apache.hadoop.gateway.dispatch.CappedBufferHttpEntityTest.java
@Test public void testS__C1_FC_OB() throws IOException { String data = "0123456789"; BasicHttpEntity basic; CappedBufferHttpEntity replay;//w ww . j a v a 2 s . c o m basic = new BasicHttpEntity(); basic.setContent(new ByteArrayInputStream(data.getBytes("UTF-8"))); replay = new CappedBufferHttpEntity(basic, 5); String output; try { output = byteRead(replay.getContent(), -1); fail("expected IOException"); } catch (IOException e) { // expected } }
From source file:org.apache.hadoop.gateway.dispatch.CappedBufferHttpEntityTest.java
@Test public void testB__C1_FC_OB() throws IOException { String data = "0123456789"; BasicHttpEntity basic; CappedBufferHttpEntity replay;/*from w w w. j a v a 2 s .c o m*/ basic = new BasicHttpEntity(); basic.setContent(new ByteArrayInputStream(data.getBytes("UTF-8"))); replay = new CappedBufferHttpEntity(basic, 5); String output; try { output = blockRead(replay.getContent(), UTF8, -1, 3); fail("expected IOException"); } catch (IOException e) { // expected } }
From source file:org.apache.hadoop.gateway.dispatch.CappedBufferHttpEntityTest.java
@Test public void testS_C1_FC_OB__C2_AC__EE() throws Exception { String data = "0123456789"; BasicHttpEntity basic; CappedBufferHttpEntity replay;/*from w w w . j a v a 2 s.c om*/ basic = new BasicHttpEntity(); basic.setContent(new ByteArrayInputStream(data.getBytes(UTF8))); replay = new CappedBufferHttpEntity(basic, 5); String output; try { output = byteRead(replay.getContent(), -1); fail("Expected IOException"); } catch (IOException e) { // Expected. } }
From source file:org.apache.hadoop.gateway.dispatch.PartiallyRepeatableHttpEntityTest.java
@Test public void testS__C1_FC_IB() throws IOException { String data = "0123456789"; BasicHttpEntity basic; PartiallyRepeatableHttpEntity replay; basic = new BasicHttpEntity(); basic.setContent(new ByteArrayInputStream(data.getBytes("UTF-8"))); replay = new PartiallyRepeatableHttpEntity(basic, 20); String output;/*from w w w. j ava 2 s . c o m*/ output = byteRead(replay.getContent(), -1); assertThat(output, is(data)); }
From source file:org.apache.hadoop.gateway.dispatch.PartiallyRepeatableHttpEntityTest.java
@Test public void testB__C1_FC_IB() throws IOException { String data = "0123456789"; BasicHttpEntity basic; PartiallyRepeatableHttpEntity replay; basic = new BasicHttpEntity(); basic.setContent(new ByteArrayInputStream(data.getBytes("UTF-8"))); replay = new PartiallyRepeatableHttpEntity(basic, 20); String output;//from w w w.j ava 2 s . c o m output = blockRead(replay.getContent(), UTF8, -1, 3); assertThat(output, is(data)); }
From source file:org.apache.hadoop.gateway.dispatch.PartiallyRepeatableHttpEntityTest.java
@Test public void testS__C1_FC_OB() throws IOException { String data = "0123456789"; BasicHttpEntity basic; PartiallyRepeatableHttpEntity replay; basic = new BasicHttpEntity(); basic.setContent(new ByteArrayInputStream(data.getBytes("UTF-8"))); replay = new PartiallyRepeatableHttpEntity(basic, 5); String output;/*from w w w . ja va 2 s. c o m*/ output = byteRead(replay.getContent(), -1); assertThat(output, is(data)); }
From source file:org.apache.hadoop.gateway.dispatch.PartiallyRepeatableHttpEntityTest.java
@Test public void testB__C1_FC_OB() throws IOException { String data = "0123456789"; BasicHttpEntity basic; PartiallyRepeatableHttpEntity replay; basic = new BasicHttpEntity(); basic.setContent(new ByteArrayInputStream(data.getBytes("UTF-8"))); replay = new PartiallyRepeatableHttpEntity(basic, 5); String output;/*from w w w . jav a2 s . co m*/ output = blockRead(replay.getContent(), UTF8, -1, 3); assertThat(output, is(data)); }
From source file:org.apache.hadoop.gateway.dispatch.PartiallyRepeatableHttpEntityTest.java
@Test public void testWriteTo() throws Exception { String input = "0123456789"; BasicHttpEntity basic; PartiallyRepeatableHttpEntity replay; basic = new BasicHttpEntity(); basic.setContent(new ByteArrayInputStream(input.getBytes(UTF8))); replay = new PartiallyRepeatableHttpEntity(basic, 5); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); replay.writeTo(buffer);/*w ww .j av a 2 s.co m*/ String output = new String(buffer.toByteArray(), UTF8); assertThat(output, is(input)); }