private void encode(ByteBuf in, List<Object> out) { // call retain here as it will call release after its written to the channel encoder.writeOutbound(in.retain()); fetchEncoderOutput(out); }
encoder.writeOutbound(msg.content().retain());
channel.writeOutbound(data); ByteBuf buf = nextReadableBuf(channel); if (buf == null) {
private void encode(ByteBuf in, List<Object> out) { // call retain here as it will call release after its written to the channel encoder.writeOutbound(in.retain()); fetchEncoderOutput(out); }
private void encode(ByteBuf in, List<Object> out) { // call retain here as it will call release after its written to the channel encoder.writeOutbound(in.retain()); fetchEncoderOutput(out); }
private void encode(ByteBuf in, List<Object> out) { // call retain here as it will call release after its written to the channel encoder.writeOutbound(in.retain()); fetchEncoderOutput(out); }
private void encode(ByteBuf in, List<Object> out) { // call retain here as it will call release after its written to the channel encoder.writeOutbound(in.retain()); fetchEncoderOutput(out); }
public static List<ByteBuf> encodeRequest(DefaultFullHttpRequest request) { EmbeddedChannel channel = new EmbeddedChannel(); channel.pipeline().addLast("http request encoder", new HttpRequestEncoder()); channel.writeOutbound(request); return extractBuffers(channel); }
@Test public void testIncorrectMessageType() { thrown.expect(RuntimeException.class); thrown.expectMessage("Only Message objects can be written to ClientCodec"); channel.writeOutbound(new Integer(1)); }
@Test public void testStatusClassInformationalMeter() { channel.writeOutbound(buildResponse(HttpResponseStatus.CONTINUE)); channel.runPendingTasks(); Meter meter = metricRegistry.meter("statusClassInformational"); assertEquals(1, meter.getCount()); }
@Test public void testStatusClassSuccessMeter() { channel.writeOutbound(buildResponse(HttpResponseStatus.OK)); channel.runPendingTasks(); Meter meter = metricRegistry.meter("statusClassSuccess"); assertEquals(1, meter.getCount()); }
@Test void encode_maximumPacketSizeExceeded_throwsEncoderException() { createServerConnectionData(12); final ImmutableList<MqttTopicFilterImpl> topicFilters = ImmutableList.of(MqttTopicFilterImpl.of("topic/#")); final MqttUnsubscribe unsubscribe = new MqttUnsubscribe(topicFilters, MqttUserPropertiesImpl.NO_USER_PROPERTIES); final int packetIdentifier = 1; final MqttStatefulUnsubscribe unsubscribeInternal = unsubscribe.createStateful(packetIdentifier); final Throwable exception = assertThrows(MqttEncodeException.class, () -> channel.writeOutbound(unsubscribeInternal)); assertTrue(exception.getMessage().contains("UNSUBSCRIBE exceeded maximum packet size")); }
private void sendPayloadToParser(ByteBuf payload) { EmbeddedChannel channel = new EmbeddedChannel(new BeatsParser()); channel.writeOutbound(payload); Object o = channel.readOutbound(); channel.writeInbound(o); }
@Test public void shouldEncodeOneChunkResponse() throws Exception { byte[] blobData = new byte[] {1, 2, 3}; String blobId = "blobId"; byte mask = createMask(1, 1); EmbeddedChannel channel = new EmbeddedChannel(new ChunkedWriteHandler(), new GetBlobResponseEncoder(3)); channel.writeOutbound(new GetBlobResponse("clientId", blobId,new ByteArrayInputStream(blobData), blobData.length)); ByteBuf buffer = (ByteBuf) channel.readOutbound(); ByteBuf expected = createBlobChunkBuffer(Messages.HEADER_BLOB, 3L, blobId, blobData, mask); assertEquals(expected, buffer); }
private void testServerToClient(Message msg) { EmbeddedChannel serverChannel = new EmbeddedChannel(new FileRegionEncoder(), MessageEncoder.INSTANCE); serverChannel.writeOutbound(msg); EmbeddedChannel clientChannel = new EmbeddedChannel( NettyUtils.createFrameDecoder(), MessageDecoder.INSTANCE); while (!serverChannel.outboundMessages().isEmpty()) { clientChannel.writeInbound(serverChannel.readOutbound()); } assertEquals(1, clientChannel.inboundMessages().size()); assertEquals(msg, clientChannel.readInbound()); }
private void testClientToServer(Message msg) { EmbeddedChannel clientChannel = new EmbeddedChannel(new FileRegionEncoder(), MessageEncoder.INSTANCE); clientChannel.writeOutbound(msg); EmbeddedChannel serverChannel = new EmbeddedChannel( NettyUtils.createFrameDecoder(), MessageDecoder.INSTANCE); while (!clientChannel.outboundMessages().isEmpty()) { serverChannel.writeOneInbound(clientChannel.readOutbound()); } assertEquals(1, serverChannel.inboundMessages().size()); assertEquals(msg, serverChannel.readInbound()); }
@Test public void encodeRequest() throws Exception { EmbeddedChannel channel = new EmbeddedChannel(new GetBlobRequestEncoder()); channel.writeOutbound(new GetBlobRequest("clientId", "blobId")); String message = (String) channel.readOutbound(); assertEquals(newGetBlobRequest("clientId", "blobId"), message); }
@Test public void encodeRequest() throws Exception { EmbeddedChannel channel = new EmbeddedChannel(new GetHeadRequestEncoder()); channel.writeOutbound(new GetHeadRequest("clientId")); String message = (String) channel.readOutbound(); assertEquals(newGetHeadRequest("clientId"), message); }
@Test public void encodeRequest() throws Exception { EmbeddedChannel channel = new EmbeddedChannel(new GetSegmentRequestEncoder()); channel.writeOutbound(new GetSegmentRequest("clientId", "segmentId")); String message = (String) channel.readOutbound(); assertEquals(newGetSegmentRequest("clientId", "segmentId"), message); }
@Test public void encodeRequest() throws Exception { EmbeddedChannel channel = new EmbeddedChannel(new GetReferencesRequestEncoder()); channel.writeOutbound(new GetReferencesRequest("clientId", "segmentId")); String message = (String) channel.readOutbound(); assertEquals(newGetReferencesRequest("clientId", "segmentId"), message); }