Search in sources :

Example 41 with StandardWorkflow

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();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 42 with StandardWorkflow

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();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) SharedConnection(com.adaptris.core.SharedConnection) MockServiceWithConnection(com.adaptris.core.stubs.MockServiceWithConnection) NullConnection(com.adaptris.core.NullConnection) Test(org.junit.Test)

Example 43 with StandardWorkflow

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();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) SharedConnection(com.adaptris.core.SharedConnection) MockServiceWithConnection(com.adaptris.core.stubs.MockServiceWithConnection) NullConnection(com.adaptris.core.NullConnection) Test(org.junit.Test)

Example 44 with StandardWorkflow

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;
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow)

Example 45 with StandardWorkflow

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();
    }
}
Also used : DefaultFailedMessageRetrierJmxMBean(com.adaptris.core.DefaultFailedMessageRetrierJmxMBean) StandardWorkflow(com.adaptris.core.StandardWorkflow) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SerializableMessage(com.adaptris.interlok.types.SerializableMessage) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) DefaultFailedMessageRetrier(com.adaptris.core.DefaultFailedMessageRetrier) DefaultSerializableMessageTranslator(com.adaptris.core.DefaultSerializableMessageTranslator) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

StandardWorkflow (com.adaptris.core.StandardWorkflow)102 Test (org.junit.Test)78 Channel (com.adaptris.core.Channel)67 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)55 Adapter (com.adaptris.core.Adapter)53 ObjectName (javax.management.ObjectName)41 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)38 TimeInterval (com.adaptris.util.TimeInterval)25 StandaloneProducer (com.adaptris.core.StandaloneProducer)20 BaseComponentMBean (com.adaptris.core.runtime.BaseComponentMBean)16 SimpleNotificationListener (com.adaptris.core.runtime.SimpleNotificationListener)16 ArrayList (java.util.ArrayList)14 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)12 MockChannel (com.adaptris.core.stubs.MockChannel)11 Notification (javax.management.Notification)11 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)10 ServiceList (com.adaptris.core.ServiceList)10 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)10 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)9 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)9