@Override public ModelOutput<ErrorRecord> createOutput(Class<? extends ErrorRecord> dataType, String path, OutputStream stream ) throws IOException { if(path == null) { throw new IllegalArgumentException("path must not be null"); } if(stream == null) { throw new IllegalArgumentException("stream must not be null"); } CsvEmitter emitter = new CsvEmitter(stream, path, this.getConfiguration(true)); return new Writer(emitter); } private static final class Reader implements ModelInput<ErrorRecord> {
@Override public ModelOutput<ItemInfo> createOutput(Class<? extends ItemInfo> dataType, String path, OutputStream stream) throws IOException { if(path == null) { throw new IllegalArgumentException("path must not be null"); } if(stream == null) { throw new IllegalArgumentException("stream must not be null"); } CsvEmitter emitter = new CsvEmitter(stream, path, this.getConfiguration(true)); return new Writer(emitter); } private static final class Reader implements ModelInput<ItemInfo> {
@Override public ModelOutput<CategorySummary> createOutput(Class<? extends CategorySummary> dataType, String path, OutputStream stream) throws IOException { if(path == null) { throw new IllegalArgumentException("path must not be null"); } if(stream == null) { throw new IllegalArgumentException("stream must not be null"); } CsvEmitter emitter = new CsvEmitter(stream, path, this.getConfiguration(true)); return new Writer(emitter); } private static final class Reader implements ModelInput<CategorySummary> {
@Override public ModelOutput<SalesDetail> createOutput(Class<? extends SalesDetail> dataType, String path, OutputStream stream ) throws IOException { if(path == null) { throw new IllegalArgumentException("path must not be null"); } if(stream == null) { throw new IllegalArgumentException("stream must not be null"); } CsvEmitter emitter = new CsvEmitter(stream, path, this.getConfiguration(true)); return new Writer(emitter); } private static final class Reader implements ModelInput<SalesDetail> {
@Override public ModelOutput<StoreInfo> createOutput(Class<? extends StoreInfo> dataType, String path, OutputStream stream) throws IOException { if(path == null) { throw new IllegalArgumentException("path must not be null"); } if(stream == null) { throw new IllegalArgumentException("stream must not be null"); } CsvEmitter emitter = new CsvEmitter(stream, path, this.getConfiguration(true)); return new Writer(emitter); } private static final class Reader implements ModelInput<StoreInfo> {
private CsvEmitter createEmitter() { CsvConfiguration conf = createConfiguration(); return new CsvEmitter(output, testName.getMethodName(), conf); }
private void assertRestorable(ValueOption<?> option) { CsvConfiguration conf = createConfiguration(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try (CsvEmitter emitter = new CsvEmitter(buffer, testName.getMethodName(), conf)) { emit(emitter, option); emitter.endRecord(); emitter.close(); try (CsvParser parser = new CsvParser( new ByteArrayInputStream(buffer.toByteArray()), testName.getMethodName(), conf)) { assertThat(parser.next(), is(true)); ValueOption<?> copy = option.getClass().newInstance(); fill(parser, copy); parser.endRecord(); assertThat(parser.next(), is(false)); assertThat(copy, is((Object) option)); } } catch (Exception e) { throw new AssertionError(e); } }
/** * Simple stress test for {@link DateTime} type. * @throws Exception if failed */ @Test public void stress_datetime() throws Exception { int count = 5000000; try (CsvEmitter emitter = new CsvEmitter(new VoidOutputStream(), "testing", createConfiguration())) { DateTimeOption value = new DateTimeOption(new DateTime(1999, 12, 31, 1, 23, 45)); for (int i = 0; i < count; i++) { emitter.emit(value); emitter.endRecord(); } } } }
/** * Simple stress test for {@link Date} type. * @throws Exception if failed */ @Test public void stress_date() throws Exception { int count = 5000000; try (CsvEmitter emitter = new CsvEmitter(new VoidOutputStream(), "testing", createConfiguration())) { DateOption value = new DateOption(new Date(1999, 12, 31)); for (int i = 0; i < count; i++) { emitter.emit(value); emitter.endRecord(); } } }