This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final String DB_DRIVER = "org.h2.Driver"; | |
private static final String DB_CONNECTION = "jdbc:h2:~/test"; | |
private static final String DB_USER = ""; | |
private static final String DB_PASSWORD = ""; | |
private static Connection getDBConnection() { | |
Connection dbConnection = null; | |
try { | |
Class.forName(DB_DRIVER); | |
} catch (ClassNotFoundException e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework</groupId> | |
<artifactId>spring-test</artifactId> | |
<version>${spring.version}</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration(locations = { | |
"file:src/integration-test/resources/META-INF/test-context.xml" | |
}) | |
@WebAppConfiguration | |
public class CustomerDetailsControllerIntegrationTest { | |
private MockMvc mockMvc; | |
@Autowired |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>io.rest-assured</groupId> | |
<artifactId>rest-assured</artifactId> | |
<version>3.1.0</version> | |
<scope>test</scope> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GetMapping("/{userId}") | |
public ResponseEntity<User> getUserDetails(@PathVariable("userId") Integer userId) { | |
return ResponseEntity.ok(userList.get(userId)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"userId": 1, | |
"firstName": "Joe", | |
"secondName": "Bloggs", | |
"email": "me@email.com", | |
"dob": "3880-09-28T23:00:00.000+0000", | |
"address": { | |
"firstLineAddress": "My First Line Address", | |
"secondLineAddress": "My Second Line Address", | |
"postCode": "MU3 28P", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testGetUserDetails() { | |
when(). | |
get("/user/{userId}", 1). | |
then(). | |
statusCode(200). | |
body("userId", equalTo(1), | |
"firstName", equalTo("Joe"), | |
"secondName", equalTo("Bloggs"), | |
"email", equalTo("me@email.com"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Cucumber-JVM --> | |
<dependency> | |
<groupId>info.cukes</groupId> | |
<artifactId>cucumber-java</artifactId> | |
<version>1.2.3</version> | |
</dependency> | |
<dependency> | |
<groupId>info.cukes</groupId> | |
<artifactId>cucumber-junit</artifactId> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>info.cukes</groupId> | |
<artifactId>cucumber-java8</artifactId> | |
<version>1.2.3</version> | |
<scope>test</scope> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ItemsListEnd2EndTest { | |
private ItemController itemController = new ItemController(); | |
private String viewName; | |
@Given("^i am on the customers list page$") | |
public void i_am_on_the_customers_list_page() throws Throwable { | |
// steps to set up or verify you're on the customers list page | |
} |