Search in sources :

Example 31 with StandardWorkflow

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

the class BasicActiveMqConsumerTest method createDurableSubsAdapter.

private Adapter createDurableSubsAdapter(String adapterName, EmbeddedActiveMq activeMqBroker) throws Exception {
    Adapter adapter = new Adapter();
    adapter.setUniqueId(adapterName);
    Channel c = new Channel();
    JmsConnection conn = activeMqBroker.getJmsConnection(createVendorImpl());
    conn.setClientId(MY_CLIENT_ID);
    c.setConsumeConnection(conn);
    StandardWorkflow swf = new StandardWorkflow();
    PasConsumer pasConsumer = new PasConsumer().withTopic(new GuidGenerator().safeUUID());
    pasConsumer.setSubscriptionId(MY_SUBSCRIPTION_ID);
    swf.setConsumer(pasConsumer);
    c.getWorkflowList().add(swf);
    ChannelList cl = new ChannelList();
    cl.addChannel(c);
    adapter.setChannelList(cl);
    return adapter;
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) PasConsumer(com.adaptris.core.jms.PasConsumer) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) JmsConnection(com.adaptris.core.jms.JmsConnection) GuidGenerator(com.adaptris.util.GuidGenerator) ChannelList(com.adaptris.core.ChannelList)

Example 32 with StandardWorkflow

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

the class BasicActiveMqConsumerTest method testQueue_ProduceWhenConsumerStopped.

@Test
public void testQueue_ProduceWhenConsumerStopped() throws Exception {
    PtpConsumer consumer = new PtpConsumer().withQueue(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandardWorkflow workflow = new StandardWorkflow();
    MockMessageProducer producer = new MockMessageProducer();
    workflow.setConsumer(consumer);
    workflow.setProducer(producer);
    Channel channel = createChannel(activeMqBroker.getJmsConnection(createVendorImpl()), workflow);
    try {
        StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue((getName())));
        channel.requestStart();
        workflow.requestStop();
        start(standaloneProducer);
        AdaptrisMessage msg = createMessage(null);
        standaloneProducer.produce(msg);
        Thread.sleep(250);
        assertEquals(0, producer.messageCount());
        stop(standaloneProducer);
    } finally {
        channel.requestClose();
    }
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) StandardWorkflow(com.adaptris.core.StandardWorkflow) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 33 with StandardWorkflow

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

the class ActiveJmsConnectionErrorHandlerTest method createWorkflow.

private Workflow createWorkflow(EmbeddedActiveMq mq, String destName) throws Exception {
    StandardWorkflow wf = new StandardWorkflow();
    PasConsumer consumer = new PasConsumer().withTopic(destName);
    wf.setProducer(new MockMessageProducer());
    wf.setConsumer(consumer);
    return wf;
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) PasConsumer(com.adaptris.core.jms.PasConsumer) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer)

Example 34 with StandardWorkflow

use of com.adaptris.core.StandardWorkflow 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 35 with StandardWorkflow

use of com.adaptris.core.StandardWorkflow 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)

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