olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kobl...@apache.org
Subject git commit: [OLINGO-413] refactor testcases
Date Fri, 22 Aug 2014 14:10:54 GMT
Repository: olingo-odata4-js
Updated Branches:
  refs/heads/master a0d101793 -> 7cbe0da42


[OLINGO-413] refactor testcases


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

Branch: refs/heads/master
Commit: 7cbe0da429512c9407944ae95ef8edc6bdb55792
Parents: a0d1017
Author: Sven Kobler <sven.kobler-morris@sap.com>
Authored: Fri Aug 22 16:10:23 2014 +0200
Committer: Sven Kobler <sven.kobler-morris@sap.com>
Committed: Fri Aug 22 16:10:23 2014 +0200

----------------------------------------------------------------------
 datajs/tests-tmp/common/cacheVerifier.js        | 241 +++++++++++++++++++
 datajs/tests-tmp/common/djstest-browser.js      |   7 +-
 datajs/tests-tmp/common/observableHttpClient.js |  84 +++++++
 ...cache-large-collection-functional-tests.html |  53 ++++
 ...s-cache-large-collection-functional-tests.js | 187 ++++++++++++++
 datajs/tests-tmp/done.txt                       |  12 +-
 ...cache-large-collection-functional-tests.html |   3 +-
 ...s-cache-large-collection-functional-tests.js |   2 +-
 8 files changed, 578 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/7cbe0da4/datajs/tests-tmp/common/cacheVerifier.js
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/common/cacheVerifier.js b/datajs/tests-tmp/common/cacheVerifier.js
new file mode 100644
index 0000000..d34d79f
--- /dev/null
+++ b/datajs/tests-tmp/common/cacheVerifier.js
@@ -0,0 +1,241 @@
+/*
+ * 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.
+ */
+
+// CacheOracle.js
+// This object verifies the operation of the cache.
+// Internally it maintains a simple model of the cache implemented using a lookup array of
the expected cached pages.
+
+(function (window, undefined) {
+
+    var CacheOracle = function (baseUri, pageSize, total, cacheSize) {
+        /** Creates a new CacheOracle
+         * @param {String} baseUri - The base URI of the collection
+         * @param {Integer} pageSize - The page size used in the cache
+         * @param {Integer} total - The total number of items in the collection
+         * @param {Integer} cacheSize - Cache size in bytes
+         */
+        this.baseUri = baseUri;
+        this.pageSize = pageSize;
+        this.total = total;
+        this.cacheSize = (cacheSize !== undefined) ? cacheSize : 1024 * 1024;
+        this.actualSize = 0;
+        this.actualCount = 0;
+        this.cachedPages = [];
+        this.exactPageCount = (total % pageSize === 0);
+        this.maxPage = Math.floor(total / pageSize);
+        this.overflowed = this.cacheSize === 0;
+    };
+
+    CacheOracle.mechanisms = {
+        memory: "memory",
+        indexeddb: "indexeddb",
+        dom: "dom",
+        best: "best"
+    };
+
+    CacheOracle.isMechanismAvailable = function (mechanism) {
+        /** Determines if the specified local storage mechanism is available
+         * @param mechanism - The name of the mechanism
+         * @returns Whether the mechanism is available
+         */
+        switch (mechanism) {
+            case CacheOracle.mechanisms.indexeddb:
+                if (window.msIndexedDB || window.mozIndexedDB || window.webkitIndexedDB ||
window.indexedDB) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+                break;
+            case CacheOracle.mechanisms.dom:
+                if (window.localStorage) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+                break;
+            case CacheOracle.mechanisms.memory:
+            case CacheOracle.mechanisms.best:
+            case undefined:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    CacheOracle.prototype.clear = function () {
+        /** Clears the cache in the oracle
+        */
+        this.cachedPages = [];
+        this.actualSize = 0;
+        this.actualCount = 0;
+        this.overflowed = this.cacheSize === 0;
+    }
+
+    CacheOracle.prototype.verifyRequests = function (requests, responses, index, count, description,
backwards, isPrefetch) {
+        /** Verifies the HTTP requests for a single data request, and updates the oracle
with cached pages
+         * @param {Array} requests - The sequence of request objects (from OData.defaultHttpClient)
+         * @param {Array} responses - The sequence of response objects (from OData.defaultHttpClient)
+         * @param {Integer} index - The starting index of the read
+         * @param {Integer} count - The count of items in the read
+         * @param {String} description - The description of the requests being verified
+         * @param {Boolean} backwards - Whether or not filterBack is being verified
+         * @param {Boolean} isPrefetch - Whether the requests being verified come from the
prefetcher
+         */
+        var that = this;
+
+        index = (index < 0 ? 0 : index);
+        var pageIndex = function (index) {
+            /** Returns the page index that the given item index belongs to
+             * @param {Integer} index - The item index
+             * @returns The page index
+             */
+            return Math.floor(index / that.pageSize);
+        };
+
+        var estimateSize = function (obj) {
+            /** Estimates the size of an object in bytes.
+             * @param {Object} obj - Object to determine the size of.
+             * @returns {Number} Estimated size of the object in bytes.
+             */
+
+            var size = 0;
+            var type = typeof obj;
+
+            if (type === "object" && obj) {
+                for (var name in obj) {
+                    size += name.length * 2 + estimateSize(obj[name]);
+                }
+            } else if (type === "string") {
+                size = obj.length * 2;
+            } else {
+                size = 8;
+            }
+            return size;
+        };
+
+        var expectedUris = [];
+        var responseIndex = 0;
+        if (count >= 0) {
+            var minPage = pageIndex(index);
+            var maxPage = Math.min(pageIndex(index + count - 1), pageIndex(this.total));
+
+            // In the case that the index is outside the range of the collection the minPage
will be greater than the maxPage  
+            maxPage = Math.max(minPage, maxPage);
+
+            if (!(isPrefetch && !this.exactPageCount && minPage > this.maxPage))
{
+                for (var page = minPage; page <= maxPage && this.actualCount <=
this.total && !(isPrefetch && this.overflowed); page++) {
+                    if (!this.cachedPages[page]) {
+
+                        expectedUris.push(that.baseUri + "?$skip=" + page * this.pageSize
+ "&$top=" + (this.pageSize));
+
+                        var actualPageSize = 0;
+                        var actualPageCount = 0;
+                        if (responses[responseIndex] && responses[responseIndex].data)
{
+                            actualPageSize += estimateSize(responses[responseIndex].data);
+                            actualPageCount += responses[responseIndex].data.value.length;
+                            // Handle server paging skipToken requests
+                            while (responses[responseIndex].data["@odata.nextLink"]) {
+                                var nextLink = responses[responseIndex].data["@odata.nextLink"];
+                                if (nextLink) {
+                                    var index = that.baseUri.indexOf(".svc/", 0);
+                                    if (index != -1) {
+                                        nextLink = that.baseUri.substring(0, index + 5) +
nextLink;
+                                    }
+                                }
+
+                                expectedUris.push(nextLink);
+                                responseIndex++;
+                                actualPageSize += estimateSize(responses[responseIndex].data);
+                                actualPageCount += responses[responseIndex].data.value.length;
+                            }
+
+                            actualPageSize += 24; // 24 byte overhead for the pages (i)ndex,
and (c)ount fields
+                        }
+
+                        responseIndex++;
+
+                        this.overflowed = this.cacheSize >= 0 && this.actualSize
+ actualPageSize > this.cacheSize;
+                        if (!this.overflowed) {
+                            this.cachedPages[page] = true;
+                            this.actualSize += actualPageSize;
+                            this.actualCount += actualPageCount;
+                        }
+                    }
+                }
+            }
+        }
+
+        if (backwards) {
+            expectedUris.reverse();
+        }
+
+        var actualUris = $.map(requests, function (r) { return r.requestUri; });
+        djstest.assertAreEqualDeep(actualUris, expectedUris, description);
+    };
+
+    CacheOracle.getExpectedFilterResults = function (data, filterIndex, filterCount, predicate,
backwards) {
+        /** Verifies the cache filter returns the correct data
+         * @param {Array} collection - Array of items in the collection
+         * @param {Integer} filterIndex - The index value
+         * @param {Integer} filterCount - The count value
+         * @param {Function} predicate - Predicate to be applied in filter, takes an item
+         * @param {Boolean} backwards - Whether or not filterBackwards is being verified
+         */
+        if (!data || !data.value) {
+            return data;
+        }
+
+        var value = [];
+        if (filterCount !== 0) {
+            // Convert [item0, item1, ...] into [{ index: 0, item: item0 }, { index: 1, item:
item1 }, ...]
+            var indexedCollection = $.map(data.value, function (item, index) {
+                return { index: index, item: item };
+            });
+
+            var grepPredicate = function (element, index) {
+                return predicate(element.item);
+            };
+
+            var index = filterIndex < 0 ? 0 : filterIndex;
+            var count = filterCount < 0 ? indexedCollection.length : filterCount;
+
+            value = backwards ?
+            // Slice up to 'index', filter, then slice 'count' number of items from the end
+                $.grep(indexedCollection.slice(0, index + 1), grepPredicate).slice(-count)
:
+            // Slice from 'index' to the end, filter, then slice 'count' number of items
from the beginning
+                $.grep(indexedCollection.slice(index), grepPredicate).slice(0, count);
+        }
+
+        var expectedResults = {};
+        for (var property in data) {
+            if (property == "value") {
+                expectedResults[property] = value;
+            } else {
+                expectedResults[property] = data[property];
+            }
+        }
+
+        return expectedResults;
+    };
+
+    window.CacheOracle = CacheOracle;
+
+})(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/7cbe0da4/datajs/tests-tmp/common/djstest-browser.js
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/common/djstest-browser.js b/datajs/tests-tmp/common/djstest-browser.js
index 9bd0f45..14e5401 100644
--- a/datajs/tests-tmp/common/djstest-browser.js
+++ b/datajs/tests-tmp/common/djstest-browser.js
@@ -35,11 +35,8 @@ if (typeof window !== 'undefined') {
 }
 
 
-function init (window) {
-    var djstest = window.djstest;
-    if (!djstest) { 
-        djstest = window.djstest = {};
-    }
+function init (parent) {
+    djstest = parent || {};
 
     // Initialize indexedDB if the window object is available
     djstest.indexedDB = window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB
|| window.indexedDB;

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/7cbe0da4/datajs/tests-tmp/common/observableHttpClient.js
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/common/observableHttpClient.js b/datajs/tests-tmp/common/observableHttpClient.js
new file mode 100644
index 0000000..9be75f8
--- /dev/null
+++ b/datajs/tests-tmp/common/observableHttpClient.js
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+// ObservableHttpClient.js
+// This object extends OData's default httpClient by supporting request and response recording
sessions, and firing a custom
+// JQuery event for each request/response.
+//
+// The events fired by this object are:
+//      request: Before a request is made
+//      success: Before the primary success handler is called
+//
+// To bind to an event, JQuery event attachers can be used on the object, e.g.
+//      $(observableHttpClient).bind("request", function (request) { ... });
+//
+// To begin a new recording session, use:
+//      var session = observableHttpClient.newSession();
+//
+// Requests and responses are then recorded in session.requests and session.responses. Session
can be ended by session.end().
+// Multiple simultaneous sessions are supported.
+
+(function (window, undefined) {
+
+    var ObservableHttpClient = function (provider) {
+        this.provider = provider ? provider : window.odatajs.oData.net.defaultHttpClient;
+    };
+
+    ObservableHttpClient.prototype.newSession = function () {
+        return new Session(this);
+    };
+
+    ObservableHttpClient.prototype.request = function (request, success, error) {
+        var that = this;
+
+        $(this).triggerHandler("request", request);
+        return this.provider.request(request, function (response) {
+            $(that).triggerHandler("success", response);
+            success(response);
+        }, error);
+    };
+
+
+    var Session = function (client) {
+        var that = this;
+
+        this.client = client;
+        this.clear();
+
+        this.requestHandler = function (event, request) { that.requests.push(request); };
+        $(client).bind("request", this.requestHandler);
+
+        this.successHandler = function (event, response) { that.responses.push(response);
};
+        $(client).bind("success", this.successHandler);
+    };
+
+    Session.prototype.clear = function () {
+        this.requests = [];
+        this.responses = [];
+    }
+
+    Session.prototype.end = function () {
+        $(this.client).unbind("request", this.requestHandler);
+        $(this.client).unbind("success", this.successHandler);
+    };
+
+    window.ObservableHttpClient = ObservableHttpClient;
+    window.Session = Session;
+
+})(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/7cbe0da4/datajs/tests-tmp/datajs-cache-large-collection-functional-tests.html
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/datajs-cache-large-collection-functional-tests.html b/datajs/tests-tmp/datajs-cache-large-collection-functional-tests.html
new file mode 100644
index 0000000..dd8550c
--- /dev/null
+++ b/datajs/tests-tmp/datajs-cache-large-collection-functional-tests.html
@@ -0,0 +1,53 @@
+<!--
+/*
+ * 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.
+ */
+ -->
+<html>
+<head>
+    <title>datajs.cache and datajs.store full local store tests</title>
+    <meta http-equiv="cache-control" content="no-cache"/> 
+    <meta http-equiv="pragma" content="no-cache"/> 
+    <meta http-equiv="expires" content="-1"/> 
+
+    <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.10.0.css" type="text/css"
/>
+    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script>
+    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
+    <script type="text/javascript" src="http://code.jquery.com/qunit/qunit-1.10.0.js"></script>
+    <!--<script type="text/javascript" src="common/TestSynchronizerClient.js"></script>-->
+    <!--<script type="text/javascript">
+        window.TestSynchronizer.init(QUnit);
+    </script>-->
+    <script type="text/javascript" src="../build/datajs-2.0.0.js"></script> 
 
+    <!--<script type="text/javascript" src="common/common.js"></script>-->
+
+    <script type="text/javascript" src="common/djstest.js"></script>
+    <script type="text/javascript" src="common/djstest-browser.js"></script>
+    <script type="text/javascript" src="common/cacheVerifier.js"></script>
+    <script type="text/javascript" src="common/observableHttpClient.js"></script>
+    <!--<script type="text/javascript" src="common/ODataReadOracle.js"></script>-->
+    
+    <script type="text/javascript" src="datajs-cache-large-collection-functional-tests.js"></script>
 
+</head>
+<body>
+ <h1 id="qunit-header">datajs.cache and datajs.store full local store tests</h1>
+ <h2 id="qunit-banner"></h2>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/7cbe0da4/datajs/tests-tmp/datajs-cache-large-collection-functional-tests.js
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/datajs-cache-large-collection-functional-tests.js b/datajs/tests-tmp/datajs-cache-large-collection-functional-tests.js
new file mode 100644
index 0000000..557510e
--- /dev/null
+++ b/datajs/tests-tmp/datajs-cache-large-collection-functional-tests.js
@@ -0,0 +1,187 @@
+/*
+ * 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.
+ */
+
+(function (window, undefined) {
+    window.odatajs.oData.defaultHandler.accept = "application/json;q=0.9, */*;q=0.1";
+    var largeCollectionFeed = "./endpoints/LargeCollectionService.svc/Customers";
+    var itemsInCollection = 2 * 1024 * 1024;
+
+    var cleanDomStorage = function (done) {
+        /* Cleans all the data saved in the browser's DOM Storage. Needs to be called asynchronously
in the 
+         *  setup and teardown methods to be consistent with indexedDb's cleanup method.
+         * @param {Function} done - Function to be called after DOM storage is cleared.
+         */
+        if (window.localStorage) {
+            window.localStorage.clear();
+        }
+        done();
+    };
+
+    var cleanIndexedDb = function (done) {
+        /** Cleans all the data saved in the browser's IndexedDb Storage.
+         * @param {Function} done - Function to be called after DOM storage is cleared.
+         */
+        var caches = this.caches;
+
+        djstest.cleanStoreOnIndexedDb(caches, done);
+    };
+
+    var makeUnexpectedErrorHandler = function () {
+        return function (err) {
+            djstest.assert(false, "Unexpected call to error handler with error: " + djstest.toString(err));
+        };
+    };
+
+    var storageMechanisms = {
+        indexeddb: { cleanup: cleanIndexedDb },
+        dom: { cleanup: cleanDomStorage }
+    };
+
+    var cleanupAllStorage = function(done) {
+        /** Cleans up all available storage mechanisms in the browser.
+         * @param {Function} done - Function to be called by each cleanup function after
storage is cleared.
+         */
+        var that = this;
+        var storeCleanup = [];
+
+        $.each(CacheOracle.mechanisms, function(_, mechanism) {
+            if (CacheOracle.isMechanismAvailable(mechanism)) {
+                storeCleanup.push(function(done) {
+                    if (storageMechanisms[mechanism]) {
+                        storageMechanisms[mechanism].cleanup.call(that, done);
+                    } else {
+                        done();
+                    }
+                });
+            }
+        });
+
+        djstest.asyncDo(storeCleanup, done);
+    };
+
+
+    module("Functional", {
+        setup: function () {
+            this.observableHttpClient = new ObservableHttpClient();
+            window.odatajs.oData.net.defaultHttpClient = this.observableHttpClient;
+            this.caches = [];
+            var that = this;
+
+            djstest.wait(function (done) {
+                cleanupAllStorage.call(that, done);
+            });
+        },
+
+        teardown: function () {
+            window.odatajs.oData.net.defaultHttpClient = this.observableHttpClient.provider;
+            var clearActions = [];
+            var that = this;
+
+            $.each(this.caches, function (_, cacheObject) {
+                cacheObject.cache.onidle = undefined;
+
+                clearActions.push(function (done) {
+                    cacheObject.cache.clear().then(function () {
+                        done();
+                    },
+                        function (err) {
+                            djstest.assert(false, "Unexpected call to error handler while
attempting to clear with error: " + djstest.toString(err));
+                        });
+                });
+            });
+
+            djstest.wait(function (done) {
+                djstest.asyncDo(clearActions, function () {
+                    cleanupAllStorage.call(that, function () {
+                        that.caches = [];
+                        done();
+                    });
+                });
+            });
+        }
+    });
+
+    $.each(["dom", "indexeddb"], function (_, mechanism) {
+        if (CacheOracle.isMechanismAvailable(mechanism)) {
+            $.each([-1, 10 * 1024 * 1024, 1024 * 10248], function (_, cacheSize) {
+                var prefetchParameters = { mechanism: mechanism, feed: largeCollectionFeed,
skip: 0, take: 5, pageSize: 1024, prefetchSize: -1, cacheSize: cacheSize };
+                djstest.addTest(function (params) {
+
+                    djstest.assertsExpected(3);
+                    var options = { name: "cache" + new Date().valueOf(), source: params.feed,
pageSize: params.pageSize, prefetchSize: params.prefetchSize,
+                        mechanism: params.mechanism, cacheSize: params.cacheSize
+                    };
+
+                    var cache = odatajs.cache.createDataCache(options);
+                    this.caches.push({ name: options.name,
+                        cache: cache
+                    });
+
+                    cache.onidle = function () {
+                        djstest.assert(true, "onidle Called");
+                        djstest.done();
+                    };
+
+                    var cacheOracle = new CacheOracle(params.feed, params.pageSize, itemsInCollection);
+                    var session = this.observableHttpClient.newSession();
+
+                    cache.readRange(params.skip, params.take).then(function (data) {
+                        var expectedRangeUrl = params.feed + "?$skip=" + params.skip + "&$top="
+ params.take;
+                        cacheOracle.verifyRequests(session.requests, session.responses, params.skip,
params.take, "largeCollection requests with prefetch", false, true);
+                        window.ODataReadOracle.readJsonAcrossServerPages(expectedRangeUrl,
function (expectedData) {
+                            djstest.assertAreEqualDeep(data, expectedData, "Verify response
data");
+                        });
+                    }, function (err) {
+                        makeUnexpectedErrorHandler(err)();
+                    });
+                }, "readRange and prefetch all to fill store on " + prefetchParameters.mechanism
+ " with cacheSize=" + prefetchParameters.cacheSize, prefetchParameters, 600000);
+
+                $.each([500, 1024 * 10 /*Test reduced from 100 to 10 to work around slow
running script error in IE8 and Safari (bug 2200)*/], function (_, pageSize) {
+                    var largeReadParameters = { mechanism: mechanism, feed: largeCollectionFeed,
skip: 0, take: 1024, pageSize: pageSize, prefetchSize: 0, cacheSize: cacheSize };
+                    djstest.addTest(function (params) {
+
+                        djstest.assertsExpected(2);
+                        var options = { name: "cache" + new Date().valueOf(), source: params.feed,
pageSize: params.pageSize, prefetchSize: params.prefetchSize,
+                            mechanism: params.mechanism, cacheSize: params.cacheSize
+                        };
+
+                        var cache = odatajs.cache.createDataCache(options);
+                        this.caches.push({ name: options.name, cache: cache });
+
+                        var cacheOracle = new CacheOracle(params.feed, params.pageSize, itemsInCollection);
+                        var session = this.observableHttpClient.newSession();
+
+                        cache.readRange(params.skip, params.take).then(function (data) {
+                            var expectedRangeUrl = params.feed + "?$skip=" + params.skip
+ "&$top=" + params.take;
+                            cacheOracle.verifyRequests(session.requests, session.responses,
params.skip, params.take, "largeCollection requests without prefetch", false, false);
+                            window.ODataReadOracle.readJsonAcrossServerPages(expectedRangeUrl,
function (expectedData) {
+                                djstest.assertAreEqualDeep(data, expectedData, "Verify response
data");
+                                djstest.done();
+                            });
+                        }, function (err) {
+                            makeUnexpectedErrorHandler(err)();
+                            djstest.done();
+                        });
+                    }, "readRange of skip=" + largeReadParameters.skip + " take=" + largeReadParameters.take
+ " cacheSize=" + largeReadParameters.cacheSize + " and pageSize=" + largeReadParameters.pageSize
+
+                        " to fill store on " + largeReadParameters.mechanism, largeReadParameters,
600000);
+                });
+            });
+        }
+    });
+})(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/7cbe0da4/datajs/tests-tmp/done.txt
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/done.txt b/datajs/tests-tmp/done.txt
index b313ca7..23bffc3 100644
--- a/datajs/tests-tmp/done.txt
+++ b/datajs/tests-tmp/done.txt
@@ -7,13 +7,17 @@ The plan is to
 
 DONE
 
-TestSynchronizerClient.js removed
+TestSynchronizerClient.js 
+  -> removed
   -> Moved from custom c# logging service to jenkins
 
-ODataReadOracle.js removed
+ODataReadOracle.js 
+  -> removed
   -> TODO check dependencies
 
-rx.js removed
+rx.js 
+  -> removed
   -> TODO check dependencies
 
-odata-json-test.js copied and splittet 
\ No newline at end of file
+odata-json-test.js 
+  -> copied and splittet 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/7cbe0da4/datajs/tests/datajs-cache-large-collection-functional-tests.html
----------------------------------------------------------------------
diff --git a/datajs/tests/datajs-cache-large-collection-functional-tests.html b/datajs/tests/datajs-cache-large-collection-functional-tests.html
index d0a298d..f17d59b 100644
--- a/datajs/tests/datajs-cache-large-collection-functional-tests.html
+++ b/datajs/tests/datajs-cache-large-collection-functional-tests.html
@@ -34,9 +34,10 @@
         window.TestSynchronizer.init(QUnit);
     </script>
     <script type="text/javascript" src="../build/datajs-2.0.0.js"></script> 
 
-    <script type="text/javascript" src="common/common.js"></script>
+    <!--<script type="text/javascript" src="common/common.js"></script>-->
 
     <script type="text/javascript" src="common/djstest.js"></script>
+    <script type="text/javascript" src="common/djstest-browser.js"></script>
     <script type="text/javascript" src="common/CacheOracle.js"></script>
     <script type="text/javascript" src="common/ObservableHttpClient.js"></script>
     <script type="text/javascript" src="common/ODataReadOracle.js"></script>

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/7cbe0da4/datajs/tests/datajs-cache-large-collection-functional-tests.js
----------------------------------------------------------------------
diff --git a/datajs/tests/datajs-cache-large-collection-functional-tests.js b/datajs/tests/datajs-cache-large-collection-functional-tests.js
index ef52307..557510e 100644
--- a/datajs/tests/datajs-cache-large-collection-functional-tests.js
+++ b/datajs/tests/datajs-cache-large-collection-functional-tests.js
@@ -18,7 +18,7 @@
  */
 
 (function (window, undefined) {
-    OData.defaultHandler.accept = "application/json;q=0.9, */*;q=0.1";
+    window.odatajs.oData.defaultHandler.accept = "application/json;q=0.9, */*;q=0.1";
     var largeCollectionFeed = "./endpoints/LargeCollectionService.svc/Customers";
     var itemsInCollection = 2 * 1024 * 1024;
 


Mime
View raw message