@Test
  public void testExclusivePoll() throws Exception {
    try {
      ObjectStoreTestHook.instance = new ObjectStoreTestHook() {

        @Override
        public void scheduledQueryPoll() {
          try {
            Thread.sleep(1000);
          } catch (InterruptedException e) {
            throw new RuntimeException(e);
          }
        }
      };
      ScheduledQuery schq = createScheduledQuery(new ScheduledQueryKey("q1", "exclusive"));
      ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
      r.setType(ScheduledQueryMaintenanceRequestType.CREATE);
      r.setScheduledQuery(schq);
      client.scheduledQueryMaintenance(r);
      // wait 1 sec for next execution
      Thread.sleep(1000);

      ExecutorService pool = Executors.newCachedThreadPool();
      Future<ScheduledQueryPollResponse> f1 = pool.submit(new AsyncPollCall("exclusive"));
      Future<ScheduledQueryPollResponse> f2 = pool.submit(new AsyncPollCall("exclusive"));

      ScheduledQueryPollResponse resp1 = f1.get();
      ScheduledQueryPollResponse resp2 = f2.get();

      assertTrue(resp1.isSetQuery() ^ resp2.isSetQuery());

      pool.shutdown();
    } finally {
      ObjectStoreTestHook.instance = null;
    }

  }
Tests handling of scheduled queries related calls to the metastore.

Checks whether expected state changes are being done to the HMS database.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestMetastoreScheduledQueries.java