@Test
  public void test006GetRegionsInQuery() {

    String[] queryStrs =
        new String[] {"SELECT DISTINCT * FROM " + SEPARATOR + "Portfolios where status='active'",
            SEPARATOR + "Portfolios", SEPARATOR + "Portfolios.values",
            SEPARATOR + "Portfolios.keys()", SEPARATOR + "Portfolios.entries(false)",
            "null = null",
            "select distinct * from " + SEPARATOR
                + "Employees where not (select distinct * from collect).isEmpty",
            "select distinct * from $2 where salary > $1",
            "SELECT DISTINCT key: key, iD: entry.value.iD, secId: posnVal.secId  FROM " + SEPARATOR
                + "pos.entries entry, entry.value.positions.values posnVal  WHERE entry.value.\"type\" = 'type0' AND posnVal.secId = 'YHOO'",
            "SELECT DISTINCT * FROM (SELECT DISTINCT * FROM " + SEPARATOR
                + "Portfolios ptf, positions pos) WHERE pos.value.secId = 'IBM'",
            "SELECT DISTINCT * FROM " + SEPARATOR
                + "Portfolios WHERE NOT(SELECT DISTINCT * FROM positions.values p WHERE p.secId = 'IBM').isEmpty",
            "SELECT DISTINCT * FROM " + SEPARATOR
                + "Portfolios where status = ELEMENT(SELECT DISTINCT * FROM " + SEPARATOR
                + "Portfolios p where p.ID = 0).status",
            "Select distinct * from " + SEPARATOR + "Portfolios pf, " + SEPARATOR + "Portfolios2, "
                + SEPARATOR + "Portfolios3, " + SEPARATOR + "Data where pf.status='active'",
            "select distinct * from " + SEPARATOR
                + "portfolios p, p.positions.values myPos, (select distinct * from " + SEPARATOR
                + "Employees x)  where myPos.secId = 'YHOO'",
            "select distinct * from " + SEPARATOR
                + "portfolios p, p.positions.values myPos, (select distinct * from " + SEPARATOR
                + "Employees x, " + SEPARATOR + "portfolios)  where myPos.secId = 'YHOO'",
            "select distinct * from " + SEPARATOR
                + "portfolios p, p.positions.values myPos, (select distinct * from " + SEPARATOR
                + "Employees x, " + SEPARATOR + "Portfolios)  where myPos.secId = 'YHOO'",
            "select distinct " + SEPARATOR + "Portfolios.size, key FROM " + SEPARATOR
                + "pos.entries",
            "select distinct " + SEPARATOR + "Portfolios2.size, key FROM " + SEPARATOR
                + "pos.entries WHERE (Select distinct * from " + SEPARATOR
                + "portfolios4, entries).size = 3",

        };
    String[][] regions = new String[][] {{SEPARATOR + "Portfolios"}, {SEPARATOR + "Portfolios"},
        {SEPARATOR + "Portfolios"},
        {SEPARATOR + "Portfolios"}, {SEPARATOR + "Portfolios"}, {}, {SEPARATOR + "Employees"},
        {SEPARATOR + "Portfolios"}, {SEPARATOR + "pos"},
        {SEPARATOR + "Portfolios"}, {SEPARATOR + "Portfolios"}, {SEPARATOR + "Portfolios"},
        {SEPARATOR + "Portfolios", SEPARATOR + "Portfolios2", SEPARATOR + "Portfolios3",
            SEPARATOR + "Data"},
        {SEPARATOR + "portfolios", SEPARATOR + "Employees"},
        {SEPARATOR + "portfolios", SEPARATOR + "Employees"},
        {SEPARATOR + "portfolios", SEPARATOR + "Employees", SEPARATOR + "Portfolios"},
        {SEPARATOR + "Portfolios", SEPARATOR + "pos"},
        {SEPARATOR + "Portfolios2", SEPARATOR + "pos", SEPARATOR + "portfolios4"}

    };

    Object[] params = new Object[] {"", CacheUtils.createRegion("Portfolios", Portfolio.class)};
    for (int i = 0; i < queryStrs.length; ++i) {
      Query q = CacheUtils.getQueryService().newQuery(queryStrs[i]);

      Set set = ((DefaultQuery) q).getRegionsInQuery(params);
      String[] qRegions = regions[i];
      assertEquals("region names don't match in query #" + i + "(\"" + queryStrs[i] + "\"",
          new HashSet(Arrays.asList(qRegions)), set);
    }
    DefaultQuery q = (DefaultQuery) CacheUtils.getQueryService().newQuery(queryStrs[0]);

    Set set = q.getRegionsInQuery(params);
    try {
      set.add("test");
      fail("The set returned should not be modifiable");
    } catch (Exception e) {
      // Expected
    }
  }
***
THIS FILE IS ENCODED IN UTF-8 IN ORDER TO TEST UNICODE IN FIELD NAMES. THE ENCODING MUST BE
SPECIFIED AS UTF-8 WHEN COMPILED
*****
geode-core/src/integrationTest/java/org/apache/geode/cache/query/QueryJUnitTest.java