Commit 2a4f1616 authored by Angelo Veltens's avatar Angelo Veltens

produce xml

parent d97ecfd3
......@@ -16,6 +16,7 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.10.0'
runtime("com.h2database:h2:1.4.199")
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
......
......@@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class GreetingsController {
@GetMapping
@GetMapping(produces = { "application/xml" })
Hello hello() {
return new Hello("Hello World");
}
......
package de.codecentric.ticketscanner;
import com.fasterxml.jackson.annotation.JsonRootName;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@Data
@JsonRootName("hello")
class Hello {
private final String greeting;
}
......@@ -26,6 +26,6 @@ public class GreetingsHttpIntegrationTest {
public void greetingShouldReturnDefaultMessage() throws Exception {
ResponseEntity response = this.restTemplate.getForEntity("http://localhost:" + port + "/", String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getBody()).isEqualTo("{\"greeting\":\"Hello World\"}");
assertThat(response.getBody()).isEqualTo("<hello><greeting>Hello World</greeting></hello>");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment