Search in sources :

Example 1 with Session

use of org.apache.qpid.proton.engine.Session in project vertx-proton by vert-x3.

the class ProtonDeliveryImplTest method testAttachments.

@Test
public void testAttachments() {
    Connection conn = Connection.Factory.create();
    Session sess = conn.session();
    Sender s = sess.sender("name");
    Delivery d = s.delivery("myTag".getBytes(StandardCharsets.UTF_8));
    ProtonDeliveryImpl delivery = new ProtonDeliveryImpl(d);
    Record attachments = delivery.attachments();
    assertNotNull("Expected attachments but got null", attachments);
    assertSame("Got different attachments on subsequent call", attachments, delivery.attachments());
    String key = "My-Connection-Key";
    assertNull("Expected attachment to be null", attachments.get(key, Connection.class));
    attachments.set(key, Connection.class, conn);
    assertNotNull("Expected attachment to be returned", attachments.get(key, Connection.class));
    assertSame("Expected attachment to be given object", conn, attachments.get(key, Connection.class));
}
Also used : Sender(org.apache.qpid.proton.engine.Sender) Connection(org.apache.qpid.proton.engine.Connection) Record(org.apache.qpid.proton.engine.Record) Delivery(org.apache.qpid.proton.engine.Delivery) Session(org.apache.qpid.proton.engine.Session) Test(org.junit.Test)

Example 2 with Session

use of org.apache.qpid.proton.engine.Session in project vertx-proton by vert-x3.

the class ProtonSenderImplTest method testAttachments.

@Test
public void testAttachments() {
    Connection conn = Connection.Factory.create();
    Session sess = conn.session();
    Sender s = sess.sender("name");
    ProtonSenderImpl sender = new ProtonSenderImpl(s);
    Record attachments = sender.attachments();
    assertNotNull("Expected attachments but got null", attachments);
    assertSame("Got different attachments on subsequent call", attachments, sender.attachments());
    String key = "My-Connection-Key";
    assertNull("Expected attachment to be null", attachments.get(key, Connection.class));
    attachments.set(key, Connection.class, conn);
    assertNotNull("Expected attachment to be returned", attachments.get(key, Connection.class));
    assertSame("Expected attachment to be given object", conn, attachments.get(key, Connection.class));
}
Also used : Sender(org.apache.qpid.proton.engine.Sender) Connection(org.apache.qpid.proton.engine.Connection) Record(org.apache.qpid.proton.engine.Record) Session(org.apache.qpid.proton.engine.Session) Test(org.junit.Test)

Example 3 with Session

use of org.apache.qpid.proton.engine.Session in project vertx-proton by vert-x3.

the class ProtonSenderImplTest method testAutoSettleIsEnabledByDefault.

@Test
public void testAutoSettleIsEnabledByDefault() {
    Connection conn = Connection.Factory.create();
    Session sess = conn.session();
    Sender s = sess.sender("name");
    ProtonSenderImpl sender = new ProtonSenderImpl(s);
    assertTrue(sender.isAutoSettle());
}
Also used : Sender(org.apache.qpid.proton.engine.Sender) Connection(org.apache.qpid.proton.engine.Connection) Session(org.apache.qpid.proton.engine.Session) Test(org.junit.Test)

Example 4 with Session

use of org.apache.qpid.proton.engine.Session in project vertx-proton by vert-x3.

the class ProtonSessionImplTest method testAttachments.

@Test
public void testAttachments() {
    Connection conn = Connection.Factory.create();
    Session s = conn.session();
    ProtonSessionImpl session = new ProtonSessionImpl(s);
    Record attachments = session.attachments();
    assertNotNull("Expected attachments but got null", attachments);
    assertSame("Got different attachments on subsequent call", attachments, session.attachments());
    String key = "My-Connection-Key";
    assertNull("Expected attachment to be null", attachments.get(key, Connection.class));
    attachments.set(key, Connection.class, conn);
    assertNotNull("Expected attachment to be returned", attachments.get(key, Connection.class));
    assertSame("Expected attachment to be given object", conn, attachments.get(key, Connection.class));
}
Also used : Connection(org.apache.qpid.proton.engine.Connection) Record(org.apache.qpid.proton.engine.Record) Session(org.apache.qpid.proton.engine.Session) Test(org.junit.Test)

Example 5 with Session

use of org.apache.qpid.proton.engine.Session in project vertx-proton by vert-x3.

the class ProtonReceiverImplTest method testAttachments.

@Test
public void testAttachments() {
    Connection conn = Connection.Factory.create();
    Session sess = conn.session();
    Receiver r = sess.receiver("name");
    ProtonReceiverImpl receiver = new ProtonReceiverImpl(r);
    Record attachments = receiver.attachments();
    assertNotNull("Expected attachments but got null", attachments);
    assertSame("Got different attachments on subsequent call", attachments, receiver.attachments());
    String key = "My-Connection-Key";
    assertNull("Expected attachment to be null", attachments.get(key, Connection.class));
    attachments.set(key, Connection.class, conn);
    assertNotNull("Expected attachment to be returned", attachments.get(key, Connection.class));
    assertSame("Expected attachment to be given object", conn, attachments.get(key, Connection.class));
}
Also used : Connection(org.apache.qpid.proton.engine.Connection) ProtonReceiver(io.vertx.proton.ProtonReceiver) Receiver(org.apache.qpid.proton.engine.Receiver) Record(org.apache.qpid.proton.engine.Record) Session(org.apache.qpid.proton.engine.Session) Test(org.junit.Test)

Aggregations

Connection (org.apache.qpid.proton.engine.Connection)7 Session (org.apache.qpid.proton.engine.Session)7 Test (org.junit.Test)7 Record (org.apache.qpid.proton.engine.Record)4 ProtonReceiver (io.vertx.proton.ProtonReceiver)3 Receiver (org.apache.qpid.proton.engine.Receiver)3 Sender (org.apache.qpid.proton.engine.Sender)3 Delivery (org.apache.qpid.proton.engine.Delivery)1