use of org.teiid.client.ResultsMessage in project teiid by teiid.
the class TestDQPCore method testNotHasRole.
@Test
public void testNotHasRole() throws Exception {
// $NON-NLS-1$
String sql = "SELECT hasRole('bar')";
// $NON-NLS-1$
String userName = "logon";
ResultsMessage rm = helpExecute(sql, userName);
assertFalse((Boolean) rm.getResultsList().get(0).get(0));
}
use of org.teiid.client.ResultsMessage in project teiid by teiid.
the class TestDQPCore method testPlanningException.
/**
* Tests whether an exception result is sent when an exception occurs
* @since 4.3
*/
@Test
public void testPlanningException() throws Exception {
// $NON-NLS-1$
String sql = "SELECT IntKey FROM BQT1.BadIdea ";
RequestMessage reqMsg = exampleRequestMessage(sql);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
try {
message.get(5000, TimeUnit.MILLISECONDS);
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof QueryResolverException);
}
}
use of org.teiid.client.ResultsMessage in project teiid by teiid.
the class TestResultsMessage method example.
public static ResultsMessage example() {
ResultsMessage message = new ResultsMessage();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
message.setColumnNames(new String[] { "A", "B", "C", "D" });
message.setDataTypes(new String[] { DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_INTEGER });
message.setFinalRow(200);
message.setFirstRow(1);
message.setLastRow(100);
List parameters = new ArrayList();
parameters.add(new ParameterInfo(ParameterInfo.IN, 0));
parameters.add(new ParameterInfo(ParameterInfo.RESULT_SET, 5));
message.setParameters(parameters);
PlanNode planDescs = new PlanNode("test");
// $NON-NLS-1$ //$NON-NLS-2$
planDescs.addProperty("key1", "val1");
// $NON-NLS-1$ //$NON-NLS-2$
planDescs.addProperty("key2", "val2");
// $NON-NLS-1$ //$NON-NLS-2$
planDescs.addProperty("key3", "val3");
// $NON-NLS-1$ //$NON-NLS-2$
planDescs.addProperty("key4", "val4");
message.setPlanDescription(planDescs);
List results = new ArrayList();
// $NON-NLS-1$
results.add(new BigInteger("100"));
// $NON-NLS-1$
results.add(new BigInteger("200"));
// $NON-NLS-1$
results.add(new BigInteger("300"));
// $NON-NLS-1$
results.add(new BigInteger("400"));
message.setResults(new List[] { results });
List warnings = new ArrayList();
// $NON-NLS-1$
warnings.add(new Exception("warning1"));
// $NON-NLS-1$
warnings.add(new Exception("warning2"));
message.setWarnings(warnings);
return message;
}
use of org.teiid.client.ResultsMessage in project teiid by teiid.
the class TestResultsMessage method testSerialize.
public void testSerialize() throws Exception {
ResultsMessage message = example();
ResultsMessage copy = UnitTestUtil.helpSerialize(message);
assertNotNull(copy.getColumnNames());
assertEquals(4, copy.getColumnNames().length);
// $NON-NLS-1$
assertEquals("A", copy.getColumnNames()[0]);
// $NON-NLS-1$
assertEquals("B", copy.getColumnNames()[1]);
// $NON-NLS-1$
assertEquals("C", copy.getColumnNames()[2]);
// $NON-NLS-1$
assertEquals("D", copy.getColumnNames()[3]);
assertNotNull(copy.getDataTypes());
assertEquals(4, copy.getDataTypes().length);
assertEquals(DataTypeManager.DefaultDataTypes.BIG_INTEGER, copy.getDataTypes()[0]);
assertEquals(DataTypeManager.DefaultDataTypes.BIG_INTEGER, copy.getDataTypes()[1]);
assertEquals(DataTypeManager.DefaultDataTypes.BIG_INTEGER, copy.getDataTypes()[2]);
assertEquals(DataTypeManager.DefaultDataTypes.BIG_INTEGER, copy.getDataTypes()[3]);
assertEquals(200, copy.getFinalRow());
assertEquals(1, copy.getFirstRow());
assertEquals(100, copy.getLastRow());
assertNotNull(copy.getParameters());
assertEquals(2, copy.getParameters().size());
ParameterInfo info1 = (ParameterInfo) copy.getParameters().get(0);
assertEquals(ParameterInfo.IN, info1.getType());
assertEquals(0, info1.getNumColumns());
ParameterInfo info2 = (ParameterInfo) copy.getParameters().get(1);
assertEquals(ParameterInfo.RESULT_SET, info2.getType());
assertEquals(5, info2.getNumColumns());
assertNotNull(copy.getPlanDescription());
assertEquals(4, copy.getPlanDescription().getProperties().size());
List<? extends List<?>> results = copy.getResultsList();
assertNotNull(results);
assertEquals(1, results.size());
assertNotNull(results.get(0));
assertEquals(4, results.get(0).size());
// $NON-NLS-1$
assertEquals(new BigInteger("100"), copy.getResultsList().get(0).get(0));
// $NON-NLS-1$
assertEquals(new BigInteger("200"), copy.getResultsList().get(0).get(1));
// $NON-NLS-1$
assertEquals(new BigInteger("300"), copy.getResultsList().get(0).get(2));
// $NON-NLS-1$
assertEquals(new BigInteger("400"), copy.getResultsList().get(0).get(3));
assertNotNull(copy.getWarnings());
assertEquals(2, copy.getWarnings().size());
assertEquals(Exception.class, copy.getWarnings().get(0).getClass());
// $NON-NLS-1$
assertEquals("warning1", ((Exception) copy.getWarnings().get(0)).getMessage());
assertEquals(Exception.class, copy.getWarnings().get(1).getClass());
// $NON-NLS-1$
assertEquals("warning2", ((Exception) copy.getWarnings().get(1)).getMessage());
}
use of org.teiid.client.ResultsMessage in project teiid by teiid.
the class TestResultsMessage method testDelayedDeserialization.
public void testDelayedDeserialization() throws Exception {
ResultsMessage message = example();
message.setDelayDeserialization(true);
ResultsMessage copy = UnitTestUtil.helpSerialize(message);
assertNull(copy.getResultsList());
copy.processResults();
assertNotNull(copy.getResultsList());
}
Aggregations