Ejemplo n.º 1
0
  public final void testExecuteWhenRedirectURIExceedsMaxLength() throws Exception {
    String url =
        StringUtils.rightPad("/YourRhn.do", (int) CreateRedirectURI.MAX_URL_LENGTH + 1, "x");

    mockRequest.stubs().method("getRequestURI").will(returnValue(url));

    CreateRedirectURI command = new CreateRedirectURI();
    String redirectUrl = command.execute(getMockRequest());

    assertEquals(LoginAction.DEFAULT_URL_BOUNCE, redirectUrl);
  }
Ejemplo n.º 2
0
  public final void testExecuteWhenRequestHasNoParams() throws Exception {
    mockRequest
        .stubs()
        .method("getParameterNames")
        .will(returnValue(new Vector<String>().elements()));

    CreateRedirectURI command = new CreateRedirectURI();
    String redirectUrl = command.execute(getMockRequest());

    assertEquals("/YourRhn.do?", redirectUrl);
  }
Ejemplo n.º 3
0
  public final void testExecuteWhenRequestHasParams() throws Exception {
    String paramName = "foo";
    String paramValue = "param value = bar#$%!";

    String expected = "/YourRhn.do?foo=" + URLEncoder.encode(paramValue, "UTF-8") + "&";

    Vector<String> paramNames = new Vector<String>();
    paramNames.add(paramName);

    mockRequest.stubs().method("getParameterNames").will(returnValue(paramNames.elements()));
    mockRequest.stubs().method("getParameter").with(eq(paramName)).will(returnValue(paramValue));

    CreateRedirectURI command = new CreateRedirectURI();
    String redirectURI = command.execute(getMockRequest());

    assertEquals(expected, redirectURI);
  }