Search in sources :

Example 11 with HierarchicalStreamReader

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"));
}
Also used : StaxReader(com.thoughtworks.xstream.io.xml.StaxReader) XMLStreamReader(javax.xml.stream.XMLStreamReader) StringReader(java.io.StringReader) HierarchicalStreamReader(com.thoughtworks.xstream.io.HierarchicalStreamReader) QNameMap(com.thoughtworks.xstream.io.xml.QNameMap) Test(org.junit.Test)

Example 12 with HierarchicalStreamReader

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());
}
Also used : StaxReader(com.thoughtworks.xstream.io.xml.StaxReader) XMLStreamReader(javax.xml.stream.XMLStreamReader) StringReader(java.io.StringReader) HierarchicalStreamReader(com.thoughtworks.xstream.io.HierarchicalStreamReader) QNameMap(com.thoughtworks.xstream.io.xml.QNameMap) Test(org.junit.Test)

Example 13 with HierarchicalStreamReader

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();
}
Also used : HierarchicalStreamReader(com.thoughtworks.xstream.io.HierarchicalStreamReader) Test(org.junit.Test)

Example 14 with HierarchicalStreamReader

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));
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DomReader(com.thoughtworks.xstream.io.xml.DomReader) DocumentBuilder(javax.xml.parsers.DocumentBuilder) HierarchicalStreamReader(com.thoughtworks.xstream.io.HierarchicalStreamReader) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 15 with HierarchicalStreamReader

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));
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DomReader(com.thoughtworks.xstream.io.xml.DomReader) DocumentBuilder(javax.xml.parsers.DocumentBuilder) HierarchicalStreamReader(com.thoughtworks.xstream.io.HierarchicalStreamReader) Document(org.w3c.dom.Document) Test(org.junit.Test)

Aggregations

HierarchicalStreamReader (com.thoughtworks.xstream.io.HierarchicalStreamReader)34 Test (org.junit.Test)28 DomReader (com.thoughtworks.xstream.io.xml.DomReader)13 DocumentBuilder (javax.xml.parsers.DocumentBuilder)13 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)13 Document (org.w3c.dom.Document)13 StringReader (java.io.StringReader)11 UnmarshallingContext (com.thoughtworks.xstream.converters.UnmarshallingContext)8 InputStream (java.io.InputStream)8 TreeUnmarshaller (com.thoughtworks.xstream.core.TreeUnmarshaller)7 WstxDriver (com.thoughtworks.xstream.io.xml.WstxDriver)6 XppReader (com.thoughtworks.xstream.io.xml.XppReader)6 HashMap (java.util.HashMap)6 XStream (com.thoughtworks.xstream.XStream)5 Metacard (ddf.catalog.data.Metacard)5 Serializable (java.io.Serializable)5 DataHolder (com.thoughtworks.xstream.converters.DataHolder)4 QNameMap (com.thoughtworks.xstream.io.xml.QNameMap)4 StaxReader (com.thoughtworks.xstream.io.xml.StaxReader)4 IOException (java.io.IOException)4