@Override
    public void encode(Event event, OutputStream output) throws IOException {
        String outputString = (format == null
                ? JSON_MAPPER.writeValueAsString(event.getData())
                : StringInterpolation.evaluate(event, format))
                + delimiter;
        output.write(outputString.getBytes(charset));
    }
@Test
    public void testEncode() throws IOException {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        Line line = new Line(new ConfigurationImpl(Collections.emptyMap()), null);
        Event e = new Event();
        e.setField("myfield1", "myvalue1");
        e.setField("myfield2", 42L);
        line.encode(e, outputStream);
        e.setField("myfield1", "myvalue2");
        e.setField("myfield2", 43L);
        line.encode(e, outputStream);

        String delimiter = Line.DEFAULT_DELIMITER;
        String resultingString = outputStream.toString();
        // first delimiter should occur at the halfway point of the string
        assertEquals(resultingString.indexOf(delimiter), (resultingString.length() / 2) - delimiter.length());
        // second delimiter should occur at end of string
        assertEquals(resultingString.lastIndexOf(delimiter), resultingString.length() - delimiter.length());
    }