Search in sources :

Example 26 with Response

use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.

the class TransactionIT method shouldWorkWhenHittingTheASTCacheInCypher.

@Test
public void shouldWorkWhenHittingTheASTCacheInCypher() throws JsonParseException {
    // give a cached plan
    Response response = http.POST("/db/data/transaction/commit", singleStatement("MATCH (group:Group {name: \\\"AAA\\\"}) RETURN *"));
    assertThat(response.status(), equalTo(200));
    assertThat(response.get("errors").size(), equalTo(0));
    // when we hit the ast cache
    response = http.POST("/db/data/transaction/commit", singleStatement("MATCH (group:Group {name: \\\"BBB\\\"}) RETURN *"));
    // then no errors (in particular no NPE)
    assertThat(response.status(), equalTo(200));
    assertThat(response.get("errors").size(), equalTo(0));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 27 with Response

use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.

the class TransactionIT method begin__rollback__commit.

@Test
public void begin__rollback__commit() throws Exception {
    // begin
    Response begin = http.POST("/db/data/transaction");
    assertThat(begin.status(), equalTo(201));
    assertHasTxLocation(begin);
    String commitResource = begin.stringFromContent("commit");
    // terminate
    Response interrupt = http.DELETE(begin.location());
    assertThat(interrupt.status(), equalTo(200));
    // commit
    Response commit = http.POST(commitResource);
    assertThat(commit.status(), equalTo(404));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 28 with Response

use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.

the class TransactionIT method begin__execute__commit.

@Test
public void begin__execute__commit() throws Exception {
    long nodesInDatabaseBeforeTransaction = countNodes();
    // begin
    Response begin = http.POST("/db/data/transaction");
    assertThat(begin.status(), equalTo(201));
    assertHasTxLocation(begin);
    String commitResource = begin.stringFromContent("commit");
    assertThat(commitResource, matches("http://localhost:\\d+/db/data/transaction/\\d+/commit"));
    assertThat(begin.get("transaction").get("expires").asText(), isValidRFCTimestamp());
    // execute
    Response execute = http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
    assertThat(execute.status(), equalTo(200));
    assertThat(execute.get("transaction").get("expires").asText(), isValidRFCTimestamp());
    // commit
    Response commit = http.POST(commitResource);
    assertThat(commit.status(), equalTo(200));
    assertThat(countNodes(), equalTo(nodesInDatabaseBeforeTransaction + 1));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 29 with Response

use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.

the class QueryResultsSerializationTest method shouldBeAbleToReturnDeletedNodesRest.

@Test
public void shouldBeAbleToReturnDeletedNodesRest() {
    // given
    graphdb().execute("CREATE (:NodeToDelete {p: 'a property'})");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (n:NodeToDelete) DELETE n RETURN n"));
    assertThat(commit, containsNoErrors());
    assertThat(commit, restContainsDeletedEntities(1));
    assertThat(commit.status(), equalTo(200));
    assertThat(nodesInDatabase(), equalTo(0L));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 30 with Response

use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.

the class QueryResultsSerializationTest method shouldNotMarkNormalEntitiesAsDeletedRest.

@Test
public void shouldNotMarkNormalEntitiesAsDeletedRest() {
    // given
    graphdb().execute("CREATE (:Start)-[:R]->(:End)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (s:Start)-[r:R]->(e:End) RETURN *"));
    assertThat(commit, containsNoErrors());
    assertThat(commit, restContainsNoDeletedEntities());
    assertThat(commit.status(), equalTo(200));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Aggregations

Response (org.neo4j.test.server.HTTP.Response)73 Test (org.junit.Test)69 JsonNode (org.codehaus.jackson.JsonNode)12 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)3 JsonParseException (org.neo4j.server.rest.domain.JsonParseException)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 Before (org.junit.Before)2 HTTP (org.neo4j.test.server.HTTP)2 HashSet (java.util.HashSet)1 Description (org.hamcrest.Description)1 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 Node (org.neo4j.graphdb.Node)1 Transaction (org.neo4j.graphdb.Transaction)1 ServerControls (org.neo4j.harness.ServerControls)1 JsonHelper.jsonNode (org.neo4j.server.rest.domain.JsonHelper.jsonNode)1