@Test
public void testCounterTwice() throws Exception {
final String name = "counter";
ProfileCollector collector = getCollector(serverNode);
ProfileConsumer cons1 = collector.getConsumer("c1");
ProfileCounter counter1 =
cons1.createCounter(name,
ProfileDataType.TASK, ProfileLevel.MAX);
// Try creating with same name and parameters
ProfileCounter counter2 =
cons1.createCounter(name,
ProfileDataType.TASK, ProfileLevel.MAX);
assertSame(counter1, counter2);
// Try creating with same name and different parameters
try {
ProfileCounter op3 =
cons1.createCounter(name,
ProfileDataType.AGGREGATE,
ProfileLevel.MAX);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
System.err.println(expected);
}
try {
ProfileCounter op3 =
cons1.createCounter(name,
ProfileDataType.TASK_AND_AGGREGATE,
ProfileLevel.MAX);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
System.err.println(expected);
}
try {
ProfileCounter op3 =
cons1.createCounter(name,
ProfileDataType.TASK,
ProfileLevel.MIN);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
System.err.println(expected);
}
try {
ProfileCounter op3 =
cons1.createCounter(name,
ProfileDataType.TASK,
ProfileLevel.MEDIUM);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
System.err.println(expected);
}
// Try creating with a different name
ProfileCounter counter4 =
cons1.createCounter("somethingelse",
ProfileDataType.TASK, ProfileLevel.MAX);
assertNotSame(counter1, counter4);
}