use of org.apache.geode.cache.query.IndexNameConflictException in project geode by apache.
the class PRQueryDUnitHelper method getCacheSerializableRunnableForDuplicatePRIndexCreate.
/**
* This function creates a duplicate index should throw an IndexNameConflictException and if not
* the test should fail.
*/
public CacheSerializableRunnable getCacheSerializableRunnableForDuplicatePRIndexCreate(final String prRegionName, final String indexName, final String indexedExpression, final String fromClause, final String alias) {
SerializableRunnable prIndexCreator = new CacheSerializableRunnable("DuplicatePartitionedIndexCreator") {
@Override
public void run2() {
Cache cache = getCache();
LogWriter logger = cache.getLogger();
QueryService qs = cache.getQueryService();
Region region = cache.getRegion(prRegionName);
try {
if (null != fromClause) {
qs.createIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, fromClause);
throw new RuntimeException("Should throw an exception because " + "the index with name : " + indexName + " should already exists");
} else {
qs.createIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, region.getFullPath() + " " + alias);
throw new RuntimeException("Should throw an exception because " + "the index with name : " + indexName + " should already exists");
}
} catch (IndexExistsException e) {
logger.info("Index Exists Excetpiont righteously throw ", e);
} catch (IndexNameConflictException ex) {
logger.info("Gott the right exception");
} catch (RegionNotFoundException exx) {
// TODO Auto-generated catch block
Assert.fail("Region Not found in this vm ", exx);
}
}
};
return (CacheSerializableRunnable) prIndexCreator;
}
Aggregations