|
@@ -3,6 +3,7 @@ package com.alibaba.otter.canal.parse.inbound.mysql.tsdb;
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.net.URL;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -12,7 +13,9 @@ import org.junit.runner.RunWith;
|
|
|
import org.springframework.test.context.ContextConfiguration;
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
|
|
|
+import com.alibaba.fastsql.sql.repository.Schema;
|
|
|
import com.alibaba.otter.canal.parse.inbound.TableMeta;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
|
|
/**
|
|
|
* @author agapple 2017年8月1日 下午7:15:54
|
|
@@ -66,4 +69,24 @@ public class MemoryTableMeta_DDL_Test {
|
|
|
System.out.println(meta);
|
|
|
Assert.assertTrue(meta.getFields().get(0).getColumnName().equalsIgnoreCase("id"));
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void test_any() throws Throwable {
|
|
|
+ MemoryTableMeta memoryTableMeta = new MemoryTableMeta();
|
|
|
+ URL url = Thread.currentThread().getContextClassLoader().getResource("dummy.txt");
|
|
|
+ File dummyFile = new File(url.getFile());
|
|
|
+ File create = new File(dummyFile.getParent() + "/ddl", "ddl_any.sql");
|
|
|
+ String sql = StringUtils.join(IOUtils.readLines(new FileInputStream(create)), "\n");
|
|
|
+ memoryTableMeta.apply(null, "test", sql, null);
|
|
|
+
|
|
|
+ List<String> tableNames = Lists.newArrayList();
|
|
|
+ for (Schema schema : memoryTableMeta.getRepository().getSchemas()) {
|
|
|
+ tableNames.addAll(schema.showTables());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String table : tableNames) {
|
|
|
+ TableMeta sourceMeta = memoryTableMeta.find("test", table);
|
|
|
+ System.out.println(sourceMeta.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|