Search in sources :

Example 1 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class JmsTransactedWorkflowTest method createPlainChannel.

private Channel createPlainChannel() throws Exception {
    GuidGenerator guid = new GuidGenerator();
    Channel result = new MockChannel();
    result.setUniqueId(guid.create(result));
    result.setMessageErrorHandler(new NullProcessingExceptionHandler());
    return result;
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) GuidGenerator(com.adaptris.util.GuidGenerator) NullProcessingExceptionHandler(com.adaptris.core.NullProcessingExceptionHandler)

Example 2 with GuidGenerator

use of com.adaptris.util.GuidGenerator 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 3 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class FileBackedMimeEncoderTest method generateOutput.

private File generateOutput() throws Exception {
    File file = TempFileUtils.createTrackedFile(this);
    MultiPartOutput output = new MultiPartOutput(new GuidGenerator().getUUID());
    output.addPart(STANDARD_PAYLOAD.getBytes(), "base64", "AdaptrisMessage/payload");
    Properties p = new Properties();
    p.setProperty(METADATA_KEY, METADATA_VALUE);
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    p.store(bytes, "");
    bytes.close();
    output.addPart(bytes.toByteArray(), "base64", "AdaptrisMessage/metadata");
    output.addPart(STANDARD_PAYLOAD_NON_JUST_ALPHA.getBytes(), "base64", "Dude/SomeOtherPart");
    try (FileOutputStream out = new FileOutputStream(file)) {
        output.writeTo(out);
    }
    return file;
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) FileOutputStream(java.io.FileOutputStream) GuidGenerator(com.adaptris.util.GuidGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Properties(java.util.Properties) File(java.io.File)

Example 4 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class WorkflowManagerTest method testInjectMessage.

@Test
public void testInjectMessage() 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);
    StandardWorkflow workflow = createWorkflow("w1");
    MockMessageProducer mockProducer = new MockMessageProducer();
    workflow.setProducer(mockProducer);
    WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
    adapterManager.createObjectName();
    ObjectName workflowObj = realWorkflowManager.createObjectName();
    channelManager.createObjectName();
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    String msgUniqueId = new GuidGenerator().getUUID();
    SerializableAdaptrisMessage msg = createSAM(msgUniqueId);
    try {
        register(mBeans);
        WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
        adapterManager.requestStart();
        workflowManagerProxy.processAsync(msg);
        assertEquals(1, mockProducer.getMessages().size());
        AdaptrisMessage procMsg = mockProducer.getMessages().get(0);
        assertEquals(msgUniqueId, procMsg.getUniqueId());
        assertEquals(PAYLOAD, procMsg.getContent());
        assertEquals(PAYLOAD_ENCODING, procMsg.getContentEncoding());
        assertTrue(procMsg.headersContainsKey(METADATA_KEY));
        assertEquals(METADATA_VALUE, procMsg.getMetadataValue(METADATA_KEY));
    } finally {
        adapter.requestClose();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) ObjectName(javax.management.ObjectName) GuidGenerator(com.adaptris.util.GuidGenerator) Test(org.junit.Test)

Example 5 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class WorkflowManagerTest method testProcess.

@Test
public void testProcess() 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);
    StandardWorkflow workflow = createWorkflow("w1");
    workflow.getServiceCollection().add(new AddMetadataService(Arrays.asList(new MetadataElement(getName(), getName()))));
    WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
    adapterManager.createObjectName();
    ObjectName workflowObj = realWorkflowManager.createObjectName();
    channelManager.createObjectName();
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    String msgUniqueId = new GuidGenerator().getUUID();
    SerializableMessage msg = createSM(msgUniqueId);
    try {
        register(mBeans);
        MessageProcessor workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
        adapterManager.requestStart();
        SerializableMessage reply = workflowManagerProxy.process(msg);
        assertEquals(msgUniqueId, reply.getUniqueId());
        assertEquals(PAYLOAD, reply.getContent());
        assertEquals(PAYLOAD_ENCODING, reply.getContentEncoding());
        Map<String, String> headers = reply.getMessageHeaders();
        assertTrue(headers.containsKey(METADATA_KEY));
        assertEquals(METADATA_VALUE, headers.get(METADATA_KEY));
        assertTrue(headers.containsKey(getName()));
        assertEquals(getName(), headers.get(getName()));
        assertEquals("", reply.getNextServiceId());
    } finally {
        adapter.requestClose();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) Channel(com.adaptris.core.Channel) MessageProcessor(com.adaptris.interlok.management.MessageProcessor) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) ObjectName(javax.management.ObjectName) StubSerializableMessage(com.adaptris.core.stubs.StubSerializableMessage) SerializableMessage(com.adaptris.interlok.types.SerializableMessage) GuidGenerator(com.adaptris.util.GuidGenerator) Test(org.junit.Test)

Aggregations

GuidGenerator (com.adaptris.util.GuidGenerator)134 Test (org.junit.Test)120 File (java.io.File)91 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)61 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)30 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)27 TimeInterval (com.adaptris.util.TimeInterval)25 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)24 RandomAccessFile (java.io.RandomAccessFile)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)23 FilenameFilter (java.io.FilenameFilter)21 ArrayList (java.util.ArrayList)20 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)18 LargeFsConsumer (com.adaptris.core.lms.LargeFsConsumer)15 Properties (java.util.Properties)15 Adapter (com.adaptris.core.Adapter)14 CoreException (com.adaptris.core.CoreException)11 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)9 ServiceException (com.adaptris.core.ServiceException)8 IOException (java.io.IOException)8