@Test
public void block1_request_BERT_multiblock() throws Exception {

    capabilities.put(LOCAL_5683, new CoapTcpCSM(1250, true));
    protoServer.init(10, scheduledExecutor, false, midSupplier, 1, CoapTransaction.Priority.NORMAL, 0, DuplicatedCoapMessageCallback.NULL);
    server.start();
    byte[] payloadBlock1 = generatePayload(0, 4096).toByteArray();
    byte[] payloadBlock2 = generatePayload(4, 2048).toByteArray();
    ByteArrayOutputStream payloadBlockFinalOs = generatePayload(6, 1024);
    payloadBlockFinalOs.write("end_of_payload".getBytes());
    byte[] payloadFinal = payloadBlockFinalOs.toByteArray();
    final ByteArrayOutputStream fullPayload = new ByteArrayOutputStream(payloadBlock1.length + payloadBlock2.length + payloadFinal.length);
    fullPayload.write(payloadBlock1);
    fullPayload.write(payloadBlock2);
    fullPayload.write(payloadFinal);
    server.addRequestHandler("/block", exchange -> {
        if (Arrays.equals(exchange.getRequestBody(), fullPayload.toByteArray())) {
            exchange.setResponseCode(Code.C204_CHANGED);
            exchange.sendResponse();
        } else {
            exchange.sendResetResponse();
        }
    });
    CoapPacket pkt = newCoapPacket(LOCAL_5683).mid(10).token(0x1234).put().block1Req(0, BlockSize.S_1024_BERT, true).uriPath("/block").build();
    pkt.setPayload(payloadBlock1);
    receive(pkt);
    assertSent(newCoapPacket(LOCAL_5683).mid(10).token(0x1234).ack(Code.C231_CONTINUE).block1Req(0, BlockSize.S_1024_BERT, true));
    pkt = newCoapPacket(LOCAL_5683).mid(11).token(0x1235).put().block1Req(4, BlockSize.S_1024_BERT, true).uriPath("/block").build();
    pkt.setPayload(payloadBlock2);
    receive(pkt);
    assertSent(newCoapPacket(LOCAL_5683).mid(11).token(0x1235).ack(Code.C231_CONTINUE).block1Req(4, BlockSize.S_1024_BERT, true));
    pkt = newCoapPacket(LOCAL_5683).mid(12).token(0x1236).put().block1Req(6, BlockSize.S_1024_BERT, false).uriPath("/block").build();
    pkt.setPayload(payloadFinal);
    receive(pkt);
    assertSent(newCoapPacket(LOCAL_5683).mid(12).token(0x1236).ack(Code.C204_CHANGED).block1Req(6, BlockSize.S_1024_BERT, false));
}