org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder Java Examples

The following examples show how to use org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder. 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: CalendarApplicationTests.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Before
    public void setup() {
        webClient = MockMvcWebClientBuilder
                // demonstrates applying a MockMvcConfigurer (Spring Security)
//                .webAppContextSetup(context, springSecurity())
                .webAppContextSetup(context)
                // for illustration only - defaults to ""
                .contextPath("")
                // By default MockMvc is used for localhost only;
                // the following will use MockMvc for example.com and example.org as well
                .useMockMvcForHosts("example.com","example.org")
                .build();

        driver = MockMvcHtmlUnitDriverBuilder
                .webAppContextSetup(context)
                .build();

        /*MockMvc mockMvc = MockMvcBuilders
                .webAppContextSetup(context)
//                .apply(springSecurity())
                .build();

        webClient = MockMvcWebClientBuilder
                .mockMvcSetup(mockMvc)
                // for illustration only - defaults to ""
                .contextPath("")
                // By default MockMvc is used for localhost only;
                // the following will use MockMvc for example.com and example.org as well
                .useMockMvcForHosts("example.com","example.org")
                .build();*/
    }
 
Example #2
Source File: MockMvcWebClientCreateTaskTests.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	webClient = MockMvcWebClientBuilder
			.webAppContextSetup(context)
			.withDelegate(new WebClient(BrowserVersion.CHROME))
			//.webAppContextSetup(context, springSecurity())
			// for illustration only - defaults to ""
			.contextPath("")
			//.useMockMvcForHosts("example.com","example.org")
			.build();
}
 
Example #3
Source File: HtmlUnitAndSpringLiveTest.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void setup() {
    webClient = MockMvcWebClientBuilder.webAppContextSetup(wac).build();
}