@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); }
@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")); }
@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); }