use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.
the class ConfigUsingDestinationOptionsTest method testInvalidSelectorConfig.
@Test(timeout = 60000)
public void testInvalidSelectorConfig() throws JMSException {
ActiveMQQueue queue = new ActiveMQQueue("TEST.FOO?consumer.selector=test||1");
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
Connection conn = factory.createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQMessageConsumer cons;
// JMS selector should be priority
try {
cons = (ActiveMQMessageConsumer) sess.createConsumer(queue, "test||1");
fail("Selector should be invalid" + cons);
} catch (InvalidSelectorException e) {
}
// Test setting using JMS destinations
try {
cons = (ActiveMQMessageConsumer) sess.createConsumer(queue);
fail("Selector should be invalid" + cons);
} catch (InvalidSelectorException e) {
}
}
use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.
the class DestinationMapTest method testQueueAndTopicWithSameName.
public void testQueueAndTopicWithSameName() throws Exception {
ActiveMQQueue q1 = new ActiveMQQueue("foo");
ActiveMQTopic t1 = new ActiveMQTopic("foo");
map.put(q1, v1);
map.put(t1, v2);
assertMapValue(q1, v1);
assertMapValue(t1, v2);
}
use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.
the class ActiveMQInitialContextFactoryTest method testDestinationsArePresent.
public void testDestinationsArePresent() throws NamingException {
// Retrieving destinations context is not yet implemented on the broker.
// For this test, a jndi file properties will be used.
InitialContext context = new InitialContext();
Object topicDestination = context.lookup("MyTopic");
// check if MyTopic is an ActiveMQTopic
assertTrue("Should have found a topic but found: " + topicDestination, topicDestination instanceof ActiveMQTopic);
Object queueDestination = context.lookup("MyQueue");
// check if MyQueue is an ActiveMQueue
assertTrue("Should have found a queue but found: " + queueDestination, queueDestination instanceof ActiveMQQueue);
}
use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.
the class ActiveMQInitialContextFactoryTest method testDynamicallyGrowing.
public void testDynamicallyGrowing() throws Exception {
Object answer = context.lookup("dynamicQueues/FOO.BAR");
assertTrue("Should have found a queue but found: " + answer, answer instanceof ActiveMQQueue);
ActiveMQQueue queue = (ActiveMQQueue) answer;
assertEquals("queue name", "FOO.BAR", queue.getPhysicalName());
answer = context.lookup("dynamicTopics/A.B.C");
assertTrue("Should have found a topic but found: " + answer, answer instanceof ActiveMQTopic);
ActiveMQTopic topic = (ActiveMQTopic) answer;
assertEquals("topic name", "A.B.C", topic.getPhysicalName());
}
use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.
the class BasicSecurityTest method testSendnReceiveAuthorization.
@Test
public void testSendnReceiveAuthorization() throws Exception {
Connection sendingConn = null;
Connection receivingConn = null;
// Sender
try {
Destination dest = new ActiveMQQueue(queueName);
receivingConn = factory.createConnection("openwireReceiver", "ReCeIvEr");
receivingConn.start();
sendingConn = factory.createConnection("openwireSender", "SeNdEr");
sendingConn.start();
Session sendingSession = sendingConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session receivingSession = receivingConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
TextMessage message = sendingSession.createTextMessage("Hello World");
MessageProducer producer = null;
producer = receivingSession.createProducer(dest);
try {
producer.send(message);
} catch (JMSSecurityException e) {
// expected
producer.close();
}
producer = sendingSession.createProducer(dest);
producer.send(message);
MessageConsumer consumer;
try {
consumer = sendingSession.createConsumer(dest);
Assert.fail("exception expected");
} catch (JMSSecurityException e) {
e.printStackTrace();
// expected
}
consumer = receivingSession.createConsumer(dest);
TextMessage received = (TextMessage) consumer.receive(5000);
assertNotNull(received);
assertEquals("Hello World", received.getText());
} finally {
if (sendingConn != null) {
sendingConn.close();
}
if (receivingConn != null) {
receivingConn.close();
}
}
}
Aggregations