Java Code Examples for org.springframework.web.context.support.GenericWebApplicationContext#getBeanFactory()

The following examples show how to use org.springframework.web.context.support.GenericWebApplicationContext#getBeanFactory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExpressionValueMethodArgumentResolverTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Before
@SuppressWarnings("resource")
public void setUp() throws Exception {
	GenericWebApplicationContext context = new GenericWebApplicationContext();
	context.refresh();
	resolver = new ExpressionValueMethodArgumentResolver(context.getBeanFactory());

	Method method = getClass().getMethod("params", int.class, String.class, String.class);
	paramSystemProperty = new MethodParameter(method, 0);
	paramContextPath = new MethodParameter(method, 1);
	paramNotSupported = new MethodParameter(method, 2);

	webRequest = new ServletWebRequest(new MockHttpServletRequest(), new MockHttpServletResponse());

	// Expose request to the current thread (for SpEL expressions)
	RequestContextHolder.setRequestAttributes(webRequest);
}
 
Example 2
Source File: RequestHeaderMethodArgumentResolverTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Before
@SuppressWarnings("resource")
public void setup() throws Exception {
	GenericWebApplicationContext context = new GenericWebApplicationContext();
	context.refresh();
	resolver = new RequestHeaderMethodArgumentResolver(context.getBeanFactory());

	Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
	paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 0);
	paramNamedValueStringArray = new SynthesizingMethodParameter(method, 1);
	paramSystemProperty = new SynthesizingMethodParameter(method, 2);
	paramContextPath = new SynthesizingMethodParameter(method, 3);
	paramResolvedNameWithExpression = new SynthesizingMethodParameter(method, 4);
	paramResolvedNameWithPlaceholder = new SynthesizingMethodParameter(method, 5);
	paramNamedValueMap = new SynthesizingMethodParameter(method, 6);
	paramDate = new SynthesizingMethodParameter(method, 7);
	paramInstant = new SynthesizingMethodParameter(method, 8);

	servletRequest = new MockHttpServletRequest();
	webRequest = new ServletWebRequest(servletRequest, new MockHttpServletResponse());

	// Expose request to the current thread (for SpEL expressions)
	RequestContextHolder.setRequestAttributes(webRequest);
}
 
Example 3
Source File: ExpressionValueMethodArgumentResolverTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Before
@SuppressWarnings("resource")
public void setUp() throws Exception {
	GenericWebApplicationContext context = new GenericWebApplicationContext();
	context.refresh();
	resolver = new ExpressionValueMethodArgumentResolver(context.getBeanFactory());

	Method method = getClass().getMethod("params", int.class, String.class, String.class);
	paramSystemProperty = new MethodParameter(method, 0);
	paramContextPath = new MethodParameter(method, 1);
	paramNotSupported = new MethodParameter(method, 2);

	webRequest = new ServletWebRequest(new MockHttpServletRequest(), new MockHttpServletResponse());

	// Expose request to the current thread (for SpEL expressions)
	RequestContextHolder.setRequestAttributes(webRequest);
}
 
Example 4
Source File: RequestHeaderMethodArgumentResolverTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Before
@SuppressWarnings("resource")
public void setup() throws Exception {
	GenericWebApplicationContext context = new GenericWebApplicationContext();
	context.refresh();
	resolver = new RequestHeaderMethodArgumentResolver(context.getBeanFactory());

	Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
	paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 0);
	paramNamedValueStringArray = new SynthesizingMethodParameter(method, 1);
	paramSystemProperty = new SynthesizingMethodParameter(method, 2);
	paramContextPath = new SynthesizingMethodParameter(method, 3);
	paramResolvedNameWithExpression = new SynthesizingMethodParameter(method, 4);
	paramResolvedNameWithPlaceholder = new SynthesizingMethodParameter(method, 5);
	paramNamedValueMap = new SynthesizingMethodParameter(method, 6);
	paramDate = new SynthesizingMethodParameter(method, 7);
	paramInstant = new SynthesizingMethodParameter(method, 8);

	servletRequest = new MockHttpServletRequest();
	webRequest = new ServletWebRequest(servletRequest, new MockHttpServletResponse());

	// Expose request to the current thread (for SpEL expressions)
	RequestContextHolder.setRequestAttributes(webRequest);
}
 
Example 5
Source File: ExpressionValueMethodArgumentResolverTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings("resource")
public void setUp() throws Exception {
	GenericWebApplicationContext context = new GenericWebApplicationContext();
	context.refresh();
	resolver = new ExpressionValueMethodArgumentResolver(context.getBeanFactory());

	Method method = getClass().getMethod("params", int.class, String.class, String.class);
	paramSystemProperty = new MethodParameter(method, 0);
	paramContextPath = new MethodParameter(method, 1);
	paramNotSupported = new MethodParameter(method, 2);

	webRequest = new ServletWebRequest(new MockHttpServletRequest(), new MockHttpServletResponse());

	// Expose request to the current thread (for SpEL expressions)
	RequestContextHolder.setRequestAttributes(webRequest);
}
 
Example 6
Source File: RequestHeaderMethodArgumentResolverTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings("resource")
public void setUp() throws Exception {
	GenericWebApplicationContext context = new GenericWebApplicationContext();
	context.refresh();
	resolver = new RequestHeaderMethodArgumentResolver(context.getBeanFactory());

	Method method = getClass().getMethod("params", String.class, String[].class, String.class, String.class, Map.class);
	paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 0);
	paramNamedValueStringArray = new SynthesizingMethodParameter(method, 1);
	paramSystemProperty = new SynthesizingMethodParameter(method, 2);
	paramContextPath = new SynthesizingMethodParameter(method, 3);
	paramNamedValueMap = new SynthesizingMethodParameter(method, 4);

	servletRequest = new MockHttpServletRequest();
	webRequest = new ServletWebRequest(servletRequest, new MockHttpServletResponse());

	// Expose request to the current thread (for SpEL expressions)
	RequestContextHolder.setRequestAttributes(webRequest);
}