@Test public void unregisterProducerInHandler() throws Exception {
    final Object producer = new Object() {
      private int calls = 0;
      @Produce public String produceString() {
        calls++;
        if (calls > 1) {
          fail("Should only have been called once, then unregistered and never called again.");
        }
        return "Please enjoy this hand-crafted String.";
      }
    };
    bus.register(producer);
    bus.register(new Object() {
      @Subscribe public void firstUnsubscribeTheProducer(String produced) {
        bus.unregister(producer);
      }
      @Subscribe public void shouldNeverBeCalled(String uhoh) {
        fail("Shouldn't receive events from an unregistered producer.");
      }
    });
  }
Test case for subscribers which unregister while handling an event.
otto/src/test/java/com/squareup/otto/UnregisteringHandlerTest.java