* BAEL-2364: Adds Spring Boot IntegrationTests with Spock Framework

* Adds o.b.boot.controller.rest.WebController as example controller
* Adds one Load Application Context Test
* Adds one WebMvcTest

* updated pom.xml's and README

* fixed module name
This commit is contained in:
Tom Hombergs
2018-12-20 21:54:20 +01:00
committed by Eugen
parent cd873618a6
commit 87b23b4d44
12 changed files with 651 additions and 0 deletions
@@ -0,0 +1,14 @@
package org.baeldung.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
@SpringBootApplication
public class Application {
private static ApplicationContext applicationContext;
public static void main(String[] args) {
applicationContext = SpringApplication.run(Application.class, args);
}
}
@@ -0,0 +1,36 @@
package org.baeldung.boot.controller.rest;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import java.util.Optional;
@RestController
@RequestMapping("/hello")
public class WebController {
private String name;
@GetMapping
public String salutation() {
return "Hello " + Optional.ofNullable(name).orElse("world") + '!';
}
@PutMapping
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setName(@RequestBody final String name) {
this.name = name;
}
@DeleteMapping
@ResponseStatus(HttpStatus.NO_CONTENT)
public void resetToDefault() {
this.name = null;
}
}