### Question:
AbstractTextStreamFormat extends ConfigurableBinaryStreamFormat<T> { @Override public ModelOutput<T> createOutput( Class<? extends T> dataType, String path, OutputStream stream) throws IOException, InterruptedException { TextFormat format = getTextFormat(); RecordDefinition<T> record = getRecordDefinition(); Set<OutputOption> options = OUTPUT_OPTS; OutputStream destination = decorate(stream); return new DecoratedOutput(record.newOutput(format.open(destination), path, options), new StringOption(path)); }  final TextFormat getTextFormat(); final RecordDefinition<T> getRecordDefinition(); @Override final long getPreferredFragmentSize(); @Override final long getMinimumFragmentSize(); @Override ModelInput<T> createInput(
            Class<? extends T> dataType,
            String path,
            InputStream stream,
            long offset, long fragmentSize); @Override ModelOutput<T> createOutput(
            Class<? extends T> dataType,
            String path,
            OutputStream stream);  }### Answer:
@Test public void output() throws Exception { MockFormat format = format(1); String[][] data = { { "Hello, world!" } }; ByteArrayOutputStream output = new ByteArrayOutputStream(); try (ModelOutput<String[]> out = format.createOutput(String[].class, "dummy", output)) { dump(out, data); } assertThat(deserialize(output.toByteArray()), is(data)); }
@Test public void output_header() throws Exception { MockFormat format = format(HeaderType.FORCE, "a", "b", "c"); ByteArrayOutputStream output = new ByteArrayOutputStream(); try (ModelOutput<String[]> out = format.createOutput(String[].class, "dummy", output)) { dump(out, new String[][] { { "A", "B", "C", }, { "D", "E", "F", }, }); } assertThat(deserialize(output.toByteArray()), is(new String[][] { { "a", "b", "c", }, { "A", "B", "C", }, { "D", "E", "F", }, })); }
@Test public void output_compression() throws Exception { MockFormat format = format(1) .withCodecClass(GzipCodec.class); String[][] data = { { "Hello, world!" } }; ByteArrayOutputStream output = new ByteArrayOutputStream(); try (ModelOutput<String[]> out = format.createOutput(String[].class, "dummy", output)) { dump(out, data); } ByteArrayOutputStream buf = new ByteArrayOutputStream(); try (InputStream in = new GZIPInputStream(new ByteArrayInputStream(output.toByteArray()))) { IOUtils.copy(in, buf); } assertThat(deserialize(buf.toByteArray()), is(data)); }