Пример #1
0
  @Test
  public void doEndTag() throws JspException {
    tag.setValue("url/path");

    tag.doStartTag();
    int action = tag.doEndTag();

    assertEquals(Tag.EVAL_PAGE, action);
  }
Пример #2
0
  @Test
  public void varDefaultScope() throws JspException {
    tag.setValue("url/path");
    tag.setVar("var");

    tag.doStartTag();
    tag.doEndTag();

    assertEquals("url/path", context.getAttribute("var", PageContext.PAGE_SCOPE));
  }
Пример #3
0
  @Test
  public void createUrlRelative() throws JspException {
    tag.setValue("url/path");

    tag.doStartTag();

    String uri = invokeCreateUrl(tag);

    assertEquals("url/path", uri);
  }
Пример #4
0
  @Test
  public void varExplicitScope() throws JspException {
    tag.setValue("url/path");
    tag.setVar("var");
    tag.setScope("request");

    tag.doStartTag();
    tag.doEndTag();

    assertEquals("url/path", context.getAttribute("var", PageContext.REQUEST_SCOPE));
  }
Пример #5
0
  @Test
  public void createUrlRemoteServer() throws JspException {
    tag.setValue("http://www.springframework.org/");

    tag.doStartTag();

    // String uri = tag.createUrl();
    String uri = invokeCreateUrl(tag);

    assertEquals("http://www.springframework.org/", uri);
  }
Пример #6
0
  @Test
  public void createUrlLocalContext() throws JspException {
    ((MockHttpServletRequest) context.getRequest()).setContextPath("/app-context");

    tag.setValue("/url/path");

    tag.doStartTag();

    String uri = invokeCreateUrl(tag);

    assertEquals("/app-context/url/path", uri);
  }
Пример #7
0
  @Test
  public void createUrlWithParamAndExsistingQueryString() throws JspException {
    tag.setValue("url/path?foo=bar");

    tag.doStartTag();

    Param param = new Param();
    param.setName("name");
    param.setValue("value");
    tag.addParam(param);

    String uri = invokeCreateUrl(tag);

    assertEquals("url/path?foo=bar&name=value", uri);
  }
Пример #8
0
  @Test
  public void createUrlWithTemplateParams() throws JspException {
    tag.setValue("url/{name}");

    tag.doStartTag();

    Param param = new Param();
    param.setName("name");
    param.setValue("value");
    tag.addParam(param);

    param = new Param();
    param.setName("n me");
    param.setValue("v lue");
    tag.addParam(param);

    String uri = invokeCreateUrl(tag);

    assertEquals("url/value?n%20me=v%20lue", uri);
  }
Пример #9
0
  @Test
  public void setHtmlEscapeDefault() throws JspException {
    tag.setValue("url/path");
    tag.setVar("var");

    tag.doStartTag();

    Param param = new Param();
    param.setName("n me");
    param.setValue("v&l=e");
    tag.addParam(param);

    param = new Param();
    param.setName("name");
    param.setValue("value2");
    tag.addParam(param);

    tag.doEndTag();

    assertEquals("url/path?n%20me=v%26l%3De&name=value2", context.getAttribute("var"));
  }
Пример #10
0
  @Test
  public void doStartTag() throws JspException {
    int action = tag.doStartTag();

    assertEquals(Tag.EVAL_BODY_INCLUDE, action);
  }