Spock (#5952)
* 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:
@@ -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);
|
||||
}
|
||||
}
|
||||
+36
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user