Search in sources :

Example 1 with DomReader

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

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

Example 3 with DomReader

use of com.thoughtworks.xstream.io.xml.DomReader in project ddf by codice.

the class TestBoundingBoxReader method testJTSConverterEPSG4326LonLat.

@Test
public void testJTSConverterEPSG4326LonLat() throws Exception {
    // Setup
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
    Document doc = docBuilder.parse("src/test/resources/BoundingBoxInLonLatEPSG4326.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)

Example 4 with DomReader

use of com.thoughtworks.xstream.io.xml.DomReader in project ddf by codice.

the class TestBoundingBoxReader method testJTSConverterBadLat.

@Test(expected = CswException.class)
public void testJTSConverterBadLat() throws Exception {
    // Setup
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
    Document doc = docBuilder.parse("src/test/resources/BoundingBoxBadCoordinates.xml");
    HierarchicalStreamReader hReader = new DomReader(doc);
    BoundingBoxReader boundingBoxReader = new BoundingBoxReader(hReader, CswAxisOrder.LAT_LON);
    // 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)

Example 5 with DomReader

use of com.thoughtworks.xstream.io.xml.DomReader in project ddf by codice.

the class TestBoundingBoxReader method testGetWktBoundingBoxInLatLon.

/**
     * Verify that if given a BoundingBox with coords in LAT/LON that the resulting WKT is in
     * LON/LAT (i.e., the coords are reversed).
     */
@Test
public void testGetWktBoundingBoxInLatLon() throws ParserConfigurationException, SAXException, IOException, CswException {
    // Setup
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
    Document doc = docBuilder.parse("src/test/resources/BoundingBoxInLatLon.xml");
    HierarchicalStreamReader hReader = new DomReader(doc);
    BoundingBoxReader boundingBoxReader = new BoundingBoxReader(hReader, CswAxisOrder.LAT_LON);
    // Perform Test
    String wktInLonLat = boundingBoxReader.getWkt();
    LOGGER.debug("WKT: {}", wktInLonLat);
    // Verify
    assertThat(wktInLonLat, is(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)22 DomReader (com.thoughtworks.xstream.io.xml.DomReader)22 DocumentBuilder (javax.xml.parsers.DocumentBuilder)22 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)22 Test (org.junit.Test)22 Document (org.w3c.dom.Document)22 Metacard (ddf.catalog.data.Metacard)6 XStream (com.thoughtworks.xstream.XStream)4 DataHolder (com.thoughtworks.xstream.converters.DataHolder)4 WstxDriver (com.thoughtworks.xstream.io.xml.WstxDriver)4 UnmarshallingContext (com.thoughtworks.xstream.converters.UnmarshallingContext)2 TreeUnmarshaller (com.thoughtworks.xstream.core.TreeUnmarshaller)2 InputStream (java.io.InputStream)2 StringWriter (java.io.StringWriter)2 URL (java.net.URL)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2