Hi The mbean name you create is for a route, so it's a RouteMBean.
You can use jconsole to look inside the running Camel test and see what mbeans there are etc. You can just add a thread sleep (long value) to keep the jvm running. Then find the right mbean you want to get and update your test code. Also take a look at the existing tests in camel-management etc. On Tue, Jan 2, 2024 at 6:53 PM Steve973 <steve...@gmail.com> wrote: > Hi, Claus. Yes, I have included camel-management as a test-scoped > dependency. > > On Tue, Jan 2, 2024 at 12:24 AM Claus Ibsen <claus.ib...@gmail.com> wrote: > > > Hi > > > > Have you added camel-management as a dependency. > > > > On Tue, Jan 2, 2024 at 2:15 AM Steve973 <steve...@gmail.com> wrote: > > > > > Hello. I have a CamelSpringBootTest, and I am trying to test that my > > > mbeans have been registered. This is how I am trying to check: > > > > > > @CamelSpringTest > > > @ContextConfiguration > > > @DirtiesContext(classMode = > > > DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) > > > class DynamicRouterJmxIT { > > > > > > @Autowired > > > CamelContext camelContext; > > > > > > @Test > > > void testExpectedMbeansExist() throws MalformedObjectNameException > { > > > Assertions.assertTrue(camelContext.isStarted()); > > > MBeanServer mBeanServer = > > > > > > camelContext.getManagementStrategy().getManagementAgent().getMBeanServer(); > > > ObjectName name = new > > > > > > > > > ObjectName("org.apache.camel:context=camelContext,type=routes,name=\"testRoute\""); > > > DynamicRouterControlService controlMbean = > > > JMX.newMBeanProxy(mBeanServer, name, > > > DynamicRouterControlService.class); > > > DynamicRouterFilterService filterMbean = > > > JMX.newMBeanProxy(mBeanServer, name, > > > DynamicRouterFilterService.class); > > > Assertions.assertNotNull(controlMbean); > > > Assertions.assertNotNull(filterMbean); > > > } > > > } > > > > > > Here is the XML that I am using for it, called > > > DynamicRouterJmxIT-context.xml: > > > > > > <beans xmlns="http://www.springframework.org/schema/beans" > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > > xsi:schemaLocation=" > > > http://www.springframework.org/schema/beans > > > http://www.springframework.org/schema/beans/spring-beans.xsd > > > http://camel.apache.org/schema/spring > > > http://camel.apache.org/schema/spring/camel-spring.xsd"> > > > > > > <camelContext id="camelContext" xmlns=" > > > http://camel.apache.org/schema/spring"> > > > <!-- enable JMX --> > > > <jmxAgent id="agent" disabled="false"/> > > > <route> > > > <from uri="direct:start" id="testRoute"/> > > > <to uri="dynamic-router:test"/> > > > </route> > > > <route> > > > <from uri="direct:subscribe-no-url-predicate"/> > > > <toD uri="dynamic-router-control:subscribe > > > ?subscribeChannel=${headers.subscribeChannel} > > > &subscriptionId=${headers.subscriptionId} > > > &destinationUri=${headers.destinationUri} > > > &priority=${headers.priority}"/> > > > </route> > > > </camelContext> > > > </beans> > > > > > > > > > I keep getting this error: > > > > > > Cannot invoke "org.apache.camel.spi.ManagementAgent.getMBeanServer()" > > > because the return value of > > > "org.apache.camel.spi.ManagementStrategy.getManagementAgent()" is null > > > > > > What am I doing wrong? > > > > > > Thanks, > > > Steve > > > > > > > > > -- > > Claus Ibsen > > ----------------- > > @davsclaus > > Camel in Action 2: https://www.manning.com/ibsen2 > > > -- Claus Ibsen ----------------- @davsclaus Camel in Action 2: https://www.manning.com/ibsen2