use of org.teiid.translator.FileConnection in project teiid by teiid.
the class TestExcelExecution method testExecutionLimit2.
@Test
public void testExecutionLimit2() throws Exception {
FileConnection connection = Mockito.mock(FileConnection.class);
Mockito.stub(connection.getFile("names.xls")).toReturn(UnitTestUtil.getTestDataFile("names.xls"));
ArrayList results = helpExecute(commonDDL, connection, "select FirstName from Sheet1 LIMIT 1");
assertEquals("[[John]]", results.toString());
}
use of org.teiid.translator.FileConnection in project teiid by teiid.
the class TestFileExecutionFactory method testGetTextFiles.
@Test
public void testGetTextFiles() throws Exception {
FileExecutionFactory fef = new FileExecutionFactory();
MetadataFactory mf = new MetadataFactory("vdb", 1, "text", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
fef.getMetadata(mf, null);
Procedure p = mf.getSchema().getProcedure("getTextFiles");
FileConnection fc = Mockito.mock(FileConnection.class);
Mockito.stub(fc.getFile("*.txt")).toReturn(new File(UnitTestUtil.getTestDataPath(), "*.txt"));
Call call = fef.getLanguageFactory().createCall("getTextFiles", Arrays.asList(new Argument(Direction.IN, new Literal("*.txt", TypeFacility.RUNTIME_TYPES.STRING), TypeFacility.RUNTIME_TYPES.STRING, null)), p);
ProcedureExecution pe = fef.createProcedureExecution(call, null, null, fc);
pe.execute();
int count = 0;
while (true) {
List<?> val = pe.next();
if (val == null) {
break;
}
assertEquals(5, val.size());
assertTrue(val.get(3) instanceof Timestamp);
assertEquals(Long.valueOf(0), val.get(4));
count++;
}
assertEquals(2, count);
call = fef.getLanguageFactory().createCall("getTextFiles", Arrays.asList(new Argument(Direction.IN, new Literal("*1*", TypeFacility.RUNTIME_TYPES.STRING), TypeFacility.RUNTIME_TYPES.STRING, null)), p);
pe = fef.createProcedureExecution(call, null, null, fc);
Mockito.stub(fc.getFile("*1*")).toReturn(new File(UnitTestUtil.getTestDataPath(), "*1*"));
pe.execute();
count = 0;
while (true) {
if (pe.next() == null) {
break;
}
count++;
}
assertEquals(1, count);
}
Aggregations