Package org.apache.tiles.request

Examples of org.apache.tiles.request.ApplicationContext


     */
    @Test
    public void testRender() throws IOException {
        Request request = createMock(Request.class);
        Writer writer = createMock(Writer.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        ApplicationResource applicationResource = createMock(ApplicationResource.class);
        expect(applicationResource.getInputStream()).andReturn(getClass().getResource("/test.html").openStream());

        Map<String,Object> context = Collections.singletonMap("testKey", (Object)"test value");

        expect(request.getApplicationContext()).andReturn(applicationContext);
        expect(applicationContext.getResource(isA(String.class))).andReturn(applicationResource).anyTimes();
        expect(request.getAvailableScopes()).andReturn(Arrays.asList("request", "session", "application"));
        expect(request.getContext("request")).andReturn(context);
        expect(request.getContext("session")).andReturn(Collections.<String,Object>emptyMap());
        expect(request.getContext("application")).andReturn(Collections.<String,Object>emptyMap());
        expect(request.getWriter()).andReturn(writer);
View Full Code Here


    public void doExecute(String location, ActionInvocation invocation) throws Exception {
        ServletContext context = ServletActionContext.getServletContext();
        HttpServletRequest request = ServletActionContext.getRequest();
        HttpServletResponse response = ServletActionContext.getResponse();

        ApplicationContext applicationContext = ServletUtil.getApplicationContext(context);
        ServletRequest servletRequest = new ServletRequest(applicationContext, request, response);

        TilesContainer container = initTilesContainer(applicationContext, servletRequest);

        container.startContext(servletRequest);
View Full Code Here

     */
    @Test
    public void testCreateVelocityRequest() {
        HttpServletRequest httpRequest = createMock(HttpServletRequest.class);
        HttpServletResponse response = createMock(HttpServletResponse.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);

        replay(velocityContext, httpRequest, response, applicationContext);
        context = VelocityRequest.createVelocityRequest(applicationContext,
                httpRequest, response, velocityContext, writer);
        ServletRequest servletRequest = (ServletRequest) context.getWrappedRequest();
View Full Code Here

        Node node = createMock(Node.class);
        ViewToolContext viewContext = createMock(ViewToolContext.class);
        HttpServletRequest request = createMock(HttpServletRequest.class);
        HttpServletResponse response = createMock(HttpServletResponse.class);
        ServletContext servletContext = createMock(ServletContext.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);

        expect(context.getInternalUserContext()).andReturn(viewContext);
        expect(viewContext.getRequest()).andReturn(request);
        expect(viewContext.getResponse()).andReturn(response);
        expect(viewContext.getServletContext()).andReturn(servletContext);
View Full Code Here

    /**
     * Test method for {@link org.apache.tiles.request.jsp.JspUtil#getApplicationContext(javax.servlet.jsp.JspContext)}.
     */
    @Test
    public void testGetApplicationContext() {
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        JspContext jspContext = createMock(JspContext.class);

        expect(jspContext.getAttribute(ApplicationAccess
                .APPLICATION_CONTEXT_ATTRIBUTE, PageContext.APPLICATION_SCOPE))
                .andReturn(applicationContext);
View Full Code Here

    /**
     * Test method for {@link JspRequest#createServletJspRequest(ApplicationContext, PageContext)}.
     */
    @Test
    public void testCreateServletJspRequest() {
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        HttpServletRequest servletRequest = createMock(HttpServletRequest.class);
        HttpServletResponse servletResponse = createMock(HttpServletResponse.class);

        expect(context.getRequest()).andReturn(servletRequest);
        expect(context.getResponse()).andReturn(servletResponse);
View Full Code Here

     */
    @Test
    public void testRender() throws IOException {
        Request request = createMock(Request.class);
        StringWriter writer = new StringWriter();
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        ApplicationResource applicationResource = createMock(ApplicationResource.class);

        Map<String,Object> context = Collections.singletonMap("testKey", (Object)"test value");

        expect(applicationContext.getResource(isA(String.class))).andReturn(applicationResource).anyTimes();
        expect(request.getAvailableScopes()).andReturn(Arrays.asList(Request.REQUEST_SCOPE, "session", Request.APPLICATION_SCOPE));
        expect(request.getContext(Request.REQUEST_SCOPE)).andReturn(context);
        expect(request.getContext("session")).andReturn(Collections.<String,Object>emptyMap());
        expect(request.getContext(Request.APPLICATION_SCOPE)).andReturn(Collections.<String,Object>emptyMap());
        expect(request.getWriter()).andReturn(writer).anyTimes();
View Full Code Here

     * @throws IOException If something goes wrong.
     * @throws ServletException If something goes wrong.
     */
    @Test
    public void testWrite() throws IOException, ServletException {
        ApplicationContext applicationContext = createMock(ServletApplicationContext.class);
        ServletContext servletContext = createMock(ServletContext.class);
        GenericServlet servlet = createMockBuilder(GenericServlet.class).createMock();
        ServletConfig servletConfig = createMock(ServletConfig.class);
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);

        expect(servletConfig.getServletContext()).andReturn(servletContext);

        replay(servlet, servletConfig);
        servlet.init(servletConfig);
        ServletContextHashModel servletContextHashModel = new ServletContextHashModel(servlet, objectWrapper);

        expect(applicationContext.getContext()).andReturn(servletContext).anyTimes();
        expect(servletContext.getRealPath(isA(String.class))).andReturn(null).anyTimes();
        URL resource = getClass().getResource("/test.ftl");
        expect(servletContext.getResource(isA(String.class))).andReturn(resource).anyTimes();
        expect(servletContext.getAttribute(ATTR_APPLICATION_MODEL)).andReturn(servletContextHashModel);
        expect(servletContext.getAttribute(ATTR_JSP_TAGLIBS_MODEL)).andReturn(null);
View Full Code Here

     * @throws IOException If something goes wrong.
     * @throws ServletException If something goes wrong.
     */
    @Test(expected = CannotRenderException.class)
    public void testRenderException1() throws IOException, ServletException {
        ApplicationContext applicationContext = createMock(ServletApplicationContext.class);
        ServletContext servletContext = createMock(ServletContext.class);
        GenericServlet servlet = createMockBuilder(GenericServlet.class).createMock();
        ServletConfig servletConfig = createMock(ServletConfig.class);
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);

        replay(servlet, servletConfig);
        servlet.init(servletConfig);

        expect(applicationContext.getContext()).andReturn(servletContext).anyTimes();
        expect(servletContext.getRealPath(isA(String.class))).andReturn(null).anyTimes();
        URL resource = getClass().getResource("/test.ftl");
        expect(servletContext.getResource(isA(String.class))).andReturn(resource).anyTimes();

        replay(applicationContext, servletContext, objectWrapper);
View Full Code Here

     * @throws IllegalAccessException If something goes wrong.
     * @throws IllegalArgumentException If something goes wrong.
     */
    @Test
    public void testResourcePortletRequest() throws NoSuchFieldException, IllegalAccessException {
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        PortletContext portletContext = createMock(PortletContext.class);
        ResourceRequest request = createMock(ResourceRequest.class);
        ResourceResponse response = createMock(ResourceResponse.class);

        replay(applicationContext, portletContext, request, response);
View Full Code Here

TOP

Related Classes of org.apache.tiles.request.ApplicationContext

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.