brusdev commented on code in PR #5333: URL: https://github.com/apache/activemq-artemis/pull/5333#discussion_r1836287191
########## tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java: ########## @@ -233,6 +235,64 @@ public void testRedeployConnector() throws Exception { } } + @Test + public void testRedeployPlugin() throws Exception { + Path brokerXML = getTestDirfile().toPath().resolve("broker.xml"); + URL url1 = RedeployTest.class.getClassLoader().getResource("reload-plugin.xml"); + URL url2 = RedeployTest.class.getClassLoader().getResource("reload-plugin-updated.xml"); + Files.copy(url1.openStream(), brokerXML); + + EmbeddedActiveMQ embeddedActiveMQ = new EmbeddedActiveMQ(); + embeddedActiveMQ.setConfigResourcePath(brokerXML.toUri().toString()); + embeddedActiveMQ.start(); + + final ReusableLatch latch = new ReusableLatch(1); + + Runnable tick = latch::countDown; + + embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick); + + try { + latch.await(10, TimeUnit.SECONDS); + + assertEquals(0, embeddedActiveMQ.getActiveMQServer().getBrokerPlugins().size()); + + embeddedActiveMQ.getActiveMQServer().registerBrokerPlugin(new NotificationActiveMQServerPlugin()); + + assertEquals(1, embeddedActiveMQ.getActiveMQServer().getBrokerPlugins().size()); + assertTrue(embeddedActiveMQ.getActiveMQServer().getBrokerPlugins().stream() + .anyMatch(plugin -> + plugin instanceof NotificationActiveMQServerPlugin)); + + Files.copy(url2.openStream(), brokerXML, StandardCopyOption.REPLACE_EXISTING); + brokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000); + latch.setCount(1); + embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick); + latch.await(10, TimeUnit.SECONDS); + + assertEquals(2, embeddedActiveMQ.getActiveMQServer().getBrokerPlugins().size()); + assertTrue(embeddedActiveMQ.getActiveMQServer().getBrokerPlugins().stream() + .anyMatch(plugin -> + plugin instanceof NotificationActiveMQServerPlugin)); + assertTrue(embeddedActiveMQ.getActiveMQServer().getBrokerPlugins().stream() + .anyMatch(plugin -> + plugin instanceof LoggingActiveMQServerPlugin)); + + Files.copy(url1.openStream(), brokerXML, StandardCopyOption.REPLACE_EXISTING); + brokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000); + latch.setCount(1); + embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick); + latch.await(10, TimeUnit.SECONDS); + + assertEquals(1, embeddedActiveMQ.getActiveMQServer().getBrokerPlugins().size()); Review Comment: Why is `embeddedActiveMQ.getActiveMQServer().getBrokerPlugins().size() == 1` after the configuration reload? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For additional commands, e-mail: gitbox-h...@activemq.apache.org For further information, visit: https://activemq.apache.org/contact