use of com.thoughtworks.xstream.io.xml.StaxDriver in project jgnash by ccavanaugh.
the class XStreamFactory method getInstance.
static XStream getInstance() {
final XStream xstream = new XStream(new StaxDriver());
xstream.alias("Message", Message.class);
xstream.alias("MessageProperty", MessageProperty.class);
return xstream;
}
use of com.thoughtworks.xstream.io.xml.StaxDriver in project jgnash by ccavanaugh.
the class CheckLayoutSerializationFactory method getStream.
private static XStream getStream() {
XStream xstream = new XStream(new StaxDriver());
xstream.alias("CheckLayout", CheckLayout.class);
xstream.alias("CheckObject", CheckObject.class);
/* Fix for printing on some Windows Systems. Value and winID do not always serialize correctly
* and do not have any apparent impact on restoring printing preferences */
if (OS.isSystemWindows()) {
try {
Class<?> media = Class.forName("sun.print.Win32MediaTray");
xstream.omitField(media, "value");
xstream.omitField(media, "winID");
} catch (ClassNotFoundException e) {
logSevere(CheckLayoutSerializationFactory.class, e);
}
}
return xstream;
}
use of com.thoughtworks.xstream.io.xml.StaxDriver in project ddf by codice.
the class TestCswTransformProvider method testUnmarshalCopyPreservesNamespaces.
@Test
public void testUnmarshalCopyPreservesNamespaces() throws Exception {
InputTransformer mockInputTransformer = mock(InputTransformer.class);
when(mockInputManager.getTransformerBySchema(anyString())).thenReturn(mockInputTransformer);
StaxDriver driver = new StaxDriver();
driver.setRepairingNamespace(true);
driver.getQnameMap().setDefaultNamespace(CswConstants.CSW_OUTPUT_SCHEMA);
driver.getQnameMap().setDefaultPrefix(CswConstants.CSW_NAMESPACE_PREFIX);
// Have to use XppReader in order to preserve the namespaces.
HierarchicalStreamReader reader = new XppReader(new StringReader(getRecord()), XmlPullParserFactory.newInstance().newPullParser());
CswTransformProvider provider = new CswTransformProvider(null, mockInputManager);
UnmarshallingContext context = new TreeUnmarshaller(null, null, null, null);
context.put(CswConstants.OUTPUT_SCHEMA_PARAMETER, "http://example.com/schema");
ArgumentCaptor<InputStream> captor = ArgumentCaptor.forClass(InputStream.class);
provider.unmarshal(reader, context);
// Verify the context arguments were set correctly
verify(mockInputTransformer, times(1)).transform(captor.capture());
InputStream inStream = captor.getValue();
String result = IOUtils.toString(inStream);
XMLUnit.setIgnoreWhitespace(true);
XMLAssert.assertXMLEqual(getRecord(), result);
}
use of com.thoughtworks.xstream.io.xml.StaxDriver in project ddf by codice.
the class TestGetRecordsResponseConverter method createXStream.
private XStream createXStream(final String elementName) {
GetRecordsResponseConverter rrConverter = new GetRecordsResponseConverter(mockProvider);
XStream xstream = new XStream(new StaxDriver(new NoNameCoder()));
xstream.registerConverter(rrConverter);
xstream.alias(CswConstants.CSW_NAMESPACE_PREFIX + CswConstants.NAMESPACE_DELIMITER + elementName, CswRecordCollection.class);
return xstream;
}
use of com.thoughtworks.xstream.io.xml.StaxDriver in project ddf by codice.
the class TestXstreamPathConverter method setup.
@Before
public void setup() {
QNameMap qmap = new QNameMap();
qmap.setDefaultNamespace(GML_NAMESPACE);
qmap.setDefaultPrefix("");
StaxDriver staxDriver = new StaxDriver(qmap);
xstream = new XStream(staxDriver);
xstream.setClassLoader(this.getClass().getClassLoader());
XstreamPathConverter converter = new XstreamPathConverter();
xstream.registerConverter(converter);
xstream.alias("Polygon", XstreamPathValueTracker.class);
argumentHolder = xstream.newDataHolder();
Set<Path> paths = new LinkedHashSet<>();
paths.addAll(Arrays.asList(POLYGON_POS_PATH, BAD_PATH, POLYGON_GML_ID_PATH));
argumentHolder.put(XstreamPathConverter.PATH_KEY, paths);
}
Aggregations