Package org.mule.api

Examples of org.mule.api.MuleEvent


        if (flow.isIgnore())
        {
            return;
        }

        MuleEvent event = muleEvent();
        run(event, before);

        showDescription();

        try
        {
            flow.process(event);
        }
        catch (Throwable t)
        {
            if (!flow.expectException(t, event))
            {
                t.setStackTrace(buildMuleStackTrace(event.getMuleContext())
                                        .toArray(new StackTraceElement[] {}));
                throw t;
            }

        }
View Full Code Here


                        original.setInvocationProperty("newProperty", "propertyValue");
                        return original;
                    }
                });

        MuleEvent eventResult = runFlow("outboundEndPointFlow", testEvent(" Hello world!]"));

        assertEquals("propertyValue", eventResult.getMessage().getInvocationProperty("newProperty"));
    }
View Full Code Here

                .ofNamespace("jira")
                .before(beforeCallSpy())
                .after(afterCallSpy());


        MuleEvent eventResult = runFlow("callingJira", testEvent("anotherString"));

        verifyCallOfMessageProcessor("create-group")
                .ofNamespace("jira").atLeast(1);

        verifyCallOfMessageProcessor("create-group")
                .ofNamespace("jira").times(1);

        assertEquals("expectedPayload", eventResult.getMessage().getPayload());

    }
View Full Code Here

        whenMessageProcessor("flow")
                .withAttributes(attribute("name").withValue("callingJira"))
                .thenReturn(muleMessageWithPayload("hello world"));


        MuleEvent muleEvent = runFlow("untilSuccessfulFlow", testEvent("something"));

        Thread.sleep(3000l);
        assertEquals("something", muleEvent.getMessage().getPayload());
        verifyCallOfMessageProcessor("flow").withAttributes(attribute("name").withValue("callingJira")).atLeastOnce();
    }
View Full Code Here

    }

    @Test
    public void executeSubSFlowWithSetValue() throws Exception{

        MuleEvent event = testEvent("");
        event.setFlowVariable("uiUsername", "testPass");
        event.setFlowVariable("requestUsername", "testPass");

       runFlow("setValueFlow", event);

        assertEquals(true, event.getFlowVariable("areCredentialsValid"));
    }
View Full Code Here

    }

    @Test
    public void test() throws Exception {

        MuleEvent event = testEvent("");
        event.setFlowVariable("test", 0);

        runFlow("subFlow", event);

        verifyCallOfMessageProcessor("logger").times(1);
    }
View Full Code Here

            result.setSkipped(true);
            return result;
        }

        long start = System.currentTimeMillis();
        MuleEvent event = muleEvent();

        try
        {
            run(event, before);
            showDescription();
            test.process(event);
            if (StringUtils.isNotBlank(test.getExpectExceptionThatSatisfies()))
            {
                fail("Exception matching '" + test.getExpectExceptionThatSatisfies() + "', but wasn't thrown");
            }
        }
        catch (final AssertionError t)
        {
            result.setFailure(buildNotifcationFrom(t));
        }
        catch (final MuleException e)
        {
            try
            {
                if (!test.expectException(e, event))
                {
                    e.setStackTrace(buildMuleStackTrace(event.getMuleContext())
                                            .toArray(new StackTraceElement[] {}));
                    result.setError(buildNotifcationFrom(e));
                }
            }
            catch (final AssertionError t)
            {
                t.setStackTrace(buildMuleStackTrace(event.getMuleContext())
                                        .toArray(new StackTraceElement[] {}));
                result.setFailure(buildNotifcationFrom(t));
            }
        }
        finally
        {
            MunitCore.reset(event.getMuleContext());
            runAfter(result, event);
        }

        long end = System.currentTimeMillis();
        result.setTime(new Float(end - start) / 1000);
View Full Code Here

public class HttpBasicAuthenticationFilterTestCase extends AbstractMuleTestCase
{

    public void testAuthenticationHeaderFailure() throws Exception
    {
        MuleEvent oldEvent = RequestContext.getEvent();

        MuleEvent event = this.getTestEvent("a");
        MuleMessage message = event.getMessage();
        message.setProperty(HttpConstants.HEADER_AUTHORIZATION, "Basic a", PropertyScope.INBOUND);
        RequestContext.setEvent(event);

        HttpBasicAuthenticationFilter filter = new HttpBasicAuthenticationFilter();

        SecurityManager manager = mock(SecurityManager.class);
        filter.setSecurityManager(manager);

        doThrow(new UnauthorisedException(null, (MuleEvent) null)).when(manager).authenticate(
            (Authentication) anyObject());

        try
        {
            filter.authenticateInbound(event);
            fail("An UnauthorisedException should be thrown");
        }
        catch (UnauthorisedException e)
        {
            assertNotNull(event.getMessage().getProperty("WWW-Authenticate"));
            assertEquals("Basic realm=", event.getMessage().getProperty("WWW-Authenticate"));
            verify(manager);
        }
        RequestContext.setEvent(oldEvent);
    }
View Full Code Here

    public void testProcess() throws Exception
    {
        InboundEndpoint endpoint = createTestInboundEndpoint(null, null);
        MessageProcessor mp = new InboundExceptionDetailsMessageProcessor(endpoint.getConnector());

        MuleEvent event = createTestInboundEvent(endpoint);
        event.getMessage().setExceptionPayload(new DefaultExceptionPayload(new RuntimeException()));

        MuleEvent result = mp.process(event);

        assertNotNull(result);
        final int status = result.getMessage().getOutboundProperty("status", 0);
        assertEquals(500, status);

    }
View Full Code Here

        final Orange orange = new Orange();
        map.put("apple", apple);
        map.put("banana", banana);
        map.put("orange", orange);

        MuleEvent result = ((Flow) muleContext.getRegistry().lookupFlowConstruct("split-map")).process(getTestEvent(map));

        assertNotNull(result);
        assertTrue(result.getMessage() instanceof MuleMessageCollection);

        final MuleMessageCollection coll = (MuleMessageCollection) result.getMessage();
        assertEquals(3, coll.size());
        final MuleMessage[] results = coll.getMessagesAsArray();

        assertTrue(apple.isBitten());
        assertTrue(banana.isBitten());
View Full Code Here

TOP

Related Classes of org.mule.api.MuleEvent

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.