@Test public void testAttributes() throws Exception { TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString()); acceptorConfig.getParams().put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, "password"); 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()); Assert.assertNotEquals(acceptorConfig.getParams().get(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME), acceptorControl.getParameters().get(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME)); Assert.assertEquals("****", acceptorControl.getParameters().get(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME)); }
Assert.assertTrue(acceptorControl.isStarted()); ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); session.close(); acceptorControl.stop(); Assert.assertFalse(acceptorControl.isStarted()); acceptorControl.start(); Assert.assertTrue(acceptorControl.isStarted()); session.close(); acceptorControl.stop(); Assert.assertFalse(acceptorControl.isStarted());
@Test public void testNotifications() throws Exception { TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString()); TransportConfiguration acceptorConfig2 = new TransportConfiguration(NettyAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString()); Configuration config = createBasicConfig().addAcceptorConfiguration(acceptorConfig).addAcceptorConfiguration(acceptorConfig2); ActiveMQServer service = createServer(false, config); service.setMBeanServer(mbeanServer); service.start(); AcceptorControl acceptorControl = createManagementControl(acceptorConfig2.getName()); SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener(); service.getManagementService().addNotificationListener(notifListener); Assert.assertEquals(0, notifListener.getNotifications().size()); acceptorControl.stop(); Assert.assertEquals(usingCore() ? 5 : 1, notifListener.getNotifications().size()); Notification notif = notifListener.getNotifications().get(usingCore() ? 2 : 0); Assert.assertEquals(CoreNotificationType.ACCEPTOR_STOPPED, notif.getType()); Assert.assertEquals(NettyAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString()); acceptorControl.start(); Assert.assertEquals(usingCore() ? 10 : 2, notifListener.getNotifications().size()); notif = notifListener.getNotifications().get(usingCore() ? 7 : 1); Assert.assertEquals(CoreNotificationType.ACCEPTOR_STARTED, notif.getType()); Assert.assertEquals(NettyAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString()); }