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));
}
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));
}
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));
}
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));
}
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;
}
Aggregations