use of io.restassured.config.RestAssuredConfig in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method configurations_are_merged.
@Test
public void configurations_are_merged() {
// Given
RestAssuredMockMvcConfig cfg1 = new RestAssuredMockMvcConfig().with().jsonConfig(jsonConfig().with().numberReturnType(JsonPathConfig.NumberReturnType.FLOAT_AND_DOUBLE));
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setConfig(cfg1).build();
// When
RestAssuredMockMvcConfig cfg2 = new RestAssuredMockMvcConfig().sessionConfig(sessionConfig().sessionIdName("php"));
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().config(cfg2).spec(specToMerge);
// Then
RestAssuredConfig mergedConfig = implOf(spec).getRestAssuredConfig();
assertThat(mergedConfig.getSessionConfig().sessionIdName()).isEqualTo("php");
assertThat(mergedConfig.getJsonConfig().numberReturnType()).isEqualTo(JsonPathConfig.NumberReturnType.FLOAT_AND_DOUBLE);
}
use of io.restassured.config.RestAssuredConfig in project rest-assured by rest-assured.
the class RequestSpecBuilder method log.
/**
* Enabled logging with the specified log detail. Set a {@link LogConfig} to configure the print stream and pretty printing options.
*
* @param logDetail The log detail.
* @return RequestSpecBuilder
*/
public RequestSpecBuilder log(LogDetail logDetail) {
notNull(logDetail, LogDetail.class);
RestAssuredConfig restAssuredConfig = spec.getConfig();
LogConfig logConfig;
if (restAssuredConfig == null) {
logConfig = new RestAssuredConfig().getLogConfig();
} else {
logConfig = restAssuredConfig.getLogConfig();
}
PrintStream printStream = logConfig.defaultStream();
boolean prettyPrintingEnabled = logConfig.isPrettyPrintingEnabled();
boolean shouldUrlEncodeRequestUri = logConfig.shouldUrlEncodeRequestUri();
spec.filter(new RequestLoggingFilter(logDetail, prettyPrintingEnabled, printStream, shouldUrlEncodeRequestUri));
return this;
}
use of io.restassured.config.RestAssuredConfig in project rest-assured by rest-assured.
the class DecoderConfigITest method filters_can_change_content_decoders.
@Test
public void filters_can_change_content_decoders() {
given().config(RestAssuredConfig.newConfig().decoderConfig(DecoderConfig.decoderConfig().contentDecoders(DecoderConfig.ContentDecoder.GZIP, DecoderConfig.ContentDecoder.DEFLATE))).filter((requestSpec, responseSpec, ctx) -> {
final RestAssuredConfig config1 = requestSpec.getConfig();
assertThat(config1.getDecoderConfig().contentDecoders(), Matchers.contains(DecoderConfig.ContentDecoder.GZIP, DecoderConfig.ContentDecoder.DEFLATE));
requestSpec.config(config1.decoderConfig(new DecoderConfig(DecoderConfig.ContentDecoder.DEFLATE)));
return ctx.next(requestSpec, responseSpec);
}).expect().body("Accept-Encoding", contains("deflate")).when().get("/headersWithValues");
}
Aggregations