use of org.springframework.context.support.StaticApplicationContext in project spring-security by spring-projects.
the class DefaultWebSecurityExpressionHandlerTests method expressionPropertiesAreResolvedAgainstAppContextBeans.
@Test
public void expressionPropertiesAreResolvedAgainstAppContextBeans() {
StaticApplicationContext appContext = new StaticApplicationContext();
RootBeanDefinition bean = new RootBeanDefinition(SecurityConfig.class);
bean.getConstructorArgumentValues().addGenericArgumentValue("ROLE_A");
appContext.registerBeanDefinition("role", bean);
this.handler.setApplicationContext(appContext);
EvaluationContext ctx = this.handler.createEvaluationContext(mock(Authentication.class), mock(FilterInvocation.class));
ExpressionParser parser = this.handler.getExpressionParser();
assertThat(parser.parseExpression("@role.getAttribute() == 'ROLE_A'").getValue(ctx, Boolean.class)).isTrue();
assertThat(parser.parseExpression("@role.attribute == 'ROLE_A'").getValue(ctx, Boolean.class)).isTrue();
}
use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.
the class ScriptTemplateViewTests method setup.
@BeforeEach
public void setup() {
this.configurer = new ScriptTemplateConfigurer();
this.context = new StaticApplicationContext();
this.context.getBeanFactory().registerSingleton("scriptTemplateConfigurer", this.configurer);
this.view = new ScriptTemplateView();
}
use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.
the class UrlBasedViewResolverTests method setup.
@BeforeEach
public void setup() {
StaticApplicationContext context = new StaticApplicationContext();
context.refresh();
this.resolver.setApplicationContext(context);
}
use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.
the class XsltViewResolverTests method resolveView.
@Test
public void resolveView() throws Exception {
StaticApplicationContext ctx = new StaticApplicationContext();
String prefix = ClassUtils.classPackageAsResourcePath(getClass());
String suffix = ".xsl";
String viewName = "products";
XsltViewResolver viewResolver = new XsltViewResolver();
viewResolver.setPrefix(prefix);
viewResolver.setSuffix(suffix);
viewResolver.setApplicationContext(ctx);
XsltView view = (XsltView) viewResolver.resolveViewName(viewName, Locale.ENGLISH);
assertThat(view).as("View should not be null").isNotNull();
assertThat(view.getUrl()).as("Incorrect URL").isEqualTo((prefix + viewName + suffix));
}
use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.
the class XsltViewTests method getXsltView.
private XsltView getXsltView(String templatePath) {
XsltView view = new XsltView();
view.setUrl(templatePath);
view.setApplicationContext(new StaticApplicationContext());
view.initApplicationContext();
return view;
}
Aggregations