@Test
public void testTwoSameNamedEndpoint() throws Exception {
SpringBusFactory factory = new SpringBusFactory();
Bus bus = factory.createBus();
try {
InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
assertNotNull(im);
InstrumentationManagerImpl imi = (InstrumentationManagerImpl)im;
imi.setServer(ManagementFactory.getPlatformMBeanServer());
imi.setEnabled(true);
imi.init();
Greeter greeter1 = new GreeterImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello");
svrFactory.setServiceBean(greeter1);
svrFactory.getProperties(true).put("managed.endpoint.name", "greeter1");
svrFactory.create();
Greeter greeter2 = new GreeterImpl();
svrFactory = new JaxWsServerFactoryBean();
svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello2");
svrFactory.setServiceBean(greeter2);
svrFactory.getProperties(true).put("managed.endpoint.name", "greeter2");
svrFactory.create();
MBeanServer mbs = im.getMBeanServer();
ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME
+ ":type=Bus.Service.Endpoint,*");
Set<?> s = mbs.queryMBeans(name, null);
assertEquals(2, s.size());