@Override public void flush() throws IOException { emitter.flush(); }
@Override public void flush() throws IOException { boolean fail = false; log.info("Flushing Composing Emitter."); for (Emitter e : emitters) { try { log.info("Flushing emitter %s.", e.getClass().getName()); e.flush(); } catch (IOException ex) { log.error(ex, "Failed to flush emitter [%s]", e.getClass().getName()); fail = true; } } if (fail) { throw new IOException("failed to flush one or more emitters"); } }
@Test public void testFlush() throws IOException { for (Emitter emitter : childEmitters) { emitter.flush(); EasyMock.replay(emitter); } composingEmitter.flush(); }
emitter.emit(event); emitter.flush(); Assert.assertTrue(httpClient.succeeded()); Map<String, String> expected = ImmutableMap.of(
emitter.emit(event); emitter.flush(); Assert.assertTrue(httpClient.succeeded());
@Test public void failEmitMalformedEvent() throws Exception { Emitter emitter = parametrizedEmmiter("http://example.com/{keyNotSetInEvents}"); Event event = new UnitEvent("test", 1); httpClient.setGoHandler(GoHandlers.failingHandler()); try { emitter.emit(event); emitter.flush(); } catch (IllegalArgumentException e) { Assert.assertEquals( e.getMessage(), StringUtils.format( "ParametrizedUriExtractor with pattern http://example.com/{keyNotSetInEvents} requires keyNotSetInEvents to be set in event, but found %s", event.toMap()) ); } } }
emitter.emit(event); emitter.flush(); Assert.assertTrue(httpClient.succeeded());
@Override public void flush() throws IOException { emitter.flush(); }
@Override public void flush() throws IOException { boolean fail = false; log.info("Flushing Composing Emitter."); for (Emitter e : emitters) { try { log.info("Flushing emitter %s.", e.getClass().getName()); e.flush(); } catch (IOException ex) { log.error(ex, "Failed to flush emitter [%s]", e.getClass().getName()); fail = true; } } if (fail) { throw new IOException("failed to flush one or more emitters"); } }