use of com.thoughtworks.xstream.io.naming.NoNameCoder in project camel by apache.
the class DefaultCompositeApiClient method configureXStream.
static XStream configureXStream() {
final PureJavaReflectionProvider reflectionProvider = new PureJavaReflectionProvider(new FieldDictionary(new AnnotationFieldKeySorter()));
final XppDriver hierarchicalStreamDriver = new XppDriver(new NoNameCoder()) {
@Override
public HierarchicalStreamWriter createWriter(final Writer out) {
return new CompactWriter(out, getNameCoder());
}
};
final XStream xStream = new XStream(reflectionProvider, hierarchicalStreamDriver);
xStream.aliasSystemAttribute(null, "class");
xStream.ignoreUnknownElements();
XStreamUtils.addDefaultPermissions(xStream);
xStream.registerConverter(new DateTimeConverter());
xStream.setMarshallingStrategy(new TreeMarshallingStrategy());
xStream.processAnnotations(ADDITIONAL_TYPES);
return xStream;
}
use of com.thoughtworks.xstream.io.naming.NoNameCoder in project camel by apache.
the class ApprovalRequestsTest method shouldSerializeAsXml.
@Test
public void shouldSerializeAsXml() {
final String xml = //
"<ProcessApprovalRequest>" + //
"<requests>" + //
"<actionType>Submit</actionType>" + //
"<contextActorId>005D00000015rZy</contextActorId>" + //
"<contextId>001D000000I8mIm</contextId>" + //
"<comments>this is a test 1</comments>" + //
"<nextApproverIds>005D00000015rY9</nextApproverIds>" + //
"<processDefinitionNameOrId>PTO_Request_Process</processDefinitionNameOrId>" + //
"<skipEntryCriteria>true</skipEntryCriteria>" + //
"</requests>" + //
"<requests>" + //
"<actionType>Submit</actionType>" + //
"<contextActorId>005D00000015rZy</contextActorId>" + //
"<contextId>001D000000I8dIm</contextId>" + //
"<comments>this is a test 2</comments>" + //
"<nextApproverIds>005D00000015xY9</nextApproverIds>" + //
"<processDefinitionNameOrId>PTO_Request_Process</processDefinitionNameOrId>" + //
"<skipEntryCriteria>true</skipEntryCriteria>" + //
"</requests>" + "</ProcessApprovalRequest>";
final XStream xStream = new XStream(new XppDriver(new NoNameCoder()) {
@Override
public HierarchicalStreamWriter createWriter(final Writer out) {
return new CompactWriter(out, getNameCoder());
}
});
xStream.ignoreUnknownElements();
XStreamUtils.addDefaultPermissions(xStream);
xStream.registerConverter(new DateTimeConverter());
xStream.processAnnotations(ApprovalRequests.class);
final String serialized = xStream.toXML(requests);
assertEquals("Approval requests should serialize as XML", xml, serialized);
}
use of com.thoughtworks.xstream.io.naming.NoNameCoder in project ddf by codice.
the class TestGetRecordsResponseConverter method testMarshalRecordCollectionFullXml.
@Ignore
public void testMarshalRecordCollectionFullXml() throws UnsupportedEncodingException, JAXBException {
final int totalResults = 5;
TransformerManager mockMetacardManager = mock(TransformerManager.class);
when(mockMetacardManager.getTransformerBySchema(anyString())).thenReturn(new CswRecordConverter(TestCswRecordConverter.getCswMetacardType()));
GetRecordsResponseConverter rrConverter = new GetRecordsResponseConverter(new CswTransformProvider(mockMetacardManager, null));
XStream xstream = new XStream(new StaxDriver(new NoNameCoder()));
xstream.registerConverter(rrConverter);
xstream.alias(CswConstants.CSW_NAMESPACE_PREFIX + CswConstants.NAMESPACE_DELIMITER + CswConstants.GET_RECORDS_RESPONSE, CswRecordCollection.class);
GetRecordsType getRecords = new GetRecordsType();
QueryType query = new QueryType();
ElementSetNameType set = new ElementSetNameType();
set.setValue(ElementSetType.FULL);
query.setElementSetName(set);
ObjectFactory objectFactory = new ObjectFactory();
getRecords.setAbstractQuery(objectFactory.createAbstractQuery(query));
CswRecordCollection collection = createCswRecordCollection(getRecords, totalResults);
collection.setElementSetType(ElementSetType.FULL);
String xml = xstream.toXML(collection);
JAXBElement<GetRecordsResponseType> jaxb = (JAXBElement<GetRecordsResponseType>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
GetRecordsResponseType response = jaxb.getValue();
// Assert the GetRecordsResponse elements and attributes
assertThat(response, not(nullValue()));
SearchResultsType resultsType = response.getSearchResults();
assertThat(resultsType, not(nullValue()));
assertThat(resultsType.getElementSet(), is(ElementSetType.FULL));
assertThat(resultsType.getNumberOfRecordsMatched().intValue(), is(totalResults));
assertThat(resultsType.getNumberOfRecordsReturned().intValue(), is(totalResults));
assertThat(resultsType.getRecordSchema(), is(CswConstants.CSW_OUTPUT_SCHEMA));
}
use of com.thoughtworks.xstream.io.naming.NoNameCoder in project openolat by klemens.
the class InstitutionConfiguration method getInstitutionConfigXStream.
public static XStream getInstitutionConfigXStream() {
XStream xstream = new XStream(new XppDriver(new NoNameCoder()));
xstream.alias("configuration", InstitutionConfiguration.class);
xstream.addImplicitCollection(InstitutionConfiguration.class, "institution", "institution", InstitutionPortletEntry.class);
xstream.alias("institution", InstitutionPortletEntry.class);
xstream.addImplicitCollection(InstitutionPortletEntry.class, "polymorphlink", "polymorphlink", PolymorphLink.class);
xstream.aliasAttribute(InstitutionPortletEntry.class, "shortname", "shortname");
xstream.alias("logo", Value.class);
xstream.alias("name", Value.class);
xstream.alias("url", Value.class);
xstream.alias("supervisor", InstitutionPortletSupervisorEntry.class);
xstream.addImplicitCollection(InstitutionPortletEntry.class, "supervisor", "supervisor", InstitutionPortletSupervisorEntry.class);
xstream.alias("person", Value.class);
xstream.alias("phone", Value.class);
xstream.alias("email", Value.class);
xstream.alias("blog", Value.class);
// polymorph link
xstream.alias("polymorphlink", PolymorphLink.class);
xstream.aliasAttribute(PolymorphLink.class, "defaultId", "default_targetid");
xstream.aliasAttribute(PolymorphLink.class, "linkType", "type");
xstream.aliasAttribute(PolymorphLink.class, "linkText", "text");
// polymorph link element
xstream.alias("element", PolymorphLinkElement.class);
xstream.addImplicitCollection(PolymorphLink.class, "element", "element", PolymorphLinkElement.class);
xstream.aliasAttribute(PolymorphLinkElement.class, "attribute", "attribute");
xstream.aliasAttribute(PolymorphLinkElement.class, "value", "value");
xstream.aliasAttribute(PolymorphLinkElement.class, "cond", "condition");
xstream.aliasAttribute(PolymorphLinkElement.class, "id", "targetid");
xstream.aliasAttribute(Value.class, "value", "value");
return xstream;
}
use of com.thoughtworks.xstream.io.naming.NoNameCoder in project OpenOLAT by OpenOLAT.
the class InstitutionConfiguration method getInstitutionConfigXStream.
public static XStream getInstitutionConfigXStream() {
XStream xstream = new XStream(new XppDriver(new NoNameCoder()));
xstream.alias("configuration", InstitutionConfiguration.class);
xstream.addImplicitCollection(InstitutionConfiguration.class, "institution", "institution", InstitutionPortletEntry.class);
xstream.alias("institution", InstitutionPortletEntry.class);
xstream.addImplicitCollection(InstitutionPortletEntry.class, "polymorphlink", "polymorphlink", PolymorphLink.class);
xstream.aliasAttribute(InstitutionPortletEntry.class, "shortname", "shortname");
xstream.alias("logo", Value.class);
xstream.alias("name", Value.class);
xstream.alias("url", Value.class);
xstream.alias("supervisor", InstitutionPortletSupervisorEntry.class);
xstream.addImplicitCollection(InstitutionPortletEntry.class, "supervisor", "supervisor", InstitutionPortletSupervisorEntry.class);
xstream.alias("person", Value.class);
xstream.alias("phone", Value.class);
xstream.alias("email", Value.class);
xstream.alias("blog", Value.class);
// polymorph link
xstream.alias("polymorphlink", PolymorphLink.class);
xstream.aliasAttribute(PolymorphLink.class, "defaultId", "default_targetid");
xstream.aliasAttribute(PolymorphLink.class, "linkType", "type");
xstream.aliasAttribute(PolymorphLink.class, "linkText", "text");
// polymorph link element
xstream.alias("element", PolymorphLinkElement.class);
xstream.addImplicitCollection(PolymorphLink.class, "element", "element", PolymorphLinkElement.class);
xstream.aliasAttribute(PolymorphLinkElement.class, "attribute", "attribute");
xstream.aliasAttribute(PolymorphLinkElement.class, "value", "value");
xstream.aliasAttribute(PolymorphLinkElement.class, "cond", "condition");
xstream.aliasAttribute(PolymorphLinkElement.class, "id", "targetid");
xstream.aliasAttribute(Value.class, "value", "value");
return xstream;
}
Aggregations