use of com.thoughtworks.xstream.core.TreeMarshaller in project ddf by codice.
the class TestCswRecordConverter method testMarshalRecord.
@Test
public void testMarshalRecord() throws IOException, JAXBException, SAXException, XpathException {
Metacard metacard = getTestMetacard();
StringWriter stringWriter = new StringWriter();
PrettyPrintWriter writer = new PrettyPrintWriter(stringWriter);
MarshallingContext context = new TreeMarshaller(writer, null, null);
converter.marshal(metacard, writer, context);
String xml = stringWriter.toString();
assertThat(xml, containsString(CswConstants.CSW_RECORD));
assertRecordXml(xml, metacard, FULL);
}
use of com.thoughtworks.xstream.core.TreeMarshaller in project ddf by codice.
the class TestCswRecordConverter method testMarshalSummaryRecord.
@Test
public void testMarshalSummaryRecord() throws IOException, JAXBException, SAXException, XpathException {
Metacard metacard = getTestMetacard();
StringWriter stringWriter = new StringWriter();
PrettyPrintWriter writer = new PrettyPrintWriter(stringWriter);
MarshallingContext context = new TreeMarshaller(writer, null, null);
context.put(CswConstants.ELEMENT_SET_TYPE, ElementSetType.SUMMARY);
converter.marshal(metacard, writer, context);
String xml = stringWriter.toString();
assertThat(xml, containsString(CswConstants.CSW_SUMMARY_RECORD));
assertRecordXml(xml, metacard, SUMMARY);
}
use of com.thoughtworks.xstream.core.TreeMarshaller in project ddf by codice.
the class TestGmdConverter method convert.
private String convert(Object object, boolean writeNamespaces) {
GmdConverter converter = new GmdConverter();
StringWriter stringWriter = new StringWriter();
PrettyPrintWriter writer = new PrettyPrintWriter(stringWriter, new NoNameCoder());
MarshallingContext context = new TreeMarshaller(writer, null, null);
context.put(CswConstants.WRITE_NAMESPACES, writeNamespaces);
converter.marshal(object, writer, context);
return stringWriter.toString();
}
use of com.thoughtworks.xstream.core.TreeMarshaller in project ddf by codice.
the class TestCswTransformProvider method testMarshalCswRecord.
@Test
public void testMarshalCswRecord() throws Exception {
when(mockMetacardManager.getTransformerBySchema(CswConstants.CSW_OUTPUT_SCHEMA)).thenReturn(mockCswRecordConverter);
when(mockCswRecordConverter.transform(any(Metacard.class), any(Map.class))).thenReturn(new BinaryContentImpl(IOUtils.toInputStream(getRecord()), new MimeType(MediaType.APPLICATION_XML)));
StringWriter stringWriter = new StringWriter();
HierarchicalStreamWriter writer = new WstxDriver().createWriter(stringWriter);
CswTransformProvider provider = new CswTransformProvider(mockMetacardManager, null);
MarshallingContext context = new TreeMarshaller(writer, null, null);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
provider.marshal(getMetacard(), writer, context);
// Verify the context arguments were set correctly
verify(mockMetacardManager, times(1)).getTransformerBySchema(captor.capture());
String outputSchema = captor.getValue();
assertThat(outputSchema, is(CswConstants.CSW_OUTPUT_SCHEMA));
}
use of com.thoughtworks.xstream.core.TreeMarshaller in project ddf by codice.
the class CswRecordConverterTest method testMarshalRecord.
@Test
public void testMarshalRecord() throws IOException, JAXBException, SAXException, XpathException {
Metacard metacard = getTestMetacard();
StringWriter stringWriter = new StringWriter();
PrettyPrintWriter writer = new PrettyPrintWriter(stringWriter);
MarshallingContext context = new TreeMarshaller(writer, null, null);
converter.marshal(metacard, writer, context);
String xml = stringWriter.toString();
assertThat(xml, containsString(CswConstants.CSW_RECORD));
assertRecordXml(xml, metacard, FULL);
}
Aggregations