Examples of DefaultMuleSession


Examples of org.mule.session.DefaultMuleSession

        //We need a session and current event for this test
        RequestContext.setEvent(new DefaultMuleEvent(
                message,
                getTestInboundEndpoint("foo"),
                new DefaultMuleSession(muleContext)));

        message.setOutboundProperty("foo", "fooOutbound");
        message.setInvocationProperty("bar", "barInvocation");
        message.setInvocationProperty("foo", "fooInvocation");
        message.setProperty("foo", "fooInbound", PropertyScope.INBOUND);
View Full Code Here

Examples of org.mule.session.DefaultMuleSession

        return events.getMessageCollectionEvent();
    }

    protected MuleSession getMergedSession(MuleEvent[] events)
    {
        MuleSession session = new DefaultMuleSession(events[0].getSession());
        for (int i = 1; i < events.length; i++)
        {
            for (String name : events[i].getSession().getPropertyNamesAsSet())
            {
                session.setProperty(name, events[i].getSession().getProperty(name));
            }
        }
        return session;
    }
View Full Code Here

Examples of org.mule.session.DefaultMuleSession

    @Override
    public final MuleEvent routeMessage(MuleMessage message, Transaction trans, OutputStream outputStream)
            throws MuleException
    {
        return routeMessage(message, new DefaultMuleSession(), trans, outputStream);
    }
View Full Code Here

Examples of org.mule.session.DefaultMuleSession

                throw se;
            }
        }
        if (session == null)
        {
            session = new DefaultMuleSession();
        }
        if (message.getReplyTo() != null)
        {
            event = new DefaultMuleEvent(message, getEndpoint(), flowConstruct, session, replyToHandler, message.getReplyTo(), ros);
            message.setReplyTo(null);
View Full Code Here

Examples of org.mule.session.DefaultMuleSession

        if (endpoint.getExchangePattern().hasResponse() && resultEvent != null
            && !VoidMuleEvent.getInstance().equals(resultEvent))
        {
            // Do not propagate security context back to caller
            MuleSession resultSession = new DefaultMuleSession(resultEvent.getSession());
            resultSession.setSecurityContext(null);
            connector.getSessionHandler().storeSessionInfoToMessage(resultSession, resultEvent.getMessage());

            if (resultEvent.getMessage() != null && !endpoint.isDisableTransportTransformer())
            {
                applyResponseTransformers(resultEvent);
View Full Code Here

Examples of org.mule.session.DefaultMuleSession

    @Test
    public void testSessionProperties() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler handler = new SerializeAndEncodeSessionHandler();
        MuleSession session = new DefaultMuleSession();

        String string = "bar";
        session.setProperty("fooString", string);

        Date date = new Date(0);
        session.setProperty("fooDate", date);

        List<String> list = createList();
        session.setProperty("fooList", list);

        handler.storeSessionInfoToMessage(session, message);
        // store save session to outbound, move it to the inbound
        // for retrieve to deserialize
        Object s = message.removeProperty(MuleProperties.MULE_SESSION_PROPERTY);
        message.setInboundProperty(MuleProperties.MULE_SESSION_PROPERTY, s);
        session = handler.retrieveSessionInfoFromMessage(message);

        Object obj = session.getProperty("fooString");
        assertTrue(obj instanceof String);
        assertEquals(string, obj);

        obj = session.getProperty("fooDate");
        assertTrue("Object should be a Date but is " + obj.getClass().getName(), obj instanceof Date);
        assertEquals(date, obj);

        obj = session.getProperty("fooList");
        assertTrue("Object should be a List but is " + obj.getClass().getName(), obj instanceof List);
        assertEquals(list, obj);
    }
View Full Code Here

Examples of org.mule.session.DefaultMuleSession

     */
    @Test
    public void testNonSerializableSessionProperties() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        MuleSession session = new DefaultMuleSession();
        SessionHandler handler = new SerializeAndEncodeSessionHandler();

        NotSerializableClass clazz = new NotSerializableClass();
        session.setProperty("foo", clazz);
        handler.storeSessionInfoToMessage(session, message);
        // store save session to outbound, move it to the inbound
        // for retrieve to deserialize
        Object s = message.removeProperty(MuleProperties.MULE_SESSION_PROPERTY);
        message.setInboundProperty(MuleProperties.MULE_SESSION_PROPERTY, s);
        session = handler.retrieveSessionInfoFromMessage(message);
        // Property was removed because it could not be serialized
        assertNull(session.getProperty("foo"));
    }
View Full Code Here

Examples of org.mule.session.DefaultMuleSession

    @Test
    public void testBackwardsCompatibility() throws Exception
    {
        MuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler legacyHandler = new LegacySessionHandler();
        MuleSession session = new DefaultMuleSession();

        String string = "bar";
        session.setProperty("fooString", string);

        Date date = new Date(0);
        session.setProperty("fooDate", date);

        List<String> list = createList();
        session.setProperty("fooList", list);

        legacyHandler.storeSessionInfoToMessage(session, message);
        try
        {
            // Try to deserialize legacy format with new session handler
View Full Code Here

Examples of org.mule.session.DefaultMuleSession

    @Test
    public void testSessionPropertiesLegacyFormat() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler handler = new LegacySessionHandler();
        MuleSession session = new DefaultMuleSession();

        String string = "bar";
        session.setProperty("fooString", string);

        Date date = new Date(0);
        session.setProperty("fooDate", date);

        List<String> list = createList();
        session.setProperty("fooList", list);

        handler.storeSessionInfoToMessage(session, message);
        // store save session to outbound, move it to the inbound
        // for retrieve to deserialize
        Object s = message.removeProperty(MuleProperties.MULE_SESSION_PROPERTY);
        message.setInboundProperty(MuleProperties.MULE_SESSION_PROPERTY, s);
        session = handler.retrieveSessionInfoFromMessage(message);

        Object obj = session.getProperty("fooString");
        assertTrue(obj instanceof String);
        assertEquals(string, obj);

        obj = session.getProperty("fooDate");
        // MULE-4567 / EE-1705
        assertTrue(obj instanceof String);

        obj = session.getProperty("fooList");
        // MULE-4567 / EE-1705
        assertTrue(obj instanceof String);
    }
View Full Code Here

Examples of org.mule.session.DefaultMuleSession

    @Test
    public void testSecurityContext() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler handler = new SerializeAndEncodeSessionHandler();
        MuleSession session = new DefaultMuleSession();

        Credentials credentials = new MuleCredentials("joe", "secret".toCharArray());
        SecurityContext sc = new DefaultSecurityContextFactory().create(new DefaultMuleAuthentication(credentials));
        session.setSecurityContext(sc);

        handler.storeSessionInfoToMessage(session, message);
        // store save session to outbound, move it to the inbound
        // for retrieve to deserialize
        Object s = message.removeProperty(MuleProperties.MULE_SESSION_PROPERTY);
        message.setInboundProperty(MuleProperties.MULE_SESSION_PROPERTY, s);
        session = handler.retrieveSessionInfoFromMessage(message);

        sc = session.getSecurityContext();
        assertEquals("joe", sc.getAuthentication().getPrincipal());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.