Package org.mule.api

Examples of org.mule.api.MuleEventContext


    public void testMethodCaching() throws Exception
    {
        Method method = this.getClass().getMethod(METHOD, new Class[] { String.class});
        Method anotherMethod = AnotherClass.class.getMethod(METHOD, new Class[] { String.class});

        MuleEventContext eventContext = mock(MuleEventContext.class);
        MockEntryPointResolver epResolver = new MockEntryPointResolver();

        epResolver.addMethodByName(this, method, eventContext);
        Method method1 = epResolver.getMethodByName(this, METHOD, eventContext);
        assertEquals(method, method1);
View Full Code Here


{
    private final static Log log = LogFactory.getLog(MuleProvider.class);

    public ResponseContext request(RequestContext request)
    {
        MuleEventContext ctx = (MuleEventContext)
                request.getAttribute(Scope.REQUEST, AbderaServiceComponent.EVENT_CONTEXT);

        try
        {
            MuleMessage requestMessage = new DefaultMuleMessage(request, ctx.getMuleContext());
            MuleMessage res = ctx.sendEvent(requestMessage);

            return (ResponseContext) res.getPayload();
        }
        catch (MuleException e)
        {
View Full Code Here

        Enhancer e = new Enhancer();
        e.setSuperclass(WaterMelon.class);
        e.setCallback(new DummyMethodCallback());
        Object proxy = e.create();

        MuleEventContext context = getTestEventContext("Blah");
        InvocationResult result = resolver.invoke(proxy, context);
        assertEquals(result.getState(), InvocationResult.State.SUCCESSFUL);
    }
View Full Code Here

    @Test
    public void testAnnotatedMethod() throws Exception
    {
        AnnotatedEntryPointResolver resolver = new AnnotatedEntryPointResolver();
        AnnotatedComponent component = new AnnotatedComponent();
        MuleEventContext context = getTestEventContext(TEST_PAYLOAD);
        //Since AnnotatedComponent2 has two annotated methods we need to set the method to call
        context.getMessage().setProperty(MuleProperties.MULE_METHOD_PROPERTY, "doStuff", PropertyScope.INVOCATION);
        InvocationResult result = resolver.invoke(component, context);
        assertEquals(result.getState(), InvocationResult.State.SUCCESSFUL);
        assertTrue(result.getResult() instanceof Map);
        Map<?, ?> map = (Map<?, ?>) result.getResult();
        assertEquals(3, map.size());
View Full Code Here

    @Test
    public void testAnnotatedMethod2() throws Exception
    {
        AnnotatedEntryPointResolver resolver = new AnnotatedEntryPointResolver();
        AnnotatedComponent component = new AnnotatedComponent();
        MuleEventContext context = getTestEventContext(TEST_PAYLOAD);
        //Since AnnotatedComponent2 has two annotated methods we need to set the method to call
        context.getMessage().setProperty(MuleProperties.MULE_METHOD_PROPERTY, "doStuff2", PropertyScope.INVOCATION);
        InvocationResult result = resolver.invoke(component, context);
        assertEquals(result.getState(), InvocationResult.State.SUCCESSFUL);
        assertTrue(result.getResult() instanceof Map);
        Map<?, ?> map = (Map<?, ?>) result.getResult();
        assertEquals(3, map.size());
View Full Code Here

    @Test
    public void testAnnotatedMethod3() throws Exception
    {
        AnnotatedEntryPointResolver resolver = new AnnotatedEntryPointResolver();
        AnnotatedComponent component = new AnnotatedComponent();
        MuleEventContext context = getTestEventContext(TEST_PAYLOAD);
        //Since AnnotatedComponent2 has two annotated methods we need to set the method to call
        context.getMessage().setProperty(MuleProperties.MULE_METHOD_PROPERTY, "doStuff3", PropertyScope.INVOCATION);
        InvocationResult result = resolver.invoke(component, context);
        assertEquals(result.getState(), InvocationResult.State.SUCCESSFUL);
        assertTrue(result.getResult() instanceof Map);
        Map<?, ?> map = (Map<?, ?>) result.getResult();
        assertEquals(2, map.size());
View Full Code Here

    @Test(expected = RequiredValueException.class)
    public void testAnnotatedMethodRequiredMissing() throws Exception
    {
        AnnotatedEntryPointResolver resolver = new AnnotatedEntryPointResolver();
        AnnotatedComponent component = new AnnotatedComponent();
        MuleEventContext context = getTestEventContext(TEST_PAYLOAD);
        //Since AnnotatedComponent2 has two annotated methods we need to set the method to call
        context.getMessage().setProperty(MuleProperties.MULE_METHOD_PROPERTY, "doStuff4", PropertyScope.INVOCATION);

        resolver.invoke(component, context);
    }
View Full Code Here

    @Test
    public void testAnnotatedMethodMissingNotRequired() throws Exception
    {
        AnnotatedEntryPointResolver resolver = new AnnotatedEntryPointResolver();
        AnnotatedComponent component = new AnnotatedComponent();
        MuleEventContext context = getTestEventContext(TEST_PAYLOAD);
        //Since AnnotatedComponent2 has two annotated methods we need to set the method to call
        context.getMessage().setProperty(MuleProperties.MULE_METHOD_PROPERTY, "doStuff5", PropertyScope.INVOCATION);
        InvocationResult result = resolver.invoke(component, context);
        assertEquals(result.getState(), InvocationResult.State.SUCCESSFUL);
        assertTrue(result.getResult() instanceof Map);
        Map<?, ?> map = (Map<?, ?>) result.getResult();
        assertEquals(1, map.size());
View Full Code Here

    @Test(expected = IllegalArgumentException.class)
    public void testIllegalAnnotatedMethod() throws Exception
    {
        AnnotatedEntryPointResolver resolver = new AnnotatedEntryPointResolver();
        IllegalAnnotatedComponent component = new IllegalAnnotatedComponent();
        MuleEventContext context = getTestEventContext(TEST_PAYLOAD);

        resolver.invoke(component, context);
    }
View Full Code Here

    @Test
    public void testMethodPropertyParameterAssignableFromPayload() throws Exception
    {
        ExplicitMethodEntryPointResolver resolver = new ExplicitMethodEntryPointResolver();
        resolver.addMethod("wash");
        MuleEventContext ctx = getTestEventContext(new Apple());
        InvocationResult result = resolver.invoke(new TestFruitCleaner(), ctx);
        assertEquals(result.getState(), InvocationResult.State.SUCCESSFUL);
    }
View Full Code Here

TOP

Related Classes of org.mule.api.MuleEventContext

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.