Search in sources :

Example 1 with NativeMetadataRepository

use of org.teiid.query.metadata.NativeMetadataRepository 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());
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) OracleExecutionFactory(org.teiid.translator.jdbc.oracle.OracleExecutionFactory) Table(org.teiid.metadata.Table) MetadataFactory(org.teiid.metadata.MetadataFactory) NativeMetadataRepository(org.teiid.query.metadata.NativeMetadataRepository) Connection(java.sql.Connection) FunctionMethod(org.teiid.metadata.FunctionMethod) Properties(java.util.Properties) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Aggregations

Connection (java.sql.Connection)1 Properties (java.util.Properties)1 DataSource (javax.sql.DataSource)1 Test (org.junit.Test)1 FunctionMethod (org.teiid.metadata.FunctionMethod)1 MetadataFactory (org.teiid.metadata.MetadataFactory)1 MetadataStore (org.teiid.metadata.MetadataStore)1 Table (org.teiid.metadata.Table)1 NativeMetadataRepository (org.teiid.query.metadata.NativeMetadataRepository)1 OracleExecutionFactory (org.teiid.translator.jdbc.oracle.OracleExecutionFactory)1