Skip to content

Instantly share code, notes, and snippets.

View brunokrebs's full-sized avatar

Bruno brunokrebs

  • Brazil
View GitHub Profile
<dependencies>
<!-- after spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<id>integration-test</id>
<goals><goal>integration-test</goal></goals>
<build>
<plugins>
<!-- maven-failsafe-plugin plugin definition goes here -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-integration-test</id>
package br.com.brunokrebs;
import org.junit.Test;
import static com.jayway.restassured.RestAssured.*;
import static com.jayway.restassured.matcher.RestAssuredMatchers.*;
import static org.hamcrest.Matchers.*;
public class EchoIT {
package br.com.brunokrebs;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
package br.com.brunokrebs;
import br.com.brunokrebs.model.User;
import com.jayway.restassured.http.ContentType;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.springframework.http.HttpStatus;
import static com.jayway.restassured.RestAssured.given;
package br.com.brunokrebs.model;
public class User {
private String name;
private String email;
private String password;
public User() { }
public User(String name, String email, String password) {
package br.com.brunokrebs.rest;
import br.com.brunokrebs.model.User;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class UserRest {
package br.com.brunokrebs;
// ... previously added imports...
import static com.jayway.restassured.RestAssured.when;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
// we need the above annotation to make test1CreateUser run before test2ListUsers
public class UserRestIT {
// ... previously defined constant and test ...
@Test
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- ... other project's definition ... -->
<dependencies>
<!-- ... spring-boot-starter-web and spring-boot-starter-actuator deps ... -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>