SpringTestContext allow setting Context

Fixes: gh-5015
This commit is contained in:
Rob Winch 2018-02-12 14:44:24 -06:00
parent 49e5b15ce2
commit 1ad57adccc
1 changed files with 6 additions and 0 deletions

View File

@ -17,6 +17,7 @@
package org.springframework.security.config.test;
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.mock.web.MockServletConfig;
import org.springframework.mock.web.MockServletContext;
@ -68,6 +69,11 @@ public class SpringTestContext implements Closeable {
} catch(Exception e) {}
}
public SpringTestContext context(ConfigurableWebApplicationContext context) {
this.context = context;
return this;
}
public SpringTestContext register(Class<?>... classes) {
AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
applicationContext.register(classes);