-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamundaFlywayTest.java
61 lines (47 loc) · 1.49 KB
/
CamundaFlywayTest.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
package org.camunda.bpm.extension.flyway;
import org.flywaydb.core.Flyway;
import org.junit.Before;
import org.junit.Test;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import static org.assertj.core.api.Assertions.assertThat;
import static org.camunda.bpm.extension.flyway.CamundaFlyway.CONFIGURATION;
public class CamundaFlywayTest {
private final DataSource dataSource = TestUtils.newH2DataSource();
private Flyway flyway;
@Before
public void setUp() {
flyway = CamundaFlyway.create().withDatasource(dataSource).get();
}
@Test
public void migrates_database() throws Exception {
flyway.migrate();
Set<String> tableNames = tableNames();
assertThat(tableNames).contains("ACT_RU_TASK");
assertThat(tableNames).hasSize(32);
}
private Set<String> tableNames() throws Exception {
Statement st = null;
ResultSet rs = null;
try {
st = dataSource.getConnection().createStatement();
rs = st.executeQuery("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = SCHEMA()");
final Set<String> names = new TreeSet<String>();
while (rs.next()) {
String name = rs.getString("TABLE_NAME");
if (!name.equals("schema_version")) {
names.add(name);
}
}
return names;
}
finally {
if (rs != null) rs.close();
if (st != null) st.close();
}
}
}