[
https://issues.apache.org/jira/browse/CXF-3483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13028188#comment-13028188
]
Pat Turner commented on CXF-3483:
---------------------------------
Hi Sergey,
I've got a Test that replicates the problem for JSONProvider and
JAXBElementProvider. Both are based on your original tests:
---
org.apache.cxf.jaxrs.provider.JSONProviderTest:
@Test
public void testOutAttributesAsElementsForList() throws Exception {
//Provider
JSONProvider provider = new JSONProvider();
provider.setAttributesToElements(true);
//data setup
TagVO2 tag = new TagVO2("A", "B");
TagVO2Holder holder = new TagVO2Holder();
holder.setTag(tag);
List<TagVO2Holder> list = new
ArrayList<JAXBElementProviderTest.TagVO2Holder>();
list.add(holder);
//ParameterizedType required for Lists of Objects
ParameterizedType type = new ParameterizedType() {
public Type getRawType() {
return List.class;
}
public Type getOwnerType() {
return null;
}
public Type[] getActualTypeArguments() {
return new Type[] { TagVO2Holder.class };
}
};
ByteArrayOutputStream bos = new ByteArrayOutputStream();
provider.writeTo(list, ArrayList.class, type,
new Annotation[0], MediaType.TEXT_XML_TYPE, new
MetadataMap<String, Object>(), bos);
//Doesn't get here
System.out.println(bos.toString());
}
---
org.apache.cxf.jaxrs.provider.JAXBElementProviderTest:
@Test
public void testOutAttributesAsElementsForList() throws Exception {
//Provider
JAXBElementProvider provider = new JAXBElementProvider();
provider.setAttributesToElements(true);
//data setup
TagVO2 tag = new TagVO2("A", "B");
TagVO2Holder holder = new TagVO2Holder();
holder.setTag(tag);
List<TagVO2Holder> list = new
ArrayList<JAXBElementProviderTest.TagVO2Holder>();
list.add(holder);
//ParameterizedType required for Lists of Objects
ParameterizedType type = new ParameterizedType() {
public Type getRawType() {
return List.class;
}
public Type getOwnerType() {
return null;
}
public Type[] getActualTypeArguments() {
return new Type[] { TagVO2Holder.class };
}
};
ByteArrayOutputStream bos = new ByteArrayOutputStream();
provider.writeTo(list, ArrayList.class, type,
new Annotation[0], MediaType.TEXT_XML_TYPE, new
MetadataMap<String, Object>(), bos);
//No exceptions, but this is a root Element only
System.out.println(bos.toString());
}
> JSONProvider: Don't force attributes to have @ if users doesn't want them too
> -----------------------------------------------------------------------------
>
> Key: CXF-3483
> URL: https://issues.apache.org/jira/browse/CXF-3483
> Project: CXF
> Issue Type: Improvement
> Components: JAX-RS
> Affects Versions: 2.3.4
> Reporter: Pat Turner
>
> Jettison provides a configuration option to omit the '@' from attributes:
> org.codehaus.jettison.mapped.Configuration.setSupressAtAttributes(boolean)
> see Jettison Jira:
> http://jira.codehaus.org/browse/JETTISON-2
> org.apache.cxf.jaxrs.provider.JSONProvider should also expose this property.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira