use of javax.jms.TemporaryQueue in project qpid-broker-j by apache.
the class AuthenticationTest method assertPlainConnectivity.
private void assertPlainConnectivity(final int port, final String mechanism) throws Exception {
final Connection connection = getConnectionBuilder().setPort(port).setUsername(USER).setPassword(USER_PASSWORD).setSaslMechanisms(mechanism).build();
try {
final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
final TemporaryQueue queue = session.createTemporaryQueue();
assertNotNull("Temporary queue was not created", queue);
} finally {
connection.close();
}
try {
getConnectionBuilder().setPort(port).setUsername(USER).setPassword("invalid" + USER_PASSWORD).setSaslMechanisms(mechanism).build();
fail("Connection is established for invalid password");
} catch (JMSException e) {
// pass
}
try {
getConnectionBuilder().setPort(port).setUsername("invalid" + AuthenticationTest.USER).setPassword(USER_PASSWORD).setSaslMechanisms(mechanism).build();
fail("Connection is established for invalid user name");
} catch (JMSException e) {
// pass
}
}
use of javax.jms.TemporaryQueue in project qpid-broker-j by apache.
the class TemporaryQueueTest method testConsumeFromAnotherConnectionUsingTemporaryQueueName.
@Test
public void testConsumeFromAnotherConnectionUsingTemporaryQueueName() throws Exception {
final Connection connection = getConnection();
try {
final Connection connection2 = getConnection();
try {
final Session session1 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
final Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
final TemporaryQueue queue = session1.createTemporaryQueue();
assertNotNull("Temporary queue cannot be null", queue);
try {
session2.createConsumer(session2.createQueue(queue.getQueueName()));
fail("Expected a JMSException when subscribing to a temporary queue created on a different session");
} catch (JMSException je) {
// pass
}
} finally {
connection2.close();
}
} finally {
connection.close();
}
}
use of javax.jms.TemporaryQueue in project qpid-broker-j by apache.
the class TemporaryQueueTest method testConsumeFromAnotherConnectionProhibited.
@Test
public void testConsumeFromAnotherConnectionProhibited() throws Exception {
final Connection connection = getConnection();
try {
final Connection connection2 = getConnection();
try {
final Session session1 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
final Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
final TemporaryQueue queue = session1.createTemporaryQueue();
assertNotNull("Temporary queue cannot be null", queue);
try {
session2.createConsumer(queue);
fail("Expected a JMSException when subscribing to a temporary queue created on a different session");
} catch (JMSException je) {
// pass
}
} finally {
connection2.close();
}
} finally {
connection.close();
}
}
use of javax.jms.TemporaryQueue in project qpid-broker-j by apache.
the class TemporaryQueueTest method testExplicitTemporaryQueueDeletion.
@Test
public void testExplicitTemporaryQueueDeletion() throws Exception {
int numberOfQueuesBeforeTest = getQueueCount();
final Connection connection = getConnection();
try {
final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
final TemporaryQueue queue = session.createTemporaryQueue();
assertNotNull("Temporary queue cannot be null", queue);
final MessageConsumer consumer = session.createConsumer(queue);
connection.start();
try {
queue.delete();
fail("Expected JMSException : should not be able to delete while there are active consumers");
} catch (JMSException je) {
// pass
}
int numberOfQueuesAfterQueueDelete = getQueueCount();
assertEquals("Unexpected number of queue", 1, numberOfQueuesAfterQueueDelete - numberOfQueuesBeforeTest);
consumer.close();
// Now deletion should succeed.
queue.delete();
try {
session.createConsumer(queue);
fail("Exception not thrown");
} catch (JMSException je) {
// pass
}
} finally {
connection.close();
}
}
use of javax.jms.TemporaryQueue in project qpid-broker-j by apache.
the class TemporaryQueueTest method delete.
@Test
public void delete() throws Exception {
Connection connection = getConnectionBuilder().setSyncPublish(true).build();
try {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue queue = session.createTemporaryQueue();
MessageProducer producer = session.createProducer(queue);
try {
producer.send(session.createTextMessage("hello"));
} catch (JMSException e) {
fail("Send to temporary queue should succeed");
}
try {
queue.delete();
} catch (JMSException e) {
fail("temporary queue should be deletable");
}
try {
producer.send(session.createTextMessage("hello"));
fail("Send to deleted temporary queue should not succeed");
} catch (JMSException e) {
// pass
}
} finally {
connection.close();
}
}
Aggregations