@Test
  public void testWmNamespaceHandling() throws Throwable {
    HiveConf hiveConf = getNewConf(null);
    Hive hm = setUpImpl(hiveConf);
    // TODO: threadlocals... Why is all this Hive client stuff like that?!!
    final AtomicReference<Hive> hm2r = new AtomicReference<>();
    Thread pointlessThread = new Thread(new Runnable() {
      @Override
      public void run() {
        HiveConf hiveConf2 = getNewConf(null);
        //TODO: HIVE-28289: TestHive/TestHiveRemote to run on Tez
        hiveConf2.setVar(HiveConf.ConfVars.HIVE_EXECUTION_ENGINE, "mr");
        hiveConf2.setVar(ConfVars.HIVE_SERVER2_WM_NAMESPACE, "hm2");
        try {
          hm2r.set(setUpImpl(hiveConf2));
        } catch (Exception e) {
          System.err.println(StringUtils.stringifyException(e));
        }
      }
    });
    pointlessThread.start();
    pointlessThread.join();
    Hive hm2 = hm2r.get();
    assertNotNull(hm2);

    hm.createResourcePlan(new WMResourcePlan("hm"), null, false);
    assertEquals(1, hm.getAllResourcePlans().size());
    assertEquals(0, hm2.getAllResourcePlans().size());
    hm2.createResourcePlan(new WMResourcePlan("hm"), null, false);
    WMNullableResourcePlan changes = new WMNullableResourcePlan();
    changes.setStatus(WMResourcePlanStatus.ACTIVE);
    hm.alterResourcePlan("hm", changes, true, false, false);
    // We should not be able to modify the active plan.
    WMPool pool = new WMPool("hm", "foo");
    pool.setAllocFraction(0);
    pool.setQueryParallelism(1);
    try {
      hm.createWMPool(pool);
      fail("Expected exception");
    } catch (HiveException e) {
    }
    // But we should still be able to modify the other plan.
    pool.unsetNs(); // The call to create sets the namespace.
    hm2.createWMPool(pool);
    // Make the 2nd plan active in a different namespace.
    changes.unsetNs();
    hm2.alterResourcePlan("hm", changes, true, false, false);
  }
Test basic Hive class interaction, that:
- We can have different Hive objects throughout the lifetime of this thread.
ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java