|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
* Copyright 2002-2020 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. |
|
|
|
@ -82,10 +82,7 @@ class ResourceDecoderTests extends AbstractDecoderTests<ResourceDecoder> { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void decodeToMono() { |
|
|
|
public void decodeToMono() { |
|
|
|
Flux<DataBuffer> input = Flux.concat( |
|
|
|
Flux<DataBuffer> input = Flux.concat(dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); |
|
|
|
dataBuffer(this.fooBytes), |
|
|
|
|
|
|
|
dataBuffer(this.barBytes)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testDecodeToMonoAll(input, ResolvableType.forClass(Resource.class), |
|
|
|
testDecodeToMonoAll(input, ResolvableType.forClass(Resource.class), |
|
|
|
step -> step |
|
|
|
step -> step |
|
|
|
.consumeNextWith(value -> { |
|
|
|
.consumeNextWith(value -> { |
|
|
|
@ -105,4 +102,22 @@ class ResourceDecoderTests extends AbstractDecoderTests<ResourceDecoder> { |
|
|
|
Collections.singletonMap(ResourceDecoder.FILENAME_HINT, "testFile")); |
|
|
|
Collections.singletonMap(ResourceDecoder.FILENAME_HINT, "testFile")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void decodeInputStreamResource() { |
|
|
|
|
|
|
|
Flux<DataBuffer> input = Flux.concat(dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); |
|
|
|
|
|
|
|
testDecodeAll(input, InputStreamResource.class, step -> step |
|
|
|
|
|
|
|
.consumeNextWith(resource -> { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
byte[] bytes = StreamUtils.copyToByteArray(resource.getInputStream()); |
|
|
|
|
|
|
|
assertThat(new String(bytes)).isEqualTo("foobar"); |
|
|
|
|
|
|
|
assertThat(resource.contentLength()).isEqualTo(fooBytes.length + barBytes.length); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (IOException ex) { |
|
|
|
|
|
|
|
throw new AssertionError(ex.getMessage(), ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.expectComplete() |
|
|
|
|
|
|
|
.verify()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|