Search in sources :

Example 76 with Channel

use of com.adaptris.core.Channel in project interlok by adaptris.

the class WorkflowRetryAndFailTest method testFailedInitialise_ExceedsMax.

@Override
@Test
public void testFailedInitialise_ExceedsMax() throws Exception {
    WorkflowList wfl = new WorkflowList();
    WorkflowRetryAndFail strategy = new WorkflowRetryAndFail(2, new TimeInterval(10L, TimeUnit.MILLISECONDS.name()));
    FailInit workflow = new FailInit(3);
    wfl.add(workflow);
    wfl.setLifecycleStrategy(strategy);
    Channel c = createChannel(wfl);
    try {
        c.requestInit();
    } catch (CoreException expected) {
    }
    // That's right 1 + 2 retries.
    assertEquals(3, workflow.getAttempts());
    assertEquals(ClosedState.getInstance(), workflow.retrieveComponentState());
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) CoreException(com.adaptris.core.CoreException) WorkflowList(com.adaptris.core.WorkflowList) Channel(com.adaptris.core.Channel) Test(org.junit.Test)

Example 77 with Channel

use of com.adaptris.core.Channel in project interlok by adaptris.

the class ConfigurationCheckRunnerTest method createAdapterConfig.

private String createAdapterConfig(AdaptrisConnection sharedComponent, AdaptrisConnection consumeConnection, AdaptrisConnection produceConnection) throws Exception {
    Adapter adapter = new Adapter();
    if (sharedComponent != null) {
        adapter.getSharedComponents().addConnection(sharedComponent);
    }
    Channel channel = new Channel();
    if (consumeConnection != null) {
        channel.setConsumeConnection(consumeConnection);
    }
    if (produceConnection != null) {
        channel.setProduceConnection(produceConnection);
    }
    adapter.getChannelList().add(channel);
    return DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
}
Also used : Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter)

Example 78 with Channel

use of com.adaptris.core.Channel in project interlok by adaptris.

the class JavaxValidationCheckerTest method createAdapterConfig.

private Adapter createAdapterConfig(boolean validates, boolean channels) throws Exception {
    Adapter adapter = new Adapter();
    if (validates) {
        // have a unique-id
        adapter.setUniqueId("MyAdapter");
        AddTimestampMetadataService ts = new AddTimestampMetadataService();
        ts.setUniqueId("valid-add-timestamp-service");
        PayloadHashingService ph = new PayloadHashingService();
        ph.setUniqueId("valid-payload-hasher");
        ph.setMetadataKey("payloadHash");
        ph.setHashAlgorithm("SHA-256");
        adapter.getSharedComponents().addService(ts);
        adapter.getSharedComponents().addService(ph);
    } else {
        // no adapter unique-id
        // explicitly set add timestamp to have an empty key, thankfully
        // no checks on the setter...
        AddTimestampMetadataService ts = new AddTimestampMetadataService();
        ts.setUniqueId("invalid-add-timestamp-service");
        ts.setMetadataKey("");
        // don't specify the hash algo or the metadata-key
        PayloadHashingService ph = new PayloadHashingService();
        ph.setUniqueId("invalid-payload-hasher");
        adapter.getSharedComponents().addService(ts);
        adapter.getSharedComponents().addService(ph);
    }
    if (channels) {
        Channel c = new Channel();
        c.setUniqueId("channel");
        StandardWorkflow w = new StandardWorkflow();
        w.setUniqueId("workflow");
        if (!validates) {
            PayloadHashingService ph = new PayloadHashingService();
            ph.setUniqueId("invalid-payload-hasher-2");
            w.getServiceCollection().add(ph);
        }
        c.getWorkflowList().add(w);
        adapter.getChannelList().add(c);
    }
    return adapter;
}
Also used : PayloadHashingService(com.adaptris.core.services.metadata.PayloadHashingService) StandardWorkflow(com.adaptris.core.StandardWorkflow) AddTimestampMetadataService(com.adaptris.core.services.metadata.AddTimestampMetadataService) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter)

Example 79 with Channel

use of com.adaptris.core.Channel in project interlok by adaptris.

the class AdapterManagerTest method testMBean_AddAndBindSharedConnection_AddChannel_StartChannel.

@Test
public void testMBean_AddAndBindSharedConnection_AddChannel_StartChannel() 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);
    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);
        adapterManager.requestStart();
        AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
        amp.addAndBindSharedConnection(m.marshal(new NullConnection(getName())));
        ObjectName channelObj = amp.addChannel(m.marshal(newChannel));
        ChannelManagerMBean cmb = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        assertEquals(ClosedState.getInstance(), cmb.getComponentState());
        // This should start, referencing the shared connection in JNDI.
        cmb.requestStart();
    } 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 80 with Channel

use of com.adaptris.core.Channel in project interlok by adaptris.

the class AdapterManagerTest method testMBean_AddChannel.

@Test
public void testMBean_AddChannel() 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();
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    try {
        register(mBeans);
        AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
        ObjectName channelObj = adapterManagerProxy.addChannel(DefaultMarshaller.getDefaultMarshaller().marshal(newChannel));
        assertNotNull(channelObj);
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        assertEquals(ClosedState.getInstance(), channelManagerProxy.getComponentState());
        Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(adapterManagerProxy.getConfiguration());
        assertEquals(1, marshalledAdapter.getChannelList().size());
    } finally {
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

Channel (com.adaptris.core.Channel)322 Test (org.junit.Test)276 Adapter (com.adaptris.core.Adapter)136 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)125 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)122 StandardWorkflow (com.adaptris.core.StandardWorkflow)111 ObjectName (javax.management.ObjectName)97 ArrayList (java.util.ArrayList)74 StandaloneProducer (com.adaptris.core.StandaloneProducer)64 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)57 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)52 Workflow (com.adaptris.core.Workflow)44 MockChannel (com.adaptris.core.stubs.MockChannel)43 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)37 TimeInterval (com.adaptris.util.TimeInterval)36 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)35 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)35 ServiceList (com.adaptris.core.ServiceList)31 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)30 CoreException (com.adaptris.core.CoreException)29