@Test
public void testMonitor() throws Throwable {

    ProceedingJoinPoint mockPjp = createPjpMock(mockSignature, 2);
    expect(mockPjp.proceed()).andReturn(null).times(2);
    replay(mockPjp);
    // Test monitor without pre-existing perf monitor.
    aspect.monitor(mockPjp, mockAnnotation);
    // Test monitor with pre-existing perf monitor.
    aspect.monitor(mockPjp, mockAnnotation);
    String otherMonitor = "OtherMonitor";
    ProceedingJoinPoint otherMockPjp = createPjpMock(mockSignature, 1);
    expect(otherMockPjp.proceed()).andReturn(null).times(1);
    replay(otherMockPjp);
    PerformanceMonitor otherMockAnnotation = createMock(PerformanceMonitor.class);
    expect(otherMockAnnotation.value()).andReturn(otherMonitor);
    replay(otherMockAnnotation);
    // Test monitor with another perf monitor.
    aspect.monitor(otherMockPjp, otherMockAnnotation);
    verifyMonitor(TEST_MONITOR, 2, 0);
    verifyMonitor(otherMonitor, 1, 0);
    verify(mockPjp);
    verify(mockAnnotation);
    verify(mockSignature);
    verify(otherMockPjp);
    verify(otherMockAnnotation);
}