79056e78dd1dc29631f8e14e55e442f3eb0c2d14
[demos/spring-boot] / src / test / java / de / juplo / demo / DemoControllerIT.java
1 package de.juplo.demo;
2
3
4 import lombok.extern.slf4j.Slf4j;
5 import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
6 import org.junit.jupiter.api.BeforeEach;
7 import org.junit.jupiter.api.Test;
8 import org.junit.jupiter.api.extension.ExtendWith;
9 import org.openqa.selenium.By;
10 import org.openqa.selenium.WebElement;
11 import org.openqa.selenium.remote.RemoteWebDriver;
12 import org.springframework.boot.test.context.SpringBootTest;
13 import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
14 import org.springframework.boot.web.server.LocalServerPort;
15
16
17 /**
18  * Integration-Test for the {@link DemoController}.
19  * @author Kai Moritz
20  */
21 @SpringBootTest(webEnvironment = RANDOM_PORT)
22 @ExtendWith(WebDriverExtension.class)
23 @Slf4j
24 public class DemoControllerIT
25 {
26   @LocalServerPort
27   int port;
28   String baseUri;
29
30
31   @BeforeEach()
32   void generateBaseUri()
33   {
34     baseUri = "http://localhost:" + port;
35   }
36
37
38   @Test
39   void testSubmit(RemoteWebDriver driver)
40   {
41     driver.get(baseUri + "/");
42
43     WebElement submit = driver.findElement(By.xpath("//div[@class='card-footer']/button"));
44     assertThat(submit).isNotNull();
45   }
46 }