Package org.mule.api

Examples of org.mule.api.MuleSession


    /** @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");
View Full Code Here

     */
    public void testEmptySequence() throws Exception
    {
        Object payload = Collections.emptySet();
        Service fc = getTestService();
        MuleSession session = getTestSession(fc, muleContext);
        MuleMessage toSplit = new DefaultMuleMessage(payload, new HashMap<String, Object>(), new HashMap<String, Object>(), null, muleContext);
        CollectionSplitter splitter = new CollectionSplitter();
        splitter.setMuleContext(muleContext);
        DefaultMuleEvent event = new DefaultMuleEvent(toSplit, getTestInboundEndpoint("ep"), session);
        assertNull(splitter.process(event));
View Full Code Here

    }

    private void assertRouted(Object payload, int count, boolean counted) throws Exception, MuleException
    {
        Service fc = getTestService();
        MuleSession session = getTestSession(fc, muleContext);

        Map<String, Object> inboundProps = new HashMap();
        inboundProps.put("inbound1", "1");
        inboundProps.put("inbound2", 2);
        inboundProps.put("inbound3", session);
View Full Code Here

        return asyncReplyMessageProcessor;
    }
   
    public MuleEvent process(MuleEvent event) throws MuleException
    {
        MuleSession calledSession = new DefaultMuleSession(event.getSession(), this);
        MuleEvent newEvent = new DefaultMuleEvent(event.getMessage(), event.getEndpoint(), event, calledSession);
        RequestContext.setEvent(newEvent);
        try
        {
            return messageProcessorChain.process(newEvent);
View Full Code Here

            else
            {
                ros = new ResponseOutputStream(outputStream);
            }
        }
        MuleSession session;
        try
        {
            session = connector.getSessionHandler().retrieveSessionInfoFromMessage(message);
        }
        catch (SerializationException se)
        {
            try
            {
                // EE-1820 Support message headers generated by previous Mule versions
                session = new LegacySessionHandler().retrieveSessionInfoFromMessage(message);
            }
            catch (Exception e)
            {
                // If the LegacySessionHandler didn't work either, just bubble up the original SerializationException (see MULE-5487) 
                throw se;
            }
        }
        if (session != null)
        {
            session.setFlowConstruct(flowConstruct);
        }
        else
        {
            session = new DefaultMuleSession(flowConstruct, connector.getMuleContext());
        }
View Full Code Here

        //checkScopeForWriteAccess(scope);
        if (PropertyScope.SESSION.equals(scope))
        {
            if (RequestContext.getEvent() != null)
            {
                MuleSession session = RequestContext.getEvent().getSession();
                for (Object key : session.getPropertyNamesAsSet())
                {
                    session.removeProperty(key);
                }
            }
        }
        else
        {
View Full Code Here

            }
        };

        messageRouter.setCatchAllStrategy(strategy);

        MuleSession session = getTestSession(getTestService(), muleContext);

        MuleEvent event = getTestEvent("hello");
        messageRouter.process(event);
        assertEquals(1, catchAllCount[0]);
        assertEquals(0, count1[0]);
View Full Code Here

    }

    public void testCorrelation() throws Exception
    {
        FilteringOutboundRouter filterRouter = new FilteringOutboundRouter();
        MuleSession session = getTestSession(getTestService(), muleContext);
        MuleMessage message = new DefaultMuleMessage(new StringBuffer(), muleContext);
        OutboundEndpoint endpoint = getTestOutboundEndpoint("test");
        filterRouter.setMessageProperties(session.getFlowConstruct(), message, endpoint);
        assertNotNull(message.getCorrelationId());
    }
View Full Code Here

        ((OutboundRouterCollection) service.getOutboundMessageProcessor()).addRoute(passThroughRouter);
        //muleContext.getRegistry().registerComponent(service);

        MuleMessage message = new DefaultMuleMessage(MESSAGE, muleContext);
        message.setOutboundProperty(MailProperties.TO_ADDRESSES_PROPERTY, EMAIL);
        MuleSession session = getTestSession(getTestService("apple", Apple.class), muleContext);
        DefaultMuleEvent event = new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, session,
            new ResponseOutputStream(System.out));
        endpoint.process(event);

        getServers().waitForIncomingEmail(AbstractEmailFunctionalTestCase.DELIVERY_DELAY_MS, 1);
View Full Code Here

TOP

Related Classes of org.mule.api.MuleSession

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.