HelloMessage { public static HelloMessage decode(ByteBuf buffer) throws UaException { return new HelloMessage( buffer.readUnsignedIntLE(), buffer.readUnsignedIntLE(), buffer.readUnsignedIntLE(), buffer.readUnsignedIntLE(), buffer.readUnsignedIntLE(), decodeString(buffer) ); } HelloMessage(@UInt32Primitive long protocolVersion,
                        @UInt32Primitive long receiveBufferSize,
                        @UInt32Primitive long sendBufferSize,
                        @UInt32Primitive long maxMessageSize,
                        @UInt32Primitive long maxChunkCount,
                        @Nullable String endpointUrl); @UInt32Primitive long getProtocolVersion(); @UInt32Primitive long getReceiveBufferSize(); @UInt32Primitive long getSendBufferSize(); @UInt32Primitive long getMaxMessageSize(); @UInt32Primitive long getMaxChunkCount(); @Nullable String getEndpointUrl(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static void encode(HelloMessage message, ByteBuf buffer); static HelloMessage decode(ByteBuf buffer);  }
@Test public void testDecodeFailsWhenEndpointUrlTooLarge() throws UaException { for (int i = 0; i < HelloMessage.MAX_ENDPOINT_URL_LENGTH * 2; i++) { ByteBuf buffer = Unpooled.buffer(); buffer.writeIntLE(0); buffer.writeIntLE(8192); buffer.writeIntLE(8192); buffer.writeIntLE(0); buffer.writeIntLE(0); buffer.writeIntLE(i); byte[] bs = new byte[i]; buffer.writeBytes(bs); if (i <= HelloMessage.MAX_ENDPOINT_URL_LENGTH) { assertNotNull(HelloMessage.decode(buffer)); } else { assertThrows(UaException.class, () -> { HelloMessage.decode(buffer); }); } buffer.release(); } }