Search in sources :

Example 1 with Record

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

the class ProtonConnectionImplTest method testAttachments.

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

Example 2 with Record

use of org.apache.qpid.proton.engine.Record 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 3 with Record

use of org.apache.qpid.proton.engine.Record 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 4 with Record

use of org.apache.qpid.proton.engine.Record 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 Record

use of org.apache.qpid.proton.engine.Record in project hono by eclipse.

the class TestSupport method newMockSender.

@SuppressWarnings("unchecked")
public static ProtonSender newMockSender(final boolean drainFlag) {
    @SuppressWarnings("rawtypes") final ArgumentCaptor<Handler> drainHandlerCaptor = ArgumentCaptor.forClass(Handler.class);
    Record attachments = mock(Record.class);
    ProtonSender sender = mock(ProtonSender.class);
    when(sender.attachments()).thenReturn(attachments);
    when(sender.isOpen()).thenReturn(Boolean.TRUE);
    when(sender.getCredit()).thenReturn(DEFAULT_CREDITS);
    when(sender.getQueued()).thenReturn(0);
    when(sender.getDrain()).thenReturn(drainFlag);
    when(sender.open()).then(invocation -> {
        drainHandlerCaptor.getValue().handle(sender);
        return sender;
    });
    when(sender.sendQueueDrainHandler(drainHandlerCaptor.capture())).then(invocation -> {
        return sender;
    });
    Target target = new Target();
    target.setAddress(DEFAULT_ADDRESS);
    when(sender.getTarget()).thenReturn(target);
    return sender;
}
Also used : ProtonSender(io.vertx.proton.ProtonSender) Target(org.apache.qpid.proton.amqp.messaging.Target) Handler(io.vertx.core.Handler) Record(org.apache.qpid.proton.engine.Record)

Aggregations

Record (org.apache.qpid.proton.engine.Record)11 Test (org.junit.Test)5 ProtonConnection (io.vertx.proton.ProtonConnection)4 Connection (org.apache.qpid.proton.engine.Connection)4 Session (org.apache.qpid.proton.engine.Session)4 RecordImpl (org.apache.qpid.proton.engine.impl.RecordImpl)4 Handler (io.vertx.core.Handler)3 ProtonReceiver (io.vertx.proton.ProtonReceiver)2 ProtonSender (io.vertx.proton.ProtonSender)2 Sender (org.apache.qpid.proton.engine.Sender)2 Vertx (io.vertx.core.Vertx)1 Target (org.apache.qpid.proton.amqp.messaging.Target)1 Delivery (org.apache.qpid.proton.engine.Delivery)1 Receiver (org.apache.qpid.proton.engine.Receiver)1