use of org.apache.activemq.artemis.tests.unit.util.InVMNamingContext in project activemq-artemis by apache.
the class JMSClusteredTestBase method setupServer1.
/**
* @throws Exception
*/
private void setupServer1() throws Exception {
Configuration configuration = createConfigServer(1, 2);
JMSConfigurationImpl jmsconfig = new JMSConfigurationImpl();
mBeanServer1 = MBeanServerFactory.createMBeanServer();
server1 = addServer(ActiveMQServers.newActiveMQServer(configuration, mBeanServer1, enablePersistence()));
jmsServer1 = new JMSServerManagerImpl(server1, jmsconfig);
context1 = new InVMNamingContext();
jmsServer1.setRegistry(new JndiBindingRegistry(context1));
}
use of org.apache.activemq.artemis.tests.unit.util.InVMNamingContext in project activemq-artemis by apache.
the class JMSBridgeImplTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Configuration config = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
InVMNamingContext context = new InVMNamingContext();
jmsServer = new JMSServerManagerImpl(addServer(ActiveMQServers.newActiveMQServer(config, false)));
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
jmsServer.createQueue(false, JMSBridgeImplTest.SOURCE, null, true, "/queue/" + JMSBridgeImplTest.SOURCE);
jmsServer.createQueue(false, JMSBridgeImplTest.TARGET, null, true, "/queue/" + JMSBridgeImplTest.TARGET);
}
use of org.apache.activemq.artemis.tests.unit.util.InVMNamingContext in project activemq-artemis by apache.
the class JMSConfigurationTest method testSetupJMSConfiguration.
@Test
public void testSetupJMSConfiguration() throws Exception {
Context context = new InVMNamingContext();
ActiveMQServer coreServer = new ActiveMQServerImpl(createDefaultInVMConfig());
JMSConfiguration jmsConfiguration = new JMSConfigurationImpl();
TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName());
List<TransportConfiguration> transportConfigs = new ArrayList<>();
transportConfigs.add(connectorConfig);
ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName(RandomUtil.randomString()).setConnectorNames(registerConnectors(coreServer, transportConfigs)).setBindings("/cf/binding1", "/cf/binding2");
jmsConfiguration.getConnectionFactoryConfigurations().add(cfConfig);
JMSQueueConfigurationImpl queueConfig = new JMSQueueConfigurationImpl().setName(RandomUtil.randomString()).setDurable(false).setBindings("/queue/binding1", "/queue/binding2");
jmsConfiguration.getQueueConfigurations().add(queueConfig);
TopicConfiguration topicConfig = new TopicConfigurationImpl().setName(RandomUtil.randomString()).setBindings("/topic/binding1", "/topic/binding2");
jmsConfiguration.getTopicConfigurations().add(topicConfig);
JMSServerManager server = new JMSServerManagerImpl(coreServer, jmsConfiguration);
server.setRegistry(new JndiBindingRegistry(context));
server.start();
for (String binding : cfConfig.getBindings()) {
Object o = context.lookup(binding);
Assert.assertNotNull(o);
Assert.assertTrue(o instanceof ConnectionFactory);
ConnectionFactory cf = (ConnectionFactory) o;
Connection connection = cf.createConnection();
connection.close();
}
for (String binding : queueConfig.getBindings()) {
Object o = context.lookup(binding);
Assert.assertNotNull(o);
Assert.assertTrue(o instanceof Queue);
Queue queue = (Queue) o;
Assert.assertEquals(queueConfig.getName(), queue.getQueueName());
}
for (String binding : topicConfig.getBindings()) {
Object o = context.lookup(binding);
Assert.assertNotNull(o);
Assert.assertTrue(o instanceof Topic);
Topic topic = (Topic) o;
Assert.assertEquals(topicConfig.getName(), topic.getTopicName());
}
server.stop();
}
use of org.apache.activemq.artemis.tests.unit.util.InVMNamingContext in project activemq-artemis by apache.
the class PagingOrderTest method testPagingOverCreatedDestinationTopics.
@Test
public void testPagingOverCreatedDestinationTopics() throws Exception {
Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(false);
ActiveMQServer server = createServer(true, config, PAGE_SIZE, -1, new HashMap<String, AddressSettings>());
JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
InVMNamingContext context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
jmsServer.createTopic(true, "tt", "/topic/TT");
server.getActiveMQServerControl().addAddressSettings("TT", "DLQ", "DLQ", -1, false, 5, 1024 * 1024, 1024 * 10, 5, 5, 1, 1000, 0, false, "PAGE", -1, 10, "KILL", true, true, true, true);
ActiveMQJMSConnectionFactory cf = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
Connection conn = cf.createConnection();
conn.setClientID("tst");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = (Topic) context.lookup("/topic/TT");
sess.createDurableSubscriber(topic, "t1");
MessageProducer prod = sess.createProducer(topic);
prod.setDeliveryMode(DeliveryMode.PERSISTENT);
TextMessage txt = sess.createTextMessage("TST");
prod.send(txt);
PagingStore store = server.getPagingManager().getPageStore(new SimpleString("TT"));
assertEquals(1024 * 1024, store.getMaxSize());
assertEquals(10 * 1024, store.getPageSizeBytes());
jmsServer.stop();
server = createServer(true, config, PAGE_SIZE, -1, new HashMap<String, AddressSettings>());
jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
AddressSettings settings = server.getAddressSettingsRepository().getMatch("TT");
assertEquals(1024 * 1024, settings.getMaxSizeBytes());
assertEquals(10 * 1024, settings.getPageSizeBytes());
assertEquals(AddressFullMessagePolicy.PAGE, settings.getAddressFullMessagePolicy());
store = server.getPagingManager().getPageStore(new SimpleString("TT"));
conn.close();
server.stop();
}
use of org.apache.activemq.artemis.tests.unit.util.InVMNamingContext in project activemq-artemis by apache.
the class PagingOrderTest method testPagingOverCreatedDestinationQueues.
@Test
public void testPagingOverCreatedDestinationQueues() throws Exception {
Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(false);
ActiveMQServer server = createServer(true, config, -1, -1, new HashMap<String, AddressSettings>());
server.getAddressSettingsRepository().getMatch("#").setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
InVMNamingContext context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
server.getActiveMQServerControl().addAddressSettings("Q1", "DLQ", "DLQ", -1, false, 5, 100 * 1024, 10 * 1024, 5, 5, 1, 1000, 0, false, "PAGE", -1, 10, "KILL", true, true, true, true);
jmsServer.createQueue(true, "Q1", null, true, "/queue/Q1");
ActiveMQJMSConnectionFactory cf = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
conn = cf.createConnection();
conn.setClientID("tst");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
javax.jms.Queue queue = (javax.jms.Queue) context.lookup("/queue/Q1");
MessageProducer prod = sess.createProducer(queue);
prod.setDeliveryMode(DeliveryMode.PERSISTENT);
BytesMessage bmt = sess.createBytesMessage();
bmt.writeBytes(new byte[1024]);
for (int i = 0; i < 500; i++) {
prod.send(bmt);
}
PagingStore store = server.getPagingManager().getPageStore(new SimpleString("Q1"));
assertEquals(100 * 1024, store.getMaxSize());
assertEquals(10 * 1024, store.getPageSizeBytes());
assertEquals(AddressFullMessagePolicy.PAGE, store.getAddressFullMessagePolicy());
jmsServer.stop();
server = createServer(true, config, -1, -1, new HashMap<String, AddressSettings>());
server.getAddressSettingsRepository().getMatch("#").setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
jmsServer = new JMSServerManagerImpl(server);
context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
AddressSettings settings = server.getAddressSettingsRepository().getMatch("Q1");
assertEquals(100 * 1024, settings.getMaxSizeBytes());
assertEquals(10 * 1024, settings.getPageSizeBytes());
assertEquals(AddressFullMessagePolicy.PAGE, settings.getAddressFullMessagePolicy());
store = server.getPagingManager().getPageStore(new SimpleString("Q1"));
assertEquals(100 * 1024, store.getMaxSize());
assertEquals(10 * 1024, store.getPageSizeBytes());
assertEquals(AddressFullMessagePolicy.PAGE, store.getAddressFullMessagePolicy());
}
Aggregations