Package org.mule.util

Examples of org.mule.util.StringDataSource


            }
        });

        LocalMuleClient client = muleContext.getClient();
        MuleMessage msg = new DefaultMuleMessage("test",  muleContext);
        msg.addOutboundAttachment("attach1", new DataHandler(new StringDataSource("foo", "attach1")));

        MuleMessage result = client.send("endpoint1", msg);
        assertEquals("We should have no attachments coming back", 0, result.getInboundAttachmentNames().size());
    }
View Full Code Here


        }

        if(attachments==null)
        {
            attachments = new HashMap<String, DataHandler>();
            attachments.put("foo", new DataHandler(new StringDataSource("fooValue")));
            attachments.put("bar", new DataHandler(new StringDataSource("barValue")));
            attachments.put("baz", new DataHandler(new StringDataSource("bazValue")));
        }
        MuleMessage message;
        message = new DefaultMuleMessage("test", muleContext);
        for (Map.Entry<String, DataHandler> attachment : attachments.entrySet())
        {
View Full Code Here

    public void testMapAttachmentsOptional() throws Exception
    {
        //clear baz attachment
        Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();
        attachments.put("foo", new DataHandler(new StringDataSource("fooValue")));
        attachments.put("bar", new DataHandler(new StringDataSource("barValue")));
        muleMessage = createMessage(null, attachments);

        MuleClient client = new MuleClient(muleContext);
        MuleMessage message = client.send("vm://attachmentsOptional", muleMessage);
        assertNotNull("return message from MuleClient.send() should not be null", message);
View Full Code Here

    public void testListAttachmentsWithOptional() throws Exception
    {
        //clear baz attachment
        Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();
        attachments.put("foo", new DataHandler(new StringDataSource("fooValue")));
        attachments.put("bar", new DataHandler(new StringDataSource("barValue")));
        muleMessage = createMessage(null, attachments);

        MuleClient client = new MuleClient(muleContext);
        MuleMessage message = client.send("vm://attachmentsListOptional", muleMessage);
        assertNotNull("return message from MuleClient.send() should not be null", message);
View Full Code Here

    public void testListAttachmentsWithMissing() throws Exception
    {
        //clear bar attachment
        Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();
        attachments.put("foo", new DataHandler(new StringDataSource("fooValue")));
        attachments.put("baz", new DataHandler(new StringDataSource("bazValue")));
        muleMessage = createMessage(null, attachments);
        try
        {
            muleContext.getClient().send("vm://attachmentsListOptional", muleMessage);
            fail("Exception expected");
View Full Code Here

    public void _testAttachments() throws Exception
    {
        String attachmentName = "the-attachment";
       
        MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
        DataHandler dataHandler = new DataHandler(new StringDataSource("attachment content"));
        message.addAttachment(attachmentName, dataHandler);
       
        MuleMessage deserializedMessage = serializationRoundtrip(message);
       
        assertEquals(1, deserializedMessage.getAttachmentNames().size());
View Full Code Here

*/
public class OutboundAttachmentsAnnotationComponent
{
    public Map<?, ?> processAttachments(@OutboundAttachments Map<String, DataHandler> attachments)
    {
        attachments.put("bar", new DataHandler(new StringDataSource("barValue")));
        //Verify that we receive any outbound attachments already set on the message
        if (attachments.containsKey("foo"))
        {
            //Overwrite the existing attachment to signal that we received it
            attachments.put("foo", new DataHandler(new StringDataSource("fooValue")));
        }
        return attachments;
    }
View Full Code Here

    protected MuleMessage createMessageWithAttachments()
    {
        try
        {
            Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();
            attachments.put("foo", new DataHandler(new StringDataSource("moo")));
            attachments.put("bar", new DataHandler(new StringDataSource("mar")));
            attachments.put("baz", new DataHandler(new StringDataSource("maz")));
            return new DefaultMuleMessage("test", null, attachments, muleContext);
        }
        catch (Exception e)
        {
            fail(e.getMessage());
View Full Code Here

    {

        try
        {
            Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();
            attachments.put("foo", new DataHandler(new StringDataSource("foovalue")));
            attachments.put("bar", new DataHandler(new StringDataSource("barvalue")));
            attachments.put("baz", new DataHandler(new StringDataSource("bazvalue")));
            message = new DefaultMuleMessage("test", null, attachments, muleContext);

        }
        catch (Exception e)
        {
View Full Code Here

        muleMessage = new DefaultMuleMessage("test", props, muleContext);

        try
        {
            muleMessage.addAttachment("foo", new DataHandler(new StringDataSource("fooValue")));
            muleMessage.addAttachment("bar", new DataHandler(new StringDataSource("barValue")));
            muleMessage.addAttachment("baz", new DataHandler(new StringDataSource("bazValue")));
        }
        catch (Exception e)
        {
            e.printStackTrace();
            fail(e.getMessage());
View Full Code Here

TOP

Related Classes of org.mule.util.StringDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.