Search in sources :

Example 11 with FakeServer

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

the class TestResultSetMetadata method setUp.

@Before
public void setUp() throws Exception {
    server = new FakeServer(true);
    server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
    // $NON-NLS-1$ //$NON-NLS-2$
    this.internalConnection = server.createConnection("jdbc:teiid:" + VDB);
}
Also used : FakeServer(org.teiid.jdbc.FakeServer) Before(org.junit.Before)

Example 12 with FakeServer

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

the class TestStats method setUp.

@BeforeClass
public static void setUp() throws Exception {
    server = new FakeServer(true);
    server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
    // $NON-NLS-1$ //$NON-NLS-2$
    connection = server.createConnection("jdbc:teiid:" + VDB);
}
Also used : FakeServer(org.teiid.jdbc.FakeServer) BeforeClass(org.junit.BeforeClass)

Example 13 with FakeServer

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

the class TestExecutionReuse method oneTimeSetUp.

@BeforeClass
public static void oneTimeSetUp() throws Exception {
    EmbeddedConfiguration config = new EmbeddedConfiguration();
    config.setUserRequestSourceConcurrency(1);
    server = new FakeServer(false);
    server.setConnectorManagerRepository(new ConnectorManagerRepository() {

        private ConnectorManager cm = new ConnectorManager("x", "y") {

            private ExecutionFactory<Object, Object> ef = new ExecutionFactory<Object, Object>() {

                @Override
                public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws TranslatorException {
                    ec = executionContext;
                    return execution;
                }

                public boolean isSourceRequired() {
                    return false;
                }
            };

            @Override
            public ExecutionFactory<Object, Object> getExecutionFactory() {
                return ef;
            }

            @Override
            public Object getConnectionFactory() throws TranslatorException {
                return null;
            }
        };

        @Override
        public ConnectorManager getConnectorManager(String connectorName) {
            return cm;
        }
    });
    server.start(config, false);
    server.deployVDB("PartsSupplier", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
}
Also used : FakeServer(org.teiid.jdbc.FakeServer) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) EmbeddedConfiguration(org.teiid.runtime.EmbeddedConfiguration) ExecutionFactory(org.teiid.translator.ExecutionFactory) ConnectorManager(org.teiid.dqp.internal.datamgr.ConnectorManager) RuntimeMetadata(org.teiid.metadata.RuntimeMetadata) ResultSetExecution(org.teiid.translator.ResultSetExecution) ExecutionContext(org.teiid.translator.ExecutionContext) TranslatorException(org.teiid.translator.TranslatorException) QueryExpression(org.teiid.language.QueryExpression) BeforeClass(org.junit.BeforeClass)

Example 14 with FakeServer

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

the class TestEventDistributor method testEvents.

@Test
public void testEvents() throws Exception {
    FakeServer server = null;
    try {
        server = new FakeServer(true);
        EventListener events = Mockito.mock(EventListener.class);
        server.getEventDistributor().register(events);
        server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
        Mockito.verify(events).vdbDeployed(VDB, "1");
        Mockito.verify(events).vdbLoaded((VDB) Mockito.any());
        server.undeployVDB(VDB);
        Mockito.verify(events).vdbDeployed(VDB, "1");
        Mockito.verify(events).vdbLoaded((VDB) Mockito.any());
        Mockito.verify(events).vdbUndeployed(VDB, "1");
    } finally {
        if (server != null) {
            server.stop();
        }
    }
}
Also used : FakeServer(org.teiid.jdbc.FakeServer) Test(org.junit.Test)

Example 15 with FakeServer

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

the class TestAsynch method oneTimeSetup.

@BeforeClass
public static void oneTimeSetup() throws Exception {
    server = new FakeServer(true);
    ModelMetaData mmd = new ModelMetaData();
    mmd.setName("v");
    mmd.setModelType(Type.PHYSICAL);
    mmd.setSchemaSourceType("ddl");
    mmd.addSourceMapping("z", "z", null);
    mmd.setSchemaText("create view test (col integer) as select 1; create foreign table someTable (col integer);");
    ef = new HardCodedExecutionFactory() {

        @Override
        public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws TranslatorException {
            partIds.add(executionContext.getPartIdentifier());
            return super.createResultSetExecution(command, executionContext, metadata, connection);
        }
    };
    server.addTranslator("z", ef);
    server.deployVDB("x", mmd);
}
Also used : ResultSetExecution(org.teiid.translator.ResultSetExecution) ExecutionContext(org.teiid.translator.ExecutionContext) FakeServer(org.teiid.jdbc.FakeServer) HardCodedExecutionFactory(org.teiid.runtime.HardCodedExecutionFactory) TranslatorException(org.teiid.translator.TranslatorException) QueryExpression(org.teiid.language.QueryExpression) RuntimeMetadata(org.teiid.metadata.RuntimeMetadata) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) BeforeClass(org.junit.BeforeClass)

Aggregations

FakeServer (org.teiid.jdbc.FakeServer)23 BeforeClass (org.junit.BeforeClass)13 EmbeddedConfiguration (org.teiid.runtime.EmbeddedConfiguration)8 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)5 Before (org.junit.Before)4 Test (org.junit.Test)4 HardCodedExecutionFactory (org.teiid.runtime.HardCodedExecutionFactory)4 InetSocketAddress (java.net.InetSocketAddress)3 Connection (java.sql.Connection)3 QueryExpression (org.teiid.language.QueryExpression)3 TranslatorException (org.teiid.translator.TranslatorException)3 ResultSet (java.sql.ResultSet)2 Properties (java.util.Properties)2 DummyTransactionManager (org.infinispan.transaction.tm.DummyTransactionManager)2 TeiidSQLException (org.teiid.jdbc.TeiidSQLException)2 RuntimeMetadata (org.teiid.metadata.RuntimeMetadata)2 ExecutionContext (org.teiid.translator.ExecutionContext)2 ResultSetExecution (org.teiid.translator.ResultSetExecution)2 IOException (java.io.IOException)1 NotSerializableException (java.io.NotSerializableException)1