@Test
public void testSchema() throws Exception {

    JDBCMockObjectFactory factory = new JDBCMockObjectFactory();
    factory.registerMockDriver();
    MockConnection connection = factory.getMockConnection();
    StatementResultSetHandler statementHandler =
            connection.getStatementResultSetHandler();
    MockResultSet result = statementHandler.createResultSet();
    result.setFetchSize(0);
    MockResultSetMetaData metaData = new MockResultSetMetaData();
    Map<String, String> fakeColumnMap = new HashMap<>();
    fakeColumnMap.put("test1", "numeric");
    fakeColumnMap.put("test2", "varchar");
    fakeColumnMap.put("test3", "int8");
    Set<String> fakeColumns = fakeColumnMap.keySet();
    metaData.setColumnCount(fakeColumnMap.size());
    int i = 1;
    for (Map.Entry<String, String> fc : fakeColumnMap.entrySet()) {
        metaData.setColumnName(i, fc.getKey());
        metaData.setColumnTypeName(i, fc.getValue());
        i++;
    }
    result.setResultSetMetaData(metaData);
    statementHandler.prepareGlobalResultSet(result);
    MacroBaseConf conf = new MacroBaseConf();
    conf.set(MacroBaseConf.ATTRIBUTES, Lists.newArrayList(fakeColumns));
    conf.set(MacroBaseConf.METRICS, new ArrayList<>());
    conf.set(MacroBaseConf.BASE_QUERY, "SELECT * FROM test;");
    SQLIngester loader = new TestSQLIngester(conf, connection);
    Schema schema = loader.getSchema("foo");
    for (Schema.SchemaColumn sc : schema.getColumns()) {
        assertTrue(fakeColumns.contains(sc.getName()));
        assertEquals(fakeColumnMap.get(sc.getName()), sc.getType());
        fakeColumns.remove(sc.getName());
    }
    assertTrue(fakeColumns.isEmpty());
}