Search in sources :

Example 6 with CoherenceManagedConnectionFactory

use of org.teiid.resource.adapter.coherence.CoherenceManagedConnectionFactory in project teiid by teiid.

the class TestCoherenceTranslator method setUp.

@Override
protected void setUp() throws Exception {
    // TODO Auto-generated method stub
    super.setUp();
    new TradesCacheSource().addMetadata();
    CoherenceManagedConnectionFactory connFactory = new CoherenceManagedConnectionFactory();
    connFactory.setCacheName(TradesCacheSource.CACHE_NAME);
    connFactory.setCacheTranslatorClassName(OBJECT_TRANSLATOR);
    CoherenceConnection conn = (CoherenceConnection) connFactory.createConnectionFactory().getConnection();
    CoherenceExecutionFactory execFactory = new CoherenceExecutionFactory();
    host = new ConnectorHost(execFactory, conn, // getTradeTranslationUtility());
    UnitTestUtil.getTestDataPath() + "/Coherence_Designer_Project/Trade.vdb");
}
Also used : ConnectorHost(org.teiid.cdk.api.ConnectorHost) CoherenceManagedConnectionFactory(org.teiid.resource.adapter.coherence.CoherenceManagedConnectionFactory) CoherenceConnection(org.teiid.resource.adapter.coherence.CoherenceConnection)

Example 7 with CoherenceManagedConnectionFactory

use of org.teiid.resource.adapter.coherence.CoherenceManagedConnectionFactory in project teiid by teiid.

the class TestCoherenceConnection method testEqualOnTrade.

@Test
public void testEqualOnTrade() throws Exception {
    CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
    f.setCacheName(CACHE_NAME);
    f.setCacheTranslatorClassName(OBJECT_TRANSLATOR);
    CoherenceConnection conn = (CoherenceConnection) f.createConnectionFactory().getConnection();
    // NOTE:  Coherence, because the datatype of ID is long, wants the "l" appended to the value
    Filter criteria = CoherenceFilterUtil.createFilter("Id = 1l");
    List<?> trades = conn.get(criteria);
    assertNotNull(trades);
    assertEquals("Did not get expected number of trades", 1, trades.size());
    long l = 1;
    criteria = CoherenceFilterUtil.createCompareFilter("Id", l, Comparison.Operator.EQ, Long.class);
    trades = conn.get(criteria);
    assertNotNull(trades);
    assertEquals("Did not get expected number of trades", 1, trades.size());
}
Also used : Filter(com.tangosol.util.Filter) CoherenceManagedConnectionFactory(org.teiid.resource.adapter.coherence.CoherenceManagedConnectionFactory) CoherenceConnection(org.teiid.resource.adapter.coherence.CoherenceConnection) Test(org.junit.Test)

Example 8 with CoherenceManagedConnectionFactory

use of org.teiid.resource.adapter.coherence.CoherenceManagedConnectionFactory in project teiid by teiid.

the class TestCoherenceConnection method testIn.

@Test
public void testIn() throws Exception {
    CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
    f.setCacheName(CACHE_NAME);
    f.setCacheTranslatorClassName(OBJECT_TRANSLATOR);
    CoherenceConnection conn = (CoherenceConnection) f.createConnectionFactory().getConnection();
    // NOTE:  Coherence, because the datatype of ID is long, wants the "l" appended to the value
    Filter criteria = CoherenceFilterUtil.createFilter("Id In (1l)");
    List<?> trades = conn.get(criteria);
    assertNotNull(trades);
    assertEquals("Did not get expected number of trades", 1, trades.size());
}
Also used : Filter(com.tangosol.util.Filter) CoherenceManagedConnectionFactory(org.teiid.resource.adapter.coherence.CoherenceManagedConnectionFactory) CoherenceConnection(org.teiid.resource.adapter.coherence.CoherenceConnection) Test(org.junit.Test)

Aggregations

CoherenceConnection (org.teiid.resource.adapter.coherence.CoherenceConnection)8 CoherenceManagedConnectionFactory (org.teiid.resource.adapter.coherence.CoherenceManagedConnectionFactory)8 Test (org.junit.Test)7 Filter (com.tangosol.util.Filter)6 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ArrayList (java.util.ArrayList)1 ConnectorHost (org.teiid.cdk.api.ConnectorHost)1