Search in sources :

Example 41 with Response

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

the class TransactionIT method begin__execute__execute_and_periodic_commit.

@Test
public void begin__execute__execute_and_periodic_commit() throws Exception {
    ServerTestUtils.withCSVFile(1, url -> {
        Response begin = http.POST("/db/data/transaction");
        http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE ()' } ] }"));
        Response response = http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'USING" + " PERIODIC COMMIT LOAD CSV FROM \\\"" + url + "\\\" AS line CREATE ()' } ] }"));
        assertThat(response, hasErrors(Status.Statement.SemanticError));
    });
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 42 with Response

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

the class TransactionIT method correctStatusCodeWhenUsingHintWithoutAnyIndex.

@Test
public void correctStatusCodeWhenUsingHintWithoutAnyIndex() throws Exception {
    // begin and execute and commit
    Response begin = http.POST("/db/data/transaction/commit", quotedJson("{ 'statements': [ { 'statement': " + "'MATCH (n:Test) USING INDEX n:Test(foo) WHERE n.foo = 42 RETURN n.foo' } ] }"));
    assertThat(begin, hasErrors(Status.Request.Schema.IndexNotFound));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 43 with Response

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

the class TransactionIT method begin__execute_and_commit.

@Test
public void begin__execute_and_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, equalTo(begin.location() + "/commit"));
    // execute and commit
    Response commit = http.POST(commitResource, quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
    assertThat(commit, containsNoErrors());
    assertThat(commit.status(), equalTo(200));
    assertThat(countNodes(), equalTo(nodesInDatabaseBeforeTransaction + 1));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 44 with Response

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

the class TransactionIT method begin__execute_multiple__commit.

@Test
public void begin__execute_multiple__commit() throws Exception {
    long nodesInDatabaseBeforeTransaction = countNodes();
    // begin
    Response begin = http.POST("/db/data/transaction");
    String commitResource = begin.stringFromContent("commit");
    // execute
    http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' }, " + "{ 'statement': 'CREATE (n)' } ] }"));
    // commit
    Response commit = http.POST(commitResource);
    assertThat(commit, containsNoErrors());
    assertThat(countNodes(), equalTo(nodesInDatabaseBeforeTransaction + 2));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 45 with Response

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

the class TransactionIT method begin__execute__commit__execute.

@Test
public void begin__execute__commit__execute() throws Exception {
    // begin
    Response begin = http.POST("/db/data/transaction");
    String commitResource = begin.stringFromContent("commit");
    // execute
    http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
    // commit
    http.POST(commitResource);
    // execute
    Response execute2 = http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ]" + " }"));
    assertThat(execute2.status(), equalTo(404));
    assertThat(execute2, hasErrors(Status.Transaction.TransactionNotFound));
}
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