Repository: olingo-odata4 Updated Branches: refs/heads/master d040afe78 -> c86009a24
OLINGO-868: Fixing a error, where a repeated annotation element is not skipped correctly Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/c86009a2 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/c86009a2 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/c86009a2 Branch: refs/heads/master Commit: c86009a2428902e73c2f3f317e5baf13e4415eab Parents: d040afe Author: Ramesh Reddy <[email protected]> Authored: Fri Feb 19 12:00:23 2016 -0600 Committer: Ramesh Reddy <[email protected]> Committed: Fri Feb 19 12:06:12 2016 -0600 ---------------------------------------------------------------------- .../org/apache/olingo/server/core/MetadataParser.java | 5 +++++ .../apache/olingo/server/core/MetadataParserTest.java | 7 ++++++- .../src/test/resources/skip-annotation.xml | 12 ++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c86009a2/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/MetadataParser.java ---------------------------------------------------------------------- diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/MetadataParser.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/MetadataParser.java index c47aa52..03359f5 100644 --- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/MetadataParser.java +++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/MetadataParser.java @@ -1140,7 +1140,12 @@ public class MetadataParser { XMLEvent event = reader.peek(); if (!parseAnnotations) { + XMLEvent eventBefore = event; event = skipAnnotations(reader, event); + // if annotation is stripped start again + if (eventBefore != event) { + continue; + } } if (!event.isStartElement() && !event.isEndElement()) { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c86009a2/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/MetadataParserTest.java ---------------------------------------------------------------------- diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/MetadataParserTest.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/MetadataParserTest.java index 8afe5d2..97ae420 100644 --- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/MetadataParserTest.java +++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/MetadataParserTest.java @@ -180,6 +180,11 @@ public class MetadataParserTest { assertEquals(6, bindings.size()); assertEquals("Microsoft.OData.SampleService.Models.TripPin.Flight/From", bindings.get(2).getPath()); assertEquals("Airports", bindings.get(2).getTarget()); - } + + @Test + public void testParsingWithNoFormat() throws Exception { + MetadataParser parser = new MetadataParser(); + provider = (CsdlEdmProvider) parser.buildEdmProvider(new FileReader("src/test/resources/skip-annotation.xml")); + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c86009a2/lib/server-core-ext/src/test/resources/skip-annotation.xml ---------------------------------------------------------------------- diff --git a/lib/server-core-ext/src/test/resources/skip-annotation.xml b/lib/server-core-ext/src/test/resources/skip-annotation.xml new file mode 100644 index 0000000..24ddbcf --- /dev/null +++ b/lib/server-core-ext/src/test/resources/skip-annotation.xml @@ -0,0 +1,12 @@ +<?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. --> +<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="Microsoft.OData.SampleService.Models.TripPin" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="Photo" HasStream="true"><Key><PropertyRef Name="Id" /></Key><Property Name="Id" Type="Edm.Int64" Nullable="false"><Annotation Term="Org.OData.Core.V1.Permissions"><EnumMember>Org.OData.Core.V1.Permission/Read</EnumMember></Annotation></Property><Property Name="Name" Type="Edm.String" /><Annotation Term="Org.OData.Core.V1.AcceptableMediaTypes"><Collection><String>image/jpeg</String></Collection></Annotation></EntityType><EntityContainer Name="DefaultContainer"><EntitySet Name="Photos" EntityType="Microsoft.OData.SampleService.Models.TripPin.Photo"><Annotation Term="Org.OData.Core.V1.ResourcePath" String="Photos" /><Annotation Term="Org.OData.Capabilities.V1.SearchRestrictions"><Record><PropertyValue Property="Searchable" Bool="true" /><PropertyValue Property= "UnsupportedExpressions"><EnumMember>Org.OData.Capabilities.V1.SearchExpressions/none</EnumMember></PropertyValue></Record></Annotation><Annotation Term="Org.OData.Capabilities.V1.InsertRestrictions"><Record><PropertyValue Property="Insertable" Bool="true" /><PropertyValue Property="NonInsertableNavigationProperties"><Collection /></PropertyValue></Record></Annotation></EntitySet></EntityContainer></Schema></edmx:DataServices></edmx:Edmx> \ No newline at end of file
