title: JUnit, H2, JaxRS, drop in-memory database between test methods
body: <p>How do I drop or delete or rollback or disconnect from my H2 database between test methods?</p>
  
  <p>Here is a bit of my hibernate test configuration:</p>
  
  <pre><code>    &lt;property name="connection.driver_class"&gt;org.h2.Driver&lt;/property&gt;
      &lt;property name="connection.url"&gt;
          jdbc:h2:mem:test;DB_CLOSE_DELAY=0;INIT=RUNSCRIPT FROM './h2-ext/add_to_date.sql'
      &lt;/property&gt;
      &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;
  </code></pre>
  
  <p>I have a base class that I'm inheriting all my tests from:</p>
  
  <pre><code>public abstract class BaseTest {
  
      @After
      public void drop() throws Exception {
          System.out.println("!!!!!! DROP !!!!!!&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;");
          // this seems to do nothing
          //org.h2.store.fs.FileUtils.deleteRecursive("mem:test", true);
          //org.h2.store.fs.FileUtils.deleteRecursive("NoTellingwhatThisdoes", true);
  
          // the schema does not get recreated, it seems
          //Session sess = DB.sf.openSession();
          //sess.createSQLQuery("DROP ALL OBJECTS;").executeUpdate();
  
          // org.h2.jdbc.JdbcSQLException: Cannot truncate "PUBLIC.FOO";
          //Session sess = DB.sf.openSession();
          //sess.createSQLQuery("TRUNCATE TABLE FOO;").executeUpdate();
          //sess.createSQLQuery("TRUNCATE TABLE BAR;").executeUpdate();
      }
  }
  </code></pre>
  
  <p>It seems that there should be a simple way to execute an integration test like this?</p>
  
  <p>Maybe I can use some Transactional annotation of some sort? But, I would like to know how to do this with relatively vanilla jersey+JUnit.</p>
  
  <p>Jersey is 2.12, Java 1.7, H2 is 1.4.181, JUnit is 4.11.</p>
  
  <p>Versions are negotiable.</p>