use of org.teiid.cdk.api.ConnectorHost in project teiid by teiid.
the class TestLoobackAsynch method test.
public void test() throws Exception {
LoopbackExecutionFactory connector = new LoopbackExecutionFactory();
connector.setWaitTime(200);
connector.setRowCount(1000);
connector.setPollIntervalInMilli(100L);
ConnectorHost host = new ConnectorHost(connector, null, FakeTranslationFactory.getInstance().getBQTTranslationUtility());
// $NON-NLS-1$
List results = host.executeCommand("SELECT intkey from bqt1.smalla");
assertEquals(1000, results.size());
}
use of org.teiid.cdk.api.ConnectorHost in project teiid by teiid.
the class TestLoopbackExecution method defer_testWaitTime.
/**
* wait time is implemented as a random value up to the specified value. assertions are then not really possible
* based upon that time.
*/
public void defer_testWaitTime() throws Exception {
int waitTime = 100;
int testCount = 10;
ConnectorHost host = new ConnectorHost(exampleProperties(waitTime, 1), null, FakeTranslationFactory.getInstance().getBQTTranslationUtility());
for (int i = 0; i < testCount; i++) {
long before = System.currentTimeMillis();
// $NON-NLS-1$
host.executeCommand("SELECT intkey FROM BQT1.SmallA");
long after = System.currentTimeMillis();
// $NON-NLS-1$
Assert.assertTrue("Waited too long", (after - before) <= waitTime);
}
}
use of org.teiid.cdk.api.ConnectorHost in project teiid by teiid.
the class TestHelper method helpTestQuery.
public static void helpTestQuery(boolean incrementRows, String sql, TranslationUtility metadata, int waitTime, int rowCount, Object[][] expectedResults) throws TranslatorException {
ConnectorHost host = new ConnectorHost(exampleProperties(incrementRows, waitTime, rowCount), null, metadata);
List actualResults = host.executeCommand(sql);
// Compare actual and expected results
// $NON-NLS-1$
Assert.assertEquals("Did not get expected number of rows", expectedResults.length, actualResults.size());
if (expectedResults.length > 0) {
// Compare column sizes
// $NON-NLS-1$
Assert.assertEquals("Did not get expected number of columns", expectedResults[0].length, ((List) actualResults.get(0)).size());
// Compare results
for (int r = 0; r < expectedResults.length; r++) {
Object[] expectedRow = expectedResults[r];
List actualRow = (List) actualResults.get(r);
for (int c = 0; c < expectedRow.length; c++) {
Object expectedValue = expectedRow[c];
Object actualValue = actualRow.get(c);
if (expectedValue == null) {
if (actualValue != null) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Assert.fail("Row " + r + ", Col " + c + ": Expected null but got " + actualValue + " of type " + actualValue.getClass().getName());
}
} else if (actualValue == null) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Assert.fail("Row " + r + ", Col " + c + ": Expected " + expectedValue + " but got null");
} else if (expectedValue.getClass().isArray() && !expectedValue.getClass().getComponentType().isPrimitive()) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Assert.assertArrayEquals("Row " + r + ", Col " + c + ": Expected " + expectedValue + " but got " + actualValue, (Object[]) expectedValue, (Object[]) actualValue);
} else {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Assert.assertEquals("Row " + r + ", Col " + c + ": Expected " + expectedValue + " but got " + actualValue, expectedValue, actualValue);
}
}
}
}
}
use of org.teiid.cdk.api.ConnectorHost 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");
}
Aggregations