use of org.apache.zeppelin.geode.GeodeOqlInterpreter in project zeppelin by apache.
the class GeodeOqlInterpreterTest method testOql.
private void testOql(Iterator<Object> queryResponseIterator, String expectedOutput, int maxResult) throws Exception {
GeodeOqlInterpreter spyGeodeOqlInterpreter = spy(new GeodeOqlInterpreter(new Properties()));
QueryService mockQueryService = mock(QueryService.class, RETURNS_DEEP_STUBS);
when(spyGeodeOqlInterpreter.getQueryService()).thenReturn(mockQueryService);
when(spyGeodeOqlInterpreter.getMaxResult()).thenReturn(maxResult);
@SuppressWarnings("unchecked") SelectResults<Object> mockResults = mock(SelectResults.class);
when(mockQueryService.newQuery(eq(OQL_QUERY)).execute()).thenReturn(mockResults);
when(mockResults.iterator()).thenReturn(queryResponseIterator);
InterpreterResult interpreterResult = spyGeodeOqlInterpreter.interpret(OQL_QUERY, null);
assertEquals(Code.SUCCESS, interpreterResult.code());
assertEquals(expectedOutput, interpreterResult.message().get(0).getData());
}
use of org.apache.zeppelin.geode.GeodeOqlInterpreter in project zeppelin by apache.
the class GeodeOqlInterpreterTest method oqlWithQueryException.
@Test
public void oqlWithQueryException() throws Exception {
GeodeOqlInterpreter spyGeodeOqlInterpreter = spy(new GeodeOqlInterpreter(new Properties()));
when(spyGeodeOqlInterpreter.getExceptionOnConnect()).thenReturn(new RuntimeException("Test Exception On Connect"));
InterpreterResult interpreterResult = spyGeodeOqlInterpreter.interpret(OQL_QUERY, null);
assertEquals(Code.ERROR, interpreterResult.code());
assertEquals("Test Exception On Connect", interpreterResult.message().get(0).getData());
}
use of org.apache.zeppelin.geode.GeodeOqlInterpreter in project zeppelin by apache.
the class GeodeOqlInterpreterTest method oqlWithExceptionOnConnect.
@Test
public void oqlWithExceptionOnConnect() throws Exception {
GeodeOqlInterpreter spyGeodeOqlInterpreter = spy(new GeodeOqlInterpreter(new Properties()));
when(spyGeodeOqlInterpreter.getQueryService()).thenThrow(new RuntimeException("Expected Test Exception!"));
InterpreterResult interpreterResult = spyGeodeOqlInterpreter.interpret(OQL_QUERY, null);
assertEquals(Code.ERROR, interpreterResult.code());
assertEquals("Expected Test Exception!", interpreterResult.message().get(0).getData());
}
use of org.apache.zeppelin.geode.GeodeOqlInterpreter in project zeppelin by apache.
the class GeodeOqlInterpreterTest method testOpenCommandIndempotency.
@Test
public void testOpenCommandIndempotency() {
Properties properties = new Properties();
properties.put("geode.locator.host", "localhost");
properties.put("geode.locator.port", "10334");
properties.put("geode.max.result", "1000");
GeodeOqlInterpreter spyGeodeOqlInterpreter = spy(new GeodeOqlInterpreter(properties));
// Ensure that an attempt to open new connection will clean any remaining connections
spyGeodeOqlInterpreter.open();
spyGeodeOqlInterpreter.open();
spyGeodeOqlInterpreter.open();
verify(spyGeodeOqlInterpreter, times(3)).open();
verify(spyGeodeOqlInterpreter, times(3)).close();
}
Aggregations