use of org.teiid.metadata.MetadataFactory in project teiid by teiid.
the class TestDynamicImportedMetaData method testUseCatalogSeparator.
@Test
public void testUseCatalogSeparator() throws Exception {
MetadataFactory mf = createMetadataFactory("x", new Properties());
Table dup = mf.addTable("dup");
mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
MetadataStore ms = mf.asMetadataStore();
server.deployVDB("test", ms);
// $NON-NLS-1$
final Connection conn = server.createConnection("jdbc:teiid:test");
Properties importProperties = new Properties();
Connection conn1 = (Connection) SimpleMock.createSimpleMock(new Object[] { new ConnectionProxy(conn), conn }, new Class<?>[] { Connection.class });
mf = getMetadata(importProperties, conn1);
Table t = mf.asMetadataStore().getSchemas().get("TEST").getTables().get("test:X.DUP");
assertEquals("\"test\":\"x\".\"dup\"", t.getNameInSource());
}
use of org.teiid.metadata.MetadataFactory in project teiid by teiid.
the class TestDynamicImportedMetaData method testExcludes.
@Test
public void testExcludes() throws Exception {
server.deployVDB("vdb", UnitTestUtil.getTestDataPath() + "/TestCase3473/test.vdb");
// $NON-NLS-1$
Connection conn = server.createConnection("jdbc:teiid:vdb");
Properties importProperties = new Properties();
importProperties.setProperty("importer.importProcedures", Boolean.TRUE.toString());
importProperties.setProperty("importer.excludeTables", "VDB\\.(SYS|pg_catalog).*");
importProperties.setProperty("importer.excludeProcedures", "VDB\\..*");
MetadataFactory mf = getMetadata(importProperties, conn);
assertEquals(String.valueOf(mf.asMetadataStore().getSchemas().get("TEST").getTables()), 3, mf.asMetadataStore().getSchemas().get("TEST").getTables().size());
assertEquals(0, mf.asMetadataStore().getSchemas().get("TEST").getProcedures().size());
}
use of org.teiid.metadata.MetadataFactory in project teiid by teiid.
the class TestDynamicImportedMetaData method testImportFunction.
@Test
public void testImportFunction() throws Exception {
MetadataFactory mf = createMetadataFactory("x", new Properties());
Table dup = mf.addTable("dup");
mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
MetadataStore ms = mf.asMetadataStore();
server.deployVDB("test", ms);
// $NON-NLS-1$
Connection conn = server.createConnection("jdbc:teiid:test");
Properties importProperties = new Properties();
importProperties.setProperty(NativeMetadataRepository.IMPORT_PUSHDOWN_FUNCTIONS, Boolean.TRUE.toString());
mf = createMetadataFactory("test", importProperties);
NativeMetadataRepository nmr = new NativeMetadataRepository();
OracleExecutionFactory oef = new OracleExecutionFactory();
oef.start();
DataSource ds = Mockito.mock(DataSource.class);
Mockito.stub(ds.getConnection()).toReturn(conn);
nmr.loadMetadata(mf, oef, ds);
Map<String, FunctionMethod> functions = mf.asMetadataStore().getSchemas().get("TEST").getFunctions();
assertEquals(18, functions.size());
}
use of org.teiid.metadata.MetadataFactory in project teiid by teiid.
the class TestDynamicImportedMetaData method testMultipleFK.
@Test
public void testMultipleFK() throws Exception {
ModelMetaData mmd = new ModelMetaData();
mmd.addSourceMetadata("ddl", "create foreign table x (y integer, z integer, primary key (y, z));" + "create foreign table z (y integer, z integer, y1 integer, z1 integer, foreign key (y, z) references x (y, z), foreign key (y1, z1) references x (y, z))");
mmd.setName("foo");
mmd.addSourceMapping("x", "x", "x");
server.addTranslator("x", new ExecutionFactory());
server.deployVDB("vdb", mmd);
// $NON-NLS-1$
Connection conn = server.createConnection("jdbc:teiid:vdb");
Properties importProperties = new Properties();
importProperties.setProperty("importer.importKeys", "true");
MetadataFactory mf = getMetadata(importProperties, conn);
Table t = mf.asMetadataStore().getSchemas().get("test").getTables().get("vdb.foo.z");
List<ForeignKey> fks = t.getForeignKeys();
assertEquals(2, fks.size());
}
use of org.teiid.metadata.MetadataFactory in project teiid by teiid.
the class TestDynamicImportedMetaData method testIgnorePkIndex.
@Test
public void testIgnorePkIndex() throws Exception {
MetadataFactory mf = createMetadataFactory("x", new Properties());
Table dup = mf.addTable("x");
mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
mf.addPrimaryKey("foo", Arrays.asList("x"), dup);
MetadataStore ms = mf.asMetadataStore();
server.deployVDB("test", ms);
// cheat and add the index after deployment
mf.addIndex("foo", false, Arrays.asList("x"), dup);
// $NON-NLS-1$
Connection conn = server.createConnection("jdbc:teiid:test");
Properties importProperties = new Properties();
importProperties.setProperty("importer.importKeys", Boolean.TRUE.toString());
importProperties.setProperty("importer.importIndexes", Boolean.TRUE.toString());
mf = getMetadata(importProperties, conn);
Table t = mf.asMetadataStore().getSchemas().get("TEST").getTables().get("test.X.X");
assertNotNull(t.getPrimaryKey());
assertEquals(0, t.getUniqueKeys().size());
assertEquals(0, t.getIndexes().size());
}
Aggregations