use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddSharedConnection_NoUniqueID.
@Test
public void testMBean_AddSharedConnection_NoUniqueID() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
try {
adapterManager.registerMBean();
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
try {
amp.addSharedConnection(m.marshal(new NullConnection()));
fail();
} catch (IllegalArgumentException e) {
}
} finally {
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddAndBindSharedConnection_AddChannel_StartChannel.
@Test
public void testMBean_AddAndBindSharedConnection_AddChannel_StartChannel() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
Channel newChannel = createChannel(getName(), 1);
StandardWorkflow wf = (StandardWorkflow) newChannel.getWorkflowList().getWorkflows().get(0);
MockServiceWithConnection service = new MockServiceWithConnection(new SharedConnection(getName()));
wf.getServiceCollection().add(service);
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
adapterManager.requestStart();
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
amp.addAndBindSharedConnection(m.marshal(new NullConnection(getName())));
ObjectName channelObj = amp.addChannel(m.marshal(newChannel));
ChannelManagerMBean cmb = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
assertEquals(ClosedState.getInstance(), cmb.getComponentState());
// This should start, referencing the shared connection in JNDI.
cmb.requestStart();
} finally {
adapterManager.requestClose();
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testMBean_RemoveSharedComponent.
@Test
public void testMBean_RemoveSharedComponent() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
adapter.getSharedComponents().addService(new NullService(NullService.class.getCanonicalName()));
adapter.getSharedComponents().addConnection(new NullConnection(NullConnection.class.getCanonicalName()));
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.removeSharedComponent(NullService.class.getCanonicalName()));
assertFalse(amp.removeSharedComponent("HelloWorld"));
Adapter marshalledAdapter = (Adapter) m.unmarshal(amp.getConfiguration());
assertEquals(0, marshalledAdapter.getSharedComponents().getServices().size());
assertTrue(amp.removeSharedComponent(NullConnection.class.getCanonicalName()));
marshalledAdapter = (Adapter) m.unmarshal(amp.getConfiguration());
assertEquals(0, marshalledAdapter.getSharedComponents().getConnections().size());
} finally {
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testMBean_RemoveSharedConnection.
@Test
public void testMBean_RemoveSharedConnection() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
adapter.getSharedComponents().addConnection(new NullConnection(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);
amp.removeSharedConnection(getName());
Adapter marshalledAdapter = (Adapter) m.unmarshal(amp.getConfiguration());
assertEquals(0, marshalledAdapter.getSharedComponents().getConnections().size());
} finally {
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testMBean_Notification_AddAndBindSharedConnection.
@Test
public void testMBean_Notification_AddAndBindSharedConnection() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
SimpleNotificationListener listener = new SimpleNotificationListener();
NotificationFilterSupport filter = new NotificationFilterSupport();
filter.enableType(NOTIF_TYPE_ADAPTER_CONFIG);
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
adapterManager.requestStart();
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
mBeanServer.addNotificationListener(adapterObj, listener, filter, null);
amp.addAndBindSharedConnection(m.marshal(new NullConnection(getName())));
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification n = listener.getNotifications().get(0);
assertEquals(NOTIF_TYPE_ADAPTER_CONFIG, n.getType());
assertEquals(NOTIF_MSG_CONFIG_UPDATED, n.getMessage());
assertEquals(amp.getConfiguration(), n.getUserData());
} finally {
adapterManager.requestClose();
}
}
Aggregations