You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/09/08 18:39:59 UTC

[42/55] [abbrv] olingo-odata4 git commit: [OLINGO-659] Removed v4 from package and class names

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/APIBasicDesignTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/APIBasicDesignTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/APIBasicDesignTestITCase.java
new file mode 100644
index 0000000..a66192b
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/APIBasicDesignTestITCase.java
@@ -0,0 +1,626 @@
+/*
+ * 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.fit.proxy;
+
+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 static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.lang.reflect.Proxy;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+// CHECKSTYLE:OFF (Maven checkstyle)
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.ext.proxy.AbstractService;
+import org.apache.olingo.ext.proxy.api.EdmStreamValue;
+import org.apache.olingo.ext.proxy.api.PrimitiveCollection;
+import org.apache.olingo.ext.proxy.commons.AbstractCollectionInvocationHandler;
+import org.apache.olingo.fit.proxy.demo.Service;
+import org.apache.olingo.fit.proxy.demo.odatademo.DemoService;
+import org.apache.olingo.fit.proxy.demo.odatademo.types.PersonDetail;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.AddressCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Color;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.CustomerCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Order;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonComposableInvoker;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Product;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types
+        .ProductCollectionComposableInvoker;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types
+        .ProductDetailCollectionComposableInvoker;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetail;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollection;
+
+// CHECKSTYLE:ON (Maven checkstyle)
+import org.junit.Test;
+
+public class APIBasicDesignTestITCase extends AbstractTestITCase {
+
+  protected AbstractService<EdmEnabledODataClient> getService() {
+    return service;
+  }
+
+  protected InMemoryEntities getContainer() {
+    return container;
+  }
+
+  @Test
+  public void readEntitySet() {
+    final OrderCollection orders = container.getOrders().execute();
+    assertFalse(orders.isEmpty());
+
+    final CustomerCollection customers = container.getCustomers().
+        orderBy("PersonID").
+        select("FirstName", "LastName", "Orders").
+        expand("Orders").
+        execute();
+
+    assertEquals(2, customers.size());
+    for (Customer customer : customers) {
+      assertNotNull(customer.getFirstName());
+      assertNotNull(customer.getLastName());
+    }
+  }
+
+  @Test
+  public void readWithReferences() {
+    final Person person = container.getOrders().getByKey(8).getCustomerForOrder().refs().load();
+    assertEquals("http://localhost:9080/stub/StaticService/V40/Static.svc/Customers(PersonID=1)",
+        person.readEntityReferenceID());
+
+    final OrderCollection orders = container.getCustomers().getByKey(1).getOrders().refs().execute();
+    assertEquals("http://localhost:9080/stub/StaticService/V40/Static.svc/Orders(7)",
+        orders.iterator().next().readEntityReferenceID());
+  }
+
+  @Test
+  public void changeSingleNavigationProperty() {
+    /*
+     * See OData Spec 11.4.6.3
+     * Alternatively, a relationship MAY be updated as part of an update to the source entity by including
+     * the required binding information for the new target entity.
+     *
+     * => use PATCH instead of PUT
+     */
+    final Person person1 = container.getPeople().getByKey(1).load();
+    final Person person5 = container.getPeople().getByKey(5).load();
+
+    person1.setParent(person5);
+    container.flush();
+  }
+
+  @Test
+  public void addViaReference() {
+    final Order order = container.getOrders().getByKey(8).load();
+
+    final OrderCollection orders = container.newEntityCollection(OrderCollection.class);
+    orders.addRef(order);
+
+    container.getCustomers().getByKey(1).setOrders(orders);
+    container.flush();
+  }
+
+  @Test
+  public void readAndCheckForPrimitive() {
+    final Customer customer = getContainer().getCustomers().getByKey(1);
+    assertNotNull(customer);
+    assertNull(customer.getPersonID());
+
+    assertEquals(1, customer.load().getPersonID(), 0);
+    service.getContext().detachAll();
+  }
+
+  @Test
+  public void readAndCheckForComplex() {
+    Customer customer = container.getCustomers().getByKey(1); // no http request
+    Address homeAddress = customer.getHomeAddress();
+    assertNotNull(homeAddress);
+    assertNull(homeAddress.getCity());
+    assertNull(homeAddress.getPostalCode());
+    assertNull(homeAddress.getStreet());
+
+    homeAddress.load(); // HTTP request at complex loading
+    assertEquals("London", homeAddress.getCity());
+    assertEquals("98052", homeAddress.getPostalCode());
+    assertEquals("1 Microsoft Way", homeAddress.getStreet());
+
+    getService().getContext().detachAll();
+
+    homeAddress = container.getCustomers().getByKey(1).load().getHomeAddress(); // HTTP request at entity loading
+    assertEquals("London", homeAddress.getCity());
+    assertEquals("98052", homeAddress.getPostalCode());
+    assertEquals("1 Microsoft Way", homeAddress.getStreet());
+
+    getService().getContext().detachAll();
+
+    customer = container.getOrders().getByKey(8).getCustomerForOrder();
+    homeAddress = customer.getHomeAddress().select("City", "PostalCode").expand("SomethingElse"); // no HTTP request
+    assertNotNull(homeAddress);
+    assertNull(homeAddress.getCity());
+    assertNull(homeAddress.getPostalCode());
+    assertNull(homeAddress.getStreet());
+
+    try {
+      homeAddress.load();
+      fail();
+    } catch (Exception e) {
+      // Generated URL
+      // "<serviceroot>/Orders(8)/CustomerForOrder/HomeAddress?$select=City,PostalCode&$expand=SomethingElse"
+      // curently unsupported by test service server
+      homeAddress.clearQueryOptions();
+    }
+  }
+
+  @Test
+  public void readWholeEntitySet() {
+    PersonCollection person = getContainer().getPeople().execute();
+    assertEquals(5, person.size(), 0);
+
+    int pageCount = 1;
+    while (person.hasNextPage()) {
+      pageCount++;
+      assertFalse(person.nextPage().execute().isEmpty());
+    }
+
+    assertEquals(2, pageCount);
+    service.getContext().detachAll(); // avoid influences
+  }
+
+  @Test
+  public void loadWithSelect() {
+    Order order =
+        getContainer().getOrders().getByKey(8);
+    assertNull(order.getOrderID());
+    assertNull(order.getOrderDate());
+
+    order.select("OrderID");
+    order.load();
+
+    assertNull(order.getOrderDate());
+    assertNotNull(order.getOrderID());
+
+    order.clearQueryOptions();
+    order.load();
+    assertNotNull(order.getOrderDate());
+    assertNotNull(order.getOrderID());
+    service.getContext().detachAll(); // avoid influences
+  }
+
+  @Test
+  public void loadWithSelectAndExpand() {
+    final Customer customer = getContainer().getCustomers().getByKey(1);
+
+    customer.expand("Orders");
+    customer.select("Orders", "PersonID");
+
+    customer.load();
+    assertEquals(1, customer.getOrders().size());
+    service.getContext().detachAll(); // avoid influences
+  }
+
+  @Test
+  public void navigateLinks() {
+    final Customer customer = getContainer().getCustomers().getByKey(1); // No HTTP Request
+    assertNotNull(customer.getCompany().load().getCompanyID()); // singleton: single request
+    assertEquals(1, customer.getOrders().execute().size()); // collection: single request
+
+    final Order order = getContainer().getOrders().getByKey(8); // No HTTP Requests
+    assertNotNull(order.getCustomerForOrder().load().getPersonID()); // entity type: single request
+
+    service.getContext().detachAll(); // avoid influences
+  }
+
+  @Test
+  public void createDelete() {
+    // Create order ....
+    final Order order = getContainer().newEntityInstance(Order.class);
+    order.setOrderID(1105);
+
+    final Calendar orderDate = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+    orderDate.clear();
+    orderDate.set(2011, 3, 4, 16, 3, 57);
+    order.setOrderDate(new Timestamp(orderDate.getTimeInMillis()));
+
+    order.setShelfLife(BigDecimal.ZERO);
+
+    final PrimitiveCollection<BigDecimal> osl = getContainer().newPrimitiveCollection(BigDecimal.class);
+    osl.add(BigDecimal.TEN.negate());
+    osl.add(BigDecimal.TEN);
+
+    order.setOrderShelfLifes(osl);
+
+    getContainer().getOrders().add(order);
+    getContainer().flush();
+
+    Order actual = getContainer().getOrders().getByKey(1105);
+    assertNull(actual.getOrderID());
+
+    actual.load();
+    assertEquals(1105, actual.getOrderID(), 0);
+    assertEquals(orderDate.getTimeInMillis(), actual.getOrderDate().getTime());
+    assertEquals(BigDecimal.ZERO, actual.getShelfLife());
+    assertEquals(2, actual.getOrderShelfLifes().size());
+
+    service.getContext().detachAll();
+
+    // (1) Delete by key (see EntityCreateTestITCase)
+    getContainer().getOrders().delete(1105);
+    assertNull(getContainer().getOrders().getByKey(1105));
+
+    service.getContext().detachAll(); // detach to show the second delete case
+
+    // (2) Delete by object (see EntityCreateTestITCase)
+    getContainer().getOrders().delete(getContainer().getOrders().getByKey(1105));
+    assertNull(getContainer().getOrders().getByKey(1105));
+
+    // (3) Delete by invoking delete method on the object itself
+    service.getContext().detachAll(); // detach to show the third delete case
+    getContainer().getOrders().getByKey(1105).delete();
+    assertNull(getContainer().getOrders().getByKey(1105));
+
+    getContainer().flush();
+
+    service.getContext().detachAll();
+    try {
+      getContainer().getOrders().getByKey(1105).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Test
+    }
+    service.getContext().detachAll(); // avoid influences
+  }
+
+  @Test
+  public void deleteSingleProperty() {
+    container.getCustomers().getByKey(1).delete("City");
+    container.flush();
+  }
+
+  @Test
+  public void deleteComplex() {
+    container.getCustomers().getByKey(1).getHomeAddress().delete();
+    container.flush();
+  }
+
+  @Test
+  public void deleteCollection() {
+    container.getCustomers().getByKey(1).getEmails().delete();
+    container.flush();
+  }
+
+  @Test
+  public void deleteEdmStreamProperty() throws IOException {
+    // ---------------------------------------
+    // Instantiate Demo Service
+    // ---------------------------------------
+    final Service<EdmEnabledODataClient> dservice =
+        Service.getV4(testDemoServiceRootURL);
+    dservice.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    final DemoService dcontainer = dservice.getEntityContainer(DemoService.class);
+    assertNotNull(dcontainer);
+    dservice.getContext().detachAll();
+    // ---------------------------------------
+    dcontainer.getPersonDetails().getByKey(1).delete("Photo");
+    dcontainer.flush();
+
+    dservice.getContext().detachAll(); // avoid influences
+  }
+
+  @Test
+  public void updateComplexProperty() {
+    Address homeAddress = container.getCustomers().getByKey(1).getHomeAddress();
+    homeAddress.setCity("Pescara");
+    homeAddress.setPostalCode("98052");
+    container.flush();
+
+    homeAddress = container.getCustomers().getByKey(1).getHomeAddress().load();
+    assertEquals("Pescara", homeAddress.getCity());
+    assertEquals("98052", homeAddress.getPostalCode());
+  }
+
+  @Test
+  public void updateAndReadEdmStreamProperty() throws IOException {
+    // ---------------------------------------
+    // Instantiate Demo Service
+    // ---------------------------------------
+    final Service<EdmEnabledODataClient> dservice =
+        Service.getV4(testDemoServiceRootURL);
+    dservice.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    final DemoService dcontainer = dservice.getEntityContainer(DemoService.class);
+    assertNotNull(dcontainer);
+    dservice.getContext().detachAll();
+    // ---------------------------------------
+    final String random = RandomStringUtils.random(124, "abcdefghijklmnopqrstuvwxyz");
+
+    final PersonDetail personDetail = dcontainer.getPersonDetails().getByKey(1); // NO HTTP Request
+
+    // 1 HTTP Request to add an Edm.Stream property value about MediaEditLink Photo
+    personDetail.setPhoto(dcontainer.newEdmStreamValue("application/octet-stream", IOUtils.toInputStream(random)));
+
+    dcontainer.flush();
+
+    final EdmStreamValue actual = dcontainer.getPersonDetails().getByKey(1).getPhoto().load(); // 1 HTTP Request
+    assertEquals(random, IOUtils.toString(actual.getStream()));
+
+    dservice.getContext().detachAll(); // avoid influences
+  }
+
+  @Test
+  public void boundOperationsAfterCreate() {
+    final Product product = getContainer().newEntityInstance(Product.class);
+    product.setProductID(1012);
+    product.setName("Latte");
+    product.setQuantityPerUnit("100g Bag");
+    product.setUnitPrice(3.24f);
+    product.setQuantityInStock(100);
+    product.setDiscontinued(false);
+    product.setUserAccess(AccessLevel.Execute);
+    product.setSkinColor(Color.Blue);
+
+    final PrimitiveCollection<Color> cc = getContainer().newPrimitiveCollection(Color.class);
+    cc.add(Color.Red);
+    cc.add(Color.Green);
+
+    product.setCoverColors(cc);
+
+    final ProductDetail detail = getContainer().newEntityInstance(ProductDetail.class);
+    detail.setProductID(product.getProductID());
+    detail.setProductDetailID(1012);
+    detail.setProductName("LatteHQ");
+    detail.setDescription("High-Quality Milk");
+
+    final ProductDetailCollection detailCollection = getContainer().newEntityCollection(ProductDetailCollection.class);
+    detailCollection.add(detail);
+
+    product.setDetails(detailCollection);
+
+    getContainer().getProducts().add(product);
+
+    // The first HTTP Request to create product and the linked product detail
+    getContainer().flush();
+
+    // The second HTTP request to access a bound operation via the local object
+    assertNotNull(product.operations().addAccessRight(AccessLevel.None).execute());
+
+    // The third HTTP Request to access a bound operation via entity URL
+    final ProductDetailCollectionComposableInvoker result =
+        container.getProducts().getByKey(1012).operations().getProductDetails(1);
+    assertEquals(1, result.execute().size());
+  }
+
+  @Test
+  public void workingWithPrimitiveCollections() throws IOException {
+    final PrimitiveCollection<String> emails = container.getPeople().getByKey(1).getEmails();
+    assertNotNull(emails);
+    assertTrue(emails.isEmpty());
+    assertFalse(emails.execute().isEmpty());
+
+    getService().getContext().detachAll();
+
+    // container.getOrders().getByKey(1).getCustomerForOrder().getEmails().execute().isEmpty());
+    // Not supported by the test service BTW generates a single request as expected:
+    // <service root>/Orders(1)/CustomerForOrder/Emails
+    emails.add("fabio.martelli@tirasa.net");
+    container.getPeople().getByKey(1).setEmails(emails);
+
+    container.flush();
+
+    boolean found = false;
+    for (String email : container.getPeople().getByKey(1).getEmails().execute()) {
+      if (email.equals("fabio.martelli@tirasa.net")) {
+        found = true;
+      }
+    }
+
+    assertTrue(found);
+
+    getService().getContext().detachAll();
+  }
+
+  @Test
+  public void workingWithSingletons() {
+    assertNotNull(container.getCompany().getVipCustomer().load().getPersonID());
+
+    container.getCompany().setName("new name");
+    container.flush();
+
+    assertEquals("new name", container.getCompany().load().getName());
+  }
+
+  @Test
+  public void createAndCallOperation() {
+    final Product product = container.newEntityInstance(Product.class);
+    product.setProductID(1001);
+    container.flush();
+
+    container.getProducts().getByKey(1000).operations().getProductDetails(1).execute();
+  }
+
+  @Test
+  public void workingWithOperations() {
+    // Primitive collections (available only skip and top)
+    final PrimitiveCollection<String> prods1 = container.operations().
+        getProductsByAccessLevel(AccessLevel.None).
+        skip(2).
+        top(3).execute();
+    assertNotNull(prods1);
+    assertFalse(prods1.isEmpty());
+
+    // Complex/Entity collection
+    final ProductCollection prods2 = container.operations().getAllProducts().
+        filter("name eq XXXX").
+        select("Name", "ProductDetail").
+        expand("ProductDetail").
+        orderBy("Name").skip(3).top(5).execute();
+    assertNotNull(prods2);
+    assertFalse(prods2.isEmpty());
+
+    // Complex/Entity
+    final Person person = container.operations().getPerson2("London").
+        select("Name").
+        expand("Order").execute();
+    assertNotNull(person);
+
+    // Primitive (no query option available)
+    final Double amount = container.getAccounts().getByKey(101).getMyGiftCard().operations().
+        getActualAmount(1.1).execute();
+    assertNotNull(amount);
+
+    // POST ...
+    final Address address = container.newComplexInstance(HomeAddress.class);
+    address.setStreet("Via Le Mani Dal Naso, 123");
+    address.setPostalCode("Tollo");
+    address.setCity("66010");
+
+    final AddressCollection ac = container.newComplexCollection(AddressCollection.class);
+    final Person updated = container.getCustomers().getByKey(2).operations().
+        resetAddress(ac, 0).select("Name").expand("Orders").execute();
+    assertNotNull(updated);
+  }
+
+  @Test
+  public void workingWithComposableOperations() {
+    final ProductCollectionComposableInvoker invoker1 = container.operations().getAllProducts();
+
+    // Complex/Entity collection (available filter, select, expand, orderBy, skip and top)
+    invoker1.operations().discount(10). // discount is an operation of ProductCollecton
+    filter("Name eq XXXX").
+    select("Name", "ProductDetail").
+    expand("ProductDetail").
+    orderBy("Name").skip(3).top(5).execute();
+
+    // Complex/Entity
+    final PersonComposableInvoker invoker2 = container.operations().getPerson2("London");
+
+    // a. whole entity
+    final Person person = invoker2.select("Name").expand("Order").execute();
+    assertNotNull(person);
+    assertEquals(1, person.getPersonID(), 0);
+
+    // b. primitive collection property
+    final PrimitiveCollection<String> emails = invoker2.getEmails().execute();
+    assertNotNull(emails);
+    assertFalse(emails.isEmpty());
+
+    // c. complex property
+    final Address homeAddress = invoker2.getHomeAddress().load();
+    assertNotNull(homeAddress);
+
+    // d. navigation property
+    final Person parent = invoker2.getParent().load();
+    assertNotNull(parent);
+    assertEquals(2, parent.getPersonID(), 0);
+  }
+
+  /**
+   * Java client should support the deletion based on locally created entity.
+   * See also <a href="https://issues.apache.org/jira/browse/OLINGO-395">Olingo Issue 395</a>.
+   */
+  @Test
+  public void issueOLINGO395() {
+    Order order = getContainer().newEntityInstance(Order.class);
+    order.setOrderID(1105);
+
+    final Calendar orderDate = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+    orderDate.clear();
+    orderDate.set(2011, 3, 4, 16, 3, 57);
+    order.setOrderDate(new Timestamp(orderDate.getTimeInMillis()));
+
+    order.setShelfLife(BigDecimal.ZERO);
+
+    final PrimitiveCollection<BigDecimal> osl = getContainer().newPrimitiveCollection(BigDecimal.class);
+    osl.add(BigDecimal.TEN.negate());
+    osl.add(BigDecimal.TEN);
+
+    order.setOrderShelfLifes(osl);
+
+    getContainer().getOrders().add(order);
+    getContainer().getOrders().delete(order);
+
+    getContainer().flush();
+
+    service.getContext().detachAll();
+    try {
+      getContainer().getOrders().getByKey(1105).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected Exception
+    }
+    service.getContext().detachAll(); // avoid influences
+
+    order = getContainer().newEntityInstance(Order.class);
+    order.setOrderID(1105);
+
+    getContainer().getOrders().delete(order);
+    getContainer().flush(); // test service doesn't fail for delete requests about unexisting objects
+
+    service.getContext().detachAll();
+    try {
+      getContainer().getOrders().getByKey(1105).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected Exception
+    }
+    service.getContext().detachAll(); // avoid influences
+  }
+
+  @Test
+  public void issueOLINGO398() {
+    AbstractCollectionInvocationHandler<?, ?> handler = AbstractCollectionInvocationHandler.class.cast(
+        Proxy.getInvocationHandler(container.getCustomers().getByKey(1).getOrders().
+            select("OrderID", "CustomerForOrder").
+            expand("CustomerForOrder").
+            top(1).
+            skip(2)));
+
+    assertEquals("http://localhost:9080/stub/StaticService/V40/Static.svc/Customers(1)/Orders?"
+        + "%24select=OrderID%2CCustomerForOrder&%24expand=CustomerForOrder&%24top=1&%24skip=2",
+        handler.getRequestURI().toASCIIString());
+
+    handler = AbstractCollectionInvocationHandler.class.cast(
+        Proxy.getInvocationHandler(container.getCustomers().getByKey(1).getOrders().
+            select("OrderID", "CustomerForOrder").
+            expand("CustomerForOrder").
+            top(1).
+            skip(2)));
+
+    assertEquals("http://localhost:9080/stub/StaticService/V40/Static.svc/Customers(1)/Orders?%24"
+        + "select=OrderID%2CCustomerForOrder&%24expand=CustomerForOrder&%24top=1&%24skip=2",
+        handler.getRequestURI().toASCIIString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/AbstractTestITCase.java
new file mode 100644
index 0000000..c6e1b2c
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/AbstractTestITCase.java
@@ -0,0 +1,149 @@
+/*
+ * 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.fit.proxy;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.ext.proxy.AbstractService;
+import org.apache.olingo.ext.proxy.api.PrimitiveCollection;
+import org.apache.olingo.fit.AbstractBaseTestITCase;
+import org.apache.olingo.fit.proxy.staticservice.Service;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Order;
+import org.junit.BeforeClass;
+
+public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
+
+  protected static String testStaticServiceRootURL;
+
+  protected static String testDemoServiceRootURL;
+
+  protected static String testKeyAsSegmentServiceRootURL;
+
+  protected static String testActionOverloadingServiceRootURL;
+
+  protected static String testOpenTypeServiceRootURL;
+
+  protected static String testLargeModelServiceRootURL;
+
+  protected static String testAuthServiceRootURL;
+
+  protected static Service<EdmEnabledODataClient> service;
+
+  protected static InMemoryEntities container;
+
+  @BeforeClass
+  public static void setUpODataServiceRoot() throws IOException {
+    testStaticServiceRootURL = "http://localhost:9080/stub/StaticService/V40/Static.svc";
+    testDemoServiceRootURL = "http://localhost:9080/stub/StaticService/V40/Demo.svc";
+    testKeyAsSegmentServiceRootURL = "http://localhost:9080/stub/StaticService/V40/KeyAsSegment.svc";
+    testActionOverloadingServiceRootURL = "http://localhost:9080/stub/StaticService/V40/ActionOverloading.svc";
+    testOpenTypeServiceRootURL = "http://localhost:9080/stub/StaticService/V40/OpenType.svc";
+    testLargeModelServiceRootURL = "http://localhost:9080/stub/StaticService/V40/Static.svc/large";
+    testAuthServiceRootURL = "http://localhost:9080/stub/DefaultService.svc/V40/Static.svc";
+
+    service = Service.getV4(testStaticServiceRootURL);
+    service.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    container = service.getEntityContainer(InMemoryEntities.class);
+    assertNotNull(container);
+    service.getContext().detachAll();
+  }
+
+  protected Customer readCustomer(final InMemoryEntities container, final int id) {
+    final Customer customer = container.getCustomers().getByKey(id).load();
+    assertNotNull(customer);
+    assertEquals(id, customer.getPersonID(), 0);
+
+    return customer;
+  }
+
+  protected void createPatchAndDeleteOrder(
+      final InMemoryEntities container, final AbstractService<EdmEnabledODataClient> service) {
+
+    // Create order ....
+    final Order order = container.newEntityInstance(Order.class);
+    order.setOrderID(105);
+
+    final Calendar orderDate = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+    orderDate.clear();
+    orderDate.set(2011, 3, 4, 16, 3, 57);
+    order.setOrderDate(new Timestamp(orderDate.getTimeInMillis()));
+
+    order.setShelfLife(BigDecimal.ZERO);
+
+    final PrimitiveCollection<BigDecimal> value = container.newPrimitiveCollection(BigDecimal.class);
+    value.add(BigDecimal.TEN.negate());
+    value.add(BigDecimal.TEN);
+    order.setOrderShelfLifes(value);
+
+    container.getOrders().add(order);
+    container.flush();
+
+    // Patch order ... (test for OLINGO-353)
+    order.setShelfLife(BigDecimal.TEN);
+    container.flush();
+
+    Order actual = container.getOrders().getByKey(105).load();
+    assertEquals(105, actual.getOrderID(), 0);
+    assertEquals(orderDate.getTimeInMillis(), actual.getOrderDate().getTime());
+    assertEquals(BigDecimal.TEN, actual.getShelfLife());
+    assertEquals(2, actual.getOrderShelfLifes().size());
+
+    // Delete order ...
+    container.getOrders().delete(105);
+    actual = container.getOrders().getByKey(105);
+    assertNull(actual);
+
+    service.getContext().detachAll();
+    actual = container.getOrders().getByKey(105);
+    assertNotNull(actual);
+
+    container.getOrders().delete(105);
+    actual = container.getOrders().getByKey(105);
+    assertNull(actual);
+
+    container.flush();
+
+    service.getContext().detachAll();
+    try {
+      container.getOrders().getByKey(105).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected Exception
+    }
+  }
+
+  @Override
+  protected ODataClient getClient() {
+    throw new RuntimeException("This method should not be used from proxy tests.");
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/AsyncTestITCase.java
new file mode 100644
index 0000000..6d4fe7f
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/AsyncTestITCase.java
@@ -0,0 +1,103 @@
+/*
+ * 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.fit.proxy;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import org.apache.commons.lang3.RandomStringUtils;
+// CHECKSTYLE:OFF (Maven checkstyle)
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.CustomerCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types
+        .PersonComposableInvoker;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types
+        .ProductCollectionComposableInvoker;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
+
+// CHECKSTYLE:ON (Maven checkstyle)
+import org.junit.Test;
+
+public class AsyncTestITCase extends AbstractTestITCase {
+
+  @Test
+  public void retrieveEntitySet() throws InterruptedException, ExecutionException {
+    final Future<CustomerCollection> futureCustomers = container.getCustomers().executeAsync();
+    assertNotNull(futureCustomers);
+
+    while (!futureCustomers.isDone()) {
+      Thread.sleep(1000L);
+    }
+
+    final CustomerCollection customers = futureCustomers.get();
+    assertNotNull(customers);
+    assertFalse(customers.isEmpty());
+    for (Customer customer : customers) {
+      assertNotNull(customer);
+    }
+  }
+
+  @Test
+  public void updateEntity() throws Exception {
+    final String randomFirstName = RandomStringUtils.random(10, "abcedfghijklmnopqrstuvwxyz");
+
+    final Person person = container.getPeople().getByKey(1);
+    person.setFirstName(randomFirstName);
+
+    final Future<Void> futureFlush = container.flushAsync();
+    assertNotNull(futureFlush);
+
+    while (!futureFlush.isDone()) {
+      Thread.sleep(1000L);
+    }
+
+    final Future<? extends Person> futurePerson = container.getPeople().getByKey(1).loadAsync();
+    assertEquals(randomFirstName, futurePerson.get().getFirstName());
+  }
+
+  @Test
+  public void invoke() throws Exception {
+    final ProductCollectionComposableInvoker invoker1 = container.operations().getAllProducts();
+
+    final Future<ProductCollection> future1 = invoker1.operations().
+        discount(10).
+        filter("Name eq XXXX").
+        select("Name", "ProductDetail").
+        expand("ProductDetail").
+        orderBy("Name").skip(3).top(5).executeAsync();
+    while (!future1.isDone()) {
+      Thread.sleep(1000L);
+    }
+    assertFalse(future1.get().isEmpty());
+
+    final PersonComposableInvoker invoker2 = container.operations().getPerson2("London");
+
+    final Future<Person> future2 = invoker2.select("Name").
+        expand("Order").executeAsync();
+    while (!future2.isDone()) {
+      Thread.sleep(1000L);
+    }
+    assertNotNull(future2.get());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/AuthEntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/AuthEntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/AuthEntityCreateTestITCase.java
new file mode 100644
index 0000000..2a54622
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/AuthEntityCreateTestITCase.java
@@ -0,0 +1,52 @@
+/*
+ * 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.fit.proxy;
+
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.fit.proxy.staticservice.Service;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
+
+public class AuthEntityCreateTestITCase extends EntityCreateTestITCase {
+
+  private Service<EdmEnabledODataClient> ecf;
+
+  private InMemoryEntities ime;
+
+  @Override
+  protected Service<EdmEnabledODataClient> getService() {
+    if (ecf == null) {
+      ecf = Service.getV4(testAuthServiceRootURL);
+      ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+      ecf.getClient().getConfiguration().
+      setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
+    }
+    return ecf;
+  }
+
+  @Override
+  protected InMemoryEntities getContainer() {
+    if (ime == null) {
+      ime = getService().getEntityContainer(InMemoryEntities.class);
+    }
+    return ime;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/AuthEntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/AuthEntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/AuthEntityRetrieveTestITCase.java
new file mode 100644
index 0000000..471c01b
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/AuthEntityRetrieveTestITCase.java
@@ -0,0 +1,37 @@
+/*
+ * 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.fit.proxy;
+
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.fit.proxy.staticservice.Service;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
+
+public class AuthEntityRetrieveTestITCase extends EntityRetrieveTestITCase {
+
+  @Override
+  protected InMemoryEntities getContainer() {
+    final Service<EdmEnabledODataClient> ecf = Service.getV4(testAuthServiceRootURL);
+    ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    ecf.getClient().getConfiguration().
+    setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
+    return ecf.getEntityContainer(InMemoryEntities.class);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/BoundOperationInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/BoundOperationInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/BoundOperationInvokeTestITCase.java
new file mode 100644
index 0000000..5847f47
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/BoundOperationInvokeTestITCase.java
@@ -0,0 +1,121 @@
+/*
+ * 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.fit.proxy;
+
+// CHECKSTYLE:OFF (Maven checkstyle)
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.sql.Timestamp;
+import java.util.Calendar;
+
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.AddressCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types
+        .ProductDetailCollectionComposableInvoker;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailKey;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfoComposableInvoker;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductComposableInvoker;
+
+import org.junit.Test;
+// CHECKSTYLE:ON (Maven checkstyle)
+
+public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
+
+  @Test
+  public void getEmployeesCount() {
+    assertNotNull(container.getCompany().load().operations().getEmployeesCount());
+  }
+
+  @Test
+  public void getProductDetails() {
+    final ProductDetailCollectionComposableInvoker result =
+        container.getProducts().getByKey(5).operations().getProductDetails(1);
+    assertEquals(1, result.execute().size());
+  }
+
+  @Test
+  public void getRelatedProduct() {
+    final ProductDetailKey key = new ProductDetailKey();
+    key.setProductID(6);
+    key.setProductDetailID(1);
+
+    final ProductComposableInvoker product =
+        container.getProductDetails().getByKey(key).operations().getRelatedProduct();
+    assertEquals(6, product.execute().getProductID(), 0);
+  }
+
+  @Test
+  public void getDefaultPI() {
+    final PaymentInstrument pi = container.getAccounts().getByKey(101).operations().getDefaultPI().execute();
+    assertEquals(101901, pi.getPaymentInstrumentID(), 0);
+  }
+
+  @Test
+  public void getAccountInfo() {
+    final AccountInfoComposableInvoker accountInfo =
+        container.getAccounts().getByKey(101).operations().getAccountInfo();
+    assertNotNull(accountInfo.execute());
+  }
+
+  @Test
+  public void getActualAmount() {
+    final Double amount =
+        container.getAccounts().getByKey(101).getMyGiftCard().operations().getActualAmount(1.1).execute();
+    assertEquals(41.79, amount, 0);
+  }
+
+  @Test
+  public void increaseRevenue() {
+    final Long result = container.getCompany().load().operations().increaseRevenue(12L).execute();
+    assertNotNull(result);
+  }
+
+  @Test
+  public void addAccessRight() {
+    final AccessLevel accessLevel =
+        container.getProducts().getByKey(5).operations().addAccessRight(AccessLevel.Execute).execute();
+    assertNotNull(accessLevel);
+  }
+
+  @Test
+  public void resetAddress() {
+    final Address address = container.newComplexInstance(HomeAddress.class);
+    address.setStreet("Via Le Mani Dal Naso, 123");
+    address.setPostalCode("Tollo");
+    address.setCity("66010");
+
+    final AddressCollection ac = container.newComplexCollection(AddressCollection.class);
+    ac.add(address);
+
+    final Person person = container.getCustomers().getByKey(2).operations().resetAddress(ac, 0).execute();
+    assertEquals(2, person.getPersonID(), 0);
+  }
+
+  @Test
+  public void refreshDefaultPI() {
+    final PaymentInstrument pi = container.getAccounts().getByKey(101).operations().
+        refreshDefaultPI(new Timestamp(Calendar.getInstance().getTimeInMillis())).execute();
+    assertEquals(101901, pi.getPaymentInstrumentID(), 0);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/ContextTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/ContextTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/ContextTestITCase.java
new file mode 100644
index 0000000..2d97038
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/ContextTestITCase.java
@@ -0,0 +1,101 @@
+/*
+ * 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.fit.proxy;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.ext.proxy.api.ODataFlushException;
+import org.apache.olingo.ext.proxy.api.PrimitiveCollection;
+import org.apache.olingo.fit.proxy.staticservice.Service;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Employee;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
+import org.junit.Test;
+
+public class ContextTestITCase extends AbstractTestITCase {
+
+  private void continueOnError(final Service<EdmEnabledODataClient> service, final InMemoryEntities container) {
+    final Person person = container.newEntityInstance(Person.class);
+    container.getPeople().add(person);
+
+    final Employee employee = container.newEntityInstance(Employee.class);
+    employee.setPersonID(199);
+    employee.setFirstName("Fabio");
+    employee.setLastName("Martelli");
+
+    final PrimitiveCollection<String> emails = container.newPrimitiveCollection(String.class);
+    emails.add("fabio.martelli@tirasa.net");
+
+    employee.setEmails(emails);
+    final Calendar date = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+    date.clear();
+    date.set(2011, 3, 4, 9, 0, 0);
+    employee.setDateHired(new Timestamp(date.getTimeInMillis()));
+    final Address homeAddress = container.newComplexInstance(Address.class);
+    homeAddress.setCity("Pescara");
+    homeAddress.setPostalCode("65100");
+    homeAddress.setStreet("viale Gabriele D'Annunzio 256");
+    employee.setHomeAddress(homeAddress);
+
+    final PrimitiveCollection<String> numbers = container.newPrimitiveCollection(String.class);
+    numbers.add("3204725072");
+    numbers.add("08569930");
+    employee.setNumbers(numbers);
+
+    container.getPeople().add(employee);
+
+    try {
+      container.flush();
+      fail();
+    } catch (ODataFlushException e) {
+      assertEquals(1, e.getErrors().size());
+      assertEquals(0, e.getErrors().get(0).getIndex());
+      assertNotNull(e.getErrors().get(0).getRequest());
+    }
+
+    service.getContext().detachAll();
+  }
+
+  @Test
+  public void transactionalContinueOnError() {
+    service.getClient().getConfiguration().setContinueOnError(true);
+    continueOnError(service, container);
+    service.getClient().getConfiguration().setContinueOnError(false);
+  }
+
+  @Test
+  public void nonTransactionalContinueOnError() {
+    final Service<EdmEnabledODataClient> _service = Service.getV4(testStaticServiceRootURL, false);
+    _service.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
+    _service.getClient().getConfiguration().setContinueOnError(true);
+
+    final InMemoryEntities _container = _service.getEntityContainer(InMemoryEntities.class);
+
+    continueOnError(_service, _container);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/DerivedTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/DerivedTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/DerivedTypeTestITCase.java
new file mode 100644
index 0000000..f59dcd8
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/DerivedTypeTestITCase.java
@@ -0,0 +1,95 @@
+/*
+ * 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.fit.proxy;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.Calendar;
+
+// CHECKSTYLE:OFF (Maven checkstyle)
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.CustomerCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyAddress;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.CreditCardPI;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.CreditCardPICollection;
+
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
+
+// CHECKSTYLE:ON (Maven checkstyle)
+import org.junit.Test;
+
+public class DerivedTypeTestITCase extends AbstractTestITCase {
+
+  @Test
+  public void read() {
+    final CustomerCollection customers = container.getPeople().execute(CustomerCollection.class);
+    assertNotNull(customers);
+
+    for (Object customer : customers) {
+      assertTrue(customer instanceof Customer);
+    }
+
+    final CreditCardPICollection creditCards = container.getAccounts().getByKey(101).
+        getMyPaymentInstruments().execute(CreditCardPICollection.class);
+    assertNotNull(creditCards);
+    for (Object creditCard : creditCards) {
+      assertTrue(creditCard instanceof CreditCardPI);
+    }
+  }
+
+  @Test
+  public void createDelete() {
+    final Customer customer = container.newEntityInstance(Customer.class);
+    customer.setPersonID(976);
+    customer.setFirstName("Test");
+    customer.setLastName("Test");
+
+    final Address homeAddress = container.newComplexInstance(CompanyAddress.class);
+    homeAddress.setStreet("V.le Gabriele D'Annunzio");
+    homeAddress.setCity("Pescara");
+    homeAddress.setPostalCode("65127");
+    customer.setHomeAddress(homeAddress);
+
+    customer.setNumbers(container.newPrimitiveCollection(String.class)); // empty
+    customer.setEmails(container.newPrimitiveCollection(String.class)); // empty
+    customer.setCity("Pescara");
+
+    final Calendar birthday = Calendar.getInstance();
+    birthday.clear();
+    birthday.set(1977, 8, 8);
+    customer.setBirthday(new Timestamp(birthday.getTimeInMillis()));
+
+    customer.setTimeBetweenLastTwoOrders(BigDecimal.valueOf(0.0000002));
+
+    container.getPeople().add(customer);
+    container.flush();
+
+    final Person actual = container.getPeople().getByKey(976, Customer.class).load();
+    assertTrue(actual instanceof Customer);
+    assertTrue(actual.getHomeAddress() instanceof CompanyAddress);
+
+    container.getPeople().delete(976);
+
+    container.flush();
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/EntityCreateTestITCase.java
new file mode 100644
index 0000000..e581111
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/EntityCreateTestITCase.java
@@ -0,0 +1,382 @@
+/*
+ * 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.fit.proxy;
+
+// CHECKSTYLE:OFF (Maven checkstyle)
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import org.apache.commons.lang3.RandomUtils;
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.ext.proxy.AbstractService;
+import org.apache.olingo.ext.proxy.api.PrimitiveCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Color;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Employee;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Order;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetail;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetailKey;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrumentCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Product;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetail;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollection;
+
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress;
+import org.junit.Assert;
+import org.junit.Test;
+// CHECKSTYLE:ON (Maven checkstyle)
+
+/**
+ * This is the unit test class to check entity create operations.
+ */
+public class EntityCreateTestITCase extends AbstractTestITCase {
+
+  protected AbstractService<EdmEnabledODataClient> getService() {
+    return service;
+  }
+
+  protected InMemoryEntities getContainer() {
+    return container;
+  }
+
+  @Test
+  public void createAndDelete() {
+    createPatchAndDeleteOrder(getContainer(), getService());
+  }
+
+  @Test
+  public void createEmployee() {
+    final Integer id = 101;
+
+    final Employee employee = getContainer().newEntityInstance(Employee.class);
+    employee.setPersonID(id);
+    employee.setFirstName("Fabio");
+    employee.setLastName("Martelli");
+
+    PrimitiveCollection<String> value = getContainer().newPrimitiveCollection(String.class);
+    value.add("fabio.martelli@tirasa.net");
+    employee.setEmails(value);
+
+    final Calendar date = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+    date.clear();
+    date.set(2011, 3, 4, 9, 0, 0);
+    employee.setDateHired(new Timestamp(date.getTimeInMillis()));
+    final Address homeAddress = getContainer().newComplexInstance(HomeAddress.class);
+    homeAddress.setCity("Pescara");
+    homeAddress.setPostalCode("65100");
+    homeAddress.setStreet("viale Gabriele D'Annunzio 256");
+    employee.setHomeAddress(homeAddress);
+
+    value = getContainer().newPrimitiveCollection(String.class);
+    value.add("3204725072");
+    value.add("08569930");
+    employee.setNumbers(value);
+
+    getContainer().getPeople().add(employee);
+
+    getContainer().flush();
+
+    Employee actual = getContainer().getPeople().getByKey(id, Employee.class).load();
+    assertNotNull(actual);
+    assertEquals(id, actual.getPersonID());
+    Assert.assertEquals(homeAddress.getCity(), actual.getHomeAddress().getCity());
+
+    getService().getContext().detachAll();
+    actual = getContainer().getPeople().getByKey(id, Employee.class).load();
+    assertNotNull(actual);
+    assertEquals(id, actual.getPersonID());
+    Assert.assertEquals(homeAddress.getCity(), actual.getHomeAddress().getCity());
+
+    getContainer().getPeople().delete(actual.getPersonID());
+    getContainer().flush();
+
+    try {
+      getContainer().getPeople().getByKey(id, Employee.class).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected
+    }
+
+    getService().getContext().detachAll();
+    try {
+      getContainer().getPeople().getByKey(id, Employee.class).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected
+    }
+  }
+
+  @Test
+  public void createWithNavigation() {
+    final Integer id = 101;
+
+    final Customer customer = getContainer().newEntityInstance(Customer.class);
+    customer.setPersonID(id);
+    customer.setPersonID(id);
+    customer.setFirstName("Fabio");
+    customer.setLastName("Martelli");
+    customer.setCity("Pescara");
+
+    PrimitiveCollection<String> value = getContainer().newPrimitiveCollection(String.class);
+    value.add("fabio.martelli@tirasa.net");
+    customer.setEmails(value);
+
+    Address homeAddress = getContainer().newComplexInstance(HomeAddress.class);
+    homeAddress.setCity("Pescara");
+    homeAddress.setPostalCode("65100");
+    homeAddress.setStreet("viale Gabriele D'Annunzio 256");
+    customer.setHomeAddress(homeAddress);
+
+    value = getContainer().newPrimitiveCollection(String.class);
+    value.add("3204725072");
+    value.add("08569930");
+    customer.setNumbers(value);
+
+    final OrderCollection orders = getContainer().newEntityCollection(OrderCollection.class);
+    orders.add(getContainer().getOrders().getByKey(8));
+    customer.setOrders(orders);
+
+    getContainer().getCustomers().add(customer);
+    getContainer().flush();
+
+    Customer actual = readCustomer(getContainer(), id);
+    Assert.assertEquals(homeAddress.getCity(), actual.getHomeAddress().getCity());
+    Assert.assertEquals(1, actual.getOrders().execute().size());
+    Assert.assertEquals(8, actual.getOrders().iterator().next().getOrderID(), 0);
+
+    getContainer().getCustomers().delete(actual.getPersonID());
+    getContainer().flush();
+
+    try {
+      getContainer().getCustomers().getByKey(id).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected
+    }
+  }
+
+  @Test
+  public void createWithBackNavigation() {
+    final Integer id = 102;
+
+    // -------------------------------
+    // Create a new order
+    // -------------------------------
+    Order order = getContainer().newEntityInstance(Order.class);
+    order.setOrderID(id);
+
+    final Calendar orderDate = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+    orderDate.clear();
+    orderDate.set(2011, 3, 4, 16, 3, 57);
+    order.setOrderDate(new Timestamp(orderDate.getTimeInMillis()));
+
+    order.setShelfLife(BigDecimal.TEN);
+
+    PrimitiveCollection<BigDecimal> osl = getContainer().newPrimitiveCollection(BigDecimal.class);
+    osl.add(BigDecimal.TEN.negate());
+    osl.add(BigDecimal.TEN);
+    order.setOrderShelfLifes(osl);
+    // -------------------------------
+
+    // -------------------------------
+    // Create a new customer
+    // -------------------------------
+    final Customer customer = getContainer().newEntityInstance(Customer.class);
+    customer.setPersonID(id);
+    customer.setPersonID(id);
+    customer.setFirstName("Fabio");
+    customer.setLastName("Martelli");
+    customer.setCity("Pescara");
+
+    PrimitiveCollection<String> value = getContainer().newPrimitiveCollection(String.class);
+    value.add("fabio.martelli@tirasa.net");
+    customer.setEmails(value);
+
+    final Address homeAddress = getContainer().newComplexInstance(HomeAddress.class);
+    homeAddress.setCity("Pescara");
+    homeAddress.setPostalCode("65100");
+    homeAddress.setStreet("viale Gabriele D'Annunzio 256");
+    customer.setHomeAddress(homeAddress);
+
+    value = getContainer().newPrimitiveCollection(String.class);
+    value.add("3204725072");
+    value.add("08569930");
+    customer.setNumbers(value);
+
+    final OrderCollection orders = getContainer().newEntityCollection(OrderCollection.class);
+    orders.add(order);
+    customer.setOrders(orders);
+    // -------------------------------
+
+    // -------------------------------
+    // Link customer to order
+    // -------------------------------
+    order.setCustomerForOrder(customer);
+    // -------------------------------
+
+    getContainer().getOrders().add(order);
+    getContainer().flush();
+
+    assertEquals(id, order.getOrderID());
+    assertEquals(id, customer.getPersonID());
+
+    Customer actual = readCustomer(getContainer(), id);
+    Assert.assertEquals(homeAddress.getCity(), actual.getHomeAddress().getCity());
+    Assert.assertEquals(1, actual.getOrders().execute().size());
+    Assert.assertEquals(id, actual.getOrders().iterator().next().getOrderID());
+
+    order = getContainer().getOrders().getByKey(id);
+    assertNotNull(order);
+    Assert.assertEquals(id, order.getCustomerForOrder().load().getPersonID());
+
+    getContainer().getOrders().delete(actual.getOrders());
+    getContainer().flush();
+
+    try {
+      getContainer().getOrders().getByKey(id).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected
+    }
+
+    actual = readCustomer(getContainer(), id);
+    assertTrue(actual.getOrders().isEmpty());
+
+    getContainer().getCustomers().delete(actual.getPersonID());
+    getContainer().flush();
+
+    try {
+      getContainer().getCustomers().getByKey(id).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected
+    }
+  }
+
+  @Test
+  public void multiKey() {
+    OrderDetail details = getContainer().newEntityInstance(OrderDetail.class);
+    details.setOrderID(8);
+    details.setProductID(1);
+    details.setQuantity(100);
+    details.setUnitPrice(5f);
+
+    getContainer().getOrderDetails().add(details);
+    getContainer().flush();
+
+    OrderDetailKey key = new OrderDetailKey();
+    key.setOrderID(8);
+    key.setProductID(1);
+
+    details = getContainer().getOrderDetails().getByKey(key).load();
+    assertNotNull(details);
+    assertEquals(Integer.valueOf(100), details.getQuantity());
+    assertEquals(8, details.getOrderID(), 0);
+    assertEquals(1, details.getProductID(), 0);
+    assertEquals(5f, details.getUnitPrice(), 0);
+
+    getContainer().getOrderDetails().delete(key);
+    getContainer().flush();
+
+    try {
+      getContainer().getOrderDetails().getByKey(key).load();
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected
+    }
+  }
+
+  @Test
+  public void deepInsert() {
+    Product product = getContainer().newEntityInstance(Product.class);
+    product.setProductID(12);
+    product.setName("Latte");
+    product.setQuantityPerUnit("100g Bag");
+    product.setUnitPrice(3.24f);
+    product.setQuantityInStock(100);
+    product.setDiscontinued(false);
+    product.setUserAccess(AccessLevel.Execute);
+    product.setSkinColor(Color.Blue);
+
+    PrimitiveCollection<Color> value = getContainer().newPrimitiveCollection(Color.class);
+    value.add(Color.Red);
+    value.add(Color.Green);
+    product.setCoverColors(value);
+
+    final ProductDetail detail = getContainer().newEntityInstance(ProductDetail.class);
+    detail.setProductID(product.getProductID());
+    detail.setProductDetailID(12);
+    detail.setProductName("LatteHQ");
+    detail.setDescription("High-Quality Milk");
+
+    final ProductDetailCollection detailCollection = getContainer().newEntityCollection(ProductDetailCollection.class);
+    detailCollection.add(detail);
+
+    product.setDetails(detailCollection);
+
+    getContainer().getProducts().add(product);
+    getContainer().flush();
+
+    product = getContainer().getProducts().getByKey(12).load();
+    assertEquals("Latte", product.getName());
+    Assert.assertEquals(12, product.getDetails().execute().iterator().next().getProductDetailID(), 0);
+  }
+
+  @Test
+  public void contained() {
+    PaymentInstrumentCollection instruments =
+        getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().execute();
+    final int sizeBefore = instruments.size();
+
+    final PaymentInstrument instrument = getContainer().newEntityInstance(PaymentInstrument.class);
+    instruments.add(instrument);
+
+    final int id = RandomUtils.nextInt(101999, 105000);
+    instrument.setPaymentInstrumentID(id);
+    instrument.setFriendlyName("New one");
+    instrument.setCreatedDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));
+
+    getContainer().flush();
+
+    instruments = getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().execute();
+    final int sizeAfter = instruments.size();
+    assertEquals(sizeBefore + 1, sizeAfter);
+
+    getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().delete(id);
+
+    getContainer().flush();
+
+    instruments = getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().execute();
+    final int sizeEnd = instruments.size();
+    assertEquals(sizeBefore, sizeEnd);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/EntityRetrieveTestITCase.java
new file mode 100644
index 0000000..3b74db8
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/EntityRetrieveTestITCase.java
@@ -0,0 +1,173 @@
+/*
+ * 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.fit.proxy;
+
+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.junit.Assert.fail;
+
+import java.lang.reflect.Proxy;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
+// CHECKSTYLE:OFF (Maven checkstyle)
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.CustomerCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Employee;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.EmployeeCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Order;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetail;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetailKey;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Product;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonCollection;
+
+// CHECKSTYLE:ON (Maven checkstyle)
+import org.junit.Test;
+
+/**
+ * This is the unit test class to check entity retrieve operations.
+ */
+public class EntityRetrieveTestITCase extends AbstractTestITCase {
+
+  protected InMemoryEntities getContainer() {
+    return container;
+  }
+
+  @Test
+  public void exists() {
+    assertTrue(getContainer().getCustomers().exists(1));
+    assertFalse(getContainer().getOrders().exists(1));
+  }
+
+  @Test
+  public void get() {
+    readCustomer(getContainer(), 1);
+  }
+
+  @Test
+  public void getAll() {
+    final PersonCollection all = getContainer().getPeople().execute();
+    assertNotNull(all);
+    assertFalse(all.isEmpty());
+    for (Person person : all) {
+      assertNotNull(person);
+    }
+
+    final EmployeeCollection employees = getContainer().getPeople().execute(EmployeeCollection.class);
+    assertNotNull(employees);
+    assertFalse(employees.isEmpty());
+    for (Employee employee : employees) {
+      assertNotNull(employee);
+    }
+
+    final CustomerCollection customers = getContainer().getPeople().execute(CustomerCollection.class);
+    assertNotNull(customers);
+    assertFalse(customers.isEmpty());
+    for (Customer customer : customers) {
+      assertNotNull(customer);
+    }
+
+    assertTrue(all.size() > employees.size() + customers.size());
+  }
+
+  @Test
+  public void navigate() {
+    final Order order = getContainer().getOrders().getByKey(8).load();
+    assertEquals(8, order.getOrderID(), 0);
+
+    final Timestamp date = order.getOrderDate();
+    assertNotNull(date);
+    final Calendar actual = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+    actual.clear();
+    actual.set(2011, 2, 4, 16, 3, 57);
+    assertEquals(actual.getTimeInMillis(), date.getTime());
+
+    final Customer customer = getContainer().getCustomers().getByKey(1).load();
+    assertNotNull(customer);
+    assertEquals(1, customer.getPersonID(), 0);
+    final Address address = customer.getHomeAddress();
+    assertNotNull(address);
+    assertEquals("98052", address.getPostalCode());
+  }
+
+  @Test
+  public void withInlineEntry() {
+    final Customer customer = readCustomer(getContainer(), 1);
+    final Company company = customer.getCompany();
+    assertEquals(0, company.load().getCompanyID(), 0);
+  }
+
+  @Test
+  public void withInlineFeed() {
+    final Customer customer = readCustomer(getContainer(), 1);
+    final OrderCollection orders = customer.getOrders();
+    assertEquals(1, orders.execute().size());
+    assertEquals(8, orders.iterator().next().getOrderID(), 0);
+  }
+
+  @Test
+  public void withActions() {
+    final Product product = getContainer().getProducts().getByKey(5).load();
+    assertEquals(5, product.getProductID(), 0);
+
+    try {
+      assertNotNull(product.operations().getClass().getMethod("addAccessRight", AccessLevel.class));
+    } catch (Exception e) {
+      fail();
+    }
+  }
+
+  @Test
+  public void multiKey() {
+    final OrderDetailKey orderDetailKey = new OrderDetailKey();
+    orderDetailKey.setOrderID(7);
+    orderDetailKey.setProductID(5);
+
+    final OrderDetail orderDetail = getContainer().getOrderDetails().getByKey(orderDetailKey).load();
+    assertNotNull(orderDetail);
+    assertEquals(7, orderDetail.getOrderID(), 0);
+    assertEquals(5, orderDetail.getProductID(), 0);
+  }
+
+  @Test
+  public void checkForETag() {
+    final Order order = getContainer().getOrders().getByKey(8).load();
+    assertTrue(StringUtils.isNotBlank(((EntityInvocationHandler) Proxy.getInvocationHandler(order)).getETag()));
+  }
+
+  @Test
+  public void contained() {
+    final PaymentInstrument instrument =
+        getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().getByKey(101901).load();
+    assertEquals(101901, instrument.getPaymentInstrumentID(), 0);
+    assertNotNull(instrument.getCreatedDate());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/EntitySetTestITCase.java
new file mode 100644
index 0000000..7610603
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/EntitySetTestITCase.java
@@ -0,0 +1,76 @@
+/*
+ * 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.fit.proxy;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * This is the unit test class to check basic feed operations.
+ */
+public class EntitySetTestITCase extends AbstractTestITCase {
+
+  @Test
+  public void count() {
+    assertNotNull(container.getOrders());
+    Assert.assertEquals(2, container.getOrders().count().longValue());
+  }
+
+  @Test
+  public void getAll() {
+    int count = 0;
+    for (Customer customer : container.getCustomers().execute()) {
+      assertNotNull(customer);
+      count++;
+    }
+    assertEquals(2, count);
+  }
+
+  @Test
+  public void iterator() {
+    int count = 0;
+    for (Customer customer : container.getCustomers()) {
+      assertNotNull(customer);
+      count++;
+    }
+    assertEquals(2, count);
+  }
+
+  @Test
+  public void readEntitySetWithNextLink() {
+    int count = 0;
+    for (Person people : container.getPeople().execute()) {
+      assertNotNull(people);
+      count++;
+    }
+    assertEquals(5, count);
+
+    int iterating = 0;
+    for (Person person : container.getPeople()) {
+      assertNotNull(person);
+      iterating++;
+    }
+    assertEquals(count + 1, iterating);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/EntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/EntityUpdateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/EntityUpdateTestITCase.java
new file mode 100644
index 0000000..fce3d85
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/EntityUpdateTestITCase.java
@@ -0,0 +1,193 @@
+/*
+ * 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.fit.proxy;
+
+// CHECKSTYLE:OFF (Maven checkstyle)
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+
+import java.lang.reflect.Proxy;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.UUID;
+
+import org.apache.commons.lang3.RandomUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.ext.proxy.AbstractService;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetail;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetailKey;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyAddress;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Order;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderCollection;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument;
+import org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
+import org.junit.Test;
+
+// CHECKSTYLE:ON (Maven checkstyle)
+/**
+ * This is the unit test class to check entity update operations.
+ */
+public class EntityUpdateTestITCase extends AbstractTestITCase {
+
+  protected AbstractService<EdmEnabledODataClient> getService() {
+    return service;
+  }
+
+  protected InMemoryEntities getContainer() {
+    return container;
+  }
+
+  @Test
+  public void update() {
+    Person person = getContainer().getPeople().getByKey(1);
+
+    final Address address = person.getHomeAddress();
+    address.setCity("XXX");
+
+    getContainer().flush();
+
+    person = getContainer().getPeople().getByKey(1).load();
+    assertEquals("XXX", person.getHomeAddress().getCity());
+  }
+
+  @Test
+  public void multiKey() {
+    final OrderDetailKey orderDetailKey = new OrderDetailKey();
+    orderDetailKey.setOrderID(7);
+    orderDetailKey.setProductID(5);
+
+    OrderDetail orderDetail = getContainer().getOrderDetails().getByKey(orderDetailKey).load();
+    assertNotNull(orderDetail);
+    assertEquals(7, orderDetail.getOrderID(), 0);
+    assertEquals(5, orderDetail.getProductID(), 0);
+
+    orderDetail.setQuantity(5);
+
+    getContainer().flush();
+
+    orderDetail = getContainer().getOrderDetails().getByKey(orderDetailKey).load();
+    assertEquals(5, orderDetail.getQuantity(), 0);
+  }
+
+  @Test
+  public void patchLink() {
+    // 1. create customer
+    Customer customer = getContainer().newEntityInstance(Customer.class);
+    customer.setPersonID(977);
+    customer.setFirstName("Test");
+    customer.setLastName("Test");
+
+    final Address homeAddress = getContainer().newComplexInstance(CompanyAddress.class);
+    homeAddress.setStreet("V.le Gabriele D'Annunzio");
+    homeAddress.setCity("Pescara");
+    homeAddress.setPostalCode("65127");
+    customer.setHomeAddress(homeAddress);
+
+    customer.setNumbers(getContainer().newPrimitiveCollection(String.class)); // empty
+    customer.setEmails(getContainer().newPrimitiveCollection(String.class)); // empty
+    customer.setCity("Pescara");
+
+    final Calendar birthday = Calendar.getInstance();
+    birthday.clear();
+    birthday.set(1977, 8, 8);
+    customer.setBirthday(new Timestamp(birthday.getTimeInMillis()));
+
+    customer.setTimeBetweenLastTwoOrders(BigDecimal.valueOf(0.0000002));
+
+    // 2. create order and set it to customer
+    final int orderId = RandomUtils.nextInt(400, 410);
+
+    Order order = getContainer().newEntityInstance(Order.class);
+    order.setOrderID(orderId);
+
+    final OrderCollection orders = getContainer().newEntityCollection(OrderCollection.class);
+    orders.add(order);
+
+    customer.setOrders(orders);
+    order.setCustomerForOrder(customer);
+
+    getContainer().getCustomers().add(customer);
+    getContainer().flush();
+
+    assertEquals(977, order.getCustomerForOrder().load().getPersonID(), 0);
+    // order.getCustomerForOrder().load() caches Customer ... test server doesn't support something like the following
+    // <service>/Orders(400)/CustomerForOrder/Orders
+    // detach all and check for stored data ..
+    getService().getContext().detachAll();
+
+    // 3. check everything after flush
+    order = getContainer().getOrders().getByKey(orderId).load();
+    assertEquals(orderId, order.getOrderID(), 0);
+
+    customer = getContainer().getCustomers().getByKey(977);
+
+    // assertEquals(1, customer.getOrders().size());
+
+    int count = 0;
+    for (Order inside : customer.getOrders().execute()) {
+      if (inside.getOrderID() == orderId) {
+        count++;
+      }
+    }
+    assertEquals(1, count);
+    assertEquals(977, order.getCustomerForOrder().load().getPersonID(), 0);
+
+    // 4. delete customer and order
+    getContainer().getCustomers().delete(977);
+    getContainer().getOrders().delete(orderId);
+
+    getContainer().flush();
+  }
+
+  @Test
+  public void concurrentModification() {
+    Order order = getContainer().getOrders().getByKey(8).load();
+    final String etag = ((EntityInvocationHandler) Proxy.getInvocationHandler(order)).getETag();
+    assertTrue(StringUtils.isNotBlank(etag));
+
+    order.setShelfLife(BigDecimal.TEN);
+
+    getContainer().flush();
+
+    order = getContainer().getOrders().getByKey(8).load();
+    assertEquals(BigDecimal.TEN, order.getShelfLife());
+  }
+
+  @Test
+  public void contained() {
+    PaymentInstrument instrument =
+        getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().getByKey(101901);
+
+    final String newName = UUID.randomUUID().toString();
+    instrument.setFriendlyName(newName);
+
+    getContainer().flush();
+
+    instrument = getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().getByKey(101901).load();
+    assertEquals(newName, instrument.getFriendlyName());
+  }
+}