use of org.apache.commons.lang3.mutable.MutableObject in project rest-assured by rest-assured.
the class HttpClientConfigITest method http_client_config_allows_specifying_that_the_http_client_instance_is_reused_in_multiple_requests.
@Test
public void http_client_config_allows_specifying_that_the_http_client_instance_is_reused_in_multiple_requests() {
final MutableObject<HttpClient> client1 = new MutableObject<HttpClient>();
final MutableObject<HttpClient> client2 = new MutableObject<HttpClient>();
RestAssured.config = RestAssuredConfig.newConfig().httpClient(HttpClientConfig.httpClientConfig().reuseHttpClientInstance());
// When
try {
given().param("url", "/hello").filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
client1.setValue(requestSpec.getHttpClient());
return ctx.next(requestSpec, responseSpec);
}
}).expect().body("hello", equalTo("Hello Scalatra")).when().get("/redirect");
given().header("name", "value").filter((requestSpec, responseSpec, ctx) -> {
client2.setValue(requestSpec.getHttpClient());
return ctx.next(requestSpec, responseSpec);
}).when().post("/reflect");
} finally {
RestAssured.reset();
}
assertThat(client1.getValue(), sameInstance(client2.getValue()));
}
use of org.apache.commons.lang3.mutable.MutableObject in project rest-assured by rest-assured.
the class AcceptHeaderITest method accept_headers_are_merged_from_request_spec_and_request_when_configured_to.
@Test
public void accept_headers_are_merged_from_request_spec_and_request_when_configured_to() {
RequestSpecification spec = new RequestSpecBuilder().setAccept("text/jux").build();
final MutableObject<List<String>> headers = new MutableObject<List<String>>();
RestAssured.given().config(RestAssuredConfig.config().headerConfig(HeaderConfig.headerConfig().mergeHeadersWithName("Accept"))).accept(ContentType.JSON).spec(spec).body("{ \"message\" : \"hello world\"}").filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
headers.setValue(requestSpec.getHeaders().getValues("Accept"));
return ctx.next(requestSpec, responseSpec);
}
}).when().post("/jsonBodyAcceptHeader").then().body(equalTo("hello world"));
assertThat(headers.getValue(), contains("application/json, application/javascript, text/javascript, text/json", "text/jux"));
}
use of org.apache.commons.lang3.mutable.MutableObject in project rest-assured by rest-assured.
the class ResultHandlerTest method supports_using_result_handlers_using_the_response_dsl.
@Test
public void supports_using_result_handlers_using_the_response_dsl() {
MutableObject<Boolean> mutableObject = new MutableObject<Boolean>(false);
RestAssuredMockMvc.given().header(new Header("headerName", "John Doe")).when().get("/header").then().apply(print(), customResultHandler(mutableObject)).statusCode(200).body("headerName", equalTo("John Doe"));
assertThat(mutableObject.getValue(), is(true));
}
use of org.apache.commons.lang3.mutable.MutableObject in project neo4j by neo4j.
the class ConsistencyCheckWithCorruptGBPTreeIT method corruptionInRelationshipTypeIndex.
@Test
void corruptionInRelationshipTypeIndex() throws Exception {
MutableObject<Long> rootNode = new MutableObject<>();
Path relationshipTypeScanStoreFile = relationshipTypeScanStoreFile();
corruptIndexes(readOnly(), (tree, inspection) -> {
rootNode.setValue(inspection.getRootNode());
tree.unsafe(pageSpecificCorruption(rootNode.getValue(), GBPTreeCorruption.broken(GBPTreePointerType.leftSibling())), CursorContext.NULL);
}, relationshipTypeScanStoreFile);
ConsistencyCheckService.Result result = runConsistencyCheck(NullLogProvider.getInstance());
assertFalse(result.isSuccessful());
assertResultContainsMessage(result, "Index inconsistency: Broken pointer found in tree node " + rootNode.getValue() + ", pointerType='left sibling'");
assertResultContainsMessage(result, "Number of inconsistent RELATIONSHIP_TYPE_SCAN_DOCUMENT records: 1");
}
use of org.apache.commons.lang3.mutable.MutableObject in project neo4j by neo4j.
the class ConsistencyCheckWithCorruptGBPTreeIT method corruptionInCountsStore.
@Test
void corruptionInCountsStore() throws Exception {
MutableObject<Long> rootNode = new MutableObject<>();
Path countsStoreFile = countsStoreFile();
final LayoutBootstrapper countsLayoutBootstrapper = (indexFile, pageCache, meta) -> new CountsLayout();
corruptIndexes(fs, readOnly(), (tree, inspection) -> {
rootNode.setValue(inspection.getRootNode());
tree.unsafe(pageSpecificCorruption(rootNode.getValue(), GBPTreeCorruption.broken(GBPTreePointerType.leftSibling())), CursorContext.NULL);
}, countsLayoutBootstrapper, countsStoreFile);
ConsistencyFlags flags = new ConsistencyFlags(false, false, true);
ConsistencyCheckService.Result result = runConsistencyCheck(NullLogProvider.getInstance(), flags);
assertFalse(result.isSuccessful());
assertResultContainsMessage(result, "Index inconsistency: Broken pointer found in tree node " + rootNode.getValue() + ", pointerType='left sibling'");
assertResultContainsMessage(result, "Number of inconsistent COUNTS records: 1");
}
Aggregations