@Test
public void testEventSerializer()
        throws Exception
{

    registerRequestToken("sample-trace-token");
    addTraceTokenProperties("key", "value");
    TraceToken traceToken = TraceTokenManager.getCurrentTraceToken();
    clearRequestToken();
    expectedEventJson.put("traceToken", "{\"id\":\"sample-trace-token\",\"key\":\"value\"}");
    JsonEventSerializer eventSerializer = new JsonEventSerializer(new NodeInfo("test"), FixedDummyEventClass.class);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    JsonGenerator jsonGenerator = new JsonFactory().createGenerator(out, JsonEncoding.UTF8);
    FixedDummyEventClass event = TestingUtils.getEvents().get(0);
    eventSerializer.serialize(event, traceToken, jsonGenerator);
    String json = out.toString(UTF_8.name());
    assertEquals(new ObjectMapper().readValue(json, Object.class), expectedEventJson, "JSON encoding " + json);
}