Fixing Geo deserializer with bad input

This commit is contained in:
Francesco Chicchiriccò 2014-05-08 16:17:48 +02:00
parent a2197314fa
commit 6ecb02643a
5 changed files with 1582 additions and 23 deletions

View File

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<entry xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/AllGeoTypesSet(-10)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.AllSpatialTypes" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="AllSpatialTypes" href="AllGeoTypesSet(-10)" />
<title />
<updated>2014-05-08T12:27:58Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">-10</d:Id>
<d:Geog m:type="Edm.GeographyPoint">
<gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
<gml:pos>51.65 178.7</gml:pos>
</gml:Point>
</d:Geog>
<d:GeogPoint m:type="Edm.GeographyPoint">
<gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
<gml:pos>52.8606 173.334</gml:pos>
</gml:Point>
</d:GeogPoint>
<d:GeogLine m:type="Edm.GeographyLineString">
<gml:LineString gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
<gml:pos>40.5 40.5</gml:pos>
<gml:pos>30.5 30.5</gml:pos>
<gml:pos>20.5 40.5</gml:pos>
<gml:pos>10.5 30.5</gml:pos>
</gml:LineString>
</d:GeogLine>
<d:GeogPolygon m:type="Edm.GeographyPolygon">
<gml:Polygon gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
<gml:exterior>
<gml:LinearRing>
<gml:pos>5 15</gml:pos>
<gml:pos>10 40</gml:pos>
<gml:pos>20 10</gml:pos>
<gml:pos>10 5</gml:pos>
<gml:pos>5 15</gml:pos>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</d:GeogPolygon>
<d:GeogCollection m:null="true" />
<d:GeogMultiPoint m:null="true" />
<d:GeogMultiLine m:type="Edm.GeographyMultiLineString">
<gml:MultiCurve gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
<gml:curveMembers>
<gml:LineString>
<gml:pos>10 10</gml:pos>
<gml:pos>20 20</gml:pos>
<gml:pos>40 10</gml:pos>
</gml:LineString>
<gml:LineString>
<gml:pos>40 40</gml:pos>
<gml:pos>30 30</gml:pos>
<gml:pos>20 40</gml:pos>
<gml:pos>10 30</gml:pos>
</gml:LineString>
</gml:curveMembers>
</gml:MultiCurve>
</d:GeogMultiLine>
<d:GeogMultiPolygon m:null="true" />
<d:Geom m:type="Edm.GeometryLineString">
<gml:LineString gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0">
<gml:pos>1 1</gml:pos>
<gml:pos>3 3</gml:pos>
<gml:pos>2 4</gml:pos>
<gml:pos>2 0</gml:pos>
</gml:LineString>
</d:Geom>
<d:GeomPoint m:type="Edm.GeometryPoint">
<gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0">
<gml:pos />
</gml:Point>
</d:GeomPoint>
<d:GeomLine m:null="true" />
<d:GeomPolygon m:null="true" />
<d:GeomCollection m:type="Edm.GeometryCollection">
<gml:MultiGeometry gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0" />
</d:GeomCollection>
<d:GeomMultiPoint m:type="Edm.GeometryMultiPoint">
<gml:MultiPoint gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0" />
</d:GeomMultiPoint>
<d:GeomMultiLine m:type="Edm.GeometryMultiLineString">
<gml:MultiCurve gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0">
<gml:curveMembers>
<gml:LineString>
<gml:pos>10 10</gml:pos>
<gml:pos>20 20</gml:pos>
<gml:pos>10 40</gml:pos>
</gml:LineString>
<gml:LineString>
<gml:pos>40 40</gml:pos>
<gml:pos>30 30</gml:pos>
<gml:pos>40 20</gml:pos>
<gml:pos>30 10</gml:pos>
</gml:LineString>
</gml:curveMembers>
</gml:MultiCurve>
</d:GeomMultiLine>
<d:GeomMultiPolygon m:type="Edm.GeometryMultiPolygon">
<gml:MultiSurface gml:srsName="http://www.opengis.net/def/crs/EPSG/0/0">
<gml:surfaceMembers>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:pos>40 40</gml:pos>
<gml:pos>20 45</gml:pos>
<gml:pos>45 30</gml:pos>
<gml:pos>40 40</gml:pos>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:pos>20 35</gml:pos>
<gml:pos>45 20</gml:pos>
<gml:pos>30 5</gml:pos>
<gml:pos>10 10</gml:pos>
<gml:pos>10 30</gml:pos>
<gml:pos>20 35</gml:pos>
</gml:LinearRing>
</gml:exterior>
<gml:interior>
<gml:LinearRing>
<gml:pos>30 20</gml:pos>
<gml:pos>20 25</gml:pos>
<gml:pos>20 15</gml:pos>
<gml:pos>30 20</gml:pos>
</gml:LinearRing>
</gml:interior>
</gml:Polygon>
</gml:surfaceMembers>
</gml:MultiSurface>
</d:GeomMultiPolygon>
</m:properties>
</content>
</entry>

File diff suppressed because it is too large Load Diff

View File

@ -19,13 +19,13 @@
under the License.
-->
<feed xml:base="http://localhost:8080/DefaultService.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<id>http://localhost:8080/DefaultService.svc/Computer</id>
<feed xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer</id>
<title type="text">Computer</title>
<updated>2014-05-08T10:00:26Z</updated>
<link rel="self" title="Computer" href="Computer" />
<entry>
<id>http://localhost:8080/DefaultService.svc/Computer(11)</id>
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(11)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Computer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Computer" href="Computer(11)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ComputerDetail" type="application/atom+xml;type=entry" title="ComputerDetail" href="Computer(11)/ComputerDetail" />
@ -34,7 +34,7 @@
<author>
<name />
</author>
<m:action metadata="http://localhost:8080/DefaultService.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:8080/DefaultService.svc/Computer(11)/GetComputer" />
<m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(11)/GetComputer" />
<content type="application/xml">
<m:properties>
<d:ComputerId m:type="Edm.Int32">11</d:ComputerId>
@ -43,7 +43,7 @@
</content>
</entry>
<entry>
<id>http://localhost:8080/DefaultService.svc/Computer(12)</id>
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(12)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Computer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Computer" href="Computer(12)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ComputerDetail" type="application/atom+xml;type=entry" title="ComputerDetail" href="Computer(12)/ComputerDetail" />
@ -52,7 +52,7 @@
<author>
<name />
</author>
<m:action metadata="http://localhost:8080/DefaultService.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:8080/DefaultService.svc/Computer(12)/GetComputer" />
<m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(12)/GetComputer" />
<content type="application/xml">
<m:properties>
<d:ComputerId m:type="Edm.Int32">12</d:ComputerId>
@ -61,7 +61,7 @@
</content>
</entry>
<entry>
<id>http://localhost:8080/DefaultService.svc/Computer(13)</id>
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(13)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Computer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Computer" href="Computer(13)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ComputerDetail" type="application/atom+xml;type=entry" title="ComputerDetail" href="Computer(13)/ComputerDetail" />
@ -70,7 +70,7 @@
<author>
<name />
</author>
<m:action metadata="http://localhost:8080/DefaultService.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:8080/DefaultService.svc/Computer(13)/GetComputer" />
<m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(13)/GetComputer" />
<content type="application/xml">
<m:properties>
<d:ComputerId m:type="Edm.Int32">13</d:ComputerId>
@ -79,7 +79,7 @@
</content>
</entry>
<entry>
<id>http://localhost:8080/DefaultService.svc/Computer(14)</id>
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(14)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Computer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Computer" href="Computer(14)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ComputerDetail" type="application/atom+xml;type=entry" title="ComputerDetail" href="Computer(14)/ComputerDetail" />
@ -88,7 +88,7 @@
<author>
<name />
</author>
<m:action metadata="http://localhost:8080/DefaultService.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:8080/DefaultService.svc/Computer(14)/GetComputer" />
<m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(14)/GetComputer" />
<content type="application/xml">
<m:properties>
<d:ComputerId m:type="Edm.Int32">14</d:ComputerId>
@ -97,7 +97,7 @@
</content>
</entry>
<entry>
<id>http://localhost:8080/DefaultService.svc/Computer(15)</id>
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(15)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Computer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Computer" href="Computer(15)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ComputerDetail" type="application/atom+xml;type=entry" title="ComputerDetail" href="Computer(15)/ComputerDetail" />
@ -106,7 +106,7 @@
<author>
<name />
</author>
<m:action metadata="http://localhost:8080/DefaultService.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:8080/DefaultService.svc/Computer(15)/GetComputer" />
<m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(15)/GetComputer" />
<content type="application/xml">
<m:properties>
<d:ComputerId m:type="Edm.Int32">15</d:ComputerId>
@ -115,7 +115,7 @@
</content>
</entry>
<entry>
<id>http://localhost:8080/DefaultService.svc/Computer(16)</id>
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(16)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Computer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Computer" href="Computer(16)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ComputerDetail" type="application/atom+xml;type=entry" title="ComputerDetail" href="Computer(16)/ComputerDetail" />
@ -124,7 +124,7 @@
<author>
<name />
</author>
<m:action metadata="http://localhost:8080/DefaultService.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:8080/DefaultService.svc/Computer(16)/GetComputer" />
<m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(16)/GetComputer" />
<content type="application/xml">
<m:properties>
<d:ComputerId m:type="Edm.Int32">16</d:ComputerId>
@ -133,7 +133,7 @@
</content>
</entry>
<entry>
<id>http://localhost:8080/DefaultService.svc/Computer(17)</id>
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(17)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Computer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Computer" href="Computer(17)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ComputerDetail" type="application/atom+xml;type=entry" title="ComputerDetail" href="Computer(17)/ComputerDetail" />
@ -142,7 +142,7 @@
<author>
<name />
</author>
<m:action metadata="http://localhost:8080/DefaultService.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:8080/DefaultService.svc/Computer(17)/GetComputer" />
<m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(17)/GetComputer" />
<content type="application/xml">
<m:properties>
<d:ComputerId m:type="Edm.Int32">17</d:ComputerId>
@ -151,7 +151,7 @@
</content>
</entry>
<entry>
<id>http://localhost:8080/DefaultService.svc/Computer(18)</id>
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(18)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Computer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Computer" href="Computer(18)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ComputerDetail" type="application/atom+xml;type=entry" title="ComputerDetail" href="Computer(18)/ComputerDetail" />
@ -160,7 +160,7 @@
<author>
<name />
</author>
<m:action metadata="http://localhost:8080/DefaultService.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:8080/DefaultService.svc/Computer(18)/GetComputer" />
<m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(18)/GetComputer" />
<content type="application/xml">
<m:properties>
<d:ComputerId m:type="Edm.Int32">18</d:ComputerId>
@ -169,7 +169,7 @@
</content>
</entry>
<entry>
<id>http://localhost:8080/DefaultService.svc/Computer(19)</id>
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(19)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Computer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Computer" href="Computer(19)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ComputerDetail" type="application/atom+xml;type=entry" title="ComputerDetail" href="Computer(19)/ComputerDetail" />
@ -178,7 +178,7 @@
<author>
<name />
</author>
<m:action metadata="http://localhost:8080/DefaultService.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:8080/DefaultService.svc/Computer(19)/GetComputer" />
<m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(19)/GetComputer" />
<content type="application/xml">
<m:properties>
<d:ComputerId m:type="Edm.Int32">19</d:ComputerId>
@ -187,7 +187,7 @@
</content>
</entry>
<entry>
<id>http://localhost:8080/DefaultService.svc/Computer(20)</id>
<id>http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(20)</id>
<category term="Microsoft.Test.OData.Services.AstoriaDefaultService.Computer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Computer" href="Computer(20)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ComputerDetail" type="application/atom+xml;type=entry" title="ComputerDetail" href="Computer(20)/ComputerDetail" />
@ -196,7 +196,7 @@
<author>
<name />
</author>
<m:action metadata="http://localhost:8080/DefaultService.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:8080/DefaultService.svc/Computer(20)/GetComputer" />
<m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/$metadata#DefaultContainer.GetComputer" title="GetComputer" target="http://localhost:${cargo.servlet.port}/stub/StaticService/V30/Static.svc/Computer(20)/GetComputer" />
<content type="application/xml">
<m:properties>
<d:ComputerId m:type="Edm.Int32">20</d:ComputerId>

View File

@ -31,6 +31,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataRawReque
import org.apache.olingo.client.api.communication.response.ODataRawResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.api.uri.v3.URIBuilder;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
@ -202,7 +203,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
}
@Test
public void checkForETagAsATOM() {
public void checkForETagAsAtom() {
checkForETag(ODataPubFormat.ATOM);
}
@ -239,4 +240,25 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
// since we are attempting to parse an EntitySet as if it was an Entity
req.execute().getBody();
}
private void geospatial(final ODataPubFormat format) {
final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()).
appendEntitySetSegment("AllGeoTypesSet").appendKeySegment(-10);
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataEntity entity = req.execute().getBody();
assertNotNull(entity);
}
@Test
public void geospatialAsJSON() {
geospatial(ODataPubFormat.JSON_FULL_METADATA);
}
@Test
public void geospatialAsAtom() {
geospatial(ODataPubFormat.ATOM);
}
}

View File

@ -73,6 +73,11 @@ class AtomGeoValueDeserializer {
}
}
// handles bad input, e.g. things like <gml:pos/>
if (result.isEmpty()) {
result.add(new Point(GeoUtils.getDimension(type), srid));
}
return result;
}