@Test
  public void testThreadSafetyOfCompiledSelectScopeId() throws Exception {
    try {
      Cache cache = CacheUtils.getCache();
      RegionFactory<Integer, Portfolio> rf = cache.createRegionFactory(RegionShortcut.PARTITION);
      Region r = rf.create("keyzset");
      for (int i = 0; i < 100; i++) {
        r.put(i, new Portfolio(i));
      }
      ScopeThreadingTestHook scopeIDTestHook = new ScopeThreadingTestHook(3);
      DefaultQuery.testHook = scopeIDTestHook;
      QueryService qs = cache.getQueryService();
      Query q = qs.newQuery(
          "SELECT DISTINCT * FROM " + SEPARATOR
              + "keyzset.keySet key WHERE key.id > 0 AND key.id <= 0 ORDER BY key asc LIMIT $3");
      Thread q1 = new Thread(new QueryRunnable(q, new Object[] {10, 20, 10}));
      Thread q2 = new Thread(new QueryRunnable(q, new Object[] {5, 10, 5}));
      Thread q3 = new Thread(new QueryRunnable(q, new Object[] {2, 10, 8}));
      q1.start();
      q2.start();
      q3.start();
      q1.join();
      q2.join();
      q3.join();
      assertEquals("Exceptions were thrown due to DefaultQuery not being thread-safe", true,
          scopeIDTestHook.isOk());
    } finally {
      DefaultQuery.testHook = null;
    }
  }
***
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