private List<Integer> compileAndRespond(String query, boolean reuseSession, int threadCount)
      throws Exception {
    List<Integer> responseList = new ArrayList<>();
    SessionState sessionState = new SessionState(conf);

    List<Callable<CommandProcessorResponse>> callables = new ArrayList<>();
    for (int i = 0; i < threadCount; i++) {
      callables.add(() -> {
        SessionState ss = (reuseSession)? sessionState : new SessionState(conf);
        SessionState.setCurrentSessionState(ss);

        CommandProcessorResponse response;
        try{
          response = driver.compileAndRespond(query);

        } finally {
          SessionState.detachSession();
        }
        return response;
      });
    }

    ExecutorService pool = Executors.newFixedThreadPool(callables.size());
    try{
      List<Future<CommandProcessorResponse>> futures = pool.invokeAll(callables);

      for (Future<CommandProcessorResponse> future : futures) {
        try {
          future.get();
          responseList.add(0);

        } catch (ExecutionException ex) {
          responseList.add(ex.getCause() instanceof CommandProcessorException ?
                ErrorMsg.COMPILE_LOCK_TIMED_OUT.getErrorCode() : CONCURRENT_COMPILATION);
        }
      }
    } finally {
      pool.shutdown();
    }

    return responseList;
  }
Test that checks that the queries above the quota are timed out, so the compilation quota maximum is honored.
@throws Exception
ql/src/test/org/apache/hadoop/hive/ql/TestCompileLock.java