You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2013/07/26 13:22:07 UTC

[02/51] [partial] initial commit

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProvTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProvTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProvTest.java
new file mode 100644
index 0000000..7fe398c
--- /dev/null
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProvTest.java
@@ -0,0 +1,285 @@
+/*******************************************************************************
+ * 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.core.edm.provider;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXpathExists;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+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.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.custommonkey.xmlunit.SimpleNamespaceContext;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmEntitySetInfo;
+import org.apache.olingo.odata2.api.edm.EdmServiceMetadata;
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.testutil.fit.BaseTest;
+import org.apache.olingo.odata2.testutil.helper.StringHelper;
+import org.apache.olingo.odata2.testutil.mock.EdmTestProvider;
+
+/**
+ * @author SAP AG
+ */
+public class EdmServiceMetadataImplProvTest extends BaseTest {
+
+  private static String metadata;
+
+  @BeforeClass
+  public static void setup() throws Exception {
+    EdmImplProv edmImplProv = new EdmImplProv(new EdmTestProvider());
+    EdmServiceMetadata serviceMetadata = edmImplProv.getServiceMetadata();
+    metadata = StringHelper.inputStreamToString(serviceMetadata.getMetadata());
+    Map<String, String> prefixMap = new HashMap<String, String>();
+    prefixMap.put("a", Edm.NAMESPACE_EDM_2008_09);
+    prefixMap.put("edmx", Edm.NAMESPACE_EDMX_2007_06);
+    prefixMap.put("m", Edm.NAMESPACE_M_2007_08);
+    prefixMap.put("annoPrefix", "http://annoNamespace");
+
+    XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
+  }
+
+  @Test
+  public void getEntitySetInfosForEmptyEdmProvider() throws Exception {
+    EdmProvider edmProvider = mock(EdmProvider.class);
+    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider);
+
+    List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos();
+    assertNotNull(infos);
+    assertEquals(Collections.emptyList(), infos);
+  }
+
+  @Test
+  public void getEntitySetInfosForEmptyEdmProviderSchemas() throws Exception {
+    List<Schema> schemas = new ArrayList<Schema>();
+
+    EdmProvider edmProvider = mock(EdmProvider.class);
+    when(edmProvider.getSchemas()).thenReturn(schemas);
+
+    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider);
+
+    List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos();
+    assertNotNull(infos);
+    assertEquals(Collections.emptyList(), infos);
+  }
+
+  @Test
+  public void oneEntitySetOneContainerForInfo() throws Exception {
+    String entitySetUriString = new URI("Employees").toASCIIString();
+
+    List<EntitySet> entitySets = new ArrayList<EntitySet>();
+    EntitySet entitySet = new EntitySet().setName("Employees");
+    entitySets.add(entitySet);
+
+    List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
+    EntityContainer container = new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(entitySets);
+    entityContainers.add(container);
+
+    List<Schema> schemas = new ArrayList<Schema>();
+    schemas.add(new Schema().setEntityContainers(entityContainers));
+
+    EdmProvider edmProvider = mock(EdmProvider.class);
+    when(edmProvider.getSchemas()).thenReturn(schemas);
+
+    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider);
+
+    List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos();
+    assertNotNull(infos);
+    assertEquals(1, infos.size());
+
+    assertEquals(infos.get(0).getEntitySetName(), "Employees");
+    assertEquals(infos.get(0).getEntityContainerName(), "Container");
+    assertEquals(infos.get(0).getEntitySetUri().toASCIIString(), entitySetUriString);
+    assertTrue(infos.get(0).isDefaultEntityContainer());
+  }
+
+  @Test
+  public void twoEntitySetsOneContainerForInfo() throws Exception {
+    List<EntitySet> entitySets = new ArrayList<EntitySet>();
+    EntitySet entitySet = new EntitySet().setName("Employees");
+    entitySets.add(entitySet);
+    entitySets.add(entitySet);
+
+    List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
+    EntityContainer container = new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(entitySets);
+    entityContainers.add(container);
+
+    List<Schema> schemas = new ArrayList<Schema>();
+    schemas.add(new Schema().setEntityContainers(entityContainers));
+
+    EdmProvider edmProvider = mock(EdmProvider.class);
+    when(edmProvider.getSchemas()).thenReturn(schemas);
+
+    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider);
+
+    List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos();
+    assertNotNull(infos);
+    assertEquals(2, infos.size());
+  }
+
+  @Test
+  public void twoContainersWithOneEntitySetEachForInfo() throws Exception {
+    String entitySetUriString = new URI("Employees").toASCIIString();
+    String entitySetUriString2 = new URI("Container2.Employees").toASCIIString();
+
+    List<EntitySet> entitySets = new ArrayList<EntitySet>();
+    EntitySet entitySet = new EntitySet().setName("Employees");
+    entitySets.add(entitySet);
+
+    List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
+    EntityContainer container = new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(entitySets);
+    entityContainers.add(container);
+
+    EntityContainer container2 = new EntityContainer().setDefaultEntityContainer(false).setName("Container2").setEntitySets(entitySets);
+    entityContainers.add(container2);
+
+    List<Schema> schemas = new ArrayList<Schema>();
+    schemas.add(new Schema().setEntityContainers(entityContainers));
+
+    EdmProvider edmProvider = mock(EdmProvider.class);
+    when(edmProvider.getSchemas()).thenReturn(schemas);
+
+    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider);
+
+    List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos();
+    assertNotNull(infos);
+    assertEquals(2, infos.size());
+
+    assertEquals(infos.get(0).getEntitySetName(), "Employees");
+    assertEquals(infos.get(0).getEntityContainerName(), "Container");
+    assertEquals(infos.get(0).getEntitySetUri().toASCIIString(), entitySetUriString);
+    assertTrue(infos.get(0).isDefaultEntityContainer());
+
+    assertEquals(infos.get(1).getEntitySetName(), "Employees");
+    assertEquals(infos.get(1).getEntityContainerName(), "Container2");
+    assertEquals(infos.get(1).getEntitySetUri().toASCIIString(), entitySetUriString2);
+    assertFalse(infos.get(1).isDefaultEntityContainer());
+  }
+
+  @Test
+  public void oneEntitySetsOneContainerTwoSchemadForInfo() throws Exception {
+    List<EntitySet> entitySets = new ArrayList<EntitySet>();
+    EntitySet entitySet = new EntitySet().setName("Employees");
+    entitySets.add(entitySet);
+
+    List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
+    EntityContainer container = new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(entitySets);
+    entityContainers.add(container);
+
+    List<Schema> schemas = new ArrayList<Schema>();
+    schemas.add(new Schema().setEntityContainers(entityContainers));
+    schemas.add(new Schema().setEntityContainers(entityContainers));
+
+    EdmProvider edmProvider = mock(EdmProvider.class);
+    when(edmProvider.getSchemas()).thenReturn(schemas);
+
+    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider);
+
+    List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos();
+    assertNotNull(infos);
+    assertEquals(2, infos.size());
+  }
+
+  @Test
+  public void dataServiceVersion() throws Exception {
+    EdmProvider edmProvider = mock(EdmProvider.class);
+    EdmImplProv edmImplProv = new EdmImplProv(edmProvider);
+
+    EdmServiceMetadata serviceMetadata = edmImplProv.getServiceMetadata();
+    assertEquals("1.0", serviceMetadata.getDataServiceVersion());
+  }
+
+  @Test
+  public void testSchemaStructure() throws Exception {
+    assertXpathExists("/edmx:Edmx", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:ComplexType", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:Association", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityContainer", metadata);
+  }
+
+  @Test
+  public void testEntityTypeStructure() throws Exception {
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType[@Name and @m:HasStream]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType[@Name and @BaseType and @m:HasStream]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Key", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Key/a:PropertyRef[@Name]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name and @Type]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name and @Type and @Nullable and @m:FC_TargetPath]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:NavigationProperty[@Name and @Relationship and @FromRole and @ToRole]", metadata);
+  }
+
+  @Test
+  public void testAnnotations() throws Exception {
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name and @Type and @Nullable and @annoPrefix:annoName]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name and @Type and @m:FC_TargetPath and @annoPrefix:annoName]", metadata);
+  }
+
+  @Test
+  public void testComplexTypeStructure() throws Exception {
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:ComplexType[@Name]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:ComplexType/a:Property[@Name and @Type]", metadata);
+  }
+
+  @Test
+  public void testEntityContainerStructure() throws Exception {
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityContainer[@Name]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityContainer/a:EntitySet[@Name and @EntityType]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityContainer/a:AssociationSet[@Name and @Association]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityContainer//a:AssociationSet/a:End[@EntitySet and @Role]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityContainer/a:FunctionImport[@Name and @ReturnType and @EntitySet and @m:HttpMethod]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityContainer/a:FunctionImport/a:Parameter[@Name and @Type]", metadata);
+  }
+
+  @Test
+  public void testAssociationStructure() throws Exception {
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:Association[@Name]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:Association/a:End[@Type and @Multiplicity and @Role]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:Association/a:ReferentialConstraint/a:Principal[@Role]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:Association/a:ReferentialConstraint/a:Principal[@Role]/a:PropertyRef[@Name]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:Association/a:ReferentialConstraint/a:Dependent[@Role]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:Association/a:ReferentialConstraint/a:Dependent[@Role]/a:PropertyRef[@Name]", metadata);
+  }
+
+  @Test
+  public void testRefScenarioContent() throws Exception {
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType[@Name='Employee']", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType[@Name='Base']", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType[@Name='Team']", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType[@Name='Room']", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType[@Name='Building']", metadata);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/AbstractProviderTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/AbstractProviderTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/AbstractProviderTest.java
new file mode 100644
index 0000000..6a47e7a
--- /dev/null
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/AbstractProviderTest.java
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * 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.core.ep;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.custommonkey.xmlunit.SimpleNamespaceContext;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.ep.EntityProvider.EntityProviderInterface;
+import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.api.ep.callback.TombstoneCallback;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.uri.PathInfo;
+
+/**
+ * @author SAP AG
+*/
+public abstract class AbstractProviderTest extends AbstractXmlProducerTestHelper {
+
+  public AbstractProviderTest(final StreamWriterImplType type) {
+    super(type);
+  }
+
+  protected final Logger log = LoggerFactory.getLogger(this.getClass());
+
+  protected static final URI BASE_URI;
+
+  static {
+    try {
+      BASE_URI = new URI("http://host:80/service/");
+    } catch (URISyntaxException e) {
+      throw new RuntimeException(e);
+    }
+  }
+  protected static final EntityProviderWriteProperties DEFAULT_PROPERTIES = EntityProviderWriteProperties.serviceRoot(BASE_URI).build();
+
+  protected Map<String, Object> employeeData;
+
+  protected ArrayList<Map<String, Object>> employeesData;
+
+  protected Map<String, Object> photoData;
+
+  protected Map<String, Object> roomData;
+
+  protected Map<String, Object> buildingData;
+
+  protected ArrayList<Map<String, Object>> roomsData;
+
+  {
+    employeeData = new HashMap<String, Object>();
+
+    Calendar date = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+    date.clear();
+    date.set(1999, 0, 1);
+
+    employeeData.put("EmployeeId", "1");
+    employeeData.put("ImmageUrl", null);
+    employeeData.put("ManagerId", "1");
+    employeeData.put("Age", new Integer(52));
+    employeeData.put("RoomId", "1");
+    employeeData.put("EntryDate", date);
+    employeeData.put("TeamId", "42");
+    employeeData.put("EmployeeName", "Walter Winter");
+
+    Map<String, Object> locationData = new HashMap<String, Object>();
+    Map<String, Object> cityData = new HashMap<String, Object>();
+    cityData.put("PostalCode", "33470");
+    cityData.put("CityName", "Duckburg");
+    locationData.put("City", cityData);
+    locationData.put("Country", "Calisota");
+
+    employeeData.put("Location", locationData);
+
+    Map<String, Object> employeeData2 = new HashMap<String, Object>();
+    employeeData2.put("EmployeeId", "1");
+    employeeData2.put("ImmageUrl", null);
+    employeeData2.put("ManagerId", "1");
+    employeeData2.put("Age", new Integer(52));
+    employeeData2.put("RoomId", "1");
+    employeeData2.put("EntryDate", date);
+    employeeData2.put("TeamId", "42");
+    employeeData2.put("EmployeeName", "Walter Winter");
+
+    Map<String, Object> locationData2 = new HashMap<String, Object>();
+    Map<String, Object> cityData2 = new HashMap<String, Object>();
+    cityData2.put("PostalCode", "33470");
+    cityData2.put("CityName", "Duckburg");
+    locationData2.put("City", cityData2);
+    locationData2.put("Country", "Calisota");
+
+    employeeData2.put("Location", locationData2);
+
+    employeesData = new ArrayList<Map<String, Object>>();
+    employeesData.add(employeeData);
+    employeesData.add(employeeData2);
+
+    photoData = new HashMap<String, Object>();
+    photoData.put("Id", Integer.valueOf(1));
+    photoData.put("Name", "Mona Lisa");
+    photoData.put("Type", "image/png");
+    photoData.put("ImageUrl", "http://www.mopo.de/image/view/2012/6/4/16548086,13385561,medRes,maxh,234,maxw,234,Parodia_Mona_Lisa_Lego_Hamburger_Morgenpost.jpg");
+    Map<String, Object> imageData = new HashMap<String, Object>();
+    imageData.put("Image", new byte[] { 1, 2, 3, 4 });
+    imageData.put("getImageType", "image/png");
+    photoData.put("Image", imageData);
+    photoData.put("BinaryData", new byte[] { -1, -2, -3, -4 });
+    photoData.put("Содержание", "В лесу шумит водопад. Если он не торопится просп воды");
+
+    roomData = new HashMap<String, Object>();
+    roomData.put("Id", "1");
+    roomData.put("Name", "Neu Schwanstein");
+    roomData.put("Seats", new Integer(20));
+    roomData.put("Version", new Integer(3));
+
+    buildingData = new HashMap<String, Object>();
+    buildingData.put("Id", "1");
+    buildingData.put("Name", "WDF03");
+    buildingData.put("Image", "image");
+  }
+
+  protected void initializeRoomData(final int count) {
+    roomsData = new ArrayList<Map<String, Object>>();
+    for (int i = 1; i <= count; i++) {
+      HashMap<String, Object> tmp = new HashMap<String, Object>();
+      tmp.put("Id", "" + i);
+      tmp.put("Name", "Neu Schwanstein" + i);
+      tmp.put("Seats", new Integer(20));
+      tmp.put("Version", new Integer(3));
+      roomsData.add(tmp);
+    }
+  }
+
+  @Before
+  public void setXmlNamespacePrefixes() throws Exception {
+    Map<String, String> prefixMap = new HashMap<String, String>();
+    prefixMap.put("a", Edm.NAMESPACE_ATOM_2005);
+    prefixMap.put("d", Edm.NAMESPACE_D_2007_08);
+    prefixMap.put("m", Edm.NAMESPACE_M_2007_08);
+    prefixMap.put("xml", Edm.NAMESPACE_XML_1998);
+    prefixMap.put("ру", "http://localhost");
+    prefixMap.put("custom", "http://localhost");
+    prefixMap.put("at", TombstoneCallback.NAMESPACE_TOMBSTONE);
+    XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
+  }
+
+  protected ODataContext createContextMock() throws ODataException {
+    PathInfo pathInfo = mock(PathInfo.class);
+    when(pathInfo.getServiceRoot()).thenReturn(BASE_URI);
+    ODataContext ctx = mock(ODataContext.class);
+    when(ctx.getPathInfo()).thenReturn(pathInfo);
+    return ctx;
+  }
+
+  protected EntityProviderInterface createEntityProvider() throws ODataException, EdmException, EntityProviderException {
+    return new ProviderFacadeImpl();
+  }
+
+  protected AtomEntityProvider createAtomEntityProvider() throws EntityProviderException {
+    return new AtomEntityProvider();
+  }
+
+  public Map<String, Object> getEmployeeData() {
+    return employeeData;
+  }
+
+  public List<Map<String, Object>> getEmployeesData() {
+    return employeesData;
+  }
+
+  public Map<String, Object> getRoomData() {
+    return roomData;
+  }
+
+  public ArrayList<Map<String, Object>> getRoomsData() {
+    return roomsData;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/AbstractXmlProducerTestHelper.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/AbstractXmlProducerTestHelper.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/AbstractXmlProducerTestHelper.java
new file mode 100644
index 0000000..f86b658
--- /dev/null
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/AbstractXmlProducerTestHelper.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.core.ep;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.olingo.odata2.testutil.fit.BaseTest;
+
+@RunWith(Parameterized.class)
+public abstract class AbstractXmlProducerTestHelper extends BaseTest {
+
+  public enum StreamWriterImplType {
+    WOODSTOCKIMPL, SUNINTERNALIMPL;
+  }
+
+  // CHECKSTYLE:OFF
+  public AbstractXmlProducerTestHelper(final StreamWriterImplType type) {
+    switch (type) {
+    case WOODSTOCKIMPL:
+      System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory"); //NOSONAR
+      break;
+    case SUNINTERNALIMPL:
+      System.setProperty("javax.xml.stream.XMLOutputFactory", "com.sun.xml.internal.stream.XMLOutputFactoryImpl"); //NOSONAR
+      break;
+    default:
+      System.setProperty("javax.xml.stream.XMLOutputFactory", "com.sun.xml.internal.stream.XMLOutputFactoryImpl"); //NOSONAR
+      break;
+    }
+  }
+
+  // CHECKSTYLE:On
+
+  @Parameterized.Parameters
+  public static List<Object[]> data() {
+    // If desired this can be made dependent on runtime variables
+    Object[][] a;
+    a = new Object[2][1];
+    a[0][0] = StreamWriterImplType.WOODSTOCKIMPL;
+    a[1][0] = StreamWriterImplType.SUNINTERNALIMPL;
+
+    return Arrays.asList(a);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/BasicProviderTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/BasicProviderTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/BasicProviderTest.java
new file mode 100644
index 0000000..34b9991
--- /dev/null
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/BasicProviderTest.java
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * 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.core.ep;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXpathExists;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.custommonkey.xmlunit.SimpleNamespaceContext;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Test;
+
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.api.processor.ODataResponse;
+import org.apache.olingo.odata2.core.commons.ContentType;
+import org.apache.olingo.odata2.testutil.helper.StringHelper;
+import org.apache.olingo.odata2.testutil.mock.EdmTestProvider;
+import org.apache.olingo.odata2.testutil.mock.MockFacade;
+
+/**
+ * @author SAP AG
+ */
+public class BasicProviderTest extends AbstractProviderTest {
+
+  public BasicProviderTest(final StreamWriterImplType type) {
+    super(type);
+  }
+
+  protected static BasicEntityProvider provider = new BasicEntityProvider();
+
+  @Test
+  public void writeMetadata() throws Exception {
+    Map<String, String> predefinedNamespaces = new HashMap<String, String>();
+    predefinedNamespaces.put("annoPrefix", "http://annoNamespace");
+    predefinedNamespaces.put("sap", "http://sap");
+    predefinedNamespaces.put("annoPrefix2", "http://annoNamespace");
+    predefinedNamespaces.put("annoPrefix", "http://annoNamespace");
+
+    ODataResponse response = provider.writeMetadata(null, predefinedNamespaces);
+    assertNotNull(response);
+    assertNotNull(response.getEntity());
+    assertEquals(ContentType.APPLICATION_XML_CS_UTF_8.toString(), response.getContentHeader());
+    String metadata = StringHelper.inputStreamToString((InputStream) response.getEntity());
+    assertTrue(metadata.contains("xmlns:sap=\"http://sap\""));
+    assertTrue(metadata.contains("xmlns:annoPrefix=\"http://annoNamespace\""));
+    assertTrue(metadata.contains("xmlns:annoPrefix2=\"http://annoNamespace\""));
+  }
+
+  private void setNamespaces() {
+    Map<String, String> prefixMap = new HashMap<String, String>();
+    prefixMap.put("edmx", Edm.NAMESPACE_EDMX_2007_06);
+    prefixMap.put("m", Edm.NAMESPACE_M_2007_08);
+    prefixMap.put("a", Edm.NAMESPACE_EDM_2008_09);
+    prefixMap.put("annoPrefix", "http://annoNamespace");
+    prefixMap.put("prefix", "namespace");
+    prefixMap.put("b", "RefScenario");
+    prefixMap.put("pre", "namespaceForAnno");
+    XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
+  }
+
+  @Test
+  public void writeMetadata2() throws Exception {
+    EdmProvider testProvider = new EdmTestProvider();
+
+    Map<String, String> predefinedNamespaces = new HashMap<String, String>();
+    predefinedNamespaces.put("annoPrefix", "http://annoNamespace");
+    predefinedNamespaces.put("sap", "http://sap");
+    predefinedNamespaces.put("annoPrefix2", "http://annoNamespace");
+    predefinedNamespaces.put("annoPrefix", "http://annoNamespace");
+    predefinedNamespaces.put("prefix", "namespace");
+    predefinedNamespaces.put("pre", "namespaceForAnno");
+
+    ODataResponse response = provider.writeMetadata(testProvider.getSchemas(), predefinedNamespaces);
+    assertNotNull(response);
+    assertNotNull(response.getEntity());
+    assertEquals(ContentType.APPLICATION_XML_CS_UTF_8.toString(), response.getContentHeader());
+    String metadata = StringHelper.inputStreamToString((InputStream) response.getEntity());
+
+    setNamespaces();
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name and @Type and @Nullable and @annoPrefix:annoName]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name and @Type and @m:FC_TargetPath and @annoPrefix:annoName]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name=\"EmployeeName\"]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name=\"EmployeeName\"]/a:propertyAnnoElement", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name=\"EmployeeName\"]/a:propertyAnnoElement2", metadata);
+
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/b:schemaElementTest2", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/prefix:schemaElementTest3", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/a:schemaElementTest4[@rel=\"self\" and @pre:href=\"http://google.com\"]", metadata);
+  }
+
+  @Test
+  public void writeMetadata3() throws Exception {
+    EdmProvider testProvider = new EdmTestProvider();
+
+    ODataResponse response = provider.writeMetadata(testProvider.getSchemas(), null);
+    assertNotNull(response);
+    assertNotNull(response.getEntity());
+    assertEquals(ContentType.APPLICATION_XML_CS_UTF_8.toString(), response.getContentHeader());
+    String metadata = StringHelper.inputStreamToString((InputStream) response.getEntity());
+
+    setNamespaces();
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name and @Type and @Nullable and @annoPrefix:annoName]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name and @Type and @m:FC_TargetPath and @annoPrefix:annoName]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name=\"EmployeeName\"]", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name=\"EmployeeName\"]/a:propertyAnnoElement", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType/a:Property[@Name=\"EmployeeName\"]/a:propertyAnnoElement2", metadata);
+
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/b:schemaElementTest2", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/prefix:schemaElementTest3", metadata);
+    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:schemaElementTest1/a:schemaElementTest4[@rel=\"self\" and @pre:href=\"http://google.com\"]", metadata);
+  }
+
+  @Test
+  public void writePropertyValue() throws Exception {
+    EdmTyped edmTyped = MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+    EdmProperty edmProperty = (EdmProperty) edmTyped;
+
+    ODataResponse response = provider.writePropertyValue(edmProperty, employeeData.get("Age"));
+    assertNotNull(response);
+    assertNotNull(response.getEntity());
+    assertEquals(ContentType.TEXT_PLAIN_CS_UTF_8.toString(), response.getContentHeader());
+    String value = StringHelper.inputStreamToString((InputStream) response.getEntity());
+    assertEquals(employeeData.get("Age").toString(), value);
+  }
+
+  @Test
+  public void readPropertyValue() throws Exception {
+    final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+
+    final Integer age = (Integer) provider.readPropertyValue(property, new ByteArrayInputStream("42".getBytes("UTF-8")), null);
+    assertEquals(Integer.valueOf(42), age);
+  }
+
+  @Test
+  public void readPropertyValueWithMapping() throws Exception {
+    final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+
+    final Long age = (Long) provider.readPropertyValue(property, new ByteArrayInputStream("42".getBytes("UTF-8")), Long.class);
+    assertEquals(Long.valueOf(42), age);
+  }
+
+  @Test(expected = EntityProviderException.class)
+  public void readPropertyValueWithInvalidMapping() throws Exception {
+    final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+
+    final Float age = (Float) provider.readPropertyValue(property, new ByteArrayInputStream("42".getBytes("UTF-8")), Float.class);
+    assertEquals(Float.valueOf(42), age);
+  }
+
+  @Test
+  public void readPropertyBinaryValue() throws Exception {
+    final byte[] bytes = new byte[] { 1, 2, 3, 4, -128 };
+    final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario2", "Photo").getProperty("Image");
+
+    assertTrue(Arrays.equals(bytes, (byte[]) provider.readPropertyValue(property, new ByteArrayInputStream(bytes), null)));
+  }
+
+  @Test
+  public void writeBinary() throws Exception {
+    final byte[] bytes = new byte[] { 49, 50, 51, 52, 65 };
+    final ODataResponse response = provider.writeBinary(ContentType.TEXT_PLAIN_CS_UTF_8.toString(), bytes);
+    assertNotNull(response);
+    assertNotNull(response.getEntity());
+    assertEquals(ContentType.TEXT_PLAIN_CS_UTF_8.toString(), response.getContentHeader());
+    final String value = StringHelper.inputStreamToString((InputStream) response.getEntity());
+    assertEquals("1234A", value);
+  }
+
+  @Test
+  public void readBinary() throws Exception {
+    final byte[] bytes = new byte[] { 1, 2, 3, 4, -128 };
+    assertTrue(Arrays.equals(bytes, provider.readBinary(new ByteArrayInputStream(bytes))));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/LoadXMLFactoryTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/LoadXMLFactoryTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/LoadXMLFactoryTest.java
new file mode 100644
index 0000000..37c2534
--- /dev/null
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/LoadXMLFactoryTest.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.core.ep;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import javax.xml.stream.XMLOutputFactory;
+
+import org.junit.Test;
+
+/**
+ * @author SAP AG
+ */
+public class LoadXMLFactoryTest {
+  // CHECKSTYLE:OFF
+  @Test
+  public void loadWoodstockFactory() throws Exception {
+    System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory"); //NOSONAR
+    XMLOutputFactory factory = XMLOutputFactory.newInstance();
+    assertNotNull(factory);
+    assertEquals("com.ctc.wstx.stax.WstxOutputFactory", factory.getClass().getName());
+  }
+
+  @Test
+  public void loadSunFactory() throws Exception {
+    System.setProperty("javax.xml.stream.XMLOutputFactory", "com.sun.xml.internal.stream.XMLOutputFactoryImpl"); //NOSONAR
+    XMLOutputFactory factory = XMLOutputFactory.newInstance();
+    assertNotNull(factory);
+    assertEquals("com.sun.xml.internal.stream.XMLOutputFactoryImpl", factory.getClass().getName());
+  }
+  // CHECKSTYLE:ON
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ODataEntityProviderPropertiesTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ODataEntityProviderPropertiesTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ODataEntityProviderPropertiesTest.java
new file mode 100644
index 0000000..f1590e3
--- /dev/null
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ODataEntityProviderPropertiesTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.core.ep;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.net.URI;
+
+import org.junit.Test;
+
+import org.apache.olingo.odata2.api.commons.InlineCount;
+import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.testutil.fit.BaseTest;
+
+/**
+ * @author SAP AG
+ */
+public class ODataEntityProviderPropertiesTest extends BaseTest {
+
+  @Test
+  public void buildFeedProperties() throws Exception {
+    URI serviceRoot = new URI("http://localhost:80/");
+    EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(serviceRoot)
+        .inlineCountType(InlineCount.ALLPAGES)
+        .inlineCount(1)
+        .nextLink("http://localhost")
+        .build();
+
+    assertEquals("Wrong base uri.", "http://localhost:80/", properties.getServiceRoot().toASCIIString());
+    assertEquals("Wrong inline count type.", InlineCount.ALLPAGES, properties.getInlineCountType());
+    assertEquals("Wrong inline count.", Integer.valueOf(1), properties.getInlineCount());
+    assertEquals("Wrong nextLink", "http://localhost", properties.getNextLink());
+  }
+
+  @Test
+  public void buildPropertiesDefaults() throws Exception {
+    URI baseUri = new URI("http://localhost:80/");
+    EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(baseUri).build();
+
+    assertEquals("http://localhost:80/", properties.getServiceRoot().toASCIIString());
+    assertNull(properties.getInlineCountType());
+    assertNull(properties.getInlineCount());
+    assertNull(properties.getMediaResourceMimeType());
+    assertNull(properties.getNextLink());
+  }
+
+  @Test
+  public void buildEntryProperties() throws Exception {
+    final String mediaResourceMimeType = "text/html";
+    final URI serviceRoot = new URI("http://localhost:80/");
+    final EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(serviceRoot)
+        .mediaResourceMimeType(mediaResourceMimeType)
+        .build();
+    assertEquals("Wrong mime type.", "text/html", properties.getMediaResourceMimeType());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/PerformanceTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/PerformanceTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/PerformanceTest.java
new file mode 100644
index 0000000..bfbfe69
--- /dev/null
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/PerformanceTest.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.odata2.core.ep;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.custommonkey.xmlunit.exceptions.XpathException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
+import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
+import org.apache.olingo.odata2.core.ep.producer.AtomEntryEntityProducer;
+import org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer;
+import org.apache.olingo.odata2.testutil.helper.StringHelper;
+import org.apache.olingo.odata2.testutil.mock.MockFacade;
+
+/**
+ * @author SAP AG
+ */
+public class PerformanceTest extends AbstractProviderTest {
+
+  public PerformanceTest(final StreamWriterImplType type) {
+    super(type);
+  }
+
+  private static final long TIMES = 100L; // increase for manual performance testing (also increase vm memory -Xmx1G)
+
+  private AtomEntryEntityProducer provider;
+  private EdmEntitySet edmEntitySet;
+  private OutputStream outStream = null;
+  private CircleStreamBuffer csb;
+  private XMLStreamWriter writer;
+
+  private boolean useCsb = true;
+
+  @Before
+  public void before() throws Exception {
+    EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(BASE_URI).build();
+    provider = new AtomEntryEntityProducer(properties);
+    edmEntitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
+
+    if (useCsb) {
+      csb = new CircleStreamBuffer();
+      outStream = csb.getOutputStream();
+    } else {
+      outStream = new ByteArrayOutputStream();
+    }
+
+    writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, "utf-8");
+
+    writer.writeStartElement("junit");
+    writer.writeDefaultNamespace(Edm.NAMESPACE_ATOM_2005);
+    writer.writeNamespace(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08);
+    writer.writeNamespace(Edm.PREFIX_D, Edm.NAMESPACE_D_2007_08);
+    writer.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, "base", "xxx");
+  }
+
+  @After
+  public void after() throws Exception {
+    writer.writeEndElement();
+    writer.flush();
+    outStream.flush();
+
+    if (useCsb) {
+      String content = StringHelper.inputStreamToString(csb.getInputStream());
+      assertNotNull(content);
+    } else {
+      InputStream in = new ByteArrayInputStream(((ByteArrayOutputStream) outStream).toByteArray());
+      String content = StringHelper.inputStreamToString(in);
+      assertNotNull(content);
+    }
+
+    try {
+
+    } finally {
+      outStream.close();
+    }
+  }
+
+  @Test
+  public void readAtomEntry() throws IOException, XpathException, SAXException, XMLStreamException, FactoryConfigurationError, ODataException {
+    long t = startTimer();
+
+    for (int i = 0; i < TIMES; i++) {
+      ExpandSelectTreeNode epProperties = null;
+      EntityInfoAggregator eia = EntityInfoAggregator.create(edmEntitySet, epProperties);
+      provider.append(writer, eia, roomData, false, false);
+    }
+    stopTimer(t, "readAtomEntry");
+  }
+
+  @Test
+  public void readAtomEntryCsb() throws Exception {
+    useCsb = true;
+    before();
+    assertNotNull(csb);
+
+    long t = startTimer();
+
+    for (int i = 0; i < TIMES; i++) {
+      ExpandSelectTreeNode epProperties = null;
+      EntityInfoAggregator eia = EntityInfoAggregator.create(edmEntitySet, epProperties);
+      provider.append(writer, eia, roomData, false, false);
+    }
+    stopTimer(t, "readAtomEntry");
+  }
+
+  @Test
+  public void readAtomEntryOptimized() throws IOException, XpathException, SAXException, XMLStreamException, FactoryConfigurationError, ODataException {
+    long t = startTimer();
+
+    ExpandSelectTreeNode epProperties = null;
+    EntityInfoAggregator eia = EntityInfoAggregator.create(edmEntitySet, epProperties);
+    for (int i = 0; i < TIMES; i++) {
+      provider.append(writer, eia, roomData, false, false);
+    }
+    stopTimer(t, "readAtomEntryOptimized");
+  }
+
+  @Test
+  public void readAtomEntryOptimizedCsb() throws Exception {
+    useCsb = true;
+    before();
+    assertNotNull(csb);
+
+    long t = startTimer();
+
+    ExpandSelectTreeNode epProperties = null;
+    EntityInfoAggregator eia = EntityInfoAggregator.create(edmEntitySet, epProperties);
+    for (int i = 0; i < TIMES; i++) {
+      provider.append(writer, eia, roomData, false, false);
+    }
+    stopTimer(t, "readAtomEntryOptimizedCsb");
+  }
+
+  private void stopTimer(long t, final String msg) {
+    t = (System.nanoTime() - t) / TIMES;
+
+    long millis = t / (1000L * 1000L);
+    long micros = t % (1000L * 1000L);
+
+    long sum = (t * TIMES) / (1000L * 1000L);
+
+    log.debug(msg + ": " + millis + "." + micros / 1000L + "[ms] (" + TIMES + " in " + sum + " [ms])");
+  }
+
+  private long startTimer() {
+    long t = System.nanoTime();
+    return t;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ProviderFacadeImplTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ProviderFacadeImplTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ProviderFacadeImplTest.java
new file mode 100644
index 0000000..e34131d
--- /dev/null
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ProviderFacadeImplTest.java
@@ -0,0 +1,243 @@
+/*******************************************************************************
+ * 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.core.ep;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+import org.apache.olingo.odata2.api.commons.HttpContentType;
+import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties;
+import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
+import org.apache.olingo.odata2.api.processor.ODataResponse;
+import org.apache.olingo.odata2.core.commons.ContentType;
+import org.apache.olingo.odata2.testutil.helper.StringHelper;
+import org.apache.olingo.odata2.testutil.mock.MockFacade;
+
+/**
+ * @author SAP AG
+ */
+public class ProviderFacadeImplTest {
+
+  private static final String EMPLOYEE_1_XML =
+      "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+          "<entry xmlns=\"" + Edm.NAMESPACE_ATOM_2005 + "\"" +
+          " xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\"" +
+          " xmlns:d=\"" + Edm.NAMESPACE_D_2007_08 + "\"" +
+          " xml:base=\"https://some.host.com/some.service.root.segment/ReferenceScenario.svc/\">" +
+          "<id>https://some.host.com/some.service.root.segment/ReferenceScenario.svc/Employees('1')</id>" +
+          "<title type=\"text\">Walter Winter</title>" +
+          "<updated>1999-01-01T00:00:00Z</updated>" +
+          "<category term=\"RefScenario.Employee\" scheme=\"" + Edm.NAMESPACE_SCHEME_2007_08 + "\"/>" +
+          "<link href=\"Employees('1')\" rel=\"edit\" title=\"Employee\"/>" +
+          "<link href=\"Employees('1')/$value\" rel=\"edit-media\" type=\"application/octet-stream\"/>" +
+          "<link href=\"Employees('1')/ne_Room\" rel=\"" + Edm.NAMESPACE_REL_2007_08 + "ne_Room\" type=\"application/atom+xml; type=entry\" title=\"ne_Room\"/>" +
+          "<link href=\"Employees('1')/ne_Manager\" rel=\"" + Edm.NAMESPACE_REL_2007_08 + "ne_Manager\" type=\"application/atom+xml; type=entry\" title=\"ne_Manager\"/>" +
+          "<link href=\"Employees('1')/ne_Team\" rel=\"" + Edm.NAMESPACE_REL_2007_08 + "ne_Team\" type=\"application/atom+xml; type=entry\" title=\"ne_Team\"/>" +
+          "<content type=\"application/octet-stream\" src=\"Employees('1')/$value\"/>" +
+          "<m:properties>" +
+          "<d:EmployeeId>1</d:EmployeeId>" +
+          "<d:EmployeeName>Walter Winter</d:EmployeeName>" +
+          "<d:ManagerId>1</d:ManagerId>" +
+          "<d:RoomId>1</d:RoomId>" +
+          "<d:TeamId>1</d:TeamId>" +
+          "<d:Location m:type=\"RefScenario.c_Location\">" +
+          "<d:Country>Germany</d:Country>" +
+          "<d:City m:type=\"RefScenario.c_City\">" +
+          "<d:PostalCode>69124</d:PostalCode>" +
+          "<d:CityName>Heidelberg</d:CityName>" +
+          "</d:City>" +
+          "</d:Location>" +
+          "<d:Age>52</d:Age>" +
+          "<d:EntryDate>1999-01-01T00:00:00</d:EntryDate>" +
+          "<d:ImageUrl>male_1_WinterW.jpg</d:ImageUrl>" +
+          "</m:properties>" +
+          "</entry>";
+
+  @Test
+  public void readEntry() throws Exception {
+    final String contentType = ContentType.APPLICATION_ATOM_XML_ENTRY.toContentTypeString();
+    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
+    InputStream content = new ByteArrayInputStream(EMPLOYEE_1_XML.getBytes("UTF-8"));
+
+    final ODataEntry result = new ProviderFacadeImpl().readEntry(contentType, entitySet, content, EntityProviderReadProperties.init().mergeSemantic(true).build());
+    assertNotNull(result);
+    assertFalse(result.containsInlineEntry());
+    assertNotNull(result.getExpandSelectTree());
+    assertTrue(result.getExpandSelectTree().isAll());
+    assertNotNull(result.getMetadata());
+    assertNull(result.getMetadata().getEtag());
+    assertNotNull(result.getMediaMetadata());
+    assertEquals(HttpContentType.APPLICATION_OCTET_STREAM, result.getMediaMetadata().getContentType());
+    assertNotNull(result.getProperties());
+    assertEquals(52, result.getProperties().get("Age"));
+  }
+
+  @Test
+  public void readPropertyValue() throws Exception {
+    final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("EntryDate");
+    InputStream content = new ByteArrayInputStream("2012-02-29T01:02:03".getBytes("UTF-8"));
+    final Object result = new ProviderFacadeImpl().readPropertyValue(property, content, Long.class);
+    assertEquals(1330477323000L, result);
+  }
+
+  @Test
+  public void readProperty() throws Exception {
+    final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+    final String xml = "<Age xmlns=\"" + Edm.NAMESPACE_D_2007_08 + "\">42</Age>";
+    InputStream content = new ByteArrayInputStream(xml.getBytes("UTF-8"));
+    final Map<String, Object> result = new ProviderFacadeImpl().readProperty(HttpContentType.APPLICATION_XML, property, content, EntityProviderReadProperties.init().build());
+    assertFalse(result.isEmpty());
+    assertEquals(42, result.get("Age"));
+  }
+
+  @Test
+  public void readLink() throws Exception {
+    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
+    InputStream content = new ByteArrayInputStream("{\"d\":{\"uri\":\"http://somelink\"}}".getBytes("UTF-8"));
+    final String result = new ProviderFacadeImpl().readLink(HttpContentType.APPLICATION_JSON, entitySet, content);
+    assertEquals("http://somelink", result);
+  }
+
+  @Test
+  public void readLinks() throws Exception {
+    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
+    InputStream content = new ByteArrayInputStream("{\"d\":{\"__count\":\"42\",\"results\":[{\"uri\":\"http://somelink\"}]}}".getBytes("UTF-8"));
+    final List<String> result = new ProviderFacadeImpl().readLinks(HttpContentType.APPLICATION_JSON, entitySet, content);
+    assertEquals(Arrays.asList("http://somelink"), result);
+  }
+
+  @Test
+  public void writeFeed() throws Exception {
+    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
+    List<Map<String, Object>> propertiesList = new ArrayList<Map<String, Object>>();
+    final ODataResponse result = new ProviderFacadeImpl().writeFeed(HttpContentType.APPLICATION_JSON, entitySet, propertiesList, EntityProviderWriteProperties.serviceRoot(URI.create("http://root/")).build());
+    assertEquals("{\"d\":{\"results\":[]}}", StringHelper.inputStreamToString((InputStream) result.getEntity()));
+  }
+
+  @Test
+  public void writeEntry() throws Exception {
+    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams");
+    Map<String, Object> properties = new HashMap<String, Object>();
+    properties.put("Id", "42");
+    final ODataResponse result = new ProviderFacadeImpl().writeEntry(HttpContentType.APPLICATION_JSON, entitySet, properties, EntityProviderWriteProperties.serviceRoot(URI.create("http://root/")).build());
+    assertEquals("{\"d\":{\"__metadata\":{\"id\":\"http://root/Teams('42')\","
+        + "\"uri\":\"http://root/Teams('42')\",\"type\":\"RefScenario.Team\"},"
+        + "\"Id\":\"42\",\"Name\":null,\"isScrumTeam\":null,"
+        + "\"nt_Employees\":{\"__deferred\":{\"uri\":\"http://root/Teams('42')/nt_Employees\"}}}}",
+        StringHelper.inputStreamToString((InputStream) result.getEntity()));
+  }
+
+  @Test
+  public void writeProperty() throws Exception {
+    final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("EntryDate");
+    final ODataResponse result = new ProviderFacadeImpl().writeProperty(HttpContentType.APPLICATION_XML, property, 987654321000L);
+    assertEquals(HttpContentType.APPLICATION_XML_UTF8, result.getContentHeader());
+    assertTrue(StringHelper.inputStreamToString((InputStream) result.getEntity())
+        .endsWith("\">2001-04-19T04:25:21</EntryDate>"));
+  }
+
+  @Test
+  public void writeLink() throws Exception {
+    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
+    Map<String, Object> properties = new HashMap<String, Object>();
+    properties.put("Id", "42");
+    final ODataResponse result = new ProviderFacadeImpl().writeLink(HttpContentType.APPLICATION_JSON, entitySet, properties, EntityProviderWriteProperties.serviceRoot(URI.create("http://root/")).build());
+    assertEquals("{\"d\":{\"uri\":\"http://root/Rooms('42')\"}}",
+        StringHelper.inputStreamToString((InputStream) result.getEntity()));
+  }
+
+  @Test
+  public void writeLinks() throws Exception {
+    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
+    Map<String, Object> properties = new HashMap<String, Object>();
+    properties.put("Id", "42");
+    List<Map<String, Object>> propertiesList = new ArrayList<Map<String, Object>>();
+    propertiesList.add(properties);
+    propertiesList.add(properties);
+    final ODataResponse result = new ProviderFacadeImpl().writeLinks(HttpContentType.APPLICATION_JSON, entitySet, propertiesList, EntityProviderWriteProperties.serviceRoot(URI.create("http://root/")).build());
+    assertEquals("{\"d\":[{\"uri\":\"http://root/Rooms('42')\"},{\"uri\":\"http://root/Rooms('42')\"}]}",
+        StringHelper.inputStreamToString((InputStream) result.getEntity()));
+  }
+
+  @Test
+  public void writeServiceDocument() throws Exception {
+    final ODataResponse result = new ProviderFacadeImpl().writeServiceDocument(HttpContentType.APPLICATION_JSON, MockFacade.getMockEdm(), "root");
+    assertEquals("{\"d\":{\"EntitySets\":[]}}", StringHelper.inputStreamToString((InputStream) result.getEntity()));
+  }
+
+  @Test
+  public void writePropertyValue() throws Exception {
+    final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("EntryDate");
+    final ODataResponse result = new ProviderFacadeImpl().writePropertyValue(property, 987654321000L);
+    assertEquals(HttpContentType.TEXT_PLAIN_UTF8, result.getContentHeader());
+    assertEquals("2001-04-19T04:25:21", StringHelper.inputStreamToString((InputStream) result.getEntity()));
+  }
+
+  @Test
+  public void writeText() throws Exception {
+    final ODataResponse result = new ProviderFacadeImpl().writeText("test");
+    assertEquals(HttpContentType.TEXT_PLAIN_UTF8, result.getContentHeader());
+    assertEquals("test", StringHelper.inputStreamToString((InputStream) result.getEntity()));
+  }
+
+  @Test
+  public void writeBinary() throws Exception {
+    final ODataResponse result = new ProviderFacadeImpl().writeBinary(HttpContentType.APPLICATION_OCTET_STREAM, new byte[] { 102, 111, 111 });
+    assertEquals(HttpContentType.APPLICATION_OCTET_STREAM, result.getContentHeader());
+    assertEquals("foo", StringHelper.inputStreamToString((InputStream) result.getEntity()));
+  }
+
+  @Test
+  public void writeBinaryNoContent() throws Exception {
+    final ODataResponse result = new ProviderFacadeImpl().writeBinary(HttpContentType.APPLICATION_OCTET_STREAM, null);
+    assertNull(result.getEntity());
+    assertNull(result.getContentHeader());
+    assertEquals(HttpStatusCodes.NO_CONTENT, result.getStatus());
+  }
+
+  @Test
+  public void writeFunctionImport() throws Exception {
+    final EdmFunctionImport function = MockFacade.getMockEdm().getDefaultEntityContainer().getFunctionImport("MaximalAge");
+    Map<String, Object> properties = new HashMap<String, Object>();
+    properties.put("MaximalAge", 99);
+    final ODataResponse result = new ProviderFacadeImpl().writeFunctionImport(HttpContentType.APPLICATION_JSON, function, properties, null);
+    assertEquals("{\"d\":{\"MaximalAge\":99}}", StringHelper.inputStreamToString((InputStream) result.getEntity()));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/aggregator/EntityInfoAggregatorTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/aggregator/EntityInfoAggregatorTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/aggregator/EntityInfoAggregatorTest.java
new file mode 100644
index 0000000..be45e5d
--- /dev/null
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/aggregator/EntityInfoAggregatorTest.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.core.ep.aggregator;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
+import org.apache.olingo.odata2.core.ep.AbstractProviderTest;
+import org.apache.olingo.odata2.testutil.mock.MockFacade;
+
+/**
+ * @author SAP AG
+ */
+public class EntityInfoAggregatorTest extends AbstractProviderTest {
+
+  public EntityInfoAggregatorTest(final StreamWriterImplType type) {
+    super(type);
+  }
+
+  @Test
+  public void testEntitySet() throws Exception {
+    EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
+
+    ExpandSelectTreeNode epProperties = null;
+    EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet, epProperties);
+
+    assertNotNull(eia);
+    EntityPropertyInfo propertyInfoAge = eia.getPropertyInfo("Age");
+    assertFalse(propertyInfoAge.isComplex());
+    assertEquals("Age", propertyInfoAge.getName());
+    assertEquals("Int32", propertyInfoAge.getType().getName());
+    EntityPropertyInfo propertyInfoLocation = eia.getPropertyInfo("Location");
+    assertTrue(propertyInfoLocation.isComplex());
+    assertNull(eia.getPropertyInfo("City"));
+    assertEquals("Location", propertyInfoLocation.getName());
+    EntityComplexPropertyInfo locationInfo = (EntityComplexPropertyInfo) propertyInfoLocation;
+    assertEquals(2, locationInfo.getPropertyInfos().size());
+
+    assertEquals("Country", locationInfo.getPropertyInfo("Country").getName());
+    assertEquals("String", locationInfo.getPropertyInfo("Country").getType().getName());
+    assertEquals(EdmTypeKind.SIMPLE, locationInfo.getPropertyInfo("Country").getType().getKind());
+
+    EntityComplexPropertyInfo cityInfo = (EntityComplexPropertyInfo) locationInfo.getPropertyInfo("City");
+    assertTrue(cityInfo.isComplex());
+    assertEquals("City", cityInfo.getName());
+    assertEquals("c_City", cityInfo.getType().getName());
+    assertEquals(EdmTypeKind.COMPLEX, cityInfo.getType().getKind());
+    assertEquals("CityName", cityInfo.getPropertyInfo("CityName").getName());
+    assertFalse(cityInfo.getPropertyInfo("CityName").isComplex());
+    assertEquals("String", cityInfo.getPropertyInfo("CityName").getType().getName());
+    assertEquals("PostalCode", cityInfo.getPropertyInfo("PostalCode").getName());
+    assertFalse(cityInfo.getPropertyInfo("PostalCode").isComplex());
+    assertEquals("String", cityInfo.getPropertyInfo("PostalCode").getType().getName());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/AbstractConsumerTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/AbstractConsumerTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/AbstractConsumerTest.java
new file mode 100644
index 0000000..b3a3968
--- /dev/null
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/AbstractConsumerTest.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * 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.core.ep.consumer;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties;
+import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
+import org.apache.olingo.odata2.api.ep.feed.ODataFeed;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.testutil.fit.BaseTest;
+import org.apache.olingo.odata2.testutil.mock.MockFacade;
+
+/**
+ * @author SAP AG
+ */
+public abstract class AbstractConsumerTest extends BaseTest {
+
+  protected static final EntityProviderReadProperties DEFAULT_PROPERTIES = EntityProviderReadProperties.init().mergeSemantic(false).build();
+
+  protected XMLStreamReader createReaderForTest(final String input) throws XMLStreamException {
+    return createReaderForTest(input, false);
+  }
+
+  protected XMLStreamReader createReaderForTest(final String input, final boolean namespaceAware) throws XMLStreamException {
+    XMLInputFactory factory = XMLInputFactory.newInstance();
+    factory.setProperty(XMLInputFactory.IS_VALIDATING, false);
+    factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, namespaceAware);
+
+    XMLStreamReader streamReader = factory.createXMLStreamReader(new StringReader(input));
+
+    return streamReader;
+  }
+
+  protected Map<String, Object> createTypeMappings(final String key, final Object value) {
+    Map<String, Object> typeMappings = new HashMap<String, Object>();
+    typeMappings.put(key, value);
+    return typeMappings;
+  }
+
+  protected InputStream getFileAsStream(final String filename) throws IOException {
+    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
+    if (in == null) {
+      throw new IOException("Requested file '" + filename + "' was not found.");
+    }
+    return in;
+  }
+
+  protected String readFile(final String filename) throws IOException {
+    InputStream in = getFileAsStream(filename);
+
+    byte[] tmp = new byte[8192];
+    int count = in.read(tmp);
+    StringBuilder b = new StringBuilder();
+    while (count >= 0) {
+      b.append(new String(tmp, 0, count));
+      count = in.read(tmp);
+    }
+
+    return b.toString();
+  }
+
+  /**
+   * Create a map with a 'String' to 'Class<?>' mapping based on given parameters.
+   * Therefore parameters MUST be a set of such pairs.
+   * As example an correct method call would be:
+   * <p>
+   * <code>
+   *    createTypeMappings("someKey", Integer.class, "anotherKey", Long.class);
+   * </code>
+   * </p>
+   * 
+   * @param firstKeyThenMappingClass
+   * @return
+   */
+  protected Map<String, Object> createTypeMappings(final Object... firstKeyThenMappingClass) {
+    Map<String, Object> typeMappings = new HashMap<String, Object>();
+    if (firstKeyThenMappingClass.length % 2 != 0) {
+      throw new IllegalArgumentException("Got odd number of parameters. Please read javadoc.");
+    }
+    for (int i = 0; i < firstKeyThenMappingClass.length; i += 2) {
+      String key = (String) firstKeyThenMappingClass[i];
+      Class<?> mappingClass = (Class<?>) firstKeyThenMappingClass[i + 1];
+      typeMappings.put(key, mappingClass);
+    }
+    return typeMappings;
+  }
+
+  protected InputStream createContentAsStream(final String content) throws UnsupportedEncodingException {
+    return new ByteArrayInputStream(content.getBytes("UTF-8"));
+  }
+
+  /**
+   * 
+   * @param content
+   * @param replaceWhitespaces if <code>true</code> all XML not necessary whitespaces between tags are
+   * @return
+   * @throws UnsupportedEncodingException
+   */
+  protected InputStream createContentAsStream(final String content, final boolean replaceWhitespaces) throws UnsupportedEncodingException {
+    String contentForStream = content;
+    if (replaceWhitespaces) {
+      contentForStream = content.replaceAll(">\\s.<", "><");
+    }
+
+    return new ByteArrayInputStream(contentForStream.getBytes("UTF-8"));
+  }
+
+  protected ODataEntry prepareAndExecuteEntry(final String fileName, final String entitySetName, final EntityProviderReadProperties readProperties) throws IOException, EdmException, ODataException, UnsupportedEncodingException, EntityProviderException {
+    //prepare
+    EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet(entitySetName);
+    String content = readFile(fileName);
+    assertNotNull(content);
+    InputStream contentBody = createContentAsStream(content);
+
+    // execute
+    JsonEntityConsumer xec = new JsonEntityConsumer();
+    ODataEntry result = xec.readEntry(entitySet, contentBody, readProperties);
+    assertNotNull(result);
+    return result;
+  }
+
+  protected ODataFeed prepareAndExecuteFeed(final String fileName, final String entitySetName, final EntityProviderReadProperties readProperties) throws IOException, EdmException, ODataException, UnsupportedEncodingException, EntityProviderException {
+    //prepare
+    EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet(entitySetName);
+    String content = readFile(fileName);
+    assertNotNull(content);
+    InputStream contentBody = createContentAsStream(content);
+
+    // execute
+    JsonEntityConsumer xec = new JsonEntityConsumer();
+    ODataFeed result = xec.readFeed(entitySet, contentBody, readProperties);
+    assertNotNull(result);
+    return result;
+  }
+
+}