@Test
public void testJvmMetricsSingletonWithDifferentProcessNames() {

  final String process1Name = "process1";
  JvmMetrics jvmMetrics1 = org.apache.hadoop.metrics2.source.JvmMetrics
      .initSingleton(process1Name, null);
  final String process2Name = "process2";
  JvmMetrics jvmMetrics2 = org.apache.hadoop.metrics2.source.JvmMetrics
      .initSingleton(process2Name, null);
  Assert.assertEquals("initSingleton should return the singleton instance",
      jvmMetrics1, jvmMetrics2);
  Assert.assertEquals("unexpected process name of the singleton instance",
      process1Name, jvmMetrics1.processName);
  Assert.assertEquals("unexpected process name of the singleton instance",
      process1Name, jvmMetrics2.processName);
}