0 Replies Latest reply on Aug 12, 2013 9:18 AM by Robert Panzer

    Proposal: Arquillian Persistence Extension and how to clean the schema

    Robert Panzer Newbie



      the Arquillian Persistence Extension does a great job preparing the database for a test, inserting data and checking the state of the database after the test. I really like it.


      Everything works without any problems when I am using for example the H2 in memory database that JBoss already has preconfigured. Every test starts with a fresh DB.


      But as our software runs on Oracle or DB2 on production there are some tests, where H2 does not really fit well. (The concurrency of Oracle is so different from other DBs)


      If I have an empty Oracle XE database everything works fine.

      The problems start when I want to execute the test a second time:

      I have some script that creates the schema using the @CreateSchema annotation. As the schema is not dropped after the test, it is already there and the create table statements fail.

      If I add some drop table statements before everything works fine again.

      But wait, it fails again if I execute the test on a fresh schema that does not have these tables and Oracle does not know a "drop table if exists".


      What could be done about this?


      I have three ideas?

      1. Support some marker before a statement that prevents a test failure if the statement fails like: "NOFAIL: drop table FOO"

      2. Add a second parameter to the @CreateSchema annotation that controls if errors let the test fail like @CreateSchema(value="schema.xml", failOnError=false)

      3. Add a @DropSchema annotation that allows to reference a script that is executed just before the test is undeployed.


      Anyone having an opinion on this?

      Or maybe I am missing something and my problem is already solved?


      Kind regards,