Hi
I have implemented the jersey fix for missing brackets in JSON arrays
(
http://blogs.sun.com/japod/entry/missing_brackets_at_json_one) to
great satisfaction for the people hacking on our AJAX rest front end.
However my tests which uses the jersey client are now failing, i.e.
the code:
--
assertThat(Status.fromStatusCode(cr.getStatus()), equalTo(Status.OK));
CountryBeanList list = cr.getEntity(CountryBeanList.class);
--
results in:
--
java.lang.ClassCastException: com.example.CountryBean cannot be cast
to com.example.CountryBeanList
at com.example.test.ResourceTest.countryListTest(ResourceTest.java:47)
--
the JSON code produced when it fails looks like this:
--
{"country":[{"name":"Denmark","countryCode":"DK"},{"name":"Finland","countryCode":"FI"}]}
--
however when leaving out the modified @Provider it looks like this
--
{"countries":{"country":[{"name":"Denmark","countryCode":"DK"},{"name":"Finland","countryCode":"FI"}]}}
--
This code can be correctly converted/tested (note the root "countries"
type). Could it be that since both CountryBean and CountryBeanList are
root elements (@XmlRootElement), the JSON provider no longer works
(when modified to handle brackets correctly) ?. Any
ideas/comments/solutions to this annoyance are most welcome.
--
Yours sincerely
Lars Tackmann