2222import java .util .Map ;
2323
2424import jakarta .servlet .jsp .tagext .Tag ;
25+ import org .junit .jupiter .api .AfterEach ;
2526import org .junit .jupiter .api .BeforeEach ;
2627import org .junit .jupiter .api .Test ;
2728
29+ import org .springframework .context .i18n .LocaleContextHolder ;
2830import org .springframework .context .support .GenericApplicationContext ;
2931import org .springframework .core .env .MapPropertySource ;
3032import org .springframework .format .annotation .NumberFormat ;
3133import org .springframework .format .annotation .NumberFormat .Style ;
32- import org .springframework .format .number .PercentStyleFormatter ;
3334import org .springframework .format .support .FormattingConversionServiceFactoryBean ;
3435import org .springframework .web .servlet .DispatcherServlet ;
3536import org .springframework .web .testfixture .servlet .MockHttpServletResponse ;
@@ -49,6 +50,8 @@ class EvalTagTests extends AbstractTagTests {
4950
5051 @ BeforeEach
5152 void setup () {
53+ LocaleContextHolder .setDefaultLocale (Locale .UK );
54+
5255 context = createPageContext ();
5356 FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean ();
5457 factory .afterPropertiesSet ();
@@ -58,6 +61,11 @@ void setup() {
5861 tag .setPageContext (context );
5962 }
6063
64+ @ AfterEach
65+ void reset () {
66+ LocaleContextHolder .setDefaultLocale (null );
67+ }
68+
6169
6270 @ Test
6371 void printScopedAttributeResult () throws Exception {
@@ -81,13 +89,12 @@ void printNullAsEmptyString() throws Exception {
8189
8290 @ Test
8391 void printFormattedScopedAttributeResult () throws Exception {
84- PercentStyleFormatter formatter = new PercentStyleFormatter ();
8592 tag .setExpression ("bean.formattable" );
8693 int action = tag .doStartTag ();
8794 assertThat (action ).isEqualTo (Tag .EVAL_BODY_INCLUDE );
8895 action = tag .doEndTag ();
8996 assertThat (action ).isEqualTo (Tag .EVAL_PAGE );
90- assertThat (((MockHttpServletResponse ) context .getResponse ()).getContentAsString ()).isEqualTo (formatter . print ( new BigDecimal ( ".25" ), Locale . getDefault ()) );
97+ assertThat (((MockHttpServletResponse ) context .getResponse ()).getContentAsString ()).isEqualTo ("25%" );
9198 }
9299
93100 @ Test
0 commit comments