use of com.adaptris.core.Adapter in project interlok by adaptris.
the class AdapterManagerTest method testMBean_removeChannel_NotFound.
@Test
public void testMBean_removeChannel_NotFound() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
assertFalse(adapterManagerProxy.removeChannel(null));
assertFalse(adapterManagerProxy.removeChannel(getName()));
Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(adapterManagerProxy.getConfiguration());
assertEquals(0, marshalledAdapter.getChannelList().size());
} finally {
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class AdapterManagerTest method testMBean_RemoveSharedService.
@Test
public void testMBean_RemoveSharedService() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
adapter.getSharedComponents().addService(new NullService(getName()));
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
try {
adapterManager.registerMBean();
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
assertTrue(amp.removeSharedService(getName()));
assertFalse(amp.removeSharedService("HelloWorld"));
Adapter marshalledAdapter = (Adapter) m.unmarshal(amp.getConfiguration());
assertEquals(0, marshalledAdapter.getSharedComponents().getServices().size());
} finally {
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class AdapterManagerTest method testMBean_NotificationOnStop.
@Test
public void testMBean_NotificationOnStop() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
AdapterManager adapterManager = new AdapterManager(adapter);
SimpleNotificationListener listener = new SimpleNotificationListener();
ObjectName adapterObj = createAdapterObjectName(adapterName);
try {
adapterManager.registerMBean();
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
mBeanServer.addNotificationListener(adapterObj, listener, null, null);
manager.requestStart();
manager.requestStop();
assertEquals(StoppedState.getInstance(), manager.getComponentState());
listener.waitForMessages(2);
// Timing issues under github actions / jenkins / vm
// assertEquals(2, listener.getNotifications().size());
//
// // Get the last notification by sorting it.
// Notification n = listener.notificationsSortedBySeqNo().get(1);
// assertEquals(NOTIF_TYPE_ADAPTER_LIFECYCLE, n.getType());
// assertEquals(NOTIF_MSG_STOPPED, n.getMessage());
// assertEquals(StoppedState.getInstance(), n.getUserData());
} finally {
mBeanServer.removeNotificationListener(adapterObj, listener);
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class AdapterManagerTest method testMBean_NotificationOnInit.
@Test
public void testMBean_NotificationOnInit() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
AdapterManager adapterManager = new AdapterManager(adapter);
SimpleNotificationListener listener = new SimpleNotificationListener();
ObjectName adapterObj = createAdapterObjectName(adapterName);
try {
adapterManager.registerMBean();
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
mBeanServer.addNotificationListener(adapterObj, listener, null, null);
manager.requestInit();
assertEquals(InitialisedState.getInstance(), manager.getComponentState());
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification n = listener.getNotifications().get(0);
assertEquals(NOTIF_TYPE_ADAPTER_LIFECYCLE, n.getType());
assertEquals(NOTIF_MSG_INITIALISED, n.getMessage());
assertEquals(InitialisedState.getInstance(), n.getUserData());
} finally {
mBeanServer.removeNotificationListener(adapterObj, listener);
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class AdapterManagerTest method testAddChild.
@Test
public void testAddChild() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel c1 = createChannel(getName() + "_1");
Channel c2 = createChannel(getName() + "_2");
ChannelManager child1 = new ChannelManager(c1, adapterManager);
ChannelManager child2 = new ChannelManager(c2, adapterManager);
assertEquals(2, adapterManager.getChildren().size());
try {
adapterManager.addChild(child1);
} catch (IllegalArgumentException expected) {
assertTrue(expected.getMessage().startsWith("duplicate Channel ID"));
}
assertEquals(2, adapterManager.getChildren().size());
try {
adapterManager.addChild(null);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(2, adapterManager.getChildren().size());
assertEquals(2, adapter.getChannelList().size());
Adapter marshalledAdapter = (Adapter) new XStreamMarshaller().unmarshal(adapterManager.getConfiguration());
assertRoundtripEquality(adapter, marshalledAdapter);
}
Aggregations