use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class TestCompositeVDB method testFunctionValidationError.
@Test
public void testFunctionValidationError() throws Exception {
VDBRepository repo = new VDBRepository();
repo.start();
repo.setSystemStore(RealMetadataFactory.example1Cached().getMetadataStore());
repo.setSystemFunctionManager(RealMetadataFactory.SFM);
MetadataStore metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("x", metadataStore);
FunctionMethod method = MetadataFactory.createFunctionFromMethod("getProperty", System.class.getMethod("getProperty", String.class));
method.setInvocationClass("?");
method.setMethod(null);
metadataStore.getSchema("x").addFunction(method);
VDBMetaData vdb = createVDBMetadata(metadataStore, "bqt");
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
cmr.addConnectorManager("x", new ConnectorManager("y", "z"));
repo.addVDB(vdb, metadataStore, null, null, cmr);
repo.finishDeployment(vdb.getName(), vdb.getVersion());
assertEquals(vdb.getStatus(), Status.FAILED);
}
use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class TestLocalConnections method oneTimeSetup.
@SuppressWarnings("serial")
@BeforeClass
public static void oneTimeSetup() throws Exception {
server.setUseCallingThread(true);
server.setConnectorManagerRepository(new ConnectorManagerRepository() {
@Override
public ConnectorManager getConnectorManager(String connectorName) {
return new ConnectorManager(connectorName, connectorName) {
@Override
public ExecutionFactory<Object, Object> getExecutionFactory() {
return new ExecutionFactory<Object, Object>() {
@Override
public boolean isSourceRequired() {
return false;
}
@Override
public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws TranslatorException {
return new ResultSetExecution() {
boolean returnedRow = false;
@Override
public void execute() throws TranslatorException {
lock.lock();
try {
sourceCounter.release();
if (!wait.await(5, TimeUnit.SECONDS)) {
throw new RuntimeException();
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
lock.unlock();
}
}
@Override
public void close() {
}
@Override
public void cancel() throws TranslatorException {
}
@Override
public List<?> next() throws TranslatorException, DataNotAvailableException {
if (returnedRow) {
return null;
}
returnedRow = true;
return new ArrayList<Object>(Collections.singleton(null));
}
};
}
};
}
@Override
public Object getConnectionFactory() throws TranslatorException {
return null;
}
};
}
});
FunctionMethod function = new FunctionMethod("foo", null, FunctionCategoryConstants.MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, TestLocalConnections.class.getName(), "blocking", null, new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER), false, FunctionMethod.Determinism.NONDETERMINISTIC);
HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
udfs.put("test", Arrays.asList(function));
server.deployVDB("PartsSupplier", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb", new DeployVDBParameter(udfs, null));
}
use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class TestReplication method deployMatViewVDB.
private void deployMatViewVDB(FakeServer server) throws Exception {
HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
udfs.put("funcs", Arrays.asList(new FunctionMethod("pause", null, null, PushDown.CANNOT_PUSHDOWN, TestMatViews.class.getName(), "pause", null, new FunctionParameter("return", DataTypeManager.DefaultDataTypes.INTEGER), true, Determinism.NONDETERMINISTIC)));
server.deployVDB(MATVIEWS, UnitTestUtil.getTestDataPath() + "/matviews.vdb", new DeployVDBParameter(udfs, null));
}
Aggregations