Search in sources :

Example 1 with VDBTranslatorMetaData

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);
}
Also used : VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Test(org.junit.Test)

Example 2 with VDBTranslatorMetaData

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);
    }
}
Also used : TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) Logger(org.teiid.logging.Logger) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData) Test(org.junit.Test)

Example 3 with VDBTranslatorMetaData

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());
}
Also used : VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData) Test(org.junit.Test)

Example 4 with VDBTranslatorMetaData

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());
}
Also used : ArrayList(java.util.ArrayList) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData) Test(org.junit.Test)

Example 5 with VDBTranslatorMetaData

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());
}
Also used : VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData) Test(org.junit.Test)

Aggregations

VDBTranslatorMetaData (org.teiid.adminapi.impl.VDBTranslatorMetaData)27 Test (org.junit.Test)13 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)6 ExecutionFactory (org.teiid.translator.ExecutionFactory)6 ModelNode (org.jboss.dmr.ModelNode)4 Translator (org.teiid.adminapi.Translator)4 ArrayList (java.util.ArrayList)3 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)3 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)3 ConnectorManagerException (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException)3 TranslatorException (org.teiid.translator.TranslatorException)3 Properties (java.util.Properties)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 Module (org.jboss.modules.Module)2 ServiceTarget (org.jboss.msc.service.ServiceTarget)2 TeiidException (org.teiid.core.TeiidException)2 UDFMetaData (org.teiid.deployers.UDFMetaData)2 TeiidConstants.asString (org.teiid.jboss.TeiidConstants.asString)2 IndexMetadataRepository (org.teiid.metadata.index.IndexMetadataRepository)2