private void doTestDelimitedMaxRecordSize(final Buffer input, Buffer delim, Integer[] chunkSizes, int maxRecordSize, Handler<Throwable> exHandler, final Buffer... expected) { final Buffer[] results = new Buffer[expected.length]; Handler<Buffer> out = new Handler<Buffer>() { int pos; public void handle(Buffer buff) { results[pos++] = buff; } }; RecordParser parser = RecordParser.newDelimited(delim, out); parser.maxRecordSize(maxRecordSize); parser.exceptionHandler(exHandler); feedChunks(input, parser, chunkSizes); checkResults(expected, results); } }
@Test public void testIllegalArguments() { assertNullPointerException(() -> RecordParser.newDelimited((Buffer) null, handler -> {})); assertNullPointerException(() -> RecordParser.newDelimited((String) null, handler -> {})); RecordParser parser = RecordParser.newDelimited("", handler -> {}); assertNullPointerException(() -> parser.setOutput(null)); assertNullPointerException(() -> parser.delimitedMode((Buffer) null)); assertNullPointerException(() -> parser.delimitedMode((String) null)); assertIllegalArgumentException(() -> parser.maxRecordSize(-1)); }
/** * Set the maximum allowed size for a record when using the delimited mode. * The delimiter itself does not count for the record size. * <p> * If a record is longer than specified, an {@link java.lang.IllegalStateException} will be thrown. * @param size the maximum record size * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.core.parsetools.RecordParser maxRecordSize(int size) { delegate.maxRecordSize(size); return this; }
/** * Set the maximum allowed size for a record when using the delimited mode. * The delimiter itself does not count for the record size. * <p> * If a record is longer than specified, an {@link java.lang.IllegalStateException} will be thrown. * @param size the maximum record size * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.core.parsetools.RecordParser maxRecordSize(int size) { delegate.maxRecordSize(size); return this; }
private void doTestDelimitedMaxRecordSize(final Buffer input, Buffer delim, Integer[] chunkSizes, int maxRecordSize, Handler<Throwable> exHandler, final Buffer... expected) { final Buffer[] results = new Buffer[expected.length]; Handler<Buffer> out = new Handler<Buffer>() { int pos; public void handle(Buffer buff) { results[pos++] = buff; } }; RecordParser parser = RecordParser.newDelimited(delim, out); parser.maxRecordSize(maxRecordSize); parser.exceptionHandler(exHandler); feedChunks(input, parser, chunkSizes); checkResults(expected, results); } }
@Test public void testIllegalArguments() { assertNullPointerException(() -> RecordParser.newDelimited((Buffer) null, handler -> {})); assertNullPointerException(() -> RecordParser.newDelimited((String) null, handler -> {})); RecordParser parser = RecordParser.newDelimited("", handler -> {}); assertNullPointerException(() -> parser.setOutput(null)); assertNullPointerException(() -> parser.delimitedMode((Buffer) null)); assertNullPointerException(() -> parser.delimitedMode((String) null)); assertIllegalArgumentException(() -> parser.maxRecordSize(-1)); }