Removed Spring’s own JSP expression support (in favor of JSP 2.0+)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,6 @@ public abstract class AbstractTagTests extends TestCase {
|
||||
|
||||
protected MockPageContext createPageContext() {
|
||||
MockServletContext sc = new MockServletContext();
|
||||
sc.addInitParameter("springJspExpressionSupport", "true");
|
||||
SimpleWebApplicationContext wac = new SimpleWebApplicationContext();
|
||||
wac.setServletContext(sc);
|
||||
wac.setNamespace("test");
|
||||
|
||||
@@ -22,15 +22,14 @@ import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.Tag;
|
||||
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.tests.sample.beans.IndexedTestBean;
|
||||
import org.springframework.tests.sample.beans.NestedTestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.DataBinder;
|
||||
@@ -228,7 +227,7 @@ public class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.name");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertTrue("Has status variable", status != null);
|
||||
@@ -298,7 +297,7 @@ public class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.name");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertTrue("Has status variable", status != null);
|
||||
@@ -354,7 +353,7 @@ public class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.name");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertTrue("Has status variable", status != null);
|
||||
@@ -412,8 +411,7 @@ public class BindTagTests extends AbstractTagTests {
|
||||
pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
pc.setAttribute("myattr", "tb.spouse.name");
|
||||
tag.setPath("${myattr}");
|
||||
tag.setPath("tb.spouse.name");
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
assertTrue("Has status variable", status != null);
|
||||
@@ -536,7 +534,7 @@ public class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.doctor");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
TestBean tb = new TestBean("somebody", 99);
|
||||
NestedTestBean ntb = new NestedTestBean("juergen&eva");
|
||||
tb.setDoctor(ntb);
|
||||
@@ -553,7 +551,7 @@ public class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.someSet");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
pc.getRequest().setAttribute("tb", new TestBean("juergen&eva", 99));
|
||||
tag.doStartTag();
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
@@ -578,7 +576,7 @@ public class BindTagTests extends AbstractTagTests {
|
||||
BindTag tag = new BindTag();
|
||||
tag.setPageContext(pc);
|
||||
tag.setPath("tb.name");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
pc.getRequest().setAttribute("tb", new TestBean("juergen&eva", 99));
|
||||
tag.doStartTag();
|
||||
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
@@ -799,9 +797,8 @@ public class BindTagTests extends AbstractTagTests {
|
||||
// transform stuff
|
||||
TransformTag transform = new TransformTag();
|
||||
transform.setPageContext(pc);
|
||||
pc.setAttribute("date", tb.getDate());
|
||||
transform.setParent(bind);
|
||||
transform.setValue("${date}");
|
||||
transform.setValue(tb.getDate());
|
||||
transform.setVar("theDate");
|
||||
transform.doStartTag();
|
||||
|
||||
@@ -816,14 +813,13 @@ public class BindTagTests extends AbstractTagTests {
|
||||
|
||||
transform = new TransformTag();
|
||||
transform.setPageContext(pc);
|
||||
pc.setAttribute("string", "name");
|
||||
transform.setValue("${string}");
|
||||
transform.setValue("name");
|
||||
transform.setParent(bind);
|
||||
transform.setVar("theString");
|
||||
transform.doStartTag();
|
||||
|
||||
assertNotNull(pc.getAttribute("theString"));
|
||||
assertEquals(pc.getAttribute("theString"), "name");
|
||||
assertEquals("name", pc.getAttribute("theString"));
|
||||
}
|
||||
|
||||
public void testTransformTagWithHtmlEscape() throws JspException {
|
||||
@@ -844,15 +840,14 @@ public class BindTagTests extends AbstractTagTests {
|
||||
|
||||
TransformTag transform = new TransformTag();
|
||||
transform.setPageContext(pc);
|
||||
pc.setAttribute("string", "na<me");
|
||||
transform.setValue("${string}");
|
||||
transform.setValue("na<me");
|
||||
transform.setParent(bind);
|
||||
transform.setVar("theString");
|
||||
transform.setHtmlEscape("true");
|
||||
transform.setHtmlEscape(true);
|
||||
transform.doStartTag();
|
||||
|
||||
assertNotNull(pc.getAttribute("theString"));
|
||||
assertEquals(pc.getAttribute("theString"), "na<me");
|
||||
assertEquals("na<me", pc.getAttribute("theString"));
|
||||
}
|
||||
|
||||
public void testTransformTagOutsideBindTag() throws JspException {
|
||||
@@ -913,7 +908,7 @@ public class BindTagTests extends AbstractTagTests {
|
||||
|
||||
TransformTag transform = new TransformTag();
|
||||
transform.setPageContext(pc);
|
||||
transform.setValue("${string2}");
|
||||
transform.setValue(null);
|
||||
transform.setParent(bind);
|
||||
transform.setVar("theString2");
|
||||
transform.doStartTag();
|
||||
@@ -940,9 +935,8 @@ public class BindTagTests extends AbstractTagTests {
|
||||
// transform stuff
|
||||
TransformTag transform = new TransformTag();
|
||||
transform.setPageContext(pc);
|
||||
pc.setAttribute("date", tb.getDate());
|
||||
transform.setParent(bind);
|
||||
transform.setValue("${date}");
|
||||
transform.setValue(tb.getDate());
|
||||
transform.setVar("theDate");
|
||||
transform.setScope("page");
|
||||
transform.doStartTag();
|
||||
@@ -950,7 +944,7 @@ public class BindTagTests extends AbstractTagTests {
|
||||
transform.release();
|
||||
|
||||
assertNotNull(pc.getAttribute("theDate"));
|
||||
assertEquals(pc.getAttribute("theDate"), df.format(tb.getDate()));
|
||||
assertEquals(df.format(tb.getDate()), pc.getAttribute("theDate"));
|
||||
|
||||
// try another time, this time using Strings
|
||||
bind = new BindTag();
|
||||
@@ -960,18 +954,16 @@ public class BindTagTests extends AbstractTagTests {
|
||||
|
||||
transform = new TransformTag();
|
||||
transform.setPageContext(pc);
|
||||
pc.setAttribute("string", "name");
|
||||
pc.setAttribute("scopy", "page");
|
||||
transform.setValue("${string}");
|
||||
transform.setValue("name");
|
||||
transform.setParent(bind);
|
||||
transform.setVar("theString");
|
||||
transform.setScope("${scopy}");
|
||||
transform.setScope("page");
|
||||
transform.doStartTag();
|
||||
|
||||
transform.release();
|
||||
|
||||
assertNotNull(pc.getAttribute("theString"));
|
||||
assertEquals(pc.getAttribute("theString"), "name");
|
||||
assertEquals("name", pc.getAttribute("theString"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -80,7 +80,7 @@ public class EvalTagTests extends AbstractTagTests {
|
||||
|
||||
public void testPrintHtmlEscapedAttributeResult() throws Exception {
|
||||
tag.setExpression("bean.html()");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
int action = tag.doStartTag();
|
||||
assertEquals(Tag.EVAL_BODY_INCLUDE, action);
|
||||
action = tag.doEndTag();
|
||||
@@ -90,7 +90,7 @@ public class EvalTagTests extends AbstractTagTests {
|
||||
|
||||
public void testPrintJavaScriptEscapedAttributeResult() throws Exception {
|
||||
tag.setExpression("bean.js()");
|
||||
tag.setJavaScriptEscape("true");
|
||||
tag.setJavaScriptEscape(true);
|
||||
int action = tag.doStartTag();
|
||||
assertEquals(Tag.EVAL_BODY_INCLUDE, action);
|
||||
action = tag.doEndTag();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,29 +47,29 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
|
||||
|
||||
assertTrue("Correct default", !tag.getRequestContext().isDefaultHtmlEscape());
|
||||
assertTrue("Correctly applied", !testTag.isHtmlEscape());
|
||||
tag.setDefaultHtmlEscape("true");
|
||||
tag.setDefaultHtmlEscape(true);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertTrue("Correctly enabled", tag.getRequestContext().isDefaultHtmlEscape());
|
||||
assertTrue("Correctly applied", testTag.isHtmlEscape());
|
||||
tag.setDefaultHtmlEscape("false");
|
||||
tag.setDefaultHtmlEscape(false);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertTrue("Correctly disabled", !tag.getRequestContext().isDefaultHtmlEscape());
|
||||
assertTrue("Correctly applied", !testTag.isHtmlEscape());
|
||||
|
||||
tag.setDefaultHtmlEscape("true");
|
||||
tag.setDefaultHtmlEscape(true);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
testTag.setHtmlEscape("true");
|
||||
testTag.setHtmlEscape(true);
|
||||
assertTrue("Correctly enabled", tag.getRequestContext().isDefaultHtmlEscape());
|
||||
assertTrue("Correctly applied", testTag.isHtmlEscape());
|
||||
testTag.setHtmlEscape("false");
|
||||
testTag.setHtmlEscape(false);
|
||||
assertTrue("Correctly enabled", tag.getRequestContext().isDefaultHtmlEscape());
|
||||
assertTrue("Correctly applied", !testTag.isHtmlEscape());
|
||||
tag.setDefaultHtmlEscape("false");
|
||||
tag.setDefaultHtmlEscape(false);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
testTag.setHtmlEscape("true");
|
||||
testTag.setHtmlEscape(true);
|
||||
assertTrue("Correctly disabled", !tag.getRequestContext().isDefaultHtmlEscape());
|
||||
assertTrue("Correctly applied", testTag.isHtmlEscape());
|
||||
testTag.setHtmlEscape("false");
|
||||
testTag.setHtmlEscape(false);
|
||||
assertTrue("Correctly disabled", !tag.getRequestContext().isDefaultHtmlEscape());
|
||||
assertTrue("Correctly applied", !testTag.isHtmlEscape());
|
||||
}
|
||||
@@ -79,15 +79,15 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
|
||||
MockServletContext sc = (MockServletContext) pc.getServletContext();
|
||||
sc.addInitParameter(WebUtils.HTML_ESCAPE_CONTEXT_PARAM, "true");
|
||||
HtmlEscapeTag tag = new HtmlEscapeTag();
|
||||
tag.setDefaultHtmlEscape("false");
|
||||
tag.setDefaultHtmlEscape(false);
|
||||
tag.setPageContext(pc);
|
||||
tag.doStartTag();
|
||||
|
||||
assertTrue("Correct default", !tag.getRequestContext().isDefaultHtmlEscape());
|
||||
tag.setDefaultHtmlEscape("true");
|
||||
tag.setDefaultHtmlEscape(true);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertTrue("Correctly enabled", tag.getRequestContext().isDefaultHtmlEscape());
|
||||
tag.setDefaultHtmlEscape("false");
|
||||
tag.setDefaultHtmlEscape(false);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertTrue("Correctly disabled", !tag.getRequestContext().isDefaultHtmlEscape());
|
||||
}
|
||||
@@ -101,10 +101,10 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
|
||||
|
||||
sc.addInitParameter(WebUtils.HTML_ESCAPE_CONTEXT_PARAM, "false");
|
||||
assertTrue("Correct default", !tag.getRequestContext().isDefaultHtmlEscape());
|
||||
tag.setDefaultHtmlEscape("true");
|
||||
tag.setDefaultHtmlEscape(true);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertTrue("Correctly enabled", tag.getRequestContext().isDefaultHtmlEscape());
|
||||
tag.setDefaultHtmlEscape("false");
|
||||
tag.setDefaultHtmlEscape(false);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertTrue("Correctly disabled", !tag.getRequestContext().isDefaultHtmlEscape());
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
assertEquals(BodyTag.EVAL_BODY_BUFFERED, tag.doStartTag());
|
||||
assertEquals(Tag.SKIP_BODY, tag.doAfterBody());
|
||||
assertEquals("test & text", result.toString());
|
||||
@@ -165,7 +165,7 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setJavaScriptEscape("true");
|
||||
tag.setJavaScriptEscape(true);
|
||||
assertEquals(BodyTag.EVAL_BODY_BUFFERED, tag.doStartTag());
|
||||
assertEquals(Tag.SKIP_BODY, tag.doAfterBody());
|
||||
assertEquals("Correct content", "\\' test & text \\\\", result.toString());
|
||||
@@ -186,8 +186,8 @@ public class HtmlEscapeTagTests extends AbstractTagTests {
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setJavaScriptEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
tag.setJavaScriptEscape(true);
|
||||
assertEquals(BodyTag.EVAL_BODY_BUFFERED, tag.doStartTag());
|
||||
assertEquals(Tag.SKIP_BODY, tag.doAfterBody());
|
||||
assertEquals("Correct content", "' test & text \\\\", result.toString());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,7 @@ import org.springframework.web.servlet.support.RequestContextUtils;
|
||||
public class MessageTagTests extends AbstractTagTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithMessageSourceResolvable1() throws JspException {
|
||||
public void testMessageTagWithMessageSourceResolvable() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@@ -55,24 +55,7 @@ public class MessageTagTests extends AbstractTagTests {
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithMessageSourceResolvable2() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@Override
|
||||
protected void writeMessage(String msg) {
|
||||
message.append(msg);
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
pc.setAttribute("myattr", new DefaultMessageSourceResolvable("test"));
|
||||
tag.setMessage("${myattr}");
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "test message", message.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithCode1() throws JspException {
|
||||
public void testMessageTagWithCode() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@@ -87,26 +70,6 @@ public class MessageTagTests extends AbstractTagTests {
|
||||
assertEquals("Correct message", "test message", message.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithCode2() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
MockHttpServletRequest request = (MockHttpServletRequest) pc.getRequest();
|
||||
request.addPreferredLocale(Locale.CANADA);
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@Override
|
||||
protected void writeMessage(String msg) {
|
||||
message.append(msg);
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
pc.setAttribute("myattr", "test");
|
||||
tag.setCode("${myattr}");
|
||||
tag.setHtmlEscape("true");
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "Canadian & test message", message.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithNullCode() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
@@ -210,81 +173,7 @@ public class MessageTagTests extends AbstractTagTests {
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithCodeAndExpressionArgument() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@Override
|
||||
protected void writeMessage(String msg) {
|
||||
message.append(msg);
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgs");
|
||||
tag.setArguments("${arg1}");
|
||||
pc.setAttribute("arg1", "my,value");
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "test my,value message {1}", message.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithCodeAndExpressionArguments() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@Override
|
||||
protected void writeMessage(String msg) {
|
||||
message.append(msg);
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgs");
|
||||
tag.setArguments("${arg1},${arg2}");
|
||||
pc.setAttribute("arg1", "my,value");
|
||||
pc.setAttribute("arg2", new Integer(5));
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "test my,value message 5", message.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithCodeAndExpressionArgumentArray() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@Override
|
||||
protected void writeMessage(String msg) {
|
||||
message.append(msg);
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgs");
|
||||
tag.setArguments("${argArray}");
|
||||
pc.setAttribute("argArray", new Object[] {"my,value", new Integer(5)});
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "test my,value message 5", message.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithCodeAndExpressionArgumentFormat() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@Override
|
||||
protected void writeMessage(String msg) {
|
||||
message.append(msg);
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setCode("testArgsFormat");
|
||||
tag.setArguments("${arg1},${arg2}");
|
||||
pc.setAttribute("arg1", "my,value");
|
||||
pc.setAttribute("arg2", new Float(5.145));
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "test my,value message 5.14 X", message.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithCodeAndText1() throws JspException {
|
||||
public void testMessageTagWithCodeAndText() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@@ -300,24 +189,6 @@ public class MessageTagTests extends AbstractTagTests {
|
||||
assertEquals("Correct message", "test message", (message.toString()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithCodeAndText2() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@Override
|
||||
protected void writeMessage(String msg) {
|
||||
message.append(msg);
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
pc.setAttribute("myattr", "test & text");
|
||||
tag.setCode("test2");
|
||||
tag.setText("${myattr}");
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "test & text", message.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithText() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
@@ -330,30 +201,11 @@ public class MessageTagTests extends AbstractTagTests {
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setText("test & text");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "test & text", message.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithTextAndExpressionArgumentFormat() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
final StringBuffer message = new StringBuffer();
|
||||
MessageTag tag = new MessageTag() {
|
||||
@Override
|
||||
protected void writeMessage(String msg) {
|
||||
message.append(msg);
|
||||
}
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setText("test {0} message {1,number,#.##} X");
|
||||
tag.setArguments("${arg1},${arg2}");
|
||||
pc.setAttribute("arg1", "my,value");
|
||||
pc.setAttribute("arg2", new Float(5.145));
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "test my,value message 5.14 X", message.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public void testMessageTagWithTextAndJavaScriptEscape() throws JspException {
|
||||
PageContext pc = createPageContext();
|
||||
@@ -366,7 +218,7 @@ public class MessageTagTests extends AbstractTagTests {
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setText("' test & text \\");
|
||||
tag.setJavaScriptEscape("true");
|
||||
tag.setJavaScriptEscape(true);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "\\' test & text \\\\", message.toString());
|
||||
}
|
||||
@@ -383,8 +235,8 @@ public class MessageTagTests extends AbstractTagTests {
|
||||
};
|
||||
tag.setPageContext(pc);
|
||||
tag.setText("' test & text \\");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setJavaScriptEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
tag.setJavaScriptEscape(true);
|
||||
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
|
||||
assertEquals("Correct message", "' test & text \\\\", message.toString());
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@ import org.springframework.mock.web.test.MockPageContext;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Unit tests for UrlTag
|
||||
*
|
||||
* @author Scott Andrews
|
||||
*/
|
||||
public class UrlTagTests extends AbstractTagTests {
|
||||
@@ -118,7 +116,7 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
public void testSetHtmlEscapeFalse() throws JspException {
|
||||
tag.setValue("url/path");
|
||||
tag.setVar("var");
|
||||
tag.setHtmlEscape("false");
|
||||
tag.setHtmlEscape(false);
|
||||
|
||||
tag.doStartTag();
|
||||
|
||||
@@ -141,7 +139,7 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
public void testSetHtmlEscapeTrue() throws JspException {
|
||||
tag.setValue("url/path");
|
||||
tag.setVar("var");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
|
||||
tag.doStartTag();
|
||||
|
||||
@@ -164,7 +162,7 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
public void testSetJavaScriptEscapeTrue() throws JspException {
|
||||
tag.setValue("url/path");
|
||||
tag.setVar("var");
|
||||
tag.setJavaScriptEscape("true");
|
||||
tag.setJavaScriptEscape(true);
|
||||
|
||||
tag.doStartTag();
|
||||
|
||||
@@ -187,8 +185,8 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
public void testSetHtmlAndJavaScriptEscapeTrue() throws JspException {
|
||||
tag.setValue("url/path");
|
||||
tag.setVar("var");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setJavaScriptEscape("true");
|
||||
tag.setHtmlEscape(true);
|
||||
tag.setJavaScriptEscape(true);
|
||||
|
||||
tag.doStartTag();
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ButtonTagTests extends AbstractFormTagTests {
|
||||
}
|
||||
|
||||
public void testDisabled() throws Exception {
|
||||
this.tag.setDisabled("true");
|
||||
this.tag.setDisabled(true);
|
||||
|
||||
this.tag.doStartTag();
|
||||
this.tag.doEndTag();
|
||||
|
||||
@@ -596,7 +596,7 @@ public class CheckboxTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testHiddenElementOmittedOnDisabled() throws Exception {
|
||||
this.tag.setPath("someBoolean");
|
||||
this.tag.setDisabled("true");
|
||||
this.tag.setDisabled(true);
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
String output = getOutput();
|
||||
|
||||
@@ -671,7 +671,7 @@ public class CheckboxesTagTests extends AbstractFormTagTests {
|
||||
public void testHiddenElementOmittedOnDisabled() throws Exception {
|
||||
this.tag.setPath("stringArray");
|
||||
this.tag.setItems(new Object[] {"foo", "bar", "baz"});
|
||||
this.tag.setDisabled("true");
|
||||
this.tag.setDisabled(true);
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
String output = getOutput();
|
||||
|
||||
@@ -225,7 +225,7 @@ public class ErrorsTagTests extends AbstractFormTagTests {
|
||||
}
|
||||
|
||||
public void testWithNonEscapedErrors() throws Exception {
|
||||
this.tag.setHtmlEscape("false");
|
||||
this.tag.setHtmlEscape(false);
|
||||
|
||||
// construct an errors instance of the tag
|
||||
TestBean target = new TestBean();
|
||||
|
||||
@@ -211,7 +211,7 @@ public class FormTagTests extends AbstractHtmlElementTagTests {
|
||||
|
||||
public void testWithNullResolvedCommand() throws Exception {
|
||||
try {
|
||||
tag.setCommandName("${null}");
|
||||
tag.setCommandName(null);
|
||||
tag.doStartTag();
|
||||
fail("Must not be able to have a command name that resolves to null");
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class HiddenInputTagTests extends AbstractFormTagTests {
|
||||
}
|
||||
|
||||
public void testDisabledTrue() throws Exception {
|
||||
this.tag.setDisabled("true");
|
||||
this.tag.setDisabled(true);
|
||||
|
||||
this.tag.doStartTag();
|
||||
this.tag.doEndTag();
|
||||
@@ -102,7 +102,7 @@ public class HiddenInputTagTests extends AbstractFormTagTests {
|
||||
// SPR-8661
|
||||
|
||||
public void testDisabledFalse() throws Exception {
|
||||
this.tag.setDisabled("false");
|
||||
this.tag.setDisabled(false);
|
||||
|
||||
this.tag.doStartTag();
|
||||
this.tag.doEndTag();
|
||||
|
||||
@@ -133,7 +133,7 @@ public class InputTagTests extends AbstractFormTagTests {
|
||||
String lang = "en";
|
||||
String dir = "ltr";
|
||||
String tabindex = "2";
|
||||
String disabled = "true";
|
||||
boolean disabled = true;
|
||||
String onclick = "doClick()";
|
||||
String ondblclick = "doDblclick()";
|
||||
String onkeydown = "doKeydown()";
|
||||
@@ -151,7 +151,7 @@ public class InputTagTests extends AbstractFormTagTests {
|
||||
String maxlength = "12";
|
||||
String alt = "Some text";
|
||||
String onselect = "doSelect()";
|
||||
String readonly = "true";
|
||||
boolean readonly = true;
|
||||
String autocomplete = "off";
|
||||
String dynamicAttribute1 = "attr1";
|
||||
String dynamicAttribute2 = "attr2";
|
||||
@@ -285,7 +285,7 @@ public class InputTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testDisabledFalse() throws Exception {
|
||||
this.tag.setPath("name");
|
||||
this.tag.setDisabled("false");
|
||||
this.tag.setDisabled(false);
|
||||
this.tag.doStartTag();
|
||||
|
||||
String output = getOutput();
|
||||
@@ -314,7 +314,7 @@ public class InputTagTests extends AbstractFormTagTests {
|
||||
*/
|
||||
public void testReadOnlyAttributeRenderingWhenReadonlyIsTrue() throws Exception {
|
||||
this.tag.setPath("name");
|
||||
this.tag.setReadonly("true");
|
||||
this.tag.setReadonly(true);
|
||||
|
||||
assertEquals(Tag.SKIP_BODY, this.tag.doStartTag());
|
||||
|
||||
@@ -327,24 +327,6 @@ public class InputTagTests extends AbstractFormTagTests {
|
||||
assertValueAttribute(output, "Rob");
|
||||
}
|
||||
|
||||
/**
|
||||
* See SPR-3127 (http://opensource.atlassian.com/projects/spring/browse/SPR-3127)
|
||||
*/
|
||||
public void testReadOnlyAttributeRenderingWhenReadonlyIsFalse() throws Exception {
|
||||
this.tag.setPath("name");
|
||||
this.tag.setReadonly("nope, this is not readonly");
|
||||
|
||||
assertEquals(Tag.SKIP_BODY, this.tag.doStartTag());
|
||||
|
||||
String output = getOutput();
|
||||
assertTagOpened(output);
|
||||
assertTagClosed(output);
|
||||
|
||||
assertContainsAttribute(output, "type", getType());
|
||||
assertAttributeNotPresent(output, "readonly");
|
||||
assertValueAttribute(output, "Rob");
|
||||
}
|
||||
|
||||
public void testDynamicTypeAttribute() throws JspException {
|
||||
this.tag.setPath("myFloat");
|
||||
this.tag.setDynamicAttribute(null, "type", "number");
|
||||
|
||||
@@ -21,15 +21,14 @@ import java.beans.PropertyEditorSupport;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.jsp.tagext.BodyTag;
|
||||
import javax.servlet.jsp.tagext.Tag;
|
||||
|
||||
import org.springframework.tests.sample.beans.Colour;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
|
||||
import org.springframework.mock.web.test.MockBodyContent;
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.tests.sample.beans.Colour;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.web.servlet.support.BindStatus;
|
||||
@@ -78,7 +77,7 @@ public class OptionTagTests extends AbstractHtmlElementTagTests {
|
||||
getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), selectName, false));
|
||||
this.tag.setValue("bar");
|
||||
this.tag.setLabel("Bar");
|
||||
this.tag.setDisabled("true");
|
||||
this.tag.setDisabled(true);
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
|
||||
result = this.tag.doEndTag();
|
||||
@@ -297,8 +296,8 @@ public class OptionTagTests extends AbstractHtmlElementTagTests {
|
||||
public void testWithCustomObjectSelected() throws Exception {
|
||||
String selectName = "testBean.someNumber";
|
||||
getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), selectName, false));
|
||||
this.tag.setValue("${myNumber}");
|
||||
this.tag.setLabel("GBP ${myNumber}");
|
||||
this.tag.setValue(new Float(12.34));
|
||||
this.tag.setLabel("GBP 12.34");
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
|
||||
result = this.tag.doEndTag();
|
||||
@@ -316,8 +315,8 @@ public class OptionTagTests extends AbstractHtmlElementTagTests {
|
||||
public void testWithCustomObjectNotSelected() throws Exception {
|
||||
String selectName = "testBean.someNumber";
|
||||
getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), selectName, false));
|
||||
this.tag.setValue("${myOtherNumber}");
|
||||
this.tag.setLabel("GBP ${myOtherNumber}");
|
||||
this.tag.setValue(new Float(12.35));
|
||||
this.tag.setLabel("GBP 12.35");
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
|
||||
result = this.tag.doEndTag();
|
||||
@@ -344,8 +343,8 @@ public class OptionTagTests extends AbstractHtmlElementTagTests {
|
||||
};
|
||||
getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, bindStatus);
|
||||
|
||||
this.tag.setValue("${myNumber}");
|
||||
this.tag.setLabel("${myNumber}");
|
||||
this.tag.setValue(new Float(12.34));
|
||||
this.tag.setLabel("12.34f");
|
||||
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
|
||||
@@ -370,8 +369,8 @@ public class OptionTagTests extends AbstractHtmlElementTagTests {
|
||||
};
|
||||
getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, bindStatus);
|
||||
|
||||
this.tag.setValue("${myOtherNumber}");
|
||||
this.tag.setLabel("${myOtherNumber}");
|
||||
this.tag.setValue(new Float(12.35));
|
||||
this.tag.setLabel("12.35f");
|
||||
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
|
||||
@@ -458,9 +457,7 @@ public class OptionTagTests extends AbstractHtmlElementTagTests {
|
||||
getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, bindStatus);
|
||||
|
||||
RulesVariant rulesVariant = new RulesVariant("someRules", "someVariant");
|
||||
getPageContext().getRequest().setAttribute("rule", rulesVariant);
|
||||
|
||||
this.tag.setValue("${rule}");
|
||||
this.tag.setValue(rulesVariant);
|
||||
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
|
||||
@@ -522,8 +519,6 @@ public class OptionTagTests extends AbstractHtmlElementTagTests {
|
||||
bean.setFriends(friends);
|
||||
|
||||
request.setAttribute("testBean", bean);
|
||||
request.setAttribute("myNumber", new Float(12.34));
|
||||
request.setAttribute("myOtherNumber", new Float(12.35));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ package org.springframework.web.servlet.tags.form;
|
||||
import java.beans.PropertyEditor;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.jsp.tagext.BodyTag;
|
||||
import javax.servlet.jsp.tagext.Tag;
|
||||
@@ -31,9 +31,10 @@ import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.test.MockPageContext;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.Errors;
|
||||
@@ -84,7 +85,7 @@ public final class OptionsTagTests extends AbstractHtmlElementTagTests {
|
||||
getPageContext().setAttribute(
|
||||
SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), "testBean.country", false));
|
||||
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
this.tag.setItemLabel("name");
|
||||
this.tag.setId("myOption");
|
||||
@@ -116,7 +117,7 @@ public final class OptionsTagTests extends AbstractHtmlElementTagTests {
|
||||
getPageContext().setAttribute(
|
||||
SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), "testBean.country", false));
|
||||
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
this.tag.setItemLabel("name");
|
||||
this.tag.setId("myOption");
|
||||
@@ -159,7 +160,15 @@ public final class OptionsTagTests extends AbstractHtmlElementTagTests {
|
||||
getPageContext().setAttribute(
|
||||
SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), "testBean.myFloat", false));
|
||||
|
||||
this.tag.setItems("${floats}");
|
||||
List<Float> floats = new ArrayList<Float>();
|
||||
floats.add(new Float("12.30"));
|
||||
floats.add(new Float("12.31"));
|
||||
floats.add(new Float("12.32"));
|
||||
floats.add(new Float("12.33"));
|
||||
floats.add(new Float("12.34"));
|
||||
floats.add(new Float("12.35"));
|
||||
|
||||
this.tag.setItems(floats);
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
String output = getOutput();
|
||||
@@ -184,11 +193,10 @@ public final class OptionsTagTests extends AbstractHtmlElementTagTests {
|
||||
}
|
||||
|
||||
public void testWithItemsNullReference() throws Exception {
|
||||
getPageContext().getRequest().removeAttribute("countries");
|
||||
getPageContext().setAttribute(
|
||||
SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), "testBean.country", false));
|
||||
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Collections.emptyList());
|
||||
this.tag.setItemValue("isoCode");
|
||||
this.tag.setItemLabel("name");
|
||||
int result = this.tag.doStartTag();
|
||||
@@ -287,7 +295,6 @@ public final class OptionsTagTests extends AbstractHtmlElementTagTests {
|
||||
bean.setCountry("UK");
|
||||
bean.setMyFloat(new Float("12.34"));
|
||||
request.setAttribute(COMMAND_NAME, bean);
|
||||
request.setAttribute("countries", Country.getCountries());
|
||||
|
||||
List floats = new ArrayList();
|
||||
floats.add(new Float("12.30"));
|
||||
|
||||
@@ -524,7 +524,7 @@ public final class RadioButtonsTagTests extends AbstractFormTagTests {
|
||||
public void testHiddenElementOmittedOnDisabled() throws Exception {
|
||||
this.tag.setPath("stringArray");
|
||||
this.tag.setItems(new Object[] {"foo", "bar", "baz"});
|
||||
this.tag.setDisabled("true");
|
||||
this.tag.setDisabled(true);
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
String output = getOutput();
|
||||
|
||||
@@ -38,11 +38,11 @@ import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.beans.propertyeditors.CustomCollectionEditor;
|
||||
import org.springframework.format.Formatter;
|
||||
import org.springframework.format.support.FormattingConversionService;
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.servlet.support.BindStatus;
|
||||
@@ -129,7 +129,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testWithResolvedList() throws Exception {
|
||||
this.tag.setPath("country");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
assertList(true);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testWithListAndNoLabel() throws Exception {
|
||||
this.tag.setPath("country");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
@@ -174,7 +174,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testWithListAndTransformTagAndEditor() throws Exception {
|
||||
this.tag.setPath("realCountry");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(getTestBean(), "testBean");
|
||||
bindingResult.getPropertyAccessor().registerCustomEditor(Country.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
@@ -202,7 +202,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testWithListAndEditor() throws Exception {
|
||||
this.tag.setPath("realCountry");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
this.tag.setItemLabel("name");
|
||||
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(getTestBean(), "testBean");
|
||||
@@ -226,7 +226,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testNestedPathWithListAndEditorAndNullValue() throws Exception {
|
||||
this.tag.setPath("bean.realCountry");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
this.tag.setItemLabel("name");
|
||||
this.tag.setMultiple("false");
|
||||
@@ -264,7 +264,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testNestedPathWithListAndEditor() throws Exception {
|
||||
this.tag.setPath("bean.realCountry");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
this.tag.setItemLabel("name");
|
||||
TestBeanWrapper testBean = new TestBeanWrapper();
|
||||
@@ -290,7 +290,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testWithListAndEditorAndNullValue() throws Exception {
|
||||
this.tag.setPath("realCountry");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
this.tag.setItemLabel("name");
|
||||
TestBeanWithRealCountry testBean = (TestBeanWithRealCountry) getTestBean();
|
||||
@@ -321,14 +321,14 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testWithMap() throws Exception {
|
||||
this.tag.setPath("sex");
|
||||
this.tag.setItems("${sexes}");
|
||||
this.tag.setItems(getSexes());
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
}
|
||||
|
||||
public void testWithInvalidList() throws Exception {
|
||||
this.tag.setPath("country");
|
||||
this.tag.setItems("${other}");
|
||||
this.tag.setItems(new TestBean());
|
||||
this.tag.setItemValue("isoCode");
|
||||
try {
|
||||
this.tag.doStartTag();
|
||||
@@ -367,7 +367,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testWithResolvedStringArray() throws Exception {
|
||||
this.tag.setPath("name");
|
||||
this.tag.setItems("${names}");
|
||||
this.tag.setItems(getNames());
|
||||
assertStringArray();
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
this.bean.setSomeList(list);
|
||||
|
||||
this.tag.setPath("someList");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
@@ -495,7 +495,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
exposeBindingResult(errors);
|
||||
|
||||
this.tag.setPath("realCountry");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
@@ -542,7 +542,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
exposeBindingResult(errors);
|
||||
|
||||
this.tag.setPath("someList");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
@@ -587,7 +587,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
exposeBindingResult(errors);
|
||||
|
||||
this.tag.setPath("someList");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
@@ -621,7 +621,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
this.bean.setSomeMap(someMap);
|
||||
|
||||
this.tag.setPath("someMap");
|
||||
this.tag.setItems("${sexes}");
|
||||
this.tag.setItems(getSexes());
|
||||
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
@@ -681,7 +681,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
this.bean.setSomeMap(someMap);
|
||||
|
||||
this.tag.setPath("someMap"); // see: TestBean
|
||||
this.tag.setItems("${countryToLocaleMap}"); // see: extendRequest()
|
||||
this.tag.setItems(getCountryToLocaleMap());
|
||||
this.tag.setItemValue("isoCode"); // Map key: Country
|
||||
this.tag.setItemLabel("displayLanguage"); // Map value: Locale
|
||||
|
||||
@@ -742,7 +742,7 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
this.bean.setSomeList(new ArrayList());
|
||||
|
||||
this.tag.setPath("someList");
|
||||
this.tag.setItems("${countries}");
|
||||
this.tag.setItems(Country.getCountries());
|
||||
this.tag.setItemValue("isoCode");
|
||||
int result = this.tag.doStartTag();
|
||||
assertEquals(Tag.SKIP_BODY, result);
|
||||
@@ -807,22 +807,12 @@ public class SelectTagTests extends AbstractFormTagTests {
|
||||
}
|
||||
|
||||
private Map getSexes() {
|
||||
Map sexes = new HashMap();
|
||||
Map<String, String> sexes = new HashMap<String, String>();
|
||||
sexes.put("F", "Female");
|
||||
sexes.put("M", "Male");
|
||||
return sexes;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void extendRequest(MockHttpServletRequest request) {
|
||||
super.extendRequest(request);
|
||||
request.setAttribute("countries", Country.getCountries());
|
||||
request.setAttribute("countryToLocaleMap", getCountryToLocaleMap());
|
||||
request.setAttribute("sexes", getSexes());
|
||||
request.setAttribute("other", new TestBean());
|
||||
request.setAttribute("names", getNames());
|
||||
}
|
||||
|
||||
private void assertList(boolean selected) throws JspException, DocumentException {
|
||||
this.tag.setItemValue("isoCode");
|
||||
this.tag.setItemLabel("name");
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TextareaTagTests extends AbstractFormTagTests {
|
||||
|
||||
public void testSimpleBind() throws Exception {
|
||||
this.tag.setPath("name");
|
||||
this.tag.setReadonly("true");
|
||||
this.tag.setReadonly(true);
|
||||
|
||||
assertEquals(Tag.SKIP_BODY, this.tag.doStartTag());
|
||||
String output = getOutput();
|
||||
@@ -61,7 +61,7 @@ public class TextareaTagTests extends AbstractFormTagTests {
|
||||
String dynamicAttribute2 = "attr2";
|
||||
|
||||
this.tag.setPath("name");
|
||||
this.tag.setReadonly("true");
|
||||
this.tag.setReadonly(true);
|
||||
this.tag.setDynamicAttribute(null, dynamicAttribute1, dynamicAttribute1);
|
||||
this.tag.setDynamicAttribute(null, dynamicAttribute2, dynamicAttribute2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user