@Test public void testProperties() throws EntityProviderException, XMLStreamException, EdmException, UnsupportedEncodingException { XmlMetadataDeserializer parser = new XmlMetadataDeserializer(); InputStream reader = createStreamReader(xmlWithTwoSchemas); EdmDataServices result = parser.readMetadata(reader, true); for (EdmSchema schema : result.getEdm().getSchemas()) { for (EdmEntityType entityType : schema.getEntityTypes()) { if ("Employee".equals(entityType.getName())) { for (String name : entityType.getPropertyNames()) { EdmProperty property = (EdmProperty)(entityType.getProperty(name)); if (propertyNames[0].equals(name)) { assertNotNull(property.getFacets()); assertEquals(Boolean.FALSE, property.getFacets().isNullable()); } else if (propertyNames[1].equals(name)) { assertNull(property.getFacets()); } } } else if ("Photo".equals(entityType.getName())) { for (String name : entityType.getPropertyNames()) { EdmProperty sProperty = (EdmProperty) entityType.getProperty(name); if ("Id".equals(sProperty.getName())) { assertEquals(Boolean.FALSE, sProperty.getFacets().isNullable()); assertEquals(EdmConcurrencyMode.Fixed, sProperty.getFacets().getConcurrencyMode()); assertEquals(new Integer(MAX_LENGTH), sProperty.getFacets().getMaxLength()); assertTrue(sProperty.isSimple()); assertEquals(EdmSimpleTypeKind.Int32.toString(), sProperty.getType().getName()); assertNull(sProperty.getCustomizableFeedMappings()); } if ("Name".equals(sProperty.getName())) { assertEquals(Boolean.TRUE, sProperty.getFacets().isUnicode()); assertEquals(DEFAULT_VALUE, sProperty.getFacets().getDefaultValue()); assertEquals(Boolean.FALSE, sProperty.getFacets().isFixedLength()); assertEquals(EdmSimpleTypeKind.String.name(), sProperty.getType().getName()); assertNull(sProperty.getCustomizableFeedMappings()); } if ("Содержание".equals(sProperty.getName())) { assertEquals(FC_TARGET_PATH, sProperty.getCustomizableFeedMappings().getFcTargetPath()); assertEquals(FC_NS_URI, sProperty.getCustomizableFeedMappings().getFcNsUri()); assertEquals(FC_NS_PREFIX, sProperty.getCustomizableFeedMappings().getFcNsPrefix()); assertEquals(FC_KEEP_IN_CONTENT, sProperty.getCustomizableFeedMappings().isFcKeepInContent()); assertEquals(EdmContentKind.text, sProperty.getCustomizableFeedMappings().getFcContentKind()); } if ("BinaryData".equals(sProperty.getName())) { assertEquals(MIME_TYPE, sProperty.getMimeType()); } } } } } }
public EdmDataServices readMetadata(final InputStream content, final boolean validate) throws EntityProviderException, EdmException { try { initialize(); EdmDataServices dataServices = new EdmDataServices(); List<EdmSchema> schemas = new ArrayList<EdmSchema>(); EdmImpl edm = new EdmImpl(); XMLStreamReader reader = XmlHelper.createStreamReader(content); while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) { edmNamespace = reader.getNamespaceURI(); checkEdmNamespace(); schemas.add(readSchema(reader, edm)); } else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader .getLocalName())) { dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion")); } } } if (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } setBaseTypeForEntityType(); setBaseTypeForComplexType(); setDetailsForEntitySet(); setAssociationSetForNavigations(); if (validate) { validate(); } edm.setEdmSchemas(schemas); dataServices.setClientEdm(edm); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
XmlMetadataDeserializer { public EdmDataServices readMetadata(final InputStream content, final boolean validate) throws EntityProviderException, EdmException { try { initialize(); EdmDataServices dataServices = new EdmDataServices(); List<EdmSchema> schemas = new ArrayList<EdmSchema>(); EdmImpl edm = new EdmImpl(); XMLStreamReader reader = XmlHelper.createStreamReader(content); while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) { edmNamespace = reader.getNamespaceURI(); checkEdmNamespace(); schemas.add(readSchema(reader, edm)); } else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader .getLocalName())) { dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion")); } } } if (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } setBaseTypeForEntityType(); setBaseTypeForComplexType(); setDetailsForEntitySet(); setAssociationSetForNavigations(); if (validate) { validate(); } edm.setEdmSchemas(schemas); dataServices.setClientEdm(edm); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } } }
XmlMetadataDeserializer { public EdmDataServices readMetadata(final InputStream content, final boolean validate) throws EntityProviderException, EdmException { try { initialize(); EdmDataServices dataServices = new EdmDataServices(); List<EdmSchema> schemas = new ArrayList<EdmSchema>(); EdmImpl edm = new EdmImpl(); XMLStreamReader reader = XmlHelper.createStreamReader(content); while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) { edmNamespace = reader.getNamespaceURI(); checkEdmNamespace(); schemas.add(readSchema(reader, edm)); } else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader .getLocalName())) { dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion")); } } } if (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } setBaseTypeForEntityType(); setBaseTypeForComplexType(); setDetailsForEntitySet(); setAssociationSetForNavigations(); if (validate) { validate(); } edm.setEdmSchemas(schemas); dataServices.setClientEdm(edm); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  }
XmlMetadataDeserializer { public EdmDataServices readMetadata(final InputStream content, final boolean validate) throws EntityProviderException, EdmException { try { initialize(); EdmDataServices dataServices = new EdmDataServices(); List<EdmSchema> schemas = new ArrayList<EdmSchema>(); EdmImpl edm = new EdmImpl(); XMLStreamReader reader = XmlHelper.createStreamReader(content); while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) { edmNamespace = reader.getNamespaceURI(); checkEdmNamespace(); schemas.add(readSchema(reader, edm)); } else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader .getLocalName())) { dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion")); } } } if (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } setBaseTypeForEntityType(); setBaseTypeForComplexType(); setDetailsForEntitySet(); setAssociationSetForNavigations(); if (validate) { validate(); } edm.setEdmSchemas(schemas); dataServices.setClientEdm(edm); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  EdmDataServices readMetadata(final InputStream content, final boolean validate); }
XmlMetadataDeserializer { public EdmDataServices readMetadata(final InputStream content, final boolean validate) throws EntityProviderException, EdmException { try { initialize(); EdmDataServices dataServices = new EdmDataServices(); List<EdmSchema> schemas = new ArrayList<EdmSchema>(); EdmImpl edm = new EdmImpl(); XMLStreamReader reader = XmlHelper.createStreamReader(content); while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) { edmNamespace = reader.getNamespaceURI(); checkEdmNamespace(); schemas.add(readSchema(reader, edm)); } else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader .getLocalName())) { dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion")); } } } if (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } setBaseTypeForEntityType(); setBaseTypeForComplexType(); setDetailsForEntitySet(); setAssociationSetForNavigations(); if (validate) { validate(); } edm.setEdmSchemas(schemas); dataServices.setClientEdm(edm); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  EdmDataServices readMetadata(final InputStream content, final boolean validate);  }