Repository: olingo-odata4
Updated Branches:
  refs/heads/master 2fbab6524 -> 096946a70


improved server metadata and tests

Change-Id: I8d69c68a83aec32c03d15fceb3b6a2a204730ff7

Signed-off-by: Michael Bolz <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/096946a7
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/096946a7
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/096946a7

Branch: refs/heads/master
Commit: 096946a70dc0dd22825c06d22d5aac2f6efe66bc
Parents: 2fbab65
Author: Klaus Straubinger <[email protected]>
Authored: Thu Oct 16 13:48:56 2014 +0200
Committer: Michael Bolz <[email protected]>
Committed: Thu Oct 16 13:55:36 2014 +0200

----------------------------------------------------------------------
 .../olingo/fit/AbstractBaseTestITCase.java      |   1 -
 .../olingo/fit/tecsvc/client/BasicITCase.java   |  93 ++--
 fit/src/test/resources/metadata-ref.xml         | 123 -----
 .../retrieve/v4/XMLMetadataRequestImpl.java     |  31 +-
 .../xml/MetadataDocumentXmlSerializerTest.java  | 186 ++++++++
 .../olingo/server/tecsvc/TechnicalServlet.java  |  11 +-
 .../server/tecsvc/data/model/EtAllPrim.java     | 188 --------
 .../server/tecsvc/data/model/EtTwoPrim.java     |  62 ---
 .../serializer/xml/MetadataDocumentTest.java    | 463 ++++---------------
 9 files changed, 365 insertions(+), 793 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/096946a7/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java 
b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
index bda92d4..21dcce1 100644
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@ -59,7 +59,6 @@ public abstract class AbstractBaseTestITCase {
         .addServlet(TechnicalServlet.class, "/odata-server-tecsvc/odata.svc/*")
         .addServlet(StaticContent.create("org-odata-core-v1.xml"),
             
"/odata-server-tecsvc/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml")
-        .addServlet(StaticContent.create("metadata-ref.xml"), 
"/odata-metadata/$metadata")
         .addWebApp(false)
         .start();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/096946a7/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java 
b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index ef1d3e4..dc34f65 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -29,6 +29,7 @@ import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.io.IOUtils;
@@ -39,23 +40,28 @@ import 
org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
 import 
org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
 import 
org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
 import 
org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
+import 
org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
 import 
org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
 import 
org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.client.api.edm.xml.v4.Reference;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.ODataClientFactory;
 import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
 import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.domain.v4.ODataValue;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.fit.AbstractBaseTestITCase;
 import org.apache.olingo.fit.tecsvc.TecSvcConst;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class BasicITCase extends AbstractBaseTestITCase {
@@ -90,15 +96,16 @@ public class BasicITCase extends AbstractBaseTestITCase {
     Edm edm = response.getBody();
 
     assertNotNull(edm);
+    assertEquals(2, edm.getSchemas().size());
     assertEquals("olingo.odata.test1", 
edm.getSchema("olingo.odata.test1").getNamespace());
     assertEquals("Namespace1_Alias", 
edm.getSchema("olingo.odata.test1").getAlias());
-    assertEquals(1, edm.getSchemas().size());
+    assertEquals("Org.OData.Core.V1", 
edm.getSchema("Org.OData.Core.V1").getNamespace());
+    assertEquals("Core", edm.getSchema("Org.OData.Core.V1").getAlias());
   }
 
   @Test
   public void readViaXmlMetadata() {
-    XMLMetadataRequest request = getClient().getRetrieveRequestFactory()
-        
.getXMLMetadataRequest(SERVICE_URI.replace("odata-server-tecsvc/odata.svc", 
"odata-metadata"));
+    XMLMetadataRequest request = 
getClient().getRetrieveRequestFactory().getXMLMetadataRequest(SERVICE_URI);
     assertNotNull(request);
 
     ODataRetrieveResponse<XMLMetadata> response = request.execute();
@@ -108,9 +115,12 @@ public class BasicITCase extends AbstractBaseTestITCase {
 
     assertNotNull(xmlMetadata);
     assertTrue(xmlMetadata instanceof 
org.apache.olingo.client.api.edm.xml.v4.XMLMetadata);
-    assertEquals("ODataDemo", 
xmlMetadata.getSchema("ODataDemo").getNamespace());
-    assertEquals(1, ((org.apache.olingo.client.api.edm.xml.v4.XMLMetadata) 
xmlMetadata).getReferences().size());
     assertEquals(2, xmlMetadata.getSchemas().size());
+    assertEquals("olingo.odata.test1", 
xmlMetadata.getSchema("olingo.odata.test1").getNamespace());
+    final List<Reference> references =
+        ((org.apache.olingo.client.api.edm.xml.v4.XMLMetadata) 
xmlMetadata).getReferences();
+    assertEquals(1, references.size());
+    assertThat(references.get(0).getUri().toASCIIString(), 
containsString("vocabularies/Org.OData.Core.V1"));
   }
 
   @Test
@@ -160,8 +170,9 @@ public class BasicITCase extends AbstractBaseTestITCase {
     }
   }
 
+  @Ignore("wrong value type!")
   @Test
-  public void readEntityRawResult() throws IOException {
+  public void readEntity() throws IOException {
     final ODataEntityRequest<ODataEntity> request = 
getClient().getRetrieveRequestFactory()
         .getEntityRequest(getClient().newURIBuilder(SERVICE_URI)
             
.appendEntitySetSegment("ESCollAllPrim").appendKeySegment(1).build());
@@ -171,33 +182,18 @@ public class BasicITCase extends AbstractBaseTestITCase {
     assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     assertThat(response.getContentType(), 
containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
 
-    //
-    final String expectedResult = "{"
-        + "\"@odata.context\":\"$metadata#ESCollAllPrim/$entity\","
-        + "\"PropertyInt16\":1,"
-        + "\"CollPropertyString\":"
-        + 
"[\"[email protected]\",\"[email protected]\",\"[email protected]\"],"
-        + "\"CollPropertyBoolean\":[true,false,true],"
-        + "\"CollPropertyByte\":[50,200,249],"
-        + "\"CollPropertySByte\":[-120,120,126],"
-        + "\"CollPropertyInt16\":[1000,2000,30112],"
-        + "\"CollPropertyInt32\":[23232323,11223355,10000001],"
-        + "\"CollPropertyInt64\":[929292929292,333333333333,444444444444],"
-        + "\"CollPropertySingle\":[1790.0,26600.0,3210.0],"
-        + "\"CollPropertyDouble\":[-17900.0,-2.78E7,3210.0],"
-        + "\"CollPropertyDecimal\":[12,-2,1234],"
-        + "\"CollPropertyBinary\":[\"q83v\",\"ASNF\",\"VGeJ\"],"
-        + 
"\"CollPropertyDate\":[\"1958-12-03\",\"1999-08-05\",\"2013-06-25\"],"
-        + 
"\"CollPropertyDateTimeOffset\":[\"2015-08-12T03:08:34Z\",\"1970-03-28T12:11:10Z\","
-        + "\"1948-02-17T09:09:09Z\"],"
-        + "\"CollPropertyDuration\":[\"PT13S\",\"PT5H28M0S\",\"PT1H0S\"],"
-        + 
"\"CollPropertyGuid\":[\"ffffff67-89ab-cdef-0123-456789aaaaaa\",\"eeeeee67-89ab-cdef-0123-456789bbbbbb\","
-        + "\"cccccc67-89ab-cdef-0123-456789cccccc\"],"
-        + "\"CollPropertyTimeOfDay\":[\"04:14:13\",\"23:59:59\",\"01:12:33\"]"
-        + "}";
-    assertEquals(expectedResult, IOUtils.toString(response.getRawResponse(), 
"UTF-8"));
+    final ODataEntity entity = response.getBody();
+    assertNotNull(entity);
+    final ODataProperty property = entity.getProperty("CollPropertyInt16");
+    assertNotNull(property);
+    assertNotNull(property.getCollectionValue());
+    assertEquals(3, property.getCollectionValue().size());
+    Iterator<ODataValue> iterator = property.getCollectionValue().iterator();
+    assertEquals(1000, iterator.next().asPrimitive().toValue());
+    assertEquals(2000, iterator.next().asPrimitive().toValue());
+    assertEquals(30112, iterator.next().asPrimitive().toValue());
   }
-  
+
   @Test
   public void readSimpleProperty() throws Exception {
     ODataPropertyRequest<ODataProperty> request = 
getClient().getRetrieveRequestFactory()
@@ -251,7 +247,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
     assertNotNull(property.getComplexValue());
     assertEquals("TEST B", 
property.getComplexValue().get("PropertyString").getPrimitiveValue().toValue());
   
   }  
-  
+
   @Test
   public void readComplexPropertyContextURL() throws Exception {
     ODataPropertyRequest<ODataProperty> request = 
getClient().getRetrieveRequestFactory()
@@ -266,19 +262,23 @@ public class BasicITCase extends AbstractBaseTestITCase {
         "\"PropertyInt16\":222,\"PropertyString\":\"TEST B\"}";
     assertEquals(expectedResult, IOUtils.toString(response.getRawResponse(), 
"UTF-8"));    
   }  
-  
-  @Test(expected=ODataClientErrorException.class)
+
+  @Test
   public void readUnknownProperty() throws Exception {
     ODataPropertyRequest<ODataProperty> request = 
getClient().getRetrieveRequestFactory()
         .getPropertyRequest(getClient().newURIBuilder(SERVICE_URI)            
             .appendEntitySetSegment("ESTwoPrim")
             .appendKeySegment(32766)
             .appendPropertySegment("Unknown")
-            .build());    
-    ODataRetrieveResponse<ODataProperty> response = request.execute();
-    assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), 
response.getStatusCode());
-  }   
-  
+            .build());
+    try {
+     request.execute();
+     fail("Expected exception not thrown!");
+    } catch (final ODataClientErrorException e) {
+      assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), 
e.getStatusLine().getStatusCode());
+    }
+  }
+
   @Test
   public void readNoContentProperty() throws Exception {
     ODataPropertyRequest<ODataProperty> request = 
getClient().getRetrieveRequestFactory()
@@ -290,18 +290,19 @@ public class BasicITCase extends AbstractBaseTestITCase {
     ODataRetrieveResponse<ODataProperty> response = request.execute();
     assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), 
response.getStatusCode());
   }   
-  
+
+  @Ignore("Content Negotiation!")
   @Test
   public void readPropertyValue() throws Exception {
-    ODataPropertyRequest<ODataProperty> request = 
getClient().getRetrieveRequestFactory()
-        .getPropertyRequest(getClient().newURIBuilder(SERVICE_URI)            
+    final ODataValueRequest request = getClient().getRetrieveRequestFactory()
+        .getPropertyValueRequest(getClient().newURIBuilder(SERVICE_URI)        
    
             .appendEntitySetSegment("ESTwoPrim")
             .appendKeySegment(32766)
             .appendPropertySegment("PropertyString")
             .appendValueSegment()
-            .build());    
-    ODataRetrieveResponse<ODataProperty> response = request.execute();
-    assertEquals("Test String1", IOUtils.toString(response.getRawResponse(), 
"UTF-8"));
+            .build());
+    ODataRetrieveResponse<ODataPrimitiveValue> response = request.execute();
+    assertEquals("Test String1", response.getBody().toValue());
   }   
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/096946a7/fit/src/test/resources/metadata-ref.xml
----------------------------------------------------------------------
diff --git a/fit/src/test/resources/metadata-ref.xml 
b/fit/src/test/resources/metadata-ref.xml
deleted file mode 100644
index eed7028..0000000
--- a/fit/src/test/resources/metadata-ref.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-<?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 xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"; Version="4.0">
-  <edmx:Reference 
Uri="http://localhost:9080/odata-server-tecsvc/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml";>
-    <edmx:Include Namespace="Org.OData.Core.V1" Alias="Core"/>
-  </edmx:Reference>
-  <edmx:DataServices>
-    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; 
Namespace="ODataDemo">
-      <TypeDefinition Name="Length" UnderlyingType="Edm.Int32">
-        <Annotation Term="Org.OData.Measures.V1.Unit" String="Centimeters"/>
-      </TypeDefinition>
-      <TypeDefinition Name="Weight" UnderlyingType="Edm.Int32">
-        <Annotation Term="Org.OData.Measures.V1.Unit" String="Kilograms"/>
-      </TypeDefinition>
-      <ComplexType Name="Size">
-        <Property Name="Height" Type="Self.Length" />
-        <Property Name="Weight" Type="Self.Weight" />
-      </ComplexType>
-      <EntityType Name="Product" HasStream="true">
-        <Key>
-          <PropertyRef Name="ID"/>
-        </Key>
-        <Property Name="ID" Type="Edm.Int32" Nullable="false"/>
-        <Property Name="Description" Type="Edm.String">
-          <Annotation Term="Core.IsLanguageDependent"/>
-        </Property>
-        <Property Name="ReleaseDate" Type="Edm.Date"/>
-        <Property Name="DiscontinuedDate" Type="Edm.Date"/>
-        <Property Name="Rating" Type="Edm.Int32"/>
-        <Property Name="Price" Type="Edm.Decimal">
-          <Annotation Term="UoM.ISOCurrency" Path="Currency"/>
-        </Property>
-        <Property Name="Currency" Type="Edm.String" MaxLength="3"/>
-        <NavigationProperty Name="Category" Type="ODataDemo.Category" 
Nullable="false" Partner="Products"/>
-        <NavigationProperty Name="Supplier" Type="ODataDemo.Supplier" 
Partner="Products"/>
-      </EntityType>
-      <EntityType Name="Category">
-        <Key>
-          <PropertyRef Name="ID"/>
-        </Key>
-        <Property Name="ID" Type="Edm.Int32" Nullable="false"/>
-        <Property Name="Name" Type="Edm.String">
-          <Annotation Term="Core.IsLanguageDependent"/>
-        </Property>
-        <NavigationProperty Name="Products" Partner="Category" 
Type="Collection(ODataDemo.Product)">
-          <OnDelete Action="Cascade"/>
-        </NavigationProperty>
-      </EntityType>
-      <EntityType Name="Supplier">
-        <Key>
-          <PropertyRef Name="ID"/>
-        </Key>
-        <Property Name="ID" Type="Edm.String" Nullable="false"/>
-        <Property Name="Name" Type="Edm.String"/>
-        <Property Name="Address" Type="ODataDemo.Address" Nullable="false"/>
-        <Property Name="Concurrency" Type="Edm.Int32" Nullable="false"/>
-        <NavigationProperty Name="Products" Partner="Supplier"/>               
                                                                                
                                                     
Type="Collection(ODataDemo.Product)"/>
-      </EntityType>
-      <EntityType Name="Country">
-        <Key>
-          <PropertyRef Name="Code"/>
-        </Key>
-        <Property Name="Code" Type="Edm.String" MaxLength="2" 
Nullable="false"/>
-        <Property Name="Name" Type="Edm.String"/>
-      </EntityType>
-      <ComplexType Name="Address">
-        <Property Name="Street" Type="Edm.String"/>
-        <Property Name="City" Type="Edm.String"/>
-        <Property Name="State" Type="Edm.String"/>
-        <Property Name="ZipCode" Type="Edm.String"/>
-        <Property Name="CountryName" Type="Edm.String"/>
-        <NavigationProperty Name="Country" Type="ODataDemo.Country">
-          <ReferentialConstraint Property="CountryName" 
ReferencedProperty="Name"/>
-        </NavigationProperty>
-      </ComplexType>
-      <Function Name="ProductsByRating">
-        <Parameter Name="Rating" Type="Edm.Int32"/>
-        <ReturnType Type="Collection(ODataDemo.Product)"/>
-      </Function>
-      <EntityContainer Name="DemoService">
-        <EntitySet Name="Products" EntityType="ODataDemo.Product">
-          <NavigationPropertyBinding Path="Category" Target="Categories"/>
-        </EntitySet>
-        <EntitySet Name="Categories" EntityType="ODataDemo.Category">
-          <NavigationPropertyBinding Path="Products" Target="Products"/>
-        </EntitySet>
-        <EntitySet Name="Suppliers" EntityType="ODataDemo.Supplier">
-          <NavigationPropertyBinding Path="Products" Target="Products"/>
-          <NavigationPropertyBinding Path="Address/Country" 
Target="Countries"/>
-          <Annotation Term="Core.OptimisticConcurrencyControl">
-            <Collection>
-              <PropertyPath>Concurrency</PropertyPath>
-            </Collection>
-          </Annotation>
-        </EntitySet>
-        <Singleton Name="Contoso" Type="Self.Supplier">
-          <NavigationPropertyBinding Path="Products" Target="Products"/>
-        </Singleton>
-        <EntitySet Name="Countries" EntityType="ODataDemo.Country"/>
-        <FunctionImport Name="ProductsByRating" EntitySet="Products" 
Function="ODataDemo.ProductsByRating"/>
-      </EntityContainer>
-    </Schema>
-  </edmx:DataServices>
-</edmx:Edmx>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/096946a7/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
index e725e04..f299732 100644
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
@@ -23,6 +23,7 @@ import java.net.URI;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.olingo.client.api.CommonODataClient;
 import 
org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
 import 
org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
@@ -50,7 +51,7 @@ public class XMLMetadataRequestImpl
 
   @Override
   public 
ODataRetrieveResponse<org.apache.olingo.client.api.edm.xml.XMLMetadata> 
execute() {
-    final SingleXMLMetadatRequestImpl rootReq = new 
SingleXMLMetadatRequestImpl((ODataClient) odataClient, uri);
+    final SingleXMLMetadatRequestImpl rootReq = new 
SingleXMLMetadatRequestImpl((ODataClient) odataClient, uri, null);
     final ODataRetrieveResponse<XMLMetadata> rootRes = rootReq.execute();
 
     final XMLMetadataResponseImpl response =
@@ -59,9 +60,11 @@ public class XMLMetadataRequestImpl
     // process external references
     for (Reference reference : rootRes.getBody().getReferences()) {
       final SingleXMLMetadatRequestImpl includeReq = new 
SingleXMLMetadatRequestImpl(
-              (ODataClient) odataClient, 
odataClient.newURIBuilder(reference.getUri().toASCIIString()).build());
+              (ODataClient) odataClient,
+              
odataClient.newURIBuilder(uri.resolve(reference.getUri()).toASCIIString()).build(),
+              uri);
       final XMLMetadata includeMetadata = includeReq.execute().getBody();
-      
+
       // edmx:Include
       for (Include include : reference.getIncludes()) {
         final Schema includedSchema = 
includeMetadata.getSchema(include.getNamespace());
@@ -116,16 +119,36 @@ public class XMLMetadataRequestImpl
 
   private class SingleXMLMetadatRequestImpl extends 
AbstractMetadataRequestImpl<XMLMetadata> {
 
+    private final URI parentURI;
     private HttpResponse httpResponse;
 
-    public SingleXMLMetadatRequestImpl(final ODataClient odataClient, final 
URI uri) {
+    public SingleXMLMetadatRequestImpl(final ODataClient odataClient, final 
URI uri, final URI parent) {
       super(odataClient, uri);
+      parentURI = parent;
     }
 
     public HttpResponse getHttpResponse() {
       return httpResponse;
     }
 
+    /** Referenced document's URIs must only have the same scheme, host, and 
port as the
+     *  main metadata document's URI but don't have to start with the service 
root
+     *  as all other OData request URIs. */
+    @Override
+    protected void checkRequest(final CommonODataClient<?> odataClient, final 
HttpUriRequest request) {
+      if (parentURI == null) {
+        super.checkRequest(odataClient, request);
+      } else {
+        if (!parentURI.getScheme().equals(uri.getScheme())
+            || !parentURI.getAuthority().equals(uri.getAuthority())) {
+          throw new IllegalArgumentException(
+              String.format("The referenced EDMX document has the URI '%s'"
+                  + " where scheme, host, or port is different from the main 
metadata document URI '%s'.",
+                  uri.toASCIIString(), parentURI.toASCIIString()));
+        }
+      }
+    }
+
     @Override
     public ODataRetrieveResponse<XMLMetadata> execute() {
       httpResponse = doExecute();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/096946a7/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
----------------------------------------------------------------------
diff --git 
a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
 
b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
new file mode 100644
index 0000000..7b778e4
--- /dev/null
+++ 
b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+package org.apache.olingo.server.core.serializer.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
+import org.apache.olingo.server.api.edmx.EdmxReferenceIncludeAnnotation;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class MetadataDocumentXmlSerializerTest {
+
+  private static ODataSerializer serializer;
+
+  @BeforeClass
+  public static void init() throws SerializerException {
+    serializer = OData.newInstance().createSerializer(ODataFormat.XML);
+  }
+
+  @Test
+  public void writeMetadataWithEmptyMockedEdm() throws Exception {
+    final Edm edm = mock(Edm.class);
+    ServiceMetadata metadata = mock(ServiceMetadata.class);
+    when(metadata.getEdm()).thenReturn(edm);
+
+    assertEquals("<?xml version='1.0' encoding='UTF-8'?>"
+        + "<edmx:Edmx Version=\"4.0\" 
xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\";>"
+        + "<edmx:DataServices/></edmx:Edmx>",
+        IOUtils.toString(serializer.metadataDocument(metadata)));
+  }
+
+  /** Writes simplest (empty) Schema. */
+  @Test
+  public void writeMetadataWithEmptySchema() throws Exception {
+    EdmSchema schema = mock(EdmSchema.class);
+    when(schema.getNamespace()).thenReturn("MyNamespace");
+    Edm edm = mock(Edm.class);
+    when(edm.getSchemas()).thenReturn(Arrays.asList(schema));
+    ServiceMetadata serviceMetadata = mock(ServiceMetadata.class);
+    when(serviceMetadata.getEdm()).thenReturn(edm);
+
+    InputStream metadata = serializer.metadataDocument(serviceMetadata);
+    assertNotNull(metadata);
+    assertEquals("<?xml version='1.0' encoding='UTF-8'?>" +
+        "<edmx:Edmx Version=\"4.0\" 
xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\";>" +
+          "<edmx:DataServices>" +
+            "<Schema xmlns=\"http://docs.oasis-open.org/odata/ns/edm\"; 
Namespace=\"MyNamespace\"/>" +
+          "</edmx:DataServices>" +
+        "</edmx:Edmx>",
+        IOUtils.toString(metadata));
+  }
+
+  @Test
+  public void writeEdmxWithLocalTestEdm() throws Exception {
+    List<EdmxReference> edmxReferences = new ArrayList<EdmxReference>();
+    EdmxReference reference = new 
EdmxReference(URI.create("http://example.com";));
+    edmxReferences.add(reference);
+
+    EdmxReference referenceWithInclude = new EdmxReference(
+            
URI.create("http://localhost/odata/odata/v4.0/referenceWithInclude";));
+    EdmxReferenceInclude include = new 
EdmxReferenceInclude("Org.OData.Core.V1", "Core");
+    referenceWithInclude.addInclude(include);
+    edmxReferences.add(referenceWithInclude);
+
+    EdmxReference referenceWithTwoIncludes = new EdmxReference(
+            
URI.create("http://localhost/odata/odata/v4.0/referenceWithTwoIncludes";));
+    referenceWithTwoIncludes.addInclude(new 
EdmxReferenceInclude("Org.OData.Core.2", "Core2"));
+    referenceWithTwoIncludes.addInclude(new 
EdmxReferenceInclude("Org.OData.Core.3", "Core3"));
+    edmxReferences.add(referenceWithTwoIncludes);
+
+    EdmxReference referenceWithIncludeAnnos = new EdmxReference(
+            
URI.create("http://localhost/odata/odata/v4.0/referenceWithIncludeAnnos";));
+    referenceWithIncludeAnnos.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotation("TermNs.2", "Q.2", 
"TargetNS.2"));
+    referenceWithIncludeAnnos.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotation("TermNs.3", 
"Q.3","TargetNS.3"));
+    edmxReferences.add(referenceWithIncludeAnnos);
+
+    EdmxReference referenceWithAll = new EdmxReference(
+            URI.create("http://localhost/odata/odata/v4.0/referenceWithAll";));
+    referenceWithAll.addInclude(new EdmxReferenceInclude("ReferenceWithAll.1", 
"Core1"));
+    referenceWithAll.addInclude(new EdmxReferenceInclude("ReferenceWithAll.2", 
"Core2"));
+    referenceWithAll.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotation("ReferenceWithAllTermNs.4", 
"Q.4", "TargetNS.4"));
+    referenceWithAll.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotation("ReferenceWithAllTermNs.5", 
"Q.5", "TargetNS.5"));
+    edmxReferences.add(referenceWithAll);
+
+    EdmxReference referenceWithAllAndNull = new EdmxReference(
+            
URI.create("http://localhost/odata/odata/v4.0/referenceWithAllAndNull";));
+    referenceWithAllAndNull.addInclude(new 
EdmxReferenceInclude("referenceWithAllAndNull.1"));
+    referenceWithAllAndNull.addInclude(new 
EdmxReferenceInclude("referenceWithAllAndNull.2", null));
+    referenceWithAllAndNull.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotation("ReferenceWithAllTermNs.4"));
+    referenceWithAllAndNull.addIncludeAnnotation(
+            new 
EdmxReferenceIncludeAnnotation("ReferenceWithAllTermAndNullNs.5", "Q.5", null));
+    referenceWithAllAndNull.addIncludeAnnotation(
+            new 
EdmxReferenceIncludeAnnotation("ReferenceWithAllTermAndNullNs.6", null, 
"TargetNS"));
+    referenceWithAllAndNull.addIncludeAnnotation(
+            new 
EdmxReferenceIncludeAnnotation("ReferenceWithAllTermAndNullNs.7", null, null));
+    edmxReferences.add(referenceWithAllAndNull);
+
+    ServiceMetadata serviceMetadata = mock(ServiceMetadata.class);
+    final Edm edm = mock(Edm.class);
+    when(serviceMetadata.getEdm()).thenReturn(edm);
+    when(serviceMetadata.getReferences()).thenReturn(edmxReferences);
+
+    InputStream metadata = serializer.metadataDocument(serviceMetadata);
+    assertNotNull(metadata);
+    final String metadataString = IOUtils.toString(metadata);
+    // edmx reference
+    assertTrue(metadataString.contains(
+            "<edmx:Reference Uri=\"http://example.com\"/>"));
+    assertTrue(metadataString.contains(
+            "<edmx:Reference " +
+                    
"Uri=\"http://localhost/odata/odata/v4.0/referenceWithInclude\";>" +
+            "<edmx:Include Namespace=\"Org.OData.Core.V1\" Alias=\"Core\"/>" +
+            "</edmx:Reference>"));
+    assertTrue(metadataString.contains(
+            "<edmx:Reference " +
+                    
"Uri=\"http://localhost/odata/odata/v4.0/referenceWithTwoIncludes\";>" +
+            "<edmx:Include Namespace=\"Org.OData.Core.2\" Alias=\"Core2\"/>" +
+            "<edmx:Include Namespace=\"Org.OData.Core.3\" Alias=\"Core3\"/>" +
+            "</edmx:Reference>"));
+    assertTrue(metadataString.contains(
+            "<edmx:Reference 
Uri=\"http://localhost/odata/odata/v4.0/referenceWithIncludeAnnos\";>" +
+            "<edmx:IncludeAnnotations TermNamespace=\"TermNs.2\" 
Qualifier=\"Q.2\" TargetNamespace=\"TargetNS.2\"/>" +
+            "<edmx:IncludeAnnotations TermNamespace=\"TermNs.3\" 
Qualifier=\"Q.3\" TargetNamespace=\"TargetNS.3\"/>" +
+            "</edmx:Reference>"));
+    assertTrue(metadataString.contains(
+            "<edmx:Reference 
Uri=\"http://localhost/odata/odata/v4.0/referenceWithAll\";>" +
+                    "<edmx:Include Namespace=\"ReferenceWithAll.1\" 
Alias=\"Core1\"/>" +
+                    "<edmx:Include Namespace=\"ReferenceWithAll.2\" 
Alias=\"Core2\"/>" +
+                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermNs.4\" " +
+                    "Qualifier=\"Q.4\" TargetNamespace=\"TargetNS.4\"/>" +
+                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermNs.5\" " +
+                    "Qualifier=\"Q.5\" TargetNamespace=\"TargetNS.5\"/>" +
+                    "</edmx:Reference>"));
+    assertTrue(metadataString.contains(
+            "<edmx:Reference 
Uri=\"http://localhost/odata/odata/v4.0/referenceWithAllAndNull\";>" +
+                    "<edmx:Include Namespace=\"referenceWithAllAndNull.1\"/>" +
+                    "<edmx:Include Namespace=\"referenceWithAllAndNull.2\"/>" +
+                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermNs.4\"/>" +
+                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermAndNullNs.5\" Qualifier=\"Q.5\"/>" +
+                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermAndNullNs.6\" " +
+                                              "TargetNamespace=\"TargetNS\"/>" 
+
+                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermAndNullNs.7\"/>" +
+                    "</edmx:Reference>"));
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/096946a7/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
----------------------------------------------------------------------
diff --git 
a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
 
b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
index f11bf41..40ceee9 100644
--- 
a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
+++ 
b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
@@ -22,6 +22,7 @@ import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataHttpHandler;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
 import org.apache.olingo.server.tecsvc.data.DataProvider;
 import org.apache.olingo.server.tecsvc.processor.TechnicalProcessor;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
@@ -33,8 +34,10 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
+
 import java.io.IOException;
-import java.util.Collections;
+import java.net.URI;
+import java.util.Arrays;
 import java.util.List;
 
 public class TechnicalServlet extends HttpServlet {
@@ -47,8 +50,10 @@ public class TechnicalServlet extends HttpServlet {
           throws ServletException, IOException {
     try {
       OData odata = OData.newInstance();
-      List<EdmxReference> references = Collections.emptyList();
-      ServiceMetadata serviceMetadata = odata.createServiceMetadata(new 
EdmTechProvider(references), references);
+      EdmxReference reference = new 
EdmxReference(URI.create("../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml"));
+      reference.addInclude(new EdmxReferenceInclude("Org.OData.Core.V1", 
"Core"));
+      final List<EdmxReference> references = Arrays.asList(reference);
+      final ServiceMetadata serviceMetadata = odata.createServiceMetadata(new 
EdmTechProvider(references), references);
 
       HttpSession session = req.getSession(true);
       DataProvider dataProvider = (DataProvider) 
session.getAttribute(DataProvider.class.getName());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/096946a7/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/model/EtAllPrim.java
----------------------------------------------------------------------
diff --git 
a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/model/EtAllPrim.java
 
b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/model/EtAllPrim.java
deleted file mode 100644
index bbc6e43..0000000
--- 
a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/model/EtAllPrim.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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.
- */
-package org.apache.olingo.server.tecsvc.data.model;
-
-import java.util.List;
-
-public class EtAllPrim {
-  private int PropertyInt16;
-  private String PropertyString;
-  private boolean PropertyBoolean;
-  private byte PropertyByte;
-  private byte PropertySByte;
-  private int PropertyInt32;
-  private int PropertyInt64;
-  private long PropertySingle;
-  private double PropertyDouble;
-  private double PropertyDecimal;
-  private byte[] PropertyBinary;
-  // TODO:Define ----------
-  private String PropertyDate;
-  private String PropertyDateTimeOffset;
-  private String PropertyDuration;
-  private String PropertyGuid;
-  private String PropertyTimeOfDay;
-  // ----------- ----------
-  private EtTwoPrim NavPropertyETTwoPrimOne;
-  private List<EtTwoPrim> NavPropertyETTwoPrimMany;
-
-  public int getPropertyInt16() {
-    return PropertyInt16;
-  }
-
-  public void setPropertyInt16(final int propertyInt16) {
-    PropertyInt16 = propertyInt16;
-  }
-
-  public String getPropertyString() {
-    return PropertyString;
-  }
-
-  public void setPropertyString(final String propertyString) {
-    PropertyString = propertyString;
-  }
-
-  public boolean isPropertyBoolean() {
-    return PropertyBoolean;
-  }
-
-  public void setPropertyBoolean(final boolean propertyBoolean) {
-    PropertyBoolean = propertyBoolean;
-  }
-
-  public byte getPropertyByte() {
-    return PropertyByte;
-  }
-
-  public void setPropertyByte(final byte propertyByte) {
-    PropertyByte = propertyByte;
-  }
-
-  public byte getPropertySByte() {
-    return PropertySByte;
-  }
-
-  public void setPropertySByte(final byte propertySByte) {
-    PropertySByte = propertySByte;
-  }
-
-  public int getPropertyInt32() {
-    return PropertyInt32;
-  }
-
-  public void setPropertyInt32(final int propertyInt32) {
-    PropertyInt32 = propertyInt32;
-  }
-
-  public int getPropertyInt64() {
-    return PropertyInt64;
-  }
-
-  public void setPropertyInt64(final int propertyInt64) {
-    PropertyInt64 = propertyInt64;
-  }
-
-  public long getPropertySingle() {
-    return PropertySingle;
-  }
-
-  public void setPropertySingle(final long propertySingle) {
-    PropertySingle = propertySingle;
-  }
-
-  public double getPropertyDouble() {
-    return PropertyDouble;
-  }
-
-  public void setPropertyDouble(final double propertyDouble) {
-    PropertyDouble = propertyDouble;
-  }
-
-  public double getPropertyDecimal() {
-    return PropertyDecimal;
-  }
-
-  public void setPropertyDecimal(final double propertyDecimal) {
-    PropertyDecimal = propertyDecimal;
-  }
-
-  public byte[] getPropertyBinary() {
-    return PropertyBinary;
-  }
-
-  public void setPropertyBinary(final byte[] propertyBinary) {
-    PropertyBinary = propertyBinary;
-  }
-
-  public String getPropertyDate() {
-    return PropertyDate;
-  }
-
-  public void setPropertyDate(final String propertyDate) {
-    PropertyDate = propertyDate;
-  }
-
-  public String getPropertyDateTimeOffset() {
-    return PropertyDateTimeOffset;
-  }
-
-  public void setPropertyDateTimeOffset(final String propertyDateTimeOffset) {
-    PropertyDateTimeOffset = propertyDateTimeOffset;
-  }
-
-  public String getPropertyDuration() {
-    return PropertyDuration;
-  }
-
-  public void setPropertyDuration(final String propertyDuration) {
-    PropertyDuration = propertyDuration;
-  }
-
-  public String getPropertyGuid() {
-    return PropertyGuid;
-  }
-
-  public void setPropertyGuid(final String propertyGuid) {
-    PropertyGuid = propertyGuid;
-  }
-
-  public String getPropertyTimeOfDay() {
-    return PropertyTimeOfDay;
-  }
-
-  public void setPropertyTimeOfDay(final String propertyTimeOfDay) {
-    PropertyTimeOfDay = propertyTimeOfDay;
-  }
-
-  public EtTwoPrim getNavPropertyETTwoPrimOne() {
-    return NavPropertyETTwoPrimOne;
-  }
-
-  public void setNavPropertyETTwoPrimOne(final EtTwoPrim 
navPropertyETTwoPrimOne) {
-    NavPropertyETTwoPrimOne = navPropertyETTwoPrimOne;
-  }
-
-  public List<EtTwoPrim> getNavPropertyETTwoPrimMany() {
-    return NavPropertyETTwoPrimMany;
-  }
-
-  public void setNavPropertyETTwoPrimMany(final List<EtTwoPrim> 
navPropertyETTwoPrimMany) {
-    NavPropertyETTwoPrimMany = navPropertyETTwoPrimMany;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/096946a7/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/model/EtTwoPrim.java
----------------------------------------------------------------------
diff --git 
a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/model/EtTwoPrim.java
 
b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/model/EtTwoPrim.java
deleted file mode 100644
index d61e571..0000000
--- 
a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/model/EtTwoPrim.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.
- */
-package org.apache.olingo.server.tecsvc.data.model;
-
-import java.util.List;
-
-public class EtTwoPrim {
-  private int PropertyInt16;
-  private String PropertyString;
-
-  private EtAllPrim NavPropertyETAllPrimOne;
-  private List<EtAllPrim> NavPropertyETAllPrimMany;
-
-  public int getPropertyInt16() {
-    return PropertyInt16;
-  }
-
-  public void setPropertyInt16(final int propertyInt16) {
-    PropertyInt16 = propertyInt16;
-  }
-
-  public String getPropertyString() {
-    return PropertyString;
-  }
-
-  public void setPropertyString(final String propertyString) {
-    PropertyString = propertyString;
-  }
-
-  public EtAllPrim getNavPropertyETAllPrimOne() {
-    return NavPropertyETAllPrimOne;
-  }
-
-  public void setNavPropertyETAllPrimOne(final EtAllPrim 
navPropertyETAllPrimOne) {
-    NavPropertyETAllPrimOne = navPropertyETAllPrimOne;
-  }
-
-  public List<EtAllPrim> getNavPropertyETAllPrimMany() {
-    return NavPropertyETAllPrimMany;
-  }
-
-  public void setNavPropertyETAllPrimMany(final List<EtAllPrim> 
navPropertyETAllPrimMany) {
-    NavPropertyETAllPrimMany = navPropertyETAllPrimMany;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/096946a7/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
index e9a6576..c094e52 100644
--- 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -18,398 +18,129 @@
  */
 package org.apache.olingo.server.core.serializer.xml;
 
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.junit.Assert.assertThat;
 
-import java.io.InputStream;
 import java.net.URI;
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.Target;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.server.api.edm.provider.Action;
-import org.apache.olingo.server.api.edm.provider.ActionImport;
-import org.apache.olingo.server.api.edm.provider.ComplexType;
-import org.apache.olingo.server.api.edm.provider.EdmProvider;
-import org.apache.olingo.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.server.api.edm.provider.EntitySet;
-import org.apache.olingo.server.api.edm.provider.EntityType;
-import org.apache.olingo.server.api.edm.provider.EnumMember;
-import org.apache.olingo.server.api.edm.provider.EnumType;
-import org.apache.olingo.server.api.edm.provider.Function;
-import org.apache.olingo.server.api.edm.provider.FunctionImport;
-import org.apache.olingo.server.api.edm.provider.NavigationProperty;
-import org.apache.olingo.server.api.edm.provider.NavigationPropertyBinding;
-import org.apache.olingo.server.api.edm.provider.Parameter;
-import org.apache.olingo.server.api.edm.provider.Property;
-import org.apache.olingo.server.api.edm.provider.ReturnType;
-import org.apache.olingo.server.api.edm.provider.Schema;
-import org.apache.olingo.server.api.edm.provider.Singleton;
-import org.apache.olingo.server.api.edm.provider.TypeDefinition;
 import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
-import org.apache.olingo.server.api.serializer.ODataSerializer;
-import org.apache.olingo.server.core.ServiceMetadataImpl;
-import org.apache.olingo.server.api.edmx.EdmxReferenceIncludeAnnotation;
+import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Test;
 
 public class MetadataDocumentTest {
 
-  @Test
-  public void writeMetadataWithEmptyMockedEdm() throws Exception {
-    ODataSerializer serializer = 
OData.newInstance().createSerializer(ODataFormat.XML);
-    ServiceMetadata metadata = mock(ServiceMetadata.class);
-    Edm edm = mock(Edm.class);
-    when(metadata.getEdm()).thenReturn(edm);
-    serializer.metadataDocument(metadata);
-  }
+  private static final String CORE_VOCABULARY =
+      
"http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml";;
 
   @Test
-  public void writeEdmxWithLocalTestEdm() throws Exception {
-    ODataSerializer serializer = 
OData.newInstance().createSerializer(ODataFormat.XML);
-
-    List<EdmxReference> edmxReferences = new ArrayList<EdmxReference>();
-    EdmxReference reference = new 
EdmxReference(URI.create("http://example.com";));
-    edmxReferences.add(reference);
-
-    EdmxReference referenceWithInclude = new EdmxReference(
-            
URI.create("http://localhost/odata/odata/v4.0/referenceWithInclude";));
-    EdmxReferenceInclude include = new 
EdmxReferenceInclude("Org.OData.Core.V1", "Core");
-    referenceWithInclude.addInclude(include);
-    edmxReferences.add(referenceWithInclude);
-
-    EdmxReference referenceWithTwoIncludes = new EdmxReference(
-            
URI.create("http://localhost/odata/odata/v4.0/referenceWithTwoIncludes";));
-    referenceWithTwoIncludes.addInclude(new 
EdmxReferenceInclude("Org.OData.Core.2", "Core2"));
-    referenceWithTwoIncludes.addInclude(new 
EdmxReferenceInclude("Org.OData.Core.3", "Core3"));
-    edmxReferences.add(referenceWithTwoIncludes);
-
-    EdmxReference referenceWithIncludeAnnos = new EdmxReference(
-            
URI.create("http://localhost/odata/odata/v4.0/referenceWithIncludeAnnos";));
-    referenceWithIncludeAnnos.addIncludeAnnotation(
-            new EdmxReferenceIncludeAnnotation("TermNs.2", "Q.2", 
"TargetNS.2"));
-    referenceWithIncludeAnnos.addIncludeAnnotation(
-            new EdmxReferenceIncludeAnnotation("TermNs.3", 
"Q.3","TargetNS.3"));
-    edmxReferences.add(referenceWithIncludeAnnos);
-
-    EdmxReference referenceWithAll = new EdmxReference(
-            URI.create("http://localhost/odata/odata/v4.0/referenceWithAll";));
-    referenceWithAll.addInclude(new EdmxReferenceInclude("ReferenceWithAll.1", 
"Core1"));
-    referenceWithAll.addInclude(new EdmxReferenceInclude("ReferenceWithAll.2", 
"Core2"));
-    referenceWithAll.addIncludeAnnotation(
-            new EdmxReferenceIncludeAnnotation("ReferenceWithAllTermNs.4", 
"Q.4", "TargetNS.4"));
-    referenceWithAll.addIncludeAnnotation(
-            new EdmxReferenceIncludeAnnotation("ReferenceWithAllTermNs.5", 
"Q.5", "TargetNS.5"));
-    edmxReferences.add(referenceWithAll);
-
-    EdmxReference referenceWithAllAndNull = new EdmxReference(
-            
URI.create("http://localhost/odata/odata/v4.0/referenceWithAllAndNull";));
-    referenceWithAllAndNull.addInclude(new 
EdmxReferenceInclude("referenceWithAllAndNull.1"));
-    referenceWithAllAndNull.addInclude(new 
EdmxReferenceInclude("referenceWithAllAndNull.2", null));
-    referenceWithAllAndNull.addIncludeAnnotation(
-            new EdmxReferenceIncludeAnnotation("ReferenceWithAllTermNs.4"));
-    referenceWithAllAndNull.addIncludeAnnotation(
-            new 
EdmxReferenceIncludeAnnotation("ReferenceWithAllTermAndNullNs.5", "Q.5", null));
-    referenceWithAllAndNull.addIncludeAnnotation(
-            new 
EdmxReferenceIncludeAnnotation("ReferenceWithAllTermAndNullNs.6", null, 
"TargetNS"));
-    referenceWithAllAndNull.addIncludeAnnotation(
-            new 
EdmxReferenceIncludeAnnotation("ReferenceWithAllTermAndNullNs.7", null, null));
-    edmxReferences.add(referenceWithAllAndNull);
-
-    ServiceMetadata serviceMetadata = new 
ServiceMetadataImpl(ODataServiceVersion.V40,
-            new TestMetadataProvider(), edmxReferences);
-    InputStream metadata = serializer.metadataDocument(serviceMetadata);
-    assertNotNull(metadata);
-
-
-    String metadataString = IOUtils.toString(metadata);
-    // edmx reference
-    assertTrue(metadataString.contains(
-            "<edmx:Reference Uri=\"http://example.com\"/>"));
-    assertTrue(metadataString.contains(
-            "<edmx:Reference " +
-                    
"Uri=\"http://localhost/odata/odata/v4.0/referenceWithInclude\";>" +
-            "<edmx:Include Namespace=\"Org.OData.Core.V1\" Alias=\"Core\"/>" +
-            "</edmx:Reference>"));
-    assertTrue(metadataString.contains(
-            "<edmx:Reference " +
-                    
"Uri=\"http://localhost/odata/odata/v4.0/referenceWithTwoIncludes\";>" +
-            "<edmx:Include Namespace=\"Org.OData.Core.2\" Alias=\"Core2\"/>" +
-            "<edmx:Include Namespace=\"Org.OData.Core.3\" Alias=\"Core3\"/>" +
-            "</edmx:Reference>"));
-    assertTrue(metadataString.contains(
-            "<edmx:Reference 
Uri=\"http://localhost/odata/odata/v4.0/referenceWithIncludeAnnos\";>" +
-            "<edmx:IncludeAnnotations TermNamespace=\"TermNs.2\" 
Qualifier=\"Q.2\" TargetNamespace=\"TargetNS.2\"/>" +
-            "<edmx:IncludeAnnotations TermNamespace=\"TermNs.3\" 
Qualifier=\"Q.3\" TargetNamespace=\"TargetNS.3\"/>" +
-            "</edmx:Reference>"));
-    assertTrue(metadataString.contains(
-            "<edmx:Reference 
Uri=\"http://localhost/odata/odata/v4.0/referenceWithAll\";>" +
-                    "<edmx:Include Namespace=\"ReferenceWithAll.1\" 
Alias=\"Core1\"/>" +
-                    "<edmx:Include Namespace=\"ReferenceWithAll.2\" 
Alias=\"Core2\"/>" +
-                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermNs.4\" " +
-                    "Qualifier=\"Q.4\" TargetNamespace=\"TargetNS.4\"/>" +
-                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermNs.5\" " +
-                    "Qualifier=\"Q.5\" TargetNamespace=\"TargetNS.5\"/>" +
-                    "</edmx:Reference>"));
-    assertTrue(metadataString.contains(
-            "<edmx:Reference 
Uri=\"http://localhost/odata/odata/v4.0/referenceWithAllAndNull\";>" +
-                    "<edmx:Include Namespace=\"referenceWithAllAndNull.1\"/>" +
-                    "<edmx:Include Namespace=\"referenceWithAllAndNull.2\"/>" +
-                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermNs.4\"/>" +
-                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermAndNullNs.5\" Qualifier=\"Q.5\"/>" +
-                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermAndNullNs.6\" " +
-                                              "TargetNamespace=\"TargetNS\"/>" 
+
-                    "<edmx:IncludeAnnotations 
TermNamespace=\"ReferenceWithAllTermAndNullNs.7\"/>" +
-                    "</edmx:Reference>"));
-  }
+  public void writeMetadataWithTechnicalScenario() throws Exception {
+    final OData odata = OData.newInstance();
+    final List<EdmxReference> references = getEdmxReferences();
+    final ServiceMetadata serviceMetadata = odata.createServiceMetadata(
+        new EdmTechProvider(references), references);
 
-  @Test
-  public void writeMetadataWithLocalTestEdm() throws Exception {
-    ODataSerializer serializer = 
OData.newInstance().createSerializer(ODataFormat.XML);
-    List<EdmxReference> edmxReferences = getEdmxReferences();
-    ServiceMetadata serviceMetadata = new 
ServiceMetadataImpl(ODataServiceVersion.V40,
-            new TestMetadataProvider(), edmxReferences);
-    InputStream metadata = serializer.metadataDocument(serviceMetadata);
+    final String metadata = IOUtils.toString(
+        
odata.createSerializer(ODataFormat.XML).metadataDocument(serviceMetadata));
     assertNotNull(metadata);
 
-    String metadataString = IOUtils.toString(metadata);
-    // edmx reference
-    assertTrue(metadataString
-            .contains("<edmx:Reference " +
-                    
"Uri=\"http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml\";>"
 +
-                    "<edmx:Include Namespace=\"Org.OData.Core.V1\" 
Alias=\"Core\"/>" +
-                    "</edmx:Reference>"));
-
-    assertTrue(metadataString
-        .contains("<edmx:Edmx Version=\"4.0\" 
xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\";>"));
-
-    assertTrue(metadataString
-        .contains("<Schema xmlns=\"http://docs.oasis-open.org/odata/ns/edm\"; " 
+
-            "Namespace=\"namespace\" Alias=\"alias\">"));
-
-    assertTrue(metadataString
-        .contains("<EntityType Name=\"ETBaseName\"><Property Name=\"P1\" 
Type=\"Edm.Int16\"/><NavigationProperty " +
-            "Name=\"N1\" Type=\"namespace.ETBaseName\" Nullable=\"true\" 
Partner=\"N1\"/></EntityType>"));
-
-    assertTrue(metadataString
-        .contains("<EntityType Name=\"ETDerivedName\" 
BaseType=\"namespace.ETBaseName\"><Property Name=\"P2\" " +
-            "Type=\"Edm.Int16\"/><NavigationProperty Name=\"N2\" 
Type=\"namespace.ETDerivedName\" Nullable=\"true\" " +
-            "Partner=\"N2\"/></EntityType>"));
-
-    assertTrue(metadataString
-        .contains("<ComplexType Name=\"CTBaseName\"><Property Name=\"P1\" 
Type=\"Edm.Int16\"/><NavigationProperty " +
-            "Name=\"N1\" Type=\"namespace.ETBaseName\" Nullable=\"true\" 
Partner=\"N1\"/></ComplexType>"));
-
-    assertTrue(metadataString
-        .contains("<ComplexType Name=\"CTDerivedName\" 
BaseType=\"namespace.CTBaseName\"><Property Name=\"P2\" " +
-            "Type=\"Edm.Int16\"/><NavigationProperty Name=\"N2\" 
Type=\"namespace.ETDerivedName\" Nullable=\"true\" " +
-            "Partner=\"N2\"/></ComplexType>"));
-
-    assertTrue(metadataString.contains("<TypeDefinition Name=\"typeDef\" 
Type=\"Edm.Int16\"/>"));
-
-    assertTrue(metadataString.contains("<Action Name=\"ActionWOParameter\" 
IsBound=\"false\"/>"));
-
-    assertTrue(metadataString
-        .contains("<Action Name=\"ActionName\" IsBound=\"true\"><Parameter 
Name=\"param\" Type=\"Edm.Int16\"/>" +
-            "<Parameter Name=\"param2\" 
Type=\"Collection(Edm.Int16)\"/><ReturnType Type=\"namespace.CTBaseName\"/>" +
-            "</Action>"));
-
-    assertTrue(metadataString
-        .contains("<Function Name=\"FunctionWOParameter\" IsBound=\"false\" 
IsComposable=\"false\"><ReturnType " +
-            "Type=\"namespace.CTBaseName\"/></Function>"));
-
-    assertTrue(metadataString
-        .contains("<Function Name=\"FunctionName\" IsBound=\"true\" 
IsComposable=\"false\"><Parameter Name=\"param\" " +
-            "Type=\"Edm.Int16\"/><Parameter Name=\"param2\" 
Type=\"Collection(Edm.Int16)\"/><ReturnType " +
-            "Type=\"namespace.CTBaseName\"/></Function>"));
-
-    assertTrue(metadataString.contains("<EntityContainer 
Name=\"container\">"));
-
-    assertTrue(metadataString
-        .contains("<EntitySet Name=\"EntitySetName\" 
EntityType=\"namespace.ETBaseName\"><NavigationPropertyBinding " +
-            "Path=\"N1\" 
Target=\"namespace.container/EntitySetName\"/></EntitySet>"));
-    assertTrue(metadataString
-        .contains("<Singleton Name=\"SingletonName\" 
EntityType=\"namespace.ETBaseName\"><NavigationPropertyBinding " +
-            "Path=\"N1\" 
Target=\"namespace.container/EntitySetName\"/></Singleton>"));
-
-    assertTrue(metadataString.contains("<ActionImport Name=\"actionImport\" 
Action=\"namespace.ActionWOParameter\"/>"));
-
-    assertTrue(metadataString
-        .contains("<FunctionImport Name=\"actionImport\" 
Function=\"namespace.FunctionName\" " +
-            "EntitySet=\"namespace.EntitySetName\" 
IncludeInServiceDocument=\"false\"/>"));
-
-    
assertTrue(metadataString.contains("</EntityContainer></Schema></edmx:DataServices></edmx:Edmx>"));
+    assertThat(metadata,
+        containsString("<edmx:Reference Uri=\"" + CORE_VOCABULARY + "\">"
+            + "<edmx:Include Namespace=\"Org.OData.Core.V1\" Alias=\"Core\"/>"
+            + "</edmx:Reference>"));
+
+    assertThat(metadata,
+        containsString("<edmx:Edmx Version=\"4.0\" 
xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\";>"));
+
+    assertThat(metadata,
+        containsString("<Schema 
xmlns=\"http://docs.oasis-open.org/odata/ns/edm\"; "
+            + "Namespace=\"olingo.odata.test1\" Alias=\"Namespace1_Alias\">"));
+
+    assertThat(metadata,
+        containsString("<EntityType Name=\"ETTwoPrim\">"
+            + "<Key><PropertyRef Name=\"PropertyInt16\"/></Key>"
+            + "<Property Name=\"PropertyInt16\" Type=\"Edm.Int16\" 
Nullable=\"false\"/>"
+            + "<Property Name=\"PropertyString\" Type=\"Edm.String\"/>"
+            + "<NavigationProperty Name=\"NavPropertyETAllPrimOne\" 
Type=\"olingo.odata.test1.ETAllPrim\"/>"
+            + "<NavigationProperty Name=\"NavPropertyETAllPrimMany\" "
+            + "Type=\"Collection(olingo.odata.test1.ETAllPrim)\"/>"
+            + "</EntityType>"));
+
+    assertThat(metadata,
+        containsString("<EntityType Name=\"ETBase\" 
BaseType=\"olingo.odata.test1.ETTwoPrim\">"
+            + "<Property Name=\"AdditionalPropertyString_5\" 
Type=\"Edm.String\"/>"
+            + "</EntityType>"));
+
+    assertThat(metadata,
+        containsString("<ComplexType Name=\"CTPrim\">"
+            + "<Property Name=\"PropertyInt16\" 
Type=\"Edm.Int16\"/></ComplexType>"));
+
+    assertThat(metadata,
+        containsString("<ComplexType Name=\"CTBase\" 
BaseType=\"olingo.odata.test1.CTTwoPrim\">"
+            + "<Property Name=\"AdditionalPropString\" 
Type=\"Edm.String\"/></ComplexType>"));
+
+    // TODO: TypeDefinition
+    // assertThat(metadata, containsString("<TypeDefinition Name=\"typeDef\" 
Type=\"Edm.Int16\"/>"));
+
+    assertThat(metadata, containsString("<Action Name=\"UARTPrimParam\" 
IsBound=\"false\">"
+        + "<Parameter Name=\"ParameterInt16\" Type=\"Edm.Int16\"/>"
+        + "<ReturnType Type=\"Edm.String\"/></Action>"));
+
+    assertThat(metadata,
+        containsString("<Action Name=\"BAESAllPrimRTETAllPrim\" 
IsBound=\"true\">"
+            + "<Parameter Name=\"ParameterESAllPrim\" "
+            + "Type=\"Collection(olingo.odata.test1.ETAllPrim)\" 
Nullable=\"false\"/>"
+            + "<ReturnType Type=\"olingo.odata.test1.ETAllPrim\"/></Action>"));
+
+    assertThat(metadata,
+        containsString("<Function Name=\"UFNRTInt16\" IsBound=\"false\" 
IsComposable=\"false\">"
+            + "<ReturnType Type=\"Edm.Int16\"/></Function>"));
+
+    assertThat(metadata,
+        containsString("<Function Name=\"BFCESTwoKeyNavRTESTwoKeyNav\" 
IsBound=\"true\" IsComposable=\"true\">"
+            + "<Parameter Name=\"BindingParam\" 
Type=\"Collection(olingo.odata.test1.ETTwoKeyNav)\" "
+            + "Nullable=\"false\"/>"
+            + "<ReturnType Type=\"Collection(olingo.odata.test1.ETTwoKeyNav)\" 
Nullable=\"false\"/></Function>"));
+
+    assertThat(metadata, containsString("<EntityContainer 
Name=\"Container\">"));
+
+    assertThat(metadata,
+        containsString("<EntitySet Name=\"ESTwoPrim\" 
EntityType=\"olingo.odata.test1.ETTwoPrim\"/>"));
+
+    assertThat(metadata,
+        containsString("<Singleton Name=\"SINav\" 
EntityType=\"olingo.odata.test1.ETTwoKeyNav\">"
+            + "<NavigationPropertyBinding Path=\"NavPropertyETTwoKeyNavMany\" 
Target=\"ESTwoKeyNav\"/>"
+            + "</Singleton>"));
+
+    assertThat(metadata,
+        containsString("<ActionImport Name=\"AIRTPrimParam\" 
Action=\"olingo.odata.test1.UARTPrimParam\"/>"));
+
+    assertThat(metadata,
+        containsString("<FunctionImport Name=\"FINInvisible2RTInt16\" 
Function=\"olingo.odata.test1.UFNRTInt16\" "
+            + "IncludeInServiceDocument=\"false\"/>"));
+
+    assertThat(metadata, 
containsString("</EntityContainer></Schema></edmx:DataServices></edmx:Edmx>"));
   }
 
   /**
-   * Write simplest (empty) Schema.
+   * <code>
+   *  <edmx:Reference 
Uri="http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml";>
+   *    <edmx:Include Namespace="Org.OData.Core.V1" Alias="Core"/>
+   *  </edmx:Reference>
+   * </code>
    *
-   * @throws Exception
+   * @return default emdx reference
    */
-  @Test
-  public void writeMetadataWithEmptySchema() throws Exception {
-    ODataSerializer serializer = 
OData.newInstance().createSerializer(ODataFormat.XML);
-    List<EdmxReference> edmxReferences = Collections.emptyList();
-    ServiceMetadata serviceMetadata = new 
ServiceMetadataImpl(ODataServiceVersion.V40,
-        new EdmProvider() {
-          @Override
-          public List<Schema> getSchemas() throws ODataException {
-            return Arrays.asList(new Schema().setNamespace("MyNamespace"));
-          }
-        },
-        edmxReferences);
-
-    InputStream metadata = serializer.metadataDocument(serviceMetadata);
-    assertNotNull(metadata);
-
-    String metadataString = IOUtils.toString(metadata);
-    assertEquals("<?xml version='1.0' encoding='UTF-8'?>" +
-        "<edmx:Edmx Version=\"4.0\" 
xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\";>" +
-          "<edmx:DataServices>" +
-            "<Schema xmlns=\"http://docs.oasis-open.org/odata/ns/edm\"; 
Namespace=\"MyNamespace\"/>" +
-          "</edmx:DataServices>" +
-        "</edmx:Edmx>",
-        metadataString);
-  }
-
-    /**
-     * <code>
-     *  <edmx:Reference 
Uri="http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml";>
-     *    <edmx:Include Namespace="Org.OData.Core.V1" Alias="Core"/>
-     *  </edmx:Reference>
-     * </code>
-     *
-     * @return default emdx reference
-     */
   private List<EdmxReference> getEdmxReferences() {
-    List<EdmxReference> edmxReferences = new ArrayList<EdmxReference>();
-    EdmxReference reference = new EdmxReference(
-            
URI.create("http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml";));
-    EdmxReferenceInclude include = new 
EdmxReferenceInclude("Org.OData.Core.V1", "Core");
-    reference.addInclude(include);
-    edmxReferences.add(reference);
-    return edmxReferences;
-  }
-
-  @Test
-  public void writeMetadataWithTechnicalScenario() throws Exception {
-    ODataSerializer serializer = 
OData.newInstance().createSerializer(ODataFormat.XML);
-    ServiceMetadata serviceMetadata = new 
ServiceMetadataImpl(ODataServiceVersion.V40,
-            new TestMetadataProvider(), 
Collections.<EdmxReference>emptyList());
-    InputStream metadata = serializer.metadataDocument(serviceMetadata);
-    assertNotNull(metadata);
-    // The technical scenario is too big to verify. We are content for now to 
make sure we can serialize it.
-    // System.out.println(StringUtils.inputStreamToString(metadata, false));
-  }
-
-  private class TestMetadataProvider extends EdmProvider {
-
-    @Override
-    public List<Schema> getSchemas() throws ODataException {
-      Property p1 = new 
Property().setName("P1").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName());
-      String ns = "namespace";
-      NavigationProperty n1 = new NavigationProperty().setName("N1")
-          .setType(new FullQualifiedName(ns, 
"ETBaseName")).setNullable(true).setPartner("N1");
-      Property p2 = new 
Property().setName("P2").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName());
-      NavigationProperty n2 = new NavigationProperty().setName("N2")
-          .setType(new FullQualifiedName(ns, 
"ETDerivedName")).setNullable(true).setPartner("N2");
-      Schema schema = new Schema().setNamespace(ns).setAlias("alias");
-      List<ComplexType> complexTypes = new ArrayList<ComplexType>();
-      schema.setComplexTypes(complexTypes);
-      ComplexType ctBase =
-          new 
ComplexType().setName("CTBaseName").setProperties(Arrays.asList(p1)).setNavigationProperties(
-              Arrays.asList(n1));
-      complexTypes.add(ctBase);
-      ComplexType ctDerived =
-          new ComplexType().setName("CTDerivedName").setBaseType(new 
FullQualifiedName(ns, "CTBaseName"))
-              
.setProperties(Arrays.asList(p2)).setNavigationProperties(Arrays.asList(n2));
-      complexTypes.add(ctDerived);
-
-      List<EntityType> entityTypes = new ArrayList<EntityType>();
-      schema.setEntityTypes(entityTypes);
-      EntityType etBase =
-          new 
EntityType().setName("ETBaseName").setProperties(Arrays.asList(p1)).setNavigationProperties(
-              Arrays.asList(n1));
-      entityTypes.add(etBase);
-      EntityType etDerived =
-          new EntityType().setName("ETDerivedName").setBaseType(new 
FullQualifiedName(ns, "ETBaseName"))
-              
.setProperties(Arrays.asList(p2)).setNavigationProperties(Arrays.asList(n2));
-      entityTypes.add(etDerived);
-
-      List<Action> actions = new ArrayList<Action>();
-      schema.setActions(actions);
-      // TODO:EntitySetPath
-      actions.add((new Action().setName("ActionWOParameter")));
-      List<Parameter> parameters = new ArrayList<Parameter>();
-      parameters.add(new 
Parameter().setName("param").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()));
-      parameters.add(new 
Parameter().setName("param2").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
-          .setCollection(true));
-      actions.add(new 
Action().setName("ActionName").setBound(true).setParameters(parameters).setReturnType(
-          new ReturnType().setType(new FullQualifiedName(ns, "CTBaseName"))));
-
-      List<Function> functions = new ArrayList<Function>();
-      schema.setFunctions(functions);
-      functions.add((new Function().setName("FunctionWOParameter")
-          .setReturnType(new ReturnType().setType(new FullQualifiedName(ns, 
"CTBaseName")))));
-      functions.add(new 
Function().setName("FunctionName").setBound(true).setParameters(parameters).setReturnType(
-          new ReturnType().setType(new FullQualifiedName(ns, "CTBaseName"))));
-
-      List<EnumType> enumTypes = new ArrayList<EnumType>();
-      schema.setEnumTypes(enumTypes);
-      List<EnumMember> members = new ArrayList<EnumMember>();
-      members.add(new EnumMember().setName("member").setValue("1"));
-      enumTypes.add(new 
EnumType().setName("EnumName").setFlags(true).setMembers(members));
-
-      List<TypeDefinition> typeDefinitions = new ArrayList<TypeDefinition>();
-      schema.setTypeDefinitions(typeDefinitions);
-      typeDefinitions.add(new TypeDefinition().setName("typeDef")
-          
.setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()));
-
-      EntityContainer container = new EntityContainer().setName("container");
-      schema.setEntityContainer(container);
-
-      List<ActionImport> actionImports = new ArrayList<ActionImport>();
-      container.setActionImports(actionImports);
-      actionImports.add(new ActionImport().setName("actionImport").setAction(
-          new FullQualifiedName(ns, "ActionWOParameter")).setEntitySet(
-          new Target().setEntityContainer(new FullQualifiedName(ns, 
"container")).setTargetName("EntitySetName")));
-
-      List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
-      container.setFunctionImports(functionImports);
-      functionImports.add(new 
FunctionImport().setName("actionImport").setFunction(
-          new FullQualifiedName(ns, "FunctionName")).setEntitySet(
-          new Target().setEntityContainer(new FullQualifiedName(ns, 
"container")).setTargetName("EntitySetName")));
-
-      List<EntitySet> entitySets = new ArrayList<EntitySet>();
-      container.setEntitySets(entitySets);
-      List<NavigationPropertyBinding> nPB = new 
ArrayList<NavigationPropertyBinding>();
-      nPB.add(new NavigationPropertyBinding().setPath("N1").setTarget(
-          new Target().setEntityContainer(new FullQualifiedName(ns, 
"container")).setTargetName("EntitySetName")));
-      entitySets.add(new EntitySet().setName("EntitySetName").setType(new 
FullQualifiedName(ns, "ETBaseName"))
-          .setNavigationPropertyBindings(nPB));
-
-      List<Singleton> singletons = new ArrayList<Singleton>();
-      container.setSingletons(singletons);
-      singletons.add(new Singleton().setName("SingletonName").setType(new 
FullQualifiedName(ns, "ETBaseName"))
-          .setNavigationPropertyBindings(nPB));
-
-      List<Schema> schemas = new ArrayList<Schema>();
-      schemas.add(schema);
-      return schemas;
-    }
+    EdmxReference reference = new EdmxReference(URI.create(CORE_VOCABULARY));
+    reference.addInclude(new EdmxReferenceInclude("Org.OData.Core.V1", 
"Core"));
+    return Arrays.asList(reference);
   }
 }

Reply via email to