@Test public void iterableCloseIsPropagated() throws Exception { final AtomicBoolean isClosed = new AtomicBoolean(false); final BlockingIterable<Map<String, List<String>>> formParametersIterable = () -> new BlockingIterator<Map<String, List<String>>>() { @Override public boolean hasNext(final long timeout, final TimeUnit unit) { return false; } @Override public Map<String, List<String>> next(final long timeout, final TimeUnit unit) { return emptyMap(); } @Override public Map<String, List<String>> next() { return emptyMap(); } @Override public void close() { isClosed.set(true); } @Override public boolean hasNext() { return false; } }; final BlockingIterable<Buffer> serialized = SERIALIZER.serialize(headers, formParametersIterable, DEFAULT_ALLOCATOR); serialized.iterator().close(); assertTrue(isClosed.get()); assertTrue("Unexpected content type.", headers.contains(CONTENT_TYPE, "application/x-www-form-urlencoded; charset=UTF-8")); }
@SuppressWarnings("ConstantConditions") @Override public Buffer serialize(final HttpHeaders headers, final Map<String, List<String>> parameters, final BufferAllocator allocator) { addContentType.accept(headers); return serialize(parameters, allocator, false); }
FormUrlEncodedHttpSerializer implements HttpSerializer<Map<String, List<String>>> { @SuppressWarnings("ConstantConditions") @Override public Buffer serialize(final HttpHeaders headers, final Map<String, List<String>> parameters, final BufferAllocator allocator) { addContentType.accept(headers); return serialize(parameters, allocator, false); } }
FormUrlEncodedHttpSerializer implements HttpSerializer<Map<String, List<String>>> { @SuppressWarnings("ConstantConditions") @Override public Buffer serialize(final HttpHeaders headers, final Map<String, List<String>> parameters, final BufferAllocator allocator) { addContentType.accept(headers); return serialize(parameters, allocator, false); } FormUrlEncodedHttpSerializer(final Charset charset, final Consumer<HttpHeaders> addContentType); }
FormUrlEncodedHttpSerializer implements HttpSerializer<Map<String, List<String>>> { @SuppressWarnings("ConstantConditions") @Override public Buffer serialize(final HttpHeaders headers, final Map<String, List<String>> parameters, final BufferAllocator allocator) { addContentType.accept(headers); return serialize(parameters, allocator, false); } FormUrlEncodedHttpSerializer(final Charset charset, final Consumer<HttpHeaders> addContentType); @SuppressWarnings("ConstantConditions") @Override Buffer serialize(final HttpHeaders headers,
                            final Map<String, List<String>> parameters,
                            final BufferAllocator allocator); @Override BlockingIterable<Buffer> serialize(final HttpHeaders headers,
                                              final BlockingIterable<Map<String, List<String>>> parameters,
                                              final BufferAllocator allocator); @Override Publisher<Buffer> serialize(final HttpHeaders headers,
                                       final Publisher<Map<String, List<String>>> parameters,
                                       final BufferAllocator allocator); @Override HttpPayloadWriter<Map<String, List<String>>> serialize(final HttpHeaders headers,
                                                                  final HttpPayloadWriter<Buffer> payloadWriter,
                                                                  final BufferAllocator allocator); }
FormUrlEncodedHttpSerializer implements HttpSerializer<Map<String, List<String>>> { @SuppressWarnings("ConstantConditions") @Override public Buffer serialize(final HttpHeaders headers, final Map<String, List<String>> parameters, final BufferAllocator allocator) { addContentType.accept(headers); return serialize(parameters, allocator, false); } FormUrlEncodedHttpSerializer(final Charset charset, final Consumer<HttpHeaders> addContentType); @SuppressWarnings("ConstantConditions") @Override Buffer serialize(final HttpHeaders headers,
                            final Map<String, List<String>> parameters,
                            final BufferAllocator allocator); @Override BlockingIterable<Buffer> serialize(final HttpHeaders headers,
                                              final BlockingIterable<Map<String, List<String>>> parameters,
                                              final BufferAllocator allocator); @Override Publisher<Buffer> serialize(final HttpHeaders headers,
                                       final Publisher<Map<String, List<String>>> parameters,
                                       final BufferAllocator allocator); @Override HttpPayloadWriter<Map<String, List<String>>> serialize(final HttpHeaders headers,
                                                                  final HttpPayloadWriter<Buffer> payloadWriter,
                                                                  final BufferAllocator allocator);  }