Search in sources :

Example 1 with DeployVDBParameter

use of org.teiid.jdbc.FakeServer.DeployVDBParameter in project teiid by teiid.

the class TestVDBMerge method testMergeWithEmptyVDB.

@Test
public void testMergeWithEmptyVDB() throws Exception {
    server.deployVDB("empty", UnitTestUtil.getTestDataPath() + "/empty.vdb");
    this.internalConnection = server.createConnection("jdbc:teiid:empty");
    // $NON-NLS-1$
    execute("select * from sys.tables where schemaname ='BQT1'");
    TestMMDatabaseMetaData.compareResultSet("TestVDBMerge/mergeEmpty.before", this.internalResultSet);
    this.internalConnection.close();
    server.deployVDB(VDB2, UnitTestUtil.getTestDataPath() + "/QT_Ora9DS_1.vdb");
    DeployVDBParameter param = new DeployVDBParameter(null, null);
    VDBImportMetadata vdbImport = new VDBImportMetadata();
    vdbImport.setName(VDB2);
    vdbImport.setVersion("1");
    param.vdbImports = Arrays.asList(vdbImport);
    server.undeployVDB("empty");
    server.deployVDB("empty", UnitTestUtil.getTestDataPath() + "/empty.vdb", param);
    this.internalConnection = server.createConnection("jdbc:teiid:empty");
    // $NON-NLS-1$
    execute("select * from sys.tables where schemaname='BQT1'");
    TestMMDatabaseMetaData.compareResultSet("TestVDBMerge/mergeEmpty.after", this.internalResultSet);
}
Also used : DeployVDBParameter(org.teiid.jdbc.FakeServer.DeployVDBParameter) VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) Test(org.junit.Test)

Example 2 with DeployVDBParameter

use of org.teiid.jdbc.FakeServer.DeployVDBParameter in project teiid by teiid.

the class TestVDBMerge method testMerge.

@Test
public void testMerge() throws Throwable {
    server.deployVDB(VDB1, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
    this.internalConnection = server.createConnection("jdbc:teiid:" + VDB1);
    // $NON-NLS-1$
    execute("select * from sys.tables where schemaname ='PartsSupplier'");
    TestMMDatabaseMetaData.compareResultSet("TestVDBMerge/merge.test", this.internalResultSet);
    // $NON-NLS-1$
    execute("select * from sys.tables where schemaname='BQT1'");
    TestMMDatabaseMetaData.compareResultSet("TestVDBMerge/merge.before", this.internalResultSet);
    this.internalConnection.close();
    server.deployVDB(VDB2, UnitTestUtil.getTestDataPath() + "/QT_Ora9DS_1.vdb");
    DeployVDBParameter param = new DeployVDBParameter(null, null);
    VDBImportMetadata vdbImport = new VDBImportMetadata();
    vdbImport.setName(VDB2);
    vdbImport.setVersion("1");
    param.vdbImports = Arrays.asList(vdbImport);
    server.removeVDB(VDB1);
    server.deployVDB(VDB1, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb", param);
    this.internalConnection = server.createConnection("jdbc:teiid:" + VDB1);
    // $NON-NLS-1$
    execute("select * from sys.tables where schemaname='BQT1' order by name");
    TestMMDatabaseMetaData.compareResultSet("TestVDBMerge/merge.after", this.internalResultSet);
}
Also used : DeployVDBParameter(org.teiid.jdbc.FakeServer.DeployVDBParameter) VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) Test(org.junit.Test)

Example 3 with DeployVDBParameter

use of org.teiid.jdbc.FakeServer.DeployVDBParameter in project teiid by teiid.

the class TestMatViews method setUp.

@Before
public void setUp() throws Exception {
    server = new FakeServer(true);
    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));
    conn = server.createConnection("jdbc:teiid:matviews");
}
Also used : DeployVDBParameter(org.teiid.jdbc.FakeServer.DeployVDBParameter) FakeServer(org.teiid.jdbc.FakeServer) HashMap(java.util.HashMap) Collection(java.util.Collection) FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter) Before(org.junit.Before)

Example 4 with DeployVDBParameter

use of org.teiid.jdbc.FakeServer.DeployVDBParameter in project teiid by teiid.

the class TestMetadataUpdates method setup.

@Before
public void setup() throws Exception {
    server.undeployVDB(VDB);
    server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/metadata.vdb", new DeployVDBParameter(null, getMetadataRepo()));
    // $NON-NLS-1$ //$NON-NLS-2$
    connection = server.createConnection("jdbc:teiid:" + VDB);
}
Also used : DeployVDBParameter(org.teiid.jdbc.FakeServer.DeployVDBParameter) Before(org.junit.Before)

Example 5 with DeployVDBParameter

use of org.teiid.jdbc.FakeServer.DeployVDBParameter 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));
}
Also used : HashMap(java.util.HashMap) RuntimeMetadata(org.teiid.metadata.RuntimeMetadata) Execution(org.teiid.translator.Execution) ResultSetExecution(org.teiid.translator.ResultSetExecution) FunctionMethod(org.teiid.metadata.FunctionMethod) List(java.util.List) ArrayList(java.util.ArrayList) DataNotAvailableException(org.teiid.translator.DataNotAvailableException) FunctionParameter(org.teiid.metadata.FunctionParameter) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) ExecutionFactory(org.teiid.translator.ExecutionFactory) ConnectorManager(org.teiid.dqp.internal.datamgr.ConnectorManager) DeployVDBParameter(org.teiid.jdbc.FakeServer.DeployVDBParameter) ResultSetExecution(org.teiid.translator.ResultSetExecution) ExecutionContext(org.teiid.translator.ExecutionContext) Command(org.teiid.language.Command) Collection(java.util.Collection) TranslatorException(org.teiid.translator.TranslatorException) BeforeClass(org.junit.BeforeClass)

Aggregations

DeployVDBParameter (org.teiid.jdbc.FakeServer.DeployVDBParameter)6 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 FunctionMethod (org.teiid.metadata.FunctionMethod)3 FunctionParameter (org.teiid.metadata.FunctionParameter)3 Before (org.junit.Before)2 Test (org.junit.Test)2 VDBImportMetadata (org.teiid.adminapi.impl.VDBImportMetadata)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BeforeClass (org.junit.BeforeClass)1 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)1 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)1 FakeServer (org.teiid.jdbc.FakeServer)1 Command (org.teiid.language.Command)1 RuntimeMetadata (org.teiid.metadata.RuntimeMetadata)1 DataNotAvailableException (org.teiid.translator.DataNotAvailableException)1 Execution (org.teiid.translator.Execution)1 ExecutionContext (org.teiid.translator.ExecutionContext)1 ExecutionFactory (org.teiid.translator.ExecutionFactory)1