use of org.apache.geode.cache.query.internal.index.CompactRangeIndex in project geode by apache.
the class QueryTraceJUnitTest method testNegTraceOnLocalRegionWithTracePrefix.
/**
* negative testing: if <TRACE> is in comments not tracing is done.
*
* @throws Exception
*/
@Test
public void testNegTraceOnLocalRegionWithTracePrefix() throws Exception {
String slComment = "-- single line comment with TRACE \n";
String mlComment = " /* Multi-line comments here" + "* ends here " + "* with TRACE too" + "*/";
String prefix = slComment + mlComment;
// Create Partition Region
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.LOCAL);
region = CacheUtils.createRegion("portfolio", af.create(), false);
if (region.size() == 0) {
for (int i = 1; i <= 100; i++) {
region.put(Integer.toString(i), new Portfolio(i, i));
}
}
assertEquals(100, region.size());
qs = CacheUtils.getQueryService();
keyIndex1 = (IndexProtocol) qs.createIndex(INDEX_NAME, IndexType.FUNCTIONAL, "ID", "/portfolio ");
assertTrue(keyIndex1 instanceof CompactRangeIndex);
Query query = qs.newQuery(prefix + queryStr);
assertFalse(((DefaultQuery) query).isTraced());
SelectResults results = (SelectResults) query.execute();
assertFalse(QueryObserverHolder.getInstance() instanceof IndexTrackingQueryObserver);
// The query should return all elements in region.
assertEquals(region.size(), results.size());
QueryObserverHolder.reset();
}
use of org.apache.geode.cache.query.internal.index.CompactRangeIndex in project geode by apache.
the class QueryTraceJUnitTest method testTraceOnLocalRegionWithTracePrefixNoComments.
@Test
public void testTraceOnLocalRegionWithTracePrefixNoComments() throws Exception {
String prefix = " <TRACE> ";
// Create Partition Region
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.LOCAL);
region = CacheUtils.createRegion("portfolio", af.create(), false);
if (region.size() == 0) {
for (int i = 1; i <= 100; i++) {
region.put(Integer.toString(i), new Portfolio(i, i));
}
}
assertEquals(100, region.size());
qs = CacheUtils.getQueryService();
keyIndex1 = (IndexProtocol) qs.createIndex(INDEX_NAME, IndexType.FUNCTIONAL, "ID", "/portfolio ");
assertTrue(keyIndex1 instanceof CompactRangeIndex);
Query query = qs.newQuery(prefix + queryStr);
assertTrue(((DefaultQuery) query).isTraced());
SelectResults results = (SelectResults) query.execute();
assertTrue(QueryObserverHolder.getInstance() instanceof IndexTrackingQueryObserver);
// The query should return all elements in region.
assertEquals(region.size(), results.size());
QueryObserverHolder.reset();
}
use of org.apache.geode.cache.query.internal.index.CompactRangeIndex in project geode by apache.
the class QueryTraceJUnitTest method testQueryFailLocalRegionWithSmallTracePrefixNoSpace.
@Test
public void testQueryFailLocalRegionWithSmallTracePrefixNoSpace() throws Exception {
String prefix = "<trace>";
// Create Partition Region
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.LOCAL);
region = CacheUtils.createRegion("portfolio", af.create(), false);
if (region.size() == 0) {
for (int i = 1; i <= 100; i++) {
region.put(Integer.toString(i), new Portfolio(i, i));
}
}
assertEquals(100, region.size());
qs = CacheUtils.getQueryService();
keyIndex1 = (IndexProtocol) qs.createIndex(INDEX_NAME, IndexType.FUNCTIONAL, "ID", "/portfolio ");
assertTrue(keyIndex1 instanceof CompactRangeIndex);
try {
Query query = qs.newQuery(prefix + queryStr);
} catch (Exception e) {
if (!(e instanceof QueryInvalidException)) {
fail("Test Failed: Query is invalid but exception was not thrown!");
}
}
}
Aggregations