Search in sources :

Example 41 with PortfolioPdx

use of org.apache.geode.cache.query.data.PortfolioPdx in project geode by apache.

the class PdxGroupByTestImpl method testCompactRangeIndex.

@Override
@Test
public void testCompactRangeIndex() throws Exception {
    Region region = this.createRegion("portfolio", PortfolioPdx.class);
    for (int i = 1; i < 200; ++i) {
        PortfolioPdx pf = new PortfolioPdx(i);
        pf.shortID = (short) ((short) i / 5);
        region.put("key-" + i, pf);
    }
    QueryService qs = CacheUtils.getQueryService();
    String[] queries = { // 6
    "select pos.secId from  /portfolio  p, p.positions.values pos where NOT (pos.secId IN SET('SUN', 'ORCL')) group by pos.secId  ", // 7
    "select pos.secId , count(pos.ID) from /portfolio p, p.positions.values pos where  pos.secId > 'APPL' group by pos.secId " };
    Object[][] r = new Object[queries.length][2];
    // Execute Queries without Indexes
    for (int i = 0; i < queries.length; i++) {
        Query q = null;
        try {
            q = CacheUtils.getQueryService().newQuery(queries[i]);
            CacheUtils.getLogger().info("Executing query: " + queries[i]);
            SelectResults sr = (SelectResults) q.execute();
            r[i][0] = sr;
            assertTrue(sr.size() > 0);
        } catch (Exception e) {
            e.printStackTrace();
            fail(q.getQueryString());
        }
    }
    // Create Indexes
    qs.createIndex("statusIndex", "status", "/portfolio");
    // Execute Queries with Indexes
    for (int i = 0; i < queries.length; i++) {
        Query q = null;
        try {
            q = CacheUtils.getQueryService().newQuery(queries[i]);
            CacheUtils.getLogger().info("Executing query: " + queries[i]);
            r[i][1] = q.execute();
            SelectResults rcw = (SelectResults) r[i][1];
            int indexLimit = queries[i].indexOf("limit");
            int limit = -1;
            boolean limitQuery = indexLimit != -1;
            if (limitQuery) {
                limit = Integer.parseInt(queries[i].substring(indexLimit + 5).trim());
            }
            assertTrue("Result size is " + rcw.size() + " and limit is " + limit, !limitQuery || rcw.size() <= limit);
            String colType = rcw.getCollectionType().getSimpleClassName();
        } catch (Exception e) {
            e.printStackTrace();
            fail(q.getQueryString());
        }
    }
    StructSetOrResultsSet ssOrrs = new StructSetOrResultsSet();
    ssOrrs.CompareQueryResultsWithoutAndWithIndexes(r, queries.length, true, queries);
}
Also used : DefaultQuery(org.apache.geode.cache.query.internal.DefaultQuery) Query(org.apache.geode.cache.query.Query) PortfolioPdx(org.apache.geode.cache.query.data.PortfolioPdx) SelectResults(org.apache.geode.cache.query.SelectResults) QueryService(org.apache.geode.cache.query.QueryService) Region(org.apache.geode.cache.Region) Test(org.junit.Test)

Example 42 with PortfolioPdx

use of org.apache.geode.cache.query.data.PortfolioPdx in project geode by apache.

the class PdxGroupByTestImpl method testConvertibleGroupByQuery_1.

@Override
@Test
public void testConvertibleGroupByQuery_1() throws Exception {
    Region region = this.createRegion("portfolio", PortfolioPdx.class);
    for (int i = 1; i < 200; ++i) {
        PortfolioPdx pf = new PortfolioPdx(i);
        pf.shortID = (short) ((short) i / 5);
        region.put("key-" + i, pf);
    }
    String queryStr = "select  p.status as status, p.ID from /portfolio p where p.ID > 0 group by status, p.ID ";
    QueryService qs = CacheUtils.getQueryService();
    Query query = qs.newQuery(queryStr);
    CompiledSelect cs = ((DefaultQuery) query).getSelect();
    assertTrue(cs.isDistinct());
    assertTrue(cs.isOrderBy());
    assertFalse(cs.isGroupBy());
}
Also used : DefaultQuery(org.apache.geode.cache.query.internal.DefaultQuery) DefaultQuery(org.apache.geode.cache.query.internal.DefaultQuery) Query(org.apache.geode.cache.query.Query) QueryService(org.apache.geode.cache.query.QueryService) CompiledSelect(org.apache.geode.cache.query.internal.CompiledSelect) Region(org.apache.geode.cache.Region) PortfolioPdx(org.apache.geode.cache.query.data.PortfolioPdx) Test(org.junit.Test)

Example 43 with PortfolioPdx

use of org.apache.geode.cache.query.data.PortfolioPdx in project geode by apache.

the class SelectStarQueryDUnitTest method testSelectStarQueryForPdxAndNonPdxObjects.

@Test
public void testSelectStarQueryForPdxAndNonPdxObjects() throws Exception {
    final Host host = Host.getHost(0);
    final VM server1 = host.getVM(0);
    final VM client = host.getVM(3);
    // create servers and regions
    // put domain objects
    final int port1 = startReplicatedCacheServer(server1);
    server1.invoke(new SerializableCallable("Set observer") {

        @Override
        public Object call() throws Exception {
            oldObserver = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
            return null;
        }
    });
    // create client
    client.invoke(new SerializableCallable("Create client") {

        @Override
        public Object call() throws Exception {
            ClientCacheFactory cf = new ClientCacheFactory();
            cf.addPoolServer(getServerHostName(server1.getHost()), port1);
            ClientCache cache = getClientCache(cf);
            cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(regName);
            return null;
        }
    });
    // Add some serialized PortfolioPdx objects
    client.invoke(new SerializableCallable("Put objects") {

        @Override
        public Object call() throws Exception {
            Region r1 = getRootRegion(regName);
            for (int i = 10; i < 20; i++) {
                r1.put("key-" + i, new PortfolioPdx(i));
            }
            return null;
        }
    });
    // query remotely from client
    client.invoke(new SerializableCallable("Query") {

        @Override
        public Object call() throws Exception {
            getLogWriter().info("Querying remotely from client");
            QueryService localQS = null;
            QueryService remoteQS = null;
            try {
                localQS = ((ClientCache) getCache()).getLocalQueryService();
                remoteQS = ((ClientCache) getCache()).getQueryService();
            } catch (Exception e) {
                fail("Exception getting query service ", e);
            }
            SelectResults res = null;
            SelectResults[][] sr = new SelectResults[1][2];
            for (int i = 0; i < queries.length; i++) {
                try {
                    res = (SelectResults) localQS.newQuery(queries[i]).execute();
                    sr[0][0] = res;
                    res = (SelectResults) remoteQS.newQuery(queries[i]).execute();
                    sr[0][1] = res;
                    CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
                } catch (Exception e) {
                    fail("Error executing query: " + queries[i], e);
                }
                assertEquals(resultSize[i], res.size());
                if (i == 3) {
                    int cnt = ((Integer) res.iterator().next());
                    assertEquals(20, cnt);
                } else {
                    for (Object rs : res) {
                        if (rs instanceof StructImpl) {
                            for (Object obj : ((StructImpl) rs).getFieldValues()) {
                                if (obj instanceof PortfolioPdx || obj instanceof PositionPdx) {
                                } else if (obj instanceof PortfolioPdx || obj instanceof PositionPdx) {
                                } else {
                                    fail("Result objects for remote client query: " + queries[i] + " should be instance of PortfolioPdx or PortfolioPdx and not " + obj.getClass());
                                }
                            }
                        } else if (rs instanceof PortfolioPdx) {
                        } else {
                            fail("Result objects for remote client query: " + queries[i] + " should be instance of PortfolioPdx and not " + rs.getClass());
                        }
                    }
                }
            }
            return null;
        }
    });
    // verify if objects iterated by query are serialized
    server1.invoke(new SerializableCallable("Get observer") {

        @Override
        public Object call() throws Exception {
            QueryObserver observer = QueryObserverHolder.getInstance();
            assertTrue(QueryObserverHolder.hasObserver());
            assertTrue(observer instanceof QueryResultTrackingObserver);
            QueryResultTrackingObserver resultObserver = (QueryResultTrackingObserver) observer;
            assertTrue(resultObserver.isObjectSerialized());
            return null;
        }
    });
    // verify if objects returned by local server query are not serialized
    server1.invoke(new SerializableCallable("Query") {

        @Override
        public Object call() throws Exception {
            QueryObserver observer = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
            QueryService qs = null;
            try {
                qs = getCache().getQueryService();
            } catch (Exception e) {
                fail("Exception getting query service ", e);
            }
            SelectResults res = null;
            for (int i = 0; i < queries.length; i++) {
                try {
                    res = (SelectResults) qs.newQuery(queries[i]).execute();
                } catch (Exception e) {
                    fail("Error executing query: " + queries[i], e);
                }
                assertEquals(resultSize[i], res.size());
                if (i == 3) {
                    int cnt = ((Integer) res.iterator().next());
                    assertEquals(20, cnt);
                } else {
                    for (Object rs : res) {
                        if (rs instanceof StructImpl) {
                            for (Object obj : ((StructImpl) rs).getFieldValues()) {
                                if (obj instanceof PortfolioPdx || obj instanceof PositionPdx) {
                                } else if (obj instanceof PortfolioPdx || obj instanceof PositionPdx) {
                                } else {
                                    fail("Result objects for remote client query: " + queries[i] + " should be instance of PortfolioPdx or PortfolioPdx and not " + obj.getClass());
                                }
                            }
                        } else if (rs instanceof PortfolioPdx) {
                        } else {
                            fail("Result objects for remote client query: " + queries[i] + " should be instance of PortfolioPdx and not " + rs.getClass());
                        }
                    }
                }
            }
            observer = QueryObserverHolder.getInstance();
            assertTrue(QueryObserverHolder.hasObserver());
            assertTrue(observer instanceof QueryResultTrackingObserver);
            QueryResultTrackingObserver resultObserver = (QueryResultTrackingObserver) observer;
            assertFalse(resultObserver.isObjectSerialized());
            QueryObserverHolder.setInstance(oldObserver);
            return null;
        }
    });
    server1.invoke(new SerializableCallable("Query") {

        @Override
        public Object call() throws Exception {
            GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
            cache.setReadSerialized(true);
            QueryService qs = null;
            try {
                qs = getCache().getQueryService();
            } catch (Exception e) {
                fail("Exception getting query service ", e);
            }
            SelectResults res = null;
            for (int i = 0; i < queries.length; i++) {
                try {
                    res = (SelectResults) qs.newQuery(queries[i]).execute();
                } catch (Exception e) {
                    fail("Error executing query: " + queries[i], e);
                }
                assertEquals(resultSize[i], res.size());
                if (i == 3) {
                    int cnt = ((Integer) res.iterator().next());
                    assertEquals(20, cnt);
                } else {
                    for (Object rs : res) {
                        if (rs instanceof StructImpl) {
                            for (Object obj : ((StructImpl) rs).getFieldValues()) {
                                if (obj instanceof PortfolioPdx || obj instanceof PositionPdx) {
                                } else if (obj instanceof PdxInstance) {
                                } else {
                                    fail("Result objects for remote client query: " + queries[i] + " should be instance of PdxInstance and not " + obj.getClass());
                                }
                            }
                        } else if (rs instanceof PdxInstance || rs instanceof PortfolioPdx) {
                        } else {
                            fail("Result objects for remote client query: " + queries[i] + " should be instance of PdxInstance and not " + rs.getClass());
                        }
                    }
                }
            }
            return null;
        }
    });
    closeCache(client);
    closeCache(server1);
}
Also used : PositionPdx(org.apache.geode.cache.query.data.PositionPdx) Host(org.apache.geode.test.dunit.Host) PortfolioPdx(org.apache.geode.cache.query.data.PortfolioPdx) ClientCache(org.apache.geode.cache.client.ClientCache) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) QueryObserver(org.apache.geode.cache.query.internal.QueryObserver) SelectResults(org.apache.geode.cache.query.SelectResults) StructImpl(org.apache.geode.cache.query.internal.StructImpl) PdxInstance(org.apache.geode.pdx.PdxInstance) QueryService(org.apache.geode.cache.query.QueryService) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Region(org.apache.geode.cache.Region) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 44 with PortfolioPdx

use of org.apache.geode.cache.query.data.PortfolioPdx in project geode by apache.

the class SelectStarQueryDUnitTest method testSelectStarQueryForPartitionedRegion.

@Test
public void testSelectStarQueryForPartitionedRegion() throws Exception {
    final Host host = Host.getHost(0);
    final VM server1 = host.getVM(0);
    final VM server2 = host.getVM(1);
    final VM server3 = host.getVM(2);
    final VM client = host.getVM(3);
    PortfolioPdx[] portfolios = new PortfolioPdx[10];
    for (int i = 0; i < portfolios.length; i++) {
        portfolios[i] = new PortfolioPdx(i);
    }
    // create servers and regions
    final int port1 = startPartitionedCacheServer(server1, portfolios);
    final int port2 = startPartitionedCacheServer(server2, portfolios);
    final int port3 = startPartitionedCacheServer(server3, portfolios);
    server1.invoke(new SerializableCallable("Set observer") {

        @Override
        public Object call() throws Exception {
            oldObserver = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
            return null;
        }
    });
    // create client
    client.invoke(new SerializableCallable("Create client") {

        @Override
        public Object call() throws Exception {
            ClientCacheFactory cf = new ClientCacheFactory();
            cf.addPoolServer(getServerHostName(server1.getHost()), port1);
            cf.addPoolServer(getServerHostName(server2.getHost()), port2);
            cf.addPoolServer(getServerHostName(server3.getHost()), port3);
            ClientCache cache = getClientCache(cf);
            cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(regName);
            return null;
        }
    });
    // put serialized PortfolioPdx objects
    client.invoke(new SerializableCallable("Put objects") {

        @Override
        public Object call() throws Exception {
            Region r1 = getRootRegion(regName);
            for (int i = 10; i < 20; i++) {
                r1.put("key-" + i, new PortfolioPdx(i));
            }
            return null;
        }
    });
    // query remotely from client
    client.invoke(new SerializableCallable("Query") {

        @Override
        public Object call() throws Exception {
            getLogWriter().info("Querying remotely from client");
            QueryService localQS = null;
            QueryService remoteQS = null;
            try {
                localQS = ((ClientCache) getCache()).getLocalQueryService();
                remoteQS = ((ClientCache) getCache()).getQueryService();
            } catch (Exception e) {
                fail("Exception getting query service ", e);
            }
            SelectResults[][] sr = new SelectResults[1][2];
            SelectResults res = null;
            for (int i = 0; i < queries.length; i++) {
                try {
                    res = (SelectResults) localQS.newQuery(queries[i]).execute();
                    sr[0][0] = res;
                    res = (SelectResults) remoteQS.newQuery(queries[i]).execute();
                    sr[0][1] = res;
                    CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
                } catch (Exception e) {
                    fail("Error executing query: " + queries[i], e);
                }
                assertEquals(resultSize[i], res.size());
                if (i == 3) {
                    int cnt = ((Integer) res.iterator().next());
                    assertEquals(20, cnt);
                } else {
                    for (Object rs : res) {
                        if (rs instanceof StructImpl) {
                            for (Object obj : ((StructImpl) rs).getFieldValues()) {
                                if (obj instanceof PortfolioPdx || obj instanceof PositionPdx) {
                                } else {
                                    fail("Result objects for remote client query: " + queries[i] + " should be instance of PortfolioPdx and not " + obj.getClass());
                                }
                            }
                        } else if (rs instanceof PortfolioPdx) {
                        } else {
                            fail("Result objects for remote client query: " + queries[i] + " should be instance of PortfolioPdx and not " + rs.getClass());
                        }
                    }
                }
            }
            return null;
        }
    });
    // verify if objects iterated by query are serialized
    server1.invoke(new SerializableCallable("Get observer") {

        @Override
        public Object call() throws Exception {
            QueryObserver observer = QueryObserverHolder.getInstance();
            assertTrue(QueryObserverHolder.hasObserver());
            assertTrue(observer instanceof QueryResultTrackingObserver);
            QueryResultTrackingObserver resultObserver = (QueryResultTrackingObserver) observer;
            assertTrue(resultObserver.isObjectSerialized());
            return null;
        }
    });
    // verify if objects returned by local server query are not serialized
    server1.invoke(new SerializableCallable("Query") {

        @Override
        public Object call() throws Exception {
            QueryObserver observer = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
            QueryService qs = null;
            try {
                qs = getCache().getQueryService();
            } catch (Exception e) {
                fail("Exception getting query service ", e);
            }
            SelectResults res = null;
            for (int i = 0; i < queries.length; i++) {
                try {
                    res = (SelectResults) qs.newQuery(queries[i]).execute();
                } catch (Exception e) {
                    fail("Error executing query: " + queries[i], e);
                }
                assertEquals(resultSize[i], res.size());
                if (i == 3) {
                    int cnt = ((Integer) res.iterator().next());
                    assertEquals(20, cnt);
                } else {
                    for (Object rs : res) {
                        if (rs instanceof StructImpl) {
                            for (Object obj : ((StructImpl) rs).getFieldValues()) {
                                if (obj instanceof PortfolioPdx || obj instanceof PositionPdx) {
                                } else {
                                    fail("Result objects for remote client query: " + queries[i] + " should be instance of PortfolioPdx and not " + obj.getClass());
                                }
                            }
                        } else if (rs instanceof PortfolioPdx) {
                        } else {
                            fail("Result objects for remote client query: " + queries[i] + " should be instance of PortfolioPdx and not " + rs.getClass());
                        }
                    }
                }
            }
            observer = QueryObserverHolder.getInstance();
            assertTrue(QueryObserverHolder.hasObserver());
            assertTrue(observer instanceof QueryResultTrackingObserver);
            QueryResultTrackingObserver resultObserver = (QueryResultTrackingObserver) observer;
            assertFalse(resultObserver.isObjectSerialized());
            // reset observer
            QueryObserverHolder.setInstance(oldObserver);
            return null;
        }
    });
    closeCache(client);
    closeCache(server1);
    closeCache(server2);
    closeCache(server3);
}
Also used : PositionPdx(org.apache.geode.cache.query.data.PositionPdx) Host(org.apache.geode.test.dunit.Host) PortfolioPdx(org.apache.geode.cache.query.data.PortfolioPdx) ClientCache(org.apache.geode.cache.client.ClientCache) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) QueryObserver(org.apache.geode.cache.query.internal.QueryObserver) SelectResults(org.apache.geode.cache.query.SelectResults) StructImpl(org.apache.geode.cache.query.internal.StructImpl) QueryService(org.apache.geode.cache.query.QueryService) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Region(org.apache.geode.cache.Region) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 45 with PortfolioPdx

use of org.apache.geode.cache.query.data.PortfolioPdx in project geode by apache.

the class SelectStarQueryDUnitTest method testSelectStarQueryForReplicatedRegion.

@Test
public void testSelectStarQueryForReplicatedRegion() throws Exception {
    final Host host = Host.getHost(0);
    final VM server1 = host.getVM(1);
    final VM client = host.getVM(3);
    // create servers and regions
    final int port1 = startReplicatedCacheServer(server1);
    server1.invoke(new SerializableCallable("Set observer") {

        @Override
        public Object call() throws Exception {
            oldObserver = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
            return null;
        }
    });
    // create client
    client.invoke(new SerializableCallable("Create client") {

        @Override
        public Object call() throws Exception {
            ClientCacheFactory cf = new ClientCacheFactory();
            cf.addPoolServer(getServerHostName(server1.getHost()), port1);
            ClientCache cache = getClientCache(cf);
            cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(regName);
            cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(regName2);
            return null;
        }
    });
    // put serialized PortfolioPdx objects
    client.invoke(new SerializableCallable("Put objects") {

        @Override
        public Object call() throws Exception {
            Region r1 = getRootRegion(regName);
            Region r2 = getRootRegion(regName2);
            for (int i = 10; i < 20; i++) {
                r1.put("key-" + i, new PortfolioPdx(i));
                r2.put("key-" + i, new PortfolioPdx(i));
            }
            return null;
        }
    });
    // query remotely from client
    client.invoke(new SerializableCallable("Query") {

        @Override
        public Object call() throws Exception {
            getLogWriter().info("Querying remotely from client");
            QueryService localQS = null;
            QueryService remoteQS = null;
            try {
                localQS = ((ClientCache) getCache()).getLocalQueryService();
                remoteQS = ((ClientCache) getCache()).getQueryService();
            } catch (Exception e) {
                fail("Exception getting query service ", e);
            }
            SelectResults res = null;
            SelectResults[][] sr = new SelectResults[1][2];
            for (int i = 0; i < multipleRegionQueries.length; i++) {
                try {
                    res = (SelectResults) localQS.newQuery(multipleRegionQueries[i]).execute();
                    sr[0][0] = res;
                    res = (SelectResults) remoteQS.newQuery(multipleRegionQueries[i]).execute();
                    sr[0][1] = res;
                    CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
                } catch (Exception e) {
                    fail("Error executing query: " + multipleRegionQueries[i], e);
                }
                assertEquals(resultSize2[i], res.size());
                if (i == 4) {
                    int cnt = ((Integer) res.iterator().next());
                    assertEquals(400, cnt);
                } else {
                    for (Object rs : res) {
                        if (rs instanceof StructImpl) {
                            for (Object obj : ((StructImpl) rs).getFieldValues()) {
                                if (obj instanceof PortfolioPdx || obj instanceof PositionPdx) {
                                } else {
                                    fail("Result objects for remote client query: " + multipleRegionQueries[i] + " should be instance of PortfolioPdx and not " + obj.getClass());
                                }
                            }
                        } else if (rs instanceof PortfolioPdx) {
                        } else {
                            fail("Result objects for remote client query: " + multipleRegionQueries[i] + " should be instance of PortfolioPdx and not " + rs.getClass());
                        }
                    }
                }
            }
            return null;
        }
    });
    // verify if objects iterated by query are serialized
    server1.invoke(new SerializableCallable("Get observer") {

        @Override
        public Object call() throws Exception {
            QueryObserver observer = QueryObserverHolder.getInstance();
            assertTrue(QueryObserverHolder.hasObserver());
            assertTrue(observer instanceof QueryResultTrackingObserver);
            QueryResultTrackingObserver resultObserver = (QueryResultTrackingObserver) observer;
            assertTrue(resultObserver.isObjectSerialized());
            return null;
        }
    });
    // verify if objects returned by local server query are not serialized
    server1.invoke(new SerializableCallable("Query") {

        @Override
        public Object call() throws Exception {
            QueryObserver observer = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
            QueryService qs = null;
            try {
                qs = getCache().getQueryService();
            } catch (Exception e) {
                fail("Exception getting query service ", e);
            }
            SelectResults res = null;
            for (int i = 0; i < multipleRegionQueries.length; i++) {
                try {
                    res = (SelectResults) qs.newQuery(multipleRegionQueries[i]).execute();
                } catch (Exception e) {
                    fail("Error executing query: " + multipleRegionQueries[i], e);
                }
                assertEquals(resultSize2[i], res.size());
                if (i == 4) {
                    int cnt = ((Integer) res.iterator().next());
                    assertEquals(400, cnt);
                } else {
                    for (Object rs : res) {
                        if (rs instanceof StructImpl) {
                            for (Object obj : ((StructImpl) rs).getFieldValues()) {
                                if (obj instanceof PortfolioPdx || obj instanceof PositionPdx) {
                                } else {
                                    fail("Result objects for remote client query: " + multipleRegionQueries[i] + " should be instance of PortfolioPdx and not " + obj.getClass());
                                }
                            }
                        } else if (rs instanceof PortfolioPdx) {
                        } else {
                            fail("Result objects for remote client query: " + multipleRegionQueries[i] + " should be instance of PortfolioPdx and not " + rs.getClass());
                        }
                    }
                }
            }
            observer = QueryObserverHolder.getInstance();
            assertTrue(QueryObserverHolder.hasObserver());
            assertTrue(observer instanceof QueryResultTrackingObserver);
            QueryResultTrackingObserver resultObserver = (QueryResultTrackingObserver) observer;
            assertFalse(resultObserver.isObjectSerialized());
            // reset observer
            QueryObserverHolder.setInstance(oldObserver);
            return null;
        }
    });
    closeCache(client);
    closeCache(server1);
}
Also used : PositionPdx(org.apache.geode.cache.query.data.PositionPdx) Host(org.apache.geode.test.dunit.Host) PortfolioPdx(org.apache.geode.cache.query.data.PortfolioPdx) ClientCache(org.apache.geode.cache.client.ClientCache) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) QueryObserver(org.apache.geode.cache.query.internal.QueryObserver) SelectResults(org.apache.geode.cache.query.SelectResults) StructImpl(org.apache.geode.cache.query.internal.StructImpl) QueryService(org.apache.geode.cache.query.QueryService) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Region(org.apache.geode.cache.Region) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

PortfolioPdx (org.apache.geode.cache.query.data.PortfolioPdx)51 Region (org.apache.geode.cache.Region)50 Test (org.junit.Test)50 QueryService (org.apache.geode.cache.query.QueryService)47 SelectResults (org.apache.geode.cache.query.SelectResults)46 Query (org.apache.geode.cache.query.Query)34 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)28 VM (org.apache.geode.test.dunit.VM)27 DefaultQuery (org.apache.geode.cache.query.internal.DefaultQuery)26 Host (org.apache.geode.test.dunit.Host)26 CacheException (org.apache.geode.cache.CacheException)19 Struct (org.apache.geode.cache.query.Struct)17 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)14 AttributesFactory (org.apache.geode.cache.AttributesFactory)13 ClientCache (org.apache.geode.cache.client.ClientCache)13 ClientCacheFactory (org.apache.geode.cache.client.ClientCacheFactory)13 CompiledSelect (org.apache.geode.cache.query.internal.CompiledSelect)13 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)13 Iterator (java.util.Iterator)12 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)12