Exemplo n.º 1
0
  /**
   * TestCase for getFormat( HttpServletRequest ) method
   *
   * <p>Get output format from URL.
   *
   * <p>
   *
   * <ol>
   *   <li>If format is null from URL, use default output format as HTML.
   *   <li>If format is HTM from URL, return the format as HTML also.
   *   <li>Else, return the received format.
   * </ol>
   */
  public void testGetOutputFormat() {
    // format is null
    assertEquals(ParameterAccessor.PARAM_FORMAT_HTML, ParameterAccessor.getFormat(request));

    // format is HTM
    request.addParameter(ParameterAccessor.PARAM_FORMAT, ParameterAccessor.PARAM_FORMAT_HTM);
    assertEquals(ParameterAccessor.PARAM_FORMAT_HTML, ParameterAccessor.getFormat(request));
    request.removeParameter(ParameterAccessor.PARAM_FORMAT);

    // format is the other
    request.addParameter(ParameterAccessor.PARAM_FORMAT, "SpecialFormat"); // $NON-NLS-1$
    assertEquals("SpecialFormat", ParameterAccessor.getFormat(request)); // $NON-NLS-1$
    request.removeParameter(ParameterAccessor.PARAM_FORMAT);
  }
Exemplo n.º 2
0
  /**
   * TestCase for getFormat( HttpServletRequest, String ) method
   *
   * <p>Get current parameter format from URL.
   */
  public void testGetParameterFormat() {
    String paramName = "SampleParam"; // $NON-NLS-1$
    String paramFormat = "yyyy-MM-dd"; // $NON-NLS-1$

    // no parameter format
    request.addParameter(paramName, "parameter value"); // $NON-NLS-1$
    assertNull(ParameterAccessor.getFormat(request, paramName));

    // set parameter format
    request.addParameter(paramName + "_format", paramFormat); // $NON-NLS-1$
    assertEquals(paramFormat, ParameterAccessor.getFormat(request, paramName));

    request.removeParameter(paramName);
    request.removeParameter(paramName + "_format"); // $NON-NLS-1$
  }