use of org.teiid.adminapi.impl.VDBTranslatorMetaData in project teiid by teiid.
the class IntegrationTestDeployment method testTraslators.
@Test
public void testTraslators() throws Exception {
Collection<? extends Translator> translators = admin.getTranslators();
assertEquals(translators.toString(), 61, translators.size());
JavaArchive jar = getLoopyArchive();
try {
admin.deploy("loopy.jar", jar.as(ZipExporter.class).exportAsInputStream());
VDBTranslatorMetaData t = (VDBTranslatorMetaData) admin.getTranslator("loopy");
assertNotNull(t);
assertEquals("ANY", t.getPropertyValue("SupportedJoinCriteria"));
assertEquals("true", t.getPropertyValue("supportsSelectDistinct"));
} finally {
admin.undeploy("loopy.jar");
}
VDBTranslatorMetaData t = (VDBTranslatorMetaData) admin.getTranslator("orcl");
assertNull(t);
}
use of org.teiid.adminapi.impl.VDBTranslatorMetaData in project teiid by teiid.
the class TestTranslatorUtil method testInject.
@Test
public void testInject() throws Exception {
VDBTranslatorMetaData tm = new VDBTranslatorMetaData();
tm.setExecutionFactoryClass(MyTranslator.class);
tm.addProperty("MyProperty", "correctly-assigned");
MyTranslator my = (MyTranslator) TranslatorUtil.buildExecutionFactory(tm);
assertEquals("correctly-assigned", my.getMyProperty());
VDBTranslatorMetaData metadata = TranslatorUtil.buildTranslatorMetadata(my, "my-module");
metadata.addProperty("MyProperty", "correctly-assigned");
Logger logger = Mockito.mock(Logger.class);
Mockito.stub(logger.isEnabled(Mockito.anyString(), Mockito.anyInt())).toReturn(true);
Mockito.doThrow(new RuntimeException("fail")).when(logger).log(Mockito.eq(MessageLevel.WARNING), Mockito.eq(LogConstants.CTX_RUNTIME), Mockito.anyString());
LogManager.setLogListener(logger);
try {
TranslatorUtil.buildExecutionFactory(metadata);
} finally {
LogManager.setLogListener(null);
}
}
use of org.teiid.adminapi.impl.VDBTranslatorMetaData in project teiid by teiid.
the class TestTranslatorUtil method testBuildExecutionFactory1.
@Test
public void testBuildExecutionFactory1() throws Exception {
VDBTranslatorMetaData tm = new VDBTranslatorMetaData();
tm.addProperty("someproperty", "correctly-assigned");
tm.setExecutionFactoryClass(MyTranslator1.class);
MyTranslator1 my = (MyTranslator1) TranslatorUtil.buildExecutionFactory(tm);
assertNull(my.getMyProperty());
assertEquals("correctly-assigned", my.getSomeProperty());
}
use of org.teiid.adminapi.impl.VDBTranslatorMetaData in project teiid by teiid.
the class TestTranslatorUtil method testExtensionMetadataProperties.
@Test
public void testExtensionMetadataProperties() throws Exception {
VDBTranslatorMetaData tm = new VDBTranslatorMetaData();
tm.setExecutionFactoryClass(MyTranslator.class);
tm.addProperty("MyProperty", "correctly-assigned");
MyTranslator my = (MyTranslator) TranslatorUtil.buildExecutionFactory(tm);
VDBTranslatorMetaData translator = TranslatorUtil.buildTranslatorMetadata(my, "my-module");
ExtendedPropertyMetadataList props = translator.getAttachment(ExtendedPropertyMetadataList.class);
ArrayList<ExtendedPropertyMetadata> importProperties = new ArrayList<ExtendedPropertyMetadata>();
for (ExtendedPropertyMetadata prop : props) {
if (prop.category().equals(PropertyType.EXTENSION_METADATA.name())) {
importProperties.add(prop);
}
}
assertEquals("{http://teiid.org}/my-extension-property", importProperties.get(0).name());
assertEquals("java.lang.String", importProperties.get(0).datatype());
assertEquals("org.teiid.metadata.Column", importProperties.get(0).owner());
assertArrayEquals(new String[] { "TOBE", "NOTTOBE" }, importProperties.get(0).allowed());
}
use of org.teiid.adminapi.impl.VDBTranslatorMetaData in project teiid by teiid.
the class TestTranslatorUtil method testInitialSetValueExecutionFactory.
@Test
public void testInitialSetValueExecutionFactory() throws Exception {
VDBTranslatorMetaData tm = new VDBTranslatorMetaData();
tm.setExecutionFactoryClass(MyTranslator2.class);
MyTranslator2 my = (MyTranslator2) TranslatorUtil.buildExecutionFactory(tm);
assertEquals("original-assigned", my.getSomeProperty());
}
Aggregations