use of org.teiid.language.Argument 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);
}
use of org.teiid.language.Argument in project teiid by teiid.
the class JDBCProcedureExecution method getOutputParameterValues.
@Override
public List<?> getOutputParameterValues() throws TranslatorException {
try {
Call proc = (Call) this.command;
List<Object> result = new ArrayList<Object>();
int paramIndex = 1;
if (proc.getReturnType() != null) {
if (proc.getReturnParameter() != null) {
addParameterValue(result, paramIndex, proc.getReturnType());
}
paramIndex++;
}
for (Argument parameter : proc.getArguments()) {
switch(parameter.getDirection()) {
case IN:
paramIndex++;
break;
case INOUT:
case OUT:
addParameterValue(result, paramIndex++, parameter.getType());
break;
}
}
return result;
} catch (SQLException e) {
throw new TranslatorException(JDBCPlugin.Event.TEIID11005, e);
}
}
Aggregations