@SuppressWarnings("unchecked") @Test public void testReadFeed() throws Exception { EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"); String content = readFile("feed_employees.xml"); InputStream contentAsStream = createContentAsStream(content); EntityStream stream = new EntityStream(); stream.setContent(contentAsStream); stream.setReadProperties(DeserializerProperties.init().build()); XmlEntityDeserializer xec = new XmlEntityDeserializer(); ODataFeed feedResult = xec.readFeed(entitySet, stream); FeedMetadata metadata = feedResult.getFeedMetadata(); assertNull(metadata.getInlineCount()); assertNull(metadata.getNextLink()); assertNull(metadata.getDeltaLink()); List<ODataEntry> entries = feedResult.getEntries(); assertEquals(6, entries.size()); ODataEntry firstEmployee = entries.get(0); Map<String, Object> properties = firstEmployee.getProperties(); assertEquals(9, properties.size()); assertEquals("1", properties.get("EmployeeId")); assertEquals("Walter Winter", properties.get("EmployeeName")); assertEquals("1", properties.get("ManagerId")); assertEquals("1", properties.get("RoomId")); assertEquals("1", properties.get("TeamId")); Map<String, Object> location = (Map<String, Object>) properties.get("Location"); assertEquals(2, location.size()); assertEquals("Germany", location.get("Country")); Map<String, Object> city = (Map<String, Object>) location.get("City"); assertEquals(2, city.size()); assertEquals("69124", city.get("PostalCode")); assertEquals("Heidelberg", city.get("CityName")); assertEquals(Integer.valueOf(52), properties.get("Age")); Calendar entryDate = (Calendar) properties.get("EntryDate"); assertEquals(915148800000L, entryDate.getTimeInMillis()); assertEquals(TimeZone.getTimeZone("GMT"), entryDate.getTimeZone()); assertEquals("Employees('1')/$value", properties.get("ImageUrl")); }
public ODataDeltaFeed readFeed(final EdmEntitySet entitySet, final EntityStream entity) throws EntityProviderException { XMLStreamReader reader = null; EntityProviderException cachedException = null; try { reader = XmlHelper.createStreamReader(entity.getContent()); EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet); XmlFeedDeserializer xfc = new XmlFeedDeserializer(); return xfc.readFeed(reader, eia, entity.getReadProperties()); } catch (EntityProviderException e) { cachedException = e; throw cachedException; } finally { if (reader != null) { try { reader.close(); } catch (XMLStreamException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED. addContent(e.getClass() .getSimpleName()), e); } } } } }
XmlEntityDeserializer { public ODataDeltaFeed readFeed(final EdmEntitySet entitySet, final EntityStream entity) throws EntityProviderException { XMLStreamReader reader = null; EntityProviderException cachedException = null; try { reader = XmlHelper.createStreamReader(entity.getContent()); EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet); XmlFeedDeserializer xfc = new XmlFeedDeserializer(); return xfc.readFeed(reader, eia, entity.getReadProperties()); } catch (EntityProviderException e) { cachedException = e; throw cachedException; } finally { if (reader != null) { try { reader.close(); } catch (XMLStreamException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED. addContent(e.getClass() .getSimpleName()), e); } } } } } }
XmlEntityDeserializer { public ODataDeltaFeed readFeed(final EdmEntitySet entitySet, final EntityStream entity) throws EntityProviderException { XMLStreamReader reader = null; EntityProviderException cachedException = null; try { reader = XmlHelper.createStreamReader(entity.getContent()); EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet); XmlFeedDeserializer xfc = new XmlFeedDeserializer(); return xfc.readFeed(reader, eia, entity.getReadProperties()); } catch (EntityProviderException e) { cachedException = e; throw cachedException; } finally { if (reader != null) { try { reader.close(); } catch (XMLStreamException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED. addContent(e.getClass() .getSimpleName()), e); } } } } } XmlEntityDeserializer(); }
XmlEntityDeserializer { public ODataDeltaFeed readFeed(final EdmEntitySet entitySet, final EntityStream entity) throws EntityProviderException { XMLStreamReader reader = null; EntityProviderException cachedException = null; try { reader = XmlHelper.createStreamReader(entity.getContent()); EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet); XmlFeedDeserializer xfc = new XmlFeedDeserializer(); return xfc.readFeed(reader, eia, entity.getReadProperties()); } catch (EntityProviderException e) { cachedException = e; throw cachedException; } finally { if (reader != null) { try { reader.close(); } catch (XMLStreamException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED. addContent(e.getClass() .getSimpleName()), e); } } } } } XmlEntityDeserializer(); ODataDeltaFeed readFeed(final EdmEntitySet entitySet, final EntityStream entity); ODataEntry readEntry(final EdmEntitySet entitySet, final EntityStream entity); Object readCollection(final EntityPropertyInfo info, EntityStream entityStream); Map<String, Object> readProperty(final EntityPropertyInfo propertyInfo, final EntityStream entityStream); }
XmlEntityDeserializer { public ODataDeltaFeed readFeed(final EdmEntitySet entitySet, final EntityStream entity) throws EntityProviderException { XMLStreamReader reader = null; EntityProviderException cachedException = null; try { reader = XmlHelper.createStreamReader(entity.getContent()); EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet); XmlFeedDeserializer xfc = new XmlFeedDeserializer(); return xfc.readFeed(reader, eia, entity.getReadProperties()); } catch (EntityProviderException e) { cachedException = e; throw cachedException; } finally { if (reader != null) { try { reader.close(); } catch (XMLStreamException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED. addContent(e.getClass() .getSimpleName()), e); } } } } } XmlEntityDeserializer(); ODataDeltaFeed readFeed(final EdmEntitySet entitySet, final EntityStream entity); ODataEntry readEntry(final EdmEntitySet entitySet, final EntityStream entity); Object readCollection(final EntityPropertyInfo info, EntityStream entityStream); Map<String, Object> readProperty(final EntityPropertyInfo propertyInfo, final EntityStream entityStream);  }