• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TransportFrame类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.qpid.proton.framing.TransportFrame的典型用法代码示例。如果您正苦于以下问题:Java TransportFrame类的具体用法?Java TransportFrame怎么用?Java TransportFrame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TransportFrame类属于org.apache.qpid.proton.framing包,在下文中一共展示了TransportFrame类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handleFrame

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
@Override
public boolean handleFrame(TransportFrame frame)
{
    if (!isHandlingFrames())
    {
        throw new IllegalStateException("Transport cannot accept frame: " + frame);
    }

    log(INCOMING, frame);

    ProtocolTracer tracer = _protocolTracer.get();
    if( tracer != null )
    {
        tracer.receivedFrame(frame);
    }

    frame.getBody().invoke(this,frame.getPayload(), frame.getChannel());
    return _closeReceived;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:20,代码来源:TransportImpl.java


示例2: log

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
void log(String event, TransportFrame frame)
{
    if (isTraceFramesEnabled()) {
        StringBuilder msg = new StringBuilder();
        msg.append("[").append(System.identityHashCode(this)).append(":")
            .append(frame.getChannel()).append("]");
        msg.append(" ").append(event).append(" ").append(frame.getBody());

        Binary bin = frame.getPayload();
        if (bin != null) {
            msg.append(" (").append(bin.getLength()).append(") ");
            msg.append(StringUtils.toQuotedString(bin, TRACE_FRAME_PAYLOAD_LENGTH, true));
        }
        System.out.println(msg.toString());
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:17,代码来源:TransportImpl.java


示例3: handleTransfer

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
private void handleTransfer(TransportImpl transport, int deliveryNumber, String deliveryTag, String messageContent)
{
    byte[] tag = deliveryTag.getBytes(StandardCharsets.UTF_8);

    Message m = Message.Factory.create();
    m.setBody(new AmqpValue(messageContent));

    byte[] encoded = new byte[BUFFER_SIZE];
    int len = m.encode(encoded, 0, BUFFER_SIZE);

    assertTrue("given array was too small", len < BUFFER_SIZE);

    Transfer transfer = new Transfer();
    transfer.setDeliveryId(UnsignedInteger.valueOf(deliveryNumber));
    transfer.setHandle(UnsignedInteger.ZERO);
    transfer.setDeliveryTag(new Binary(tag));
    transfer.setMessageFormat(UnsignedInteger.valueOf(DeliveryImpl.DEFAULT_MESSAGE_FORMAT));

    transport.handleFrame(new TransportFrame(0, transfer, new Binary(encoded, 0, len)));
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:21,代码来源:TransportImplTest.java


示例4: matches

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
@Override
public boolean matches(Object transportFrameObj)
{
    if(transportFrameObj == null)
    {
        return false;
    }

    TransportFrame transportFrame = (TransportFrame)transportFrameObj;
    FrameBody actualFrame = transportFrame.getBody();

    int _expectedChannel = _expectedTransportFrame.getChannel();
    FrameBody expectedFrame = _expectedTransportFrame.getBody();

    return _expectedChannel == transportFrame.getChannel()
            && expectedFrame.getClass().equals(actualFrame.getClass());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:18,代码来源:FrameParserTest.java


示例5: testTickRemoteTimeout

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
@Test
public void testTickRemoteTimeout()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    int timeout = 4000;
    Open open = new Open();
    open.setIdleTimeOut(new UnsignedInteger(4000));
    TransportFrame openFrame = new TransportFrame(CHANNEL_ID, open, null);
    transport.handleFrame(openFrame);
    pumpMockTransport(transport);

    long deadline = transport.tick(0);
    assertEquals("Expected to be returned a deadline of 2000",  2000, deadline);  // deadline = 4000 / 2

    deadline = transport.tick(1000);    // Wait for less than the deadline with no data - get the same value
    assertEquals("When the deadline hasn't been reached tick() should return the previous deadline",  2000, deadline);
    assertEquals("When the deadline hasn't been reached tick() shouldn't write data", 0, transport.writes.size());

    deadline = transport.tick(timeout/2); // Wait for the deadline - next deadline should be (4000/2)*2
    assertEquals("When the deadline has been reached expected a new deadline to be returned 4000",  4000, deadline);
    assertEquals("tick() should have written data", 1, transport.writes.size());
    assertEquals("tick() should have written an empty frame", null, transport.writes.get(0));

    transport.writeFrame(CHANNEL_ID, new Begin(), null, null);
    while(transport.pending() > 0) transport.pop(transport.head().remaining());
    int framesWrittenBeforeTick = transport.writes.size();
    deadline = transport.tick(3000);
    assertEquals("Writing data resets the deadline",  5000, deadline);
    assertEquals("When the deadline is reset tick() shouldn't write an empty frame", 0, transport.writes.size() - framesWrittenBeforeTick);

    transport.writeFrame(CHANNEL_ID, new Attach(), null, null);
    assertTrue(transport.pending() > 0);
    framesWrittenBeforeTick = transport.writes.size();
    deadline = transport.tick(4000);
    assertEquals("Having pending data does not reset the deadline",  5000, deadline);
    assertEquals("Having pending data prevents tick() from sending an empty frame", 0, transport.writes.size() - framesWrittenBeforeTick);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:41,代码来源:TransportImplTest.java


示例6: testSessionBeginAfterCloseSent

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
/**
 * Verify that no Begin frame is emitted by the Transport should a Session open
 * after the Close frame was sent.
 */
@Test
public void testSessionBeginAfterCloseSent()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 1, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);

    // Send the necessary response to Open
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 1, transport.writes.size());

    // Cause a Close frame to be sent
    connection.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Close);

    // Open the session and verify the transport doesn't
    // send any Begin frame, as a Close frame was sent already.
    session.open();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:41,代码来源:TransportImplTest.java


示例7: receivedFrame

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
@Override
public void receivedFrame(TransportFrame transportFrame) {
   if (connection.isTraceFrames()) {
      TRACE_FRAMES.trace("{} | RECV: {}", connection.getRemoteURI(), transportFrame.getBody());
   }

   AmqpFrameValidator inspector = connection.getReceivedFrameInspector();
   if (inspector != null) {
      transportFrame.getBody().invoke(this, transportFrame.getPayload(), inspector);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:AmqpProtocolTracer.java


示例8: sentFrame

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
@Override
public void sentFrame(TransportFrame transportFrame) {
   if (connection.isTraceFrames()) {
      TRACE_FRAMES.trace("{} | SENT: {}", connection.getRemoteURI(), transportFrame.getBody());
   }

   AmqpFrameValidator inspector = connection.getSentFrameInspector();
   if (inspector != null) {
      transportFrame.getBody().invoke(this, transportFrame.getPayload(), inspector);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:AmqpProtocolTracer.java


示例9: receivedFrame

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
@Override
public void receivedFrame(TransportFrame transportFrame)
{
    RECEIVED_LOGGER.finer(_logMessagePrefix + " received frame: " + transportFrame);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:6,代码来源:LoggingProtocolTracer.java


示例10: sentFrame

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
@Override
public void sentFrame(TransportFrame transportFrame)
{
    SENT_LOGGER.finer(_logMessagePrefix + " writing frame: " + transportFrame);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:6,代码来源:LoggingProtocolTracer.java


示例11: writeFrame

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
void writeFrame(int channel, Object frameBody, ByteBuffer payload,
                Runnable onPayloadTooLarge)
{
    startFrame();

    writePerformative(frameBody);

    if(_maxFrameSize > 0 && payload != null && (payload.remaining() + _performativeSize) > _maxFrameSize)
    {
        if(onPayloadTooLarge != null)
        {
            onPayloadTooLarge.run();
        }
        writePerformative(frameBody);
    }

    int capacity;
    if (_maxFrameSize > 0) {
        capacity = _maxFrameSize - _performativeSize;
    } else {
        capacity = Integer.MAX_VALUE;
    }
    int payloadSize = Math.min(payload == null ? 0 : payload.remaining(), capacity);

    ProtocolTracer tracer = _protocolTracer == null ? null : _protocolTracer.get();
    if( tracer != null || _transport.isTraceFramesEnabled())
    {
        // XXX: this is a bit of a hack but it eliminates duplicate
        // code, further refactor will fix this
        if (_frameType == AMQP_FRAME_TYPE)
        {
            ByteBuffer originalPayload = null;
            if( payload!=null )
            {
                originalPayload = payload.duplicate();
                originalPayload.limit(payload.position() + payloadSize);
            }

            Binary payloadBin = Binary.create(originalPayload);
            FrameBody body = null;
            if (frameBody == null)
            {
                body = new EmptyFrame();
            }
            else
            {
                body = (FrameBody) frameBody;
            }

            TransportFrame frame = new TransportFrame(channel, body, payloadBin);

            _transport.log(TransportImpl.OUTGOING, frame);

            if(tracer != null)
            {
                tracer.sentFrame(frame);
            }
        }
    }

    if(payloadSize > 0)
    {
        while (_buffer.remaining() < payloadSize) {
            grow();
        }

        int oldLimit = payload.limit();
        payload.limit(payload.position() + payloadSize);
        _buffer.put(payload);
        payload.limit(oldLimit);
    }

    endFrame(channel);

    _framesOutput += 1;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:77,代码来源:FrameWriter.java


示例12: doLinkAttachAfterEndSentTestImpl

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
void doLinkAttachAfterEndSentTestImpl(boolean receiverLink)
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    Link link = null;
    if(receiverLink)
    {
        link = session.receiver("myReceiver");
    }
    else
    {
        link = session.sender("mySender");
    }

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);

    // Send the necessary responses to open/begin
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    // Cause a End frame to be sent
    session.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof End);

    // Open the link and verify the transport doesn't
    // send any Attach frame, as an End frame was sent already.
    link.open();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:52,代码来源:TransportImplTest.java


示例13: doLinkDetachAfterEndSentTestImpl

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
void doLinkDetachAfterEndSentTestImpl(boolean receiverLink)
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    Link link = null;
    if(receiverLink)
    {
        link = session.receiver("myReceiver");
    }
    else
    {
        link = session.sender("mySender");
    }
    link.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);

    // Send the necessary responses to open/begin
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    // Cause an End frame to be sent
    session.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(3) instanceof End);

    // Close the link and verify the transport doesn't
    // send any Detach frame, as an End frame was sent already.
    link.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:54,代码来源:TransportImplTest.java


示例14: testSenderSendBeforeOpenConnection

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
@Test
public void testSenderSendBeforeOpenConnection()
{
    MockTransportImpl transport = new MockTransportImpl();

    Connection connection = Proton.connection();
    transport.bind(connection);

    Collector collector = Collector.Factory.create();
    connection.collect(collector);

    Session session = connection.session();
    session.open();

    String linkName = "mySender";
    Sender sender = session.sender(linkName);
    sender.open();

    sendMessage(sender, "tag1", "content1");

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());

    // Now open the connection, expect the Open and Begin and Attach frames but
    // nothing else as we the sender wont have credit yet.
    connection.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);

    // Send the necessary responses to open/begin/attach then give sender credit
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    Attach attach = new Attach();
    attach.setHandle(UnsignedInteger.ZERO);
    attach.setRole(Role.RECEIVER);
    attach.setName(linkName);
    attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
    transport.handleFrame(new TransportFrame(0, attach, null));

    Flow flow = new Flow();
    flow.setHandle(UnsignedInteger.ZERO);
    flow.setDeliveryCount(UnsignedInteger.ZERO);
    flow.setNextIncomingId(UnsignedInteger.ONE);
    flow.setNextOutgoingId(UnsignedInteger.ZERO);
    flow.setIncomingWindow(UnsignedInteger.valueOf(1024));
    flow.setOutgoingWindow(UnsignedInteger.valueOf(1024));
    flow.setLinkCredit(UnsignedInteger.valueOf(10));

    transport.handleFrame(new TransportFrame(0, flow, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    // Now pump the transport again and expect a transfer for the message
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Transfer);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:70,代码来源:TransportImplTest.java


示例15: testSessionEndAfterCloseSent

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
/**
 * Verify that no End frame is emitted by the Transport should a Session close
 * after the Close frame was sent.
 */
@Test
public void testSessionEndAfterCloseSent()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);

    // Send the necessary responses to open/begin
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    // Cause a Close frame to be sent
    connection.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Close);

    // Close the session and verify the transport doesn't
    // send any End frame, as a Close frame was sent already.
    session.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:47,代码来源:TransportImplTest.java


示例16: doLinkAttachAfterCloseSentTestImpl

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
void doLinkAttachAfterCloseSentTestImpl(boolean receiverLink)
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    Link link = null;
    if(receiverLink)
    {
        link = session.receiver("myReceiver");
    }
    else
    {
        link = session.sender("mySender");
    }

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);

    // Send the necessary responses to open/begin
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    // Cause a Close frame to be sent
    connection.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Close);

    // Open the link and verify the transport doesn't
    // send any Attach frame, as a Close frame was sent already.
    link.open();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:52,代码来源:TransportImplTest.java


示例17: testReceiverFlowAfterCloseSent

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
/**
 * Verify that no Flow frame is emitted by the Transport should a Receiver
 * have credit added after the Close frame was sent.
 */
@Test
public void testReceiverFlowAfterCloseSent()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    String linkName = "myReceiver";
    Receiver receiver = session.receiver(linkName);
    receiver.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);

    // Send the necessary responses to open/begin/attach
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    Attach attach = new Attach();
    attach.setHandle(UnsignedInteger.ZERO);
    attach.setRole(Role.RECEIVER);
    attach.setName(linkName);
    attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
    transport.handleFrame(new TransportFrame(0, attach, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    // Cause the Close frame to be sent
    connection.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Close);

    // Grant new credit for the Receiver and verify the transport doesn't
    // send any Flow frame, as a Close frame was sent already.
    receiver.flow(1);
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:59,代码来源:TransportImplTest.java


示例18: testNoReceiverFlowAfterDetachSentWhileDraining

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
/**
 * Verify that no Flow frame is emitted by the Transport should a Receiver
 * have pending drain when a detach is sent for that receiver.
 */
@Test
public void testNoReceiverFlowAfterDetachSentWhileDraining()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    String linkName = "myReceiver";
    Receiver receiver = session.receiver(linkName);
    receiver.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);

    // Send the necessary responses to open/begin/attach
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    Attach attach = new Attach();
    attach.setHandle(UnsignedInteger.ZERO);
    attach.setRole(Role.RECEIVER);
    attach.setName(linkName);
    attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
    transport.handleFrame(new TransportFrame(0, attach, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    // Start a drain for the Receiver and verify the transport doesn't
    // send any Flow frame, due to the detach being initiated.
    receiver.drain(10);
    pumpMockTransport(transport);

    // Cause the Detach frame to be sent
    receiver.detach();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 5, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(4) instanceof Detach);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:57,代码来源:TransportImplTest.java


示例19: testDispositionAfterCloseSent

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
/**
 * Verify that no Disposition frame is emitted by the Transport should a Delivery
 * have disposition applied after the Close frame was sent.
 */
@Test
public void testDispositionAfterCloseSent()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    String linkName = "myReceiver";
    Receiver receiver = session.receiver(linkName);
    receiver.flow(5);
    receiver.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
    assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Flow);

    Delivery delivery = receiver.current();
    assertNull("Should not yet have a delivery", delivery);

    // Send the necessary responses to open/begin/attach as well as a transfer
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    begin.setNextOutgoingId(UnsignedInteger.ONE);
    begin.setIncomingWindow(UnsignedInteger.valueOf(1024));
    begin.setOutgoingWindow(UnsignedInteger.valueOf(1024));
    transport.handleFrame(new TransportFrame(0, begin, null));

    Attach attach = new Attach();
    attach.setHandle(UnsignedInteger.ZERO);
    attach.setRole(Role.SENDER);
    attach.setName(linkName);
    attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
    transport.handleFrame(new TransportFrame(0, attach, null));

    String deliveryTag = "tag1";
    String messageContent = "content1";
    handleTransfer(transport, 1, deliveryTag, messageContent);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());

    delivery = verifyDelivery(receiver, deliveryTag, messageContent);
    assertNotNull("Should now have a delivery", delivery);

    // Cause the Close frame to be sent
    connection.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 5, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(4) instanceof Close);

    delivery.disposition(Released.getInstance());
    delivery.settle();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 5, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:74,代码来源:TransportImplTest.java


示例20: testTransferAfterCloseSent

import org.apache.qpid.proton.framing.TransportFrame; //导入依赖的package包/类
/**
 * Verify that no Transfer frame is emitted by the Transport should a Delivery
 * be sendable after the Close frame was sent.
 */
@Test
public void testTransferAfterCloseSent()
{
    MockTransportImpl transport = new MockTransportImpl();

    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Collector collector = Collector.Factory.create();
    connection.collect(collector);

    Session session = connection.session();
    session.open();

    String linkName = "mySender";
    Sender sender = session.sender(linkName);
    sender.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);

    // Send the necessary responses to open/begin/attach then give sender credit
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    Attach attach = new Attach();
    attach.setHandle(UnsignedInteger.ZERO);
    attach.setRole(Role.RECEIVER);
    attach.setName(linkName);
    attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
    transport.handleFrame(new TransportFrame(0, attach, null));

    Flow flow = new Flow();
    flow.setHandle(UnsignedInteger.ZERO);
    flow.setDeliveryCount(UnsignedInteger.ZERO);
    flow.setNextIncomingId(UnsignedInteger.ONE);
    flow.setNextOutgoingId(UnsignedInteger.ZERO);
    flow.setIncomingWindow(UnsignedInteger.valueOf(1024));
    flow.setOutgoingWindow(UnsignedInteger.valueOf(1024));
    flow.setLinkCredit(UnsignedInteger.valueOf(10));

    transport.handleFrame(new TransportFrame(0, flow, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    // Cause the Close frame to be sent
    connection.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Close);

    // Send a new message and verify the transport doesn't
    // send any Transfer frame, as a Close frame was sent already.
    sendMessage(sender, "tag1", "content1");
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:74,代码来源:TransportImplTest.java



注:本文中的org.apache.qpid.proton.framing.TransportFrame类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DummyLibraryProperties类代码示例发布时间:2022-05-22
下一篇:
Java DynFixed类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap