Liquibase liquibase = new Liquibase((String) null, new ClassLoaderResourceAccessor(), database);
Database hibernateDatabase = new HibernateClassicDatabase();
hibernateDatabase.setDefaultSchemaName("PUBLIC");
hibernateDatabase.setDefaultCatalogName("TESTDB");
hibernateDatabase.setConnection(new JdbcConnection(new HibernateConnection("hibernate:classic:" + HIBERNATE_CONFIG_FILE)));
DiffResult diffResult = liquibase.diff(hibernateDatabase, database, compareControl);
assertTrue(diffResult.getMissingObjects().size() > 0);
File outFile = File.createTempFile("lb-test", ".xml");
OutputStream outChangeLog = new FileOutputStream(outFile);
String changeLogString = toChangeLog(diffResult);
outChangeLog.write(changeLogString.getBytes("UTF-8"));
outChangeLog.close();
log.info("Changelog:\n" + changeLogString);
liquibase = new Liquibase(outFile.toString(), new FileSystemResourceAccessor(), database);
StringWriter stringWriter = new StringWriter();
liquibase.update((String) null, stringWriter);
log.info(stringWriter.toString());
liquibase.update((String) null);
long currentTimeMillis = System.currentTimeMillis();
Connection connection2 = DriverManager.getConnection("jdbc:hsqldb:mem:TESTDB2" + currentTimeMillis, "SA", "");
Database database2 = new HsqlDatabase();
database2.setConnection(new JdbcConnection(connection2));
Configuration cfg = new Configuration();
cfg.configure(HIBERNATE_CONFIG_FILE);
cfg.getProperties().remove(Environment.DATASOURCE);
cfg.setProperty(Environment.URL, "jdbc:hsqldb:mem:TESTDB2" + currentTimeMillis);