Search in sources :

Example 76 with MutableObject

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()));
}
Also used : Response(io.restassured.response.Response) FilterableResponseSpecification(io.restassured.specification.FilterableResponseSpecification) Filter(io.restassured.filter.Filter) SystemDefaultHttpClient(org.apache.http.impl.client.SystemDefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) FilterableRequestSpecification(io.restassured.specification.FilterableRequestSpecification) MutableObject(org.apache.commons.lang3.mutable.MutableObject) FilterContext(io.restassured.filter.FilterContext) Test(org.junit.Test)

Example 77 with MutableObject

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"));
}
Also used : Response(io.restassured.response.Response) FilterableResponseSpecification(io.restassured.specification.FilterableResponseSpecification) Filter(io.restassured.filter.Filter) FilterableRequestSpecification(io.restassured.specification.FilterableRequestSpecification) RequestSpecification(io.restassured.specification.RequestSpecification) List(java.util.List) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) FilterableRequestSpecification(io.restassured.specification.FilterableRequestSpecification) MutableObject(org.apache.commons.lang3.mutable.MutableObject) FilterContext(io.restassured.filter.FilterContext) Test(org.junit.Test)

Example 78 with MutableObject

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));
}
Also used : Header(io.restassured.http.Header) MutableObject(org.apache.commons.lang3.mutable.MutableObject) Test(org.junit.Test)

Example 79 with MutableObject

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");
}
Also used : Path(java.nio.file.Path) MutableObject(org.apache.commons.lang3.mutable.MutableObject) Test(org.junit.jupiter.api.Test)

Example 80 with MutableObject

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");
}
Also used : Path(java.nio.file.Path) BeforeEach(org.junit.jupiter.api.BeforeEach) DatabaseReadOnlyChecker.readOnly(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.readOnly) GBPTreeCorruption.pageSpecificCorruption(org.neo4j.index.internal.gbptree.GBPTreeCorruption.pageSpecificCorruption) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Config(org.neo4j.configuration.Config) NullLogProvider(org.neo4j.logging.NullLogProvider) InspectingVisitor(org.neo4j.index.internal.gbptree.InspectingVisitor) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) TestInstance(org.junit.jupiter.api.TestInstance) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) NATIVE30(org.neo4j.configuration.GraphDatabaseSettings.SchemaIndex.NATIVE30) BeforeAll(org.junit.jupiter.api.BeforeAll) MutableObject(org.apache.commons.lang3.mutable.MutableObject) Transaction(org.neo4j.graphdb.Transaction) Path(java.nio.file.Path) UncloseableDelegatingFileSystemAbstraction(org.neo4j.io.fs.UncloseableDelegatingFileSystemAbstraction) DatabaseReadOnlyChecker.writable(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable) TestDirectory(org.neo4j.test.rule.TestDirectory) String.format(java.lang.String.format) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Test(org.junit.jupiter.api.Test) List(java.util.List) NATIVE_BTREE10(org.neo4j.configuration.GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Writer(java.io.Writer) DatabaseReadOnlyChecker(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) IOUtils.readLines(org.apache.commons.io.IOUtils.readLines) NONE(org.neo4j.internal.helpers.progress.ProgressMonitorFactory.NONE) ImmutableLongList(org.eclipse.collections.api.list.primitive.ImmutableLongList) GBPTreeInspection(org.neo4j.index.internal.gbptree.GBPTreeInspection) Arrays(org.bouncycastle.util.Arrays) Label(org.neo4j.graphdb.Label) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) LogProvider(org.neo4j.logging.LogProvider) NULL(org.neo4j.io.pagecache.tracing.PageCacheTracer.NULL) JobSchedulerFactory.createInitialisedScheduler(org.neo4j.kernel.impl.scheduler.JobSchedulerFactory.createInitialisedScheduler) GBPTreeBootstrapper(org.neo4j.index.internal.gbptree.GBPTreeBootstrapper) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) GBPTree(org.neo4j.index.internal.gbptree.GBPTree) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) SchemaLayouts(org.neo4j.kernel.impl.index.schema.SchemaLayouts) CountsLayout(org.neo4j.internal.counts.CountsLayout) GBPTreeCorruption(org.neo4j.index.internal.gbptree.GBPTreeCorruption) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) JobScheduler(org.neo4j.scheduler.JobScheduler) FileHandle(org.neo4j.io.fs.FileHandle) DEFAULT(org.neo4j.consistency.checking.full.ConsistencyFlags.DEFAULT) UTF_8(java.nio.charset.StandardCharsets.UTF_8) StringWriter(java.io.StringWriter) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) IOException(java.io.IOException) IndexDirectoryStructure(org.neo4j.kernel.api.index.IndexDirectoryStructure) ProgressMonitorFactory(org.neo4j.internal.helpers.progress.ProgressMonitorFactory) GBPTreePointerType(org.neo4j.index.internal.gbptree.GBPTreePointerType) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) ConsistencyCheckIncompleteException(org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) EphemeralFileSystemAbstraction(org.neo4j.io.fs.EphemeralFileSystemAbstraction) NO_FLUSH_ON_CLOSE(org.neo4j.index.internal.gbptree.GBPTreeOpenOptions.NO_FLUSH_ON_CLOSE) GraphDatabaseSettings.neo4j_home(org.neo4j.configuration.GraphDatabaseSettings.neo4j_home) ConsistencyFlags(org.neo4j.consistency.checking.full.ConsistencyFlags) LayoutBootstrapper(org.neo4j.index.internal.gbptree.LayoutBootstrapper) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) LayoutBootstrapper(org.neo4j.index.internal.gbptree.LayoutBootstrapper) ConsistencyFlags(org.neo4j.consistency.checking.full.ConsistencyFlags) CountsLayout(org.neo4j.internal.counts.CountsLayout) MutableObject(org.apache.commons.lang3.mutable.MutableObject) Test(org.junit.jupiter.api.Test)

Aggregations

Mutable (org.apache.commons.lang3.mutable.Mutable)119 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)113 MutableObject (org.apache.commons.lang3.mutable.MutableObject)111 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)101 ArrayList (java.util.ArrayList)93 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)91 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)78 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)54 AssignOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)49 Pair (org.apache.hyracks.algebricks.common.utils.Pair)47 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)46 ConstantExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression)35 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)29 GbyVariableExpressionPair (org.apache.asterix.lang.common.expression.GbyVariableExpressionPair)26 ILogicalPlan (org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)25 List (java.util.List)23 AsterixConstantValue (org.apache.asterix.om.constants.AsterixConstantValue)23 AggregateFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression)23 UnnestingFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression)23 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)22