use of org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl in project teiid by teiid.
the class TestHotrodExecution method setup.
@BeforeClass
public static void setup() throws Exception {
TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-5"));
SERVER = new HotRodTestServer(PORT);
MetadataFactory mf = TestProtobufMetadataProcessor.protoMatadata("tables.proto");
EF = new InfinispanExecutionFactory();
TransformationMetadata tm = TestProtobufMetadataProcessor.getTransformationMetadata(mf, EF);
// String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
// System.out.println(ddl);
METADATA = new RuntimeMetadataImpl(tm);
UTILITY = new TranslationUtility(tm);
InfinispanConnection connection = SERVER.getConnection();
// only use G2 & G4 as cache only support single id
connection.registerProtobufFile(new ProtobufResource("tables.proto", ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("tables.proto"))));
EC = Mockito.mock(ExecutionContext.class);
Mockito.stub(EC.getBatchSize()).toReturn(512);
}
use of org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl in project teiid by teiid.
the class TestIckleConversionVisitor method helpExecute.
private IckleConversionVisitor helpExecute(MetadataFactory mf, String query, String expected) throws Exception {
InfinispanExecutionFactory ef = new InfinispanExecutionFactory();
TransformationMetadata metadata = TestProtobufMetadataProcessor.getTransformationMetadata(mf, ef);
TranslationUtility utility = new TranslationUtility(metadata);
Select cmd = (Select) utility.parseCommand(query);
IckleConversionVisitor visitor = new IckleConversionVisitor(new RuntimeMetadataImpl(metadata), false);
visitor.visitNode(cmd);
if (!visitor.exceptions.isEmpty()) {
throw visitor.exceptions.get(0);
}
String actual = visitor.getQuery();
assertEquals(expected, actual);
return visitor;
}
use of org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl in project teiid by teiid.
the class TestProtobufMetadataProcessor method testTableWireFormat.
@Test
public void testTableWireFormat() throws Exception {
MetadataFactory mf = protoMatadata("tables.proto");
InfinispanExecutionFactory ef = new InfinispanExecutionFactory();
TransformationMetadata metadata = getTransformationMetadata(mf, ef);
TreeMap<Integer, TableWireFormat> map = MarshallerBuilder.getWireMap(mf.getSchema().getTable("G2"), new RuntimeMetadataImpl(metadata));
String expected = "{8=TableWireFormat [expectedTag=8, attributeName=e1, nested=null], " + "18=TableWireFormat [expectedTag=18, attributeName=e2, nested=null], " + "42=TableWireFormat [expectedTag=42, attributeName=pm1.G3, nested={" + "8=TableWireFormat [expectedTag=8, attributeName=pm1.G2/pm1.G3/e1, nested=null], " + "18=TableWireFormat [expectedTag=18, attributeName=pm1.G2/pm1.G3/e2, nested=null]}], " + "50=TableWireFormat [expectedTag=50, attributeName=pm1.G4, nested={" + "8=TableWireFormat [expectedTag=8, attributeName=pm1.G2/pm1.G4/e1, nested=null], " + "18=TableWireFormat [expectedTag=18, attributeName=pm1.G2/pm1.G4/e2, nested=null]}], " + "58=TableWireFormat [expectedTag=58, attributeName=e5, nested=null], " + "65=TableWireFormat [expectedTag=65, attributeName=e6, nested=null]}";
assertEquals(expected, map.toString());
}
use of org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl in project teiid by teiid.
the class TestOlapTranslator method testCannedProcedure.
@Test
public void testCannedProcedure() throws Exception {
String ddl = "create foreign procedure proc(arg integer, arg1 date) returns table (x string) options (\"teiid_rel:native-query\" '$2 $1 something')";
String query = "exec proc(2, {d'1970-01-01'})";
TransformationMetadata tm = RealMetadataFactory.fromDDL(ddl, "x", "phy");
CommandBuilder commandBuilder = new CommandBuilder(tm);
Command obj = commandBuilder.getCommand(query);
OlapExecutionFactory oef = new OlapExecutionFactory();
Connection mock = Mockito.mock(java.sql.Connection.class);
OlapWrapper mock2 = Mockito.mock(OlapWrapper.class);
OlapConnection mock3 = Mockito.mock(OlapConnection.class);
OlapStatement mock4 = Mockito.mock(OlapStatement.class);
Mockito.stub(mock4.executeOlapQuery(Mockito.anyString())).toThrow(new TeiidRuntimeException());
Mockito.stub(mock3.createStatement()).toReturn(mock4);
Mockito.stub(mock2.unwrap(OlapConnection.class)).toReturn(mock3);
Mockito.stub(mock.unwrap(OlapWrapper.class)).toReturn(mock2);
ProcedureExecution pe = oef.createProcedureExecution((Call) obj, Mockito.mock(ExecutionContext.class), new RuntimeMetadataImpl(tm), mock);
try {
pe.execute();
fail();
} catch (TeiidRuntimeException e) {
Mockito.verify(mock4).executeOlapQuery("'1970-01-01' 2 something");
}
}
use of org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl in project teiid by teiid.
the class TestWSTranslator method testStreaming.
@Test
public void testStreaming() throws Exception {
WSExecutionFactory ef = new WSExecutionFactory();
WSConnection mockConnection = Mockito.mock(WSConnection.class);
MetadataFactory mf = new MetadataFactory("vdb", 1, "x", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
ef.getMetadata(mf, mockConnection);
Procedure p = mf.getSchema().getProcedure(WSExecutionFactory.INVOKE_HTTP);
assertEquals(7, p.getParameters().size());
TransformationMetadata tm = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "vdb");
RuntimeMetadataImpl rm = new RuntimeMetadataImpl(tm);
Dispatch<Object> mockDispatch = mockDispatch();
DataSource mock = Mockito.mock(DataSource.class);
ByteArrayInputStream baos = new ByteArrayInputStream(new byte[100]);
Mockito.stub(mock.getInputStream()).toReturn(baos);
Mockito.stub(mockDispatch.invoke(Mockito.any(DataSource.class))).toReturn(mock);
Mockito.stub(mockConnection.createDispatch(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(Class.class), Mockito.any(Service.Mode.class))).toReturn(mockDispatch);
CommandBuilder cb = new CommandBuilder(tm);
Call call = (Call) cb.getCommand("call invokeHttp('GET', null, null, true)");
BinaryWSProcedureExecution pe = new BinaryWSProcedureExecution(call, rm, Mockito.mock(ExecutionContext.class), ef, mockConnection);
pe.execute();
List<?> result = pe.getOutputParameterValues();
Blob b = (Blob) result.get(0);
assertEquals(100, ObjectConverterUtil.convertToByteArray(b.getBinaryStream()).length);
try {
ObjectConverterUtil.convertToByteArray(b.getBinaryStream());
fail();
} catch (SQLException e) {
// should only be able to read once
}
}
Aggregations