@Before
  public void setUp() throws Exception {
    file.delete();

    db.start();

    connection = db.getConnection();
  }
  @Test
  public void whenDatabaseIsUpgradedTheVersionIsIncremented() throws Exception {
    db.shutdown();
    db = new FileDatabaseVersion2(file);
    db.start();
    connection = db.getConnection();

    long dbVersion = db.getCurrentVersion();

    assertThat(dbVersion, is(equalTo(db.getSoftwareVersion())));
  }
  @Test
  public void schemaCreationIsNotRunWhenDatabaseExists() throws Exception {
    db.shutdown();
    db.start();
    connection = db.getConnection();

    // Would throw an exception if the table didn't exist
    QueryPreparedStatementWrapper prepareQueryStatement =
        connection.prepareQueryStatement("SELECT * FROM testtable");
    try {
      prepareQueryStatement.execute();
    } finally {
      DatabaseUtil.close(prepareQueryStatement);
    }
  }
  @Test
  public void upgradeScriptsRunWhenDatabaseIsOlderVersion() throws Exception {
    db.shutdown();
    db = new FileDatabaseVersion2(file);
    db.start();
    connection = db.getConnection();

    // Would throw an exception if the table didn't exist
    QueryPreparedStatementWrapper prepareQueryStatement =
        connection.prepareQueryStatement("SELECT * FROM version2table");
    try {
      prepareQueryStatement.execute();
    } finally {
      DatabaseUtil.close(prepareQueryStatement);
    }
  }
 @After
 public void tearDown() throws Exception {
   db.shutdown();
 }