2 Replies Latest reply on Apr 23, 2013 3:39 PM by Cesar Ricardez

    Expecting a RollbackException in a Persistence test?

    Cesar Ricardez Newbie

      Hi, i'm using Arquillian with Persistence Extension 1.0.0alpha6 and i trying to test a double insertion on database, so when i persist an entity i must receive a RollbackException cause there is an object previously inserted, but since the insertion is using the same transaction as APE when i call persist the Rollback is catched by APE and i never chatch any exception...

      My question is...is there another approach to do this, o is there imposible with APE??




      Here is my test-code

      @RunWith( Arquillian.class )


      public class AppTestIssue6 {



          App app1;




          EntityManager manager;



          UserTransaction transaction;





          @Deployment(  )

          public static Archive<?> createDeployment() {

              return ShrinkWrap.create(WebArchive.class, "test.war")


                      .addAsResource("persistence_local.xml", "META-INF/persistence.xml")

                      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");





          @Cleanup( phase = TestExecutionPhase.BEFORE )

          @UsingDataSet( "applications_populate.yml" )

          @Test( expected = RollbackException.class )

          public void testpersistWithaUsingDataSet() {       




              App app = new App();



              app.setCreatedAt(new Date());

              app.setModifiedAt(new Date());