use of com.thoughtworks.xstream.io.xml.QNameMap in project ddf by codice.
the class XstreamPathConverterTest method testAttributeValid.
@Test
public void testAttributeValid() throws XMLStreamException {
XMLStreamReader streamReader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(GML_XML));
HierarchicalStreamReader reader = new StaxReader(new QNameMap(), streamReader);
XstreamPathValueTracker pathValueTracker = (XstreamPathValueTracker) xstream.unmarshal(reader, null, argumentHolder);
assertThat(pathValueTracker.getFirstValue(POLYGON_GML_ID_PATH), is("p1"));
}
use of com.thoughtworks.xstream.io.xml.QNameMap in project ddf by codice.
the class XstreamPathConverterTest method testBadPath.
@Test
public void testBadPath() throws XMLStreamException {
XMLStreamReader streamReader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(GML_XML));
HierarchicalStreamReader reader = new StaxReader(new QNameMap(), streamReader);
XstreamPathValueTracker pathValueTracker = (XstreamPathValueTracker) xstream.unmarshal(reader, null, argumentHolder);
assertThat(pathValueTracker.getFirstValue(BAD_PATH), nullValue());
}
use of com.thoughtworks.xstream.io.xml.QNameMap in project ddf by codice.
the class XstreamPathConverterTest method assertRepeatedElements.
private void assertRepeatedElements(String xml) throws XMLStreamException {
Path path = new Path("/Polygon/B/C/D/E/F/G");
Set<Path> paths = new LinkedHashSet<>();
paths.add(path);
argumentHolder.put(XstreamPathConverter.PATH_KEY, paths);
XMLStreamReader streamReader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
HierarchicalStreamReader reader = new StaxReader(new QNameMap(), streamReader);
XstreamPathValueTracker pathValueTracker = (XstreamPathValueTracker) xstream.unmarshal(reader, null, argumentHolder);
assertThat(pathValueTracker.getAllValues(path), is(Arrays.asList("value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8")));
}
use of com.thoughtworks.xstream.io.xml.QNameMap in project camel by apache.
the class XStreamDataFormat method createHierarchicalStreamWriter.
protected HierarchicalStreamWriter createHierarchicalStreamWriter(Exchange exchange, Object body, OutputStream stream) throws XMLStreamException {
updateCharactorEncodingInfo(exchange);
if (getXstreamDriver() != null) {
return getXstreamDriver().createWriter(stream);
}
XMLStreamWriter xmlWriter = getStaxConverter().createXMLStreamWriter(stream, exchange);
return new StaxWriter(new QNameMap(), xmlWriter);
}
use of com.thoughtworks.xstream.io.xml.QNameMap 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