List of usage examples for io.netty.buffer ByteBufAllocator DEFAULT
ByteBufAllocator DEFAULT
To view the source code for io.netty.buffer ByteBufAllocator DEFAULT.
Click Source Link
From source file:io.gatling.http.client.body.multipart.impl.MessageEndPartImpl.java
License:Apache License
@Override public long transferTo(WritableByteChannel target) throws IOException { slowTarget = false;//from w w w. j a v a2 s .c o m return transferTo(lazyLoadContentBuffer(ByteBufAllocator.DEFAULT), target, PartImplState.DONE); }
From source file:io.gatling.http.client.body.multipart.impl.PartImpl.java
License:Apache License
protected ByteBuf computePreContentBytes(int preContentLength) { ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer(preContentLength); ByteBufVisitor bytesVisitor = new ByteBufVisitor(buffer); visitPreContent(bytesVisitor);//from w w w . j a va 2s . c o m return buffer; }
From source file:io.gatling.http.client.body.multipart.impl.PartImpl.java
License:Apache License
protected ByteBuf computePostContentBytes(int postContentLength) { ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer(postContentLength); ByteBufVisitor bytesVisitor = new ByteBufVisitor(buffer); visitPostContent(bytesVisitor);/*from w w w . ja v a 2 s. c om*/ return buffer; }
From source file:io.grpc.alts.internal.AltsTsiFrameProtectorTest.java
License:Apache License
@Test public void parserHeader_frameLengthNegativeFails() throws GeneralSecurityException { ByteBufAllocator alloc = ByteBufAllocator.DEFAULT; List<Object> out = new ArrayList<>(); FakeChannelCrypter crypter = new FakeChannelCrypter(); AltsTsiFrameProtector.Unprotector unprotector = new AltsTsiFrameProtector.Unprotector(crypter, alloc); ByteBuf in = getDirectBuffer(AltsTsiFrameProtector.getHeaderBytes(), ref); in.writeIntLE(-1);//from w w w.j a v a 2s . c o m in.writeIntLE(6); try { unprotector.unprotect(in, out, alloc); fail("Exception expected"); } catch (IllegalArgumentException ex) { assertThat(ex).hasMessageThat().contains("Invalid header field: frame size too small"); } unprotector.destroy(); }
From source file:io.grpc.alts.internal.AltsTsiFrameProtectorTest.java
License:Apache License
@Test public void parserHeader_frameTooSmall() throws GeneralSecurityException { ByteBufAllocator alloc = ByteBufAllocator.DEFAULT; List<Object> out = new ArrayList<>(); FakeChannelCrypter crypter = new FakeChannelCrypter(); AltsTsiFrameProtector.Unprotector unprotector = new AltsTsiFrameProtector.Unprotector(crypter, alloc); ByteBuf in = getDirectBuffer(AltsTsiFrameProtector.getHeaderBytes() + FakeChannelCrypter.getTagBytes(), ref);//from w ww . jav a2 s . c o m in.writeIntLE(FRAME_MIN_SIZE - 1); in.writeIntLE(6); try { unprotector.unprotect(in, out, alloc); fail("Exception expected"); } catch (IllegalArgumentException ex) { assertThat(ex).hasMessageThat().contains("Invalid header field: frame size too small"); } unprotector.destroy(); }
From source file:io.grpc.alts.internal.AltsTsiFrameProtectorTest.java
License:Apache License
@Test public void parserHeader_frameTooLarge() throws GeneralSecurityException { ByteBufAllocator alloc = ByteBufAllocator.DEFAULT; List<Object> out = new ArrayList<>(); FakeChannelCrypter crypter = new FakeChannelCrypter(); AltsTsiFrameProtector.Unprotector unprotector = new AltsTsiFrameProtector.Unprotector(crypter, alloc); ByteBuf in = getDirectBuffer(AltsTsiFrameProtector.getHeaderBytes() + FakeChannelCrypter.getTagBytes(), ref);// w ww .j a v a 2 s . c om in.writeIntLE(AltsTsiFrameProtector.getLimitMaxAllowedFrameBytes() - AltsTsiFrameProtector.getHeaderLenFieldBytes() + 1); in.writeIntLE(6); try { unprotector.unprotect(in, out, alloc); fail("Exception expected"); } catch (IllegalArgumentException ex) { assertThat(ex).hasMessageThat().contains("Invalid header field: frame size too large"); } unprotector.destroy(); }
From source file:io.grpc.alts.internal.AltsTsiFrameProtectorTest.java
License:Apache License
@Test public void parserHeader_frameTypeInvalid() throws GeneralSecurityException { ByteBufAllocator alloc = ByteBufAllocator.DEFAULT; List<Object> out = new ArrayList<>(); FakeChannelCrypter crypter = new FakeChannelCrypter(); AltsTsiFrameProtector.Unprotector unprotector = new AltsTsiFrameProtector.Unprotector(crypter, alloc); ByteBuf in = getDirectBuffer(AltsTsiFrameProtector.getHeaderBytes() + FakeChannelCrypter.getTagBytes(), ref);/*from ww w. j av a2s. c om*/ in.writeIntLE(FRAME_MIN_SIZE); in.writeIntLE(5); try { unprotector.unprotect(in, out, alloc); fail("Exception expected"); } catch (IllegalArgumentException ex) { assertThat(ex).hasMessageThat().contains("Invalid header field: frame type"); } unprotector.destroy(); }
From source file:io.grpc.alts.internal.AltsTsiFrameProtectorTest.java
License:Apache License
@Test public void parserHeader_frameZeroOk() throws GeneralSecurityException { ByteBufAllocator alloc = ByteBufAllocator.DEFAULT; List<Object> out = new ArrayList<>(); FakeChannelCrypter crypter = new FakeChannelCrypter(); AltsTsiFrameProtector.Unprotector unprotector = new AltsTsiFrameProtector.Unprotector(crypter, alloc); ByteBuf in = getDirectBuffer(AltsTsiFrameProtector.getHeaderBytes() + FakeChannelCrypter.getTagBytes(), ref);/*from ww w. j a v a 2 s. c om*/ in.writeIntLE(FRAME_MIN_SIZE); in.writeIntLE(6); unprotector.unprotect(in, out, alloc); assertThat(in.readableBytes()).isEqualTo(0); unprotector.destroy(); }
From source file:io.grpc.alts.internal.AltsTsiFrameProtectorTest.java
License:Apache License
@Test public void parserHeader_EmptyUnprotectNoRetain() throws GeneralSecurityException { ByteBufAllocator alloc = ByteBufAllocator.DEFAULT; List<Object> out = new ArrayList<>(); FakeChannelCrypter crypter = new FakeChannelCrypter(); AltsTsiFrameProtector.Unprotector unprotector = new AltsTsiFrameProtector.Unprotector(crypter, alloc); ByteBuf emptyBuf = getDirectBuffer(0, ref); unprotector.unprotect(emptyBuf, out, alloc); assertThat(emptyBuf.refCnt()).isEqualTo(1); unprotector.destroy();/*from w w w.ja va2s . c o m*/ }
From source file:io.grpc.alts.internal.AltsTsiFrameProtectorTest.java
License:Apache License
@Test public void parserHeader_frameMaxOk() throws GeneralSecurityException { ByteBufAllocator alloc = ByteBufAllocator.DEFAULT; List<Object> out = new ArrayList<>(); FakeChannelCrypter crypter = new FakeChannelCrypter(); AltsTsiFrameProtector.Unprotector unprotector = new AltsTsiFrameProtector.Unprotector(crypter, alloc); ByteBuf in = getDirectBuffer(AltsTsiFrameProtector.getHeaderBytes() + FakeChannelCrypter.getTagBytes(), ref);/*from w w w . ja v a 2 s . c om*/ in.writeIntLE(AltsTsiFrameProtector.getLimitMaxAllowedFrameBytes() - AltsTsiFrameProtector.getHeaderLenFieldBytes()); in.writeIntLE(6); unprotector.unprotect(in, out, alloc); assertThat(in.readableBytes()).isEqualTo(0); unprotector.destroy(); }