use of org.apache.commons.io.output.WriterOutputStream in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method logging_is_not_overwritten_when_not_defined_in_specification.
@Test
public void logging_is_not_overwritten_when_not_defined_in_specification() {
// Given
StringWriter writer = new StringWriter();
PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setConfig(RestAssuredMockMvcConfig.newConfig().logConfig(LogConfig.logConfig().defaultStream(captor))).addQueryParam("name", "Johan").build();
// When
RestAssuredMockMvc.given().spec(specToMerge).log().params().standaloneSetup(new GreetingController()).when().get("/greeting").then().body("id", equalTo(1)).body("content", equalTo("Hello, Johan!"));
// Then
assertThat(writer.toString()).isEqualTo("Request params:\t<none>\n" + "Query params:\tname=Johan\n" + "Form params:\t<none>\n" + "Path params:\t<none>\n" + "Multiparts:\t\t<none>\n");
}
use of org.apache.commons.io.output.WriterOutputStream in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method logging_is_overwritten_when_defined_in_specification.
@Test
public void logging_is_overwritten_when_defined_in_specification() {
// Given
StringWriter writer = new StringWriter();
PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setConfig(RestAssuredMockMvcConfig.newConfig().logConfig(LogConfig.logConfig().defaultStream(captor))).and().log(LogDetail.ALL).build();
// When
RestAssuredMockMvc.given().log().params().spec(specToMerge).standaloneSetup(new GreetingController()).when().get("/greeting?name={name}", "Johan").then().body("id", equalTo(1)).body("content", equalTo("Hello, Johan!"));
// Then
assertThat(writer.toString()).isEqualTo("Request method:\tGET\n" + "Request URI:\thttp://localhost:8080/greeting?name=Johan\n" + "Proxy:\t\t\t<none>\n" + "Request params:\t<none>\n" + "Query params:\t<none>\n" + "Form params:\t<none>\n" + "Path params:\t<none>\n" + "Headers:\t\t<none>\n" + "Cookies:\t\t<none>\n" + "Multiparts:\t\t<none>\n" + "Body:\t\t\t<none>\n");
}
use of org.apache.commons.io.output.WriterOutputStream in project cas by apereo.
the class CasTomcatBannerTests method verifyAction.
@Test
public void verifyAction() {
val banner = new CasTomcatBanner();
val writer = new StringWriter();
val out = new WriterOutputStream(writer, StandardCharsets.UTF_8);
try (val stream = new PrintStream(out, true, StandardCharsets.UTF_8)) {
banner.printBanner(environment, CasTomcatBanner.class, stream);
}
val output = writer.toString();
assertNotNull(output);
}
use of org.apache.commons.io.output.WriterOutputStream in project cas by apereo.
the class CasJettyBannerTests method verifyAction.
@Test
public void verifyAction() {
val banner = new CasJettyBanner();
val writer = new StringWriter();
val out = new WriterOutputStream(writer, StandardCharsets.UTF_8);
try (val stream = new PrintStream(out, true, StandardCharsets.UTF_8)) {
banner.printBanner(environment, CasJettyBanner.class, stream);
}
val output = writer.toString();
assertNotNull(output);
}
use of org.apache.commons.io.output.WriterOutputStream in project cas by apereo.
the class CasStarterBannerTests method verifyAction.
@Test
public void verifyAction() {
val banner = new CasStarterBanner();
val writer = new StringWriter();
val out = new WriterOutputStream(writer, StandardCharsets.UTF_8);
try (val stream = new PrintStream(out, true, StandardCharsets.UTF_8)) {
banner.printBanner(environment, CasStarterBanner.class, stream);
}
val output = writer.toString();
assertNotNull(output);
assertTrue(output.contains("Starter"));
}
Aggregations