Example usage for org.springframework.boot.test.context.assertj AssertableWebApplicationContext getBean

List of usage examples for org.springframework.boot.test.context.assertj AssertableWebApplicationContext getBean

Introduction

In this page you can find the example usage for org.springframework.boot.test.context.assertj AssertableWebApplicationContext getBean.

Prototype

Object getBean(String name) throws BeansException;

Source Link

Document

Return an instance, which may be shared or independent, of the specified bean.

Usage

From source file:org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfigurationTests.java

private int getResponseStatus(AssertableWebApplicationContext context, String path)
        throws IOException, javax.servlet.ServletException {
    FilterChainProxy filterChainProxy = context.getBean(FilterChainProxy.class);
    MockServletContext servletContext = new MockServletContext();
    MockHttpServletResponse response = new MockHttpServletResponse();
    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
    MockHttpServletRequest request = new MockHttpServletRequest(servletContext);
    request.setServletPath(path);//  w  w  w. j av a 2 s.c  om
    request.setMethod("GET");
    filterChainProxy.doFilter(request, response, new MockFilterChain());
    return response.getStatus();
}