public void testGetIndex() throws Exception {
    req.setupGetRequestURI("/my/namespace/foo/");
    req.setupGetServletPath("/my/namespace/foo/");
    req.setupGetAttribute(null);
    req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
    req.setupGetMethod("GET");

    ActionMapping mapping = mapper.getMapping(req, configManager);

    assertEquals("/my/namespace", mapping.getNamespace());
    assertEquals("foo/", mapping.getName());
    assertEquals("index", mapping.getMethod());
  }
  public void testPostCreate() throws Exception {
    req.setupGetRequestURI("/my/namespace/bar/1/foo/");
    req.setupGetServletPath("/my/namespace/bar/1/foo/");
    req.setupGetAttribute(null);
    req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
    req.setupGetMethod("POST");

    ActionMapping mapping = mapper.getMapping(req, configManager);

    assertEquals("/my/namespace", mapping.getNamespace());
    assertEquals("foo/", mapping.getName());
    assertEquals("create", mapping.getMethod());
    assertEquals(1, mapping.getParams().size());
    assertEquals("1", mapping.getParams().get("bar"));
  }
  public void testGetEdit() throws Exception {
    mapper.setIdParameterName("id");
    mapper.setAllowDynamicMethodCalls("true");
    req.setupGetRequestURI("/my/namespace/foo/3!edit");
    req.setupGetServletPath("/my/namespace/foo/3!edit");
    req.setupGetAttribute(null);
    req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
    req.setupGetMethod("GET");

    ActionMapping mapping = mapper.getMapping(req, configManager);

    assertEquals("/my/namespace", mapping.getNamespace());
    assertEquals("foo/3", mapping.getName());
    assertEquals("edit", mapping.getMethod());
    assertEquals("3", mapping.getParams().get("id"));
  }
  public void testDeleteRemoveWithFakeDelete() throws Exception {

    req.setupGetRequestURI("/my/namespace/bar/1/foo/2");
    req.setupGetServletPath("/my/namespace/bar/1/foo/2");
    req.setupAddParameter(Restful2ActionMapper.HTTP_METHOD_PARAM, "DELETE");
    req.setupAddParameter(Restful2ActionMapper.HTTP_METHOD_PARAM, "DELETE");
    req.setupGetAttribute(null);
    req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
    req.setupGetMethod("POST");

    ActionMapping mapping = mapper.getMapping(req, configManager);

    assertEquals("/my/namespace", mapping.getNamespace());
    assertEquals("foo/2", mapping.getName());
    assertEquals("remove", mapping.getMethod());
    assertEquals(1, mapping.getParams().size());
    assertEquals("1", mapping.getParams().get("bar"));
  }
  public void testPutUpdateWithIdParam() throws Exception {

    mapper.setIdParameterName("id");
    req.setupGetRequestURI("/my/namespace/bar/1/foo/2");
    req.setupGetServletPath("/my/namespace/bar/1/foo/2");
    req.setupGetAttribute(null);
    req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
    req.setupGetMethod("PUT");

    ActionMapping mapping = mapper.getMapping(req, configManager);

    assertEquals("/my/namespace", mapping.getNamespace());
    assertEquals("foo", mapping.getName());
    assertEquals("update", mapping.getMethod());
    assertEquals(2, mapping.getParams().size());
    assertEquals("1", mapping.getParams().get("bar"));
    assertEquals("2", mapping.getParams().get("id"));
  }