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