You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by bi...@apache.org on 2014/05/16 04:26:39 UTC
[11/11] git commit: [OLINGO-289] Upgrade the datajs version to 1.1.3
and check in some missing test cases
[OLINGO-289] Upgrade the datajs version to 1.1.3 and check in some missing test cases
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/commit/ebfc5869
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/tree/ebfc5869
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/diff/ebfc5869
Branch: refs/heads/master
Commit: ebfc58690c1004365b907fadb0747478efb53469
Parents: 9aa185d
Author: Bing Li <bi...@apache.org>
Authored: Fri May 16 10:16:12 2014 +0800
Committer: Bing Li <bi...@apache.org>
Committed: Fri May 16 10:16:12 2014 +0800
----------------------------------------------------------------------
JSLib/tests/common/TestSynchronizerClient.js | 8 +-
JSLib/tests/common/cacheoracle.js | 128 ++++++++++++++++++----
JSLib/tests/common/djstest.js | 2 +-
JSLib/tests/odata-atom-tests.js | 2 +-
JSLib/tests/odata-qunit-tests.htm | 15 +++
JSLib/tests/run-tests.wsf | 15 +++
JSLib/tests/test-list.js | 13 +++
7 files changed, 159 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/blob/ebfc5869/JSLib/tests/common/TestSynchronizerClient.js
----------------------------------------------------------------------
diff --git a/JSLib/tests/common/TestSynchronizerClient.js b/JSLib/tests/common/TestSynchronizerClient.js
index c758413..f83ebd2 100644
--- a/JSLib/tests/common/TestSynchronizerClient.js
+++ b/JSLib/tests/common/TestSynchronizerClient.js
@@ -207,6 +207,12 @@
nextUrl = JSON.parse(nextUrl).d;
if (nextUrl) {
window.location.href = nextUrl;
+ // MISSING CODEPLEX CODE STARTS
+ } else if (window.jscoverage_report) {
+ // Generate code coverage reports if it is enabled
+ // See http://siliconforks.com/jscoverage/manual.html for more information
+ jscoverage_report();
+ // MISSING CODEPLEX CODE STOPS
}
}
}
@@ -215,4 +221,4 @@
window.TestSynchronizer = {
init: init
};
-})(window);
\ No newline at end of file
+})(window);
http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/blob/ebfc5869/JSLib/tests/common/cacheoracle.js
----------------------------------------------------------------------
diff --git a/JSLib/tests/common/cacheoracle.js b/JSLib/tests/common/cacheoracle.js
index 59a695b..66d55aa 100644
--- a/JSLib/tests/common/cacheoracle.js
+++ b/JSLib/tests/common/cacheoracle.js
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
@@ -17,16 +17,22 @@
(function (window, undefined) {
- var CacheOracle = function (baseUri, pageSize, total) {
+ var CacheOracle = function (baseUri, pageSize, total, cacheSize) {
/// <summary>Creates a new CacheOracle</summary>
/// <param name="baseUri" type="String">The base URI of the collection</param>
/// <param name="pageSize" type="Integer">The page size used in the cache</param>
/// <param name="total" type="Integer">The total number of items in the collection</param>
+ /// <param name="cacheSize" type="Integer">Cache size in bytes</param>
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 = {
@@ -42,7 +48,7 @@
/// <returns>Whether the mechanism is available</returns>
switch (mechanism) {
case CacheOracle.mechanisms.indexeddb:
- if (window.mozIndexedDB) {
+ if (window.msIndexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.indexedDB) {
return true;
}
else {
@@ -69,51 +75,131 @@
CacheOracle.prototype.clear = function () {
/// <summary>Clears the cache in the oracle</summary>
this.cachedPages = [];
+ this.actualSize = 0;
+ this.actualCount = 0;
+ this.overflowed = this.cacheSize === 0;
}
- CacheOracle.prototype.verifyRequests = function (requests, responses, index, count, description) {
+ CacheOracle.prototype.verifyRequests = function (requests, responses, index, count, description, backwards, isPrefetch) {
/// <summary>Verifies the HTTP requests for a single data request, and updates the oracle with cached pages</summary>
/// <param name="requests" type="Array">The sequence of request objects (from OData.defaultHttpClient)</param>
/// <param name="responses" type="Array">The sequence of response objects (from OData.defaultHttpClient)</param>
/// <param name="index" type="Integer">The starting index of the read</param>
/// <param name="count" type="Integer">The count of items in the read</param>
/// <param name="description" type="String">The description of the requests being verified</param>
+ /// <param name="backwards" type="Boolean">Whether or not filterBack is being verified</param>
+ /// <param name="isPrefetch" type="Boolean">Whether the requests being verified come from the prefetcher</param>
var that = this;
+ index = (index < 0 ? 0 : index);
var pageIndex = function (index) {
/// <summary>Returns the page index that the given item index belongs to</summary>
/// <param name="index" type="Integer">The item index</param>
/// <returns>The page index</returns>
return Math.floor(index / that.pageSize);
- }
+ };
+
+ var estimateSize = function (obj) {
+ /// <summary>Estimates the size of an object in bytes.</summary>
+ /// <param name="obj" type="Object">Object to determine the size of.</param>
+ /// <returns type="Number">Estimated size of the object in bytes.</returns>
- var minPage = pageIndex(index);
- var maxPage = Math.min(pageIndex(index + count - 1), pageIndex(that.total));
+ var size = 0;
+ var type = typeof obj;
- // Workaround for Bug 2055: Calling readRange with count = 0 still fires a single HTTP request
- maxPage = Math.max(minPage, maxPage);
+ 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;
- for (var page = minPage; page <= maxPage; page++) {
- if (!this.cachedPages[page]) {
- expectedUris.push(that.baseUri + "?$skip=" + page * that.pageSize + "&$top=" + (that.pageSize));
-
- // Handle server paging skipToken requests
- while (responses[responseIndex] && responses[responseIndex].data && responses[responseIndex].data.__next) {
- expectedUris.push(responses[responseIndex].data.__next);
- responseIndex++;
+ 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.results);
+ actualPageCount += responses[responseIndex].data.results.length;
+ // Handle server paging skipToken requests
+ while (responses[responseIndex].data.__next) {
+ expectedUris.push(responses[responseIndex].data.__next);
+ responseIndex++;
+ actualPageSize += estimateSize(responses[responseIndex].data.results);
+ actualPageCount += responses[responseIndex].data.results.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;
+ }
+ }
}
-
- responseIndex++;
- this.cachedPages[page] = true;
}
}
+ if (backwards) {
+ expectedUris.reverse();
+ }
+
var actualUris = $.map(requests, function (r) { return r.requestUri; });
djstest.assertAreEqualDeep(actualUris, expectedUris, description);
};
+ CacheOracle.getExpectedFilterResults = function (collection, filterIndex, filterCount, predicate, backwards) {
+ /// <summary>Verifies the cache filter returns the correct data</summary>
+ /// <param name="collection" type="Array">Array of items in the collection</param>
+ /// <param name="filterIndex" type="Integer">The index value</param>
+ /// <param name="filterCount" type="Integer">The count value</param>
+ /// <param name="predicate" type="Function">Predicate to be applied in filter, takes an item</param>
+ /// <param name="backwards" type="Boolean">Whether or not filterBackwards is being verified</param>
+ var expectedResults = [];
+ if (filterCount !== 0) {
+ // Convert [item0, item1, ...] into [{ index: 0, item: item0 }, { index: 1, item: item1 }, ...]
+ var indexedCollection = $.map(collection, 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;
+
+ var expectedResults = 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);
+ }
+
+ return expectedResults;
+ };
+
window.CacheOracle = CacheOracle;
})(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/blob/ebfc5869/JSLib/tests/common/djstest.js
----------------------------------------------------------------------
diff --git a/JSLib/tests/common/djstest.js b/JSLib/tests/common/djstest.js
index c7b2de5..c871088 100644
--- a/JSLib/tests/common/djstest.js
+++ b/JSLib/tests/common/djstest.js
@@ -397,4 +397,4 @@
djstest.done();
}
});
-})(window);
\ No newline at end of file
+})(window);
http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/blob/ebfc5869/JSLib/tests/odata-atom-tests.js
----------------------------------------------------------------------
diff --git a/JSLib/tests/odata-atom-tests.js b/JSLib/tests/odata-atom-tests.js
index 52c0c94..70a8cd9 100644
--- a/JSLib/tests/odata-atom-tests.js
+++ b/JSLib/tests/odata-atom-tests.js
@@ -4753,4 +4753,4 @@
});
// DATAJS INTERNAL END
-})(this);
\ No newline at end of file
+})(this);
http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/blob/ebfc5869/JSLib/tests/odata-qunit-tests.htm
----------------------------------------------------------------------
diff --git a/JSLib/tests/odata-qunit-tests.htm b/JSLib/tests/odata-qunit-tests.htm
index 7f3248d..47b63a1 100644
--- a/JSLib/tests/odata-qunit-tests.htm
+++ b/JSLib/tests/odata-qunit-tests.htm
@@ -35,6 +35,7 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEAL
<script type="text/javascript" src="common/ODataReadOracle.js"></script>
<script type="text/javascript" src="common/TestSynchronizerClient.js"></script>
+ <script type="text/javascript" src="common/rx.js"></script>
<script type="text/javascript">
window.TestSynchronizer.init(QUnit);
@@ -65,10 +66,24 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEAL
<script type="text/javascript" src="../src/cache-source.js"></script>
<script type="text/javascript" src="../src/cache.js"></script>
+ <script type="text/javascript" src="common/mockHttpClient.js"></script>
+ <script type="text/javascript" src="common/mockXMLHttpRequest.js"></script>
<script type="text/javascript" src="common/djstest.js"></script>
+ <script type="text/javascript" src="common/CacheOracle.js"></script>
+ <script type="text/javascript" src="odata-tests.js"></script>
<script type="text/javascript" src="odata-atom-tests.js"></script>
+ <script type="text/javascript" src="odata-json-tests.js"></script>
+ <script type="text/javascript" src="odata-json-light-tests.js"></script>
+ <script type="text/javascript" src="odata-metadata-tests.js"></script>
+ <script type="text/javascript" src="odata-xml-tests.js"></script>
+ <script type="text/javascript" src="odata-handler-tests.js"></script>
+ <script type="text/javascript" src="odata-net-tests.js"></script>
+ <script type="text/javascript" src="odata-batch-tests.js"></script>
+ <script type="text/javascript" src="cache-tests.js"></script>
+ <script type="text/javascript" src="store-tests.js"></script>
+ <script type="text/javascript" src="store-indexeddb-tests.js"></script>
</head>
<body>
<h1 id="qunit-header">OData Unit Tests</h1>
http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/blob/ebfc5869/JSLib/tests/run-tests.wsf
----------------------------------------------------------------------
diff --git a/JSLib/tests/run-tests.wsf b/JSLib/tests/run-tests.wsf
index 26d954d..0174c9e 100644
--- a/JSLib/tests/run-tests.wsf
+++ b/JSLib/tests/run-tests.wsf
@@ -19,6 +19,16 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEAL
1 - failed to launch tests
2 - tests failed
</comment>
+ <!-- MISSING CODEPLEX CODE STARTS -->
+ <named name="testFiles" helpstring="Comma-separated list of HTML test files to run"
+ type="string" required="false" />
+ <named name="browsers" helpstring="Comma-separated list of browsers to run on" type="string"
+ required="false" />
+ <named name="timeout" helpstring="Timeout (in seconds) for each browser" type="string"
+ required="false" />
+ <named name="reinstallWCFDataServices" helpstring="If specified WCF Data Services will be reinstalled"
+ type="boolean" required="false" />
+ <!-- MISSING CODEPLEX CODE STOPS -->
</runtime>
<script language="JScript" src="test-list.js" />
<script language="JScript">
@@ -393,6 +403,11 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEAL
result = shell.ExpandEnvironmentStrings("%DJSOUT%\\JSLib.sln\\tests");
}
+ // MISSING CODEPLEX CODE STARTS
+ if (result === "%DJSOUT%\\JSLib.sln\\tests") {
+ result = shell.ExpandEnvironmentStrings("%_nttree%\\DataJS\\JSLib.sln\\tests");
+ }
+ // MISSING CODEPLEX CODE STOPS
return result;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata3-js/blob/ebfc5869/JSLib/tests/test-list.js
----------------------------------------------------------------------
diff --git a/JSLib/tests/test-list.js b/JSLib/tests/test-list.js
index 3a805d1..a0cbd49 100644
--- a/JSLib/tests/test-list.js
+++ b/JSLib/tests/test-list.js
@@ -15,6 +15,19 @@
function getAllTestFiles() {
return [
+// MISSING CODEPLEX CODE STARTS
+ "odata-batch-functional-tests.html",
+ "odata-metadata-awareness-functional-tests.html",
+ "odata-read-functional-tests.html",
+ "odata-request-functional-tests.html",
+ "odata-links-functional-tests.html",
+ "odata-cache-functional-tests.html",
+ "odata-cache-filter-functional-tests.html",
+ "odata-cache-fperf-tests.html",
+ "odata-cache-rx-functional-tests.html",
+ "odata-read-crossdomain-functional-tests.html",
+ "datajs-cache-large-collection-functional-tests.html",
+// MISSING CODEPLEX CODE STOPS
"odata-qunit-tests.htm"
];
}
\ No newline at end of file