Package com.mockrunner.mock.web

Examples of com.mockrunner.mock.web.MockHttpSession


        req.setServerPort(url.getPort() == -1 ? 80 : url.getPort());
        req.setContextPath(url.getPath());

        MockHttpServletResponse res = new MockHttpServletResponse();
        MockFilterChain chain = new MockFilterChain();
        MockHttpSession session = new MockHttpSession();
        req.setSession(session);

        MockServletContext servletContext = new MockServletContext();
        session.setupServletContext(servletContext);

        filter.init(config);

        // the servlet to call at the end of the chain, just writes the provided content out
        // to the response
View Full Code Here


        request.setContentType("application/x-www-form-urlencoded");

    request.setMethod("POST");
    request.setBodyContent(body);

        MockHttpSession session = new MockHttpSession();
        session.setupServletContext(new MockServletContext());
        request.setSession(session);

        request.setUserPrincipal(null);

    return request;
View Full Code Here

    private void navigationTest(NavigationalStateComponent component, boolean useQueryStringPortalURL)
    throws Exception
    {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpSession session = new MockHttpSession();
        HttpServletResponse response = new MockHttpServletResponse();
        ServletConfig config = new MockServletConfig();
        request.setSession(session);
        request.setServerName("www.sporteportal.com");
        request.setScheme("http");
View Full Code Here

            throw ex;
    }

    private RequestContext initRequestContext()
    {
        MockHttpSession session = new MockHttpSession();
        session.setupServletContext(servletContext);
        assertEquals(servletContext, session.getServletContext());

        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();

        request.setSession(session);
View Full Code Here

       
        // create the mock request context
        MockHttpServletRequest request = new MockHttpServletRequest();      
        MockHttpServletResponse response = new MockHttpServletResponse();
        request.setUserPrincipal(new MockPrincipal("david"));
        MockHttpSession session = new MockHttpSession();
        request.setSession(session);
        String sessionId = session.getId();

        MockRequestContext context = new MockRequestContext(request, response);
       
        // create a simple key
        String window1 = "/default-page.psml";
        ContentCacheKey cckey1 = contentCache.createCacheKey(context, window1);
        assertEquals(cckey1.getKey(), sessionId + "/portal//default-page.psml");

        // create a another key for desktop
        String window2 = "/about.psml";
        context.getParameterMap().put("encoder", "desktop");
        ContentCacheKey cckey2 = contentCache.createCacheKey(context, window2);
        assertEquals(cckey2.getKey(), sessionId + "/desktop//about.psml");
       
        // create some MockTheme objects
        MockTheme theme1 = new MockTheme("/default-page.psml");
        MockTheme theme2 = new MockTheme("/about.psml");
       
        // put it in the cache
        CacheElement element1 = contentCache.createElement(cckey1, theme1);
        contentCache.put(element1);
        CacheElement element2 = contentCache.createElement(cckey2, theme2);
        contentCache.put(element2);
       
        // assert the gets
        Object result1 = contentCache.get(cckey1);
        assertNotNull(result1);
        System.out.println("result 1 = " + result1);
        Object result2 = contentCache.get(cckey2);
        assertNotNull(result2);
        System.out.println("result 2 = " + result2);
       
        // assert isKey Apis       
        assertTrue(contentCache.isKeyInCache(cckey1));
               
       
        // test removes
        contentCache.remove(cckey1);
        assertFalse(contentCache.isKeyInCache(cckey1));       
        assertTrue(contentCache.isKeyInCache(cckey2));
       
        // test user stuff
        session = new MockHttpSession();
        request.setSession(session);       
        sessionId = session.getId();       
        request.setUserPrincipal(new MockPrincipal("sean"));       
        // create a simple key
        String window3 = "/default-page.psml";
        ContentCacheKey cckey3 = contentCache.createCacheKey(context, window3);
        assertEquals(cckey3.getKey(), sessionId + "/desktop//default-page.psml");
View Full Code Here

    private RequestContext initRequestContext()
    {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        MockHttpSession session = new MockHttpSession();

        request.setUserPrincipal(new Principal(){ public String getName(){ return USERNAME; } });

        request.setRemoteAddr("123.234.145.156");
        request.setSession(session);
View Full Code Here

       
        // create the mock request context
        MockHttpServletRequest request = new MockHttpServletRequest();      
        MockHttpServletResponse response = new MockHttpServletResponse();
        request.setUserPrincipal(new MockPrincipal("david"));
        MockHttpSession session = new MockHttpSession();
        request.setSession(session);
        String sessionId = session.getId();

        MockRequestContext context = new MockRequestContext(request, response);
       
        // create a simple key
        String window1 = "555-01";
        ContentCacheKey cckey1 = contentCache.createCacheKey(context, window1);
        assertEquals(cckey1.getKey(), sessionId + "/portal/555-01");

        // create a another key for desktop
        String window2 = "555-02";
        context.getParameterMap().put("encoder", "desktop");
        ContentCacheKey cckey2 = contentCache.createCacheKey(context, window2);
        assertEquals(cckey2.getKey(), sessionId + "/desktop/555-02");
       
        // create some PortletContent mock objects
        PortletContent content1 = new MockPortletContent(cckey1, 100, "ContentOne", "content1content1content1content1");
        PortletContent content2 = new MockPortletContent(cckey2, 200, "ContentTwo", "content2content2content2content2");
       
        // put it in the cache
        CacheElement element1 = contentCache.createElement(cckey1, content1);
        contentCache.put(element1);
        CacheElement element2 = contentCache.createElement(cckey2, content2);
        contentCache.put(element2);
       
        // assert the gets
        Object result1 = contentCache.get(cckey1);
        assertNotNull(result1);
        System.out.println("result 1 = " + result1);
        Object result2 = contentCache.get(cckey2);
        assertNotNull(result2);
        System.out.println("result 2 = " + result2);
       
        // assert isKey Apis       
        assertTrue(contentCache.isKeyInCache(cckey1));
               
       
        // test removes
        contentCache.remove(cckey1);
        assertFalse(contentCache.isKeyInCache(cckey1));       
        assertTrue(contentCache.isKeyInCache(cckey2));
       
        // test user stuff
        session = new MockHttpSession();
        request.setSession(session);       
        sessionId = session.getId();       
        request.setUserPrincipal(new MockPrincipal("sean"));       
        // create a simple key
        String window3 = "555-03";
        ContentCacheKey cckey3 = contentCache.createCacheKey(context, window3);
        assertEquals(cckey3.getKey(), sessionId + "/desktop/555-03");
View Full Code Here

   
   
    protected HttpServletRequest buildRequest(PortalURL portalURL, boolean useQueryStringPortalURL)
    {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpSession session = new MockHttpSession();

        request.setSession(session);
        request.setServerName("www.sporteportal.com");
        request.setScheme("http");
        request.setContextPath("/jetspeed");
View Full Code Here

    {
        RequestContextComponent rcc = (RequestContextComponent) new Mock(RequestContextComponent.class).proxy();
       
        MockServletConfig config = new MockServletConfig();
        MockServletContext context = new MockServletContext();
        MockHttpSession session = new MockHttpSession();
        session.setupServletContext(context);
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setupAddParameter("action", "constraints");
        request.setupAddParameter("method", method);
        request.setupAddParameter("xml", xml);
        request.setupAddParameter("name", defName);
View Full Code Here

    {
        RequestContextComponent rcc = (RequestContextComponent) new Mock(RequestContextComponent.class).proxy();
       
        MockServletConfig config = new MockServletConfig();
        MockServletContext context = new MockServletContext();
        MockHttpSession session = new MockHttpSession();
        session.setupServletContext(context);
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setupAddParameter("action", p_sAction);
        request.setupAddParameter("id", p_sPortletId);
        if (p_sRow != null)
        {
View Full Code Here

TOP

Related Classes of com.mockrunner.mock.web.MockHttpSession

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.