@Test
  public void testPRNonLocalQueryException() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    setCacheInVMs(vm0, vm1);

    // Creating PR's on the participating VM's
    // Creating DataStore node on the VM0.
    vm0.invoke(prQueryDUnitHelper.getCacheSerializableRunnableForPRCreate(name, redundancy,
        Portfolio.class));
    vm1.invoke(prQueryDUnitHelper.getCacheSerializableRunnableForPRCreate(name, redundancy,
        Portfolio.class));

    // Creating Colocated Region DataStore node on the VM0.
    vm0.invoke(prQueryDUnitHelper.getCacheSerializableRunnableForPRColocatedCreate(coloName,
        redundancy, name));
    vm1.invoke(prQueryDUnitHelper.getCacheSerializableRunnableForPRColocatedCreate(coloName,
        redundancy, name));

    // Creating local region on vm0 to compare the results of query.
    vm0.invoke(prQueryDUnitHelper.getCacheSerializableRunnableForLocalRegionCreation(localName,
        Portfolio.class));

    vm0.invoke(prQueryDUnitHelper.getCacheSerializableRunnableForLocalRegionCreation(coloLocalName,
        NewPortfolio.class));

    // Generating portfolio object array to be populated across the PR's & Local Regions
    Portfolio[] portfolio = createPortfoliosAndPositions(cntDest);
    NewPortfolio[] newPortfolio = createNewPortfoliosAndPositions(cntDest);

    vm0.invoke(prQueryDUnitHelper.getCacheSerializableRunnableForPRPuts(localName, portfolio, cnt,
        cntDest));
    vm0.invoke(prQueryDUnitHelper.getCacheSerializableRunnableForPRPuts(coloLocalName, newPortfolio,
        cnt, cntDest));

    // Putting the data into the PR's created
    vm0.invoke(
        prQueryDUnitHelper.getCacheSerializableRunnableForPRPuts(name, portfolio, cnt, cntDest));
    vm0.invoke(prQueryDUnitHelper.getCacheSerializableRunnableForPRPuts(coloName, newPortfolio, cnt,
        cntDest));

    // querying the VM for data and comparing the result with query result of local region.
    vm0.invoke(() -> {
      Cache cache = getCache();

      String[] queries = new String[] {"r1.ID = r2.id",};

      Object[][] r = new Object[queries.length][2];
      assertNotNull(cache.getRegion(name));
      assertNotNull(cache.getRegion(coloName));
      assertNotNull(cache.getRegion(localName));
      assertNotNull(cache.getRegion(coloLocalName));

      addIgnoredException(CacheClosedException.class.getName());
      addIgnoredException(ForceReattemptException.class.getName());
      addIgnoredException(QueryInvocationTargetException.class.getName());
      addIgnoredException(RegionDestroyedException.class.getName());
      addIgnoredException(ReplyException.class.getName());

      QueryService qs = getCache().getQueryService();
      assertThatThrownBy(() -> {
        for (int i = 0; i < queries.length; i++) {
          getCache().getLogger().info("About to execute local query: " + queries[i]);
          r[i][1] = qs.newQuery("Select " + " * from " + SEPARATOR + name + " r1, " + SEPARATOR
              + coloName + " r2 where " + queries[i]).execute();
        }
      }).isInstanceOf(UnsupportedOperationException.class)
          .hasMessageContaining("A query on a Partitioned Region").hasMessageContaining(
              "may not reference any other region if query is NOT executed within a Function");
    });
  }
1. Creates two PR Data Stores with redundantCopies = 1.

<p>
2. Populates the region with test data.

<p>
3. Fires a LOCAL query on one data store VM and verifies the result.
geode-core/src/distributedTest/java/org/apache/geode/cache/query/partitioned/PRColocatedEquiJoinDUnitTest.java