jakartaee/rest

TCK Challenge: ee.jakarta.tck.ws.rs.ee.rs.container.requestcontext.JAXRSClientIT.containsHeaderStringTest uses header "Header3" causing getHeadersTest to incorrectly fail in some implementation.

Closed this issue · 0 comments

The new ee.jakarta.tck.ws.rs.ee.rs.container.requestcontext.JAXRSClientIT.containsHeaderStringTest added in Jakarta Rest 4.0 uses a capitalized "Header3" header. The existing getHeadersTest will then fail in some implementations as it uses a lowercase "header3". For example, in Liberty header names are cached, this results in the capitalized "Header3" being re-used, causing getHeadersTest to fail.

08-22-2024 14:41:52:STARTING TEST : getHeadersTest()
08-22-2024 14:41:52:[Request] Dispatching request: 'GET http://localhost:8010/jaxrs_ee_rs_container_requestcontext_web/resource/getheaders' to target server at 'localhost:8010'
08-22-2024 14:41:52:###############################
08-22-2024 14:41:52:  TRACE: [WIRE] - >> GET http://localhost:8010/jaxrs_ee_rs_container_requestcontext_web/resource/getheaders
08-22-2024 14:41:52:  TRACE: [WIRE] - >> Accept:*/*, header1:header1, header2:header2, header3:header3, header4:header4, OPERATION:GETHEADERS
08-22-2024 14:41:52:  TRACE: [WIRE] - << 200 OK
08-22-2024 14:41:52:  TRACE: [WIRE] - << Content-Language: en-US
08-22-2024 14:41:52:  TRACE: [WIRE] - << Content-Length: 199
08-22-2024 14:41:52:  TRACE: [WIRE] - << Content-Type: application/octet-stream
08-22-2024 14:41:52:  TRACE: [WIRE] - << Date: Thu, 22 Aug 2024 19:41:52 GMT
08-22-2024 14:41:52:  TRACE: [WIRE] - << Accept:*/*;Connection:Keep-Alive;header1:header1;header2:header2;Header3:header3;header4:header4;Host:localhost:8010;OPERATION:GETHEADERS;User-Agent:Apache-HttpClient/4.5.13 (Java/21.0.1);;GETHEADERS
08-22-2024 14:41:52:[WebValidatorBase] Unable to find the following search string in the server's response: 'header3:header3
[WebValidatorBase] Server's response:
-------------------------------------------
Accept:*/*;Connection:Keep-Alive;header1:header1;header2:header2;Header3:header3;header4:header4;Host:localhost:8010;OPERATION:GETHEADERS;User-Agent:Apache-HttpClient/4.5.13 (Java/21.0.1);;GETHEADERS
-------------------------------------------

08-22-2024 14:41:52:[JAXRSCommonClient] null failed!  Check output for cause of failure.
ee.jakarta.tck.ws.rs.common.webclient.TestFailureException: Test FAILED!
	at ee.jakarta.tck.ws.rs.common.client.JaxrsWebTestCase.execute(JaxrsWebTestCase.java:219)
	at ee.jakarta.tck.ws.rs.common.client.JaxrsCommonClient.invoke(JaxrsCommonClient.java:209)
	at ee.jakarta.tck.ws.rs.ee.rs.container.requestcontext.JAXRSClientIT.invokeRequestAndCheckResponse(JAXRSClientIT.java:888)
	at ee.jakarta.tck.ws.rs.ee.rs.container.requestcontext.JAXRSClientIT.invokeRequestAndCheckResponse(JAXRSClientIT.java:877)
	at ee.jakarta.tck.ws.rs.ee.rs.container.requestcontext.JAXRSClientIT.getHeadersTest(JAXRSClientIT.java:382)

Headers should be case insensitive: https://jakarta.ee/specifications/platform/9/apidocs/jakarta/servlet/http/httpservletrequest#getHeader-java.lang.String- so the implementation should ignore case, which it does. But these TCK tests compare the headers (and other things) as case sensitive, that causes the failure.

I think it would be more complicated and risky to change the tests to identify when they are comparing header names and compare ignoring case. Therefore I believe the best solution, at least for Jakarta 4.0 would be to change the containsHeaderStringTest to use "header3" instead of "Header3" for the name. Since case is not important to this test this seems to be the best and more expedient solution with the least risk.