List of usage examples for io.netty.buffer PooledByteBufAllocator PooledByteBufAllocator
@SuppressWarnings("deprecation") public PooledByteBufAllocator(boolean preferDirect)
From source file:org.springframework.core.io.buffer.DataBufferTests.java
License:Apache License
@Parameterized.Parameters(name = "{0}") public static Object[][] buffers() { return new Object[][] { { new NettyDataBufferAllocator(new UnpooledByteBufAllocator(true)) }, { new NettyDataBufferAllocator(new UnpooledByteBufAllocator(false)) }, { new NettyDataBufferAllocator(new PooledByteBufAllocator(true)) }, { new NettyDataBufferAllocator(new PooledByteBufAllocator(false)) }, { new DefaultDataBufferAllocator(true) }, { new DefaultDataBufferAllocator(false) } }; }
From source file:org.springframework.core.io.buffer.PooledDataBufferTests.java
License:Apache License
@Parameterized.Parameters(name = "{0}") public static Object[][] buffers() { return new Object[][] { { new NettyDataBufferFactory(new UnpooledByteBufAllocator(true)) }, { new NettyDataBufferFactory(new UnpooledByteBufAllocator(false)) }, { new NettyDataBufferFactory(new PooledByteBufAllocator(true)) }, { new NettyDataBufferFactory(new PooledByteBufAllocator(false)) } }; }
From source file:org.springframework.web.reactive.function.BodyExtractorsTests.java
License:Apache License
@Test // SPR-17054 public void unsupportedMediaTypeShouldConsumeAndCancel() { NettyDataBufferFactory factory = new NettyDataBufferFactory(new PooledByteBufAllocator(true)); NettyDataBuffer buffer = factory.wrap(ByteBuffer.wrap("spring".getBytes(StandardCharsets.UTF_8))); TestPublisher<DataBuffer> body = TestPublisher.create(); MockClientHttpResponse response = new MockClientHttpResponse(HttpStatus.OK); response.getHeaders().setContentType(MediaType.APPLICATION_PDF); response.setBody(body.flux());/*from w w w.j a va 2 s.co m*/ BodyExtractor<Mono<User>, ReactiveHttpInputMessage> extractor = BodyExtractors.toMono(User.class); StepVerifier.create(extractor.extract(response, this.context)).then(() -> { body.assertWasSubscribed(); body.emit(buffer); }).expectErrorSatisfies(throwable -> { assertTrue(throwable instanceof UnsupportedMediaTypeException); try { buffer.release(); Assert.fail("releasing the buffer should have failed"); } catch (IllegalReferenceCountException exc) { } body.assertCancelled(); }).verify(); }