|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
* Copyright 2002-2022 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
@ -81,7 +81,7 @@ public abstract class AbstractEncoderTests<E extends Encoder<?>> extends Abstrac |
|
|
|
* Helper methods that tests for a variety of encoding scenarios. This methods |
|
|
|
* Helper methods that tests for a variety of encoding scenarios. This methods |
|
|
|
* invokes: |
|
|
|
* invokes: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link #testEncode(Publisher, ResolvableType, Consumer, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncode(Publisher, ResolvableType, MimeType, Map, Consumer)}</li> |
|
|
|
* <li>{@link #testEncodeError(Publisher, ResolvableType, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncodeError(Publisher, ResolvableType, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncodeCancel(Publisher, ResolvableType, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncodeCancel(Publisher, ResolvableType, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncodeEmpty(ResolvableType, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncodeEmpty(ResolvableType, MimeType, Map)}</li> |
|
|
@ -94,30 +94,32 @@ public abstract class AbstractEncoderTests<E extends Encoder<?>> extends Abstrac |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected <T> void testEncodeAll(Publisher<? extends T> input, Class<? extends T> inputClass, |
|
|
|
protected <T> void testEncodeAll(Publisher<? extends T> input, Class<? extends T> inputClass, |
|
|
|
Consumer<StepVerifier.FirstStep<DataBuffer>> stepConsumer) { |
|
|
|
Consumer<StepVerifier.FirstStep<DataBuffer>> stepConsumer) { |
|
|
|
testEncodeAll(input, ResolvableType.forClass(inputClass), stepConsumer, null, null); |
|
|
|
|
|
|
|
|
|
|
|
testEncodeAll(input, ResolvableType.forClass(inputClass), null, null, stepConsumer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Helper methods that tests for a variety of decoding scenarios. This methods |
|
|
|
* Helper methods that tests for a variety of decoding scenarios. This methods |
|
|
|
* invokes: |
|
|
|
* invokes: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link #testEncode(Publisher, ResolvableType, Consumer, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncode(Publisher, ResolvableType, MimeType, Map, Consumer)}</li> |
|
|
|
* <li>{@link #testEncodeError(Publisher, ResolvableType, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncodeError(Publisher, ResolvableType, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncodeCancel(Publisher, ResolvableType, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncodeCancel(Publisher, ResolvableType, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncodeEmpty(ResolvableType, MimeType, Map)}</li> |
|
|
|
* <li>{@link #testEncodeEmpty(ResolvableType, MimeType, Map)}</li> |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @param <T> the output type |
|
|
|
* @param input the input to be provided to the encoder |
|
|
|
* @param input the input to be provided to the encoder |
|
|
|
* @param inputType the input type |
|
|
|
* @param inputType the input type |
|
|
|
* @param stepConsumer a consumer to {@linkplain StepVerifier verify} the output |
|
|
|
|
|
|
|
* @param mimeType the mime type to use for decoding. May be {@code null}. |
|
|
|
* @param mimeType the mime type to use for decoding. May be {@code null}. |
|
|
|
* @param hints the hints used for decoding. May be {@code null}. |
|
|
|
* @param hints the hints used for decoding. May be {@code null}. |
|
|
|
* @param <T> the output type |
|
|
|
* @param stepConsumer a consumer to {@linkplain StepVerifier verify} the output |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected <T> void testEncodeAll(Publisher<? extends T> input, ResolvableType inputType, |
|
|
|
protected <T> void testEncodeAll(Publisher<? extends T> input, ResolvableType inputType, |
|
|
|
Consumer<StepVerifier.FirstStep<DataBuffer>> stepConsumer, |
|
|
|
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints, |
|
|
|
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) { |
|
|
|
Consumer<StepVerifier.FirstStep<DataBuffer>> stepConsumer) { |
|
|
|
testEncode(input, inputType, stepConsumer, mimeType, hints); |
|
|
|
|
|
|
|
|
|
|
|
testEncode(input, inputType, mimeType, hints, stepConsumer); |
|
|
|
testEncodeError(input, inputType, mimeType, hints); |
|
|
|
testEncodeError(input, inputType, mimeType, hints); |
|
|
|
testEncodeCancel(input, inputType, mimeType, hints); |
|
|
|
testEncodeCancel(input, inputType, mimeType, hints); |
|
|
|
testEncodeEmpty(inputType, mimeType, hints); |
|
|
|
testEncodeEmpty(inputType, mimeType, hints); |
|
|
@ -133,25 +135,25 @@ public abstract class AbstractEncoderTests<E extends Encoder<?>> extends Abstrac |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected <T> void testEncode(Publisher<? extends T> input, Class<? extends T> inputClass, |
|
|
|
protected <T> void testEncode(Publisher<? extends T> input, Class<? extends T> inputClass, |
|
|
|
Consumer<StepVerifier.FirstStep<DataBuffer>> stepConsumer) { |
|
|
|
Consumer<StepVerifier.FirstStep<DataBuffer>> stepConsumer) { |
|
|
|
testEncode(input, ResolvableType.forClass(inputClass), stepConsumer, null, null); |
|
|
|
|
|
|
|
|
|
|
|
testEncode(input, ResolvableType.forClass(inputClass), null, null, stepConsumer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Test a standard {@link Encoder#encode encode} scenario. |
|
|
|
* Test a standard {@link Encoder#encode encode} scenario. |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @param <T> the output type |
|
|
|
* @param input the input to be provided to the encoder |
|
|
|
* @param input the input to be provided to the encoder |
|
|
|
* @param inputType the input type |
|
|
|
* @param inputType the input type |
|
|
|
* @param stepConsumer a consumer to {@linkplain StepVerifier verify} the output |
|
|
|
|
|
|
|
* @param mimeType the mime type to use for decoding. May be {@code null}. |
|
|
|
* @param mimeType the mime type to use for decoding. May be {@code null}. |
|
|
|
* @param hints the hints used for decoding. May be {@code null}. |
|
|
|
* @param hints the hints used for decoding. May be {@code null}. |
|
|
|
* @param <T> the output type |
|
|
|
* @param stepConsumer a consumer to {@linkplain StepVerifier verify} the output |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected <T> void testEncode(Publisher<? extends T> input, ResolvableType inputType, |
|
|
|
protected <T> void testEncode(Publisher<? extends T> input, ResolvableType inputType, |
|
|
|
Consumer<StepVerifier.FirstStep<DataBuffer>> stepConsumer, |
|
|
|
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints, |
|
|
|
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) { |
|
|
|
Consumer<StepVerifier.FirstStep<DataBuffer>> stepConsumer) { |
|
|
|
|
|
|
|
|
|
|
|
Flux<DataBuffer> result = encoder().encode(input, this.bufferFactory, inputType, |
|
|
|
Flux<DataBuffer> result = encoder().encode(input, this.bufferFactory, inputType, mimeType, hints); |
|
|
|
mimeType, hints); |
|
|
|
|
|
|
|
StepVerifier.FirstStep<DataBuffer> step = StepVerifier.create(result); |
|
|
|
StepVerifier.FirstStep<DataBuffer> step = StepVerifier.create(result); |
|
|
|
stepConsumer.accept(step); |
|
|
|
stepConsumer.accept(step); |
|
|
|
} |
|
|
|
} |
|
|
|