olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [32/51] [abbrv] [partial] Removing /ODataJClient: merge complete
Date Thu, 22 May 2014 11:43:40 GMT
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AbstractTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AbstractTestITCase.java
deleted file mode 100644
index 70643f0..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AbstractTestITCase.java
+++ /dev/null
@@ -1,605 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.msopentech.odatajclient.engine.client.http.HttpMethod;
-import com.msopentech.odatajclient.engine.communication.ODataClientErrorException;
-import com.msopentech.odatajclient.engine.communication.request.UpdateType;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataDeleteRequest;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataEntityCreateRequest;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataEntityUpdateRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntityRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataDeleteResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityCreateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityUpdateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.data.ODataCollectionValue;
-import com.msopentech.odatajclient.engine.data.ODataComplexValue;
-import com.msopentech.odatajclient.engine.data.ODataProperty;
-import com.msopentech.odatajclient.engine.data.ODataValue;
-import com.msopentech.odatajclient.engine.metadata.edm.EdmSimpleType;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import com.msopentech.odatajclient.engine.data.Entry;
-import com.msopentech.odatajclient.engine.data.Feed;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.data.ODataInlineEntity;
-import com.msopentech.odatajclient.engine.data.ODataLink;
-import com.msopentech.odatajclient.engine.data.impl.v3.AtomEntry;
-import com.msopentech.odatajclient.engine.data.impl.v3.JSONEntry;
-import com.msopentech.odatajclient.engine.data.ODataEntitySet;
-import com.msopentech.odatajclient.engine.data.ODataInlineEntitySet;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import com.msopentech.odatajclient.engine.client.ODataClientFactory;
-import com.msopentech.odatajclient.engine.client.ODataV3Client;
-import com.msopentech.odatajclient.engine.utils.URIUtils;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Properties;
-import java.util.Set;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractTestITCase {
-
-    /**
-     * Logger.
-     */
-    protected static final Logger LOG = LoggerFactory.getLogger(AbstractTestITCase.class);
-
-    protected static final String TEST_PRODUCT_TYPE = "Microsoft.Test.OData.Services.AstoriaDefaultService.Product";
-
-    protected static final String servicesODataServiceRootURL =
-            "http://services.odata.org/V3/(S(csquyjnoaywmz5xcdbfhlc1p))/OData/OData.svc/";
-
-    protected static ODataV3Client client;
-
-    protected static String testDefaultServiceRootURL;
-
-    protected static String testStaticServiceRootURL;
-
-    protected static String testActionOverloadingServiceRootURL;
-
-    protected static String testKeyAsSegmentServiceRootURL;
-
-//    protected static String testODataWriterDefaultServiceRootURL;
-    protected static String testOpenTypeServiceRootURL;
-
-    protected static String testPrimitiveKeysServiceRootURL;
-
-    protected static String testLargeModelServiceRootURL;
-
-    protected static String testAuthServiceRootURL;
-
-    @BeforeClass
-    public static void setUpODataServiceRoot() throws IOException {
-        String testBaseURL = null;
-
-        InputStream propStream = null;
-        try {
-            propStream = AbstractTestITCase.class.getResourceAsStream("/test.properties");
-            final Properties props = new Properties();
-            props.load(propStream);
-
-            testBaseURL = props.getProperty("test.base.url");
-        } catch (Exception e) {
-            LOG.error("Could not load test.properties", e);
-        } finally {
-            if (propStream != null) {
-                propStream.close();
-            }
-        }
-        assertNotNull("Check value for the 'test.base.url' property", testBaseURL);
-
-        testDefaultServiceRootURL = testBaseURL + "/DefaultService.svc";
-        testStaticServiceRootURL = "http://localhost:9080/StaticService/V3/Static.svc";
-        testActionOverloadingServiceRootURL = testBaseURL + "/ActionOverloadingService.svc";
-        testKeyAsSegmentServiceRootURL = testBaseURL + "/KeyAsSegmentService.svc";
-//        testODataWriterDefaultServiceRootURL = testBaseURL + "/ODataWriterDefaultService.svc";
-        testOpenTypeServiceRootURL = testBaseURL + "/OpenTypeService.svc";
-        testPrimitiveKeysServiceRootURL = "http://localhost:9080/StaticService/V3/Static.svc";
-        testLargeModelServiceRootURL = "http://localhost:9080/StaticService/V3/Static.svc/large";
-        testAuthServiceRootURL = "http://localhost:9080/DefaultService.svc";
-    }
-
-    /**
-     * This is needed for correct number handling (Double, for example).
-     */
-    @BeforeClass
-    public static void setEnglishLocale() {
-        Locale.setDefault(Locale.ENGLISH);
-    }
-
-    @BeforeClass
-    public static void setClientInstance() {
-        client = ODataClientFactory.getV3();
-    }
-
-    protected void checkLinks(final Collection<ODataLink> original, final Collection<ODataLink> actual) {
-        assertTrue(original.size() <= actual.size());
-
-        for (ODataLink originalLink : original) {
-            ODataLink foundOriginal = null;
-            ODataLink foundActual = null;
-
-            for (ODataLink actualLink : actual) {
-
-                if (actualLink.getType() == originalLink.getType()
-                        && (originalLink.getLink() == null
-                        || actualLink.getLink().toASCIIString().endsWith(originalLink.getLink().toASCIIString()))
-                        && actualLink.getName().equals(originalLink.getName())) {
-
-                    foundOriginal = originalLink;
-                    foundActual = actualLink;
-                }
-            }
-
-            assertNotNull(foundOriginal);
-            assertNotNull(foundActual);
-
-            if (foundOriginal instanceof ODataInlineEntity && foundActual instanceof ODataInlineEntity) {
-                final ODataEntity originalInline = ((ODataInlineEntity) foundOriginal).getEntity();
-                assertNotNull(originalInline);
-
-                final ODataEntity actualInline = ((ODataInlineEntity) foundActual).getEntity();
-                assertNotNull(actualInline);
-
-                checkProperties(originalInline.getProperties(), actualInline.getProperties());
-            }
-        }
-    }
-
-    protected void checkProperties(final Collection<ODataProperty> original, final Collection<ODataProperty> actual) {
-        assertTrue(original.size() <= actual.size());
-
-        // re-organize actual properties into a Map<String, ODataProperty>
-        final Map<String, ODataProperty> actualProps = new HashMap<String, ODataProperty>(actual.size());
-
-        for (ODataProperty prop : actual) {
-            assertFalse(actualProps.containsKey(prop.getName()));
-            actualProps.put(prop.getName(), prop);
-        }
-
-        assertTrue(actual.size() <= actualProps.size());
-
-        for (ODataProperty prop : original) {
-            assertNotNull(prop);
-            if (actualProps.containsKey(prop.getName())) {
-                final ODataProperty actualProp = actualProps.get(prop.getName());
-                assertNotNull(actualProp);
-
-                if (prop.getValue() != null && actualProp.getValue() != null) {
-                    checkPropertyValue(prop.getName(), prop.getValue(), actualProp.getValue());
-                }
-            } else {
-                // nothing ... maybe :FC_KeepInContent="false"
-                // ..... no assert can be done ....
-            }
-        }
-    }
-
-    protected void checkPropertyValue(final String propertyName,
-            final ODataValue original, final ODataValue actual) {
-
-        assertNotNull("Null original value for " + propertyName, original);
-        assertNotNull("Null actual value for " + propertyName, actual);
-
-        assertEquals("Type mismatch for '" + propertyName + "': "
-                + original.getClass().getSimpleName() + "-" + actual.getClass().getSimpleName(),
-                original.getClass().getSimpleName(), actual.getClass().getSimpleName());
-
-        if (original.isComplex()) {
-            final List<ODataProperty> originalFileds = new ArrayList<ODataProperty>();
-            for (ODataProperty prop : original.asComplex()) {
-                originalFileds.add(prop);
-            }
-
-            final List<ODataProperty> actualFileds = new ArrayList<ODataProperty>();
-            for (ODataProperty prop : (ODataComplexValue) actual) {
-                actualFileds.add(prop);
-            }
-
-            checkProperties(originalFileds, actualFileds);
-        } else if (original.isCollection()) {
-            assertTrue(original.asCollection().size() <= actual.asCollection().size());
-
-            boolean found = original.asCollection().isEmpty();
-
-            for (ODataValue originalValue : original.asCollection()) {
-                for (ODataValue actualValue : actual.asCollection()) {
-                    try {
-                        checkPropertyValue(propertyName, originalValue, actualValue);
-                        found = true;
-                    } catch (AssertionError ignore) {
-                        // ignore
-                    }
-                }
-            }
-
-            assertTrue("Found " + actual + " but expected " + original, found);
-        } else {
-            assertTrue("Primitive value for '" + propertyName + "' type mismatch: " + original.asPrimitive().
-                    getTypeName() + "-" + actual.asPrimitive().getTypeName(),
-                    original.asPrimitive().getTypeName().equals(actual.asPrimitive().getTypeName()));
-
-            assertEquals("Primitive value for '" + propertyName + "' mismatch: " + original.asPrimitive().toString()
-                    + "-" + actual.asPrimitive().toString(),
-                    original.asPrimitive().toString(), actual.asPrimitive().toString());
-        }
-    }
-
-    protected ODataEntity getSampleCustomerInfo(final int id, final String sampleinfo) {
-        final ODataEntity entity =
-                client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo");
-        entity.setMediaEntity(true);
-
-        entity.addProperty(client.getObjectFactory().newPrimitiveProperty("Information",
-                client.getPrimitiveValueBuilder().setText(sampleinfo).setType(
-                EdmSimpleType.String).build()));
-
-        return entity;
-    }
-
-    protected ODataEntity getSampleCustomerProfile(
-            final int id, final String sampleName, final boolean withInlineInfo) {
-
-        final ODataEntity entity =
-                client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
-
-        // add name attribute
-        entity.addProperty(client.getObjectFactory().newPrimitiveProperty("Name",
-                client.getPrimitiveValueBuilder().setText(sampleName).setType(
-                EdmSimpleType.String).build()));
-
-        // add key attribute
-        entity.addProperty(client.getObjectFactory().newPrimitiveProperty("CustomerId",
-                client.getPrimitiveValueBuilder().setText(String.valueOf(id)).setType(
-                EdmSimpleType.Int32).build()));
-
-        // add BackupContactInfo attribute (collection)
-        final ODataCollectionValue backupContactInfoValue = new ODataCollectionValue(
-                "Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails)");
-        entity.addProperty(client.getObjectFactory().newCollectionProperty("BackupContactInfo",
-                backupContactInfoValue));
-
-        // add BackupContactInfo.ContactDetails attribute (complex)
-        final ODataComplexValue contactDetails = new ODataComplexValue(
-                "Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails");
-        backupContactInfoValue.add(contactDetails);
-
-        // add BackupContactInfo.ContactDetails.AlternativeNames attribute (collection)
-        final ODataCollectionValue altNamesValue = new ODataCollectionValue("Collection(Edm.String)");
-        altNamesValue.add(client.getPrimitiveValueBuilder().
-                setText("myname").setType(EdmSimpleType.String).build());
-        contactDetails.add(client.getObjectFactory().newCollectionProperty("AlternativeNames", altNamesValue));
-
-        // add BackupContactInfo.ContactDetails.EmailBag attribute (collection)
-        final ODataCollectionValue emailBagValue = new ODataCollectionValue("Collection(Edm.String)");
-        emailBagValue.add(client.getPrimitiveValueBuilder().
-                setText("myname@mydomain.com").setType(EdmSimpleType.String).build());
-        contactDetails.add(client.getObjectFactory().newCollectionProperty("EmailBag", emailBagValue));
-
-        // add BackupContactInfo.ContactDetails.ContactAlias attribute (complex)
-        final ODataComplexValue contactAliasValue = new ODataComplexValue(
-                "Microsoft.Test.OData.Services.AstoriaDefaultService.Aliases");
-        contactDetails.add(client.getObjectFactory().newComplexProperty("ContactAlias", contactAliasValue));
-
-        // add BackupContactInfo.ContactDetails.ContactAlias.AlternativeNames attribute (collection)
-        final ODataCollectionValue aliasAltNamesValue = new ODataCollectionValue("Collection(Edm.String)");
-        aliasAltNamesValue.add(client.getPrimitiveValueBuilder().
-                setText("myAlternativeName").setType(EdmSimpleType.String).build());
-        contactAliasValue.add(client.getObjectFactory().newCollectionProperty("AlternativeNames", aliasAltNamesValue));
-
-        if (withInlineInfo) {
-            final ODataInlineEntity inlineInfo = client.getObjectFactory().newInlineEntity(
-                    "Info",
-                    URI.create("Customer(" + id + ")/Info"),
-                    getSampleCustomerInfo(id, sampleName + "_Info"));
-            inlineInfo.getEntity().setMediaEntity(true);
-            entity.addLink(inlineInfo);
-        }
-
-        return entity;
-    }
-
-    protected void debugEntry(final Entry entry, final String message) {
-        if (LOG.isDebugEnabled()) {
-            final StringWriter writer = new StringWriter();
-            client.getSerializer().entry(entry, writer);
-            writer.flush();
-            LOG.debug(message + "\n{}", writer.toString());
-        }
-    }
-
-    protected void debugFeed(final Feed feed, final String message) {
-        if (LOG.isDebugEnabled()) {
-            final StringWriter writer = new StringWriter();
-            client.getSerializer().feed(feed, writer);
-            writer.flush();
-            LOG.debug(message + "\n{}", writer.toString());
-        }
-    }
-
-    protected void debugODataProperty(final ODataProperty property, final String message) {
-        LOG.debug(message + "\n{}", property.toString());
-    }
-
-    protected void debugODataValue(final ODataValue value, final String message) {
-        LOG.debug(message + "\n{}", value.toString());
-    }
-
-    protected void debugODataEntity(final ODataEntity entity, final String message) {
-        if (LOG.isDebugEnabled()) {
-            StringWriter writer = new StringWriter();
-            client.getSerializer().entry(client.getBinder().getEntry(entity, AtomEntry.class), writer);
-            writer.flush();
-            LOG.debug(message + " (Atom)\n{}", writer.toString());
-
-            writer = new StringWriter();
-            client.getSerializer().entry(client.getBinder().getEntry(entity, JSONEntry.class), writer);
-            writer.flush();
-            LOG.debug(message + " (JSON)\n{}", writer.toString());
-        }
-    }
-
-    protected void debugInputStream(final InputStream input, final String message) {
-        if (LOG.isDebugEnabled()) {
-            try {
-                LOG.debug(message + "\n{}", IOUtils.toString(input));
-            } catch (IOException e) {
-                LOG.error("Error writing stream", e);
-            } finally {
-                IOUtils.closeQuietly(input);
-            }
-        }
-    }
-
-    protected String getETag(final URI uri) {
-        final ODataRetrieveResponse<ODataEntity> res = client.getRetrieveRequestFactory().
-                getEntityRequest(uri).execute();
-        try {
-            return res.getEtag();
-        } finally {
-            res.close();
-        }
-    }
-
-    protected ODataEntity read(final ODataPubFormat format, final URI editLink) {
-        final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(editLink);
-        req.setFormat(format);
-
-        final ODataRetrieveResponse<ODataEntity> res = req.execute();
-        final ODataEntity entity = res.getBody();
-
-        assertNotNull(entity);
-
-        if (ODataPubFormat.JSON_FULL_METADATA == format || ODataPubFormat.ATOM == format) {
-            assertEquals(req.getURI(), entity.getEditLink());
-        }
-
-        return entity;
-    }
-
-    protected ODataEntity createEntity(
-            final String serviceRootURL,
-            final ODataPubFormat format,
-            final ODataEntity original,
-            final String entitySetName) {
-
-        final URIBuilder uriBuilder = client.getURIBuilder(serviceRootURL);
-        uriBuilder.appendEntitySetSegment(entitySetName);
-
-        debugODataEntity(original, "About to create");
-
-        final ODataEntityCreateRequest createReq =
-                client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
-        createReq.setFormat(format);
-
-        final ODataEntityCreateResponse createRes = createReq.execute();
-        assertEquals(201, createRes.getStatusCode());
-        assertEquals("Created", createRes.getStatusMessage());
-
-        final ODataEntity created = createRes.getBody();
-        assertNotNull(created);
-
-        debugODataEntity(created, "Just created");
-
-        return created;
-    }
-
-    protected ODataEntity compareEntities(final String serviceRootURL,
-            final ODataPubFormat format,
-            final ODataEntity original,
-            final int actualObjectId,
-            final Collection<String> expands) {
-
-        final URIBuilder uriBuilder = client.getURIBuilder(serviceRootURL).
-                appendEntityTypeSegment("Customer").appendKeySegment(actualObjectId);
-
-        // search expanded
-        if (expands != null) {
-            for (String expand : expands) {
-                uriBuilder.expand(expand);
-            }
-        }
-
-        final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
-        req.setFormat(format);
-
-        final ODataRetrieveResponse<ODataEntity> res = req.execute();
-        assertEquals(200, res.getStatusCode());
-
-        final ODataEntity actual = res.getBody();
-        assertNotNull(actual);
-
-        // check defined links
-        checkLinks(original.getAssociationLinks(), actual.getAssociationLinks());
-        checkLinks(original.getEditMediaLinks(), actual.getEditMediaLinks());
-        checkLinks(original.getNavigationLinks(), actual.getNavigationLinks());
-
-        // check defined properties equality
-        checkProperties(original.getProperties(), actual.getProperties());
-
-        return actual;
-    }
-
-    protected void cleanAfterCreate(
-            final ODataPubFormat format,
-            final ODataEntity created,
-            final boolean includeInline,
-            final String baseUri) {
-
-        final Set<URI> toBeDeleted = new HashSet<URI>();
-        toBeDeleted.add(created.getEditLink());
-
-        if (includeInline) {
-            for (ODataLink link : created.getNavigationLinks()) {
-                if (link instanceof ODataInlineEntity) {
-                    final ODataEntity inline = ((ODataInlineEntity) link).getEntity();
-                    if (inline.getEditLink() != null) {
-                        toBeDeleted.add(URIUtils.getURI(baseUri, inline.getEditLink().toASCIIString()));
-                    }
-                }
-
-                if (link instanceof ODataInlineEntitySet) {
-                    final ODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
-                    for (ODataEntity entity : inline.getEntities()) {
-                        if (entity.getEditLink() != null) {
-                            toBeDeleted.add(URIUtils.getURI(baseUri, entity.getEditLink().toASCIIString()));
-                        }
-                    }
-                }
-            }
-        }
-
-        assertFalse(toBeDeleted.isEmpty());
-
-        for (URI link : toBeDeleted) {
-            final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(link);
-            final ODataDeleteResponse deleteRes = deleteReq.execute();
-
-            assertEquals(204, deleteRes.getStatusCode());
-            assertEquals("No Content", deleteRes.getStatusMessage());
-
-            deleteRes.close();
-
-            final ODataEntityRequest retrieveReq = client.getRetrieveRequestFactory().getEntityRequest(link);
-            // bug that needs to be fixed on the SampleService - cannot get entity not found with header
-            // Accept: application/json;odata=minimalmetadata
-            retrieveReq.setFormat(format == ODataPubFormat.JSON_FULL_METADATA ? ODataPubFormat.JSON : format);
-
-            Exception exception = null;
-            try {
-                retrieveReq.execute();
-                fail();
-            } catch (ODataClientErrorException e) {
-                exception = e;
-                assertEquals(404, e.getStatusLine().getStatusCode());
-            }
-            assertNotNull(exception);
-        }
-    }
-
-    protected void updateEntityDescription(
-            final ODataPubFormat format, final ODataEntity changes, final UpdateType type) {
-
-        updateEntityDescription(format, changes, type, null);
-    }
-
-    protected void updateEntityDescription(
-            final ODataPubFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
-
-        updateEntityStringProperty("Description", format, changes, type, etag);
-    }
-
-    protected void updateEntityStringProperty(final String propertyName,
-            final ODataPubFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
-
-        final URI editLink = changes.getEditLink();
-
-        final String newm = "New " + propertyName + "(" + System.currentTimeMillis() + ")";
-
-        ODataProperty propertyValue = changes.getProperty(propertyName);
-
-        final String oldm;
-        if (propertyValue == null) {
-            oldm = null;
-        } else {
-            oldm = propertyValue.getValue().toString();
-            changes.removeProperty(propertyValue);
-        }
-
-        assertNotEquals(newm, oldm);
-
-        changes.addProperty(client.getObjectFactory().newPrimitiveProperty(propertyName,
-                client.getPrimitiveValueBuilder().setText(newm).build()));
-
-        update(type, changes, format, etag);
-
-        final ODataEntity actual = read(format, editLink);
-
-        propertyValue = null;
-
-        for (ODataProperty prop : actual.getProperties()) {
-            if (prop.getName().equals(propertyName)) {
-                propertyValue = prop;
-            }
-        }
-
-        assertNotNull(propertyValue);
-        assertEquals(newm, propertyValue.getValue().toString());
-    }
-
-    protected void update(
-            final UpdateType type, final ODataEntity changes, final ODataPubFormat format, final String etag) {
-        final ODataEntityUpdateRequest req = client.getCUDRequestFactory().getEntityUpdateRequest(type, changes);
-
-        if (client.getConfiguration().isUseXHTTPMethod()) {
-            assertEquals(HttpMethod.POST, req.getMethod());
-        } else {
-            assertEquals(type.getMethod(), req.getMethod());
-        }
-        req.setFormat(format);
-
-        if (StringUtils.isNotBlank(etag)) {
-            req.setIfMatch(etag); // Product include ETag header into the response .....
-        }
-
-        final ODataEntityUpdateResponse res = req.execute();
-        assertEquals(204, res.getStatusCode());
-    }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ActionOverloadingTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ActionOverloadingTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ActionOverloadingTestITCase.java
deleted file mode 100644
index de9e03b..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ActionOverloadingTestITCase.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import com.msopentech.odatajclient.engine.communication.response.ODataInvokeResponse;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.data.ODataEntitySet;
-import com.msopentech.odatajclient.engine.data.ODataNoContent;
-import com.msopentech.odatajclient.engine.data.ODataProperty;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.data.ODataValue;
-import com.msopentech.odatajclient.engine.metadata.EdmV3Metadata;
-import com.msopentech.odatajclient.engine.metadata.edm.EdmSimpleType;
-import com.msopentech.odatajclient.engine.metadata.edm.v3.EntityContainer;
-import com.msopentech.odatajclient.engine.metadata.edm.v3.FunctionImport;
-import com.msopentech.odatajclient.engine.utils.URIUtils;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.junit.Test;
-
-public class ActionOverloadingTestITCase extends AbstractTestITCase {
-
-    @Test
-    public void retrieveProducts() {
-        final EdmV3Metadata metadata = client.getRetrieveRequestFactory().
-                getMetadataRequest(testActionOverloadingServiceRootURL).execute().getBody();
-        assertNotNull(metadata);
-
-        final EntityContainer container = metadata.getSchema(0).getEntityContainers().get(0);
-        assertNotNull(container);
-
-        int execs = 0;
-        for (FunctionImport funcImp : container.getFunctionImports("RetrieveProduct")) {
-            final ODataInvokeResponse<ODataProperty> res;
-            if (funcImp.getParameters().isEmpty()) {
-                final URIBuilder funcImpBuilder = client.getURIBuilder(testActionOverloadingServiceRootURL).
-                        appendFunctionImportSegment(URIUtils.rootFunctionImportURISegment(container, funcImp));
-
-                res = client.getInvokeRequestFactory().<ODataProperty>getInvokeRequest(
-                        funcImpBuilder.build(), metadata, funcImp).execute();
-            } else if ("Microsoft.Test.OData.Services.AstoriaDefaultService.Product".
-                    equals(funcImp.getParameters().get(0).getType())) {
-
-                final ODataEntity product = client.getRetrieveRequestFactory().getEntityRequest(
-                        client.getURIBuilder(testActionOverloadingServiceRootURL).
-                        appendEntityTypeSegment("Product").appendKeySegment(-10).build()).
-                        execute().getBody();
-                assertNotNull(product);
-
-                res = client.getInvokeRequestFactory().<ODataProperty>getInvokeRequest(
-                        product.getOperation("RetrieveProduct").getTarget(), metadata, funcImp).execute();
-            } else if ("Microsoft.Test.OData.Services.AstoriaDefaultService.OrderLine".
-                    equals(funcImp.getParameters().get(0).getType())) {
-
-                final Map<String, Object> key = new LinkedHashMap<String, Object>(2);
-                key.put("OrderId", -10);
-                key.put("ProductId", -10);
-                final ODataEntity orderLine = client.getRetrieveRequestFactory().getEntityRequest(
-                        client.getURIBuilder(testActionOverloadingServiceRootURL).
-                        appendEntityTypeSegment("OrderLine").appendKeySegment(key).build()).
-                        execute().getBody();
-                assertNotNull(orderLine);
-
-                res = client.getInvokeRequestFactory().<ODataProperty>getInvokeRequest(
-                        orderLine.getOperation("RetrieveProduct").getTarget(), metadata, funcImp).execute();
-            } else {
-                res = null;
-            }
-
-            assertNotNull(res);
-            assertEquals(200, res.getStatusCode());
-            assertEquals(Integer.valueOf(-10), res.getBody().getPrimitiveValue().<Integer>toCastValue());
-            execs++;
-        }
-        assertEquals(3, execs);
-    }
-
-    @Test
-    public void increaseSalaries() {
-        final EdmV3Metadata metadata =
-                client.getRetrieveRequestFactory().getMetadataRequest(testActionOverloadingServiceRootURL).execute().
-                getBody();
-        assertNotNull(metadata);
-
-        final EntityContainer container = metadata.getSchema(0).getEntityContainers().get(0);
-        assertNotNull(container);
-
-        int execs = 0;
-        for (FunctionImport funcImp : container.getFunctionImports("IncreaseSalaries")) {
-            final Map<String, ODataValue> parameters = new LinkedHashMap<String, ODataValue>(1);
-            parameters.put("n",
-                    client.getPrimitiveValueBuilder().setType(EdmSimpleType.Int32).setValue(5).build());
-
-            final ODataInvokeResponse<ODataNoContent> res;
-            if ("Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.Employee)".
-                    equals(funcImp.getParameters().get(0).getType())) {
-
-                final URIBuilder builder = client.getURIBuilder(testActionOverloadingServiceRootURL).
-                        appendEntitySetSegment("Person").
-                        appendStructuralSegment("Microsoft.Test.OData.Services.AstoriaDefaultService.Employee");
-
-                final ODataEntitySet employees = client.getRetrieveRequestFactory().getEntitySetRequest(
-                        builder.build()).execute().getBody();
-                assertNotNull(employees);
-
-                res = client.getInvokeRequestFactory().<ODataNoContent>getInvokeRequest(
-                        builder.appendFunctionImportSegment(funcImp.getName()).build(), metadata, funcImp, parameters).
-                        execute();
-            } else if ("Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee)".
-                    equals(funcImp.getParameters().get(0).getType())) {
-
-                final URIBuilder builder = client.getURIBuilder(testActionOverloadingServiceRootURL).
-                        appendEntitySetSegment("Person").
-                        appendStructuralSegment("Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee");
-
-                final ODataEntitySet specialEmployees = client.getRetrieveRequestFactory().getEntitySetRequest(
-                        builder.build()).execute().getBody();
-                assertNotNull(specialEmployees);
-
-                res = client.getInvokeRequestFactory().<ODataNoContent>getInvokeRequest(
-                        builder.appendFunctionImportSegment(funcImp.getName()).build(), metadata, funcImp, parameters).
-                        execute();
-            } else {
-                res = null;
-            }
-
-            assertNotNull(res);
-            assertEquals(204, res.getStatusCode());
-            execs++;
-        }
-        assertEquals(2, execs);
-    }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AsyncTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AsyncTestITCase.java
deleted file mode 100644
index f2df3f1..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AsyncTestITCase.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
-
-import com.msopentech.odatajclient.engine.communication.request.UpdateType;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataEntityUpdateRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataMediaRequest;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataMediaEntityCreateRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityUpdateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataMediaEntityCreateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.data.ODataEntitySet;
-import com.msopentech.odatajclient.engine.data.ODataPrimitiveValue;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-
-public class AsyncTestITCase extends AbstractTestITCase {
-
-    @Test
-    public void retrieveEntitySet() throws InterruptedException, ExecutionException {
-        final URIBuilder uriBuilder = client.getURIBuilder(testDefaultServiceRootURL).
-                appendEntitySetSegment("Product");
-        final Future<ODataRetrieveResponse<ODataEntitySet>> futureRes =
-                client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).asyncExecute();
-        assertNotNull(futureRes);
-
-        while (!futureRes.isDone()) {
-        }
-
-        final ODataRetrieveResponse<ODataEntitySet> res = futureRes.get();
-        assertNotNull(res);
-        assertEquals(200, res.getStatusCode());
-        assertFalse(res.getBody().getEntities().isEmpty());
-    }
-
-    @Test
-    public void updateEntity() throws InterruptedException, ExecutionException {
-        final URI uri = client.getURIBuilder(testDefaultServiceRootURL).
-                appendEntityTypeSegment("Product").appendKeySegment(-10).build();
-
-        final ODataRetrieveResponse<ODataEntity> entityRes = client.getRetrieveRequestFactory().
-                getEntityRequest(uri).execute();
-        final ODataEntity entity = entityRes.getBody();
-        entity.getAssociationLinks().clear();
-        entity.getNavigationLinks().clear();
-        entity.getEditMediaLinks().clear();
-        entity.getProperty("Description").setValue(
-                client.getPrimitiveValueBuilder().setText("AsyncTest#updateEntity").build());
-
-        final ODataEntityUpdateRequest updateReq =
-                client.getCUDRequestFactory().getEntityUpdateRequest(uri, UpdateType.MERGE, entity);
-        updateReq.setIfMatch(entityRes.getEtag());
-        final Future<ODataEntityUpdateResponse> futureRes = updateReq.asyncExecute();
-
-        while (!futureRes.isDone()) {
-        }
-
-        final ODataEntityUpdateResponse res = futureRes.get();
-        assertNotNull(res);
-        assertEquals(204, res.getStatusCode());
-    }
-
-    /**
-     * @see MediaEntityTest#createMediaEntity(com.msopentech.odatajclient.engine.format.ODataPubFormat)
-     */
-    @Test
-    public void createMediaEntity() throws InterruptedException, ExecutionException, IOException {
-        URIBuilder builder = client.getURIBuilder(testDefaultServiceRootURL).appendEntitySetSegment("Car");
-
-        final String TO_BE_UPDATED = "async buffered stream sample";
-        final InputStream input = IOUtils.toInputStream(TO_BE_UPDATED);
-
-        final ODataMediaEntityCreateRequest createReq =
-                client.getStreamedRequestFactory().getMediaEntityCreateRequest(builder.build(), input);
-
-        final ODataMediaEntityCreateRequest.MediaEntityCreateStreamManager streamManager = createReq.execute();
-        final Future<ODataMediaEntityCreateResponse> futureCreateRes = streamManager.getAsyncResponse();
-
-        while (!futureCreateRes.isDone()) {
-        }
-        final ODataMediaEntityCreateResponse createRes = futureCreateRes.get();
-
-        assertEquals(201, createRes.getStatusCode());
-
-        final ODataEntity created = createRes.getBody();
-        assertNotNull(created);
-        assertEquals(2, created.getProperties().size());
-
-        final int id = "VIN".equals(created.getProperties().get(0).getName())
-                ? created.getProperties().get(0).getPrimitiveValue().<Integer>toCastValue()
-                : created.getProperties().get(1).getPrimitiveValue().<Integer>toCastValue();
-
-        builder = client.getURIBuilder(testDefaultServiceRootURL).
-                appendEntityTypeSegment("Car").appendKeySegment(id).appendValueSegment();
-
-        final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
-
-        final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
-        assertEquals(200, retrieveRes.getStatusCode());
-        assertEquals(TO_BE_UPDATED, IOUtils.toString(retrieveRes.getBody()));
-    }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AuthEntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AuthEntityRetrieveTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AuthEntityRetrieveTestITCase.java
deleted file mode 100644
index 0a99553..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/AuthEntityRetrieveTestITCase.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.msopentech.odatajclient.engine.it;
-
-import com.msopentech.odatajclient.engine.client.http.AbstractBasicAuthHttpClientFactory;
-import com.msopentech.odatajclient.engine.client.http.DefaultHttpClientFactory;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class AuthEntityRetrieveTestITCase extends EntityRetrieveTestITCase {
-
-    @BeforeClass
-    public static void enableBasicAuth() {
-        client.getConfiguration().setHttpClientFactory(new AbstractBasicAuthHttpClientFactory() {
-
-            @Override
-            protected String getUsername() {
-                return "odatajclient";
-            }
-
-            @Override
-            protected String getPassword() {
-                return "odatajclient";
-            }
-        });
-    }
-
-    @AfterClass
-    public static void disableBasicAuth() {
-        client.getConfiguration().setHttpClientFactory(new DefaultHttpClientFactory());
-    }
-
-    @Override
-    protected String getServiceRoot() {
-        return testAuthServiceRootURL;
-    }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/BatchTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/BatchTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/BatchTestITCase.java
deleted file mode 100644
index f099dfb..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/BatchTestITCase.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-
-import com.msopentech.odatajclient.engine.communication.request.batch.ODataBatchRequest;
-import com.msopentech.odatajclient.engine.communication.request.batch.ODataBatchRequest.BatchStreamManager;
-import com.msopentech.odatajclient.engine.communication.request.ODataStreamManager;
-import com.msopentech.odatajclient.engine.communication.request.UpdateType;
-import com.msopentech.odatajclient.engine.communication.request.batch.ODataBatchResponseItem;
-import com.msopentech.odatajclient.engine.communication.request.batch.ODataChangeset;
-import com.msopentech.odatajclient.engine.communication.request.batch.ODataChangesetResponseItem;
-import com.msopentech.odatajclient.engine.communication.request.batch.ODataRetrieve;
-import com.msopentech.odatajclient.engine.communication.request.batch.ODataRetrieveResponseItem;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataEntityCreateRequest;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataEntityUpdateRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntityRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntityRequest.ODataEntityResponseImpl;
-import org.junit.Test;
-import com.msopentech.odatajclient.engine.communication.response.ODataBatchResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityCreateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityUpdateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataResponse;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.data.ODataObjectFactory;
-import com.msopentech.odatajclient.engine.data.ODataPrimitiveValue;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import com.msopentech.odatajclient.engine.utils.ODataBatchConstants;
-import com.msopentech.odatajclient.engine.utils.URIUtils;
-import com.msopentech.odatajclient.engine.utils.Wrapper;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import org.apache.http.HttpResponse;
-
-public class BatchTestITCase extends AbstractTestITCase {
-
-    private static String PREFIX = "!!PREFIX!!";
-
-    private static String SUFFIX = "!!SUFFIX!!";
-
-    private static int MAX = 10000;
-
-    @Test
-    public void stringStreaming() {
-        final TestStreamManager streaming = new TestStreamManager();
-
-        new StreamingThread(streaming).start();
-
-        streaming.addObject((PREFIX + "\n").getBytes());
-
-        for (int i = 0; i <= MAX; i++) {
-            streaming.addObject((i + ") send info\n").getBytes());
-        }
-
-        streaming.addObject((SUFFIX).getBytes());
-        streaming.finalizeBody();
-    }
-
-    @Test
-    public void emptyBatchRequest() {
-        // create your request
-        final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testDefaultServiceRootURL);
-
-        final BatchStreamManager payload = request.execute();
-        final ODataBatchResponse response = payload.getResponse();
-
-        assertEquals(202, response.getStatusCode());
-        assertEquals("Accepted", response.getStatusMessage());
-
-        final Iterator<ODataBatchResponseItem> iter = response.getBody();
-        assertFalse(iter.hasNext());
-    }
-
-    @Test
-    public void changesetWithError() {
-        // create your request
-        final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testDefaultServiceRootURL);
-
-        final BatchStreamManager payload = request.execute();
-        final ODataChangeset changeset = payload.addChangeset();
-
-        URIBuilder targetURI;
-        ODataEntityCreateRequest create;
-
-        targetURI = client.getURIBuilder(testDefaultServiceRootURL).appendEntitySetSegment("Customer");
-        for (int i = 1; i <= 2; i++) {
-            // Create Customer into the changeset
-            create = client.getCUDRequestFactory().getEntityCreateRequest(
-                    targetURI.build(),
-                    getSampleCustomerProfile(100 + i, "Sample customer", false));
-            create.setFormat(ODataPubFormat.JSON);
-            changeset.addRequest(create);
-        }
-
-        targetURI = client.getURIBuilder(testDefaultServiceRootURL).appendEntitySetSegment("WrongEntitySet");
-        create = client.getCUDRequestFactory().getEntityCreateRequest(
-                targetURI.build(),
-                getSampleCustomerProfile(105, "Sample customer", false));
-        create.setFormat(ODataPubFormat.JSON);
-        changeset.addRequest(create);
-
-        targetURI = client.getURIBuilder(testDefaultServiceRootURL).appendEntitySetSegment("Customer");
-        for (int i = 3; i <= 4; i++) {
-            // Create Customer into the changeset
-            create = client.getCUDRequestFactory().getEntityCreateRequest(
-                    targetURI.build(),
-                    getSampleCustomerProfile(100 + i, "Sample customer", false));
-            create.setFormat(ODataPubFormat.ATOM);
-            changeset.addRequest(create);
-        }
-
-        final ODataBatchResponse response = payload.getResponse();
-        assertEquals(202, response.getStatusCode());
-        assertEquals("Accepted", response.getStatusMessage());
-
-        final Iterator<ODataBatchResponseItem> iter = response.getBody();
-        final ODataChangesetResponseItem chgResponseItem = (ODataChangesetResponseItem) iter.next();
-
-        final ODataResponse res = chgResponseItem.next();
-        assertEquals(404, res.getStatusCode());
-        assertEquals("Not Found", res.getStatusMessage());
-        assertEquals(Integer.valueOf(3), Integer.valueOf(
-                res.getHeader(ODataBatchConstants.CHANGESET_CONTENT_ID_NAME).iterator().next()));
-        assertFalse(chgResponseItem.hasNext());
-    }
-
-    @Test
-    public void changesetWithReference() {
-        // create your request
-        final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testDefaultServiceRootURL);
-        final BatchStreamManager streamManager = request.execute();
-
-        final ODataChangeset changeset = streamManager.addChangeset();
-        ODataEntity customer = getSampleCustomerProfile(20, "sample customer", false);
-
-        URIBuilder uriBuilder = client.getURIBuilder(testAuthServiceRootURL).appendEntitySetSegment("Customer");
-
-        // add create request
-        final ODataEntityCreateRequest createReq =
-                client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), customer);
-
-        changeset.addRequest(createReq);
-
-        // retrieve request reference
-        int createRequestRef = changeset.getLastContentId();
-
-        // add update request: link CustomerInfo(17) to the new customer
-        final ODataEntity customerChanges = client.getObjectFactory().newEntity(customer.getName());
-        customerChanges.addLink(client.getObjectFactory().newEntityNavigationLink(
-                "Info",
-                client.getURIBuilder(testAuthServiceRootURL).appendEntitySetSegment("CustomerInfo").
-                appendKeySegment(17).build()));
-
-        final ODataEntityUpdateRequest updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(
-                URI.create("$" + createRequestRef), UpdateType.PATCH, customerChanges);
-
-        changeset.addRequest(updateReq);
-
-        final ODataBatchResponse response = streamManager.getResponse();
-        assertEquals(202, response.getStatusCode());
-        assertEquals("Accepted", response.getStatusMessage());
-
-        // verify response payload ...
-        final Iterator<ODataBatchResponseItem> iter = response.getBody();
-
-        final ODataBatchResponseItem item = iter.next();
-        assertTrue(item instanceof ODataChangesetResponseItem);
-
-        final ODataChangesetResponseItem chgitem = (ODataChangesetResponseItem) item;
-
-        ODataResponse res = chgitem.next();
-        assertEquals(201, res.getStatusCode());
-        assertTrue(res instanceof ODataEntityCreateResponse);
-
-        customer = ((ODataEntityCreateResponse) res).getBody();
-
-        ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(
-                URIUtils.getURI(testDefaultServiceRootURL, customer.getEditLink().toASCIIString() + "/Info"));
-
-        assertEquals(Integer.valueOf(17),
-                req.execute().getBody().getProperty("CustomerInfoId").getPrimitiveValue().<Integer>toCastValue());
-
-        res = chgitem.next();
-        assertEquals(204, res.getStatusCode());
-        assertTrue(res instanceof ODataEntityUpdateResponse);
-
-        // clean ...
-        assertEquals(204, client.getCUDRequestFactory().getDeleteRequest(
-                URIUtils.getURI(testDefaultServiceRootURL, customer.getEditLink().toASCIIString())).execute().
-                getStatusCode());
-
-        try {
-            client.getRetrieveRequestFactory().getEntityRequest(
-                    URIUtils.getURI(testDefaultServiceRootURL, customer.getEditLink().toASCIIString())).
-                    execute().getBody();
-            fail();
-        } catch (Exception e) {
-            // ignore
-        }
-    }
-
-    @Test
-    public void batchRequest() {
-        // create your request
-        final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testDefaultServiceRootURL);
-
-        final BatchStreamManager streamManager = request.execute();
-
-        // -------------------------------------------
-        // Add retrieve item
-        // -------------------------------------------
-        ODataRetrieve retrieve = streamManager.addRetrieve();
-
-        // prepare URI
-        URIBuilder targetURI = client.getURIBuilder(testDefaultServiceRootURL);
-        targetURI.appendEntityTypeSegment("Customer").appendKeySegment(-10).
-                expand("Logins").select("CustomerId,Logins/Username");
-
-        // create new request
-        ODataEntityRequest query = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
-        query.setFormat(ODataPubFormat.ATOM);
-
-        retrieve.setRequest(query);
-        // -------------------------------------------
-
-        // -------------------------------------------
-        // Add changeset item
-        // -------------------------------------------
-        final ODataChangeset changeset = streamManager.addChangeset();
-
-        // Update Product into the changeset
-        targetURI = client.getURIBuilder(testDefaultServiceRootURL).
-                appendEntityTypeSegment("Product").appendKeySegment(-10);
-        final URI editLink = targetURI.build();
-
-        final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
-        merge.setEditLink(editLink);
-
-        merge.addProperty(client.getObjectFactory().newPrimitiveProperty(
-                "Description", client.getPrimitiveValueBuilder().setText("new description from batch").build()));
-
-        final ODataEntityUpdateRequest changes =
-                client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.MERGE, merge);
-        changes.setFormat(ODataPubFormat.JSON_FULL_METADATA);
-        changes.setIfMatch(getETag(editLink));
-
-        changeset.addRequest(changes);
-
-        // Create Customer into the changeset
-        targetURI = client.getURIBuilder(testDefaultServiceRootURL).appendEntitySetSegment("Customer");
-        final ODataEntity original = getSampleCustomerProfile(1000, "Sample customer", false);
-        final ODataEntityCreateRequest create =
-                client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
-        create.setFormat(ODataPubFormat.ATOM);
-        changeset.addRequest(create);
-        // -------------------------------------------
-
-        // -------------------------------------------
-        // Add retrieve item
-        // -------------------------------------------
-        retrieve = streamManager.addRetrieve();
-
-        // prepare URI
-        targetURI = client.getURIBuilder(testDefaultServiceRootURL).
-                appendEntityTypeSegment("Product").appendKeySegment(-10);
-
-        // create new request
-        query = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
-
-        retrieve.setRequest(query);
-        // -------------------------------------------
-
-        final ODataBatchResponse response = streamManager.getResponse();
-        assertEquals(202, response.getStatusCode());
-        assertEquals("Accepted", response.getStatusMessage());
-
-        final Iterator<ODataBatchResponseItem> iter = response.getBody();
-
-        // retrive the first item (ODataRetrieve)
-        ODataBatchResponseItem item = iter.next();
-        assertTrue(item instanceof ODataRetrieveResponseItem);
-
-        ODataRetrieveResponseItem retitem = (ODataRetrieveResponseItem) item;
-        ODataResponse res = retitem.next();
-        assertTrue(res instanceof ODataEntityResponseImpl);
-        assertEquals(200, res.getStatusCode());
-        assertEquals("OK", res.getStatusMessage());
-
-        ODataEntityResponseImpl entres = (ODataEntityResponseImpl) res;
-        ODataEntity entity = entres.getBody();
-        assertEquals(new Integer(-10), entity.getProperty("CustomerId").getPrimitiveValue().<Integer>toCastValue());
-
-        // retrieve the second item (ODataChangeset)
-        item = iter.next();
-        assertTrue(item instanceof ODataChangesetResponseItem);
-
-        final ODataChangesetResponseItem chgitem = (ODataChangesetResponseItem) item;
-        res = chgitem.next();
-        assertTrue(res instanceof ODataEntityUpdateResponse);
-        assertEquals(204, res.getStatusCode());
-        assertEquals("No Content", res.getStatusMessage());
-
-        res = chgitem.next();
-        assertTrue(res instanceof ODataEntityCreateResponse);
-        assertEquals(201, res.getStatusCode());
-        assertEquals("Created", res.getStatusMessage());
-
-        final ODataEntityCreateResponse createres = (ODataEntityCreateResponse) res;
-        entity = createres.getBody();
-        assertEquals(new Integer(1000), entity.getProperty("CustomerId").getPrimitiveValue().<Integer>toCastValue());
-
-        // retrive the third item (ODataRetrieve)
-        item = iter.next();
-        assertTrue(item instanceof ODataRetrieveResponseItem);
-
-        retitem = (ODataRetrieveResponseItem) item;
-        res = retitem.next();
-        assertTrue(res instanceof ODataEntityResponseImpl);
-        assertEquals(200, res.getStatusCode());
-        assertEquals("OK", res.getStatusMessage());
-
-        entres = (ODataEntityResponseImpl) res;
-        entity = entres.getBody();
-        assertEquals("new description from batch",
-                entity.getProperty("Description").getPrimitiveValue().<String>toCastValue());
-
-        assertFalse(iter.hasNext());
-    }
-
-    private static class TestStreamManager extends ODataStreamManager<ODataBatchResponse> {
-
-        public TestStreamManager() {
-            super(new Wrapper<Future<HttpResponse>>());
-        }
-
-        public ODataStreamManager<ODataBatchResponse> addObject(byte[] src) {
-            stream(src);
-            return this;
-        }
-
-        @Override
-        protected ODataBatchResponse getResponse(long timeout, TimeUnit unit) {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-    };
-
-    /**
-     * To be used for debug purposes.
-     */
-    private static class StreamingThread extends Thread {
-
-        private final TestStreamManager streaming;
-
-        public StreamingThread(final TestStreamManager streaming) {
-            this.streaming = streaming;
-        }
-
-        @Override
-        public void run() {
-            try {
-                final StringBuilder builder = new StringBuilder();
-
-                byte[] buff = new byte[1024];
-
-                int len;
-
-                while ((len = streaming.getBody().read(buff)) >= 0) {
-                    builder.append(new String(buff, 0, len));
-                }
-
-                assertTrue(builder.toString().startsWith(PREFIX));
-                assertTrue(builder.toString().contains((MAX / 2) + ") send info"));
-                assertTrue(builder.toString().contains((MAX / 3) + ") send info"));
-                assertTrue(builder.toString().contains((MAX / 20) + ") send info"));
-                assertTrue(builder.toString().contains((MAX / 30) + ") send info"));
-                assertTrue(builder.toString().contains(MAX + ") send info"));
-                assertTrue(builder.toString().endsWith(SUFFIX));
-
-            } catch (IOException e) {
-                fail();
-            }
-        }
-    }
-
-    private static class BatchStreamingThread extends Thread {
-
-        private final BatchStreamManager streaming;
-
-        public BatchStreamingThread(final BatchStreamManager streaming) {
-            this.streaming = streaming;
-        }
-
-        @Override
-        public void run() {
-            try {
-                final StringBuilder builder = new StringBuilder();
-
-                byte[] buff = new byte[1024];
-
-                int len;
-
-                while ((len = streaming.getBody().read(buff)) >= 0) {
-                    builder.append(new String(buff, 0, len));
-                }
-
-                LOG.debug("Batch request {}", builder.toString());
-
-                assertTrue(builder.toString().contains("Content-Id:2"));
-                assertTrue(builder.toString().contains("GET " + servicesODataServiceRootURL));
-            } catch (IOException e) {
-                fail();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/CountTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/CountTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/CountTestITCase.java
deleted file mode 100644
index 3c1f9c4..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/CountTestITCase.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-import com.msopentech.odatajclient.engine.communication.ODataClientErrorException;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataValueRequest;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.data.ODataValue;
-import com.msopentech.odatajclient.engine.format.ODataValueFormat;
-
-public class CountTestITCase extends AbstractTestITCase {
-    //counts the total number of customers
-
-    @Test
-    public void entityCount() {
-        URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-                appendEntityTypeSegment("Customer").appendCountSegment();
-        final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
-        req.setFormat(ODataValueFormat.TEXT);
-        try {
-            final ODataValue value = req.execute().getBody();
-            assertTrue(10 <= Integer.parseInt(value.toString()));
-        } catch (ODataClientErrorException e) {
-            LOG.error("Error code: {}", e.getStatusLine().getStatusCode(), e);
-        }
-    }
-    //returns 415 error for invalid header.
-
-    @Test
-    public void invalidAccept() {
-        final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
-                appendEntityTypeSegment("Customer").appendCountSegment();
-        final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
-        req.setFormat(ODataValueFormat.TEXT);
-        req.setAccept("application/json;odata=fullmetadata");
-        try {
-            final ODataValue value = req.execute().getBody();
-            fail();
-        } catch (ODataClientErrorException e) {
-            assertEquals(415, e.getStatusLine().getStatusCode());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/CreateMediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/CreateMediaEntityTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/CreateMediaEntityTestITCase.java
deleted file mode 100644
index a291efe..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/CreateMediaEntityTestITCase.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
-import com.msopentech.odatajclient.engine.communication.request.UpdateType;
-import com.msopentech.odatajclient.engine.communication.request.cud.CUDRequestFactory;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataDeleteRequest;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataEntityUpdateRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntityRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataMediaRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.RetrieveRequestFactory;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataMediaEntityCreateRequest;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataMediaEntityCreateRequest.MediaEntityCreateStreamManager;
-import com.msopentech.odatajclient.engine.communication.request.streamed.StreamedRequestFactory;
-import com.msopentech.odatajclient.engine.communication.response.ODataDeleteResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityUpdateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataMediaEntityCreateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.data.ODataObjectFactory;
-import com.msopentech.odatajclient.engine.data.ODataPrimitiveValue;
-import com.msopentech.odatajclient.engine.data.ODataProperty;
-import com.msopentech.odatajclient.engine.metadata.edm.EdmSimpleType;
-import com.msopentech.odatajclient.engine.format.ODataMediaFormat;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import org.apache.commons.io.input.BoundedInputStream;
-
-public class CreateMediaEntityTestITCase extends AbstractTestITCase {
-
-    // create media entity with json
-    @Test
-    public void createMediaWithJSON() {
-        ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
-        String contentType = "application/json;odata=fullmetadata";
-        String prefer = "return-content";
-        String fileType = "/images/image1.jpg";
-        try {
-            createMediaEntity(format, contentType, prefer, fileType);
-        } catch (IOException e) {
-            fail(e.getMessage());
-        }
-    }
-    // with png image
-
-    @Test
-    public void createMediaWithJSONAndPng() {
-        ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
-        String contentType = "application/json;odata=fullmetadata";
-        String prefer = "return-content";
-        String fileType = "/images/image1.png";
-        try {
-            createMediaEntity(format, contentType, prefer, fileType);
-        } catch (IOException e) {
-            fail(e.getMessage());
-        }
-    }
-    // with a long image
-
-    @Test
-    public void createMediaWithJSONBigImage() {
-        ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
-        String contentType = "application/json;odata=fullmetadata";
-        String prefer = "return-content";
-        String fileType = "/images/Renault.jpg";
-        try {
-            createMediaEntity(format, contentType, prefer, fileType);
-        } catch (IOException e) {
-            fail(e.getMessage());
-        }
-    }
-    // create media entity with json no metadata.
-
-    @Test
-    public void createMediaWithJSONNoMetadata() {
-        ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
-        String contentType = "application/json;odata=nometadata";
-        String prefer = "return-content";
-        String fileType = "/images/image1.jpg";
-        try {
-            createMediaEntity(format, contentType, prefer, fileType);
-        } catch (IOException e) {
-            LOG.error("", e);
-            fail(e.getMessage());
-        }
-    }
-    // with JSON minimal meta data
-
-    @Test
-    public void createMediaWithJSONMinimalMetadata() {
-        ODataPubFormat format = ODataPubFormat.JSON;
-        String contentType = "application/json";
-        String prefer = "return-content";
-        String fileType = "/images/image1.jpg";
-        try {
-            createMediaEntity(format, contentType, prefer, fileType);
-        } catch (IOException e) {
-            LOG.error("", e);
-            fail(e.getMessage());
-        }
-    }
-    // create media with atom 
-
-    @Test
-    public void createMediaWithATOM() {
-        ODataPubFormat format = ODataPubFormat.ATOM;
-        String contentType = "application/atom+xml";
-        String prefer = "return-content";
-        String fileType = "/images/image1.png";
-        try {
-            createMediaEntity(format, contentType, prefer, fileType);
-        } catch (IOException e) {
-            LOG.error("", e);
-            fail(e.getMessage());
-        }
-    }
-    // create video with atom
-
-    @Test
-    public void createVideoWithATOM() {
-        ODataPubFormat format = ODataPubFormat.ATOM;
-        String contentType = "application/atom+xml";
-        String prefer = "return-content";
-        String fileType = "/images/big_buck_bunny.mp4";
-        try {
-            createMediaEntity(format, contentType, prefer, fileType);
-        } catch (IOException e) {
-            LOG.error("", e);
-            fail(e.getMessage());
-        }
-    }
-    // create video with json
-
-    @Test
-    public void createVideoWithJSON() {
-        ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
-        String contentType = "application/json;odata=fullmetadata";
-        String prefer = "return-content";
-        String fileType = "/images/big_buck_bunny.mp4";
-        try {
-            createMediaEntity(format, contentType, prefer, fileType);
-        } catch (IOException e) {
-            LOG.error("", e);
-            fail(e.getMessage());
-        }
-    }
-    // code to create a media entity. 
-    // Step 1 - POST an entity
-    // Step 2 - PUT other properties in that entity.
-
-    private void createMediaEntity(final ODataPubFormat format, final String contentType, final String prefer,
-            final String file) throws IOException {
-
-        try {
-            final URIBuilder uriBuilder = client.getURIBuilder(testDefaultServiceRootURL).
-                    appendEntitySetSegment("Car");
-
-            // The sample service has an upload request size of 65k
-            final InputStream inputStream = new BoundedInputStream(getClass().getResourceAsStream(file), 65000);
-
-            final ODataMediaEntityCreateRequest createReq =
-                    client.getStreamedRequestFactory().getMediaEntityCreateRequest(uriBuilder.build(), inputStream);
-            createReq.setFormat(format);
-            createReq.setContentType(contentType);
-            createReq.setPrefer(prefer);
-            final MediaEntityCreateStreamManager streamManager = createReq.execute();
-            final ODataMediaEntityCreateResponse createRes = streamManager.getResponse();
-            if (prefer.equals("return-content")) {
-                assertEquals(201, createRes.getStatusCode());
-
-                final ODataEntity createdEntity = createRes.getBody();
-                assertNotNull(createdEntity);
-                assertEquals(2, createdEntity.getProperties().size());
-                // get the vin property of the entity created
-                final int id = "VIN".equals(createdEntity.getProperties().get(0).getName())
-                        ? createdEntity.getProperties().get(0).getPrimitiveValue().<Integer>toCastValue()
-                        : createdEntity.getProperties().get(1).getPrimitiveValue().<Integer>toCastValue();
-                uriBuilder.appendKeySegment(id).appendValueSegment();
-                // get the stream value that got created  
-                final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(uriBuilder.build());
-                retrieveReq.setFormat(ODataMediaFormat.WILDCARD);
-                final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
-                assertEquals(200, retrieveRes.getStatusCode());
-                assertNotNull(retrieveRes.getBody());
-                String etag = retrieveRes.getEtag();
-                // get the entity created 
-                final ODataEntity entity =
-                        client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Car");
-
-                final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(client.getURIBuilder(
-                        testDefaultServiceRootURL).
-                        appendEntityTypeSegment("Car").appendKeySegment(id).build());
-                req.setFormat(format);
-
-                final ODataRetrieveResponse<ODataEntity> res = req.execute();
-                final ODataEntity entityToBeUpdated = res.getBody();
-                assertNotNull(entity);
-                String propertyName = "Description";
-                final String newValue = "New renault car - " + propertyName;
-
-                ODataProperty propertyValue = entityToBeUpdated.getProperty(propertyName);
-
-                if (propertyValue != null) {
-                    entityToBeUpdated.removeProperty(propertyValue);
-                }
-                // add new value for the property
-                entityToBeUpdated.addProperty(client.getObjectFactory().newPrimitiveProperty(propertyName,
-                        client.getPrimitiveValueBuilder().setText(newValue).setType(EdmSimpleType.String).build()));
-
-                UpdateType type = UpdateType.REPLACE;
-                // update the entity in the server
-                ODataEntityUpdateRequest updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(type,
-                        entityToBeUpdated);
-                req.setFormat(format);
-                if (StringUtils.isNotBlank(etag)) {
-                    req.setIfMatch(etag);
-                }
-                ODataEntityUpdateResponse updateRes = updateReq.execute();
-                assertEquals(204, updateRes.getStatusCode());
-
-                final ODataEntityRequest afterUpdateReq = client.getRetrieveRequestFactory().getEntityRequest(
-                        client.getURIBuilder(testDefaultServiceRootURL).
-                        appendEntityTypeSegment("Car").appendKeySegment(id).build());
-
-                req.setFormat(format);
-                //assert whether the original value is equal to the actual value that got updated.
-                final ODataRetrieveResponse<ODataEntity> afterUpdateRes = afterUpdateReq.execute();
-                final ODataEntity entityAfterUpdate = afterUpdateRes.getBody();
-                assertEquals(newValue, entityAfterUpdate.getProperty("Description").getValue().toString());
-
-                // delete the entity
-                URIBuilder deleteUriBuilder = client.getURIBuilder(testDefaultServiceRootURL).
-                        appendEntityTypeSegment("Car(" + id + ")");
-                ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(deleteUriBuilder.build());
-                deleteReq.setFormat(format);
-                deleteReq.setContentType(contentType);
-                ODataDeleteResponse deleteRes = deleteReq.execute();
-                assertEquals(204, deleteRes.getStatusCode());
-            } else {
-                assertEquals(204, createRes.getStatusCode());
-            }
-        } catch (Exception e) {
-            if ((format.equals(ODataPubFormat.JSON) || (format.equals(ODataPubFormat.JSON_NO_METADATA)) && e.
-                    getMessage().equals("No edit link found"))) {
-                assertTrue(true);
-            } else {
-                fail(e.getMessage());
-            }
-        } catch (AssertionError e) {
-            fail(e.getMessage());
-        }
-    }
-}


Mime
View raw message