Skip to content

Commit

Permalink
added check for object existence in testCreateAndRollbackTransaction()
Browse files Browse the repository at this point in the history
  • Loading branch information
fasseg committed May 13, 2013
1 parent 760cae5 commit 528eed7
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -87,12 +87,25 @@ public void testCreateAndRollbackTransaction() throws Exception {
assertNotNull(tx.getCreated());
assertTrue(tx.getState() == State.NEW);

/* create a new object inside the tx */
HttpPost postNew = new HttpPost(serverAddress + "fcr:tx/" + tx.getId() + "/objects/testobj2/fcr:newhack");
resp = execute(postNew);
assertTrue(resp.getStatusLine().getStatusCode() == 200);

/* check if the object is already there, before the commit */
HttpGet getObj = new HttpGet(serverAddress + "/objects/testobj2");
resp = execute(getObj);
assertTrue(resp.getStatusLine().toString(),resp.getStatusLine().getStatusCode() == 404);

/* and rollback */
HttpPost rollbackTx = new HttpPost(serverAddress + "fcr:tx/" + tx.getId() + "/fcr:rollback");
resp = execute(rollbackTx);
Transaction rolledBack = mapper.readValue(resp.getEntity().getContent(), Transaction.class);
assertEquals(rolledBack.getId(),tx.getId());
assertTrue(rolledBack.getState() == State.ROLLED_BACK);

/* check if the object is there, after the rollback */
resp = execute(getObj);
assertTrue(resp.getStatusLine().toString(),resp.getStatusLine().getStatusCode() == 404);
}
}

0 comments on commit 528eed7

Please sign in to comment.