@Test
public void testNotifyListener() throws InvalidSyntaxException {

    IMocksControl c = EasyMock.createControl();
    EndpointEventListener epl = c.createMock(EndpointEventListener.class);
    Capture<EndpointEvent> capturedEvents = newCapture(CaptureType.ALL);
    Capture<String> capturedFilters = newCapture(CaptureType.ALL);
    epl.endpointChanged(capture(capturedEvents), capture(capturedFilters));
    expectLastCall().anyTimes();
    EndpointDescription endpoint1 = createEndpoint("myClass");
    EndpointDescription endpoint2 = createEndpoint("notMyClass");
    c.replay();
    EndpointListenerNotifier notifier = new EndpointListenerNotifier();
    Filter filter = FrameworkUtil.createFilter("(objectClass=myClass)");
    notifier.add(epl, new HashSet(asList(filter)), Collections.emptyList());
    notifier.sendEvent(new EndpointEvent(EndpointEvent.ADDED, endpoint1));
    notifier.sendEvent(new EndpointEvent(EndpointEvent.ADDED, endpoint2));
    notifier.sendEvent(new EndpointEvent(EndpointEvent.REMOVED, endpoint1));
    notifier.sendEvent(new EndpointEvent(EndpointEvent.REMOVED, endpoint2));
    c.verify();
    // Expect listener to be called for endpoint1 but not for endpoint2
    List<EndpointEvent> expected = Arrays.asList(
            new EndpointEvent(EndpointEvent.ADDED, endpoint1),
            new EndpointEvent(EndpointEvent.REMOVED, endpoint1)
            );
    MatcherAssert.assertThat(capturedEvents.getValues(), Matchers.sameBeanAs(expected));
}