/
SQLiteIntegrationTest.java
89 lines (75 loc) · 2.85 KB
/
SQLiteIntegrationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package liquibase.dbtest.sqlite;
import liquibase.Liquibase;
import liquibase.Scope;
import liquibase.database.DatabaseFactory;
import liquibase.dbtest.AbstractIntegrationTest;
import liquibase.exception.ValidationFailedException;
import org.junit.Test;
import java.io.File;
import java.util.Date;
import static org.junit.Assert.assertTrue;
public class SQLiteIntegrationTest extends AbstractIntegrationTest {
public SQLiteIntegrationTest() throws Exception {
super("sqlite", DatabaseFactory.getInstance().getDatabase("sqlite"));
File f = new File("sqlite");
try {
f.mkdir();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected boolean isDatabaseProvidedByTravisCI() {
return true;
}
@Override
@Test
public void testRunChangeLog() throws Exception {
super.testRunChangeLog(); //To change body of overridden methods use File | Settings | File Templates.
}
@Test
public void smartDataLoad() throws Exception {
if (this.getDatabase() == null) {
return;
}
Liquibase liquibase = createLiquibase("changelogs/common/smartDataLoad.changelog.xml");
clearDatabase();
try {
liquibase.update(this.contexts);
} catch (ValidationFailedException e) {
e.printDescriptiveError(System.out);
throw e;
}
// check that the automatically rollback now works too
try {
liquibase.rollback(new Date(0), this.contexts);
} catch (ValidationFailedException e) {
e.printDescriptiveError(System.out);
throw e;
}
}
@Override
@Test
public void testDiffExternalForeignKeys() throws Exception {
//cross-schema security for oracle is a bother, ignoring test for now
}
@Override
public void testOutputChangeLog() throws Exception {
Scope.getCurrentScope().getLog(getClass()).info("Due to several unimplemented ALTER TABLE substatements in SQLite, " +
"this test is technically impossible on this RDBMS.");
assertTrue(true);
}
@Override
public void tearDown() throws Exception {
super.tearDown();
try {
String url = getDatabase().getConnection().getURL()
.replaceFirst("jdbc:sqlite:", ""); // remove the prefix of the URL jdbc:sqlite:C:\path\to\tmp\dir\liquibase.db
Scope.getCurrentScope().getLog(getClass()).info("Marking SQLite database as delete on exit: " + url);
// Want to delete the sqlite db on jvm exit so that future runs are not using stale data.
new File(url).deleteOnExit();
} catch (Exception e) {
Scope.getCurrentScope().getLog(getClass()).warning("Failed to mark SQLite database as delete on exit.", e);
}
}
}