@Test
  public void testFailureCacheHardLimit() throws Exception {
    MetricCollector.getInstance().deinit();
    conf = new HiveConf();
    MetricCollector collector = MetricCollector.getInstance();
    MetricCollector metricCollectorSpy = Mockito.spy(collector);
    Mockito.doReturn(1L).when(metricCollectorSpy).getMaxSize(Mockito.any());
    metricCollectorSpy.init(conf);
    metricCollectorSpy.addMetric(new ReplicationMetric(1, "repl",
        0, null));
    try {
      metricCollectorSpy.addMetric(new ReplicationMetric(2, "repl",
          0, null));
      Assert.fail();
    } catch (SemanticException e) {
      Assert.assertEquals("Metrics are not getting collected. ", e.getMessage());
    }
  }
Unit Test class for In Memory Replication Metric Collection.
ql/src/test/org/apache/hadoop/hive/ql/parse/repl/metric/TestReplicationMetricCollector.java