@Test public void writeServiceDocumentWithOneEnitySetTwoContainersTwoSchemas() throws Exception { List<EntitySet> entitySets = new ArrayList<EntitySet>(); entitySets.add(new EntitySet().setName("Employees")); List<EntityContainer> entityContainers = new ArrayList<EntityContainer>(); entityContainers.add(new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets( entitySets)); entityContainers.add(new EntityContainer().setDefaultEntityContainer(false).setName("Container2").setEntitySets( entitySets)); List<EntityContainer> entityContainers2 = new ArrayList<EntityContainer>(); entityContainers2.add(new EntityContainer().setDefaultEntityContainer(false).setName("Container3").setEntitySets( entitySets)); entityContainers2.add(new EntityContainer().setDefaultEntityContainer(false).setName("Container4").setEntitySets( entitySets)); schemas.add(new Schema().setEntityContainers(entityContainers)); schemas.add(new Schema().setEntityContainers(entityContainers2)); ODataResponse response = new AtomEntityProvider().writeServiceDocument(edm, "http: String xmlString = verifyResponse(response); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString); assertXpathEvaluatesTo("Employees", "/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString); assertXpathEvaluatesTo("Employees", "/a:service/a:workspace/a:collection[@href='Container2.Employees']/atom:title", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString); assertXpathEvaluatesTo("Employees", "/a:service/a:workspace/a:collection[@href='Container3.Employees']/atom:title", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString); assertXpathEvaluatesTo("Employees", "/a:service/a:workspace/a:collection[@href='Container4.Employees']/atom:title", xmlString); }
public void writeServiceDocument(final Writer writer) throws EntityProviderException { EdmServiceMetadata serviceMetadata = edm.getServiceMetadata(); try { XMLStreamWriter xmlStreamWriter = XmlHelper.getXMLOutputFactory().createXMLStreamWriter(writer); xmlStreamWriter.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); xmlStreamWriter.setPrefix(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998); xmlStreamWriter.setPrefix(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005); xmlStreamWriter.setDefaultNamespace(Edm.NAMESPACE_APP_2007); xmlStreamWriter.writeStartElement(FormatXml.APP_SERVICE); xmlStreamWriter.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, FormatXml.XML_BASE, serviceRoot); xmlStreamWriter.writeDefaultNamespace(Edm.NAMESPACE_APP_2007); xmlStreamWriter.writeNamespace(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005); xmlStreamWriter.writeStartElement(FormatXml.APP_WORKSPACE); xmlStreamWriter.writeStartElement(Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_TITLE); xmlStreamWriter.writeCharacters(FormatXml.ATOM_TITLE_DEFAULT); xmlStreamWriter.writeEndElement(); List<EdmEntitySetInfo> entitySetInfos = serviceMetadata.getEntitySetInfos(); for (EdmEntitySetInfo info : entitySetInfos) { xmlStreamWriter.writeStartElement(FormatXml.APP_COLLECTION); xmlStreamWriter.writeAttribute(FormatXml.ATOM_HREF, info.getEntitySetUri().toASCIIString()); xmlStreamWriter.writeStartElement(Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_TITLE); xmlStreamWriter.writeCharacters(info.getEntitySetName()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndDocument(); xmlStreamWriter.flush(); } catch (FactoryConfigurationError e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } catch (XMLStreamException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } catch (EdmException e) { throw new EntityProviderProducerException(e.getMessageReference(), e); } catch (ODataException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } }
AtomServiceDocumentProducer { public void writeServiceDocument(final Writer writer) throws EntityProviderException { EdmServiceMetadata serviceMetadata = edm.getServiceMetadata(); try { XMLStreamWriter xmlStreamWriter = XmlHelper.getXMLOutputFactory().createXMLStreamWriter(writer); xmlStreamWriter.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); xmlStreamWriter.setPrefix(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998); xmlStreamWriter.setPrefix(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005); xmlStreamWriter.setDefaultNamespace(Edm.NAMESPACE_APP_2007); xmlStreamWriter.writeStartElement(FormatXml.APP_SERVICE); xmlStreamWriter.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, FormatXml.XML_BASE, serviceRoot); xmlStreamWriter.writeDefaultNamespace(Edm.NAMESPACE_APP_2007); xmlStreamWriter.writeNamespace(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005); xmlStreamWriter.writeStartElement(FormatXml.APP_WORKSPACE); xmlStreamWriter.writeStartElement(Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_TITLE); xmlStreamWriter.writeCharacters(FormatXml.ATOM_TITLE_DEFAULT); xmlStreamWriter.writeEndElement(); List<EdmEntitySetInfo> entitySetInfos = serviceMetadata.getEntitySetInfos(); for (EdmEntitySetInfo info : entitySetInfos) { xmlStreamWriter.writeStartElement(FormatXml.APP_COLLECTION); xmlStreamWriter.writeAttribute(FormatXml.ATOM_HREF, info.getEntitySetUri().toASCIIString()); xmlStreamWriter.writeStartElement(Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_TITLE); xmlStreamWriter.writeCharacters(info.getEntitySetName()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndDocument(); xmlStreamWriter.flush(); } catch (FactoryConfigurationError e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } catch (XMLStreamException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } catch (EdmException e) { throw new EntityProviderProducerException(e.getMessageReference(), e); } catch (ODataException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } } }
AtomServiceDocumentProducer { public void writeServiceDocument(final Writer writer) throws EntityProviderException { EdmServiceMetadata serviceMetadata = edm.getServiceMetadata(); try { XMLStreamWriter xmlStreamWriter = XmlHelper.getXMLOutputFactory().createXMLStreamWriter(writer); xmlStreamWriter.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); xmlStreamWriter.setPrefix(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998); xmlStreamWriter.setPrefix(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005); xmlStreamWriter.setDefaultNamespace(Edm.NAMESPACE_APP_2007); xmlStreamWriter.writeStartElement(FormatXml.APP_SERVICE); xmlStreamWriter.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, FormatXml.XML_BASE, serviceRoot); xmlStreamWriter.writeDefaultNamespace(Edm.NAMESPACE_APP_2007); xmlStreamWriter.writeNamespace(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005); xmlStreamWriter.writeStartElement(FormatXml.APP_WORKSPACE); xmlStreamWriter.writeStartElement(Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_TITLE); xmlStreamWriter.writeCharacters(FormatXml.ATOM_TITLE_DEFAULT); xmlStreamWriter.writeEndElement(); List<EdmEntitySetInfo> entitySetInfos = serviceMetadata.getEntitySetInfos(); for (EdmEntitySetInfo info : entitySetInfos) { xmlStreamWriter.writeStartElement(FormatXml.APP_COLLECTION); xmlStreamWriter.writeAttribute(FormatXml.ATOM_HREF, info.getEntitySetUri().toASCIIString()); xmlStreamWriter.writeStartElement(Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_TITLE); xmlStreamWriter.writeCharacters(info.getEntitySetName()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndDocument(); xmlStreamWriter.flush(); } catch (FactoryConfigurationError e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } catch (XMLStreamException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } catch (EdmException e) { throw new EntityProviderProducerException(e.getMessageReference(), e); } catch (ODataException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } } AtomServiceDocumentProducer(final Edm edm, final String serviceRoot); }
AtomServiceDocumentProducer { public void writeServiceDocument(final Writer writer) throws EntityProviderException { EdmServiceMetadata serviceMetadata = edm.getServiceMetadata(); try { XMLStreamWriter xmlStreamWriter = XmlHelper.getXMLOutputFactory().createXMLStreamWriter(writer); xmlStreamWriter.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); xmlStreamWriter.setPrefix(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998); xmlStreamWriter.setPrefix(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005); xmlStreamWriter.setDefaultNamespace(Edm.NAMESPACE_APP_2007); xmlStreamWriter.writeStartElement(FormatXml.APP_SERVICE); xmlStreamWriter.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, FormatXml.XML_BASE, serviceRoot); xmlStreamWriter.writeDefaultNamespace(Edm.NAMESPACE_APP_2007); xmlStreamWriter.writeNamespace(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005); xmlStreamWriter.writeStartElement(FormatXml.APP_WORKSPACE); xmlStreamWriter.writeStartElement(Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_TITLE); xmlStreamWriter.writeCharacters(FormatXml.ATOM_TITLE_DEFAULT); xmlStreamWriter.writeEndElement(); List<EdmEntitySetInfo> entitySetInfos = serviceMetadata.getEntitySetInfos(); for (EdmEntitySetInfo info : entitySetInfos) { xmlStreamWriter.writeStartElement(FormatXml.APP_COLLECTION); xmlStreamWriter.writeAttribute(FormatXml.ATOM_HREF, info.getEntitySetUri().toASCIIString()); xmlStreamWriter.writeStartElement(Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_TITLE); xmlStreamWriter.writeCharacters(info.getEntitySetName()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndDocument(); xmlStreamWriter.flush(); } catch (FactoryConfigurationError e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } catch (XMLStreamException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } catch (EdmException e) { throw new EntityProviderProducerException(e.getMessageReference(), e); } catch (ODataException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } } AtomServiceDocumentProducer(final Edm edm, final String serviceRoot); void writeServiceDocument(final Writer writer); }
AtomServiceDocumentProducer { public void writeServiceDocument(final Writer writer) throws EntityProviderException { EdmServiceMetadata serviceMetadata = edm.getServiceMetadata(); try { XMLStreamWriter xmlStreamWriter = XmlHelper.getXMLOutputFactory().createXMLStreamWriter(writer); xmlStreamWriter.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); xmlStreamWriter.setPrefix(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998); xmlStreamWriter.setPrefix(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005); xmlStreamWriter.setDefaultNamespace(Edm.NAMESPACE_APP_2007); xmlStreamWriter.writeStartElement(FormatXml.APP_SERVICE); xmlStreamWriter.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, FormatXml.XML_BASE, serviceRoot); xmlStreamWriter.writeDefaultNamespace(Edm.NAMESPACE_APP_2007); xmlStreamWriter.writeNamespace(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005); xmlStreamWriter.writeStartElement(FormatXml.APP_WORKSPACE); xmlStreamWriter.writeStartElement(Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_TITLE); xmlStreamWriter.writeCharacters(FormatXml.ATOM_TITLE_DEFAULT); xmlStreamWriter.writeEndElement(); List<EdmEntitySetInfo> entitySetInfos = serviceMetadata.getEntitySetInfos(); for (EdmEntitySetInfo info : entitySetInfos) { xmlStreamWriter.writeStartElement(FormatXml.APP_COLLECTION); xmlStreamWriter.writeAttribute(FormatXml.ATOM_HREF, info.getEntitySetUri().toASCIIString()); xmlStreamWriter.writeStartElement(Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_TITLE); xmlStreamWriter.writeCharacters(info.getEntitySetName()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndDocument(); xmlStreamWriter.flush(); } catch (FactoryConfigurationError e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } catch (XMLStreamException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } catch (EdmException e) { throw new EntityProviderProducerException(e.getMessageReference(), e); } catch (ODataException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } } AtomServiceDocumentProducer(final Edm edm, final String serviceRoot); void writeServiceDocument(final Writer writer);  }