Search in sources :

Example 11 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestSessionServiceImpl method testActiveVDBWithNoVersion.

@Test
public void testActiveVDBWithNoVersion() throws Exception {
    VDBRepository repo = Mockito.mock(VDBRepository.class);
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("name");
    vdb.setVersion(1);
    vdb.setStatus(Status.ACTIVE);
    Mockito.stub(repo.getLiveVDB("name")).toReturn(vdb);
    ssi.setVDBRepository(repo);
    ssi.getActiveVDB("name", null);
    Mockito.verify(repo, Mockito.times(1)).getLiveVDB("name");
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) VDBRepository(org.teiid.deployers.VDBRepository) Test(org.junit.Test)

Example 12 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestSessionServiceImpl method testActiveVDBNameWithVersionNonInteger.

@Test
public void testActiveVDBNameWithVersionNonInteger() throws Exception {
    VDBRepository repo = Mockito.mock(VDBRepository.class);
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("name");
    vdb.setVersion(1);
    vdb.setStatus(Status.ACTIVE);
    Mockito.stub(repo.getLiveVDB("name", 1)).toReturn(vdb);
    ssi.setVDBRepository(repo);
    assertNull(ssi.getActiveVDB("name.x", null));
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) VDBRepository(org.teiid.deployers.VDBRepository) Test(org.junit.Test)

Example 13 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestLogonImpl method addVdb.

private VDBMetaData addVdb(VDBRepository repo, String name, String sc, String authenticationType) {
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName(name);
    vdb.setVersion(1);
    vdb.setStatus(Status.ACTIVE);
    Mockito.stub(repo.getLiveVDB(name, "1")).toReturn(vdb);
    vdb.addProperty(SessionServiceImpl.SECURITY_DOMAIN_PROPERTY, sc);
    vdb.addProperty(SessionServiceImpl.AUTHENTICATION_TYPE_PROPERTY, authenticationType);
    return vdb;
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData)

Example 14 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestDDLMetadataStore method testVDBExport.

@Test
public void testVDBExport() throws Exception {
    EmbeddedConfiguration ec = new EmbeddedConfiguration();
    ec.setUseDisk(false);
    ec.setSecurityHelper(new ThreadLocalSecurityHelper());
    es.addTranslator("y", new TestEmbeddedServer.FakeTranslator(false));
    es.start(ec);
    final AtomicInteger counter = new AtomicInteger();
    ConnectionFactoryProvider<AtomicInteger> cfp = new EmbeddedServer.SimpleConnectionFactoryProvider<AtomicInteger>(counter);
    es.addConnectionFactoryProvider("z", cfp);
    es.addMetadataRepository("myrepo", Mockito.mock(MetadataRepository.class));
    es.deployVDB(new FileInputStream(UnitTestUtil.getTestDataPath() + "/first-db.ddl"), true);
    Admin admin = es.getAdmin();
    VDBMetaData vdb = (VDBMetaData) admin.getVDB("empty", "2");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    VDBMetadataParser.marshell(vdb, out);
    String expected = ObjectConverterUtil.convertFileToString(new File(UnitTestUtil.getTestDataPath() + "/" + "first-vdb.xml"));
    assertEquals(expected, new String(out.toByteArray()));
    String exportedDdl = admin.getSchema("empty", "2", null, null, null);
    Assert.assertEquals(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("first-vdb.ddl")), exportedDdl);
}
Also used : TestEmbeddedServer(org.teiid.runtime.TestEmbeddedServer) EmbeddedConfiguration(org.teiid.runtime.EmbeddedConfiguration) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Admin(org.teiid.adminapi.Admin) FileInputStream(java.io.FileInputStream) MetadataRepository(org.teiid.metadata.MetadataRepository) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) File(java.io.File) Test(org.junit.Test)

Example 15 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class Request method initMetadata.

/**
 * if the metadata has not been supplied via setMetadata, this method will create the appropriate state
 *
 * @throws TeiidComponentException
 */
protected void initMetadata() throws TeiidComponentException {
    if (this.metadata != null) {
        return;
    }
    // Prepare dependencies for running the optimizer
    this.capabilitiesFinder = new CachedFinder(this.connectorManagerRepo, workContext.getVDB());
    if (this.bufferManager.getOptions() != null) {
        this.capabilitiesFinder = new TempCapabilitiesFinder(this.capabilitiesFinder, this.bufferManager.getOptions().getDefaultNullOrder());
    } else {
        this.capabilitiesFinder = new TempCapabilitiesFinder(this.capabilitiesFinder);
    }
    VDBMetaData vdbMetadata = workContext.getVDB();
    metadata = vdbMetadata.getAttachment(QueryMetadataInterface.class);
    globalTables = vdbMetadata.getAttachment(GlobalTableStore.class);
    if (metadata == null) {
        throw new TeiidComponentException(QueryPlugin.Event.TEIID30489, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30489, this.vdbName, this.vdbVersion));
    }
    TempMetadataAdapter tma = new TempMetadataAdapter(metadata, this.tempTableStore.getMetadataStore());
    tma.setSession(true);
    this.metadata = tma;
}
Also used : TempMetadataAdapter(org.teiid.query.metadata.TempMetadataAdapter) GlobalTableStore(org.teiid.query.tempdata.GlobalTableStore) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) TeiidComponentException(org.teiid.core.TeiidComponentException) TempCapabilitiesFinder(org.teiid.query.metadata.TempCapabilitiesFinder) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface)

Aggregations

VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)121 Test (org.junit.Test)48 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)36 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)16 MetadataStore (org.teiid.metadata.MetadataStore)15 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)14 VDBRepository (org.teiid.deployers.VDBRepository)12 ArrayList (java.util.ArrayList)10 IOException (java.io.IOException)9 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)9 Properties (java.util.Properties)8 XMLStreamException (javax.xml.stream.XMLStreamException)8 VDBImportMetadata (org.teiid.adminapi.impl.VDBImportMetadata)8 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)7 TeiidComponentException (org.teiid.core.TeiidComponentException)7 VDBKey (org.teiid.vdb.runtime.VDBKey)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 VDBTranslatorMetaData (org.teiid.adminapi.impl.VDBTranslatorMetaData)6 Schema (org.teiid.metadata.Schema)6 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)5