ARTEMIS-2880 support FQQN syntax for JNDI lookup
This commit is contained in:
parent
582a430213
commit
57b8c22a62
|
@ -215,7 +215,7 @@ public class ReadOnlyContext implements Context, Serializable {
|
|||
}
|
||||
if (result == null) {
|
||||
int pos = name.indexOf(':');
|
||||
if (pos > 0) {
|
||||
if (pos > 0 && !name.contains("::")) {
|
||||
String scheme = name.substring(0, pos);
|
||||
Context ctx = NamingManager.getURLContext(scheme, environment);
|
||||
if (ctx == null) {
|
||||
|
|
|
@ -60,6 +60,7 @@ import org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory;
|
|||
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.utils.Wait;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -475,6 +476,29 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
|||
Assert.assertTrue(destination instanceof Queue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueueFQQN() throws Exception {
|
||||
final String QUEUE = "myQueue";
|
||||
Hashtable<String, String> props = new Hashtable<>();
|
||||
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
|
||||
props.put("queue.myQueue", "myAddress::" + QUEUE);
|
||||
Context ctx = new InitialContext(props);
|
||||
liveService.getSecurityStore().setSecurityEnabled(false);
|
||||
|
||||
Destination destination = (Destination) ctx.lookup(QUEUE);
|
||||
Assert.assertTrue(destination instanceof Queue);
|
||||
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
|
||||
try (Connection connection = connectionFactory.createConnection()) {
|
||||
Session session = connection.createSession();
|
||||
MessageProducer producer = session.createProducer(destination);
|
||||
producer.send(session.createMessage());
|
||||
Wait.assertTrue(() -> liveService.locateQueue(QUEUE).getMessageCount() == 1, 2000, 100);
|
||||
MessageConsumer consumer = session.createConsumer(destination);
|
||||
connection.start();
|
||||
assertNotNull(consumer.receiveNoWait());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDynamicQueue() throws NamingException, JMSException {
|
||||
Hashtable<String, String> props = new Hashtable<>();
|
||||
|
@ -485,6 +509,28 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
|||
Assert.assertTrue(destination instanceof Queue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDynamicQueueFQQN() throws Exception {
|
||||
final String QUEUE = "myQueue";
|
||||
Hashtable<String, String> props = new Hashtable<>();
|
||||
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
|
||||
Context ctx = new InitialContext(props);
|
||||
liveService.getSecurityStore().setSecurityEnabled(false);
|
||||
|
||||
Destination destination = (Destination) ctx.lookup("dynamicQueues/myAddress::" + QUEUE);
|
||||
Assert.assertTrue(destination instanceof Queue);
|
||||
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
|
||||
try (Connection connection = connectionFactory.createConnection()) {
|
||||
Session session = connection.createSession();
|
||||
MessageProducer producer = session.createProducer(destination);
|
||||
producer.send(session.createMessage());
|
||||
Wait.assertTrue(() -> liveService.locateQueue(QUEUE).getMessageCount() == 1, 2000, 100);
|
||||
MessageConsumer consumer = session.createConsumer(destination);
|
||||
connection.start();
|
||||
assertNotNull(consumer.receiveNoWait());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTopic() throws NamingException, JMSException {
|
||||
Hashtable<String, String> props = new Hashtable<>();
|
||||
|
@ -500,6 +546,28 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
|||
Assert.assertTrue(destination instanceof Topic);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTopicFQQN() throws Exception {
|
||||
final String SUBSCRIPTION = "mySubsription";
|
||||
Hashtable<String, String> props = new Hashtable<>();
|
||||
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
|
||||
props.put("topic.myTopic", "myTopic::" + SUBSCRIPTION);
|
||||
Context ctx = new InitialContext(props);
|
||||
liveService.getSecurityStore().setSecurityEnabled(false);
|
||||
|
||||
Destination destination = (Destination) ctx.lookup("myTopic");
|
||||
Assert.assertTrue(destination instanceof Topic);
|
||||
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
|
||||
Connection connection = connectionFactory.createConnection();
|
||||
Session session = connection.createSession();
|
||||
MessageProducer producer = session.createProducer(destination);
|
||||
producer.send(session.createMessage());
|
||||
Wait.assertTrue(() -> liveService.locateQueue(SUBSCRIPTION).getMessageCount() == 1, 2000, 100);
|
||||
MessageConsumer consumer = session.createConsumer(destination);
|
||||
connection.start();
|
||||
assertNotNull(consumer.receiveNoWait());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDynamicTopic() throws NamingException, JMSException {
|
||||
Hashtable<String, String> props = new Hashtable<>();
|
||||
|
@ -510,6 +578,28 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
|
|||
Assert.assertTrue(destination instanceof Topic);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDynamicTopicFQQN() throws Exception {
|
||||
final String SUBSCRIPTION = "mySubsription";
|
||||
Hashtable<String, String> props = new Hashtable<>();
|
||||
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
|
||||
props.put("topic.myTopic", "myTopic::" + SUBSCRIPTION);
|
||||
Context ctx = new InitialContext(props);
|
||||
liveService.getSecurityStore().setSecurityEnabled(false);
|
||||
|
||||
Destination destination = (Destination) ctx.lookup("dynamicTopics/myTopic::" + SUBSCRIPTION);
|
||||
Assert.assertTrue(destination instanceof Topic);
|
||||
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
|
||||
Connection connection = connectionFactory.createConnection();
|
||||
Session session = connection.createSession();
|
||||
MessageProducer producer = session.createProducer(destination);
|
||||
producer.send(session.createMessage());
|
||||
Wait.assertTrue(() -> liveService.locateQueue(SUBSCRIPTION).getMessageCount() == 1, 2000, 100);
|
||||
MessageConsumer consumer = session.createConsumer(destination);
|
||||
connection.start();
|
||||
assertNotNull(consumer.receiveNoWait());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoteCFWithTCPUserPassword() throws Exception {
|
||||
|
||||
|
|
Loading…
Reference in New Issue