use of org.apache.geode.cache.query.internal.QCompiler in project geode by apache.
the class GemfireDataCommandsDUnitTest method doQueryRegionsAssociatedMembers.
private void doQueryRegionsAssociatedMembers(String queryTemplate, int expectedMembers, boolean returnAll, String... regions) {
InternalCache cache = getCache();
String query = queryTemplate;
int i = 1;
for (String r : regions) {
query = query.replace("?" + i, r);
i++;
}
getLogWriter().info("Checking members for query : " + query);
QCompiler compiler = new QCompiler();
Set<String> regionsInQuery = null;
try {
CompiledValue compiledQuery = compiler.compileQuery(query);
Set regionSet = new HashSet();
// GFSH ENV VARIBLES
compiledQuery.getRegionsInQuery(regionSet, null);
regionsInQuery = Collections.unmodifiableSet(regionSet);
getLogWriter().info("Region in query : " + regionsInQuery);
if (regionsInQuery.size() > 0) {
Set<DistributedMember> members = DataCommands.getQueryRegionsAssociatedMembers(regionsInQuery, cache, returnAll);
getLogWriter().info("Members for Region in query : " + members);
if (expectedMembers != -1) {
assertNotNull(members);
assertEquals(expectedMembers, members.size());
} else
assertEquals(0, members.size());
} else {
// Regions do not exist at all
assertEquals(-1, expectedMembers);
}
} catch (QueryInvalidException qe) {
fail("Invalid Query", qe);
}
}
Aggregations