Search in sources :

Example 1 with ProtonByteBufferAllocator

use of org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator in project qpid-protonj2 by apache.

the class ImperativeClientTestCase method createEncodedMessage.

protected byte[] createEncodedMessage(Section<?>... body) {
    Encoder encoder = CodecFactory.getEncoder();
    ProtonBuffer buffer = new ProtonByteBufferAllocator().allocate();
    for (Section<?> section : body) {
        encoder.writeObject(buffer, encoder.newEncoderState(), section);
    }
    byte[] result = new byte[buffer.getReadableBytes()];
    buffer.readBytes(result);
    return result;
}
Also used : ProtonBuffer(org.apache.qpid.protonj2.buffer.ProtonBuffer) Encoder(org.apache.qpid.protonj2.codec.Encoder) ProtonByteBufferAllocator(org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator)

Example 2 with ProtonByteBufferAllocator

use of org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator in project qpid-protonj2 by apache.

the class ProtonEngineTestSupport method createEncodedMessage.

protected byte[] createEncodedMessage(Data... body) {
    Encoder encoder = CodecFactory.getEncoder();
    ProtonBuffer buffer = new ProtonByteBufferAllocator().allocate();
    for (Data data : body) {
        encoder.writeObject(buffer, encoder.newEncoderState(), data);
    }
    byte[] result = new byte[buffer.getReadableBytes()];
    buffer.readBytes(result);
    return result;
}
Also used : ProtonBuffer(org.apache.qpid.protonj2.buffer.ProtonBuffer) Encoder(org.apache.qpid.protonj2.codec.Encoder) ProtonByteBufferAllocator(org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator) Data(org.apache.qpid.protonj2.types.messaging.Data)

Example 3 with ProtonByteBufferAllocator

use of org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator in project qpid-protonj2 by apache.

the class ProtonEngineTestSupport method createEncodedMessage.

protected byte[] createEncodedMessage(Section<Object> body) {
    Encoder encoder = CodecFactory.getEncoder();
    ProtonBuffer buffer = new ProtonByteBufferAllocator().allocate();
    encoder.writeObject(buffer, encoder.newEncoderState(), body);
    byte[] result = new byte[buffer.getReadableBytes()];
    buffer.readBytes(result);
    return result;
}
Also used : ProtonBuffer(org.apache.qpid.protonj2.buffer.ProtonBuffer) Encoder(org.apache.qpid.protonj2.codec.Encoder) ProtonByteBufferAllocator(org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator)

Example 4 with ProtonByteBufferAllocator

use of org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator in project qpid-protonj2 by apache.

the class ProtonEngineTestSupport method createEncodedMessage.

protected byte[] createEncodedMessage(Section<?>... body) {
    Encoder encoder = CodecFactory.getEncoder();
    ProtonBuffer buffer = new ProtonByteBufferAllocator().allocate();
    for (Section<?> section : body) {
        encoder.writeObject(buffer, encoder.newEncoderState(), section);
    }
    byte[] result = new byte[buffer.getReadableBytes()];
    buffer.readBytes(result);
    return result;
}
Also used : ProtonBuffer(org.apache.qpid.protonj2.buffer.ProtonBuffer) Encoder(org.apache.qpid.protonj2.codec.Encoder) ProtonByteBufferAllocator(org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator)

Example 5 with ProtonByteBufferAllocator

use of org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator in project qpid-protonj2 by apache.

the class ImperativeClientTestCase method createEncodedMessage.

protected byte[] createEncodedMessage(Data... body) {
    Encoder encoder = CodecFactory.getEncoder();
    ProtonBuffer buffer = new ProtonByteBufferAllocator().allocate();
    for (Data data : body) {
        encoder.writeObject(buffer, encoder.newEncoderState(), data);
    }
    byte[] result = new byte[buffer.getReadableBytes()];
    buffer.readBytes(result);
    return result;
}
Also used : ProtonBuffer(org.apache.qpid.protonj2.buffer.ProtonBuffer) Encoder(org.apache.qpid.protonj2.codec.Encoder) ProtonByteBufferAllocator(org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator) Data(org.apache.qpid.protonj2.types.messaging.Data)

Aggregations

ProtonBuffer (org.apache.qpid.protonj2.buffer.ProtonBuffer)6 ProtonByteBufferAllocator (org.apache.qpid.protonj2.buffer.ProtonByteBufferAllocator)6 Encoder (org.apache.qpid.protonj2.codec.Encoder)6 Data (org.apache.qpid.protonj2.types.messaging.Data)2