You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
Given an openapi endpoint
And that endpoint can respond in application/json
And that endpoint can respond in application/xml
When a request with accept: application/xml is executed
And a valid XML is returned
Then the content-type of the response should be valid
And test should pass green
Actual behavior
The test always fails with Values not equal for header element 'Content-Type', expected 'application/json' but was 'application/xml'
Test case sample
@TestpublicclassOpenApiClientITextendsTestNGCitrusSpringSupport {
privatefinalintport = SocketUtils.findAvailableTcpPort(8080);
@BindToRegistryprivatefinalHttpServerhttpServer = newHttpServerBuilder()
.port(port)
.timeout(5000L)
.autoStart(true)
.defaultStatus(HttpStatus.NO_CONTENT)
.build();
@BindToRegistryprivatefinalHttpClienthttpClient = newHttpClientBuilder()
.requestUrl("http://localhost:%d".formatted(port))
.build();
privatefinalOpenApiSpecificationpetstoreSpec = OpenApiSpecification.from(
Resources.create("classpath:org/citrusframework/openapi/petstore/petstore-v3.json"));
@CitrusTestpublicvoidBUG_should_be_possible_to_switch_content_type__to_xml() {
variable("petId", "1001");
when(openapi(petstoreSpec)
.client(httpClient)
.send("getPetById")
.message()
.accept("application/xml")
.fork(true));
then(http().server(httpServer)
.receive()
.get("/pet/${petId}")
.message()
.accept("@contains('application/xml')@"));
then(http().server(httpServer)
.send()
.response(HttpStatus.OK)
.message()
.body("<pet></pet>")
.contentType("application/xml"));
then(openapi(petstoreSpec)
.client(httpClient)
.receive("getPetById", HttpStatus.OK)
.message()
// TODO BUG XML bodies do not seem to work, even if there is just XML as "produces" in the spec
.body("<pet></pet>")
// TODO BUG the type/contentType statements are useless, if there is another type in the spec.// even if there are two. i.E:// # this will always use JSON as type// produces:// - application/json// - application/xml
.contentType("application/xml")
.type(XML));
}
}
The text was updated successfully, but these errors were encountered:
novarx
pushed a commit
to postfinance/citrus
that referenced
this issue
Jul 17, 2024
cleanup
remove bug related todos
created issues for that:
- citrusframework#1190
- citrusframework#1189
update TODOs
refactor
disable deprecated tests
feature: put new openapi actions to mustache (WIP)
feature: improve receive action
feature: cleanup OpenApiClientRequestActionBuilder
feature: send typed fluent openapi builder works
feature: first fluent java implementation (wip)
chore: add todo-readme
chore: improve OpenApi example
chore: cleanup generator tests
chore: add license to new files
chore: remove author annotations
feat(citrusframework#1156): provide test api generator
Citrus Version
4.2.1
Expected behavior
Given an openapi endpoint
And that endpoint can respond in
application/json
And that endpoint can respond in
application/xml
When a request with
accept: application/xml
is executedAnd a valid XML is returned
Then the content-type of the response should be valid
And test should pass green
Actual behavior
The test always fails with
Values not equal for header element 'Content-Type', expected 'application/json' but was 'application/xml'
Test case sample
The text was updated successfully, but these errors were encountered: