use of com.adaptris.core.StandardWorkflow 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();
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class AdapterManagerTest method testMBean_SharedConnection_GarbageCollectedReferences.
@Test
public void testMBean_SharedConnection_GarbageCollectedReferences() throws Exception {
// Tests the behaviour with WeakHashMap inside AdaptrisConnectionImp
// We use the AdapterManager to test this, because we marshal the channel to XML to add it
// to the channel so we aren't actually holding a reference to it for the test.
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
Channel newChannel = createChannel(getName(), 1);
newChannel.setConsumeConnection(new SharedConnection(getName()));
newChannel.setProduceConnection(new SharedConnection(getName()));
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);
// Add the shared connection and the channel.
adapterManager.addSharedConnection(m.marshal(new NullConnection(getName())));
adapterManager.addChannel(m.marshal(newChannel));
adapterManager.requestStart();
adapterManager.requestClose();
NullConnection beforeRemove = (NullConnection) adapterManager.getWrappedComponent().getSharedComponents().getConnections().get(0);
assertEquals(1, beforeRemove.retrieveMessageConsumers().size());
assertEquals(1, beforeRemove.retrieveMessageProducers().size());
// one for the channel, and one for the service.
assertEquals(2, beforeRemove.retrieveExceptionListeners().size());
adapterManager.removeChannel(getName());
// Suggest a garbage collection which *should* remove the references for the connection.
System.gc();
Thread.sleep(1000);
adapterManager.requestStart();
NullConnection afterRemove = (NullConnection) adapterManager.getWrappedComponent().getSharedComponents().getConnections().get(0);
assertEquals(0, afterRemove.retrieveMessageConsumers().size());
assertEquals(0, afterRemove.retrieveMessageProducers().size());
assertEquals(0, afterRemove.retrieveExceptionListeners().size());
} finally {
adapterManager.requestClose();
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddSharedConnection_AddChannel_StartAdapter.
@Test
public void testMBean_AddSharedConnection_AddChannel_StartAdapter() 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);
newChannel.setConsumeConnection(new SharedConnection(getName()));
newChannel.setProduceConnection(new SharedConnection(getName()));
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);
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
amp.addSharedConnection(m.marshal(new NullConnection(getName())));
ObjectName channelObj = amp.addChannel(m.marshal(newChannel));
ChannelManagerMBean cmb = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
adapterManager.requestStart();
assertEquals(StartedState.getInstance(), cmb.getComponentState());
} finally {
adapterManager.requestClose();
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class ComponentManagerCase method createWorkflow.
protected StandardWorkflow createWorkflow(String uid) throws CoreException {
StandardWorkflow wf = new StandardWorkflow();
wf.setUniqueId(uid);
return wf;
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class DefaultFailedMessageRetrierJmxTest method testMBean_Retry_SerializableMessage_WorkflowNotFound.
@Test
public void testMBean_Retry_SerializableMessage_WorkflowNotFound() 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");
SerializableMessage serialized = new DefaultSerializableMessageTranslator().translate(msg);
AdapterManager adapterManager = new AdapterManager(adapter);
try {
adapterManager.registerMBean();
adapterManager.requestStart();
ObjectName retrierObjName = createRetrierObjectName(adapterManager);
DefaultFailedMessageRetrierJmxMBean jmxBean = JMX.newMBeanProxy(mBeanServer, retrierObjName, DefaultFailedMessageRetrierJmxMBean.class);
assertFalse(jmxBean.retryMessage(serialized));
assertEquals(0, mock.messageCount());
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
Aggregations