use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ChannelManagerTest method testAdapterStopped_InitChannel.
@Test
public void testAdapterStopped_InitChannel() 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.requestStart();
adapterManager.requestStop();
try {
channelManagerProxy.requestInit();
fail();
} catch (CoreException e) {
assertEquals(createErrorMessageString(adapterManager.getComponentState(), InitialisedState.getInstance()), e.getMessage());
}
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class DefaultFailedMessageRetrierJmxTest method testMBean_Retry_File_NotEncoded.
@Test
public void testMBean_Retry_File_NotEncoded() throws Exception {
Adapter adapter = createAdapter(getName());
Channel c = createChannel(getName());
StandardWorkflow wf = createWorkflow(getName());
MockMessageProducer mock = new MockMessageProducer();
wf.setProducer(mock);
c.getWorkflowList().add(wf);
adapter.getChannelList().add(c);
DefaultFailedMessageRetrier retrier = new DefaultFailedMessageRetrier();
adapter.setFailedMessageRetrier(retrier);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(Workflow.WORKFLOW_ID_KEY, getName() + "@BLAHBLAH");
File fileToRetry = writeFile(msg, null);
AdapterManager adapterManager = new AdapterManager(adapter);
try {
adapterManager.registerMBean();
adapterManager.requestStart();
ObjectName retrierObjName = createRetrierObjectName(adapterManager);
DefaultFailedMessageRetrierJmxMBean jmxBean = JMX.newMBeanProxy(mBeanServer, retrierObjName, DefaultFailedMessageRetrierJmxMBean.class);
try {
jmxBean.retryMessage(fileToRetry);
fail();
} catch (CoreException expected) {
}
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class WorkflowManagerTest method testChannelClosed_StartWorkflow.
@Test
public void testChannelClosed_StartWorkflow() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
Workflow workflow = createWorkflow("w1");
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
ObjectName channelObj = channelManager.createObjectName();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
adapterManager.requestStart();
channelManagerProxy.requestClose(TIMEOUT_MILLIS);
try {
workflowManagerProxy.requestStart(TIMEOUT_MILLIS);
fail();
} catch (CoreException e) {
assertEquals(createErrorMessageString(ClosedState.getInstance(), StartedState.getInstance()), e.getMessage());
}
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class WorkflowManagerTest method testChannelInitialised_StartWorkflow.
@Test
public void testChannelInitialised_StartWorkflow() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
Workflow workflow = createWorkflow("w1");
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
ObjectName channelObj = channelManager.createObjectName();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
adapterManager.requestStart();
channelManager.requestClose();
channelManager.requestInit();
try {
workflowManagerProxy.requestStart(TIMEOUT_MILLIS);
fail();
} catch (CoreException e) {
assertEquals(createErrorMessageString(InitialisedState.getInstance(), StartedState.getInstance()), e.getMessage());
}
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class WorkflowManagerTest method testChannelClosed_StopWorkflow.
@Test
public void testChannelClosed_StopWorkflow() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
Workflow workflow = createWorkflow("w1");
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
ObjectName channelObj = channelManager.createObjectName();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
adapterManager.requestStart();
channelManagerProxy.requestClose(TIMEOUT_MILLIS);
try {
workflowManagerProxy.requestStop(TIMEOUT_MILLIS);
fail();
} catch (CoreException e) {
assertEquals(createErrorMessageString(ClosedState.getInstance(), StoppedState.getInstance()), e.getMessage());
}
} finally {
adapter.requestClose();
}
}
Aggregations