Search in sources :

Example 46 with HardCodedExecutionFactory

use of org.teiid.runtime.HardCodedExecutionFactory in project teiid by teiid.

the class TestMatViews method testImportedMatView.

@Test
public void testImportedMatView() throws Exception {
    ModelMetaData mmd2 = new ModelMetaData();
    mmd2.setName("view1");
    mmd2.setModelType(Type.PHYSICAL);
    mmd2.setSchemaSourceType("DDL");
    mmd2.setSchemaText("create foreign table x (col integer); CREATE VIEW v1 ( col1 string ) OPTIONS (MATERIALIZED true) AS select current_database() from x");
    mmd2.addSourceMapping("a", "a", null);
    HardCodedExecutionFactory hcef = new HardCodedExecutionFactory();
    hcef.addData("SELECT x.col FROM x", Arrays.asList(Collections.singletonList(1)));
    server.addTranslator("a", hcef);
    server.deployVDB("base", mmd2);
    VDBMetaData vdbMetaData = new VDBMetaData();
    vdbMetaData.setXmlDeployment(true);
    VDBImportMetadata importVDB = new VDBImportMetadata();
    importVDB.setName("base");
    importVDB.setVersion("1");
    vdbMetaData.getVDBImports().add(importVDB);
    vdbMetaData.setName("importing");
    server.deployVDB(vdbMetaData);
    Connection c = server.getDriver().connect("jdbc:teiid:importing", null);
    Statement s = c.createStatement();
    ResultSet rs = s.executeQuery("select * from v1");
    rs.next();
    assertEquals("base", rs.getString(1));
}
Also used : VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) HardCodedExecutionFactory(org.teiid.runtime.HardCodedExecutionFactory) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Aggregations

HardCodedExecutionFactory (org.teiid.runtime.HardCodedExecutionFactory)46 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)43 Test (org.junit.Test)40 Properties (java.util.Properties)27 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)27 StringContentProvider (org.eclipse.jetty.client.util.StringContentProvider)10 Connection (java.sql.Connection)8 ResultSet (java.sql.ResultSet)8 Statement (java.sql.Statement)7 CallableStatement (java.sql.CallableStatement)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 FakeServer (org.teiid.jdbc.FakeServer)4 QueryExpression (org.teiid.language.QueryExpression)3 RuntimeMetadata (org.teiid.metadata.RuntimeMetadata)3 Table (org.teiid.metadata.Table)3 EmbeddedConfiguration (org.teiid.runtime.EmbeddedConfiguration)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 BeforeClass (org.junit.BeforeClass)2 AbstractQueryTest (org.teiid.jdbc.AbstractQueryTest)2