You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/11/14 17:49:14 UTC

git commit: [OLINGO-68] Support alias in edm impl

Updated Branches:
  refs/heads/master b6772ec1f -> 82f439376


[OLINGO-68] Support alias in edm impl


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/82f43937
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/82f43937
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/82f43937

Branch: refs/heads/master
Commit: 82f4393760c00026e05a0cb1b445e8181f644690
Parents: b6772ec
Author: Christian Amend <ch...@apache.org>
Authored: Thu Nov 14 17:47:57 2013 +0100
Committer: Christian Amend <ch...@apache.org>
Committed: Thu Nov 14 17:47:57 2013 +0100

----------------------------------------------------------------------
 .../odata2/api/edm/provider/AliasInfo.java      | 61 ++++++++++++++++++++
 .../odata2/api/edm/provider/EdmProvider.java    |  5 ++
 .../apache/olingo/odata2/core/edm/EdmImpl.java  | 38 ++++++++++--
 .../odata2/core/edm/provider/EdmImplProv.java   | 15 +++++
 .../odata2/core/edm/provider/EdmxProvider.java  | 16 +++++
 .../core/ep/consumer/XmlMetadataConsumer.java   |  2 +-
 .../olingo/odata2/core/edm/EdmImplTest.java     |  7 +++
 .../core/edm/provider/EdmImplProvTest.java      | 41 ++++++++++++-
 .../core/edm/provider/EdmxProviderTest.java     | 40 +++++++++----
 .../odata2/testutil/mock/EdmTestProvider.java   | 10 ++++
 10 files changed, 213 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/82f43937/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/AliasInfo.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/AliasInfo.java b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/AliasInfo.java
new file mode 100644
index 0000000..5bf09ca
--- /dev/null
+++ b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/AliasInfo.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.odata2.api.edm.provider;
+
+/**
+ * Objects of this class hold an alias and the associated namespace
+ */
+public class AliasInfo {
+
+  private String alias;
+  private String namespace;
+
+  /**
+   * @return the alias
+   */
+  public String getAlias() {
+    return alias;
+  }
+
+  /**
+   * @param alias
+   * @return {@link AliasInfo} for method chaining
+   */
+  public AliasInfo setAlias(String alias) {
+    this.alias = alias;
+    return this;
+  }
+
+  /**
+   * @return the namespace which is associated with this alias
+   */
+  public String getNamespace() {
+    return namespace;
+  }
+
+  /**
+   * @param namespace
+   * @return {@link AliasInfo} for method chaining
+   */
+  public AliasInfo setNamespace(String namespace) {
+    this.namespace = namespace;
+    return this;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/82f43937/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/EdmProvider.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/EdmProvider.java b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/EdmProvider.java
index bc793eb..9462131 100644
--- a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/EdmProvider.java
+++ b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/EdmProvider.java
@@ -116,4 +116,9 @@ public abstract class EdmProvider {
   public List<Schema> getSchemas() throws ODataException {
     throw new ODataNotImplementedException();
   }
+
+  public List<AliasInfo> getAliasInfos() throws ODataException {
+    return null;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/82f43937/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmImpl.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmImpl.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmImpl.java
index eae2bde..80f3776 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmImpl.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmImpl.java
@@ -43,6 +43,7 @@ public abstract class EdmImpl implements Edm {
   private Map<FullQualifiedName, EdmEntityType> edmEntityTypes;
   private Map<FullQualifiedName, EdmComplexType> edmComplexTypes;
   private Map<FullQualifiedName, EdmAssociation> edmAssociations;
+  private Map<String, String> aliasToNamespaceInfo;
   private List<EdmEntitySet> edmEntitySets;
   private List<EdmFunctionImport> edmFunctionImports;
 
@@ -88,8 +89,10 @@ public abstract class EdmImpl implements Edm {
   }
 
   @Override
-  public EdmEntityType getEntityType(final String namespace, final String name) throws EdmException {
-    FullQualifiedName fqName = new FullQualifiedName(namespace, name);
+  public EdmEntityType getEntityType(final String namespaceOrAlias, final String name) throws EdmException {
+    String finalNamespace = getNamespaceForAlias(namespaceOrAlias);
+
+    FullQualifiedName fqName = new FullQualifiedName(finalNamespace, name);
     if (edmEntityTypes.containsKey(fqName)) {
       return edmEntityTypes.get(fqName);
     }
@@ -108,9 +111,29 @@ public abstract class EdmImpl implements Edm {
     return edmEntityType;
   }
 
+  private String getNamespaceForAlias(final String namespaceOrAlias) throws EdmException {
+    if (aliasToNamespaceInfo == null) {
+      try {
+        aliasToNamespaceInfo = createAliasToNamespaceInfo();
+        if (aliasToNamespaceInfo == null) {
+          aliasToNamespaceInfo = new HashMap<String, String>();
+        }
+      } catch (ODataException e) {
+        throw new EdmException(EdmException.COMMON, e);
+      }
+    }
+    String namespace = aliasToNamespaceInfo.get(namespaceOrAlias);
+    // If not contained in info it must be a namespace
+    if (namespace == null) {
+      namespace = namespaceOrAlias;
+    }
+    return namespace;
+  }
+
   @Override
-  public EdmComplexType getComplexType(final String namespace, final String name) throws EdmException {
-    FullQualifiedName fqName = new FullQualifiedName(namespace, name);
+  public EdmComplexType getComplexType(final String namespaceOrAlias, final String name) throws EdmException {
+    String finalNamespace = getNamespaceForAlias(namespaceOrAlias);
+    FullQualifiedName fqName = new FullQualifiedName(finalNamespace, name);
     if (edmComplexTypes.containsKey(fqName)) {
       return edmComplexTypes.get(fqName);
     }
@@ -130,8 +153,9 @@ public abstract class EdmImpl implements Edm {
   }
 
   @Override
-  public EdmAssociation getAssociation(final String namespace, final String name) throws EdmException {
-    FullQualifiedName fqName = new FullQualifiedName(namespace, name);
+  public EdmAssociation getAssociation(final String namespaceOrAlias, final String name) throws EdmException {
+    String finalNamespace = getNamespaceForAlias(namespaceOrAlias);
+    FullQualifiedName fqName = new FullQualifiedName(finalNamespace, name);
     if (edmAssociations.containsKey(fqName)) {
       return edmAssociations.get(fqName);
     }
@@ -195,4 +219,6 @@ public abstract class EdmImpl implements Edm {
   protected abstract List<EdmEntitySet> createEntitySets() throws ODataException;
 
   protected abstract List<EdmFunctionImport> createFunctionImports() throws ODataException;
+
+  protected abstract Map<String, String> createAliasToNamespaceInfo() throws ODataException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/82f43937/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java
index 60ecc83..f647dc9 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java
@@ -19,7 +19,9 @@
 package org.apache.olingo.odata2.core.edm.provider;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.olingo.odata2.api.edm.EdmAssociation;
 import org.apache.olingo.odata2.api.edm.EdmComplexType;
@@ -28,6 +30,7 @@ import org.apache.olingo.odata2.api.edm.EdmEntitySet;
 import org.apache.olingo.odata2.api.edm.EdmEntityType;
 import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
 import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.AliasInfo;
 import org.apache.olingo.odata2.api.edm.provider.Association;
 import org.apache.olingo.odata2.api.edm.provider.ComplexType;
 import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
@@ -126,4 +129,16 @@ public class EdmImplProv extends EdmImpl implements EdmProviderAccessor {
     }
     return edmFunctionImports;
   }
+
+  @Override
+  protected Map<String, String> createAliasToNamespaceInfo() throws ODataException {
+    List<AliasInfo> aliasInfos = edmProvider.getAliasInfos();
+    Map<String, String> aliasToNamespaceInfo = new HashMap<String, String>();
+    if (aliasInfos != null) {
+      for (AliasInfo info : aliasInfos) {
+        aliasToNamespaceInfo.put(info.getAlias(), info.getNamespace());
+      }
+    }
+    return aliasToNamespaceInfo;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/82f43937/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmxProvider.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmxProvider.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmxProvider.java
index 4edd055..7c338c5 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmxProvider.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmxProvider.java
@@ -19,11 +19,13 @@
 package org.apache.olingo.odata2.core.edm.provider;
 
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.AliasInfo;
 import org.apache.olingo.odata2.api.edm.provider.Association;
 import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
 import org.apache.olingo.odata2.api.edm.provider.ComplexType;
@@ -40,6 +42,8 @@ import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.core.commons.XmlHelper;
 import org.apache.olingo.odata2.core.ep.consumer.XmlMetadataConsumer;
 
+import com.sun.org.apache.bcel.internal.generic.ARRAYLENGTH;
+
 public class EdmxProvider extends EdmProvider {
   private DataServices dataServices;
 
@@ -171,4 +175,16 @@ public class EdmxProvider extends EdmProvider {
   public List<Schema> getSchemas() throws ODataException {
     return dataServices.getSchemas();
   }
+  
+  @Override
+  public List<AliasInfo> getAliasInfos(){
+    List<AliasInfo> aliasInfos = new ArrayList<AliasInfo>();
+    for(Schema schema : dataServices.getSchemas()){
+      if(schema.getAlias() != null){
+        aliasInfos.add(new AliasInfo().setAlias(schema.getAlias()).setNamespace(schema.getNamespace()));
+      }
+    }
+    
+    return aliasInfos;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/82f43937/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
index 028a219..7918aeb 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
@@ -1015,7 +1015,7 @@ public class XmlMetadataConsumer {
 
   private void validateAssociationEnd(final AssociationSetEnd end, final Association association)
       throws EntityProviderException {
-    if (!(association.getEnd1().getRole().equals(end.getRole()) ^ 
+    if (!(association.getEnd1().getRole().equals(end.getRole()) ^
         association.getEnd2().getRole().equals(end.getRole()))) {
       throw new EntityProviderException(EntityProviderException.COMMON.addContent("Invalid Association"));
     }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/82f43937/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/EdmImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/EdmImplTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/EdmImplTest.java
index 8d2cfa3..ab5e53f 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/EdmImplTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/EdmImplTest.java
@@ -24,7 +24,9 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.olingo.odata2.api.edm.EdmAssociation;
 import org.apache.olingo.odata2.api.edm.EdmComplexType;
@@ -135,5 +137,10 @@ public class EdmImplTest extends BaseTest {
       List<EdmFunctionImport> edmFunctionImports = new ArrayList<EdmFunctionImport>();
       return edmFunctionImports;
     }
+
+    @Override
+    protected Map<String, String> createAliasToNamespaceInfo() throws ODataException {
+      return new HashMap<String, String>();
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/82f43937/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProvTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProvTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProvTest.java
index 5552d94..574b1f5 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProvTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProvTest.java
@@ -22,8 +22,15 @@ import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmAssociation;
+import org.apache.olingo.odata2.api.edm.EdmComplexType;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
 import org.apache.olingo.odata2.api.edm.EdmException;
 import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.AliasInfo;
 import org.apache.olingo.odata2.api.edm.provider.Association;
 import org.apache.olingo.odata2.api.edm.provider.ComplexType;
 import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
@@ -41,14 +48,24 @@ public class EdmImplProvTest extends BaseTest {
   public static void getEdmImpl() throws Exception {
     EdmProvider edmProvider = mock(EdmProvider.class);
 
+    List<AliasInfo> aliasInfos = new ArrayList<AliasInfo>();
+
     EntityType entityType = new EntityType().setName("EntityType1");
     when(edmProvider.getEntityType(new FullQualifiedName("EntityType1Ns", "EntityType1"))).thenReturn(entityType);
+    AliasInfo aliasInfo1 = new AliasInfo().setAlias("et1").setNamespace("EntityType1Ns");
+    aliasInfos.add(aliasInfo1);
 
     ComplexType complexType = new ComplexType().setName("ComplexType1");
     when(edmProvider.getComplexType(new FullQualifiedName("ComplexType1Ns", "ComplexType1"))).thenReturn(complexType);
+    AliasInfo aliasInfo2 = new AliasInfo().setAlias("ct1").setNamespace("ComplexType1Ns");
+    aliasInfos.add(aliasInfo2);
 
     Association association = new Association().setName("Association1");
     when(edmProvider.getAssociation(new FullQualifiedName("Association1Ns", "Association1"))).thenReturn(association);
+    AliasInfo aliasInfo3 = new AliasInfo().setAlias("at1").setNamespace("Association1Ns");
+    aliasInfos.add(aliasInfo3);
+
+    when(edmProvider.getAliasInfos()).thenReturn(aliasInfos);
 
     EntityContainerInfo defaultEntityContainer = new EntityContainerInfo().setName("Container1");
     when(edmProvider.getEntityContainerInfo(null)).thenReturn(defaultEntityContainer);
@@ -59,17 +76,35 @@ public class EdmImplProvTest extends BaseTest {
 
   @Test
   public void testEntityType() throws EdmException {
-    assertEquals("EntityType1", edm.getEntityType("EntityType1Ns", "EntityType1").getName());
+    EdmEntityType entityType = edm.getEntityType("EntityType1Ns", "EntityType1");
+    assertEquals("EntityType1", entityType.getName());
+
+    EdmEntityType entityTypeWithAlias = edm.getEntityType("et1", "EntityType1");
+    assertEquals("EntityType1", entityTypeWithAlias.getName());
+
+    assertEquals(entityType, entityTypeWithAlias);
   }
 
   @Test
   public void testComplexType() throws EdmException {
-    assertEquals("ComplexType1", edm.getComplexType("ComplexType1Ns", "ComplexType1").getName());
+    EdmComplexType complexType = edm.getComplexType("ComplexType1Ns", "ComplexType1");
+    assertEquals("ComplexType1", complexType.getName());
+
+    EdmComplexType complexTypeWithAlias = edm.getComplexType("ct1", "ComplexType1");
+    assertEquals("ComplexType1", complexTypeWithAlias.getName());
+
+    assertEquals(complexType, complexTypeWithAlias);
   }
 
   @Test
   public void testAssociation() throws EdmException {
-    assertEquals("Association1", edm.getAssociation("Association1Ns", "Association1").getName());
+    EdmAssociation association = edm.getAssociation("Association1Ns", "Association1");
+    assertEquals("Association1", association.getName());
+
+    EdmAssociation associationWithAlias = edm.getAssociation("at1", "Association1");
+    assertEquals("Association1", associationWithAlias.getName());
+
+    assertEquals(association, associationWithAlias);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/82f43937/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmxProviderTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmxProviderTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmxProviderTest.java
index 1fc1419..22e4f4e 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmxProviderTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmxProviderTest.java
@@ -24,8 +24,6 @@ import static org.junit.Assert.assertNotNull;
 import java.io.InputStream;
 import java.util.List;
 
-import javax.xml.stream.XMLStreamException;
-
 import org.apache.olingo.odata2.api.edm.Edm;
 import org.apache.olingo.odata2.api.edm.EdmEntitySet;
 import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
@@ -37,8 +35,6 @@ import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
 import org.apache.olingo.odata2.api.edm.provider.EntityType;
 import org.apache.olingo.odata2.api.edm.provider.Schema;
 import org.apache.olingo.odata2.api.ep.EntityProvider;
-import org.apache.olingo.odata2.api.ep.EntityProviderException;
-import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.api.processor.ODataResponse;
 import org.apache.olingo.odata2.testutil.mock.EdmTestProvider;
 import org.junit.Test;
@@ -46,7 +42,27 @@ import org.junit.Test;
 public class EdmxProviderTest {
 
   @Test
-  public void testEntityType() throws EntityProviderException, ODataException, XMLStreamException {
+  public void getElementsWithAlias() throws Exception {
+    Edm edm = createEdm();
+    assertNotNull(edm);
+
+    assertNotNull(edm.getEntityType("Self", "Employee"));
+    assertNotNull(edm.getEntityType("Self", "Room"));
+    assertNotNull(edm.getEntityType("Self", "Manager"));
+    assertNotNull(edm.getEntityType("Self", "Team"));
+    assertNotNull(edm.getEntityType("Self", "Building"));
+
+    assertNotNull(edm.getAssociation("Self", "BuildingRooms"));
+    assertNotNull(edm.getAssociation("Self", "ManagerEmployees"));
+    assertNotNull(edm.getAssociation("Self", "TeamEmployees"));
+    assertNotNull(edm.getAssociation("Self", "RoomEmployees"));
+
+    assertNotNull(edm.getComplexType("Self", "c_Location"));
+    assertNotNull(edm.getComplexType("Self", "c_City"));
+  }
+
+  @Test
+  public void testEntityType() throws Exception {
     Edm edm = createEdm();
 
     assertNotNull(edm);
@@ -63,7 +79,7 @@ public class EdmxProviderTest {
   }
 
   @Test
-  public void testAssociation() throws EntityProviderException, ODataException, XMLStreamException {
+  public void testAssociation() throws Exception {
     Edm edm = createEdm();
     assertNotNull(edm);
 
@@ -80,7 +96,7 @@ public class EdmxProviderTest {
   }
 
   @Test
-  public void testAssociationSet() throws EntityProviderException, ODataException, XMLStreamException {
+  public void testAssociationSet() throws Exception {
     EdmProvider testProvider = new EdmTestProvider();
     Edm edm = createEdm();
     assertNotNull(edm);
@@ -99,7 +115,7 @@ public class EdmxProviderTest {
   }
 
   @Test
-  public void testSchema() throws EntityProviderException, ODataException, XMLStreamException {
+  public void testSchema() throws Exception {
     EdmProvider testProvider = new EdmTestProvider();
     Edm edm = createEdm();
     assertNotNull(edm);
@@ -119,7 +135,7 @@ public class EdmxProviderTest {
   }
 
   @Test
-  public void testContainer() throws EntityProviderException, ODataException, XMLStreamException {
+  public void testContainer() throws Exception {
     EdmProvider testProvider = new EdmTestProvider();
     Edm edm = createEdm();
     assertNotNull(edm);
@@ -138,7 +154,7 @@ public class EdmxProviderTest {
   }
 
   @Test
-  public void testEntitySets() throws EntityProviderException, ODataException {
+  public void testEntitySets() throws Exception {
     Edm edm = createEdm();
     assertNotNull(edm);
 
@@ -147,7 +163,7 @@ public class EdmxProviderTest {
   }
 
   @Test
-  public void testFunctionImports() throws EntityProviderException, ODataException {
+  public void testFunctionImports() throws Exception {
     Edm edm = createEdm();
     assertNotNull(edm);
 
@@ -155,7 +171,7 @@ public class EdmxProviderTest {
     assertEquals(7, functionImports.size());
   }
 
-  private Edm createEdm() throws EntityProviderException, ODataException {
+  private Edm createEdm() throws Exception {
     EdmProvider testProvider = new EdmTestProvider();
     ODataResponse response = EntityProvider.writeMetadata(testProvider.getSchemas(), null);
     InputStream in = (InputStream) response.getEntity();

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/82f43937/odata2-lib/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/mock/EdmTestProvider.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/mock/EdmTestProvider.java b/odata2-lib/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/mock/EdmTestProvider.java
index cb9392b..c41f3fa 100644
--- a/odata2-lib/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/mock/EdmTestProvider.java
+++ b/odata2-lib/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/mock/EdmTestProvider.java
@@ -27,6 +27,7 @@ import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
 import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
 import org.apache.olingo.odata2.api.edm.EdmTargetPath;
 import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.AliasInfo;
 import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute;
 import org.apache.olingo.odata2.api.edm.provider.AnnotationElement;
 import org.apache.olingo.odata2.api.edm.provider.Association;
@@ -100,13 +101,22 @@ public class EdmTestProvider extends EdmProvider {
   private static final String FUNCTION_IMPORT_5 = "MostCommonLocation";
   private static final String FUNCTION_IMPORT_6 = "ManagerPhoto";
   private static final String FUNCTION_IMPORT_7 = "OldestEmployee";
+  private static final String SCHEMA_ALIAS = "Self";
 
   @Override
+  public List<AliasInfo> getAliasInfos(){
+    List<AliasInfo> aliasInfos = new ArrayList<AliasInfo>();
+    aliasInfos.add(new AliasInfo().setAlias(SCHEMA_ALIAS).setNamespace(NAMESPACE_1));
+    return aliasInfos;
+  }
+  
+  @Override
   public List<Schema> getSchemas() throws ODataException {
     final List<Schema> schemas = new ArrayList<Schema>();
 
     Schema schema = new Schema();
     schema.setNamespace(NAMESPACE_1);
+    schema.setAlias(SCHEMA_ALIAS);
 
     final List<EntityType> entityTypes = new ArrayList<EntityType>();
     entityTypes.add(getEntityType(ENTITY_TYPE_1_1));