Package org.nutz.mvc.view

Source Code of org.nutz.mvc.view.JspViewTest

package org.nutz.mvc.view;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;
import org.nutz.mock.Mock;
import org.nutz.mock.servlet.MockHttpServletRequest;
import org.nutz.mvc.Mvcs;

public class JspViewTest {

    @Before
    public void before() {
        Mvcs.setServletContext(Mock.servlet.context());
    }

    @Test
    public void test_name() throws Exception {
        MockHttpServletRequest req = Mock.servlet.fullRequest();
        JspView fv = new JspView("abc.bcd");
        fv.render(req, null, null);
        assertEquals("/WEB-INF/abc/bcd.jsp", req.getDispatcherTarget());
    }

    @Test
    public void test_req_path() throws Exception {
        MockHttpServletRequest req = Mock.servlet.fullRequest();
        req.setPathInfo("/abc/bcd.do");
        JspView fv = new JspView(null);
        fv.render(req, null, null);
        assertEquals("/WEB-INF/abc/bcd.jsp", req.getDispatcherTarget());
    }

    @Test
    public void test_req_path2() throws Exception {
        MockHttpServletRequest req = Mock.servlet.fullRequest();
        req.setPathInfo("/abc/bcd.do");
        JspView fv = new JspView("");
        fv.render(req, null, null);
        assertEquals("/WEB-INF/abc/bcd.jsp", req.getDispatcherTarget());
    }

    @Test
    public void test_req_path3() throws Exception {
        MockHttpServletRequest req = Mock.servlet.fullRequest();
        req.setPathInfo("/abc/bcd.do");
        JspView fv = new JspView("  \r\n\t  ");
        fv.render(req, null, null);
        assertEquals("/WEB-INF/abc/bcd.jsp", req.getDispatcherTarget());
    }

    @Test
    public void test_dest_path() throws Exception {
        MockHttpServletRequest req = Mock.servlet.fullRequest();
        JspView fv = new JspView("/abc/bcd.jsp");
        fv.render(req, null, null);
        assertEquals("/abc/bcd.jsp", req.getDispatcherTarget());
    }
}
TOP

Related Classes of org.nutz.mvc.view.JspViewTest

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.