Java Code Examples for org.apache.qpid.proton.engine.Link#open()
The following examples show how to use
org.apache.qpid.proton.engine.Link#open() .
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: Handshaker.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onLinkRemoteOpen(Event evt) { Link link = evt.getLink(); if (link.getLocalState() == EndpointState.UNINITIALIZED) { link.setSource(link.getRemoteSource()); link.setTarget(link.getRemoteTarget()); link.open(); } }
Example 2
Source File: TransportImplTest.java From qpid-proton-j with Apache License 2.0 | 5 votes |
void doOpenLinkBeforeOpenConnectionTestImpl(boolean receiverLink) { MockTransportImpl transport = new MockTransportImpl(); Connection connection = Proton.connection(); transport.bind(connection); 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), 0, transport.writes.size()); // Now open the connection, expect the Open, Begin, and Attach frames 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); }
Example 3
Source File: TransportImplTest.java From qpid-proton-j with Apache License 2.0 | 4 votes |
void doOpenLinkBeforeOpenSessionTestImpl(boolean receiverLink) { MockTransportImpl transport = new MockTransportImpl(); Connection connection = Proton.connection(); transport.bind(connection); // Open the connection connection.open(); // Create but don't open the session Session session = connection.session(); // Open the link Link link = null; if(receiverLink) { link = session.receiver("myReceiver"); } else { link = session.sender("mySender"); } link.open(); pumpMockTransport(transport); // Expect only an Open frame, no attach should be sent as the session isn't open assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 1, transport.writes.size()); assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open); // Now open the session, expect the Begin 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); // Note: an Attach wasn't sent because link is no longer 'modified' after earlier pump. It // could easily be argued it should, given how the engine generally handles things. Seems // unlikely to be of much real world concern. //assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach); }
Example 4
Source File: TransportImplTest.java From qpid-proton-j with Apache License 2.0 | 4 votes |
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()); }
Example 5
Source File: TransportImplTest.java From qpid-proton-j with Apache License 2.0 | 4 votes |
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()); }
Example 6
Source File: TransportImplTest.java From qpid-proton-j with Apache License 2.0 | 4 votes |
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()); }