stopBroker();
_monitor.markDiscardPoint();
RestTestHelper restTestHelper = new RestTestHelper(findFreePort());
TestBrokerConfiguration config = getBrokerConfiguration();
config.addHttpManagementConfiguration();
config.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT, Port.PORT, restTestHelper.getHttpPort());
config.removeObjectConfiguration(Port.class, TestBrokerConfiguration.ENTRY_NAME_JMX_PORT);
config.removeObjectConfiguration(Port.class, TestBrokerConfiguration.ENTRY_NAME_RMI_PORT);
Map<String, Object> anonymousProviderAttributes = new HashMap<String, Object>();
anonymousProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE);
anonymousProviderAttributes.put(AuthenticationProvider.NAME, "testAnonymous");
config.addObjectConfiguration(AuthenticationProvider.class, anonymousProviderAttributes);
// set password authentication provider on http port for the tests
config.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT, Port.AUTHENTICATION_PROVIDER,
TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER);
config.setObjectAttribute(Plugin.class, TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
config.setSaved(false);
restTestHelper.setUsernameAndPassword("webadmin", "webadmin");
startBroker();
setupConnection();
// Validate the queue depth is as expected
long messageCount = ((AMQSession<?, ?>) _session).getQueueDepth((AMQDestination) _destination);
assertEquals("Broker has invalid message count for test", 2, messageCount);
// Ensure the alert has not occurred yet
assertLoggingNotYetOccured(MESSAGE_COUNT_ALERT);
// Change max message count to 5, start broker and make sure that that's triggered at the right time
TestBrokerConfiguration brokerConfiguration = getBrokerConfiguration();
setTestSystemProperty("queue.alertThresholdQueueDepthMessages","5");
brokerConfiguration.setSaved(false);
restTestHelper.submitRequest("queue/test/test/" + getTestQueueName(), "PUT", Collections.<String, Object>singletonMap(org.apache.qpid.server.model.Queue.ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, 5));
// Trigger the new value
sendMessage(_session, _destination, 3);
_session.commit();
// Validate that the alert occurred.