DataTypeDictionaryReader { CompletableFuture<ByteString> readDataTypeDictionaryBytes(NodeId nodeId, int fragmentSize) { CompositeByteBuf fragmentBuffer = Unpooled.compositeBuffer(); CompletableFuture<ByteBuf> future = readFragments( nodeId, fragmentBuffer, fragmentSize, 0 ); return future.thenApply(buffer -> { int length = buffer.readableBytes(); for (int i = buffer.writerIndex() - 1; i >= 0; i--) { byte lastByte = buffer.getByte(i); boolean empty = (lastByte == 0 || Character.isWhitespace(lastByte) || Character.isSpaceChar(lastByte)); if (!empty) break; else length -= 1; } byte[] bs = new byte[length]; buffer.readBytes(bs, 0, length); if (logger.isDebugEnabled()) { String xmlString = new String(bs); logger.debug("Dictionary XML: {}", xmlString); } return ByteString.of(bs); }); } DataTypeDictionaryReader(
        UaStackClient stackClient,
        OpcUaSession session,
        BsdParser bsdParser); CompletableFuture<List<DataTypeDictionary<?>>> readDataTypeDictionaries();  }
@Test void testReadDataTypeDictionaryBytes() throws Exception { int[] fragmentSizes = new int[]{1, 2, 1024, 2048, 4096, 8192}; int[] dictionarySizes = new int[]{1, 2, 1024, 1025, 2048, 2049, 4096, 4097, 8192, 8193, 65535, 65536}; for (int fragmentSize : fragmentSizes) { for (int dictionarySize : dictionarySizes) { byte[] dictionary = new byte[dictionarySize]; for (int i = 0; i < dictionarySize; i++) { byte b = (byte) i; if (b == 0) b++; dictionary[i] = b; } System.out.printf("fragmentSize=%d dictionarySize=%d\n", fragmentSize, dictionarySize); testReadDataTypeDictionaryBytes(ByteString.of(dictionary), fragmentSize); } } }