// Path: core/src/java/com/strategicgains/eventing/local/LocalEventBus.java
// public class LocalEventBus
// extends EventBus
// {
// 	public LocalEventBus(Collection<EventHandler> handlers, boolean shouldReraiseOnError, long pollDelayMillis)
// 	{
// 		super(new LocalEventTransport(handlers, shouldReraiseOnError, pollDelayMillis));
// 	}
// 
// 	/**
// 	 * @param value
// 	 */
//     public void retryOnError(boolean value)
//     {
//     	((LocalEventTransport) getTransport()).retryOnError(value);
//     }
// }
// 
// Path: core/src/java/com/strategicgains/eventing/local/LocalEventBusBuilder.java
// public class LocalEventBusBuilder
// implements EventBusBuilder<LocalEventBus, LocalEventBusBuilder>
// {
// 	private static final long DEFAULT_POLL_DELAY = 0L;
// 
// 	private Set<EventHandler> subscribers = new LinkedHashSet<EventHandler>();
// 	private Set<Class<?>> publishableEventTypes = new HashSet<Class<?>>();
// 	private boolean shouldRepublishOnError = false;
// 	private long pollDelay = DEFAULT_POLL_DELAY;
// 
// 	public LocalEventBusBuilder()
// 	{
// 		super();
// 	}
// 
// 	@Override
// 	public LocalEventBus build()
// 	{
// 		assert(!subscribers.isEmpty());
// 
// 		LocalEventBus bus = new LocalEventBus(subscribers, shouldRepublishOnError, pollDelay);
// 		
// 		for (Class<?> eventType : publishableEventTypes)
// 		{
// 			bus.addPublishableEventType(eventType);
// 		}
// 		
// 		return bus;
// 	}
// 
//     public LocalEventBusBuilder shouldRepublishOnError(boolean value)
//     {
//     	this.shouldRepublishOnError = value;
// 	    return this;
//     }
//     
//     public LocalEventBusBuilder pollDelay(long millis)
//     {
//     	this.pollDelay = millis;
//     	return this;
//     }
// 
//     @Override
//     public LocalEventBusBuilder subscribe(EventHandler handler)
//     {
//     	if (!subscribers.contains(handler))
//     	{
//     		subscribers.add(handler);
//     	}
//     	
//     	return this;
//     }
// 
//     @Override
//     public LocalEventBusBuilder unsubscribe(EventHandler handler)
//     {
//     	subscribers.remove(handler);
//     	return this;
//     }
//     
//     public LocalEventBusBuilder addPublishableEventType(Class<?> eventType)
//     {
//     	publishableEventTypes.add(eventType);
//     	return this;
//     }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.strategicgains.eventing.local.LocalEventBus;
import com.strategicgains.eventing.local.LocalEventBusBuilder;
		DomainEvents.publish(new HandledEvent());
		DomainEvents.publish(new IgnoredEvent());
		DomainEvents.publish(new HandledEvent());
		DomainEvents.publish(new IgnoredEvent());
		DomainEvents.publish(new HandledEvent());
		DomainEvents.publish(new IgnoredEvent());
		DomainEvents.publish(new HandledEvent());
		DomainEvents.publish(new IgnoredEvent());
		Thread.sleep(150);
		assertEquals(5, handler.getCallCount());
		assertEquals(5, ignoredHandler.getCallCount());
		assertEquals(0, longHandler.getCallCount());
	}

	@Test
	public void shouldNotNotifyEventHandler()
	throws Exception
	{
		assertEquals(0, ignoredHandler.getCallCount());
		DomainEvents.publish(new IgnoredEvent());
		Thread.sleep(150);
		assertEquals(0, handler.getCallCount());
		assertEquals(1, ignoredHandler.getCallCount());
		assertEquals(0, longHandler.getCallCount());
	}

	@Test
	public void shouldRetryEventHandler()
	throws Exception
	{
// Path: core/src/java/com/strategicgains/eventing/local/LocalEventBus.java
// public class LocalEventBus
// extends EventBus
// {
// 	public LocalEventBus(Collection<EventHandler> handlers, boolean shouldReraiseOnError, long pollDelayMillis)
// 	{
// 		super(new LocalEventTransport(handlers, shouldReraiseOnError, pollDelayMillis));
// 	}
// 
// 	/**
// 	 * @param value
// 	 */
//     public void retryOnError(boolean value)
//     {
//     	((LocalEventTransport) getTransport()).retryOnError(value);
//     }
// }
// 
// Path: core/src/java/com/strategicgains/eventing/local/LocalEventBusBuilder.java
// public class LocalEventBusBuilder
// implements EventBusBuilder<LocalEventBus, LocalEventBusBuilder>
// {
// 	private static final long DEFAULT_POLL_DELAY = 0L;
// 
// 	private Set<EventHandler> subscribers = new LinkedHashSet<EventHandler>();
// 	private Set<Class<?>> publishableEventTypes = new HashSet<Class<?>>();
// 	private boolean shouldRepublishOnError = false;
// 	private long pollDelay = DEFAULT_POLL_DELAY;
// 
// 	public LocalEventBusBuilder()
// 	{
// 		super();
// 	}
// 
// 	@Override
// 	public LocalEventBus build()
// 	{
// 		assert(!subscribers.isEmpty());
// 
// 		LocalEventBus bus = new LocalEventBus(subscribers, shouldRepublishOnError, pollDelay);
// 		
// 		for (Class<?> eventType : publishableEventTypes)
// 		{
// 			bus.addPublishableEventType(eventType);
// 		}
// 		
// 		return bus;
// 	}
// 
//     public LocalEventBusBuilder shouldRepublishOnError(boolean value)
//     {
//     	this.shouldRepublishOnError = value;
// 	    return this;
//     }
//     
//     public LocalEventBusBuilder pollDelay(long millis)
//     {
//     	this.pollDelay = millis;
//     	return this;
//     }
// 
//     @Override
//     public LocalEventBusBuilder subscribe(EventHandler handler)
//     {
//     	if (!subscribers.contains(handler))
//     	{
//     		subscribers.add(handler);
//     	}
//     	
//     	return this;
//     }
// 
//     @Override
//     public LocalEventBusBuilder unsubscribe(EventHandler handler)
//     {
//     	subscribers.remove(handler);
//     	return this;
//     }
//     
//     public LocalEventBusBuilder addPublishableEventType(Class<?> eventType)
//     {
//     	publishableEventTypes.add(eventType);
//     	return this;
//     }
// }


// Path: core/test/java/com/strategicgains/eventing/DomainEventsTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.strategicgains.eventing.local.LocalEventBus;
import com.strategicgains.eventing.local.LocalEventBusBuilder;

		DomainEvents.publish(new HandledEvent());
		DomainEvents.publish(new IgnoredEvent());
		DomainEvents.publish(new HandledEvent());
		DomainEvents.publish(new IgnoredEvent());
		DomainEvents.publish(new HandledEvent());
		DomainEvents.publish(new IgnoredEvent());
		DomainEvents.publish(new HandledEvent());
		DomainEvents.publish(new IgnoredEvent());
		Thread.sleep(150);
		assertEquals(5, handler.getCallCount());
		assertEquals(5, ignoredHandler.getCallCount());
		assertEquals(0, longHandler.getCallCount());
	}

	@Test
	public void shouldNotNotifyEventHandler()
	throws Exception
	{
		assertEquals(0, ignoredHandler.getCallCount());
		DomainEvents.publish(new IgnoredEvent());
		Thread.sleep(150);
		assertEquals(0, handler.getCallCount());
		assertEquals(1, ignoredHandler.getCallCount());
		assertEquals(0, longHandler.getCallCount());
	}

	@Test
	public void shouldRetryEventHandler()
	throws Exception
	{
		((LocalEventBus) DomainEvents.getBus("primary")).retryOnError(true);