Skip to content

Commit a2ec8f8

Browse files
sdeleuzesbrannen
authored andcommitted
Fix EvalTagTests with locales other than English
Issue: SPR-11392 (cherry picked from commit edb0b0e)
1 parent 03e243a commit a2ec8f8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.math.BigDecimal;
2020
import java.util.HashMap;
21+
import java.util.Locale;
2122
import java.util.Map;
2223

2324
import javax.servlet.jsp.tagext.Tag;
@@ -26,6 +27,7 @@
2627
import org.springframework.core.env.MapPropertySource;
2728
import org.springframework.format.annotation.NumberFormat;
2829
import org.springframework.format.annotation.NumberFormat.Style;
30+
import org.springframework.format.number.PercentFormatter;
2931
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
3032
import org.springframework.mock.web.test.MockHttpServletResponse;
3133
import org.springframework.mock.web.test.MockPageContext;
@@ -70,12 +72,14 @@ public void testPrintNullAsEmptyString() throws Exception {
7072
}
7173

7274
public void testPrintFormattedScopedAttributeResult() throws Exception {
75+
PercentFormatter formatter = new PercentFormatter();
7376
tag.setExpression("bean.formattable");
7477
int action = tag.doStartTag();
7578
assertEquals(Tag.EVAL_BODY_INCLUDE, action);
7679
action = tag.doEndTag();
7780
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());
7983
}
8084

8185
public void testPrintHtmlEscapedAttributeResult() throws Exception {

0 commit comments

Comments
 (0)