|
| 1 | +package com.oltpbenchmark.api; |
| 2 | + |
| 3 | +import com.oltpbenchmark.catalog.Table; |
| 4 | +import com.oltpbenchmark.util.SQLUtil; |
| 5 | + |
| 6 | +import java.nio.file.Paths; |
| 7 | +import java.sql.ResultSet; |
| 8 | +import java.sql.Statement; |
| 9 | +import java.util.ArrayList; |
| 10 | +import java.util.List; |
| 11 | + |
| 12 | +public class TestDDLOverride extends AbstractTestCase<MockBenchmark> { |
| 13 | + |
| 14 | + public TestDDLOverride() { |
| 15 | + super(false, false, Paths.get("src", "test", "resources", "benchmarks", "mockbenchmark", "ddl-hsqldb.sql").toAbsolutePath().toString()); |
| 16 | + } |
| 17 | + |
| 18 | + @Override |
| 19 | + public List<Class<? extends Procedure>> procedures() { |
| 20 | + return new ArrayList<>(); |
| 21 | + } |
| 22 | + |
| 23 | + @Override |
| 24 | + public Class<MockBenchmark> benchmarkClass() { |
| 25 | + return MockBenchmark.class; |
| 26 | + } |
| 27 | + |
| 28 | + @Override |
| 29 | + public List<String> ignorableTables() { |
| 30 | + return null; |
| 31 | + } |
| 32 | + |
| 33 | + public void testCreateWithDdlOverride() throws Exception { |
| 34 | + this.benchmark.createDatabase(); |
| 35 | + |
| 36 | + assertFalse("Failed to get table names for " + benchmark.getBenchmarkName().toUpperCase(), this.catalog.getTables().isEmpty()); |
| 37 | + for (Table table : this.catalog.getTables()) { |
| 38 | + String tableName = table.getName(); |
| 39 | + Table catalog_tbl = this.catalog.getTable(tableName); |
| 40 | + |
| 41 | + String sql = SQLUtil.getCountSQL(this.workConf.getDatabaseType(), catalog_tbl); |
| 42 | + |
| 43 | + try (Statement stmt = conn.createStatement(); |
| 44 | + ResultSet result = stmt.executeQuery(sql);) { |
| 45 | + |
| 46 | + assertNotNull(result); |
| 47 | + |
| 48 | + boolean adv = result.next(); |
| 49 | + assertTrue(sql, adv); |
| 50 | + |
| 51 | + int count = result.getInt(1); |
| 52 | + assertEquals(0, count); |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | +} |
0 commit comments