コード例 #1
0
 @After
 public void closeTransaction() throws DataAccessException, SQLException {
   try {
     if (connectionToKeepInMemoryDatabaseAlive != null) {
       connectionToKeepInMemoryDatabaseAlive.close();
     }
   } finally {
     CurrentTransaction.close(false);
   }
 }
コード例 #2
0
  @Before
  public void createInMemoryDatabase() throws DataAccessException, SQLException {
    JdbcDataSource dataSource = new JdbcDataSource();
    dataSource.setURL("jdbc:h2:mem:" + getClass().getSimpleName() + "_" + uniqueId + ";MVCC=TRUE");
    uniqueId++;

    CompositeDatasourceTransaction.registerDataSource("test", dataSource);
    connectionToKeepInMemoryDatabaseAlive = dataSource.getConnection();

    CurrentTransaction.create();
  }