@Test
  public void testSimpleCallback() {
    final AtomicBoolean flag = new AtomicBoolean(false);

    DefaultRavenFactory factory =
        new DefaultRavenFactory() {
          @Override
          protected Connection createConnection(Dsn dsn) {
            Connection connection = super.createConnection(dsn);

            connection.addEventSendFailureCallback(
                new EventSendFailureCallback() {
                  @Override
                  public void onFailure(Event event, Exception exception) {
                    flag.set(true);
                  }
                });

            return connection;
          }
        };

    String dsn = "https://*****:*****@localhost:1234/1?raven.async=false";
    Raven raven = factory.createRavenInstance(new Dsn(dsn));
    raven.sendMessage("Message that will fail because DSN points to garbage.");

    assertThat(flag.get(), is(true));
  }
  @Test
  public void testExceptionInsideCallback() {
    DefaultRavenFactory factory =
        new DefaultRavenFactory() {
          @Override
          protected Connection createConnection(Dsn dsn) {
            Connection connection = super.createConnection(dsn);

            connection.addEventSendFailureCallback(
                new EventSendFailureCallback() {
                  @Override
                  public void onFailure(Event event, Exception exception) {
                    throw new RuntimeException("Error inside of EventSendFailureCallback");
                  }
                });

            return connection;
          }
        };

    String dsn = "https://*****:*****@localhost:1234/1?raven.async=false";
    Raven raven = factory.createRavenInstance(new Dsn(dsn));
    raven.sendMessage("Message that will fail because DSN points to garbage.");
  }