3939import org .springframework .web .testfixture .servlet .MockPageContext ;
4040
4141import static org .assertj .core .api .Assertions .assertThat ;
42+ import static org .mockito .ArgumentMatchers .any ;
4243import static org .mockito .ArgumentMatchers .eq ;
4344import static org .mockito .ArgumentMatchers .isNull ;
44- import static org .mockito .ArgumentMatchers .same ;
4545import static org .mockito .BDDMockito .given ;
4646import static org .mockito .Mockito .mock ;
47- import static org .mockito .Mockito .spy ;
4847
4948/**
5049 * @author Keith Donald
@@ -60,15 +59,9 @@ class EvalTagTests extends AbstractTagTests {
6059 void setup () {
6160 LocaleContextHolder .setDefaultLocale (Locale .UK );
6261
63- context = spy (createPageContext ());
64- ELContext elContext = mock ();
65- ELResolver elResolver = mock ();
66- given (elResolver .getValue (same (elContext ), isNull (), eq ("pageContext" ))).willReturn (context );
67- given (elContext .getELResolver ()).willReturn (elResolver );
68- given (context .getELContext ()).willReturn (elContext );
69-
7062 FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean ();
7163 factory .afterPropertiesSet ();
64+ context = createPageContext ();
7265 context .getRequest ().setAttribute ("org.springframework.core.convert.ConversionService" , factory .getObject ());
7366 context .getRequest ().setAttribute ("bean" , new Bean ());
7467
@@ -198,12 +191,18 @@ void mapAccess() throws Exception {
198191
199192 @ Test
200193 void resolveImplicitVariable () throws Exception {
194+ ELContext elContext = mock ();
195+ ELResolver elResolver = mock ();
196+ given (elContext .getELResolver ()).willReturn (elResolver );
197+ given (elResolver .getValue (any (ELContext .class ), isNull (), eq ("pageContext" ))).willReturn (context );
198+ ((ExtendedMockPageContext ) context ).setELContext (elContext );
199+
201200 tag .setExpression ("pageContext.getClass().getSimpleName()" );
202201 int action = tag .doStartTag ();
203202 assertThat (action ).isEqualTo (Tag .EVAL_BODY_INCLUDE );
204203 action = tag .doEndTag ();
205204 assertThat (action ).isEqualTo (Tag .EVAL_PAGE );
206- assertThat (((MockHttpServletResponse ) context .getResponse ()).getContentAsString ()).isEqualTo ("MockPageContext " );
205+ assertThat (((MockHttpServletResponse ) context .getResponse ()).getContentAsString ()).isEqualTo ("ExtendedMockPageContext " );
207206 }
208207
209208
0 commit comments