示例#1
0
  public void testReplaceUriTemplateParamsTemplateWithoutParamMatch() throws JspException {
    List<Param> params = new LinkedList<Param>();
    Set<String> usedParams = new HashSet<String>();

    String uri = tag.replaceUriTemplateParams("url/{path}", params, usedParams);

    assertEquals("url/{path}", uri);
    assertEquals(0, usedParams.size());
  }
示例#2
0
  @Test
  public void replaceUriTemplateParamsNoParams() throws JspException {
    List<Param> params = new LinkedList<Param>();
    Set<String> usedParams = new HashSet<String>();

    String uri = tag.replaceUriTemplateParams("url/path", params, usedParams);

    assertEquals("url/path", uri);
    assertEquals(0, usedParams.size());
  }
示例#3
0
  public void testReplaceUriTemplateParamsTemplateWithParamMatchValueEncoded() throws JspException {
    List<Param> params = new LinkedList<Param>();
    Set<String> usedParams = new HashSet<String>();

    Param param = new Param();
    param.setName("name");
    param.setValue("v lue");
    params.add(param);

    String uri = tag.replaceUriTemplateParams("url/{name}", params, usedParams);

    assertEquals("url/v%20lue", uri);
    assertEquals(1, usedParams.size());
    assertTrue(usedParams.contains("name"));
  }
示例#4
0
  @Test
  public void replaceUriTemplateParamsTemplateWithPathSegment() throws JspException {
    List<Param> params = new LinkedList<Param>();
    Set<String> usedParams = new HashSet<String>();

    Param param = new Param();
    param.setName("name");
    param.setValue("my/Id");
    params.add(param);

    String uri = tag.replaceUriTemplateParams("url/{/name}", params, usedParams);

    assertEquals("url/my%2FId", uri);
    assertEquals(1, usedParams.size());
    assertTrue(usedParams.contains("name"));
  }