Search in sources :

Example 71 with SelectResults

use of org.apache.geode.cache.query.SelectResults in project geode by apache.

the class CompactRangeIndexJUnitTest method testInvalidTokens.

@Test
public void testInvalidTokens() throws Exception {
    final Region r = utils.getCache().getRegion("/exampleRegion");
    r.put("0", new Portfolio(0));
    r.invalidate("0");
    index = utils.createIndex("compact range index", "p.status", "/exampleRegion p");
    QueryService qs = utils.getCache().getQueryService();
    SelectResults results = (SelectResults) qs.newQuery("Select * from /exampleRegion r where r.status='active'").execute();
    // the remove should have happened
    assertEquals(0, results.size());
    results = (SelectResults) qs.newQuery("Select * from /exampleRegion r where r.status!='inactive'").execute();
    assertEquals(0, results.size());
    CompactRangeIndex cindex = (CompactRangeIndex) index;
    MemoryIndexStore indexStore = (MemoryIndexStore) cindex.getIndexStorage();
    CloseableIterator iterator = indexStore.get(QueryService.UNDEFINED);
    int count = 0;
    while (iterator.hasNext()) {
        count++;
        iterator.next();
    }
    assertEquals("incorrect number of entries in collection", 0, count);
}
Also used : CloseableIterator(org.apache.geode.internal.cache.persistence.query.CloseableIterator) SelectResults(org.apache.geode.cache.query.SelectResults) QueryService(org.apache.geode.cache.query.QueryService) Portfolio(org.apache.geode.cache.query.data.Portfolio) Region(org.apache.geode.cache.Region) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 72 with SelectResults

use of org.apache.geode.cache.query.SelectResults in project geode by apache.

the class PRQueryRegionClosedJUnitTest method testQueryingWithRegionClose.

/**
   * Tests the execution of query on a PartitionedRegion created on a single data store. <br>
   * 1. Creates a PR with redundancy=0 on a single VM. <br>
   * 2. Puts some test Objects in cache.<br>
   * 3. Create a Thread and fire queries on the data and verifies the result.<br>
   * 4. Create another Thread and call Region#close() on the PR region.<br>
   * 
   * 
   * @throws Exception
   */
@Test
public void testQueryingWithRegionClose() throws Exception {
    logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: Test Started  ");
    logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: creating PR Region ");
    final Region region = PartitionedRegionTestHelper.createPartitionedRegion(regionName, localMaxMemory, redundancy);
    final Region localRegion = PartitionedRegionTestHelper.createLocalRegion(localRegionName);
    final StringBuffer errorBuf = new StringBuffer("");
    PortfolioData[] portfolios = new PortfolioData[100];
    try {
        for (int j = 0; j < 100; j++) {
            portfolios[j] = new PortfolioData(j);
        }
        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: populating PortfolioData into the PR Datastore  ");
        populateData(region, portfolios);
        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: populating PortfolioData into the PR Datastore  ");
        populateData(localRegion, portfolios);
        final String[] queryString = { "ID = 0 OR ID = 1", "ID > 4 AND ID < 9", "ID = 5", "ID < 5 ", "ID <= 5" };
        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: Creating a Thread which will fire queries on the datastore");
        Thread t1 = new Thread(new Runnable() {

            public void run() {
                final String expectedRegionDestroyedException = RegionDestroyedException.class.getName();
                logger.info("<ExpectedException action=add>" + expectedRegionDestroyedException + "</ExpectedException>");
                for (int i = 0; i < queryString.length; i++) {
                    try {
                        SelectResults resSetPR = region.query(queryString[i]);
                        SelectResults resSetLocal = localRegion.query(queryString[i]);
                        String failureString = PartitionedRegionTestHelper.compareResultSets(resSetPR, resSetLocal);
                        Thread.sleep(delayQuery);
                        if (failureString != null) {
                            errorBuf.append(failureString);
                            throw (new Exception(failureString));
                        }
                    } catch (InterruptedException ie) {
                        fail("interrupted");
                    } catch (RegionDestroyedException rde) {
                        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: RegionDestroyedException as Expected " + rde);
                    } catch (RegionNotFoundException rnfe) {
                        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: RegionNotFoundException as Expected " + rnfe);
                    } catch (QueryInvocationTargetException qite) {
                        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: QueryInvocationTargetException as Expected " + qite);
                    } catch (Exception qe) {
                        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: Unexpected Exception " + qe);
                        encounteredException = true;
                        StringWriter sw = new StringWriter();
                        qe.printStackTrace(new PrintWriter(sw));
                        errorBuf.append(sw);
                    }
                }
                logger.info("<ExpectedException action=remove>" + expectedRegionDestroyedException + "</ExpectedException>");
            }
        });
        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: Creating a Thread which will call Region.destroyRegion() on the datastore ");
        Thread t2 = new Thread(new Runnable() {

            public void run() {
                try {
                    Thread.sleep(2500);
                } catch (InterruptedException ie) {
                    fail("interrupted");
                }
                region.close();
                logger.info("PROperationWithQueryDUnitTest#getCacheSerializableRunnableForRegionClose: Region Closed on VM ");
            }
        });
        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: Initiating the  Threads");
        t1.start();
        t2.start();
        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: Waiting for the Threads to join ");
        t1.join(30000);
        assertFalse(t1.isAlive());
        t2.join(30000);
        assertFalse(t2.isAlive());
        logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: checking for any Unexpected Exception's occurred");
        assertFalse("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: Exception occurred in Query-thread", encounteredException);
    } catch (Exception e) {
        e.printStackTrace();
        fail("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: Test failed because of exception " + e);
    }
    logger.info("PRQueryRegionClosedJUnitTest#testQueryingWithRegionClose: Test Ended");
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) SelectResults(org.apache.geode.cache.query.SelectResults) StringWriter(java.io.StringWriter) Region(org.apache.geode.cache.Region) PortfolioData(org.apache.geode.cache.query.data.PortfolioData) PrintWriter(java.io.PrintWriter) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 73 with SelectResults

use of org.apache.geode.cache.query.SelectResults in project geode by apache.

the class PRQueryRegionDestroyedJUnitTest method testQueryOnSingleDataStore.

/**
   * Tests the execution of query on a PartitionedRegion created on a single data store. <br>
   * 1. Creates a PR with redundancy=0 on a single VM. <br>
   * 2. Puts some test Objects in cache.<br>
   * 3. Create a Thread and fire queries on the data and verifies the result.<br>
   * 4. Create another Thread and call Region#destroyRegion() on the PR region.<br>
   * 
   * 
   * @throws Exception
   */
@Test
public void testQueryOnSingleDataStore() throws Exception {
    logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: Test Started  ");
    logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: creating PR Region ");
    final Region region = PartitionedRegionTestHelper.createPartitionedRegion(regionName, localMaxMemory, redundancy);
    final Region localRegion = PartitionedRegionTestHelper.createLocalRegion(localRegionName);
    final StringBuffer errorBuf = new StringBuffer("");
    PortfolioData[] portfolios = new PortfolioData[dataSize];
    try {
        for (int j = 0; j < dataSize; j++) {
            portfolios[j] = new PortfolioData(j);
        }
        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: populating PortfolioData into the PR Datastore  ");
        populateData(region, portfolios);
        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: populating PortfolioData into the PR Datastore  ");
        populateData(localRegion, portfolios);
        final String[] queryString = { "ID = 0 OR ID = 1", "ID > 4 AND ID < 9", "ID = 5", "ID < 5 ", "ID <= 5" };
        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: Creating a Thread which will fire queries on the datastore");
        Thread t1 = new Thread(new Runnable() {

            public void run() {
                final String expectedRegionDestroyedException = RegionDestroyedException.class.getName();
                logger.info("<ExpectedException action=add>" + expectedRegionDestroyedException + "</ExpectedException>");
                for (int i = 0; i < queryString.length; i++) {
                    try {
                        SelectResults resSetPR = region.query(queryString[i]);
                        SelectResults resSetLocal = localRegion.query(queryString[i]);
                        String failureString = PartitionedRegionTestHelper.compareResultSets(resSetPR, resSetLocal);
                        Thread.sleep(delayQuery);
                        if (failureString != null) {
                            errorBuf.append(failureString);
                            throw (new Exception(failureString));
                        }
                    } catch (InterruptedException ie) {
                        fail("interrupted");
                    } catch (QueryInvocationTargetException qite) {
                        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: QueryInvocationTargetException as Expected " + qite);
                    } catch (RegionDestroyedException rde) {
                        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: RegionDestroyedException as Expected " + rde);
                    } catch (RegionNotFoundException rnfe) {
                        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: RegionNotFoundException as Expected " + rnfe);
                    } catch (Exception qe) {
                        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: Unexpected Exception " + qe);
                        encounteredException = true;
                        StringWriter sw = new StringWriter();
                        qe.printStackTrace(new PrintWriter(sw));
                        errorBuf.append(sw);
                    }
                }
                logger.info("<ExpectedException action=remove>" + expectedRegionDestroyedException + "</ExpectedException>");
            }
        });
        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: Creating a Thread which will call Region.destroyRegion() on the datastore ");
        Thread t2 = new Thread(new Runnable() {

            public void run() {
                try {
                    Thread.sleep(2500);
                } catch (InterruptedException ie) {
                    logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore:Thread Interrupted Exceptionduring region Destroy ");
                    fail("interrupted");
                }
                region.destroyRegion();
            }
        });
        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: Initiating the  Threads");
        t1.start();
        t2.start();
        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: Waiting for the Threads to join ");
        ThreadUtils.join(t1, 30 * 1000);
        ThreadUtils.join(t2, 30 * 1000);
        logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: checking for any Unexpected Exception's occurred");
        assertFalse("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: Exception occurred in Query-thread", encounteredException);
    } catch (Exception e) {
        e.printStackTrace();
        fail("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: Test failed because of exception " + e);
    }
    logger.info("PRQueryRegionDestroyedJUnitTest#testQueryOnSingleDataStore: Test Ended");
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) SelectResults(org.apache.geode.cache.query.SelectResults) StringWriter(java.io.StringWriter) Region(org.apache.geode.cache.Region) PortfolioData(org.apache.geode.cache.query.data.PortfolioData) PrintWriter(java.io.PrintWriter) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 74 with SelectResults

use of org.apache.geode.cache.query.SelectResults in project geode by apache.

the class PRQueryDUnitHelper method getCacheSerializableRunnableForPROrderByQueryWithLimit.

public CacheSerializableRunnable getCacheSerializableRunnableForPROrderByQueryWithLimit(final String regionName, final String localRegion) {
    SerializableRunnable PrRegion = new CacheSerializableRunnable("PRQuery") {

        public void run2() throws CacheException {
            Cache cache = getCache();
            // Querying the localRegion and the PR region
            String[] queries = new String[] { "status as st from /REGION_NAME order by status", "p.status from /REGION_NAME p order by p.status", "p.position1.secId, p.ID from /REGION_NAME p order by p.position1.secId, p.ID desc", "key from /REGION_NAME.keys key order by key.status, key.ID", "key.ID from /REGION_NAME.keys key order by key.ID", "key.ID, key.status from /REGION_NAME.keys key order by key.status, key.ID asc", "key.ID, key.status from /REGION_NAME.keys key order by key.status desc, key.ID", "p.status, p.ID from /REGION_NAME p order by p.status asc, p.ID", "p.ID from /REGION_NAME p, p.positions.values order by p.ID", "* from /REGION_NAME p, p.positions.values val order by p.ID, val.secId", "p.iD, p.status from /REGION_NAME p order by p.iD", "iD, status from /REGION_NAME order by iD", "* from /REGION_NAME p order by p.getID()", "* from /REGION_NAME p order by p.getP1().secId, p.ID desc, p.ID", " p.position1.secId , p.ID as st from /REGION_NAME p order by p.position1.secId, p.ID", "e.key.ID, e.value.status from /REGION_NAME.entrySet e order by e.key.ID, e.value.status desc", "e.key from /REGION_NAME.entrySet e order by e.key.ID, e.key.pkid desc", "p, pos from /REGION_NAME p, p.positions.values pos order by p.ID, pos.secId desc", "p, pos from /REGION_NAME p, p.positions.values pos order by pos.secId, p.ID", "status , ID as ied from /REGION_NAME where ID > 0 order by status, ID desc", "p.status as st, p.ID as id from /REGION_NAME p where ID > 0 and status = 'inactive' order by p.status, p.ID desc", "p.position1.secId as st, p.ID as ied from /REGION_NAME p where p.ID > 0 and p.position1.secId != 'IBM' order by p.position1.secId, p.ID", " key.status as st, key.ID from /REGION_NAME.keys key where key.ID > 5 order by key.status, key.ID desc", " key.ID, key.status as st from /REGION_NAME.keys key where key.status = 'inactive' order by key.status desc, key.ID" };
            Object[][] r = new Object[queries.length][2];
            Region local = cache.getRegion(localRegion);
            Region region = cache.getRegion(regionName);
            assertNotNull(region);
            final String[] expectedExceptions = new String[] { RegionDestroyedException.class.getName(), ReplyException.class.getName(), CacheClosedException.class.getName(), ForceReattemptException.class.getName(), QueryInvocationTargetException.class.getName() };
            for (final String expectedException : expectedExceptions) {
                getCache().getLogger().info("<ExpectedException action=add>" + expectedException + "</ExpectedException>");
            }
            String distinct = "<TRACE>SELECT DISTINCT ";
            QueryService qs = getCache().getQueryService();
            Object[] params;
            try {
                for (int l = 1; l <= 3; l++) {
                    String[] rq = new String[queries.length];
                    for (int j = 0; j < queries.length; j++) {
                        String qStr = null;
                        synchronized (region) {
                            // Execute on local region.
                            qStr = (distinct + queries[j].replace("REGION_NAME", localRegion));
                            qStr += (" LIMIT " + (l * l));
                            rq[j] = qStr;
                            SelectResults sr = (SelectResults) qs.newQuery(qStr).execute();
                            r[j][0] = sr;
                            if (sr.asList().size() > l * l) {
                                fail("The resultset size exceeds limit size. Limit size=" + l * l + ", result size =" + sr.asList().size());
                            }
                            // Execute on remote region.
                            qStr = (distinct + queries[j].replace("REGION_NAME", regionName));
                            qStr += (" LIMIT " + (l * l));
                            rq[j] = qStr;
                            SelectResults srr = (SelectResults) qs.newQuery(qStr).execute();
                            r[j][1] = srr;
                            if (srr.size() > l * l) {
                                fail("The resultset size exceeds limit size. Limit size=" + l * l + ", result size =" + srr.asList().size());
                            }
                        // assertIndexDetailsEquals("The resultset size is not same as limit size.", l*l,
                        // srr.asList().size());
                        // getCache().getLogger().info("Finished executing PR query: " + qStr);
                        }
                    }
                    StructSetOrResultsSet ssORrs = new StructSetOrResultsSet();
                    ssORrs.CompareQueryResultsWithoutAndWithIndexes(r, queries.length, true, rq);
                }
                org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Queries Executed successfully on Local region & PR Region");
            } catch (QueryInvocationTargetException e) {
                // not it's okay
                throw new TestException("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught unexpected query exception", e);
            } catch (QueryException e) {
                org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().error("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught QueryException while querying" + e, e);
                throw new TestException("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught unexpected query exception", e);
            } catch (RegionDestroyedException rde) {
                org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught a RegionDestroyedException while querying as expected ", rde);
            } catch (CancelException cce) {
                org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught a CancelException while querying as expected ", cce);
            } finally {
                for (final String expectedException : expectedExceptions) {
                    getCache().getLogger().info("<ExpectedException action=remove>" + expectedException + "</ExpectedException>");
                }
            }
        }
    };
    return (CacheSerializableRunnable) PrRegion;
}
Also used : StructSetOrResultsSet(org.apache.geode.cache.query.functional.StructSetOrResultsSet) TestException(util.TestException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) QueryException(org.apache.geode.cache.query.QueryException) SelectResults(org.apache.geode.cache.query.SelectResults) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) QueryService(org.apache.geode.cache.query.QueryService) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) CancelException(org.apache.geode.CancelException) Cache(org.apache.geode.cache.Cache)

Example 75 with SelectResults

use of org.apache.geode.cache.query.SelectResults in project geode by apache.

the class PRQueryDUnitHelper method getCacheSerializableRunnableForPRAndRRQueryWithCompactAndRangeIndexAndCompareResults.

public SerializableRunnableIF getCacheSerializableRunnableForPRAndRRQueryWithCompactAndRangeIndexAndCompareResults(final String name, final String coloName, final String localName, final String coloLocalName) {
    SerializableRunnable PrRegion = new CacheSerializableRunnable("PRQuery") {

        @Override
        public void run2() throws CacheException {
            Cache cache = getCache();
            // Querying the PR region
            String[] queries = new String[] { "r1.ID = pos2.id", "r1.ID = pos2.id AND r1.ID > 5", "r1.ID = pos2.id AND r1.status = 'active'", "r1.ID = pos2.id ORDER BY r1.ID", "r1.ID = pos2.id ORDER BY pos2.id", "r1.ID = pos2.id ORDER BY r2.status", "r1.ID = pos2.id AND r1.status != r2.status", "r1.ID = pos2.id AND r1.status = r2.status", "r1.ID = pos2.id AND r1.positions.size = r2.positions.size", "r1.ID = pos2.id AND r1.positions.size > r2.positions.size", "r1.ID = pos2.id AND r1.positions.size < r2.positions.size", "r1.ID = pos2.id AND r1.positions.size = r2.positions.size AND r2.positions.size > 0", "r1.ID = pos2.id AND (r1.positions.size > r2.positions.size OR r2.positions.size > 0)", "r1.ID = pos2.id AND (r1.positions.size < r2.positions.size OR r1.positions.size > 0)" };
            Object[][] r = new Object[queries.length][2];
            Region region = null;
            region = cache.getRegion(name);
            assertNotNull(region);
            region = cache.getRegion(coloName);
            assertNotNull(region);
            region = cache.getRegion(localName);
            assertNotNull(region);
            region = cache.getRegion(coloLocalName);
            assertNotNull(region);
            final String[] expectedExceptions = new String[] { RegionDestroyedException.class.getName(), ReplyException.class.getName(), CacheClosedException.class.getName(), ForceReattemptException.class.getName(), QueryInvocationTargetException.class.getName() };
            for (final String expectedException : expectedExceptions) {
                getCache().getLogger().info("<ExpectedException action=add>" + expectedException + "</ExpectedException>");
            }
            QueryService qs = getCache().getQueryService();
            try {
                for (int j = 0; j < queries.length; j++) {
                    getCache().getLogger().info("About to execute local query: " + queries[j]);
                    Function func = new TestQueryFunction("testfunction");
                    Object funcResult = FunctionService.onRegion((getCache().getRegion(name) instanceof PartitionedRegion) ? getCache().getRegion(name) : getCache().getRegion(coloName)).setArguments("<trace> Select " + (queries[j].contains("ORDER BY") ? "DISTINCT" : "") + " * from /" + name + " r1, /" + coloName + " r2, r2.positions.values pos2 where " + queries[j]).execute(func).getResult();
                    r[j][0] = ((ArrayList) funcResult).get(0);
                    getCache().getLogger().info("About to execute local query: " + queries[j]);
                    SelectResults r2 = (SelectResults) qs.newQuery("Select " + (queries[j].contains("ORDER BY") ? "DISTINCT" : "") + " * from /" + localName + " r1, /" + coloLocalName + " r2, r2.positions.values pos2 where " + queries[j]).execute();
                    r[j][1] = r2.asList();
                }
                org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Queries Executed successfully on Local region & PR Region");
                StructSetOrResultsSet ssORrs = new StructSetOrResultsSet();
                ssORrs.CompareQueryResultsAsListWithoutAndWithIndexes(r, queries.length, false, false, queries);
            } catch (QueryInvocationTargetException e) {
                // cause and see whether or not it's okay
                throw new TestException("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught unexpected query exception", e);
            } catch (QueryException e) {
                org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().error("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught QueryException while querying" + e, e);
                throw new TestException("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught unexpected query exception", e);
            } catch (RegionDestroyedException rde) {
                org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught a RegionDestroyedException while querying as expected ", rde);
            } catch (CancelException cce) {
                org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("PRQueryDUnitHelper#getCacheSerializableRunnableForPRQueryAndCompareResults: Caught a CancelException while querying as expected ", cce);
            } finally {
                for (final String expectedException : expectedExceptions) {
                    getCache().getLogger().info("<ExpectedException action=remove>" + expectedException + "</ExpectedException>");
                }
            }
        }
    };
    return (CacheSerializableRunnable) PrRegion;
}
Also used : StructSetOrResultsSet(org.apache.geode.cache.query.functional.StructSetOrResultsSet) TestException(util.TestException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) Function(org.apache.geode.cache.execute.Function) QueryException(org.apache.geode.cache.query.QueryException) SelectResults(org.apache.geode.cache.query.SelectResults) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) QueryService(org.apache.geode.cache.query.QueryService) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) CancelException(org.apache.geode.CancelException) Cache(org.apache.geode.cache.Cache)

Aggregations

SelectResults (org.apache.geode.cache.query.SelectResults)577 Test (org.junit.Test)423 Query (org.apache.geode.cache.query.Query)360 Region (org.apache.geode.cache.Region)336 QueryService (org.apache.geode.cache.query.QueryService)331 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)256 Portfolio (org.apache.geode.cache.query.data.Portfolio)249 Index (org.apache.geode.cache.query.Index)133 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)112 Host (org.apache.geode.test.dunit.Host)107 VM (org.apache.geode.test.dunit.VM)107 CacheException (org.apache.geode.cache.CacheException)105 Iterator (java.util.Iterator)104 AttributesFactory (org.apache.geode.cache.AttributesFactory)101 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)92 DefaultQuery (org.apache.geode.cache.query.internal.DefaultQuery)89 Cache (org.apache.geode.cache.Cache)84 Struct (org.apache.geode.cache.query.Struct)80 LocalRegion (org.apache.geode.internal.cache.LocalRegion)67 ObjectType (org.apache.geode.cache.query.types.ObjectType)66