@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({ WebDriver.class, MockMvcHtmlUnitDriverBuilder.class }) @ConditionalOnBean(MockMvc.class) public MockMvcHtmlUnitDriverBuilder mockMvcHtmlUnitDriverBuilder(MockMvc mockMvc) { return MockMvcHtmlUnitDriverBuilder.mockMvcSetup(mockMvc) .withDelegate(new LocalHostWebConnectionHtmlUnitDriver(this.environment, BrowserVersion.CHROME)); }
@WithSigningUser @Test public void methodSecurity() { WebDriver driver = MockMvcHtmlUnitDriverBuilder.webAppContextSetup(wac).build(); assertThatThrownBy(() -> { AdminLinkClaPage.to(driver); }).hasRootCauseExactlyInstanceOf(AccessDeniedException.class); }
@Before @Override public void setup() { super.setup(); webDriver = MockMvcHtmlUnitDriverBuilder .mockMvcSetup(mockMvc) .contextPath(contextPath) .build(); LoginPage loginPage = new LoginPage(webDriver, contextPath, port); loginPage.login(ADMIN_USER_NAME, ADMIN_PASSWORD); }
@Before public void setUp() throws Exception { driver = MockMvcHtmlUnitDriverBuilder .webAppContextSetup(context) .withDelegate(new WebConnectionHtmlUnitDriver(BrowserVersion.CHROME)) .contextPath("") .build(); }
@Bean @ConditionalOnMissingBean(WebDriver.class) @ConditionalOnBean(MockMvcHtmlUnitDriverBuilder.class) public HtmlUnitDriver htmlUnitDriver(MockMvcHtmlUnitDriverBuilder builder) { return builder.build(); }
@Before public void setup() { driver = MockMvcHtmlUnitDriverBuilder.webAppContextSetup(context).contextPath("/dddsample").build(); }
@Before public void setup() { this.driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(this.mockMvc).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(); }