@Test
public void testDispatchIAccumulator_withHeader() {
final BasicAccumulator acc = new BasicAccumulator();
final JsonDispatcherConfig config = new JsonDispatcherConfig();
final TestDispatchCallback callback = new TestDispatchCallback();
final AppEvent header = new AppEvent("testheader", "testheadervalue");
final AppEvent event = new AppEvent("testkey", "testvalue");
acc.trackAppEvent(event);
config.callback = callback;
config.url = "testurl";
config.debugMode = true;
config.useCompression = false;
config.trackingHeader.add(header);
final JsonDispatcher disp = new JsonDispatcher(config);
assertTrue(!callback.errorCalled);
assertTrue(null == callback.output);
assertTrue(disp.dispatch(acc));
assertTrue(!callback.errorCalled);
try {
final String output = "{\"data\":[" + header.toJSON() + "," + event.toJSON() + "]}";
assertArrayEquals(output.getBytes("UTF-8"), callback.output);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
assertTrue(false);
}