From 261a863e8f61504a335dcfdbe1ed9f01d7e1fcbc Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Wed, 5 Feb 2014 17:22:36 +0100 Subject: [PATCH] Fix EvalTagTests with locales other than english Fix testPrintFormattedScopedAttributeResult test in org.springframework.web.servlet.tags.EvalTagTests class by making an assertion which is not locale dependent. Issue: SPR-11392 --- .../org/springframework/web/servlet/tags/EvalTagTests.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java index 9238ed9cd2..12fe666267 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java @@ -18,6 +18,7 @@ package org.springframework.web.servlet.tags; import java.math.BigDecimal; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import javax.servlet.jsp.tagext.Tag; @@ -26,6 +27,7 @@ import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.env.MapPropertySource; import org.springframework.format.annotation.NumberFormat; import org.springframework.format.annotation.NumberFormat.Style; +import org.springframework.format.number.PercentFormatter; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.mock.web.test.MockHttpServletResponse; import org.springframework.mock.web.test.MockPageContext; @@ -70,12 +72,14 @@ public class EvalTagTests extends AbstractTagTests { } public void testPrintFormattedScopedAttributeResult() throws Exception { + PercentFormatter formatter = new PercentFormatter(); tag.setExpression("bean.formattable"); int action = tag.doStartTag(); assertEquals(Tag.EVAL_BODY_INCLUDE, action); action = tag.doEndTag(); assertEquals(Tag.EVAL_PAGE, action); - assertEquals("25%", ((MockHttpServletResponse) context.getResponse()).getContentAsString()); + assertEquals(formatter.print(new BigDecimal(".25"), Locale.getDefault()), + ((MockHttpServletResponse) context.getResponse()).getContentAsString()); } public void testPrintHtmlEscapedAttributeResult() throws Exception {