Package org.nutz.mvc

Examples of org.nutz.mvc.ActionContext


    root.add("/a/b/c", "A");
    root.add("/a/c/", "B");
    root.add("/a/f", "C");
    root.add("/a", "D");

    ActionContext ac = new ActionContext();
    assertEquals("A", root.get(ac, "/a/b/c"));
    assertEquals("/a/b/c", ac.getPath());

    assertEquals("B", root.get(ac, "/a/c"));
    assertEquals("/a/c", ac.getPath());

    assertEquals("C", root.get(ac, "/a/f/"));
    assertEquals("/a/f/", ac.getPath());

    assertEquals("D", root.get(ac, "/a/"));
    assertEquals("/a/", ac.getPath());

    assertNull(root.get(ac, "/a/x"));
    assertEquals("/a/x", ac.getPath());
  }
View Full Code Here


  @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

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

        root.add("/a/b/c", "A");
        root.add("/a/c/", "B");
        root.add("/a/f", "C");
        root.add("/a", "D");

        ActionContext ac = new ActionContext();
        assertEquals("A", root.get(ac, "/a/b/c"));
        assertEquals("/a/b/c", ac.getPath());

        assertEquals("B", root.get(ac, "/a/c"));
        assertEquals("/a/c", ac.getPath());

        assertEquals("C", root.get(ac, "/a/f/"));
        assertEquals("/a/f/", ac.getPath());

        assertEquals("D", root.get(ac, "/a/"));
        assertEquals("/a/", ac.getPath());

        assertNull(root.get(ac, "/a/x"));
        assertEquals("/a/x", ac.getPath());
    }
View Full Code Here

    @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

        root.add("/a/b/c", "A");
        root.add("/a/c/", "B");
        root.add("/a/f", "C");
        root.add("/a", "D");

        ActionContext ac = new ActionContext();
        assertEquals("A", root.get(ac, "/a/b/c"));
        assertEquals("/a/b/c", ac.getPath());

        assertEquals("B", root.get(ac, "/a/c"));
        assertEquals("/a/c", ac.getPath());

        assertEquals("C", root.get(ac, "/a/f/"));
        assertEquals("/a/f/", ac.getPath());

        assertEquals("D", root.get(ac, "/a/"));
        assertEquals("/a/", ac.getPath());

        assertNull(root.get(ac, "/a/x"));
        assertEquals("/a/x", ac.getPath());
    }
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.