Skip to content

Commit

Permalink
Merge pull request #176 from pdowler/CADC-13452
Browse files Browse the repository at this point in the history
youcat ingest table completed
  • Loading branch information
pdowler authored Oct 3, 2024
2 parents 96d4187 + ff996e3 commit 6d34c86
Show file tree
Hide file tree
Showing 33 changed files with 1,602 additions and 769 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,21 @@
*
* @author pdowler
*/
public class TableCreatorTest {
public class TableCreatorTest extends TestUtil {
private static final Logger log = Logger.getLogger(TableCreatorTest.class);

static {
Log4jInit.setLevel("ca.nrc.cadc.tap.db", Level.INFO);
//Log4jInit.setLevel("ca.nrc.cadc.profiler", Level.INFO);
Log4jInit.setLevel("ca.nrc.cadc.tap", Level.INFO);
}

private DataSource dataSource;
private final String TEST_SCHEMA = "tap_schema";

public TableCreatorTest() {
// create a datasource and register with JNDI
try {
DBConfig conf = new DBConfig();
ConnectionConfig cc = conf.getConnectionConfig("TAP_SCHEMA_TEST", "cadctest");
dataSource = DBUtil.getDataSource(cc);
log.info("configured data source: " + cc.getServer() + "," + cc.getDatabase() + "," + cc.getDriver() + "," + cc.getURL());
} catch (Exception ex) {
log.error("setup failed", ex);
throw new IllegalStateException("failed to create DataSource", ex);
}
super();
}

@Test
public void testCreateTable() {
try {
String testTable = TEST_SCHEMA + ".testCreateTable";
String testTable = testSchemaName + ".testCreateTable";
// cleanup
TableCreator tc = new TableCreator(dataSource);
try {
Expand All @@ -128,7 +115,7 @@ public void testCreateTable() {
log.debug("cleanup-before-test failed");
}

TableDesc orig = new TableDesc(TEST_SCHEMA, testTable);
TableDesc orig = new TableDesc(testSchemaName, testTable);
orig.tableType = TableDesc.TableType.TABLE;
orig.getColumnDescs().add(new ColumnDesc(testTable, "c0", TapDataType.STRING));
orig.getColumnDescs().add(new ColumnDesc(testTable, "c1", TapDataType.SHORT));
Expand Down Expand Up @@ -161,7 +148,7 @@ public void testCreateTable() {
@Test
public void testCreateIndex() {
try {
String testTable = TEST_SCHEMA + ".testCreateIndex";
String testTable = testSchemaName + ".testCreateIndex";
// cleanup
TableCreator tc = new TableCreator(dataSource);
try {
Expand All @@ -170,7 +157,7 @@ public void testCreateIndex() {
log.debug("cleanup-before-test failed");
}

TableDesc orig = new TableDesc(TEST_SCHEMA, testTable);
TableDesc orig = new TableDesc(testSchemaName, testTable);
orig.tableType = TableDesc.TableType.TABLE;
ColumnDesc col = new ColumnDesc(testTable, "c0", TapDataType.STRING);
orig.getColumnDescs().add(col);
Expand Down Expand Up @@ -199,7 +186,7 @@ public void testCreateIndex() {
@Test
public void testCreateUniqueIndex() {
try {
String testTable = TEST_SCHEMA + ".testCreateUniqueIndex";
String testTable = testSchemaName + ".testCreateUniqueIndex";
// cleanup
TableCreator tc = new TableCreator(dataSource);
try {
Expand All @@ -208,7 +195,7 @@ public void testCreateUniqueIndex() {
log.debug("cleanup-before-test failed");
}

TableDesc orig = new TableDesc(TEST_SCHEMA, testTable);
TableDesc orig = new TableDesc(testSchemaName, testTable);
orig.tableType = TableDesc.TableType.TABLE;
ColumnDesc col = new ColumnDesc(testTable, "c0", TapDataType.STRING);
orig.getColumnDescs().add(col);
Expand Down Expand Up @@ -248,8 +235,8 @@ public void testCreateUniqueIndex() {
@Test
public void testInvalidTableName() {
try {
String testTable = TEST_SCHEMA + ".testInvalidTableName;drop table tap_schema.tables";
TableDesc orig = new TableDesc(TEST_SCHEMA, testTable);
String testTable = testSchemaName + ".testInvalidTableName;drop table tap_schema.tables";
TableDesc orig = new TableDesc(testSchemaName, testTable);
orig.tableType = TableDesc.TableType.TABLE;
orig.getColumnDescs().add(new ColumnDesc(testTable, "c0", TapDataType.STRING));

Expand All @@ -267,8 +254,8 @@ public void testInvalidTableName() {
@Test
public void testInvalidColumnName() {
try {
String testTable = TEST_SCHEMA + ".testInvalidColumnName;drop table tap_schema.tables";
TableDesc orig = new TableDesc(TEST_SCHEMA, testTable);
String testTable = testSchemaName + ".testInvalidColumnName;drop table tap_schema.tables";
TableDesc orig = new TableDesc(testSchemaName, testTable);
orig.tableType = TableDesc.TableType.TABLE;
orig.getColumnDescs().add(new ColumnDesc(testTable, "c0", TapDataType.STRING));

Expand Down
Loading

0 comments on commit 6d34c86

Please sign in to comment.