use of org.apache.http.entity.BasicHttpEntity in project knox by apache.
the class PartiallyRepeatableHttpEntityTest method testS_C1_FC_IB__C2_FC_IB.
@Test
public void testS_C1_FC_IB__C2_FC_IB() throws IOException {
String data = "0123456789";
BasicHttpEntity basic;
PartiallyRepeatableHttpEntity replay;
basic = new BasicHttpEntity();
basic.setContent(new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)));
replay = new PartiallyRepeatableHttpEntity(basic, 20);
String output;
output = byteRead(replay.getContent(), -1);
assertThat(output, is(data));
output = byteRead(replay.getContent(), -1);
assertThat(output, is(data));
}
use of org.apache.http.entity.BasicHttpEntity in project knox by apache.
the class PartiallyRepeatableHttpEntityTest method testS_C1_FC_OB__C2_AC__EE.
@Test(expected = IOException.class)
public void testS_C1_FC_OB__C2_AC__EE() throws Exception {
String data = "0123456789";
BasicHttpEntity basic;
PartiallyRepeatableHttpEntity replay;
basic = new BasicHttpEntity();
basic.setContent(new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)));
replay = new PartiallyRepeatableHttpEntity(basic, 5);
String output;
output = byteRead(replay.getContent(), -1);
assertThat(output, is(data));
replay.getContent();
}
use of org.apache.http.entity.BasicHttpEntity in project knox by apache.
the class PartiallyRepeatableHttpEntityTest method testB_C1_PC_IB__C2_FC.
// C1 PC/IB; C2 FC.
@Test
public void testB_C1_PC_IB__C2_FC() throws IOException {
String data = "0123456789";
BasicHttpEntity basic;
PartiallyRepeatableHttpEntity replay;
InputStream stream;
String text;
basic = new BasicHttpEntity();
basic.setContent(new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)));
replay = new PartiallyRepeatableHttpEntity(basic, 20);
stream = replay.getContent();
text = blockRead(stream, StandardCharsets.UTF_8, 4, 1);
assertThat(text, is("0123"));
stream.close();
stream = replay.getContent();
text = blockRead(stream, StandardCharsets.UTF_8, -1, 7);
assertThat(text, is("0123456789"));
}
use of org.apache.http.entity.BasicHttpEntity in project knox by apache.
the class PartiallyRepeatableHttpEntityTest method testIsChunked.
@Test
public void testIsChunked() throws Exception {
String input = "0123456789";
BasicHttpEntity basic;
PartiallyRepeatableHttpEntity replay;
basic = new BasicHttpEntity();
basic.setContent(new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)));
replay = new PartiallyRepeatableHttpEntity(basic, 5);
assertThat(replay.isChunked(), is(false));
basic = new BasicHttpEntity();
basic.setContent(new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)));
basic.setChunked(true);
replay = new PartiallyRepeatableHttpEntity(basic, 5);
assertThat(replay.isChunked(), is(true));
}
use of org.apache.http.entity.BasicHttpEntity in project knox by apache.
the class PartiallyRepeatableHttpEntityTest method testIsStreaming.
@Test
public void testIsStreaming() throws Exception {
String input = "0123456789";
BasicHttpEntity basic;
InputStreamEntity streaming;
PartiallyRepeatableHttpEntity replay;
basic = new BasicHttpEntity();
basic.setContent(new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)));
replay = new PartiallyRepeatableHttpEntity(basic, 5);
assertThat(replay.isStreaming(), is(true));
basic = new BasicHttpEntity();
basic.setContent(null);
replay = new PartiallyRepeatableHttpEntity(basic, 5);
assertThat(replay.isStreaming(), is(false));
streaming = new InputStreamEntity(new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)), 10, ContentType.TEXT_PLAIN);
replay = new PartiallyRepeatableHttpEntity(streaming, 5);
assertThat(replay.isStreaming(), is(true));
}
Aggregations