Search in sources :

Example 16 with MarshallingContext

use of com.thoughtworks.xstream.converters.MarshallingContext in project ddf by codice.

the class TestCswRecordConverter method testMarshalRecordWithNamespaces.

@Test
public void testMarshalRecordWithNamespaces() 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.WRITE_NAMESPACES, true);
    converter.marshal(metacard, writer, context);
    String xml = stringWriter.toString();
    XMLUnit.setIgnoreWhitespace(true);
    assertXMLEqual(getControlRecord(), xml);
}
Also used : TreeMarshaller(com.thoughtworks.xstream.core.TreeMarshaller) Metacard(ddf.catalog.data.Metacard) StringWriter(java.io.StringWriter) PrettyPrintWriter(com.thoughtworks.xstream.io.xml.PrettyPrintWriter) MarshallingContext(com.thoughtworks.xstream.converters.MarshallingContext) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 17 with MarshallingContext

use of com.thoughtworks.xstream.converters.MarshallingContext 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);
}
Also used : TreeMarshaller(com.thoughtworks.xstream.core.TreeMarshaller) Metacard(ddf.catalog.data.Metacard) StringWriter(java.io.StringWriter) PrettyPrintWriter(com.thoughtworks.xstream.io.xml.PrettyPrintWriter) MarshallingContext(com.thoughtworks.xstream.converters.MarshallingContext) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 18 with MarshallingContext

use of com.thoughtworks.xstream.converters.MarshallingContext 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);
}
Also used : TreeMarshaller(com.thoughtworks.xstream.core.TreeMarshaller) Metacard(ddf.catalog.data.Metacard) StringWriter(java.io.StringWriter) PrettyPrintWriter(com.thoughtworks.xstream.io.xml.PrettyPrintWriter) MarshallingContext(com.thoughtworks.xstream.converters.MarshallingContext) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

MarshallingContext (com.thoughtworks.xstream.converters.MarshallingContext)18 HierarchicalStreamWriter (com.thoughtworks.xstream.io.HierarchicalStreamWriter)11 TreeMarshaller (com.thoughtworks.xstream.core.TreeMarshaller)10 StringWriter (java.io.StringWriter)10 Test (org.junit.Test)9 PrettyPrintWriter (com.thoughtworks.xstream.io.xml.PrettyPrintWriter)7 ByteArrayInputStream (java.io.ByteArrayInputStream)7 Matchers.anyString (org.mockito.Matchers.anyString)7 XStream (com.thoughtworks.xstream.XStream)6 Metacard (ddf.catalog.data.Metacard)6 JAXBElement (javax.xml.bind.JAXBElement)5 Ignore (jdk.nashorn.internal.ir.annotations.Ignore)5 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)5 BinaryContentImpl (ddf.catalog.data.impl.BinaryContentImpl)4 GetRecordsResponseType (net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType)4 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)4 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)4 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)4 SearchResultsType (net.opengis.cat.csw.v_2_0_2.SearchResultsType)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4