Package org.nutz.mvc

Examples of org.nutz.mvc.ActionContext


    @Test
    public void test_single_path_arg() {
        MappingNode<String> root = new MappingNode<String>();
        root.add("/a/?/c", "A");

        ActionContext ac = new ActionContext();
        assertEquals("A", root.get(ac, "/a/b/c"));
        assertEquals(1, ac.getPathArgs().size());
        assertEquals("b", ac.getPathArgs().get(0));
    }
View Full Code Here


    @Test
    public void test_multi_path_arg() {
        MappingNode<String> root = new MappingNode<String>();
        root.add("/a/*", "A");

        ActionContext ac = new ActionContext();
        assertEquals("A", root.get(ac, "/a"));
        assertEquals(0, ac.getPathArgs().size());

        assertEquals("A", root.get(ac, "/a/b/c"));
        assertEquals(2, ac.getPathArgs().size());
        assertEquals("b", ac.getPathArgs().get(0));
        assertEquals("c", ac.getPathArgs().get(1));
    }
View Full Code Here

    @Test
    public void test_single_and_multi_path_arg() {
        MappingNode<String> root = new MappingNode<String>();
        root.add("/a/?/c/*", "A");

        ActionContext ac = new ActionContext();

        assertEquals("A", root.get(ac, "/a/b/c"));
        assertEquals(1, ac.getPathArgs().size());
        assertEquals("b", ac.getPathArgs().get(0));

        assertEquals("A", root.get(ac, "/a/b/c/d"));
        assertEquals(2, ac.getPathArgs().size());
        assertEquals("b", ac.getPathArgs().get(0));
        assertEquals("d", ac.getPathArgs().get(1));

        assertEquals("A", root.get(ac, "/a/b/c/d/e"));
        assertEquals(3, ac.getPathArgs().size());
        assertEquals("b", ac.getPathArgs().get(0));
        assertEquals("d", ac.getPathArgs().get(1));
        assertEquals("e", ac.getPathArgs().get(2));

    }
View Full Code Here

      MappingNode<String> root = new MappingNode<String>();
        root.add("/*", "A");
        root.add("/abc/wendal", "B");
        root.add("/abc/wen/?/zzz", "B");
        root.add("/abc/wen/?/zzz/*", "B");
        ActionContext ac = new ActionContext();

        assertEquals("A", root.get(ac, "/a/b/c/d/e")); // 连第一个路径都不匹配
        assertEquals("A", root.get(ac, "/abc/abc"));   // 匹配第一路径,但不匹配第二路径
        assertEquals("B", root.get(ac, "/abc/wendal")); // 匹配第一个路径, 也匹配第二路径
        assertEquals("B", root.get(ac, "/abc/wen/qq/zzz")); // 匹配全部
View Full Code Here

public class ViewProcessorTest extends AbstractMvcTest {

    @Test
    public void test_error_processor() throws Throwable {
        ViewProcessor p = new EViewProcessor();
        ActionContext ac = new ActionContext();
        ac.setRequest(request).setResponse(response).setServletContext(servletContext);
        Throwable t = new Throwable();
        ac.setError(t);
        p.process(ac);
        Object obj = request.getAttribute(ViewProcessor.DEFAULT_ATTRIBUTE);
        assertNotNull(obj);
        assertTrue(obj instanceof Throwable);
        assertEquals(t, obj);
View Full Code Here

                req_attr.put(tem, req.getAttribute(tem));
        }
        context.set("a", req_attr);// 兼容最初的写法
        context.set("req_attr", req_attr);

        ActionContext ac = Mvcs.getActionContext();
        if (ac != null)
            context.set("pathargs", Mvcs.getActionContext().getPathArgs());

        HttpSession session = Mvcs.getHttpSession(false);
        if (session != null) {
View Full Code Here

TOP

Related Classes of org.nutz.mvc.ActionContext

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.