/**
* Verifies if the commit works.
*/
public void resourceLevelCommit() {
EntityManager entityManager = entityManagerFactory.createEntityManager();
// begins the trasnaction
entityManager.getTransaction().begin();
// inserts a book
Book book = new Book();
book.setId(ID);
book.setName(ENTITY_NAME);
entityManager.persist(book);
// verifies if the transaction is marked as ACTIVE
assertTrue(entityManager.getTransaction().isActive(),
"The transaction is active, but the container returned false when the method isActive was called.");
// verify if the rollbackonly is not set.
assertFalse(entityManager.getTransaction().getRollbackOnly(),
"The transaction is not marked as rollback, but the container returned true for the method getRollbackOnly()");
// makes a commit
entityManager.getTransaction().commit();
entityManager.close();
// verifies if the bean is persistent.
Book bookResult = entityManager.find(Book.class, new Integer(ID));
assertNotNull(bookResult, "The container did not make the rollback");
}