use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestRequest method testProcessRequestPreparedStatement.
/**
* Test PreparedStatementRequest.processRequest().
* Test processing the same query twice, and make sure that doesn't cause problems.
* @throws Exception
* @since 4.2
*/
@Test
public void testProcessRequestPreparedStatement() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>("preparedplan", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.PREPAREDPLAN, 0);
// Try before plan is cached.
// If this doesn't throw an exception, assume it was successful.
RequestMessage message = new RequestMessage(QUERY);
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
message.setStatementType(StatementType.PREPARED);
message.setParameterValues(new ArrayList<Object>());
helpProcessMessage(message, cache, workContext);
// Try again, now that plan is already cached.
// If this doesn't throw an exception, assume it was successful.
message = new RequestMessage(QUERY);
message.setStatementType(StatementType.PREPARED);
message.setParameterValues(new ArrayList<Object>());
helpProcessMessage(message, cache, workContext);
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestRequest method testProcessRequest.
/**
* Test Request.processRequest().
* Test processing the same query twice, and make sure that doesn't cause problems.
* See defect 17209.
* @throws Exception
* @since 4.2
*/
@Test
public void testProcessRequest() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// Try before plan is cached.
// If this doesn't throw an exception, assume it was successful.
RequestMessage message = new RequestMessage(QUERY);
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
helpProcessMessage(message, null, workContext);
// Try again, now that plan is already cached.
// If this doesn't throw an exception, assume it was successful.
message = new RequestMessage(QUERY);
helpProcessMessage(message, null, workContext);
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestDQPCore method testRsCacheInvalidation.
@Test
public void testRsCacheInvalidation() throws Exception {
// $NON-NLS-1$
String sql = "select * FROM vqt.SmallB";
// $NON-NLS-1$
String userName = "1";
// $NON-NLS-1$
int sessionid = 1;
RequestMessage reqMsg = exampleRequestMessage(sql);
reqMsg.setUseResultSetCache(true);
ResultsMessage rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(10, rm.getResultsList().size());
assertEquals(0, this.core.getRsCache().getCacheHitCount());
// $NON-NLS-1$
sql = "select * FROM vqt.SmallB";
reqMsg = exampleRequestMessage(sql);
reqMsg.setUseResultSetCache(true);
rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(10, rm.getResultsList().size());
assertEquals(1, this.core.getRsCache().getCacheHitCount());
Thread.sleep(100);
// $NON-NLS-1$
sql = "delete from bqt1.smalla";
reqMsg = exampleRequestMessage(sql);
rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(1, rm.getResultsList().size());
// $NON-NLS-1$
sql = "select * FROM vqt.SmallB";
reqMsg = exampleRequestMessage(sql);
reqMsg.setUseResultSetCache(true);
rm = execute(userName, sessionid, reqMsg);
// $NON-NLS-1$
assertEquals(10, rm.getResultsList().size());
assertEquals(1, this.core.getRsCache().getCacheHitCount());
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestDQPCore method exampleRequestMessage.
public RequestMessage exampleRequestMessage(String sql) {
RequestMessage msg = new RequestMessage(sql);
msg.setCursorType(ResultSet.TYPE_SCROLL_INSENSITIVE);
msg.setFetchSize(10);
msg.setPartialResults(false);
msg.setExecutionId(100);
msg.setExecutionId(id++);
return msg;
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestDQPCore method helpTestVisibilityFails.
public void helpTestVisibilityFails(String sql) throws Exception {
RequestMessage reqMsg = exampleRequestMessage(sql);
reqMsg.setTxnAutoWrapMode(RequestMessage.TXN_WRAP_OFF);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
ResultsMessage results = message.get(5000, TimeUnit.MILLISECONDS);
// $NON-NLS-1$
assertEquals("[QueryValidatorException]Group does not exist: BQT3.SmallA", results.getException().toString());
}
Aggregations