use of org.teiid.translator.jdbc.teiid.TeiidExecutionFactory in project teiid by teiid.
the class TestDynamicImportedMetaData method getMetadata.
private MetadataFactory getMetadata(Properties importProperties, Connection conn) throws TranslatorException {
MetadataFactory mf = createMetadataFactory("test", importProperties);
TeiidExecutionFactory tef = new TeiidExecutionFactory();
tef.getMetadata(mf, conn);
return mf;
}
use of org.teiid.translator.jdbc.teiid.TeiidExecutionFactory in project teiid by teiid.
the class TestDynamicImportedMetaData method testMultiSource.
@Test
public void testMultiSource() throws Exception {
ModelMetaData mmd = new ModelMetaData();
mmd.addSourceMetadata("ddl", "create foreign table x (y integer primary key);");
mmd.setName("foo");
mmd.addSourceMapping("x", "x", "x");
server.addTranslator("x", new ExecutionFactory());
server.deployVDB("vdb", mmd);
TeiidExecutionFactory tef = new TeiidExecutionFactory() {
@Override
public void closeConnection(Connection connection, DataSource factory) {
}
};
tef.setSupportsDirectQueryProcedure(true);
tef.start();
server.addTranslator("teiid", tef);
DataSource ds = Mockito.mock(DataSource.class);
Mockito.stub(ds.getConnection()).toReturn(server.getDriver().connect("jdbc:teiid:vdb", null));
server.addConnectionFactory("teiid1", ds);
server.addConnectionFactory("teiid2", ds);
server.deployVDB(new FileInputStream(UnitTestUtil.getTestDataFile("multi.xml")));
Connection c = server.createConnection("jdbc:teiid:multi", null);
Statement s = c.createStatement();
s.execute("call native('select ?', 'b')");
ResultSet rs = s.getResultSet();
assertTrue(rs.next());
assertTrue(rs.next());
assertFalse(rs.next());
s.execute("call native(request=>'select ?', variable=>('b',), target=>'teiid1')");
rs = s.getResultSet();
assertTrue(rs.next());
Object[] result = (Object[]) rs.getArray(1).getArray();
assertArrayEquals(new Object[] { "b" }, result);
assertFalse(rs.next());
}
use of org.teiid.translator.jdbc.teiid.TeiidExecutionFactory in project teiid by teiid.
the class TestDynamicImportedMetaData method testMultiSourceImportError.
@Test
public void testMultiSourceImportError() throws Exception {
ModelMetaData mmd = new ModelMetaData();
mmd.addSourceMetadata("ddl", "create foreign table x (y integer primary key);");
mmd.setName("foo");
mmd.addSourceMapping("x", "x", "x");
server.addTranslator("x", new ExecutionFactory());
server.deployVDB("vdb", mmd);
TeiidExecutionFactory tef = new TeiidExecutionFactory() {
@Override
public void closeConnection(Connection connection, DataSource factory) {
}
};
tef.start();
server.addTranslator("teiid", tef);
DataSource ds = Mockito.mock(DataSource.class);
Connection c = server.getDriver().connect("jdbc:teiid:vdb", null);
// bad databasemetadata
DatabaseMetaData dbmd = (DatabaseMetaData) SimpleMock.createSimpleMock(new Object[] { new BadMetadata(), c.getMetaData() }, new Class[] { DatabaseMetaData.class });
Connection mock = Mockito.mock(Connection.class);
Mockito.stub(mock.getMetaData()).toReturn(dbmd);
Mockito.stub(ds.getConnection()).toReturn(mock);
DataSource ds1 = Mockito.mock(DataSource.class);
Mockito.stub(ds1.getConnection()).toReturn(server.getDriver().connect("jdbc:teiid:vdb", null));
server.addConnectionFactory("teiid1", ds);
server.addConnectionFactory("teiid2", ds1);
server.deployVDB(new FileInputStream(UnitTestUtil.getTestDataFile("multi.xml")));
}
Aggregations