use of com.adaptris.core.Channel in project interlok by adaptris.
the class AdapterManagerTest method testMBean_getArtifactIdentifiers.
@Test
public void testMBean_getArtifactIdentifiers() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
Channel newChannel1 = createChannel(getName() + "_1");
adapter.getChannelList().add(newChannel1);
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);
assertNotNull(adapterManagerProxy.getArtifactIdentifiers());
// Should be 3 in the versions
// The version for adp-core-apt.jar and adp-core.jar and interlok-common.
assertEquals(3, adapterManagerProxy.getArtifactIdentifiers().size());
} finally {
}
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddChannel_NoUniqueID.
@Test
public void testMBean_AddChannel_NoUniqueID() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel newChannel = new Channel();
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);
try {
adapterManagerProxy.addChannel(DefaultMarshaller.getDefaultMarshaller().marshal(newChannel));
fail();
} catch (CoreException expected) {
}
} finally {
}
}
use of com.adaptris.core.Channel 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);
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class ChannelManagerTest method testMBean_AddWorkflow.
@Test
public void testMBean_AddWorkflow() 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 = createWorkflow(getName() + "_1");
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 workflowObj = channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow));
assertNotNull(workflowObj);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
assertEquals(ClosedState.getInstance(), workflowManagerProxy.getComponentState());
Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(adapterManagerProxy.getConfiguration());
Channel 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.Channel in project interlok by adaptris.
the class ChannelManagerTest method testAdapterInitialised_StopChannel.
@Test
public void testAdapterInitialised_StopChannel() 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);
adapterManager.requestInit();
try {
channelManagerProxy.requestStop();
fail();
} catch (CoreException e) {
assertEquals(createErrorMessageString(adapterManager.getComponentState(), StoppedState.getInstance()), e.getMessage());
}
} finally {
adapter.requestClose();
}
}
Aggregations