Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix XML content handling in Spring Web Controller #5949

Merged
merged 1 commit into from Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -287,6 +287,10 @@ public void registerProviders(BeanArchiveIndexBuildItem beanArchiveIndexBuildIte
useAllAvailable = true;
break OUTER;
}
if (collectProviders(providersToRegister, categorizedContextResolvers, instance, "produces")) {
useAllAvailable = true;
break OUTER;
}

if (collectProviders(providersToRegister, categorizedReaders, instance, "consumes")) {
useAllAvailable = true;
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/spring-web/pom.xml
Expand Up @@ -23,6 +23,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-undertow</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jaxb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-di</artifactId>
Expand Down
@@ -0,0 +1,24 @@
package io.quarkus.it.spring.web;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Book {

private String name;

public Book() {
}

public Book(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,14 @@
package io.quarkus.it.spring.web;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BookController {

@GetMapping(produces = MediaType.APPLICATION_XML_VALUE, path = "/book")
public Book someBook() {
return new Book("Guns germs and steel");
}
}
Expand Up @@ -204,4 +204,13 @@ public void testResponseEntityWithIllegalArgumentException() {
.body(containsString("hello from error"))
.statusCode(402);
}

@Test
public void testMethodReturningXmlContent() {
RestAssured.when().get("/book")
.then()
.statusCode(200)
.contentType("application/xml")
.body(containsString("steel"));
}
}