AntonRoskvist commented on code in PR #5333:
URL: https://github.com/apache/activemq-artemis/pull/5333#discussion_r1836359623


##########
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:
   I added some comments clarifying this.
   
   I start the broker without any plugins.
   I add one plugin programmatically (which should not be affected by following 
configuration reloads).
   I add one plugin through configuration, then remove the same plugin through 
configuration.
   
   The final assert is then to verify that the programmatically added plugin 
stayed registered.



-- 
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


Reply via email to