*/
public class DuplicationStrategyTest {
@Test
public void testMultipleRegistrationOfEventListenerKeepsOriginalListener() {
EventListenerRegistry eventListenerRegistry = new EventListenerRegistryImpl();
EventListenerGroup<PostInsertEventListener> eventEventListenerGroup = eventListenerRegistry.getEventListenerGroup(
EventType.POST_INSERT
);
assertTrue( "We should start of with no listeners", eventEventListenerGroup.count() == 0 );
FullTextIndexEventListener firstFullTextIndexEventListener = new FullTextIndexEventListener();
eventListenerRegistry.setListeners( EventType.POST_INSERT, firstFullTextIndexEventListener );
eventListenerRegistry.addDuplicationStrategy(
new HibernateSearchIntegrator.DuplicationStrategyImpl(
FullTextIndexEventListener.class
)
);
eventListenerRegistry.appendListeners( EventType.POST_INSERT, new FullTextIndexEventListener() );
assertTrue(
"We should only be one listener, but we have " + eventEventListenerGroup.count(),
eventEventListenerGroup.count() == 1
);