use of com.adaptris.core.Adapter in project interlok by adaptris.
the class ChannelManagerTest method testRestart.
@Test
public void testRestart() 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);
ObjectName adapterObj = adapterManager.createObjectName();
ObjectName channelObj = child1.createObjectName();
try {
adapterManager.registerMBean();
adapterManager.requestStart();
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
channelManagerProxy.requestStop();
assertEquals(StoppedState.getInstance(), channelManagerProxy.getComponentState());
channelManagerProxy.requestRestart();
assertEquals(StartedState.getInstance(), channelManagerProxy.getComponentState());
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class ChannelManagerTest method testAdapterClosed_CloseChannel.
@Test
public void testAdapterClosed_CloseChannel() 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);
ObjectName adapterObj = adapterManager.createObjectName();
ObjectName channelObj = child1.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>(Arrays.asList(new BaseComponentMBean[] { adapterManager, child1, child2 }));
try {
register(mBeans);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
assertEquals(ClosedState.getInstance(), channelManagerProxy.getComponentState());
channelManagerProxy.requestClose();
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class ChannelManagerTest method testMBean_RemoveWorkflow.
@Test
public void testMBean_RemoveWorkflow() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel newChannel = createChannel(getName() + "_1");
ObjectName adapterObj = adapterManager.createObjectName();
ChannelManager channelManager = new ChannelManager(newChannel, adapterManager);
ObjectName channelObj = channelManager.createObjectName();
StandardWorkflow newWorkflow1 = createWorkflow(getName() + "_1");
StandardWorkflow newWorkflow2 = createWorkflow(getName() + "_2");
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
adapterManager.registerMBean();
AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
ObjectName workflowObj1 = channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow1));
ObjectName workflowObj2 = channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow2));
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj1, WorkflowManagerMBean.class);
Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(adapterManagerProxy.getConfiguration());
Channel marshalledChannel = (Channel) DefaultMarshaller.getDefaultMarshaller().unmarshal(channelManagerProxy.getConfiguration());
assertEquals(1, marshalledAdapter.getChannelList().size());
assertEquals(2, marshalledAdapter.getChannelList().get(0).getWorkflowList().size());
assertEquals(2, marshalledChannel.getWorkflowList().size());
assertTrue(channelManagerProxy.removeWorkflow(newWorkflow1.getUniqueId()));
marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(adapterManagerProxy.getConfiguration());
marshalledChannel = (Channel) DefaultMarshaller.getDefaultMarshaller().unmarshal(channelManagerProxy.getConfiguration());
assertEquals(1, marshalledAdapter.getChannelList().size());
assertEquals(1, marshalledAdapter.getChannelList().get(0).getWorkflowList().size());
assertEquals(1, marshalledChannel.getWorkflowList().size());
} finally {
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class ChannelManagerTest method testProxyEquality.
@Test
public void testProxyEquality() 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);
ObjectName adapterObj = adapterManager.createObjectName();
ObjectName channelObj = child1.createObjectName();
try {
adapterManager.registerMBean();
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
assertEquals(child1, channelManagerProxy);
assertFalse(child1 == channelManagerProxy);
} finally {
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class ChannelManagerTest method testMBean_AddWorkflow_NoUniqueId.
@Test
public void testMBean_AddWorkflow_NoUniqueId() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel newChannel = createChannel(getName() + "_1");
ObjectName adapterObj = adapterManager.createObjectName();
ChannelManager channelManager = new ChannelManager(newChannel, adapterManager);
ObjectName channelObj = channelManager.createObjectName();
StandardWorkflow newWorkflow = new StandardWorkflow();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
adapterManager.registerMBean();
AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
try {
ObjectName workflowObj = channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow));
fail();
} catch (CoreException e) {
}
} finally {
adapterManager.requestClose();
}
}
Aggregations