jbertram commented on code in PR #4488:
URL: https://github.com/apache/activemq-artemis/pull/4488#discussion_r1262647465


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java:
##########
@@ -257,6 +257,32 @@ public void testSecurityCacheSizes() throws Exception {
       Wait.assertEquals(usingCore() ? 8 : 1, () -> 
serverControl.getAuthorizationCacheSize());
    }
 
+   @Test
+   public void testClearingSecurityCaches() throws Exception {
+      ActiveMQServerControl serverControl = createManagementControl();
+
+      ServerLocator loc = createInVMNonHALocator();
+      ClientSessionFactory csf = createSessionFactory(loc);
+      ClientSession session = csf.createSession("myUser", "myPass", false, 
true, false, false, 0);
+      session.start();
+
+      final String address = "ADDRESS";
+      serverControl.createAddress(address, "MULTICAST");
+      ClientProducer producer = session.createProducer(address);
+      ClientMessage m = session.createMessage(true);
+      m.putStringProperty("hello", "world");
+      producer.send(m);
+
+      Assert.assertTrue(serverControl.getAuthenticationCacheSize() > 0);
+      Wait.assertTrue(() -> serverControl.getAuthorizationCacheSize() > 0);
+
+      serverControl.clearAuthenticationCache();
+      serverControl.clearAuthorizationCache();
+
+      Assert.assertEquals(usingCore() ? 1 : 0, 
serverControl.getAuthenticationCacheSize());

Review Comment:
   The `usingCore()` method is implemented by:
   
    - 
`org.apache.activemq.artemis.tests.integration.management.ActiveMQServerControlTest`
 (returns `false`)
    - 
`org.apache.activemq.artemis.tests.integration.management.ActiveMQServerControlUsingCoreTest`
 (returns `true`)
   
   This method is meant to indicate when core _messages_ are being used for 
management rather than JMX. Using core requires an extra connection so the 
management messages can be sent. This extra connection (and everything that 
goes with it like authentications and authorizations) need to be ignored so 
that the same tests work with or without core.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to