Search in sources :

Example 1 with LoggingActiveMQServerPlugin

use of org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin in project activemq-artemis by apache.

the class LoggingActiveMQServerPluginTest method createServerWithLoggingPlugin.

protected ActiveMQServer createServerWithLoggingPlugin(String loggingPluginEventType) throws Exception {
    // initial plugin
    LoggingActiveMQServerPlugin loggingActiveMQServerPlugin = new LoggingActiveMQServerPlugin();
    Map<String, String> properties = new HashMap<>();
    properties.put(loggingPluginEventType, "true");
    loggingActiveMQServerPlugin.init(properties);
    // register
    Configuration config = createDefaultConfig(true);
    config.registerBrokerPlugin(loggingActiveMQServerPlugin);
    return createServer(false, config);
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) LoggingActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin) HashMap(java.util.HashMap)

Example 2 with LoggingActiveMQServerPlugin

use of org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin in project activemq-artemis by apache.

the class XmlConfigPluginTest method testLoggingActiveMQServerPluginWrongValue.

/**
 *  ensure the LoggingActiveMQServerPlugin uses default values when configured with incorrect values
 * @throws Exception
 */
@Test
public void testLoggingActiveMQServerPluginWrongValue() throws Exception {
    ActiveMQServer server = createServerFromConfig("broker-logging-plugin-wrong.xml");
    try {
        server.start();
        assertEquals("only one plugin should be registered", 1, server.getBrokerPlugins().size());
        assertTrue("ensure LoggingActiveMQServerPlugin is registered", server.getBrokerPlugins().get(0) instanceof LoggingActiveMQServerPlugin);
        LoggingActiveMQServerPlugin loggingActiveMQServerPlugin = (LoggingActiveMQServerPlugin) server.getBrokerPlugins().get(0);
        assertEquals("check logAll", false, loggingActiveMQServerPlugin.isLogAll());
        assertEquals("check logConnectionEvents", false, loggingActiveMQServerPlugin.isLogConnectionEvents());
        assertEquals("check logSessionEvents", false, loggingActiveMQServerPlugin.isLogSessionEvents());
        assertEquals("check logConsumerEvents", false, loggingActiveMQServerPlugin.isLogConsumerEvents());
        assertEquals("check logDeliveringEvents", false, loggingActiveMQServerPlugin.isLogDeliveringEvents());
        assertEquals("check logSendingEvents", false, loggingActiveMQServerPlugin.isLogSendingEvents());
        assertEquals("check logInternalEvents", false, loggingActiveMQServerPlugin.isLogInternalEvents());
    } finally {
        if (server != null) {
            server.stop();
        }
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) LoggingActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin) Test(org.junit.Test)

Example 3 with LoggingActiveMQServerPlugin

use of org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin in project activemq-artemis by apache.

the class XmlConfigPluginTest method testLoggingActiveMQServerPlugin.

/**
 * Ensure the configuration is bring picked up correctly by LoggingActiveMQServerPlugin
 * @throws Exception
 */
@Test
public void testLoggingActiveMQServerPlugin() throws Exception {
    ActiveMQServer server = createServerFromConfig("broker-logging-plugin.xml");
    try {
        server.start();
        assertEquals("only one plugin should be registered", 1, server.getBrokerPlugins().size());
        assertTrue("ensure LoggingActiveMQServerPlugin is registered", server.getBrokerPlugins().get(0) instanceof LoggingActiveMQServerPlugin);
        LoggingActiveMQServerPlugin loggingActiveMQServerPlugin = (LoggingActiveMQServerPlugin) server.getBrokerPlugins().get(0);
        assertEquals("check logAll", true, loggingActiveMQServerPlugin.isLogAll());
        assertEquals("check logConnectionEvents", true, loggingActiveMQServerPlugin.isLogConnectionEvents());
        assertEquals("check logSessionEvents", true, loggingActiveMQServerPlugin.isLogSessionEvents());
        assertEquals("check logConsumerEvents", true, loggingActiveMQServerPlugin.isLogConsumerEvents());
        assertEquals("check logDeliveringEvents", true, loggingActiveMQServerPlugin.isLogDeliveringEvents());
        assertEquals("check logSendingEvents", true, loggingActiveMQServerPlugin.isLogSendingEvents());
        assertEquals("check logInternalEvents", true, loggingActiveMQServerPlugin.isLogInternalEvents());
    } finally {
        if (server != null) {
            server.stop();
        }
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) LoggingActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin) Test(org.junit.Test)

Example 4 with LoggingActiveMQServerPlugin

use of org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin in project activemq-artemis by apache.

the class ConfigurationImplTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    boolean b = RandomUtil.randomBoolean();
    conf.setHAPolicyConfiguration(new LiveOnlyPolicyConfiguration());
    int i = RandomUtil.randomInt();
    conf.setScheduledThreadPoolMaxSize(i);
    Assert.assertEquals(i, conf.getScheduledThreadPoolMaxSize());
    long l = RandomUtil.randomLong();
    conf.setSecurityInvalidationInterval(l);
    Assert.assertEquals(l, conf.getSecurityInvalidationInterval());
    b = RandomUtil.randomBoolean();
    conf.setSecurityEnabled(b);
    Assert.assertEquals(b, conf.isSecurityEnabled());
    String s = RandomUtil.randomString();
    conf.setBindingsDirectory(s);
    Assert.assertEquals(s, conf.getBindingsDirectory());
    b = RandomUtil.randomBoolean();
    conf.setCreateBindingsDir(b);
    Assert.assertEquals(b, conf.isCreateBindingsDir());
    s = RandomUtil.randomString();
    conf.setJournalDirectory(s);
    Assert.assertEquals(s, conf.getJournalDirectory());
    b = RandomUtil.randomBoolean();
    conf.setCreateJournalDir(b);
    Assert.assertEquals(b, conf.isCreateJournalDir());
    i = RandomUtil.randomInt() % 2;
    JournalType journal = i == 0 ? JournalType.ASYNCIO : JournalType.NIO;
    conf.setJournalType(journal);
    Assert.assertEquals(journal, conf.getJournalType());
    b = RandomUtil.randomBoolean();
    conf.setJournalSyncTransactional(b);
    Assert.assertEquals(b, conf.isJournalSyncTransactional());
    b = RandomUtil.randomBoolean();
    conf.setJournalSyncNonTransactional(b);
    Assert.assertEquals(b, conf.isJournalSyncNonTransactional());
    i = RandomUtil.randomInt();
    conf.setJournalFileSize(i);
    Assert.assertEquals(i, conf.getJournalFileSize());
    i = RandomUtil.randomInt();
    conf.setJournalMinFiles(i);
    Assert.assertEquals(i, conf.getJournalMinFiles());
    i = RandomUtil.randomInt();
    conf.setJournalMaxIO_AIO(i);
    Assert.assertEquals(i, conf.getJournalMaxIO_AIO());
    i = RandomUtil.randomInt();
    conf.setJournalMaxIO_NIO(i);
    Assert.assertEquals(i, conf.getJournalMaxIO_NIO());
    s = RandomUtil.randomString();
    conf.setManagementAddress(new SimpleString(s));
    Assert.assertEquals(s, conf.getManagementAddress().toString());
    i = RandomUtil.randomInt();
    conf.setMessageExpiryThreadPriority(i);
    Assert.assertEquals(i, conf.getMessageExpiryThreadPriority());
    l = RandomUtil.randomLong();
    conf.setMessageExpiryScanPeriod(l);
    Assert.assertEquals(l, conf.getMessageExpiryScanPeriod());
    b = RandomUtil.randomBoolean();
    conf.setPersistDeliveryCountBeforeDelivery(b);
    Assert.assertEquals(b, conf.isPersistDeliveryCountBeforeDelivery());
    b = RandomUtil.randomBoolean();
    conf.setEnabledAsyncConnectionExecution(b);
    Assert.assertEquals(b, conf.isAsyncConnectionExecutionEnabled());
    b = RandomUtil.randomBoolean();
    conf.setPersistenceEnabled(b);
    Assert.assertEquals(b, conf.isPersistenceEnabled());
    b = RandomUtil.randomBoolean();
    conf.setJMXManagementEnabled(b);
    Assert.assertEquals(b, conf.isJMXManagementEnabled());
    l = RandomUtil.randomLong();
    conf.setFileDeployerScanPeriod(l);
    Assert.assertEquals(l, conf.getFileDeployerScanPeriod());
    l = RandomUtil.randomLong();
    conf.setConnectionTTLOverride(l);
    Assert.assertEquals(l, conf.getConnectionTTLOverride());
    i = RandomUtil.randomInt();
    conf.setThreadPoolMaxSize(i);
    Assert.assertEquals(i, conf.getThreadPoolMaxSize());
    SimpleString ss = RandomUtil.randomSimpleString();
    conf.setManagementNotificationAddress(ss);
    Assert.assertEquals(ss, conf.getManagementNotificationAddress());
    s = RandomUtil.randomString();
    conf.setClusterUser(s);
    Assert.assertEquals(s, conf.getClusterUser());
    i = RandomUtil.randomInt();
    conf.setIDCacheSize(i);
    Assert.assertEquals(i, conf.getIDCacheSize());
    b = RandomUtil.randomBoolean();
    conf.setPersistIDCache(b);
    Assert.assertEquals(b, conf.isPersistIDCache());
    i = RandomUtil.randomInt();
    conf.setJournalCompactMinFiles(i);
    Assert.assertEquals(i, conf.getJournalCompactMinFiles());
    i = RandomUtil.randomInt();
    conf.setJournalCompactPercentage(i);
    Assert.assertEquals(i, conf.getJournalCompactPercentage());
    i = RandomUtil.randomInt();
    conf.setJournalBufferSize_AIO(i);
    Assert.assertEquals(i, conf.getJournalBufferSize_AIO());
    i = RandomUtil.randomInt();
    conf.setJournalBufferTimeout_AIO(i);
    Assert.assertEquals(i, conf.getJournalBufferTimeout_AIO());
    i = RandomUtil.randomInt();
    conf.setJournalBufferSize_NIO(i);
    Assert.assertEquals(i, conf.getJournalBufferSize_NIO());
    i = RandomUtil.randomInt();
    conf.setJournalBufferTimeout_NIO(i);
    Assert.assertEquals(i, conf.getJournalBufferTimeout_NIO());
    b = RandomUtil.randomBoolean();
    conf.setLogJournalWriteRate(b);
    Assert.assertEquals(b, conf.isLogJournalWriteRate());
    l = RandomUtil.randomLong();
    conf.setServerDumpInterval(l);
    Assert.assertEquals(l, conf.getServerDumpInterval());
    s = RandomUtil.randomString();
    conf.setPagingDirectory(s);
    Assert.assertEquals(s, conf.getPagingDirectory());
    s = RandomUtil.randomString();
    conf.setLargeMessagesDirectory(s);
    Assert.assertEquals(s, conf.getLargeMessagesDirectory());
    b = RandomUtil.randomBoolean();
    conf.setWildcardRoutingEnabled(b);
    Assert.assertEquals(b, conf.isWildcardRoutingEnabled());
    l = RandomUtil.randomLong();
    conf.setTransactionTimeout(l);
    Assert.assertEquals(l, conf.getTransactionTimeout());
    b = RandomUtil.randomBoolean();
    conf.setMessageCounterEnabled(b);
    Assert.assertEquals(b, conf.isMessageCounterEnabled());
    l = RandomUtil.randomPositiveLong();
    conf.setMessageCounterSamplePeriod(l);
    Assert.assertEquals(l, conf.getMessageCounterSamplePeriod());
    i = RandomUtil.randomInt();
    conf.setMessageCounterMaxDayHistory(i);
    Assert.assertEquals(i, conf.getMessageCounterMaxDayHistory());
    l = RandomUtil.randomLong();
    conf.setTransactionTimeoutScanPeriod(l);
    Assert.assertEquals(l, conf.getTransactionTimeoutScanPeriod());
    s = RandomUtil.randomString();
    conf.setClusterPassword(s);
    Assert.assertEquals(s, conf.getClusterPassword());
    conf.registerBrokerPlugin(new LoggingActiveMQServerPlugin());
    Assert.assertEquals("ensure one plugin registered", 1, conf.getBrokerPlugins().size());
    // This will use serialization to perform a deep copy of the object
    Configuration conf2 = conf.copy();
    Assert.assertTrue(conf.equals(conf2));
}
Also used : LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) LoggingActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) JournalType(org.apache.activemq.artemis.core.server.JournalType) Test(org.junit.Test)

Aggregations

LoggingActiveMQServerPlugin (org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin)4 Test (org.junit.Test)3 Configuration (org.apache.activemq.artemis.core.config.Configuration)2 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)2 HashMap (java.util.HashMap)1 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 LiveOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration)1 JournalType (org.apache.activemq.artemis.core.server.JournalType)1