djcoleman commented on code in PR #4663:
URL: https://github.com/apache/camel-quarkus/pull/4663#discussion_r1138394936


##########
integration-tests-jvm/management/src/test/java/org/apache/camel/quarkus/component/management/it/ManagementTest.java:
##########
@@ -24,23 +24,69 @@
 import javax.management.ObjectName;
 
 import io.quarkus.test.junit.QuarkusTest;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 @QuarkusTest
 class ManagementTest {
 
+    private MBeanServer server;
+
+    @Inject
+    ProducerTemplate template;
+
+    @Inject
+    CamelContext camelContext;
+
+    @BeforeEach
+    public void setUp() {
+        server = ManagementFactory.getPlatformMBeanServer();
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = { "components", "consumers", "context", 
"dataformats", "endpoints", "processors", "routes",
+            "services" })
+    public void testManagementObjects(String type) throws Exception {
+        // Look up an object instance by type
+        ObjectName objectName = new ObjectName("org.apache.camel:type=" + type 
+ ",*");
+        Set<ObjectInstance> mbeans = server.queryMBeans(objectName, null);
+        assertTrue(mbeans.size() > 0);
+
+        // The CamelId attribute is common to all managed Camel objects,
+        // and should match the name of the CamelContext.
+        ObjectInstance mbean = mbeans.iterator().next();
+        String camelId = (String) server.getAttribute(mbean.getObjectName(), 
"CamelId");
+        assertEquals(camelContext.getName(), camelId);
+    }
+
     @Test
-    public void testCamelManagement() throws Exception {
-        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
-        ObjectName objectName = new 
ObjectName("org.apache.camel:type=context,*");
+    public void testManagedBean() throws Exception {
+        ObjectName objectName = new 
ObjectName("org.apache.camel:type=processors,name=\"counter\",*");
         Set<ObjectInstance> mbeans = server.queryMBeans(objectName, null);
         assertEquals(1, mbeans.size());
-
         ObjectInstance instance = mbeans.iterator().next();
-        String routeXML = (String) server.invoke(instance.getObjectName(), 
"dumpRoutesAsXml", new Object[] {}, new String[] {});

Review Comment:
   Sure, I can add that check back in.



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