org.apache.activemq.artemis.core.config.Configuration

Here are the examples of the java api class org.apache.activemq.artemis.core.config.Configuration taken from open source projects.

1. HornetQProtocolManagerTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration configuration = createDefaultConfig(false);
    configuration.setPersistenceEnabled(false);
    configuration.getAcceptorConfigurations().clear();
    configuration.addAcceptorConfiguration("legacy", "tcp://localhost:61616?protocols=HORNETQ").addAcceptorConfiguration("corepr", "tcp://localhost:61617?protocols=CORE");
    configuration.addConnectorConfiguration("legacy", "tcp://localhost:61616");
    JMSConfiguration jmsConfiguration = new JMSConfigurationImpl();
    jmsConfiguration.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName("testQueue").setBindings("testQueue"));
    embeddedJMS = new EmbeddedJMS();
    embeddedJMS.setConfiguration(configuration);
    embeddedJMS.setJmsConfiguration(jmsConfiguration);
    embeddedJMS.start();
}

2. FailoverBackupLeakTest#setUp()

View license
@Before
public void setUp() throws Exception {
    Configuration config0 = createConfig("127.0.0.1", 0);
    Configuration config1 = createConfig("127.0.0.1", 1);
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    s1 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    s2 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    s1.start();
    s2.start();
    Assert.assertTrue(s1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(s2.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
}

3. FailoverClusterTest#setUp()

View license
@Before
public void setUp() throws Exception {
    Map<String, String> params = new HashMap<>();
    params.put("rebalanceClusterClients", "true");
    params.put("updateClusterClients", "true");
    Configuration config1 = createConfig("localhost", 1, params);
    Configuration config2 = createConfig("localhost", 2, params);
    deployClusterConfiguration(config1, 2);
    deployClusterConfiguration(config2, 1);
    server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server2 = new EmbeddedJMS().setConfiguration(config2).setJmsConfiguration(new JMSConfigurationImpl());
    clientUrl = "failover://(" + newURI(1) + "," + newURI(2) + ")";
}

4. InitalReconnectDelayTest#setUp()

View license
@Before
public void setUp() throws Exception {
    Configuration config1 = createConfig(1);
    Configuration config2 = createConfig(2);
    deployClusterConfiguration(config1, 2);
    deployClusterConfiguration(config2, 1);
    server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server2 = new EmbeddedJMS().setConfiguration(config2).setJmsConfiguration(new JMSConfigurationImpl());
    server1.start();
    server2.start();
    Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(server2.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
}

5. TwoBrokerFailoverClusterTest#setUp()

View license
@Before
public void setUp() throws Exception {
    HashMap<String, String> map = new HashMap<>();
    map.put("rebalanceClusterClients", "true");
    map.put("updateClusterClients", "true");
    map.put("updateClusterClientsOnRemove", "true");
    Configuration config0 = createConfig("127.0.0.1", 0, map);
    Configuration config1 = createConfig("127.0.0.1", 1, map);
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    clientUrl = "failover://(" + newURI("127.0.0.1", 0) + "," + newURI("127.0.0.1", 1) + ")";
    server0.start();
    server1.start();
    Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
}

6. MultipleLivesMultipleBackupsFailoverTest#createLiveConfig()

View license
protected void createLiveConfig(NodeManager nodeManager, int liveNode, int... otherLiveNodes) throws Exception {
    TransportConfiguration liveConnector = createTransportConfiguration(isNetty(), false, generateParams(liveNode, isNetty()));
    Configuration config0 = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(isNetty(), true, generateParams(liveNode, isNetty()))).setHAPolicyConfiguration(sharedStore ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration()).setBindingsDirectory(getBindingsDir() + "_" + liveNode).setJournalDirectory(getJournalDir() + "_" + liveNode).setPagingDirectory(getPageDir() + "_" + liveNode).setLargeMessagesDirectory(getLargeMessagesDir() + "_" + liveNode).addConnectorConfiguration(liveConnector.getName(), liveConnector);
    String[] pairs = new String[otherLiveNodes.length];
    for (int i = 0; i < otherLiveNodes.length; i++) {
        TransportConfiguration otherLiveConnector = createTransportConfiguration(isNetty(), false, generateParams(otherLiveNodes[i], isNetty()));
        config0.addConnectorConfiguration(otherLiveConnector.getName(), otherLiveConnector);
        pairs[i] = otherLiveConnector.getName();
    }
    config0.addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), pairs));
    servers.put(liveNode, new SameProcessActiveMQServer(createInVMFailoverServer(true, config0, nodeManager, liveNode)));
}

7. SingleLiveMultipleBackupsFailoverTest#createBackupConfig()

View license
protected void createBackupConfig(int liveNode, int nodeid, int... nodes) throws Exception {
    TransportConfiguration backupConnector = createTransportConfiguration(isNetty(), false, generateParams(nodeid, isNetty()));
    Configuration config1 = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(isNetty(), true, generateParams(nodeid, isNetty()))).setHAPolicyConfiguration(sharedStore ? new SharedStoreSlavePolicyConfiguration() : new ReplicatedPolicyConfiguration()).addConnectorConfiguration(backupConnector.getName(), backupConnector).setBindingsDirectory(getBindingsDir() + "_" + liveNode).setJournalDirectory(getJournalDir() + "_" + liveNode).setPagingDirectory(getPageDir() + "_" + liveNode).setLargeMessagesDirectory(getLargeMessagesDir() + "_" + liveNode);
    String[] staticConnectors = new String[nodes.length];
    for (int i = 0; i < nodes.length; i++) {
        TransportConfiguration liveConnector = createTransportConfiguration(isNetty(), false, generateParams(nodes[i], isNetty()));
        config1.addConnectorConfiguration(liveConnector.getName(), liveConnector);
        staticConnectors[i] = liveConnector.getName();
    }
    config1.addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), staticConnectors));
    servers.put(nodeid, new SameProcessActiveMQServer(createInVMFailoverServer(true, config1, nodeManager, nodeid)));
}

8. ActiveMQConnectionFactoryTest#startServer()

View license
private void startServer() throws Exception {
    liveTC = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
    Map<String, TransportConfiguration> connectors = new HashMap<>();
    connectors.put(liveTC.getName(), liveTC);
    List<String> connectorNames = new ArrayList<>();
    connectorNames.add(liveTC.getName());
    Configuration liveConf = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)).setConnectorConfigurations(connectors).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration());
    final long broadcastPeriod = 250;
    final String bcGroupName = "bc1";
    final int localBindPort = 5432;
    BroadcastGroupConfiguration bcConfig1 = new BroadcastGroupConfiguration().setName(bcGroupName).setBroadcastPeriod(broadcastPeriod).setConnectorInfos(connectorNames).setEndpointFactory(new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(groupPort).setLocalBindPort(localBindPort));
    List<BroadcastGroupConfiguration> bcConfigs1 = new ArrayList<>();
    bcConfigs1.add(bcConfig1);
    liveConf.setBroadcastGroupConfigurations(bcConfigs1);
    liveService = addServer(ActiveMQServers.newActiveMQServer(liveConf, false));
    liveService.start();
}

9. StompTestBase#createServer()

Project: activemq-artemis
Source File: StompTestBase.java
View license
/**
    * @return
    * @throws Exception
    */
protected JMSServerManager createServer() throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    TransportConfiguration allTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName());
    Configuration config = createBasicConfig().setPersistenceEnabled(false).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    config.addAcceptorConfiguration(allTransport);
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setDurable(false).setBindings(getQueueName()));
    jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
    server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
    return server;
}

10. AcceptorsTest#testMultipleAcceptorsWithSameHostPortDifferentName()

Project: activemq-artemis
Source File: AcceptorsTest.java
View license
@Test
public void testMultipleAcceptorsWithSameHostPortDifferentName() throws Exception {
    final String acceptorFactoryClass = FakeAcceptorFactory.class.getName();
    Map<String, Object> params = new HashMap<>();
    params.put("host", "localhost");
    params.put("port", 5445);
    Set<TransportConfiguration> tcs = new HashSet<>();
    tcs.add(new TransportConfiguration(acceptorFactoryClass, params, "Acceptor1"));
    tcs.add(new TransportConfiguration(acceptorFactoryClass, params, "Acceptor2"));
    Configuration config = createBasicConfig();
    config.setAcceptorConfigurations(tcs);
    ActiveMQServer server = createServer(config);
    server.start();
    waitForServerToStart(server);
    assertNotNull(server.getRemotingService().getAcceptor("Acceptor1"));
    assertNotNull(server.getRemotingService().getAcceptor("Acceptor2"));
}

11. PersistentPushQueueConsumerTest#startup()

View license
public static void startup() throws Exception {
    Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    activeMQServer = ActiveMQServers.newActiveMQServer(configuration);
    activeMQServer.start();
    deployment = EmbeddedContainer.start();
    manager = new MessageServiceManager();
    manager.start();
    deployment.getRegistry().addSingletonResource(manager.getQueueManager().getDestination());
    deployment.getRegistry().addSingletonResource(manager.getTopicManager().getDestination());
}

12. RawAckTest#setup()

Project: activemq-artemis
Source File: RawAckTest.java
View license
@BeforeClass
public static void setup() throws Exception {
    Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    activeMQServer = ActiveMQServers.newActiveMQServer(configuration);
    activeMQServer.start();
    HashMap<String, Object> transportConfig = new HashMap<>();
    serverLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig));
    sessionFactory = serverLocator.createSessionFactory();
    consumerSessionFactory = serverLocator.createSessionFactory();
    activeMQServer.createQueue(new SimpleString("testQueue"), new SimpleString("testQueue"), null, false, false);
    session = sessionFactory.createSession(true, true);
    producer = session.createProducer("testQueue");
    session.start();
}

13. FileConfigurationParser#parseMainConfig()

View license
public Configuration parseMainConfig(final InputStream input) throws Exception {
    Reader reader = new InputStreamReader(input);
    String xml = XMLUtil.readerToString(reader);
    xml = XMLUtil.replaceSystemProps(xml);
    Element e = XMLUtil.stringToElement(xml);
    Configuration config = new ConfigurationImpl();
    parseMainConfig(e, config);
    return config;
}

14. ColocatedHAManager#activateReplicatedBackup()

View license
/**
    * activate a backup server replicating from a specified node.
    *
    * decline and the requesting server can cast a re vote
    *
    * @param nodeID the id of the node to replicate from
    * @return true if the server was created and started
    * @throws Exception
    */
private synchronized boolean activateReplicatedBackup(SimpleString nodeID) throws Exception {
    Configuration configuration = server.getConfiguration().copy();
    ActiveMQServer backup = server.createBackupServer(configuration);
    try {
        TopologyMember member = server.getClusterManager().getDefaultConnection(null).getTopology().getMember(nodeID.toString());
        int portOffset = haPolicy.getBackupPortOffset() * (backupServers.size() + 1);
        String name = "colocated_backup_" + backupServers.size() + 1;
        //make sure we don't restart as we are colocated
        haPolicy.getBackupPolicy().setRestartBackup(false);
        //set the backup policy
        backup.setHAPolicy(haPolicy.getBackupPolicy());
        updateReplicatedConfiguration(configuration, name, portOffset, haPolicy.getExcludedConnectors(), haPolicy.getBackupPolicy().getScaleDownPolicy() == null);
        backup.addActivationParam(ActivationParams.REPLICATION_ENDPOINT, member);
        backupServers.put(configuration.getName(), backup);
        backup.start();
    } catch (Exception e) {
        backup.stop();
        ActiveMQServerLogger.LOGGER.activateReplicatedBackupFailed(e);
        return false;
    }
    ActiveMQServerLogger.LOGGER.activatingReplica(nodeID);
    return true;
}

15. FileConfigurationParserTest#testParsingClusterConnectionURIs()

View license
@Test
public void testParsingClusterConnectionURIs() throws Exception {
    FileConfigurationParser parser = new FileConfigurationParser();
    String configStr = firstPart + "<cluster-connections>\n" + "   <cluster-connection-uri name=\"my-cluster\" address=\"multicast://my-discovery-group?messageLoadBalancingType=STRICT;retryInterval=333;connectorName=netty-connector;maxHops=1\"/>\n" + "</cluster-connections>\n" + lastPart;
    ByteArrayInputStream input = new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8));
    Configuration config = parser.parseMainConfig(input);
    Assert.assertEquals(1, config.getClusterConfigurations().size());
    Assert.assertEquals("my-discovery-group", config.getClusterConfigurations().get(0).getDiscoveryGroupName());
    Assert.assertEquals(333, config.getClusterConfigurations().get(0).getRetryInterval());
}

16. HAPolicyConfigurationTest#liveOnlyTest()

View license
@Test
public void liveOnlyTest() throws Exception {
    Configuration configuration = createConfiguration("live-only-hapolicy-config.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof LiveOnlyActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof LiveOnlyPolicy);
        LiveOnlyPolicy liveOnlyPolicy = (LiveOnlyPolicy) haPolicy;
        ScaleDownPolicy scaleDownPolicy = liveOnlyPolicy.getScaleDownPolicy();
        assertNotNull(scaleDownPolicy);
        assertEquals(scaleDownPolicy.getGroupName(), "boo!");
        assertEquals(scaleDownPolicy.getDiscoveryGroup(), "wahey");
        List<String> connectors = scaleDownPolicy.getConnectors();
        assertNotNull(connectors);
        assertEquals(connectors.size(), 0);
    } finally {
        server.stop();
    }
}

17. HAPolicyConfigurationTest#ReplicatedTest()

View license
@Test
public void ReplicatedTest() throws Exception {
    Configuration configuration = createConfiguration("replicated-hapolicy-config.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof SharedNothingLiveActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof ReplicatedPolicy);
        ReplicatedPolicy replicatedPolicy = (ReplicatedPolicy) haPolicy;
        assertEquals(replicatedPolicy.getGroupName(), "purple");
        assertTrue(replicatedPolicy.isCheckForLiveServer());
        assertEquals(replicatedPolicy.getClusterName(), "abcdefg");
        assertEquals(replicatedPolicy.getInitialReplicationSyncTimeout(), 9876);
    } finally {
        server.stop();
    }
}

18. HAPolicyConfigurationTest#ReplicaTest3()

View license
@Test
public void ReplicaTest3() throws Exception {
    Configuration configuration = createConfiguration("replica-hapolicy-config3.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof SharedNothingBackupActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof ReplicaPolicy);
        ReplicaPolicy replicaPolicy = (ReplicaPolicy) haPolicy;
        assertEquals(replicaPolicy.getGroupName(), "tiddles");
        assertEquals(replicaPolicy.getMaxSavedReplicatedJournalsSize(), 22);
        assertEquals(replicaPolicy.getClusterName(), "33rrrrr");
        assertFalse(replicaPolicy.isRestartBackup());
        ScaleDownPolicy scaleDownPolicy = replicaPolicy.getScaleDownPolicy();
        assertNull(scaleDownPolicy);
    } finally {
        server.stop();
    }
}

19. HAPolicyConfigurationTest#SharedStoreMasterTest()

View license
@Test
public void SharedStoreMasterTest() throws Exception {
    Configuration configuration = createConfiguration("shared-store-master-hapolicy-config.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof SharedStoreLiveActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof SharedStoreMasterPolicy);
        SharedStoreMasterPolicy masterPolicy = (SharedStoreMasterPolicy) haPolicy;
        assertFalse(masterPolicy.isFailoverOnServerShutdown());
    } finally {
        server.stop();
    }
}

20. HAPolicyConfigurationTest#SharedStoreSlaveTest()

View license
@Test
public void SharedStoreSlaveTest() throws Exception {
    Configuration configuration = createConfiguration("shared-store-slave-hapolicy-config.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof SharedStoreBackupActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof SharedStoreSlavePolicy);
        SharedStoreSlavePolicy sharedStoreSlavePolicy = (SharedStoreSlavePolicy) haPolicy;
        assertFalse(sharedStoreSlavePolicy.isFailoverOnServerShutdown());
        assertFalse(sharedStoreSlavePolicy.isRestartBackup());
        ScaleDownPolicy scaleDownPolicy = sharedStoreSlavePolicy.getScaleDownPolicy();
        assertNotNull(scaleDownPolicy);
        assertEquals(scaleDownPolicy.getGroupName(), "boo!");
        assertEquals(scaleDownPolicy.getDiscoveryGroup(), "wahey");
        List<String> connectors = scaleDownPolicy.getConnectors();
        assertNotNull(connectors);
        assertEquals(connectors.size(), 0);
    } finally {
        server.stop();
    }
}

21. HAPolicyConfigurationTest#SharedStoreSlaveTest3()

View license
@Test
public void SharedStoreSlaveTest3() throws Exception {
    Configuration configuration = createConfiguration("shared-store-slave-hapolicy-config3.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof SharedStoreBackupActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof SharedStoreSlavePolicy);
        SharedStoreSlavePolicy sharedStoreSlavePolicy = (SharedStoreSlavePolicy) haPolicy;
        assertTrue(sharedStoreSlavePolicy.isFailoverOnServerShutdown());
        assertTrue(sharedStoreSlavePolicy.isRestartBackup());
        ScaleDownPolicy scaleDownPolicy = sharedStoreSlavePolicy.getScaleDownPolicy();
        assertNull(scaleDownPolicy);
    } finally {
        server.stop();
    }
}

22. HAPolicyConfigurationTest#colocatedTestNullBackup()

View license
@Test
public void colocatedTestNullBackup() throws Exception {
    Configuration configuration = createConfiguration("colocated-hapolicy-config-null-backup.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof ColocatedActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof ColocatedPolicy);
        ColocatedPolicy colocatedPolicy = (ColocatedPolicy) haPolicy;
        ReplicatedPolicy livePolicy = (ReplicatedPolicy) colocatedPolicy.getLivePolicy();
        assertNotNull(livePolicy);
        assertEquals(livePolicy.getGroupName(), "purple");
        assertTrue(livePolicy.isCheckForLiveServer());
        assertEquals(livePolicy.getClusterName(), "abcdefg");
        ReplicaPolicy backupPolicy = (ReplicaPolicy) colocatedPolicy.getBackupPolicy();
        assertNotNull(backupPolicy);
    } finally {
        server.stop();
    }
}

23. HAPolicyConfigurationTest#colocatedTest2()

View license
@Test
public void colocatedTest2() throws Exception {
    Configuration configuration = createConfiguration("colocated-hapolicy-config2.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof ColocatedActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof ColocatedPolicy);
        ColocatedPolicy colocatedPolicy = (ColocatedPolicy) haPolicy;
        SharedStoreMasterPolicy livePolicy = (SharedStoreMasterPolicy) colocatedPolicy.getLivePolicy();
        assertNotNull(livePolicy);
        assertFalse(livePolicy.isFailoverOnServerShutdown());
        SharedStoreSlavePolicy backupPolicy = (SharedStoreSlavePolicy) colocatedPolicy.getBackupPolicy();
        assertNotNull(backupPolicy);
        assertFalse(backupPolicy.isFailoverOnServerShutdown());
        assertFalse(backupPolicy.isRestartBackup());
    } finally {
        server.stop();
    }
}

24. HAPolicyConfigurationTest#colocatedTest2nullbackup()

View license
@Test
public void colocatedTest2nullbackup() throws Exception {
    Configuration configuration = createConfiguration("colocated-hapolicy-config2-null-backup.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof ColocatedActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof ColocatedPolicy);
        ColocatedPolicy colocatedPolicy = (ColocatedPolicy) haPolicy;
        SharedStoreMasterPolicy livePolicy = (SharedStoreMasterPolicy) colocatedPolicy.getLivePolicy();
        assertNotNull(livePolicy);
        assertFalse(livePolicy.isFailoverOnServerShutdown());
        SharedStoreSlavePolicy backupPolicy = (SharedStoreSlavePolicy) colocatedPolicy.getBackupPolicy();
        assertNotNull(backupPolicy);
    } finally {
        server.stop();
    }
}

25. HAPolicyConfigurationTest#liveOnlyTest()

View license
private void liveOnlyTest(String file) throws Exception {
    Configuration configuration = createConfiguration(file);
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof LiveOnlyActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof LiveOnlyPolicy);
        LiveOnlyPolicy liveOnlyPolicy = (LiveOnlyPolicy) haPolicy;
        ScaleDownPolicy scaleDownPolicy = liveOnlyPolicy.getScaleDownPolicy();
        assertNull(scaleDownPolicy);
    } finally {
        server.stop();
    }
}

26. ActiveMQTestBase#createDefaultConfig()

View license
private Configuration createDefaultConfig(final int index, final Map<String, Object> params, final String... acceptors) {
    Configuration configuration = createBasicConfig(index);
    for (String acceptor : acceptors) {
        TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params);
        configuration.getAcceptorConfigurations().add(transportConfig);
    }
    return configuration;
}

27. OpenwireArtemisBaseTest#setUpNonClusterServers()

View license
protected void setUpNonClusterServers(EmbeddedJMS[] servers) throws Exception {
    Configuration[] serverCfgs = new Configuration[servers.length];
    for (int i = 0; i < servers.length; i++) {
        serverCfgs[i] = createConfig(i);
    }
    for (int i = 0; i < servers.length; i++) {
        servers[i] = new EmbeddedJMS().setConfiguration(serverCfgs[i]).setJmsConfiguration(new JMSConfigurationImpl());
    }
    for (int i = 0; i < servers.length; i++) {
        servers[i].start();
    }
}

28. OpenwireArtemisBaseTest#setUpClusterServers()

View license
protected void setUpClusterServers(EmbeddedJMS[] servers) throws Exception {
    Configuration[] serverCfgs = new Configuration[servers.length];
    for (int i = 0; i < servers.length; i++) {
        serverCfgs[i] = createConfig(i);
    }
    for (int i = 0; i < servers.length; i++) {
        deployClusterConfiguration(serverCfgs[i], getTargets(servers.length, i));
    }
    for (int i = 0; i < servers.length; i++) {
        servers[i] = new EmbeddedJMS().setConfiguration(serverCfgs[i]).setJmsConfiguration(new JMSConfigurationImpl());
    }
    for (int i = 0; i < servers.length; i++) {
        servers[i].start();
    }
    for (int i = 0; i < servers.length; i++) {
        Assert.assertTrue(servers[i].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, servers.length));
    }
}

29. ReconnectTest#setUp()

Project: activemq-artemis
Source File: ReconnectTest.java
View license
@Before
public void setUp() throws Exception {
    Configuration config = createConfig(0);
    bs = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
    bs.start();
    tcpUri = new URI(newURI(0));
    workers = new Worker[WORKER_COUNT];
    for (int i = 0; i < WORKER_COUNT; i++) {
        workers[i] = new Worker("worker-" + i);
        workers[i].start();
    }
}

30. StompInternalStateTest#createDefaultConfig()

View license
@Override
protected Configuration createDefaultConfig(final boolean netty) throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    Configuration config = super.createDefaultConfig(netty).setPersistenceEnabled(false).addAcceptorConfiguration(stompTransport);
    return config;
}

31. ConsumerCloseTest#setUp()

View license
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig();
    server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    address = RandomUtil.randomSimpleString();
    queue = RandomUtil.randomSimpleString();
    locator = createInVMNonHALocator();
    sf = createSessionFactory(locator);
    session = addClientSession(sf.createSession(false, true, true));
    session.createQueue(address, queue, false);
}

32. HangConsumerTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig().setMessageExpiryScanPeriod(10);
    ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    server = addServer(new MyActiveMQServer(config, ManagementFactory.getPlatformMBeanServer(), securityManager));
    server.start();
    locator = createInVMNonHALocator();
}

33. HeuristicXATest#testInvalidCall()

View license
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testInvalidCall() throws Exception {
    Configuration configuration = createDefaultInVMConfig().setJMXManagementEnabled(true);
    ActiveMQServer server = createServer(false, configuration);
    server.setMBeanServer(mbeanServer);
    server.start();
    ActiveMQServerControl jmxServer = ManagementControlHelper.createActiveMQServerControl(mbeanServer);
    Assert.assertFalse(jmxServer.commitPreparedTransaction("Nananananana"));
}

34. MessageGroupingTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration configuration = createDefaultInVMConfig();
    server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
    server.start();
    locator = createInVMNonHALocator();
    clientSessionFactory = createSessionFactory(locator);
    clientSession = addClientSession(clientSessionFactory.createSession(false, true, true));
    clientSession.createQueue(qName, qName, null, false);
}

35. NIOvsOIOTest#testPerf()

Project: activemq-artemis
Source File: NIOvsOIOTest.java
View license
private void testPerf(boolean nio) throws Exception {
    Configuration config = createDefaultInVMConfig();
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.USE_NIO_PROP_NAME, nio);
    config.getAcceptorConfigurations().add(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params));
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    AddressSettings addressSettings = new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK).setMaxSizeBytes(10 * 1024 * 1024);
    final String dest = "test-destination";
    HierarchicalRepository<AddressSettings> repos = server.getAddressSettingsRepository();
    repos.addMatch(dest, addressSettings);
    server.start();
    for (int i = 0; i < 2; i++) {
        doTest(dest);
    }
}

36. RedeliveryConsumerTest#setUp()

View license
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
/**
    * @param persistDeliveryCountBeforeDelivery
    * @throws Exception
    */
private void setUp(final boolean persistDeliveryCountBeforeDelivery) throws Exception {
    Configuration config = createDefaultInVMConfig().setPersistDeliveryCountBeforeDelivery(persistDeliveryCountBeforeDelivery);
    server = createServer(true, config);
    server.start();
    locator = createInVMNonHALocator();
    factory = createSessionFactory(locator);
    ClientSession session = addClientSession(factory.createSession(false, false, false));
    try {
        session.createQueue(ADDRESS, ADDRESS, true);
    } catch (ActiveMQException expected) {
    }
    session.close();
}

37. SessionFactoryTest#startServer()

View license
private void startServer() throws Exception {
    liveTC = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
    final long broadcastPeriod = 250;
    final String bcGroupName = "bc1";
    final int localBindPort = 5432;
    BroadcastGroupConfiguration broadcastGroupConfiguration = new BroadcastGroupConfiguration().setName(bcGroupName).setBroadcastPeriod(broadcastPeriod).setConnectorInfos(Arrays.asList(liveTC.getName())).setEndpointFactory(new UDPBroadcastEndpointFactory().setGroupAddress(getUDPDiscoveryAddress()).setGroupPort(getUDPDiscoveryPort()).setLocalBindPort(localBindPort));
    Configuration liveConf = createDefaultInVMConfig().addConnectorConfiguration(liveTC.getName(), liveTC).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()).addBroadcastGroupConfiguration(broadcastGroupConfiguration);
    liveService = createServer(false, liveConf);
    liveService.start();
}

38. WildCardRoutingTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration configuration = createDefaultInVMConfig().setWildcardRoutingEnabled(true).setTransactionTimeoutScanPeriod(500);
    server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
    server.start();
    server.getManagementService().enableNotifications(false);
    locator = createInVMNonHALocator();
    sf = createSessionFactory(locator);
    clientSession = addClientSession(sf.createSession(false, true, true));
}

39. ClusterTestBase#setupDiscoveryClusterConnection()

View license
protected void setupDiscoveryClusterConnection(final String name, final int node, final String discoveryGroupName, final String address, final MessageLoadBalancingType messageLoadBalancingType, final int maxHops, final boolean netty) {
    ActiveMQServer server = servers[node];
    if (server == null) {
        throw new IllegalStateException("No server at node " + node);
    }
    TransportConfiguration connectorConfig = createTransportConfiguration(netty, false, generateParams(node, netty));
    server.getConfiguration().getConnectorConfigurations().put(name, connectorConfig);
    Configuration config = server.getConfiguration();
    ClusterConnectionConfiguration clusterConf = new ClusterConnectionConfiguration().setName(name).setAddress(address).setConnectorName(name).setRetryInterval(100).setDuplicateDetection(true).setMessageLoadBalancingType(messageLoadBalancingType).setMaxHops(maxHops).setConfirmationWindowSize(1024).setDiscoveryGroupName(discoveryGroupName);
    List<ClusterConnectionConfiguration> clusterConfs = config.getClusterConfigurations();
    clusterConfs.add(clusterConf);
}

40. FailoverTestBase#adaptLiveConfigForReplicatedFailBack()

View license
protected final void adaptLiveConfigForReplicatedFailBack(TestableServer server) {
    Configuration configuration = server.getServer().getConfiguration();
    final TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
    if (server.getServer().getHAPolicy().isSharedStore()) {
        ClusterConnectionConfiguration cc = configuration.getClusterConfigurations().get(0);
        Assert.assertNotNull("cluster connection configuration", cc);
        Assert.assertNotNull("static connectors", cc.getStaticConnectors());
        cc.getStaticConnectors().add(backupConnector.getName());
        // backupConnector is only necessary for fail-back tests
        configuration.getConnectorConfigurations().put(backupConnector.getName(), backupConnector);
        return;
    }
    ReplicatedPolicy haPolicy = (ReplicatedPolicy) server.getServer().getHAPolicy();
    haPolicy.setCheckForLiveServer(true);
}

41. ValidateAIOTest#testValidateAIO()

View license
@Test
public void testValidateAIO() throws Exception {
    Configuration config = createDefaultInVMConfig().setJournalType(// This will force AsyncIO
    JournalType.ASYNCIO);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, true));
    try {
        server.start();
    } finally {
        server.stop();
    }
}

42. FloodServerTest#setUp()

View license
// Static --------------------------------------------------------
// Attributes ----------------------------------------------------
// Constructors --------------------------------------------------
// TestCase overrides -------------------------------------------
// Public --------------------------------------------------------
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultNettyConfig();
    server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    serverManager = new JMSServerManagerImpl(server);
    initialContext = new InVMNamingContext();
    serverManager.setRegistry(new JndiBindingRegistry(initialContext));
    serverManager.start();
    serverManager.activated();
    serverManager.createTopic(false, topicName, topicName);
    registerConnectionFactory();
}

43. JMSServerConfigParserTest#testParsing()

View license
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testParsing() throws Exception {
    Configuration config = createDefaultInVMConfig().addConnectorConfiguration(// anything so the parsing will work
    "netty", new TransportConfiguration());
    String conf = "activemq-jms-for-JMSServerDeployerTest.xml";
    FileJMSConfiguration jmsconfig = new FileJMSConfiguration();
    FileDeploymentManager deploymentManager = new FileDeploymentManager(conf);
    deploymentManager.addDeployable(jmsconfig);
    deploymentManager.readConfiguration();
    assertEquals(1, jmsconfig.getQueueConfigurations().size());
    JMSQueueConfiguration queueConfig = jmsconfig.getQueueConfigurations().get(0);
    assertEquals("fullConfigurationQueue", queueConfig.getName());
    assertEquals(1, jmsconfig.getTopicConfigurations().size());
    TopicConfiguration topicConfig = jmsconfig.getTopicConfigurations().get(0);
    assertEquals("fullConfigurationTopic", topicConfig.getName());
}

44. ConnectionFactoryControlTest#startServer()

View license
/**
    * @throws Exception
    */
protected void startServer() throws Exception {
    Configuration config = createDefaultInVMConfig().addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY)).setJMXManagementEnabled(true);
    server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, true));
    server.start();
    jmsServerManager = new JMSServerManagerImpl(server);
    jmsServerManager.start();
    ctx = new InVMNamingContext();
    jmsServerManager.setRegistry(new JndiBindingRegistry(ctx));
    jmsServerManager.activated();
}

45. JMSQueueControlTest#setUp()

View license
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true);
    server = createServer(this.getName().contains("WithRealData"), config);
    server.setMBeanServer(mbeanServer);
    serverManager = new JMSServerManagerImpl(server);
    context = new InVMNamingContext();
    serverManager.setRegistry(new JndiBindingRegistry(context));
    serverManager.start();
    serverManager.activated();
    queueName = RandomUtil.randomString();
    serverManager.createQueue(false, queueName, null, true, queueName);
    queue = (ActiveMQQueue) ActiveMQJMSClient.createQueue(queueName);
}

46. JMSServerControl2Test#startActiveMQServer()

View license
// Static --------------------------------------------------------
private void startActiveMQServer(final String acceptorFactory) throws Exception {
    Configuration config = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(acceptorFactory));
    server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, true));
    server.start();
    context = new InVMNamingContext();
    serverManager = new JMSServerManagerImpl(server);
    addActiveMQComponent(serverManager);
    serverManager.setRegistry(new JndiBindingRegistry(context));
    serverManager.start();
    serverManager.activated();
}

47. JMSServerControlTest#startServer()

View license
/**
    * @throws Exception
    */
protected void startServer() throws Exception {
    Configuration config = createDefaultNettyConfig().setJMXManagementEnabled(true).addConnectorConfiguration("netty", new TransportConfiguration(ActiveMQTestBase.NETTY_CONNECTOR_FACTORY)).addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
    server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, true));
    serverManager = new JMSServerManagerImpl(server);
    context = new InVMNamingContext();
    serverManager.setRegistry(new JndiBindingRegistry(context));
    serverManager.start();
    serverManager.activated();
    this.fakeJMSStorageManager = new FakeJMSStorageManager(serverManager.getJMSStorageManager());
    serverManager.replaceStorageManager(fakeJMSStorageManager);
}

48. TopicControlTest#setUp()

View license
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true);
    server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, false));
    server.start();
    serverManager = new JMSServerManagerImpl(server);
    serverManager.start();
    serverManager.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
    serverManager.activated();
    clientID = RandomUtil.randomString();
    subscriptionName = RandomUtil.randomString();
    String topicName = RandomUtil.randomString();
    serverManager.createTopic(false, topicName, topicBinding);
    topic = (ActiveMQTopic) ActiveMQJMSClient.createTopic(topicName);
}

49. AcceptorControlTest#testAttributes()

View license
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testAttributes() throws Exception {
    TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
    Configuration config = createBasicConfig().addAcceptorConfiguration(acceptorConfig);
    ActiveMQServer service = createServer(false, config);
    service.setMBeanServer(mbeanServer);
    service.start();
    AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName());
    Assert.assertEquals(acceptorConfig.getName(), acceptorControl.getName());
    Assert.assertEquals(acceptorConfig.getFactoryClassName(), acceptorControl.getFactoryClassName());
}

50. AddressControlTest#setUp()

View license
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true);
    server = createServer(false, config);
    server.setMBeanServer(mbeanServer);
    server.start();
    locator = createInVMNonHALocator().setBlockOnNonDurableSend(true);
    sf = createSessionFactory(locator);
    session = sf.createSession(false, true, false);
    session.start();
    addClientSession(session);
}

51. AddressControlUsingCoreTest#setUp()

View license
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true);
    server = createServer(false, config);
    server.setMBeanServer(mbeanServer);
    server.start();
    ServerLocator locator = createInVMNonHALocator().setBlockOnNonDurableSend(true);
    ClientSessionFactory sf = createSessionFactory(locator);
    session = sf.createSession(false, true, false);
    session.start();
}

52. BroadcastGroupControlTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    TransportConfiguration connectorConfiguration = new TransportConfiguration(NETTY_CONNECTOR_FACTORY);
    List<String> connectorInfos = new ArrayList<>();
    connectorInfos.add(connectorConfiguration.getName());
    broadcastGroupConfig = new BroadcastGroupConfiguration().setName(RandomUtil.randomString()).setBroadcastPeriod(RandomUtil.randomPositiveInt()).setConnectorInfos(connectorInfos).setEndpointFactory(new UDPBroadcastEndpointFactory().setGroupAddress("231.7.7.7").setGroupPort(1199).setLocalBindPort(1198));
    Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true).addConnectorConfiguration(connectorConfiguration.getName(), connectorConfiguration).addBroadcastGroupConfiguration(broadcastGroupConfig);
    server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, false));
    server.start();
    broadcastGroupControl = createManagementControl(broadcastGroupConfig.getName());
}

53. DivertControlTest#setUp()

View license
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    CoreQueueConfiguration queueConfig = new CoreQueueConfiguration().setAddress(RandomUtil.randomString()).setName(RandomUtil.randomString()).setDurable(false);
    CoreQueueConfiguration forwardQueueConfig = new CoreQueueConfiguration().setAddress(RandomUtil.randomString()).setName(RandomUtil.randomString()).setDurable(false);
    divertConfig = new DivertConfiguration().setName(RandomUtil.randomString()).setRoutingName(RandomUtil.randomString()).setAddress(queueConfig.getAddress()).setForwardingAddress(forwardQueueConfig.getAddress()).setExclusive(RandomUtil.randomBoolean());
    TransportConfiguration connectorConfig = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
    Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true).addQueueConfiguration(queueConfig).addQueueConfiguration(forwardQueueConfig).addDivertConfiguration(divertConfig).addConnectorConfiguration(connectorConfig.getName(), connectorConfig);
    server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, false));
    server.start();
}

54. ManagementServiceImplTest#testHandleManagementMessageWithOperation()

View license
@Test
public void testHandleManagementMessageWithOperation() throws Exception {
    String queue = RandomUtil.randomString();
    String address = RandomUtil.randomString();
    Configuration config = createBasicConfig().setJMXManagementEnabled(false);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    // invoke attribute and operation on the server
    ServerMessage message = new ServerMessageImpl(1, 100);
    ManagementHelper.putOperationInvocation(message, ResourceNames.CORE_SERVER, "createQueue", queue, address);
    ServerMessage reply = server.getManagementService().handleMessage(message);
    Assert.assertTrue(ManagementHelper.hasOperationSucceeded(reply));
}

55. ManagementServiceImplTest#testHandleManagementMessageWithOperationWhichFails()

View license
@Test
public void testHandleManagementMessageWithOperationWhichFails() throws Exception {
    Configuration config = createBasicConfig().setJMXManagementEnabled(false);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    // invoke attribute and operation on the server
    ServerMessage message = new ServerMessageImpl(1, 100);
    ManagementHelper.putOperationInvocation(message, ResourceNames.CORE_SERVER, "thereIsNoSuchOperation");
    ServerMessage reply = server.getManagementService().handleMessage(message);
    Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
    Assert.assertNotNull(ManagementHelper.getResult(reply));
}

56. ManagementServiceImplTest#testHandleManagementMessageWithUnknowResource()

View license
@Test
public void testHandleManagementMessageWithUnknowResource() throws Exception {
    Configuration config = createBasicConfig().setJMXManagementEnabled(false);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    // invoke attribute and operation on the server
    ServerMessage message = new ServerMessageImpl(1, 100);
    ManagementHelper.putOperationInvocation(message, "Resouce.Does.Not.Exist", "toString");
    ServerMessage reply = server.getManagementService().handleMessage(message);
    Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
    Assert.assertNotNull(ManagementHelper.getResult(reply));
}

57. ManagementServiceImplTest#testHandleManagementMessageWithUnknownAttribute()

View license
@Test
public void testHandleManagementMessageWithUnknownAttribute() throws Exception {
    Configuration config = createBasicConfig().setJMXManagementEnabled(false);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    // invoke attribute and operation on the server
    ServerMessage message = new ServerMessageImpl(1, 100);
    ManagementHelper.putAttribute(message, ResourceNames.CORE_SERVER, "started");
    ServerMessage reply = server.getManagementService().handleMessage(message);
    Assert.assertTrue(ManagementHelper.hasOperationSucceeded(reply));
    Assert.assertTrue((Boolean) ManagementHelper.getResult(reply));
}

58. ManagementServiceImplTest#testHandleManagementMessageWithKnownAttribute()

View license
@Test
public void testHandleManagementMessageWithKnownAttribute() throws Exception {
    Configuration config = createBasicConfig().setJMXManagementEnabled(false);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    // invoke attribute and operation on the server
    ServerMessage message = new ServerMessageImpl(1, 100);
    ManagementHelper.putAttribute(message, ResourceNames.CORE_SERVER, "attribute.Does.Not.Exist");
    ServerMessage reply = server.getManagementService().handleMessage(message);
    Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
    Assert.assertNotNull(ManagementHelper.getResult(reply));
}

59. ManagementServiceImplTest#testGetResources()

View license
@Test
public void testGetResources() throws Exception {
    Configuration config = createBasicConfig().setJMXManagementEnabled(false);
    ManagementServiceImpl managementService = new ManagementServiceImpl(null, config);
    managementService.setStorageManager(new NullStorageManager());
    SimpleString address = RandomUtil.randomSimpleString();
    managementService.registerAddress(address);
    Queue queue = new FakeQueue(RandomUtil.randomSimpleString());
    managementService.registerQueue(queue, RandomUtil.randomSimpleString(), new FakeStorageManager());
    Object[] addresses = managementService.getResources(AddressControl.class);
    Assert.assertEquals(1, addresses.length);
    Assert.assertTrue(addresses[0] instanceof AddressControl);
    AddressControl addressControl = (AddressControl) addresses[0];
    Assert.assertEquals(address.toString(), addressControl.getAddress());
    Object[] queues = managementService.getResources(QueueControl.class);
    Assert.assertEquals(1, queues.length);
    Assert.assertTrue(queues[0] instanceof QueueControl);
    QueueControl queueControl = (QueueControl) queues[0];
    Assert.assertEquals(queue.getName().toString(), queueControl.getName());
}

60. ManagementWithPagingServerTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true);
    server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, true));
    AddressSettings defaultSetting = new AddressSettings().setPageSizeBytes(5120).setMaxSizeBytes(10240).setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
    server.getAddressSettingsRepository().addMatch("#", defaultSetting);
    server.start();
    locator = createInVMNonHALocator().setBlockOnNonDurableSend(false).setConsumerWindowSize(0);
    ClientSessionFactory sf = createSessionFactory(locator);
    session1 = sf.createSession(false, true, false);
    session1.start();
    session2 = sf.createSession(false, true, false);
    session2.start();
}

61. QueueControlTest#setUp()

View license
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration conf = createDefaultInVMConfig().setJMXManagementEnabled(true);
    server = addServer(ActiveMQServers.newActiveMQServer(conf, mbeanServer, false));
    server.start();
    locator = createInVMNonHALocator().setBlockOnNonDurableSend(true).setConsumerWindowSize(0);
    ClientSessionFactory sf = createSessionFactory(locator);
    session = sf.createSession(false, true, false);
    session.start();
}

62. SecurityManagementWithConfiguredAdminUserTest#setupAndStartActiveMQServer()

View license
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
protected ActiveMQServer setupAndStartActiveMQServer() throws Exception {
    Configuration config = createDefaultInVMConfig().setSecurityEnabled(true);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
    ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
    securityManager.getConfiguration().addUser(validAdminUser, validAdminPassword);
    securityManager.getConfiguration().addUser(invalidAdminUser, invalidAdminPassword);
    securityManager.getConfiguration().addRole(validAdminUser, "admin");
    securityManager.getConfiguration().addRole(validAdminUser, "guest");
    securityManager.getConfiguration().addRole(invalidAdminUser, "guest");
    Set<Role> adminRole = securityRepository.getMatch(ActiveMQDefaultConfiguration.getDefaultManagementAddress().toString());
    adminRole.add(new Role("admin", true, true, true, true, true, true, true));
    securityRepository.addMatch(ActiveMQDefaultConfiguration.getDefaultManagementAddress().toString(), adminRole);
    Set<Role> guestRole = securityRepository.getMatch("*");
    guestRole.add(new Role("guest", true, true, true, true, true, true, false));
    securityRepository.addMatch("*", guestRole);
    return server;
}

63. SpawnedServerSupport#createSharedFolderConfig()

View license
static Configuration createSharedFolderConfig(String folder, int thisport, int otherport, boolean isBackup) {
    HAPolicyConfiguration haPolicyConfiguration = null;
    if (isBackup) {
        haPolicyConfiguration = new SharedStoreSlavePolicyConfiguration();
        ((SharedStoreSlavePolicyConfiguration) haPolicyConfiguration).setAllowFailBack(false);
    } else {
        haPolicyConfiguration = new SharedStoreMasterPolicyConfiguration();
    }
    Configuration config = createConfig(folder).clearAcceptorConfigurations().setJournalFileSize(15 * 1024 * 1024).addAcceptorConfiguration(createTransportConfigiguration(true, thisport)).addConnectorConfiguration("thisServer", createTransportConfigiguration(false, thisport)).addConnectorConfiguration("otherServer", createTransportConfigiguration(false, otherport)).setMessageExpiryScanPeriod(500).addClusterConfiguration(isBackup ? setupClusterConn("thisServer", "otherServer") : setupClusterConn("thisServer")).setHAPolicyConfiguration(haPolicyConfiguration);
    return config;
}

64. BatchDelayTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.BATCH_DELAY, DELAY);
    TransportConfiguration tc = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
    Configuration config = createBasicConfig().addAcceptorConfiguration(tc);
    server = createServer(false, config);
    server.start();
}

65. DirectDeliverTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.DIRECT_DELIVER, true);
    TransportConfiguration tc = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    Configuration config = createBasicConfig().addAcceptorConfiguration(tc);
    server = createServer(false, config);
    server.start();
    locator = createNettyNonHALocator();
    addServerLocator(locator);
}

66. LDAPSecurityTest#setUp()

View license
@Before
public void setUp() throws Exception {
    locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getCanonicalName()));
    testDir = temporaryFolder.getRoot().getAbsolutePath();
    ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager("LDAPLogin");
    Configuration configuration = new ConfigurationImpl().setSecurityEnabled(true).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName())).setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)).setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)).setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)).setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false));
    server = ActiveMQServers.newActiveMQServer(configuration, ManagementFactory.getPlatformMBeanServer(), securityManager, false);
}

67. ConnectionLimitTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Map<String, Object> nettyParams = new HashMap<>();
    nettyParams.put(TransportConstants.CONNECTIONS_ALLOWED, 1);
    Map<String, Object> invmParams = new HashMap<>();
    invmParams.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.CONNECTIONS_ALLOWED, 1);
    Configuration configuration = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, nettyParams)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, invmParams));
    server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
    server.start();
}

68. ResourceLimitTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    ResourceLimitSettings resourceLimitSettings = new ResourceLimitSettings();
    resourceLimitSettings.setMatch(SimpleString.toSimpleString("myUser"));
    resourceLimitSettings.setMaxConnections(1);
    resourceLimitSettings.setMaxQueues(1);
    Configuration configuration = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)).addResourceLimitSettings(resourceLimitSettings);
    server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
    server.start();
}

69. ExtraStompTest#createPersistentServerWithStompMinLargeSize()

View license
protected JMSServerManager createPersistentServerWithStompMinLargeSize(int sz) throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    params.put(TransportConstants.STOMP_MIN_LARGE_MESSAGE_SIZE, sz);
    TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    Configuration config = createBasicConfig().setPersistenceEnabled(true).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setBindings(getQueueName()));
    jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
    server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry((new InVMNamingContext())));
    return server;
}

70. ExtraStompTest#createServerWithExtraStompOptions()

View license
protected JMSServerManager createServerWithExtraStompOptions(String ttl, Boolean enableMessageID) throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    if (ttl != null) {
        params.put(TransportConstants.CONNECTION_TTL, ttl);
    }
    if (enableMessageID != null) {
        params.put(TransportConstants.STOMP_ENABLE_MESSAGE_ID, enableMessageID);
    }
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    TransportConfiguration stompTransport = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
    Configuration config = createBasicConfig().setPersistenceEnabled(false).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setDurable(false).setBindings(getQueueName()));
    jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
    server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
    return server;
}

71. ExtraStompTest#createServerWithStompInterceptor()

View license
protected JMSServerManager createServerWithStompInterceptor(List<String> stompIncomingInterceptor, List<String> stompOutgoingInterceptor) throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    TransportConfiguration stompTransport = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
    Configuration config = createBasicConfig().setPersistenceEnabled(false).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)).setIncomingInterceptorClassNames(stompIncomingInterceptor).setOutgoingInterceptorClassNames(stompOutgoingInterceptor);
    ActiveMQServer hornetQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setDurable(false).setBindings(getQueueName()));
    jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
    server = new JMSServerManagerImpl(hornetQServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
    return server;
}

72. StompWebSocketTest#createServer()

View license
/**
    * @return
    * @throws Exception
    */
private JMSServerManager createServer() throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT + 1);
    TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    Configuration config = createBasicConfig().addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName())).addQueueConfiguration(new CoreQueueConfiguration().setAddress(getQueueName()).setName(getQueueName()).setDurable(false));
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
    server.setRegistry(null);
    return server;
}

73. StompV11TestBase#createServer()

View license
/**
    * @return
    * @throws Exception
    */
protected JMSServerManager createServer() throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    Configuration config = createBasicConfig().setPersistenceEnabled(persistenceEnabled).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setBindings(getQueueName()));
    jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
    server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
    return server;
}

74. String64KLimitTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
    server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    locator = createInVMNonHALocator();
    sf = createSessionFactory(locator);
    session = sf.createSession();
}

75. JMSClusteredTestBase#createConfigServer()

View license
/**
    * @return
    */
protected Configuration createConfigServer(final int source, final int destination) throws Exception {
    final String destinationLabel = "toServer" + destination;
    final String sourceLabel = "server" + source;
    Configuration configuration = createDefaultInVMConfig(source).setSecurityEnabled(false).setJMXManagementEnabled(true).setPersistenceEnabled(false).addConnectorConfiguration(destinationLabel, new TransportConfiguration(InVMConnectorFactory.class.getName(), generateInVMParams(destination))).addConnectorConfiguration(sourceLabel, new TransportConfiguration(InVMConnectorFactory.class.getName(), generateInVMParams(source))).addClusterConfiguration(new ClusterConnectionConfiguration().setName(destinationLabel).setAddress("jms").setConnectorName(sourceLabel).setRetryInterval(250).setMaxHops(MAX_HOPS).setConfirmationWindowSize(1024).setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND).setStaticConnectors(new ArrayList<String>() {

        {
            add(destinationLabel);
        }
    }));
    configuration.getAddressesSettings().put("#", new AddressSettings().setRedistributionDelay(0));
    return configuration;
}

76. JMSTestBase#setUp()

Project: activemq-artemis
Source File: JMSTestBase.java
View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    mbeanServer = MBeanServerFactory.createMBeanServer();
    Configuration config = createDefaultConfig(true).setSecurityEnabled(useSecurity()).addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY)).setTransactionTimeoutScanPeriod(100);
    server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, usePersistence()));
    jmsServer = new JMSServerManagerImpl(server);
    namingContext = new InVMNamingContext();
    jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
    jmsServer.start();
    registerConnectionFactory();
}

77. SimpleSendReceiveSoakTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    clearDataRecreateServerDirs();
    Configuration config = createDefaultConfig(isNetty()).setJournalFileSize(10 * 1024 * 1024);
    server = createServer(IS_JOURNAL, config, -1, -1, new HashMap<String, AddressSettings>());
    server.start();
    ServerLocator locator = createFactory(isNetty());
    ClientSessionFactory sf = createSessionFactory(locator);
    ClientSession session = sf.createSession();
    session.createQueue(SimpleSendReceiveSoakTest.ADDRESS, SimpleSendReceiveSoakTest.ADDRESS, true);
    session.close();
}

78. MultiThreadConsumerStressTest#setupServer()

View license
private void setupServer(final JournalType journalType) throws Exception {
    Configuration config = createDefaultNettyConfig().setJournalType(journalType).setJournalFileSize(ActiveMQDefaultConfiguration.getDefaultJournalFileSize()).setJournalMinFiles(ActiveMQDefaultConfiguration.getDefaultJournalMinFiles()).setJournalCompactMinFiles(2).setJournalCompactPercentage(50);
    server = createServer(true, config);
    server.start();
    ServerLocator locator = createNettyNonHALocator().setBlockOnDurableSend(false).setBlockOnNonDurableSend(false).setBlockOnAcknowledge(false);
    sf = createSessionFactory(locator);
    ClientSession sess = sf.createSession();
    try {
        sess.createQueue(ADDRESS, QUEUE, true);
    } catch (Exception ignored) {
    }
    sess.close();
    locator.close();
    locator = createInVMNonHALocator();
    sf = createSessionFactory(locator);
}

79. PageCursorStressTest#createServer()

View license
/**
    * @throws Exception
    */
private void createServer() throws Exception {
    OperationContextImpl.clearContext();
    Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(true);
    server = createServer(true, config, PAGE_SIZE, PAGE_MAX, new HashMap<String, AddressSettings>());
    server.start();
    queueList.clear();
    try {
        queue = server.createQueue(ADDRESS, ADDRESS, null, true, false);
        queue.pause();
    } catch (Exception ignored) {
    }
}

80. JMSBridgeImplTest#setUp()

View license
@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);
}

81. RelativePathTest#testRelativePath()

View license
@Test
public void testRelativePath() throws Exception {
    Configuration configuration = createDefaultConfig(false);
    File instanceHome = new File(getTemporaryDir(), "artemisHome");
    File dataHome = new File(instanceHome, "data");
    // One folder up for testing
    File bindingsHome = new File(instanceHome, "../binx");
    System.out.println("InstanceHome->" + instanceHome);
    instanceHome.mkdirs();
    configuration.setBrokerInstance(instanceHome);
    configuration.setJournalDirectory("./data");
    configuration.setPagingDirectory("./paging");
    configuration.setBindingsDirectory("../binx");
    // one folder up from instance home
    configuration.setLargeMessagesDirectory("./large");
    ActiveMQServer server = createServer(true, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES, new HashMap<String, AddressSettings>());
    server.start();
    server.stop();
    checkData(dataHome, ".amq");
    checkData(bindingsHome, ".bindings");
}

82. RelativePathTest#testDataOutsideHome()

View license
@Test
public void testDataOutsideHome() throws Exception {
    Configuration configuration = createDefaultConfig(false);
    File instanceHome = new File(getTemporaryDir(), "artemisHome");
    configuration.setBrokerInstance(instanceHome);
    // the journal should be outside of the artemisInstance on this case
    File journalOutside = new File(getTemporaryDir(), "./journalOut").getAbsoluteFile();
    configuration.setJournalDirectory(journalOutside.getAbsolutePath());
    // Somewhere inside artemis.instance
    configuration.setBindingsDirectory("./bind");
    File bindingsInside = new File(instanceHome, "bind");
    //      configuration.setJournal
    System.out.println("Journal dir::" + configuration.getJournalDirectory());
    System.out.println("Journal loc::" + configuration.getJournalLocation());
    ActiveMQServer server = createServer(true, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES, new HashMap<String, AddressSettings>());
    server.start();
    server.stop();
    checkData(journalOutside, ".amq");
    // Checking if the journal created the lock as well
    checkData(journalOutside, "server.lock");
    checkData(bindingsInside, ".bindings");
}

83. ArtemisBrokerWrapper#start()

View license
@Override
public void start() throws Exception {
    clearDataRecreateServerDirs();
    mbeanServer = MBeanServerFactory.createMBeanServer();
    server = createServer(realStore, true);
    server.setMBeanServer(mbeanServer);
    server.getConfiguration().getAcceptorConfigurations().clear();
    Configuration serverConfig = server.getConfiguration();
    serverConfig.setJMXManagementEnabled(true);
    Map<String, AddressSettings> addressSettingsMap = serverConfig.getAddressesSettings();
    //do policy translation
    PolicyMap policyMap = this.bservice.getDestinationPolicy();
    if (policyMap != null) {
        translatePolicyMap(serverConfig, policyMap);
    }
    String match = "jms.queue.#";
    AddressSettings commonSettings = addressSettingsMap.get(match);
    if (commonSettings == null) {
        commonSettings = new AddressSettings();
        addressSettingsMap.put(match, commonSettings);
    }
    SimpleString dla = new SimpleString("jms.queue.ActiveMQ.DLQ");
    commonSettings.setDeadLetterAddress(dla);
    commonSettings.setAutoCreateJmsQueues(true);
    if (bservice.extraConnectors.size() == 0) {
        serverConfig.addAcceptorConfiguration("home", "tcp://localhost:61616");
    }
    for (BrokerService.ConnectorInfo info : bservice.extraConnectors) {
        addServerAcceptor(serverConfig, info);
    }
    serverConfig.setSecurityEnabled(enableSecurity);
    if (enableSecurity) {
        ActiveMQJAASSecurityManager sm = (ActiveMQJAASSecurityManager) server.getSecurityManager();
        SecurityConfiguration securityConfig = sm.getConfiguration();
        securityConfig.addRole("openwireSender", "sender");
        securityConfig.addUser("openwireSender", "SeNdEr");
        //sender cannot receive
        Role senderRole = new Role("sender", true, false, false, false, true, true, false);
        securityConfig.addRole("openwireReceiver", "receiver");
        securityConfig.addUser("openwireReceiver", "ReCeIvEr");
        //receiver cannot send
        Role receiverRole = new Role("receiver", false, true, false, false, true, true, false);
        securityConfig.addRole("openwireGuest", "guest");
        securityConfig.addUser("openwireGuest", "GuEsT");
        //guest cannot do anything
        Role guestRole = new Role("guest", false, false, false, false, false, false, false);
        securityConfig.addRole("openwireDestinationManager", "manager");
        securityConfig.addUser("openwireDestinationManager", "DeStInAtIoN");
        //guest cannot do anything
        Role destRole = new Role("manager", false, false, false, false, true, true, false);
        Map<String, Set<Role>> settings = server.getConfiguration().getSecurityRoles();
        if (settings == null) {
            settings = new HashMap<>();
            server.getConfiguration().setSecurityRoles(settings);
        }
        Set<Role> anySet = settings.get("#");
        if (anySet == null) {
            anySet = new HashSet<>();
            settings.put("#", anySet);
        }
        anySet.add(senderRole);
        anySet.add(receiverRole);
        anySet.add(guestRole);
        anySet.add(destRole);
    }
    Set<TransportConfiguration> acceptors = serverConfig.getAcceptorConfigurations();
    Iterator<TransportConfiguration> iter = acceptors.iterator();
    while (iter.hasNext()) {
        System.out.println("acceptor =>: " + iter.next());
    }
    jmsServer = new JMSServerManagerImpl(server);
    InVMNamingContext namingContext = new InVMNamingContext();
    jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
    jmsServer.start();
    server.start();
    stopped = false;
}

84. FailoverComplexClusterTest#commonSetup()

View license
//default setup for most tests
private void commonSetup() throws Exception {
    Map<String, String> params = new HashMap<>();
    params.put("rebalanceClusterClients", "true");
    params.put("updateClusterClients", "true");
    params.put("updateClusterClientsOnRemove", "true");
    Configuration config0 = createConfig("localhost", 0, params);
    Configuration config1 = createConfig("localhost", 1, params);
    Configuration config2 = createConfig("localhost", 2, params);
    deployClusterConfiguration(config0, 1, 2);
    deployClusterConfiguration(config1, 0, 2);
    deployClusterConfiguration(config2, 0, 1);
    servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    servers[2] = new EmbeddedJMS().setConfiguration(config2).setJmsConfiguration(new JMSConfigurationImpl());
    servers[0].start();
    servers[1].start();
    servers[2].start();
    Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
    Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
    Assert.assertTrue(servers[2].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
}

85. FailoverPriorityTest#setupThreeBrokers()

View license
private void setupThreeBrokers() throws Exception {
    params.put("rebalanceClusterClients", "false");
    params.put("updateClusterClients", "false");
    params.put("updateClusterClientsOnRemove", "false");
    Configuration config0 = createConfig("127.0.0.1", 0, params);
    Configuration config1 = createConfig("127.0.0.1", 1, params);
    Configuration config2 = createConfig("127.0.0.1", 2, params);
    deployClusterConfiguration(config0, 1, 2);
    deployClusterConfiguration(config1, 0, 2);
    deployClusterConfiguration(config2, 0, 1);
    servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    servers[2] = new EmbeddedJMS().setConfiguration(config2).setJmsConfiguration(new JMSConfigurationImpl());
    servers[0].start();
    servers[1].start();
    servers[2].start();
    Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
    Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
    Assert.assertTrue(servers[2].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
}

86. AutomaticColocatedQuorumVoteTest#getConfiguration()

View license
private Configuration getConfiguration(String identity, boolean scaleDown, TransportConfiguration liveConnector, TransportConfiguration liveAcceptor, TransportConfiguration... otherLiveNodes) throws Exception {
    Configuration configuration = createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(liveAcceptor).addConnectorConfiguration(liveConnector.getName(), liveConnector).setJournalDirectory(getJournalDir() + identity).setBindingsDirectory(getBindingsDir() + identity).setLargeMessagesDirectory(getLargeMessagesDir() + identity).setPagingDirectory(getPageDir() + identity).addQueueConfiguration(new CoreQueueConfiguration().setAddress("jms.queue.testQueue").setName("jms.queue.testQueue"));
    List<String> transportConfigurationList = new ArrayList<>();
    final ColocatedPolicyConfiguration haPolicy = new ColocatedPolicyConfiguration();
    for (TransportConfiguration otherLiveNode : otherLiveNodes) {
        configuration.addConnectorConfiguration(otherLiveNode.getName(), otherLiveNode);
        transportConfigurationList.add(otherLiveNode.getName());
        haPolicy.getExcludedConnectors().add(otherLiveNode.getName());
    }
    String[] input = new String[transportConfigurationList.size()];
    transportConfigurationList.toArray(input);
    configuration.addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), input));
    haPolicy.setBackupPortOffset(100);
    haPolicy.setBackupRequestRetries(-1);
    haPolicy.setBackupRequestRetryInterval(500);
    haPolicy.setMaxBackups(1);
    haPolicy.setRequestBackup(true);
    configuration.setHAPolicyConfiguration(haPolicy);
    if (!replicated) {
        SharedStoreMasterPolicyConfiguration ssmc = new SharedStoreMasterPolicyConfiguration();
        SharedStoreSlavePolicyConfiguration sssc = new SharedStoreSlavePolicyConfiguration();
        haPolicy.setLiveConfig(ssmc);
        haPolicy.setBackupConfig(sssc);
        if (scaleDown) {
            sssc.setScaleDownConfiguration(new ScaleDownConfiguration());
        }
    } else {
        ReplicatedPolicyConfiguration rpc = new ReplicatedPolicyConfiguration();
        ReplicaPolicyConfiguration rpc2 = new ReplicaPolicyConfiguration();
        haPolicy.setLiveConfig(rpc);
        haPolicy.setBackupConfig(rpc2);
        if (scaleDown) {
            rpc2.setScaleDownConfiguration(new ScaleDownConfiguration());
        }
    }
    return configuration;
}

87. MultipleLivesMultipleBackupsFailoverTest#createBackupConfig()

View license
protected void createBackupConfig(NodeManager nodeManager, int liveNode, int nodeid, boolean createClusterConnections, int[] otherBackupNodes, int... otherClusterNodes) throws Exception {
    Configuration config1 = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(isNetty(), true, generateParams(nodeid, isNetty()))).setHAPolicyConfiguration(sharedStore ? new SharedStoreSlavePolicyConfiguration() : new ReplicaPolicyConfiguration()).setBindingsDirectory(getBindingsDir() + "_" + liveNode).setJournalDirectory(getJournalDir() + "_" + liveNode).setPagingDirectory(getPageDir() + "_" + liveNode).setLargeMessagesDirectory(getLargeMessagesDir() + "_" + liveNode);
    for (int node : otherBackupNodes) {
        TransportConfiguration liveConnector = createTransportConfiguration(isNetty(), false, generateParams(node, isNetty()));
        config1.addConnectorConfiguration(liveConnector.getName(), liveConnector);
    }
    TransportConfiguration backupConnector = createTransportConfiguration(isNetty(), false, generateParams(nodeid, isNetty()));
    config1.addConnectorConfiguration(backupConnector.getName(), backupConnector);
    String[] clusterNodes = new String[otherClusterNodes.length];
    for (int i = 0; i < otherClusterNodes.length; i++) {
        TransportConfiguration connector = createTransportConfiguration(isNetty(), false, generateParams(otherClusterNodes[i], isNetty()));
        config1.addConnectorConfiguration(connector.getName(), connector);
        clusterNodes[i] = connector.getName();
    }
    config1.addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), clusterNodes));
    servers.put(nodeid, new SameProcessActiveMQServer(createInVMFailoverServer(true, config1, nodeManager, liveNode)));
}

88. FailoverComplexClusterTest#testFailOverWithUpdateClientsOnRemove()

View license
@Test
public void testFailOverWithUpdateClientsOnRemove() throws Exception {
    // Broker A
    Configuration config0 = createConfig(0, "?rebalanceClusterClients=true&updateClusterClients=true&updateClusterClientsOnRemove=true");
    // Broker B
    Configuration config1 = createConfig(1, "?rebalanceClusterClients=true&updateClusterClients=true&updateClusterClientsOnRemove=true");
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    servers[0].start();
    servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    servers[1].start();
    servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2);
    servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2);
    Thread.sleep(1000);
    // create client connecting only to A. It should receive broker B address whet it connects to A.
    setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=true");
    createClients(1);
    Thread.sleep(5000);
    // We stop broker A.
    servers[0].stop();
    servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 1);
    Thread.sleep(5000);
    // Client should failover to B.
    assertAllConnectedTo(BROKER_B_CLIENT_TC_ADDRESS);
}

89. FailoverPriorityTest#testPriorityBackup()

View license
@Test
public void testPriorityBackup() throws Exception {
    Configuration config0 = createConfig("127.0.0.1", 0);
    Configuration config1 = createConfig("127.0.0.1", 1);
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    servers[0].start();
    servers[1].start();
    Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Thread.sleep(1000);
    setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")?randomize=false&priorityBackup=true&initialReconnectDelay=1000&useExponentialBackOff=false");
    createClients(5);
    assertAllConnectedTo(urls.get(0));
    restart(false, 0, 1);
    for (int i = 0; i < 3; i++) {
        restart(true, 0, 1);
    }
    Thread.sleep(5000);
    restart(false, 0, 1);
}

90. FailoverPriorityTest#testPriorityBackupList()

View license
@Test
public void testPriorityBackupList() throws Exception {
    Configuration config0 = createConfig("127.0.0.1", 0);
    Configuration config1 = createConfig("127.0.0.1", 1);
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    servers[0].start();
    servers[1].start();
    Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Thread.sleep(1000);
    setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")?randomize=false&priorityBackup=true&priorityURIs=tcp://127.0.0.1:61617&initialReconnectDelay=1000&useExponentialBackOff=false");
    createClients(5);
    Thread.sleep(3000);
    assertAllConnectedTo(urls.get(1));
    restart(false, 1, 0);
    for (int i = 0; i < 3; i++) {
        restart(true, 1, 0);
    }
    restart(false, 1, 0);
}

91. FailoverPriorityTest#testPriorityBackupAndUpdateClients()

View license
@Test
public void testPriorityBackupAndUpdateClients() throws Exception {
    Configuration config0 = createConfig("127.0.0.1", 0);
    Configuration config1 = createConfig("127.0.0.1", 1);
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    servers[0].start();
    servers[1].start();
    Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Thread.sleep(1000);
    setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")?randomize=false&priorityBackup=true&initialReconnectDelay=1000&useExponentialBackOff=false");
    createClients(5);
    // Let's wait a little bit longer just in case it takes a while to realize that the
    // Broker A is the one with higher priority.
    Thread.sleep(5000);
    assertAllConnectedTo(urls.get(0));
}

92. FailoverRandomTest#setUp()

View license
@Before
public void setUp() throws Exception {
    Map<String, String> params = new HashMap<>();
    params.put("rebalanceClusterClients", "true");
    params.put("updateClusterClients", "true");
    params.put("updateClusterClientsOnRemove", "true");
    params.put("brokerName", "A");
    Configuration config0 = createConfig("127.0.0.1", 0, params);
    params.put("brokerName", "B");
    Configuration config1 = createConfig("127.0.0.2", 1, params);
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server0.start();
    server1.start();
    Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
}

93. FailoverTransportBrokerTest#setUp()

View license
@Before
public void setUp() throws Exception {
    Configuration config0 = createConfig(0);
    server = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    Configuration config1 = createConfig(1);
    remoteServer = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server.start();
    remoteServer.start();
}

94. FailoverUpdateURIsTest#testUpdateURIsViaFile()

View license
@Test
public void testUpdateURIsViaFile() throws Exception {
    String targetDir = "target/testUpdateURIsViaFile";
    new File(targetDir).mkdir();
    File updateFile = new File(targetDir + "/updateURIsFile.txt");
    LOG.info(updateFile);
    LOG.info(updateFile.toURI());
    LOG.info(updateFile.getAbsoluteFile());
    LOG.info(updateFile.getAbsoluteFile().toURI());
    FileOutputStream out = new FileOutputStream(updateFile);
    out.write(firstTcpUri.getBytes());
    out.close();
    Configuration config0 = createConfig(0);
    server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    server0.start();
    // no failover uri's to start with, must be read from file...
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:()?updateURIsURL=file:///" + updateFile.getAbsoluteFile());
    connection = cf.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue theQueue = session.createQueue(QUEUE_NAME);
    MessageProducer producer = session.createProducer(theQueue);
    MessageConsumer consumer = session.createConsumer(theQueue);
    Message message = session.createTextMessage("Test message");
    producer.send(message);
    Message msg = consumer.receive(2000);
    Assert.assertNotNull(msg);
    server0.stop();
    server0 = null;
    Configuration config1 = createConfig(10);
    server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server1.start();
    // add the transport uri for broker number 2
    out = new FileOutputStream(updateFile, true);
    out.write(",".getBytes());
    out.write(secondTcpUri.toString().getBytes());
    out.close();
    producer.send(message);
    msg = consumer.receive(2000);
    Assert.assertNotNull(msg);
}

95. FailoverUpdateURIsTest#testAutoUpdateURIs()

View license
@Test
public void testAutoUpdateURIs() throws Exception {
    Map<String, String> params = new HashMap<>();
    params.put("updateClusterClients", "true");
    Configuration config0 = createConfig("localhost", 0, params);
    deployClusterConfiguration(config0, 10);
    server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    server0.start();
    Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 1));
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + firstTcpUri + ")");
    connection = cf.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue theQueue = session.createQueue(QUEUE_NAME);
    MessageProducer producer = session.createProducer(theQueue);
    MessageConsumer consumer = session.createConsumer(theQueue);
    Message message = session.createTextMessage("Test message");
    producer.send(message);
    Message msg = consumer.receive(4000);
    Assert.assertNotNull(msg);
    Configuration config1 = createConfig(10);
    deployClusterConfiguration(config1, 0);
    server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server1.start();
    Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    TimeUnit.SECONDS.sleep(4);
    LOG.info("stopping brokerService 1");
    server0.stop();
    server0 = null;
    producer.send(message);
    msg = consumer.receive(4000);
    Assert.assertNotNull(msg);
}

96. FanoutTransportBrokerTest#setUp()

View license
@Before
public void setUp() throws Exception {
    Configuration config0 = createConfig(0);
    server = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    Configuration config1 = createConfig(1);
    remoteServer = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server.start();
    remoteServer.start();
}

97. LargeMessageOverReplicationTest#setUp()

View license
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    ruleFired.setCount(1);
    messageChunkCount = 0;
    TransportConfiguration liveConnector = TransportConfigurationUtils.getNettyConnector(true, 0);
    TransportConfiguration liveAcceptor = TransportConfigurationUtils.getNettyAcceptor(true, 0);
    TransportConfiguration backupConnector = TransportConfigurationUtils.getNettyConnector(false, 0);
    TransportConfiguration backupAcceptor = TransportConfigurationUtils.getNettyAcceptor(false, 0);
    Configuration backupConfig = createDefaultInVMConfig().setBindingsDirectory(getBindingsDir(0, true)).setJournalDirectory(getJournalDir(0, true)).setPagingDirectory(getPageDir(0, true)).setLargeMessagesDirectory(getLargeMessagesDir(0, true));
    Configuration liveConfig = createDefaultInVMConfig();
    ReplicatedBackupUtils.configureReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, liveAcceptor);
    liveServer = createServer(liveConfig);
    liveServer.getConfiguration().addQueueConfiguration(new CoreQueueConfiguration().setName("jms.queue.Queue").setAddress("jms.queue.Queue"));
    liveServer.start();
    waitForServerToStart(liveServer);
    backupServer = createServer(backupConfig);
    backupServer.start();
    waitForServerToStart(backupServer);
    // Just to make sure the expression worked
    Assert.assertEquals(10000, factory.getMinLargeMessageSize());
    Assert.assertEquals(10000, factory.getProducerWindowSize());
    Assert.assertEquals(100, factory.getRetryInterval());
    Assert.assertEquals(-1, factory.getReconnectAttempts());
    Assert.assertTrue(factory.isHA());
    connection = (ActiveMQConnection) factory.createConnection();
    waitForRemoteBackup(connection.getSessionFactory(), 30);
    session = connection.createSession(true, Session.SESSION_TRANSACTED);
    queue = session.createQueue("Queue");
    producer = session.createProducer(queue);
}

98. PagingOMETest#testPageCleanup()

Project: activemq-artemis
Source File: PagingOMETest.java
View license
@Test
@BMRules(rules = { @BMRule(name = "fakeOME", targetClass = "org.apache.activemq.artemis.core.paging.cursor.PagedReferenceImpl", targetMethod = "getPagedMessage", targetLocation = "ENTRY", action = "org.apache.activemq.artemis.tests.extras.byteman.PagingOMETest.refCheck()") })
public void testPageCleanup() throws Exception {
    clearDataRecreateServerDirs();
    Configuration config = createDefaultConfig(false);
    config.setJournalSyncNonTransactional(false);
    HashMap<String, AddressSettings> map = new HashMap<>();
    AddressSettings value = new AddressSettings();
    map.put(ADDRESS.toString(), value);
    server = createServer(true, config, PAGE_SIZE, PAGE_MAX, map);
    server.start();
    final int numberOfMessages = 2;
    locator = createInVMNonHALocator();
    locator.setBlockOnNonDurableSend(true);
    locator.setBlockOnDurableSend(true);
    locator.setBlockOnAcknowledge(false);
    locator.setConsumerWindowSize(0);
    sf = createSessionFactory(locator);
    ClientSession session = sf.createSession(false, false, false);
    session.createQueue(ADDRESS, ADDRESS, null, true);
    Queue queue = server.locateQueue(ADDRESS);
    queue.getPageSubscription().getPagingStore().startPaging();
    Assert.assertTrue(queue.getPageSubscription().getPagingStore().isPaging());
    ClientProducer producer = session.createProducer(PagingOMETest.ADDRESS);
    ClientMessage message = null;
    byte[] body = new byte[MESSAGE_SIZE];
    ByteBuffer bb = ByteBuffer.wrap(body);
    for (int j = 1; j <= MESSAGE_SIZE; j++) {
        bb.put(getSamplebyte(j));
    }
    for (int i = 0; i < numberOfMessages; i++) {
        message = session.createMessage(true);
        ActiveMQBuffer bodyLocal = message.getBodyBuffer();
        bodyLocal.writeBytes(body);
        producer.send(message);
        if (i % 1000 == 0) {
            session.commit();
        }
    }
    session.commit();
    session = sf.createSession(false, false, false);
    session.start();
    assertEquals(numberOfMessages, queue.getMessageCount());
    // The consumer has to be created after the queue.getMessageCount assertion
    // otherwise delivery could alter the messagecount and give us a false failure
    ClientConsumer consumer = session.createConsumer(PagingOMETest.ADDRESS);
    ClientMessage msg = null;
    msg = consumer.receive(1000);
    failureActive = true;
    msg.individualAcknowledge();
    try {
        session.commit();
        Assert.fail("exception expected");
    } catch (Exception expected) {
    }
    failureActive = false;
    session.rollback();
    session.close();
    sf.close();
    locator.close();
    server.stop();
    server.start();
    locator = createInVMNonHALocator();
    locator.setBlockOnNonDurableSend(true);
    locator.setBlockOnDurableSend(true);
    locator.setBlockOnAcknowledge(false);
    locator.setConsumerWindowSize(0);
    sf = createSessionFactory(locator);
    session = sf.createSession(false, false, false);
    consumer = session.createConsumer(PagingOMETest.ADDRESS);
    session.start();
    for (int i = 0; i < numberOfMessages; i++) {
        msg = consumer.receive(1000);
        Assert.assertNotNull(msg);
        msg.individualAcknowledge();
    }
    Assert.assertNull(consumer.receiveImmediate());
    session.commit();
    session.close();
    sf.close();
    server.stop();
}

99. ReplicationBackupTest#testReplicatedBackupAnnouncement()

View license
/*
   * simple test to induce a potential race condition where the server's acceptors are active, but the server's
   * state != STARTED
   */
@Test
@BMRules(rules = { @BMRule(name = "prevent backup annoucement", targetClass = "org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation", targetMethod = "run", targetLocation = "AT EXIT", action = "org.apache.activemq.artemis.tests.extras.byteman.ReplicationBackupTest.breakIt();") })
public void testReplicatedBackupAnnouncement() throws Exception {
    TransportConfiguration liveConnector = TransportConfigurationUtils.getNettyConnector(true, 0);
    TransportConfiguration liveAcceptor = TransportConfigurationUtils.getNettyAcceptor(true, 0);
    TransportConfiguration backupConnector = TransportConfigurationUtils.getNettyConnector(false, 0);
    TransportConfiguration backupAcceptor = TransportConfigurationUtils.getNettyAcceptor(false, 0);
    Configuration backupConfig = createDefaultInVMConfig().setBindingsDirectory(getBindingsDir(0, true)).setJournalDirectory(getJournalDir(0, true)).setPagingDirectory(getPageDir(0, true)).setLargeMessagesDirectory(getLargeMessagesDir(0, true));
    Configuration liveConfig = createDefaultInVMConfig();
    ReplicatedBackupUtils.configureReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, liveAcceptor);
    liveServer = createServer(liveConfig);
    // start the live server in a new thread so we can start the backup simultaneously to induce a potential race
    Thread startThread = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                liveServer.start();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    startThread.start();
    ruleFired.await();
    backupServer = createServer(backupConfig);
    backupServer.start();
    ActiveMQTestBase.waitForRemoteBackup(null, 3, true, backupServer);
}

100. StartStopDeadlockTest#testDeadlock()

View license
/*
   * simple test to make sure connect still works with some network latency  built into netty
   * */
@Test
@BMRules(rules = { @BMRule(name = "Server.start wait-init", targetClass = "org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl", targetMethod = "initialisePart2", targetLocation = "ENTRY", condition = "incrementCounter(\"server-Init\") == 2", action = "System.out.println(\"server backup init\"), waitFor(\"start-init\")"), @BMRule(name = "JMSServer.stop wait-init", targetClass = "org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl", targetMethod = "stop", targetLocation = "ENTRY", action = "signalWake(\"start-init\", true)"), @BMRule(name = "StartStopDeadlockTest tearDown", targetClass = "org.apache.activemq.artemis.tests.extras.byteman.StartStopDeadlockTest", targetMethod = "tearDown", targetLocation = "ENTRY", action = "deleteCounter(\"server-Init\")") })
public void testDeadlock() throws Exception {
    // A live server that will always be crashed
    Configuration confLive = createDefaultNettyConfig().setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration());
    final ActiveMQServer serverLive = addServer(ActiveMQServers.newActiveMQServer(confLive));
    serverLive.start();
    // A backup that will be waiting to be activated
    Configuration config = createDefaultNettyConfig().setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration());
    final ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, true));
    final JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
    final InVMNamingContext context = new InVMNamingContext();
    jmsServer.setRegistry(new JndiBindingRegistry(context));
    jmsServer.start();
    final AtomicInteger errors = new AtomicInteger(0);
    final CountDownLatch align = new CountDownLatch(2);
    final CountDownLatch startLatch = new CountDownLatch(1);
    Thread tCrasher = new Thread("tStart") {

        @Override
        public void run() {
            try {
                align.countDown();
                startLatch.await();
                System.out.println("Crashing....");
                serverLive.stop(true);
            } catch (Exception e) {
                errors.incrementAndGet();
                e.printStackTrace();
            }
        }
    };
    Thread tStop = new Thread("tStop") {

        @Override
        public void run() {
            try {
                align.countDown();
                startLatch.await();
                jmsServer.stop();
            } catch (Exception e) {
                errors.incrementAndGet();
                e.printStackTrace();
            }
        }
    };
    tCrasher.start();
    tStop.start();
    align.await();
    startLatch.countDown();
    tCrasher.join();
    tStop.join();
    assertEquals(0, errors.get());
}