use of org.apache.qpid.proton.engine.Sender in project activemq-artemis by apache.
the class AmqpTransactionTest method testSentTransactionalMessageIsSettleWithTransactionalDisposition.
@Test(timeout = 30000)
public void testSentTransactionalMessageIsSettleWithTransactionalDisposition() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
assertNotNull(session);
AmqpSender sender = session.createSender(getQueueName());
sender.setStateInspector(new AmqpValidator() {
@Override
public void inspectDeliveryUpdate(Sender sender, Delivery delivery) {
if (delivery.remotelySettled()) {
DeliveryState state = delivery.getRemoteState();
if (state instanceof TransactionalState) {
LOG.debug("Remote settled with TX state: {}", state);
} else {
LOG.warn("Remote settled with non-TX state: {}", state);
markAsInvalid("Remote did not settled with TransactionState.");
}
}
}
});
session.begin();
assertTrue(session.isInTransaction());
AmqpMessage message = new AmqpMessage();
message.setText("Test-Message");
sender.send(message);
session.commit();
sender.getStateInspector().assertValid();
connection.close();
}
use of org.apache.qpid.proton.engine.Sender 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.Sender 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());
}
use of org.apache.qpid.proton.engine.Sender 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.Sender in project activemq-artemis by apache.
the class AmqpSecurityTest method testSendAndRejected.
@Test(timeout = 60000)
public void testSendAndRejected() throws Exception {
AmqpClient client = createAmqpClient(guestUser, guestPass);
client.setValidator(new AmqpValidator() {
@Override
public void inspectOpenedResource(Sender sender) {
ErrorCondition condition = sender.getRemoteCondition();
if (condition != null && condition.getCondition() != null) {
if (!condition.getCondition().equals(AmqpError.UNAUTHORIZED_ACCESS)) {
markAsInvalid("Should have been tagged with unauthorized access error");
}
} else {
markAsInvalid("Sender should have been opened with an error");
}
}
});
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
try {
try {
session.createSender(getQueueName());
fail("Should not be able to consume here.");
} catch (Exception ex) {
IntegrationTestLogger.LOGGER.info("Caught expected exception");
}
connection.getStateInspector().assertValid();
} finally {
connection.close();
}
}
Aggregations