use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.
the class HADispatcherDUnitTest method createCQ.
private void createCQ() throws CqException, CqExistsException, RegionNotFoundException {
QueryService cqService = null;
try {
cqService = cache.getQueryService();
} catch (Exception cqe) {
cqe.printStackTrace();
fail("Failed to getCQService.");
}
// Create CQ Attributes.
CqAttributesFactory cqf = new CqAttributesFactory();
CqListener[] cqListeners = { new CqQueryTestListener(getLogWriter()) };
cqf.initCqListeners(cqListeners);
CqAttributes cqa = cqf.create();
String cqName = "CQForHARegionQueueTest";
String queryStr = "Select * from " + Region.SEPARATOR + REGION_NAME;
// Create CQ.
CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa);
cq1.execute();
}
use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.
the class CQListGIIDUnitTest method waitForEvent.
public static void waitForEvent(int event, String cqName, String key) {
// Get CQ Service.
QueryService cqService = null;
try {
cqService = cache.getQueryService();
} catch (Exception cqe) {
Assert.fail("Failed to getCQService.", cqe);
}
CqQuery cQuery = cqService.getCq(cqName);
if (cQuery == null) {
Assert.fail("Failed to get CqQuery for CQ : " + cqName, new Exception("Failed to get CqQuery for CQ : " + cqName));
}
CqAttributes cqAttr = cQuery.getCqAttributes();
CqListener[] cqListener = cqAttr.getCqListeners();
CqQueryTestListener listener = (CqQueryTestListener) cqListener[0];
switch(event) {
case CREATE:
listener.waitForCreated(key);
break;
case UPDATE:
listener.waitForUpdated(key);
break;
case DESTROY:
listener.waitForDestroyed(key);
break;
case INVALIDATE:
listener.waitForInvalidated(key);
break;
case CLOSE:
listener.waitForClose();
break;
case REGION_CLEAR:
listener.waitForRegionClear();
break;
case REGION_INVALIDATE:
listener.waitForRegionInvalidate();
break;
}
}
use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.
the class ClientCQPostAuthorizationDUnitTest method createCQ.
private void createCQ(final int num) throws CqException, CqExistsException {
for (int i = 0; i < num; i++) {
QueryService cqService = getProxyCaches(i).getQueryService();
String cqName = "CQ_" + i;
String queryStr = cqNameToQueryStrings.get(cqName) + getProxyCaches(i).getRegion(REGION_NAME).getFullPath();
// Create CQ Attributes.
CqAttributesFactory cqf = new CqAttributesFactory();
CqListener[] cqListeners = { new CqQueryTestListener(getLogWriter()) };
((CqQueryTestListener) cqListeners[0]).cqName = cqName;
cqf.initCqListeners(cqListeners);
CqAttributes cqa = cqf.create();
// Create CQ.
CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa);
assertTrue("newCq() state mismatch", cq1.getState().isStopped());
}
}
use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.
the class ClientCQPostAuthorizationDUnitTest method waitForLastKey.
private void waitForLastKey(final int cqIndex) {
String cqName = "CQ_" + cqIndex;
QueryService qService = getProxyCaches(cqIndex).getQueryService();
ClientCQImpl cqQuery = (ClientCQImpl) qService.getCq(cqName);
((CqQueryTestListener) cqQuery.getCqListeners()[0]).waitForCreated("LAST_KEY");
}
use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.
the class ClientCQPostAuthorizationDUnitTest method waitForLastKeyUpdate.
private void waitForLastKeyUpdate(final int cqIndex) {
String cqName = "CQ_" + cqIndex;
QueryService qService = getProxyCaches(cqIndex).getQueryService();
ClientCQImpl cqQuery = (ClientCQImpl) qService.getCq(cqName);
((CqQueryTestListener) cqQuery.getCqListeners()[0]).waitForUpdated("LAST_KEY");
}
Aggregations