Package org.mule.api.transport

Examples of org.mule.api.transport.SessionHandler


    {
        Connector connector = muleContext.getRegistry().lookupConnector("httpConnector");
        assertTrue(connector instanceof HttpConnector);
       
        HttpConnector httpConnector = (HttpConnector) connector;
        SessionHandler sessionHandler = httpConnector.getSessionHandler();
        assertTrue(sessionHandler instanceof TestSessionHandler);
    }
View Full Code Here


    }

    public void testMultipleAuthentications() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        SessionHandler sessionHandler = new MuleSessionHandler();
        MuleMessage reply;
        Map props;

        EncryptionStrategy strategy = muleContext.getSecurityManager().getEncryptionStrategy("PBE");
       
View Full Code Here

{
    /** @see EE-1705/MULE-4567 */
    public void testSessionProperties() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler handler = new SerializeAndEncodeSessionHandler();
        MuleSession session = new DefaultMuleSession(muleContext);
       
        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);
       
View Full Code Here

    /** @see EE-1774 */
    public void testNonSerializableSessionProperties() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        MuleSession session = new DefaultMuleSession(muleContext);
        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

    /** @see EE-1820 */
    public void testBackwardsCompatibility() throws Exception
    {
        MuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler legacyHandler = new LegacySessionHandler();
        MuleSession session = new DefaultMuleSession(muleContext);
       
        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
            session = new SerializeAndEncodeSessionHandler().retrieveSessionInfoFromMessage(message);
        }
        catch (SerializationException e)
        {
            // expected
        }
        session = legacyHandler.retrieveSessionInfoFromMessage(message);
    }   
View Full Code Here

   
    /** @see EE-1820 */
    public void testSessionPropertiesLegacyFormat() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler handler = new LegacySessionHandler();
        MuleSession session = new DefaultMuleSession(muleContext);
       
        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);
       
View Full Code Here

    /** @see MULE-4720 */
    public void testSecurityContext() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler handler = new SerializeAndEncodeSessionHandler();
        MuleSession session = new DefaultMuleSession(muleContext);
       
        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

   
    /** @see EE-1774 */
    public void testNotSerializableSecurityContext() throws Exception
    {
        MuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler handler = new SerializeAndEncodeSessionHandler();
        MuleSession session = new DefaultMuleSession(muleContext);
       
        session.setSecurityContext(new NotSerializableSecurityContext());
       
        try
        {
            handler.storeSessionInfoToMessage(session, message);
            fail("Should throw a SerializationException");
        }
        catch (SerializationException e)
        {
            // expected
View Full Code Here

                    {
                        MuleMessage muleMessage = receiver.createMuleMessage(payload, endpoint.getEncoding());
                        preRouteMuleMessage(muleMessage);

                        // TODO Move getSessionHandler() to the Connector interface
                        SessionHandler handler;
                        if (endpoint.getConnector() instanceof AbstractConnector)
                        {
                            handler = ((AbstractConnector) endpoint.getConnector()).getSessionHandler();
                        }
                        else
                        {
                            handler = new MuleSessionHandler();
                        }
                        MuleSession session;
                        try
                        {
                            session = handler.retrieveSessionInfoFromMessage(muleMessage);
                        }
                        catch (SerializationException e)
                        {
                            // EE-1820 Support message headers generated by previous Mule versions
                            session = new LegacySessionHandler().retrieveSessionInfoFromMessage(muleMessage);
View Full Code Here

    {
        Connector connector = muleContext.getRegistry().lookupConnector("httpConnector");
        assertTrue(connector instanceof HttpConnector);
       
        HttpConnector httpConnector = (HttpConnector) connector;
        SessionHandler sessionHandler = httpConnector.getSessionHandler();
        assertTrue(sessionHandler instanceof TestSessionHandler);
    }
View Full Code Here

TOP

Related Classes of org.mule.api.transport.SessionHandler

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.