Skip to content

Instantly share code, notes, and snippets.

@kronar
Created June 16, 2016 09:34
Show Gist options
  • Save kronar/4614b636ec5c379f1cd5df2a6fed1ec4 to your computer and use it in GitHub Desktop.
Save kronar/4614b636ec5c379f1cd5df2a6fed1ec4 to your computer and use it in GitHub Desktop.
package internal;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Assert;
import org.junit.Test;
/**
* Created by nikita on 16.06.16.
*/
public class TetsEBHandlersIdentity {
private static final class HandlerOne {
public static AtomicInteger counter = new AtomicInteger();
@Subscribe
public void onInteger(Integer value) {
counter.incrementAndGet();
}
}
@Test
public void test() {
EventBus eb = new EventBus();
eb.register(new HandlerOne());
eb.register(new HandlerOne());
eb.post(new Integer(100));
//Fucking bug in Guava event bus
Assert.assertEquals(HandlerOne.counter.intValue(), 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment