@Test
@SuppressWarnings("deprecation")
public void testPriority() throws Exception {

  Configuration conf = new Configuration();
  final String namespace = "ipc.12";
  conf.set(namespace + "." + DecayRpcScheduler
      .IPC_FCQ_DECAYSCHEDULER_PERIOD_KEY, "99999999"); // Never flush
  conf.set(namespace + "." + DecayRpcScheduler
      .IPC_FCQ_DECAYSCHEDULER_THRESHOLDS_KEY, "25, 50, 75");
  scheduler = new DecayRpcScheduler(4, namespace, conf);
  assertEquals(0, getPriorityIncrementCallCount("A")); // 0 out of 0 calls
  assertEquals(3, getPriorityIncrementCallCount("A")); // 1 out of 1 calls
  assertEquals(0, getPriorityIncrementCallCount("B")); // 0 out of 2 calls
  assertEquals(1, getPriorityIncrementCallCount("B")); // 1 out of 3 calls
  assertEquals(0, getPriorityIncrementCallCount("C")); // 0 out of 4 calls
  assertEquals(0, getPriorityIncrementCallCount("C")); // 1 out of 5 calls
  assertEquals(1, getPriorityIncrementCallCount("A")); // 2 out of 6 calls
  assertEquals(1, getPriorityIncrementCallCount("A")); // 3 out of 7 calls
  assertEquals(2, getPriorityIncrementCallCount("A")); // 4 out of 8 calls
  assertEquals(2, getPriorityIncrementCallCount("A")); // 5 out of 9 calls
  MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  ObjectName mxbeanName = new ObjectName(
      "Hadoop:service="+ namespace + ",name=DecayRpcScheduler");
  String cvs1 = (String) mbs.getAttribute(mxbeanName, "CallVolumeSummary");
  assertTrue("Get expected JMX of CallVolumeSummary before decay",
      cvs1.equals("{\"A\":6,\"B\":2,\"C\":2}"));
  scheduler.forceDecay();
  String cvs2 = (String) mbs.getAttribute(mxbeanName, "CallVolumeSummary");
  assertTrue("Get expected JMX for CallVolumeSummary after decay",
      cvs2.equals("{\"A\":3,\"B\":1,\"C\":1}"));
}