use of org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType in project geotoolkit by Geomatys.
the class WfsXMLBindingTest method unmarshallingTest.
@Test
public void unmarshallingTest() throws JAXBException, FileNotFoundException {
InputStream is = WfsXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/wfs/v110/capabilities.xml");
Object unmarshalled = unmarshaller.unmarshal(is);
if (unmarshalled instanceof JAXBElement) {
unmarshalled = ((JAXBElement) unmarshalled).getValue();
}
assertTrue(unmarshalled instanceof WFSCapabilitiesType);
WFSCapabilitiesType result = (WFSCapabilitiesType) unmarshalled;
assertTrue(result.getFeatureTypeList() != null);
WFSCapabilitiesType expResult = new WFSCapabilitiesType();
List<FeatureTypeType> featList = new ArrayList<>();
List<String> otherSRS = Arrays.asList("urn:ogc:def:crs", "crs:EPSG::32615", "crs:EPSG::5773");
WGS84BoundingBoxType bbox = new WGS84BoundingBoxType(29.8, -90.1, 30, -89.9);
FeatureTypeType ft1 = new FeatureTypeType(new QName("http://www.opengis.net/ows-6/utds/0.3", "Building", "utds"), "", "urn:ogc:def:crs:EPSG::4979", otherSRS, Arrays.asList(bbox));
featList.add(ft1);
FeatureTypeType ft2 = new FeatureTypeType(new QName("http://www.opengis.net/ows-6/utds/0.3", "AircraftTransportationComplex", "utds"), "", "urn:ogc:def:crs:EPSG::4979", otherSRS, Arrays.asList(bbox));
featList.add(ft2);
FeatureTypeType ft3 = new FeatureTypeType(new QName("http://www.opengis.net/ows-6/utds/0.3", "Fence", "utds"), "", "urn:ogc:def:crs:EPSG::4979", otherSRS, Arrays.asList(bbox));
featList.add(ft3);
FeatureTypeListType featureList = new FeatureTypeListType(null, featList);
expResult.setFeatureTypeList(featureList);
assertEquals(expResult.getFeatureTypeList().getFeatureType(), result.getFeatureTypeList().getFeatureType());
assertEquals(expResult.getFeatureTypeList(), result.getFeatureTypeList());
/*assertEquals(expResult.getOperationsMetadata(), result.getOperationsMetadata());
assertEquals(expResult.getFilterCapabilities(), result.getFilterCapabilities());
assertEquals(expResult, result);*/
// TEST with WFSBindingUtilities
is = WfsXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/wfs/v110/capabilities.xml");
result = (WFSCapabilitiesType) WFSBindingUtilities.unmarshall(is, WFSVersion.v110);
assertEquals(expResult.getFeatureTypeList().getFeatureType(), result.getFeatureTypeList().getFeatureType());
assertEquals(expResult.getFeatureTypeList(), result.getFeatureTypeList());
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + '\n' + "<wfs:Transaction version=\"1.1.0\" service=\"WFS\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:ogc=\"http://www.opengis.net/ogc\" " + '\n' + " xmlns:wfs=\"http://www.opengis.net/wfs\" xmlns:sampling=\"http://www.opengis.net/sampling/1.0\">" + '\n' + " <wfs:Insert idgen=\"UseExisting\">" + '\n' + " </wfs:Insert>" + '\n' + "</wfs:Transaction>";
unmarshalled = unmarshaller.unmarshal(new StringReader(xml));
assertTrue(unmarshalled instanceof TransactionType);
TransactionType resultT = (TransactionType) unmarshalled;
InsertElementType ins = new InsertElementType();
ins.setIdgen(IdentifierGenerationOptionType.USE_EXISTING);
TransactionType expResultT = new TransactionType("WFS", "1.1.0", null, null, ins);
assertEquals(expResultT, resultT);
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + '\n' + "<wfs:Transaction version=\"1.1.0\" service=\"WFS\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:ogc=\"http://www.opengis.net/ogc\" " + '\n' + " xmlns:wfs=\"http://www.opengis.net/wfs\" xmlns:sampling=\"http://www.opengis.net/sampling/1.0\">" + '\n' + " <wfs:Delete typeName=\"gml:test\">" + '\n' + " </wfs:Delete>" + '\n' + "</wfs:Transaction>";
unmarshalled = unmarshaller.unmarshal(new StringReader(xml));
assertTrue(unmarshalled instanceof TransactionType);
resultT = (TransactionType) unmarshalled;
DeleteElementType del = new DeleteElementType();
del.setTypeName(new QName("http://www.opengis.net/gml", "test"));
expResultT = new TransactionType("WFS", "1.1.0", null, null, del);
assertEquals(expResultT, resultT);
}
use of org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method briefRecordMarshalingTest.
/**
* Test brief Record Marshalling.
*/
@Test
public void briefRecordMarshalingTest() throws JAXBException {
Marshaller marshaller = pool.acquireMarshaller();
/*
* Test marshalling BRIEF csw Record v2.0.2
*/
SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
SimpleLiteral title = new SimpleLiteral("(JASON-1)");
SimpleLiteral type = new SimpleLiteral("clearinghouse");
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
BriefRecordType record = new BriefRecordType(id, title, type, bbox);
StringWriter sw = new StringWriter();
marshaller.marshal(record, sw);
String result = sw.toString();
String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:BriefRecord xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + "</csw:BriefRecord>\n";
assertXmlEquals(expResult, result, "xmlns:*");
/*
* Test marshalling csw Record v2.0.2
*/
List<SimpleLiteral> identifiers = new ArrayList<>();
identifiers.add(new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}"));
identifiers.add(new SimpleLiteral("urn:ogc:x-def:F7807C8AB645"));
List<SimpleLiteral> titles = new ArrayList<>();
titles.add(new SimpleLiteral("(JASON-1)"));
titles.add(new SimpleLiteral("(JASON-2)"));
type = new SimpleLiteral("clearinghouse");
bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
bbox.add(new WGS84BoundingBoxType(176, -16.4, -178, 6.1));
record = new BriefRecordType(identifiers, titles, type, bbox);
sw = new StringWriter();
marshaller.marshal(record, sw);
result = sw.toString();
expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:BriefRecord xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:identifier>urn:ogc:x-def:F7807C8AB645</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:title>(JASON-2)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>176.0 -16.4</ows:LowerCorner>\n" + " <ows:UpperCorner>-178.0 6.1</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + "</csw:BriefRecord>\n";
assertXmlEquals(expResult, result, "xmlns:*");
pool.recycle(marshaller);
}
use of org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method transactionResponseMarshalingTest.
@Test
public void transactionResponseMarshalingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
Marshaller marshaller = pool.acquireMarshaller();
SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
SimpleLiteral title = new SimpleLiteral("(JASON-1)");
SimpleLiteral type = new SimpleLiteral("clearinghouse");
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
Object record = new BriefRecordType(id, title, type, bbox);
final List<InsertResultType> inserteds = new ArrayList<>();
inserteds.add(new InsertResultType(Arrays.asList(record), null));
TransactionSummaryType summ = new TransactionSummaryType(2, 0, 1, "rid");
TransactionResponseType request = new TransactionResponseType(summ, inserteds, "2.0.2");
String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<csw:TransactionResponse version=\"2.0.2\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:ows=\"http://www.opengis.net/ows\">\n" + " <csw:TransactionSummary requestId=\"rid\">\n" + " <csw:totalInserted>2</csw:totalInserted>\n" + " <csw:totalUpdated>0</csw:totalUpdated>\n" + " <csw:totalDeleted>1</csw:totalDeleted>\n" + " </csw:TransactionSummary>\n" + " <csw:InsertResult>\n" + " <csw:BriefRecord>\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " </csw:BriefRecord>\n" + " </csw:InsertResult>\n" + "</csw:TransactionResponse>\n";
StringWriter sw = new StringWriter();
marshaller.marshal(request, sw);
String result = sw.toString();
assertXmlEquals(expResult, result, "xmlns:*");
pool.recycle(marshaller);
}
use of org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method getRecordsResponseUnMarshalingTest.
/**
* Test getRecordById request Marshalling.
*/
@Test
public void getRecordsResponseUnMarshalingTest() throws JAXBException {
Unmarshaller unmarshaller = pool.acquireUnmarshaller();
/*
* Test marshalling csw getRecordByIdResponse v2.0.2
*/
SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
SimpleLiteral title = new SimpleLiteral("(JASON-1)");
SimpleLiteral type = new SimpleLiteral("clearinghouse");
List<SimpleLiteral> subject = new ArrayList<>();
subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
subject.add(new SimpleLiteral("oceans elevation 2"));
SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
SimpleLiteral Abstract = new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.");
SimpleLiteral references = new SimpleLiteral("http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml");
SimpleLiteral spatial = new SimpleLiteral("northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;");
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
RecordType record = new RecordType(id, title, type, subject, null, modified, null, Abstract, bbox, null, null, null, spatial, references);
BriefRecordType briefRecord = new BriefRecordType(id, title, type, bbox);
SummaryRecordType sumRecord = new SummaryRecordType(id, title, type, bbox, subject, null, modified, Abstract);
List<Object> records = new ArrayList<>();
records.add(record);
records.add(briefRecord);
records.add(sumRecord);
final SearchResultsType sr = new SearchResultsType("set", ElementSetType.BRIEF, 1, records, 1, 0);
GetRecordsResponse expResult = new GetRecordsResponseType("rid", 100000, "v1.2", sr);
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:GetRecordsResponse version=\"v1.2\" xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dct=\"http://purl.org/dc/terms/\">\n" + " <csw:RequestId>rid</csw:RequestId>\n" + " <csw:SearchStatus timestamp=\"1970-01-01T01:01:40.000+01:00\"/>\n" + " <csw:SearchResults resultSetId=\"set\" elementSet=\"brief\" numberOfRecordsMatched=\"1\" numberOfRecordsReturned=\"1\" nextRecord=\"0\">\n" + " <csw:Record>\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + " <dc:subject>oceans elevation 2</dc:subject>\n" + " <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + " <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + " <dct:references>http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml</dct:references>\n" + " <dct:spatial>northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;</dct:spatial>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " </csw:Record>\n" + " <csw:BriefRecord>\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " </csw:BriefRecord>\n" + " <csw:SummaryRecord>\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + " <dc:subject>oceans elevation 2</dc:subject>\n" + " <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + " <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " </csw:SummaryRecord>\n" + " </csw:SearchResults>\n" + "</csw:GetRecordsResponse>\n";
GetRecordsResponse result = ((JAXBElement<GetRecordsResponse>) unmarshaller.unmarshal(new StringReader(xml))).getValue();
assertTrue(result.getSearchResults().getAny() instanceof List);
List<Object> resultList = result.getSearchResults().getAny();
List<Object> expResultList = expResult.getSearchResults().getAny();
assertEquals(expResultList.get(0), resultList.get(0));
assertEquals(expResultList.get(1), resultList.get(1));
assertEquals(expResultList.get(2), resultList.get(2));
assertEquals(expResultList, resultList);
assertEquals(expResult.getSearchResults().getAny(), result.getSearchResults().getAny());
assertEquals(expResult.getSearchStatus(), result.getSearchStatus());
assertEquals(expResult, result);
pool.recycle(unmarshaller);
}
use of org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method briefRecordUnmarshalingTest.
/**
* Test brief Record Unmarshalling.
*/
@Test
public void briefRecordUnmarshalingTest() throws JAXBException {
Unmarshaller unmarshaller = pool.acquireUnmarshaller();
/*
* Test marshalling BRIEF csw Record v2.0.2
*/
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:BriefRecord xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + "</csw:BriefRecord>\n";
StringReader sr = new StringReader(xml);
BriefRecordType result = (BriefRecordType) unmarshaller.unmarshal(sr);
SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
SimpleLiteral title = new SimpleLiteral("(JASON-1)");
SimpleLiteral type = new SimpleLiteral("clearinghouse");
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
BriefRecordType expResult = new BriefRecordType(id, title, type, bbox);
assertEquals(expResult, result);
/*
* Test marshalling csw Record v2.0.2
*/
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:BriefRecord xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:identifier>urn:ogc:x-def:F7807C8AB645</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:title>(JASON-2)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>176.0 -16.4</ows:LowerCorner>\n" + " <ows:UpperCorner>-178.0 6.1</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + "</csw:BriefRecord>\n";
sr = new StringReader(xml);
result = (BriefRecordType) unmarshaller.unmarshal(sr);
List<SimpleLiteral> identifiers = new ArrayList<>();
identifiers.add(new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}"));
identifiers.add(new SimpleLiteral("urn:ogc:x-def:F7807C8AB645"));
List<SimpleLiteral> titles = new ArrayList<>();
titles.add(new SimpleLiteral("(JASON-1)"));
titles.add(new SimpleLiteral("(JASON-2)"));
type = new SimpleLiteral("clearinghouse");
bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
bbox.add(new WGS84BoundingBoxType(176, -16.4, -178, 6.1));
expResult = new BriefRecordType(identifiers, titles, type, bbox);
assertEquals(expResult, result);
pool.recycle(unmarshaller);
}
Aggregations