use of com.thoughtworks.xstream.io.HierarchicalStreamReader in project ddf by codice.
the class TestXstreamPathConverter method testGetFirstNodeValue.
@Test
public void testGetFirstNodeValue() 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_POS_PATH), is("-180.000000 90.000000"));
}
use of com.thoughtworks.xstream.io.HierarchicalStreamReader in project ddf by codice.
the class TestXstreamPathConverter 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.HierarchicalStreamReader in project ddf by codice.
the class TestBoundingBoxReader method testNonBoundingBox.
/**
* Verify that if the reader is given something that isn't a BoundingBox, then an exception
* is raised.
*/
@Test(expected = CswException.class)
public void testNonBoundingBox() throws CswException {
HierarchicalStreamReader hReader = mock(HierarchicalStreamReader.class);
when(hReader.getNodeName()).thenReturn("NOT_A_BOUNDING_BOX");
BoundingBoxReader boundingBoxReader = new BoundingBoxReader(hReader, CswAxisOrder.LON_LAT);
boundingBoxReader.getWkt();
}
use of com.thoughtworks.xstream.io.HierarchicalStreamReader in project ddf by codice.
the class TestBoundingBoxReader method testGetWktBoundingBoxInLonLatForPoint.
/**
* Verify that if given a BoundingBox with coords in LON/LAT for a Point, i.e., both corners
* have same exact Lon/Lat, that the resulting WKT is a POINT in LON/LAT.
*/
@Test
public void testGetWktBoundingBoxInLonLatForPoint() throws ParserConfigurationException, SAXException, IOException, CswException {
// Setup
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse("src/test/resources/BoundingBoxInLonLatForPoint.xml");
HierarchicalStreamReader hReader = new DomReader(doc);
BoundingBoxReader boundingBoxReader = new BoundingBoxReader(hReader, CswAxisOrder.LON_LAT);
// Perform Test
String wktInLonLat = boundingBoxReader.getWkt();
LOGGER.debug("WKT: {}", wktInLonLat);
// Verify
assertThat(wktInLonLat, is(POINT_CONTROL_WKT_IN_LON_LAT));
}
use of com.thoughtworks.xstream.io.HierarchicalStreamReader in project ddf by codice.
the class TestBoundingBoxReader method testGetWktBoundingBoxInLonLat.
/**
* Verify that if given a BoundingBox with coords in LON/LAT that the resulting WKT is in
* LON/LAT.
*/
@Test
public void testGetWktBoundingBoxInLonLat() throws ParserConfigurationException, SAXException, IOException, CswException {
// Setup
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse("src/test/resources/BoundingBoxInLonLat.xml");
HierarchicalStreamReader hReader = new DomReader(doc);
BoundingBoxReader boundingBoxReader = new BoundingBoxReader(hReader, CswAxisOrder.LON_LAT);
// Perform Test
String wktInLonLat = boundingBoxReader.getWkt();
LOGGER.debug("WKT: {}", wktInLonLat);
// Verify
assertThat(wktInLonLat, is(NON_JTS_FORMATTED_POLYGON_CONTROL_WKT_IN_LON_LAT));
}
Aggregations