use of com.thoughtworks.xstream.io.xml.WstxDriver in project ddf by codice.
the class TestGenericFeatureConverter method testGeoServerLatLonSwappingForPoint.
@Test
public void testGeoServerLatLonSwappingForPoint() {
XStream xstream = new XStream(new WstxDriver());
FeatureCollectionConverterWfs20 fcConverter = new FeatureCollectionConverterWfs20();
Map<String, FeatureConverter> fcMap = new HashMap<String, FeatureConverter>();
GenericFeatureConverterWfs20 converter = new GenericFeatureConverterWfs20();
fcMap.put("states", converter);
fcMap.put("streams", converter);
fcConverter.setFeatureConverterMap(fcMap);
xstream.registerConverter(fcConverter);
converter.setMetacardType(buildStatesMetacardType());
converter.setCoordinateOrder(GeospatialUtil.LAT_LON_ORDER);
xstream.registerConverter(converter);
xstream.alias("FeatureCollection", Wfs20FeatureCollection.class);
InputStream is = TestGenericFeatureConverter.class.getResourceAsStream("/geoserver_sample_point.xml");
Wfs20FeatureCollection wfc = (Wfs20FeatureCollection) xstream.fromXML(is);
assertEquals(1, wfc.getMembers().size());
Metacard mc = wfc.getMembers().get(0);
assertEquals(mc.getId(), "states.10");
// Verifies that lat/lon was swapped to lon/lat order for the WKT conversion
// to set the metacard's location
assertTrue(mc.getLocation().startsWith("POINT (-123.26 49.41)"));
}
use of com.thoughtworks.xstream.io.xml.WstxDriver in project ddf by codice.
the class TestGenericFeatureConverter method testUnmarshalSingleFeatureXmlToObject.
@Test
//DDF-733
@Ignore
public void testUnmarshalSingleFeatureXmlToObject() {
XStream xstream = new XStream(new WstxDriver());
MetacardType metacardType = buildMetacardType();
GenericFeatureConverterWfs20 converter = new GenericFeatureConverterWfs20();
converter.setMetacardType(buildMetacardType());
converter.setSourceId(SOURCE_ID);
converter.setCoordinateOrder(GeospatialUtil.LAT_LON_ORDER);
xstream.registerConverter(converter);
xstream.registerConverter(new GmlGeometryConverter());
xstream.alias(FEATURE_TYPE, MetacardImpl.class);
InputStream is = TestGenericFeatureConverter.class.getResourceAsStream("/video_data_set.xml");
Metacard mc = (Metacard) xstream.fromXML(is);
assertEquals("video_data_set.2", mc.getId());
assertEquals(FEATURE_TYPE, mc.getContentTypeName());
assertEquals(metacardType.getName(), mc.getMetacardType().getName());
assertEquals(SOURCE_ID, mc.getSourceId());
assertEquals("video_data_set.2", mc.getTitle());
assertEquals(2L, mc.getAttribute(PROPERTY_PREFIX + ID_ELEMENT).getValue());
assertEquals(Long.valueOf(1L), mc.getAttribute(PROPERTY_PREFIX + VERSION_ELEMENT).getValue());
assertEquals(DatatypeConverter.parseDateTime("2005-04-07T09:54:38.983").getTime(), mc.getAttribute(PROPERTY_PREFIX + END_DATE_ELEMENT).getValue());
assertEquals("/data/test_suite/video/video/videoFile.mpg", mc.getAttribute(PROPERTY_PREFIX + FILENAME_ELEMENT).getValue());
assertEquals(720L, mc.getAttribute(PROPERTY_PREFIX + HEIGHT_ELEMENT).getValue());
assertEquals("a8a55092f0afae881099637ef7746cd8d7066270d9af4cf0f52c41dab53c4005", mc.getAttribute(PROPERTY_PREFIX + INDEX_ID_ELEMENT).getValue());
assertEquals(getOtherTagsXml(), mc.getAttribute(PROPERTY_PREFIX + OTHER_TAGS_XML_ELEMENT).getValue());
assertEquals(26L, mc.getAttribute(PROPERTY_PREFIX + REPOSITORY_ID_ELEMENT).getValue());
assertEquals(DatatypeConverter.parseDateTime("2005-04-07T09:53:39.000").getTime(), mc.getAttribute(PROPERTY_PREFIX + START_DATE_ELEMENT).getValue());
assertEquals(1280L, mc.getAttribute(PROPERTY_PREFIX + WIDTH_ELEMENT).getValue());
assertEquals(getLocation(), mc.getLocation());
assertEquals(mc.getLocation(), mc.getAttribute(PROPERTY_PREFIX + GROUND_GEOM_ELEMENT).getValue());
assertNotNull(mc.getCreatedDate());
assertNotNull(mc.getEffectiveDate());
assertNotNull(mc.getModifiedDate());
assertNotNull(mc.getContentTypeNamespace());
assertEquals(mc.getContentTypeNamespace().toString(), Wfs20Constants.NAMESPACE_URN_ROOT + metacardType.getName());
}
use of com.thoughtworks.xstream.io.xml.WstxDriver in project ddf by codice.
the class TestGenericFeatureConverter method testUnmarshalFeatureCollectionXmlToObject.
@Test
public void testUnmarshalFeatureCollectionXmlToObject() {
XStream xstream = new XStream(new WstxDriver());
FeatureCollectionConverterWfs20 fcConverter = new FeatureCollectionConverterWfs20();
Map<String, FeatureConverter> fcMap = new HashMap<String, FeatureConverter>();
GenericFeatureConverterWfs20 converter = new GenericFeatureConverterWfs20();
fcMap.put("video_data_set", converter);
fcConverter.setFeatureConverterMap(fcMap);
xstream.registerConverter(fcConverter);
converter.setMetacardType(buildMetacardType());
converter.setCoordinateOrder(GeospatialUtil.LAT_LON_ORDER);
xstream.registerConverter(converter);
xstream.registerConverter(new GmlGeometryConverter());
xstream.alias("FeatureCollection", Wfs20FeatureCollection.class);
InputStream is = TestGenericFeatureConverter.class.getResourceAsStream("/video_data_set_collection.xml");
Wfs20FeatureCollection wfc = (Wfs20FeatureCollection) xstream.fromXML(is);
assertEquals(4, wfc.getMembers().size());
Metacard mc = wfc.getMembers().get(0);
assertEquals(mc.getId(), "video_data_set.1");
}
use of com.thoughtworks.xstream.io.xml.WstxDriver in project ddf by codice.
the class TestGenericFeatureConverter method testReadCdata.
@Test
//DDF-733
@Ignore
public void testReadCdata() {
XStream xstream = new XStream(new WstxDriver());
String contents = "<tag>my cdata contents</tag>";
String xml = "<string><![CDATA[" + contents + "]]></string>";
String results = (String) xstream.fromXML(xml);
assertEquals(contents, results);
}
use of com.thoughtworks.xstream.io.xml.WstxDriver in project ddf by codice.
the class TestGenericFeatureConverter method testGeoServerLatLonSwappingForMultiPolygon.
@Test
public void testGeoServerLatLonSwappingForMultiPolygon() {
XStream xstream = new XStream(new WstxDriver());
FeatureCollectionConverterWfs20 fcConverter = new FeatureCollectionConverterWfs20();
Map<String, FeatureConverter> fcMap = new HashMap<String, FeatureConverter>();
GenericFeatureConverterWfs20 converter = new GenericFeatureConverterWfs20();
fcMap.put("states", converter);
fcMap.put("streams", converter);
fcConverter.setFeatureConverterMap(fcMap);
xstream.registerConverter(fcConverter);
converter.setMetacardType(buildStatesMetacardType());
converter.setCoordinateOrder(GeospatialUtil.LAT_LON_ORDER);
xstream.registerConverter(converter);
xstream.alias("FeatureCollection", Wfs20FeatureCollection.class);
InputStream is = TestGenericFeatureConverter.class.getResourceAsStream("/geoserver_sample_polygon.xml");
Wfs20FeatureCollection wfc = (Wfs20FeatureCollection) xstream.fromXML(is);
assertEquals(1, wfc.getMembers().size());
Metacard mc = wfc.getMembers().get(0);
assertEquals(mc.getId(), "states.10");
// Verifies that lat/lon was swapped to lon/lat order for the WKT conversion
// to set the metacard's location
assertTrue(mc.getLocation().startsWith("MULTIPOLYGON (((-89.1 36.1, -89.1 37.1, -88.1 37.1, -88.1 36.1, -89.1 36.1"));
}
Aggregations