Hi, Johan
This code solves it. But the number of hours spent on
this makes me squirm.
Thanks.
public void setUp() throws Exception {
mockStatic(ManagementFactory.class);
expect( ManagementFactory.getPlatformMBeanServer() ).
andReturn( EasyMock.createMock(MBeanServer.class) );
replayAll();
mBeanServerMock = ManagementFactory.getPlatformMBeanServer();
verifyAll();
}
@Test
public void testRegistration(){
try {
ObjectName on = new
ObjectName("com.test.bean:type=XMBean");
ObjectInstance oi = new ObjectInstance( on,
"com.test.bean.XMBean");
expect(mBeanServerMock.registerMBean(isA(XMBean.class),
eq(on))). --> Note this line too
andReturn(new ObjectInstance( on,
"com.test.bean.XMBean"));
}
}