Exemplo n.º 1
0
 protected void setToken(String token) {
   request
       .getParameterMap()
       .put(TokenHelper.TOKEN_NAME_FIELD, new String[] {TokenHelper.DEFAULT_TOKEN_NAME});
   request.getParameterMap().put(TokenHelper.DEFAULT_TOKEN_NAME, new String[] {token});
   extraContext.put(ActionContext.PARAMETERS, HttpParameters.create(params).build());
 }
Exemplo n.º 2
0
  public void testGetMapping() throws Exception {
    StrutsMockHttpServletRequest request = new StrutsMockHttpServletRequest();
    request.setupGetServletPath("/myapp/view/12");

    ActionMapping am = mapper.getMapping(request, null);
    assertEquals("myapp", am.getName());
    assertEquals(1, am.getParams().size());
    assertEquals("12", am.getParams().get("view"));
  }
Exemplo n.º 3
0
  public void testGetMapping2() throws Exception {
    StrutsMockHttpServletRequest request = new StrutsMockHttpServletRequest();
    request.setupGetServletPath("/myapp/12/region/europe");

    ActionMapping am = mapper.getMapping(request, null);
    assertEquals("myapp", am.getName());
    assertEquals(2, am.getParams().size());
    assertEquals("12", am.getParams().get("myappId"));
    assertEquals("europe", am.getParams().get("region"));
  }
Exemplo n.º 4
0
  protected void setUp() throws Exception {
    loadConfigurationProviders(new TestConfigurationProvider());

    session = new TreeMap<>();
    params = new TreeMap<>();
    extraContext = new TreeMap<>();
    extraContext.put(ActionContext.SESSION, session);
    extraContext.put(ActionContext.PARAMETERS, HttpParameters.createEmpty().build());

    request = new StrutsMockHttpServletRequest();
    httpSession = new StrutsMockHttpSession();
    request.setSession(httpSession);
    request.setParameterMap(params);
    extraContext.put(ServletActionContext.HTTP_REQUEST, request);

    ValueStack stack = ActionContext.getContext().getValueStack();
    stack.getContext().putAll(extraContext);
    oldContext = new ActionContext(stack.getContext());
    ActionContext.setContext(oldContext);
  }
Exemplo n.º 5
0
  public void testGetMappingNoSlash() throws Exception {
    StrutsMockHttpServletRequest request = new StrutsMockHttpServletRequest();
    request.setupGetServletPath("noslash");

    assertNull(mapper.getMapping(request, null));
  }