use of io.netty.buffer.PooledByteBufAllocator in project motan by weibocom.
the class YarMessageHandlerWarpperTest method buildHttpRequest.
private FullHttpRequest buildHttpRequest(YarRequest yarRequest, String requestPath) throws Exception {
PooledByteBufAllocator allocator = new PooledByteBufAllocator();
ByteBuf buf = allocator.buffer(2048, 1024 * 1024);
if (yarRequest != null) {
buf.writeBytes(YarProtocol.toProtocolBytes(yarRequest));
}
FullHttpRequest httpReqeust = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, requestPath, buf);
return httpReqeust;
}
use of io.netty.buffer.PooledByteBufAllocator in project netty by netty.
the class AbstractSslHandlerThroughputBenchmark method setup.
@Setup(Level.Iteration)
public final void setup() throws Exception {
allocator = new PooledByteBufAllocator(true);
initSslHandlers(allocator);
wrapSrcBuffer = allocateBuffer(messageSize);
byte[] bytes = new byte[messageSize];
PlatformDependent.threadLocalRandom().nextBytes(bytes);
wrapSrcBuffer.writeBytes(bytes);
// Complete the initial TLS handshake.
doHandshake();
}
use of io.netty.buffer.PooledByteBufAllocator in project netty by netty.
the class SslEngineHandshakeBenchmark method setup.
@Setup(Level.Iteration)
public void setup() {
allocator = new PooledByteBufAllocator(true);
// Init an engine one time and create the buffers needed for an handshake so we can use them in the benchmark
initEngines(allocator);
initHandshakeBuffers();
destroyEngines();
}
use of io.netty.buffer.PooledByteBufAllocator in project spring-framework by spring-projects.
the class BodyExtractorsTests method unsupportedMediaTypeShouldConsumeAndCancel.
// SPR-17054
@Test
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());
BodyExtractor<Mono<User>, ReactiveHttpInputMessage> extractor = BodyExtractors.toMono(User.class);
StepVerifier.create(extractor.extract(response, this.context)).then(() -> {
body.assertWasSubscribed();
body.emit(buffer);
}).expectErrorSatisfies(throwable -> {
boolean condition = throwable instanceof UnsupportedMediaTypeException;
assertThat(condition).isTrue();
assertThatExceptionOfType(IllegalReferenceCountException.class).isThrownBy(buffer::release);
body.assertCancelled();
}).verify();
}
use of io.netty.buffer.PooledByteBufAllocator in project thingsboard by thingsboard.
the class MqttTransportHandlerTest method getMqttPublishMessage.
MqttPublishMessage getMqttPublishMessage() {
MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, true, MqttQoS.AT_LEAST_ONCE, false, 123);
MqttPublishVariableHeader variableHeader = new MqttPublishVariableHeader("v1/gateway/telemetry", packedId.incrementAndGet());
ByteBuf payload = new EmptyByteBuf(new PooledByteBufAllocator());
return new MqttPublishMessage(mqttFixedHeader, variableHeader, payload);
}
Aggregations