@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();*/ }
@Bean @ConditionalOnMissingBean({ WebClient.class, MockMvcWebClientBuilder.class }) @ConditionalOnBean(MockMvc.class) public MockMvcWebClientBuilder mockMvcWebClientBuilder(MockMvc mockMvc) { return MockMvcWebClientBuilder.mockMvcSetup(mockMvc) .withDelegate(new LocalHostWebClient(this.environment)); }
@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(); }
@Bean @ConditionalOnMissingBean @ConditionalOnBean(MockMvcWebClientBuilder.class) public WebClient htmlUnitWebClient(MockMvcWebClientBuilder builder) { return builder.build(); }
@Before public void setup() { webClient = MockMvcWebClientBuilder .webAppContextSetup(context) .build(); }
/** * Sets up the HTMLUnit Web Client. * * @throws Exception * in case of error during setup. */ @Before public void setupWebClient() throws Exception { webClient = MockMvcWebClientBuilder.webAppContextSetup(wac).build(); webDriver = MockMvcHtmlUnitDriverBuilder.webAppContextSetup(wac).build(); }