org.apache.qpid.proton.codec.AMQPDefinedTypes Java Examples

The following examples show how to use org.apache.qpid.proton.codec.AMQPDefinedTypes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FrameWriterTest.java    From qpid-proton-j with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    AMQPDefinedTypes.registerAllTypes(decoder, encoder);

    buffer = ByteBuffer.allocate(16384);

    encoder.setByteBuffer(buffer);
    decoder.setByteBuffer(buffer);

    Random random = new Random(System.currentTimeMillis());
    bigPayload = ReadableBuffer.ByteBufferReader.allocate(4096);
    for (int i = 0; i < bigPayload.remaining(); ++i) {
        bigPayload.array()[i] = (byte) random.nextInt(127);
    }

    littlePayload = ReadableBuffer.ByteBufferReader.allocate(16);
    for (int i = 0; i < littlePayload.remaining(); ++i) {
        littlePayload.array()[i] = (byte) random.nextInt(127);
    }
}
 
Example #2
Source File: FrameWriterBenchmark.java    From qpid-proton-j with Apache License 2.0 6 votes vote down vote up
public void initProton() {
    byteBuf = ByteBuffer.allocate(DEFAULT_BUFFER_SIZE);
    this.decoder = new DecoderImpl();
    this.encoder = new EncoderImpl(decoder);
    AMQPDefinedTypes.registerAllTypes(decoder, encoder);

    transport = (TransportImpl) Proton.transport();
    frameWriter = new FrameWriter(encoder, 16 * 1024, (byte) 0, transport);

    transfer = new Transfer();
    transfer.setDeliveryId(UnsignedInteger.ONE);
    transfer.setHandle(UnsignedInteger.valueOf(16));
    transfer.setDeliveryTag(new Binary(new byte[] { 0, 1}));
    transfer.setMessageFormat(UnsignedInteger.ZERO);

    payload = ReadableBuffer.ByteBufferReader.wrap(PAYLOAD_BYTES);
}
 
Example #3
Source File: TransportImpl.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a transport with the given maximum frame size.
 * Note that the maximumFrameSize also determines the size of the output buffer.
 */
TransportImpl(int maxFrameSize)
{
    AMQPDefinedTypes.registerAllTypes(_decoder, _encoder);

    _maxFrameSize = maxFrameSize;
    _frameWriter = new FrameWriter(_encoder, _remoteMaxFrameSize,
                                   FrameWriter.AMQP_FRAME_TYPE,
                                   this);
}
 
Example #4
Source File: SaslImpl.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
/**
 * @param maxFrameSize the size of the input and output buffers
 * {@link SaslTransportWrapper#_inputBuffer} and
 * {@link SaslTransportWrapper#_outputBuffer}.
 */
SaslImpl(TransportImpl transport, int maxFrameSize)
{
    _transport = transport;
    _maxFrameSize = maxFrameSize;

    AMQPDefinedTypes.registerAllTypes(_decoder,_encoder);
    _frameParser = new SaslFrameParser(this, _decoder, maxFrameSize, _transport);
    _frameWriter = new FrameWriter(_encoder, maxFrameSize, FrameWriter.SASL_FRAME_TYPE, _transport);
}
 
Example #5
Source File: SaslFrameParserTest.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
public SaslFrameParserTest()
{
    DecoderImpl decoder = new DecoderImpl();
    EncoderImpl encoder = new EncoderImpl(decoder);
    AMQPDefinedTypes.registerAllTypes(decoder,encoder);

    _frameParser = new SaslFrameParser(_mockSaslFrameHandler, decoder, Transport.MIN_MAX_FRAME_SIZE, mockTransport);
    _saslFrameBody = new SaslInit();
    _saslFrameBody.setMechanism(Symbol.getSymbol("unused"));
    _saslFrameBytes = ByteBuffer.wrap(_amqpFramer.generateSaslFrame(0, new byte[0], _saslFrameBody));
}
 
Example #6
Source File: FrameParserTest.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp()
{
    AMQPDefinedTypes.registerAllTypes(_decoder, _encoder);

    when(_mockFrameHandler.isHandlingFrames()).thenReturn(true);
}
 
Example #7
Source File: InteropTest.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
Decoder createDecoder(byte[] data)
{
    DecoderImpl decoder = new DecoderImpl();
    AMQPDefinedTypes.registerAllTypes(decoder, new EncoderImpl(decoder));
    ByteBuffer buffer = ByteBuffer.allocate(data.length);
    buffer.put(data);
    buffer.rewind();
    decoder.setByteBuffer(buffer);

    return decoder;
}
 
Example #8
Source File: MessageBenchmark.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
public void init()
{
    byteBuf = ByteBuffer.allocate(bufferSize());
    this.decoder = new DecoderImpl();
    this.encoder = new EncoderImpl(decoder);
    AMQPDefinedTypes.registerAllTypes(decoder, encoder);
    //initialize encoders
    encoder.setByteBuffer(byteBuf);
    decoder.setByteBuffer(byteBuf);
}
 
Example #9
Source File: AmqpFramer.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public AmqpFramer()
{
    AMQPDefinedTypes.registerAllTypes(_decoder, _encoder);
}