1 Reply Latest reply on Apr 18, 2013 7:04 AM by Bartosz Majsak

    Persistence cleanup with used_rows_only strategy hiding exceptions

    Steve Friesen Newbie

      Good morning.

       

      I am having trouble cleaning up seeded data with the used_rows_only strategy. I have a single test in my test class:

       

          @Deployment
          public static JavaArchive createDeployment() {
              JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class)
                  .addClasses(AbstractFacade.class,AppUserFacade.class,AppUser.class,UserRole.class)
                  .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
                  .addAsManifestResource("test-persistence.xml", ArchivePaths.create("persistence.xml"));
              System.out.println(javaArchive.toString(true));
              return javaArchive;
          }
          
          @EJB
          AppUserFacade appUserFacade;
          
       @Test @InSequence(1)
          @UsingDataSet("datasets/appusers.yml")
          public void should_get_user_2_from_findUserByUserName() {
              System.out.println("should_get_user_2_from_findUserByUserName()");
              AppUser appUser = appUserFacade.findUserByName("testuser2");
              Assert.assertNotNull(appUser);
          }
      
      

       

      My arquillian.xml has these persistence extensions:

       

      <extension qualifier="persistence">
        <property name="defaultDataSource">jdbc/FisTestDbDs</property>
        <property name="defaultCleanupPhase">AFTER</property>
        <property name="defaultCleanupStrategy">USED_ROWS_ONLY</property>
       </extension>
       <extension qualifier="persistence-dbunit">
        <property name="defaultDataSetFormat">YAML</property>
        <property name="schema">fistest</property>
       </extension>
       <extension qualifier="persistence-script">
        <property name="sqlStatementDelimiter">NEW_LINE</property>
       </extension>
      
      

       

      If I have an exception when cleaning data and defaultCleanupStrategy is USED_ROWS_ONLY, the test will complete successfully but the data will not be cleaned up. However, if I run the same test with defaultCleanupStrategy set to USED_TABLES_ONLY, the exception is not caught, the test fails, and I can see why data was unable to be cleaned up. Let me know if I am doing something incorrectly. Otherwise it appears that cleanup code needs to propagate database exception for USED_ROWS_ONLY.

       

      Here is the exception that I get when I run it with USED_TABLES_ONLY:

       

      -------------------------------------------------------------------------------
      Test set: com.steve.sftest4.ejb.test.SteveBeanTest
      -------------------------------------------------------------------------------
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 40.132 sec <<< FAILURE!
      should_get_user_2_from_findUserByUserName(com.steve.sftest4.ejb.test.SteveBeanTest)  Time elapsed: 27.381 sec  <<< ERROR!
      org.jboss.arquillian.persistence.dbunit.exception.DBUnitDataSetHandlingException: Unable to clean database.
       at org.jboss.arquillian.persistence.dbunit.cleanup.UsedTablesOnlyCleanupStrategyExecutor.cleanupDatabase(UsedTablesOnlyCleanupStrategyExecutor.java:54)
       at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.cleanDatabase(DBUnitDataHandler.java:174)
       at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.cleanup(DBUnitDataHandler.java:115)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
       at org.jboss.arquillian.persistence.dbunit.DBUnitDataStateLogger.aroundCleanup(DBUnitDataStateLogger.java:121)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
       at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
       at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
       at org.jboss.arquillian.persistence.core.lifecycle.DataCleanupHandler.verifyDatabase(DataCleanupHandler.java:71)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
       at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.persistence.core.lifecycle.ErrorCollectorHandler.collectErrors(ErrorCollectorHandler.java:46)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.persistence.dbunit.DBUnitPersistenceTestLifecycleHandler.provideDatabaseConnection(DBUnitPersistenceTestLifecycleHandler.java:118)
       at org.jboss.arquillian.persistence.dbunit.DBUnitPersistenceTestLifecycleHandler.provideDatabaseConnectionAroundAfterPersistenceTest(DBUnitPersistenceTestLifecycleHandler.java:89)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
       at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
       at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
       at org.jboss.arquillian.persistence.core.lifecycle.PersistenceTestTrigger.afterTest(PersistenceTestTrigger.java:122)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
       at org.jboss.arquillian.testenricher.cdi.CreationalContextDestroyer.destory(CreationalContextDestroyer.java:44)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:601)
       at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
       at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
       at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
       at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
       at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.after(EventTestRunnerAdaptor.java:103)
       at org.jboss.arquillian.junit.Arquillian$5$1.evaluate(Arquillian.java:245)
       at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
       at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
       at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)
       at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
       at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
       at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)
       at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
       at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
       at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
       at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
       at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
       at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
       at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
       at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)
       at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160)
       at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)
       at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
       at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
       at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
       at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
       at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
       at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
       at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
       at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
       at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
       at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
       at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
       at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
       at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
       at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
       at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
       at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
       at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
       at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
       at java.lang.Thread.run(Thread.java:722)
      Caused by: java.sql.SQLException: ORA-20000: SF Test Exception
      ORA-06512: at "FISTEST.APP_USER_BD", line 8
      ORA-04088: error during execution of trigger 'FISTEST.APP_USER_BD'
       at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
       at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
       at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
       at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
       at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
       at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
       at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
       at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:999)
       at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
       at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1890)
       at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1855)
       at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:304)
       at com.sun.gjc.spi.base.StatementWrapper.execute(StatementWrapper.java:359)
       at org.dbunit.database.statement.SimpleStatement.executeBatch(SimpleStatement.java:69)
       at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:126)
       at org.jboss.arquillian.persistence.dbunit.cleanup.UsedTablesOnlyCleanupStrategyExecutor.cleanupDatabase(UsedTablesOnlyCleanupStrategyExecutor.java:50)
       ... 175 more
      
      

       

      Also, is there a way to have the seeding and cleanup log database activity to the server log? In my test-persistence.xml file I have eclipselink properties set for sql logging:

       

      <property name="eclipselink.logging.level.sql" value="FINE"/>
        <property name="eclipselink.logging.parameters" value="true"/>
      
      

      This does logging for sql in my test class, but is there a way to get the same logging for seeding and cleanup?

       

      Thanks,

       

      Steve