Add tests for json-customize example#535
Conversation
Jackson, Flexjson으로 사용자 지정 JSON Writer를 사용한 부분은 7.2.1로 버전 업그레이드를 할 때, 기본으로 제공되는 StrutsJSONWriter 만 사용할 수 있어서, 아직은 7.1.1로 버전을 고정해두었다. 이 문제 현상에 대해서는 struts-example의 json-customize 예제에 테스트 코드를 추가해서 보고했다. * apache/struts-examples#535
|
@fp024 you must rebase onto main branch |
|
@lukaszlenart |
- fix flexjson serialization to fully exclude null fields - replace JSON verification with "json-unit-assertj"
|
When flexjson excludes fields with null values, it leaves trailing keys behind, which results in an invalid JSON string. I have pushed an additional commit to resolve this issue. |
|
Test |
|
I added and shared this test case specifically because it fails on Struts 7.2.1 while passing completely on Struts 7.1.1. On Struts 7.2.1, the following configuration does not take effect, and the system is seemingly forced to use only the default <bean type="org.apache.struts2.json.JSONWriter" name="flexJSONWriter" class="org.demo.FlexJSONWriter"
scope="prototype"/>
<constant name="struts.json.writer" value="flexJSONWriter"/> |
|
Thanks for that, I will double check what's wrong |
|
Nice, this is regression in Struts 7.2.1, I will prepare a fix. |
|
Ticket ready, on it |
|
Thank you very much for checking. Have a nice day! 👍 |
Summary
Adds JUnit tests for the
json-customizeexample.Motivation
This PR adds a reproducible JUnit test case to the
struts-examplesrepository to make it easier to verify the behavior of the custom JSON writer configuration.With Struts 7.1.1, the custom JSON writer configured by the
json-customizeexample is used as expected. However, after changing only the Struts version to 7.2.1, the configured custom JSON writer no longer appears to be selected, andorg.apache.struts2.json.StrutsJSONWriteris used instead.The behavior can be reproduced or verified by changing only the Struts version to 7.2.1 and running the added tests.
Since the Struts main repository does not have the Issues tab enabled, I am submitting this to
struts-examplesas a reproducible test case.Notes
The tests use "json-unit-assertj" to validate the serialized JSON output. The
lastLoginfield is validated by date format instead of comparing against a fixed value.Thanks 👍