Search in sources :

Example 11 with PrettyPrintWriter

use of com.thoughtworks.xstream.io.xml.PrettyPrintWriter 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 12 with PrettyPrintWriter

use of com.thoughtworks.xstream.io.xml.PrettyPrintWriter 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 13 with PrettyPrintWriter

use of com.thoughtworks.xstream.io.xml.PrettyPrintWriter 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

PrettyPrintWriter (com.thoughtworks.xstream.io.xml.PrettyPrintWriter)13 MarshallingContext (com.thoughtworks.xstream.converters.MarshallingContext)7 TreeMarshaller (com.thoughtworks.xstream.core.TreeMarshaller)7 StringWriter (java.io.StringWriter)7 Metacard (ddf.catalog.data.Metacard)4 IOException (java.io.IOException)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 Test (org.junit.Test)4 XStream (com.thoughtworks.xstream.XStream)3 Writer (java.io.Writer)3 NoNameCoder (com.thoughtworks.xstream.io.naming.NoNameCoder)2 BinaryContentImpl (ddf.catalog.data.impl.BinaryContentImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileWriter (java.io.FileWriter)2 ObjectOutputStream (java.io.ObjectOutputStream)2 PsiFragment (com.intellij.dupLocator.util.PsiFragment)1 XStreamException (com.thoughtworks.xstream.XStreamException)1 PureJavaReflectionProvider (com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider)1 QuickWriter (com.thoughtworks.xstream.core.util.QuickWriter)1 HierarchicalStreamWriter (com.thoughtworks.xstream.io.HierarchicalStreamWriter)1