|
18 | 18 |
|
19 | 19 | import java.math.BigDecimal;
|
20 | 20 | import java.util.HashMap;
|
| 21 | +import java.util.Locale; |
21 | 22 | import java.util.Map;
|
22 | 23 |
|
23 | 24 | import javax.servlet.jsp.tagext.Tag;
|
|
26 | 27 | import org.springframework.core.env.MapPropertySource;
|
27 | 28 | import org.springframework.format.annotation.NumberFormat;
|
28 | 29 | import org.springframework.format.annotation.NumberFormat.Style;
|
| 30 | +import org.springframework.format.number.PercentFormatter; |
29 | 31 | import org.springframework.format.support.FormattingConversionServiceFactoryBean;
|
30 | 32 | import org.springframework.mock.web.test.MockHttpServletResponse;
|
31 | 33 | import org.springframework.mock.web.test.MockPageContext;
|
@@ -70,12 +72,14 @@ public void testPrintNullAsEmptyString() throws Exception {
|
70 | 72 | }
|
71 | 73 |
|
72 | 74 | public void testPrintFormattedScopedAttributeResult() throws Exception {
|
| 75 | + PercentFormatter formatter = new PercentFormatter(); |
73 | 76 | tag.setExpression("bean.formattable");
|
74 | 77 | int action = tag.doStartTag();
|
75 | 78 | assertEquals(Tag.EVAL_BODY_INCLUDE, action);
|
76 | 79 | action = tag.doEndTag();
|
77 | 80 | assertEquals(Tag.EVAL_PAGE, action);
|
78 |
| - assertEquals("25%", ((MockHttpServletResponse) context.getResponse()).getContentAsString()); |
| 81 | + assertEquals(formatter.print(new BigDecimal(".25"), Locale.getDefault()), |
| 82 | + ((MockHttpServletResponse) context.getResponse()).getContentAsString()); |
79 | 83 | }
|
80 | 84 |
|
81 | 85 | public void testPrintHtmlEscapedAttributeResult() throws Exception {
|
|
0 commit comments