You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ko...@apache.org on 2014/08/20 13:42:28 UTC

[1/3] git commit: [OLINGO-408] add and fix comments

Repository: olingo-odata4-js
Updated Branches:
  refs/heads/master 5c98f9f3e -> caa44a31a


[OLINGO-408] add and fix comments


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/256d1f2d
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/tree/256d1f2d
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/diff/256d1f2d

Branch: refs/heads/master
Commit: 256d1f2d88cc929f65200725f889000085d2a2d9
Parents: 5c98f9f
Author: Sven Kobler <sv...@sap.com>
Authored: Wed Aug 20 10:25:14 2014 +0200
Committer: Sven Kobler <sv...@sap.com>
Committed: Wed Aug 20 10:25:33 2014 +0200

----------------------------------------------------------------------
 datajs/Gruntfile.js               |  63 +++++-
 datajs/grunt-config/rat-config.js |   2 +-
 datajs/package.json               |   1 +
 datajs/src/lib/odata.js           |   2 +-
 datajs/tests/common/djstest.js    | 401 +++++++++++++++++++--------------
 5 files changed, 284 insertions(+), 185 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/256d1f2d/datajs/Gruntfile.js
----------------------------------------------------------------------
diff --git a/datajs/Gruntfile.js b/datajs/Gruntfile.js
index 0a2ac06..7d967e5 100644
--- a/datajs/Gruntfile.js
+++ b/datajs/Gruntfile.js
@@ -5,7 +5,6 @@ module.exports = function(grunt) {
     banner: grunt.file.read('src/banner.txt'),
     filename : '<%= pkg.name %>-<%= pkg.version %>',
 
-
     browserify: {
       // start with index.js and follow all required source in order pack them together 
       datajs: {
@@ -123,27 +122,51 @@ module.exports = function(grunt) {
       },
     },
     jsdoc : {
-        dist : {
+        src : {
             src: ['src/**/*.js'], 
             options: {
                 destination: 'build/doc',
                 verbose : false 
             }
+        },
+        test : {
+            src: ['tests/**/*.js'], 
+            options: {
+                destination: 'build/doc-test',
+                verbose : false 
+            }
         }
+    },
+    "npm-clean": {
+      tmp: {
+        src: [ "build/tmp"]
+      },
+      doc: {
+        src: ["build/doc"],
+          options: {
+                force: true
+            }
+      },
+      "doc-test": {
+        src: ["build/doc-test"],
+          options: {
+                force: true
+            }
+      },
     }
   };
   
-  //join local configuration for proxies and local test servers
+  /*** Join local configuration for proxies and local test servers ***/
   if (grunt.file.exists('localgrunt.config')) {
     console.log("merge localgrunt.config");
     var localGrundConfig = grunt.file.read('localgrunt.config');
     init.connect['test-browser'].proxies = init.connect['test-browser'].proxies.concat(JSON.parse(localGrundConfig).proxies);
   }
 
-
+  /*** Init ***/
   grunt.initConfig(init);
 
-  // These plugins provide necessary tasks.
+  /*** Load tasks from npm modules ***/
   grunt.loadNpmTasks('grunt-browserify');
   grunt.loadNpmTasks('grunt-contrib-uglify');
   grunt.loadNpmTasks("grunt-connect-proxy");
@@ -151,21 +174,37 @@ module.exports = function(grunt) {
   grunt.loadNpmTasks("grunt-contrib-copy");
   grunt.loadNpmTasks("grunt-contrib-concat");
   grunt.loadNpmTasks("grunt-jsdoc");
-  grunt.loadNpmTasks('grunt-node-qunit');/*TODO replace by grunt contrib-qunit*/
 
-  //load the task from the grunt-config directory
-  //these are rat, 
+  //    Start Qunit tests direcly in node js, internally qunit (npm qunit) 
+  //    is used, no phantomjs instance required
+  grunt.loadNpmTasks('grunt-node-qunit'); 
+  grunt.loadNpmTasks('grunt-contrib-clean');
+
+  //    Load the custom-* tasks from the grunt-config directory
   grunt.loadTasks('grunt-config');
+
+  //    rename some tasks to avoid name clashes with the user tasks
+  grunt.renameTask('clean','npm-clean');
   
 
-  grunt.registerTask('doc', ['jsdoc']);
+  /*** E N D U S E R   T A S K S ***/
+
+  grunt.registerTask('clean', ['npm-clean:doc','npm-clean:tmp']);
+
+  //    Runs the license header check to verify the any source file contains a license header
+  grunt.registerTask('license-check', ['custom-license-check']);
+
+  //    Create documentation in /build/doc
+  grunt.registerTask('doc', [/*'npm-clean:doc',*/'jsdoc:src']);
+  grunt.registerTask('doc-test', [/*'npm-clean:doc-test',*/'jsdoc:test']);
+
+  //    Build the odatajs library
   grunt.registerTask('build', ['browserify:datajs', 'uglify:build', 'concat','copy:forDemo']);
+
+
   grunt.registerTask('test-browser', ['configureProxies:test-browser', 'connect:test-browser']);
   grunt.registerTask('test-node', ['node-qunit:default-tests']);
 
-
-  //This task runs the Apache Relase Autit Tool (RAT)
-  //grunt.registerTask('rat', ['shell:rat'/*,'rat-check:rat'*/]);
   
 };
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/256d1f2d/datajs/grunt-config/rat-config.js
----------------------------------------------------------------------
diff --git a/datajs/grunt-config/rat-config.js b/datajs/grunt-config/rat-config.js
index 019192b..06f5b7d 100644
--- a/datajs/grunt-config/rat-config.js
+++ b/datajs/grunt-config/rat-config.js
@@ -11,5 +11,5 @@ module.exports = function(grunt) {
 
  
   grunt.loadTasks('grunt-config/custom-tasks/rat/tasks');
-  grunt.registerTask('license',['rat:src','rat:test']);
+  grunt.registerTask('custom-license-check',['rat:src','rat:test']);
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/256d1f2d/datajs/package.json
----------------------------------------------------------------------
diff --git a/datajs/package.json b/datajs/package.json
index 32ae996..1e939a6 100644
--- a/datajs/package.json
+++ b/datajs/package.json
@@ -27,6 +27,7 @@
     "grunt": "^0.4.5",
     "grunt-browserify": "^2.1.0",
     "grunt-connect-proxy": "^0.1.10",
+    "grunt-contrib-clean": "^0.6.0",
     "grunt-contrib-concat": "^0.5.0",
     "grunt-contrib-connect": "^0.7.1",
     "grunt-contrib-copy": "^0.5.0",

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/256d1f2d/datajs/src/lib/odata.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/odata.js b/datajs/src/lib/odata.js
index d971025..0249aa3 100644
--- a/datajs/src/lib/odata.js
+++ b/datajs/src/lib/odata.js
@@ -58,7 +58,7 @@ function dispatchHandler(handlerMethod, requestOrResponse, context) {
     if (i === len) {
         throw { message: "no handler for data" };
     }
-};
+}
 
 /** Default success handler for OData.
  * @param data - Data to process.

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/256d1f2d/datajs/tests/common/djstest.js
----------------------------------------------------------------------
diff --git a/datajs/tests/common/djstest.js b/datajs/tests/common/djstest.js
index 90af598..182dd40 100644
--- a/datajs/tests/common/djstest.js
+++ b/datajs/tests/common/djstest.js
@@ -17,108 +17,133 @@
  * under the License.
  */
 
-var init = function (window) {
-    var djstest = {};
 
+// Because this code contains a init function to be useable directly inside the browser as well as in nodejs
+// we define the @namespace djstest here instead of the a @module name djstest
+
+/** Create namespace djstest in window.djstest when this file is loaded as java script by the browser
+ * @namespace djstest
+ */
+
+
+var init = function init () {
 
-    djstest.indexedDB = window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.indexedDB;
+    var djstest = {};
+    // Initialize indexedDB if the window object is available
+    if (typeof window !== 'undefined') {
+        djstest.indexedDB = window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.indexedDB;
+    }
 
-    djstest.cleanStoreOnIndexedDb = function (storeObjects, done) {
+    // Initialize indexedDB function if the indexedDB is available
+    if (djstest.indexedDB === undefined) {
+        djstest.cleanStoreOnIndexedDb = function (storeObjects, done) {
+            throw "indexedDB not supported in this environment (start test in browser)";
+        };
+    } else {
         /** Cleans all the test data saved in the IndexedDb database.
          * @param {Array} storeNames - Array of store objects with a property that is the name of the store
          * @param {Function} done - Callback function
          */
+        djstest.cleanStoreOnIndexedDb = function (storeObjects, done) {
+            var IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || {};
 
-        var IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || {};
-
-        var deleteObjectStores = function (db) {
-            $.each(db.objectStoreNames, function (_, storeName) {
-                db.deleteObjectStore(storeName);
-            });
-        };
-
-        if (djstest.indexedDB) {
-            var job = new djstest.Job();
-            $.each(storeObjects, function (_, storeObject) {
-                job.queue((function (storeObject) {
-                    return function (success, fail) {
-                        var dbname = "_datajs_" + storeObject.name;
-                        var request = djstest.indexedDB.open(dbname);
-                        request.onsuccess = function (event) {
-                            var db = request.result;
-
-                            if ("setVersion" in db) {
-                                var versionRequest = db.setVersion("0.1");
-                                versionRequest.onsuccess = function (event) {
-                                    var transaction = versionRequest.transaction;
-                                    transaction.oncomplete = function () {
-                                        db.close();
-                                        success();
-                                    }
-                                    deleteObjectStores(db);
+            function deleteObjectStores(db) {
+                $.each(db.objectStoreNames, function (_, storeName) {
+                    db.deleteObjectStore(storeName);
+                });
+            }
+            var job;
+
+            if (djstest.indexedDB) {
+                job = new djstest.Job();
+                $.each(storeObjects, function (_, storeObject) {
+                    job.queue((function (storeObject) {
+                        return function (success, fail) {
+                            var dbname = "_datajs_" + storeObject.name;
+                            var request = djstest.indexedDB.open(dbname);
+                            request.onsuccess = function (event) {
+                                var db = request.result;
+
+                                if ("setVersion" in db) {
+                                    var versionRequest = db.setVersion("0.1");
+                                    versionRequest.onsuccess = function (event) {
+                                        var transaction = versionRequest.transaction;
+                                        transaction.oncomplete = function () {
+                                            db.close();
+                                            success();
+                                        };
+                                        deleteObjectStores(db);
+                                    };
+                                    versionRequest.onerror = function (e) {
+                                        djstest.fail("Error on cleanup - code: " + e.code + " name: " + e.name + "message: " + message);
+                                        fail();
+                                    };
+                                    return;
+                                }
+
+                                // new api cleanup
+                                db.close();
+                                var deleteRequest = djstest.indexedDB.deleteDatabase(dbname);
+                                deleteRequest.onsuccess = function (event) {
+                                    djstest.log("djstest indexeddb cleanup - deleted database " + dbname);
+                                    success();
                                 };
-                                versionRequest.onerror = function (e) {
-                                    djstest.fail("Error on cleanup - code: " + e.code + " name: " + e.name + "message: " + message);
+                                deleteRequest.onerror = function (e) {
+                                    djstest.fail("djstest indexeddb cleanup - error deleting database " + dbname);
                                     fail();
                                 };
-                                return;
-                            }
-
-                            // new api cleanup
-                            db.close();
-                            var deleteRequest = djstest.indexedDB.deleteDatabase(dbname);
-                            deleteRequest.onsuccess = function (event) {
-                                djstest.log("djstest indexeddb cleanup - deleted database " + dbname);
-                                success();
-                            };
-                            deleteRequest.onerror = function (e) {
-                                djstest.fail("djstest indexeddb cleanup - error deleting database " + dbname);
-                                fail();
+                                djstest.log("djstest indexeddb cleanup - requested deletion of database " + dbname);
                             };
-                            djstest.log("djstest indexeddb cleanup - requested deletion of database " + dbname);
-                        };
 
-                        request.onerror = function (e) {
-                            djstest.fail(e.code + ": " + e.message);
+                            request.onerror = function (e) {
+                                djstest.fail(e.code + ": " + e.message);
+                            };
                         };
-                    };
-                })(storeObject));
-            });
-        }
+                    })(storeObject));
+                });
+            }
 
-        if (job) {
-            job.run(function (succeeded) {
-                if (!succeeded) {
-                    djstest.fail("cleanup job failed");
-                }
+            if (job) {
+                job.run(function (succeeded) {
+                    if (!succeeded) {
+                        djstest.fail("cleanup job failed");
+                    }
+                    done();
+                });
+            }
+            else {
                 done();
-            });
-        }
-        else {
-            done();
-        }
-    };
+            }
+        };
+    }
 
+    /** Constructs a Job object that allows for enqueuing and synchronizing the execution of functions.
+     * @class Job
+     * @constructor
+     * @returns {Object} Job object
+     */
     djstest.Job = function () {
-        /** Constructs a Job object that allows for enqueuing and synchronizing the execution of functions.
-         * @returns {Object} Job object
-         */
+        
         var currentTask = -1;
         var tasks = [];
 
         var failedTasks = 0;
 
+        /** Adds a function to the job queue regardless if the queue is already executing or not.
+         * @method djstest.Job#queue
+         * @param {Function} fn - Function to execute.
+         */
         this.queue = function (fn) {
-            /** Adds a function to the job queue regardless if the queue is already executing or not.
-             * @param {Function} fn - Function to execute.
-             */
+            
             tasks.push(fn);
         };
 
+        /** Adds a function to the front of the job queue regardless if the queue is already executing or not.
+         * @method djstest.Job#queueNext
+         * @param {Function} fn - Function to execute.
+         */
         this.queueNext = function (fn) {
-            /** Adds a function to the front of the job queue regardless if the queue is already executing or not.
-             * @param {Function} fn - Function to execute.
-             */
+        
             if (currentTask < 0) {
                 tasks.unshift(fn);
             } else {
@@ -126,13 +151,12 @@ var init = function (window) {
             }
         };
 
+        /** Starts the execution of this job.
+         * @method djstest.Job#run
+         * @param {Function} done - Callback invoked when the job has finished executing all of its enqueued tasks.
+         */
         this.run = function (done) {
-            /** Starts the execution of this job.
-             * @param {Function} done - Callback invoked when the job has finished executing all of its enqueued tasks.
-            */
             /// This method does nothing if called on a unit of work that is already executing.
-            
-
             if (currentTask >= 0) {
                 return;
             }
@@ -142,7 +166,10 @@ var init = function (window) {
                 return;
             }
 
-            var makeTaskDoneCallBack = function (failed) {
+            /**
+             * @method djstest.Job~makeTaskDoneCallBack
+            */
+            function makeTaskDoneCallBack(failed) {
                 return function () {
                     // Track the failed task and continue the execution of the job. 
                     if (failed) {
@@ -155,11 +182,12 @@ var init = function (window) {
                         runNextTask();
                     }
                 };
-            };
+            }
 
-            var runNextTask = function () {
-                /** Executes the next function in the queue.
-                */
+            /** Executes the next function in the queue.
+             * @method djstest.Job~runNextTask
+            */
+            function runNextTask() {
                 defer(function () {
                     try {
                         tasks[currentTask](makeTaskDoneCallBack(false), makeTaskDoneCallBack(true));
@@ -167,27 +195,32 @@ var init = function (window) {
                         makeTaskDoneCallBack(true)();
                     }
                 });
-            };
+            }
 
             currentTask = 0;
             runNextTask();
         };
     };
 
-    var defer = function (fn) {
-        /** Defers the execution of an arbitrary function that takes no parameters.
-         * @param {Function} fn - Function to schedule for later execution.
-         */
+    /** Defers the execution of an arbitrary function that takes no parameters.
+     * @memberof djstest
+     * @inner
+     * @param {Function} fn - Function to schedule for later execution.
+     */
+    function defer(fn) {
         setTimeout(fn, 0);
     }
 
-    var exposeDateValues = function (data) {
-        /** Exposes date values for Date objects to facilitate debugging
-         * @param {Object} data - The object to operate on
-         */
+    /** Exposes date values for Date objects to facilitate debugging
+     * @memberof djstest
+     * @inner
+     * @param {Object} data - The object to operate on
+     */
+    function exposeDateValues(data) {
+     
         if (typeof data === "object") {
             if (data instanceof Date) {
-                data["__date__"] = data.toUTCString();
+                data.__date__ = data.toUTCString();
             }
             else {
                 for (var prop in data) {
@@ -199,11 +232,14 @@ var init = function (window) {
         return data;
     }
 
-    var extractFunctionName = function (text) {
-        /** Determines the name of a function.
-         * @param {String} text - Function text.
-         * @returns {String} The name of the function from text if found; the original text otherwise.
-         */
+    /** Determines the name of a function.
+     * @memberof djstest
+     * @inner
+     * @param {String} text - Function text.
+     * @returns {String} The name of the function from text if found; the original text otherwise.
+     */
+    function extractFunctionName(text) {
+
         var index = text.indexOf("function ");
         if (index < 0) {
             return text;
@@ -221,30 +257,36 @@ var init = function (window) {
         }
 
         return result;
-    };
+    }
+
+    /** Removes metadata annotations from the specified object.
+     * @memberof djstest
+     * @inner
+     * @param data - Object to remove metadata from; possibly null.
+     */
+    function removeMetadata(data) {
 
-    var removeMetadata = function (data) {
-        /** Removes metadata annotations from the specified object.
-         * @param data - Object to remove metadata from; possibly null.
-         */
         if (typeof data === "object" && data !== null) {
-            delete data["__metadata"];
-            for (prop in data) {
+            delete data.__metadata;
+            for (var prop in data) {
                 removeMetadata(data[prop]);
             }
         }
-    };
+    }
 
+    /** Add the unit test cases
+     * @param disable - Indicate whether this test case should be disabled
+    */
     djstest.addFullTest = function (disable, fn, name, arg, timeout) {
-        /** Add the unit test cases
-         * @param disable - Indicate whether this test case should be disabled
-        */
-        if (disable != true) {
+
+        if (disable !== true) {
             djstest.addTest(fn, name, arg, timeout);
         }
     };
 
-
+    /** Add the unit test cases
+     * @param disable - Indicate whether this test case should be disabled
+    */
     djstest.addTest = function (fn, name, arg, timeout) {
         if (!name) {
             name = extractFunctionName(fn.toString());
@@ -261,39 +303,45 @@ var init = function (window) {
         });
     };
 
+    /** Asserts that a condition is true.
+     * @param {Boolean} test - Condition to test.
+     * @param {String} message - Text message for condition being tested.
+     */
     djstest.assert = function (test, message) {
-        /** Asserts that a condition is true.
-         * @param {Boolean} test - Condition to test.
-         * @param {String} message - Text message for condition being tested.
-         */
+        
         QUnit.ok(test, message);
     };
 
+    /** Asserts that the values of the expected and actualobjects are equal.
+     * @memberof djstest
+     * @inner
+     */
     djstest.assertAreEqual = function (actual, expected, message) {
-        /** Asserts that the values of the expected and actualobjects are equal.
-        */
         QUnit.equal(actual, expected, message);
     };
 
+    /** Asserts that the actual and expected objects are the same.
+     */
     djstest.assertAreEqualDeep = function (actual, expected, message) {
-        /** Asserts that the actual and expected objects are the same.
-        */
         QUnit.deepEqual(exposeDateValues(actual), exposeDateValues(expected), message);
     };
 
+    /** Asserts that the actual and expected objects are the same but removes the metadata bevore
+     */
     djstest.assertWithoutMetadata = function (actual, expected, message) {
-        removeMetadata(actual)
+        removeMetadata(actual);
         removeMetadata(expected);
         djstest.assertAreEqualDeep(actual, expected, message);
     };
 
+    /** Calls each async action in asyncActions, passing each action a function which keeps a count and
+     * calls the passed done function when all async actions complete
+     * @param {Array} asyncActions -Array of asynchronous actions to be executed, 
+     * each taking a single parameter - the callback function to call when the action is done.</param>
+     * @param {Function} done - Function to be executed in the last async action to complete.
+     */
     djstest.asyncDo = function (asyncActions, done) {
-        /** Calls each async action in asyncActions, passing each action a function which keeps a count and
-         * calls the passed done function when all async actions complete
-         * @param {Array} asyncActions -Array of asynchronous actions to be executed, 
-         * each taking a single parameter - the callback function to call when the action is done.</param>
-         * @param {Function} done - Function to be executed in the last async action to complete.
-         */
+
         var count = 0;
         var doneOne = function () {
             count++;
@@ -309,18 +357,20 @@ var init = function (window) {
         } else {
             done();
         }
-    }
+    };
 
+    /** Makes a deep copy of an object.
+     */
     djstest.clone = function (object) {
-        /** Makes a deep copy of an object.
-        */
+        
         return $.extend(true, {}, object);
     };
 
+    /** Destroys the cache and then completes the test
+     * @param cache - The cache to destroy
+     */
     djstest.destroyCacheAndDone = function (cache) {
-        /** Destroys the cache and then completes the test
-        * @param cache - The cache to destroy
-        */
+     
         cache.clear().then(function () {
             djstest.done();
         }, function (err) {
@@ -329,15 +379,17 @@ var init = function (window) {
         });
     };
 
+    /** Indicates that the currently running test has finished.
+     */
     djstest.done = function () {
-        /** Indicates that the currently running test has finished.
-        */
+      
         QUnit.start();
     };
 
+    /** Test passes if and only if an exception is thrown.
+     */
     djstest.expectException = function (testFunction, message) {
-        /** Test passes if and only if an exception is thrown.
-        */
+     
         try {
             testFunction();
             djstest.fail("Expected exception but function succeeded: " + " " + message);
@@ -348,34 +400,36 @@ var init = function (window) {
         }
     };
 
+    /** Indicates the expected number of asserts, fails test if number is not met.
+     * @param {Number} asserts - Number of asserts expected in test.
+     */
     djstest.assertsExpected = function (asserts) {
-        /** Indicates the expected number of asserts, fails test if number is not met.
-         * @param {Number} asserts - Number of asserts expected in test.
-         */
+        
         expect(asserts);
-    }
-
+    };
+    /** Marks the current test as failed.
+     * @param {String} message - Failure message.
+     */
     djstest.fail = function (message) {
-        /** Marks the current test as failed.
-         * @param {String} message - Failure message.
-         */
+
         QUnit.ok(false, message);
     };
 
+    /** Returns a function that when invoked will fail this test and be done with it.
+     * @param {String} message - Failure message.
+     * @param {Function} [cleanupCallback] - 
+     * @returns {Function} A new function.
+     */
     djstest.failAndDoneCallback = function (message, cleanupCallback) {
-        /** Returns a function that when invoked will fail this test and be done with it.
-         * @param {String} message - Failure message.
-         * @param {Function} [cleanupCallback] - 
-         * @returns {Function} A new function.
-        */
+
         return function (err) {
-            message = "" + message + (err) ? window.JSON.stringify(err) : "";
+            message = "" + message + (err) ? JSON.stringify(err) : "";
             djstest.fail(message);
             if (cleanupCallback) {
                 try {
                     cleanupCallback();
                 } catch (e) {
-                    djstest.fail("error during cleanupCallback: " + window.JSON.stringify(e));
+                    djstest.fail("error during cleanupCallback: " + JSON.stringify(e));
                 }
             }
 
@@ -383,33 +437,35 @@ var init = function (window) {
         };
     };
 
+    /** Logs a test message.
+     * @param {String} message - Test message.
+     */
     djstest.log = function (message) {
-        /** Logs a test message.
-         * @param {String} message - Test message.
-         */
+
         var context = { result: true, actual: true, expected: true, message: message };
         QUnit.log(context);
     };
 
+    /** Marks the current test as failed.
+     * @param {String} message - Failure message.
+     */
     djstest.pass = function (message) {
-        /** Marks the current test as failed.
-         * @param {String} message - Failure message.
-         */
         QUnit.ok(true, message);
     };
 
+    /** Dumps the object as a string
+     * @param {Object} obj - Object to dump
+     */
     djstest.toString = function (obj) {
-        /** Dumps the object as a string
-         * @param {Object} obj - Object to dump
-         */
+
         return QUnit.jsDump.parse(obj);
     };
 
+    /** Executes the function, pausing test execution until the callback is called
+     * @param {Function} fn - Function to execute; takes one parameter which is the callback
+     * This function is typically used in asynchronous setup/teardown methods</remarks>
+     */
     djstest.wait = function (fn) {
-        /** Executes the function, pausing test execution until the callback is called
-         * @param {Function} fn - Function to execute; takes one parameter which is the callback
-         * This function is typically used in asynchronous setup/teardown methods</remarks>
-         */
         QUnit.stop();
         fn(function () {
             QUnit.start();
@@ -418,7 +474,7 @@ var init = function (window) {
 
     // Disable caching to ensure that every test-related AJAX request is actually being sent,
     // and set up a default error handler
-    if (window !== undefined) {//TODO improve
+    if (typeof window !== undefined) {
         $.ajaxSetup({
             cache: false,
             error: function (jqXHR, textStatus, errorThrown) {
@@ -435,15 +491,18 @@ var init = function (window) {
             }
         });
     }
-
     return djstest;
 };
 
+//export djstest
+
 if (typeof window !== 'undefined') {
-    //in browser call init() directly window as context
-    window.djstest = init(window);
+    //expose to browsers window object
+    window.djstest = init();
+    init();
 } else {
-    //expose function init to be called with a custom context
-    module.exports.init = init;
+    //expose in commonjs style
+    //var $ = {};
+    module.exports = init();
 }
 


[2/3] git commit: [OLINGO-407] changed tester.html datajs to odatajs

Posted by ko...@apache.org.
[OLINGO-407] changed tester.html datajs to odatajs


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/1a681e82
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/tree/1a681e82
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/diff/1a681e82

Branch: refs/heads/master
Commit: 1a681e826cf14819562c184016d513ebdb19a23c
Parents: 256d1f2
Author: Sven Kobler <sv...@sap.com>
Authored: Wed Aug 20 10:34:19 2014 +0200
Committer: Sven Kobler <sv...@sap.com>
Committed: Wed Aug 20 10:34:19 2014 +0200

----------------------------------------------------------------------
 datajs/demo/tester.html | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/1a681e82/datajs/demo/tester.html
----------------------------------------------------------------------
diff --git a/datajs/demo/tester.html b/datajs/demo/tester.html
index 041f7cd..bd4e513 100644
--- a/datajs/demo/tester.html
+++ b/datajs/demo/tester.html
@@ -108,18 +108,18 @@
                 }
 
                 var metaDatasuccess = function(metadata){
-                    datajs.V4.oData.read(requestUri, success, errorFunc, null, null, metadata);
+                    odatajs.oData.read(requestUri, success, errorFunc, null, null, metadata);
                 };
 
                 if ( metadata === 'full') {
                     requestUri.headers =  { Accept : 'application/json;odata.metadata=full' };
-                    datajs.V4.oData.read(requestUri, success, errorFunc);
+                    odatajs.oData.read(requestUri, success, errorFunc);
                 } else if ( metadata === 'minimal') {
                     requestUri.headers =  { Accept : 'application/json;odata.metadata=minimal' };
                     getMetaData(metaDatasuccess);
                 } else {
                     requestUri.headers =  { Accept : 'application/json;odata.metadata=none' };
-                    datajs.V4.oData.read(requestUri, success, errorFunc);
+                    odatajs.oData.read(requestUri, success, errorFunc);
                 }
             }
 
@@ -152,7 +152,7 @@
                     requestUri: "http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/$metadata", //"http://localhost:6630/PrimitiveKeys.svc/$metadata",
                     data: null,
                 };
-                datajs.V4.oData.read(metadataRequest, metaDatasuccess, errorFunc,datajs.V4.oData.metadataHandler);
+                odatajs.oData.read(metadataRequest, metaDatasuccess, errorFunc,odatajs.oData.metadataHandler);
             }
 
             /*******Special buttons***********/           
@@ -172,7 +172,7 @@
                     data: null,
                 };
 
-                datajs.V4.oData.read(metadataRequest, success, errorFunc,datajs.V4.oData.metadataHandler);
+                odatajs.oData.read(metadataRequest, success, errorFunc,odatajs.oData.metadataHandler);
             });
 
             $('#btnPOST_entry_food').on("click", function(){
@@ -188,7 +188,7 @@
                         Name: "flour1"
                     }
                 };
-                datajs.V4.oData.read(requestUri, success, errorFunc);
+                odatajs.oData.read(requestUri, success, errorFunc);
             });
             $('#btnPOST_entry_categorie').on("click", function(){
 
@@ -204,7 +204,7 @@
                         Name: "cat111"
                     }
                 };
-                datajs.V4.oData.read(requestUri, success, errorFunc);
+                odatajs.oData.read(requestUri, success, errorFunc);
             });
 
 


[3/3] git commit: [OLINGO-407] fix tester.html (minimal to full) now again working

Posted by ko...@apache.org.
[OLINGO-407] fix tester.html (minimal to full) now again working


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/caa44a31
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/tree/caa44a31
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/diff/caa44a31

Branch: refs/heads/master
Commit: caa44a31a099c7ea5449befc75408354733694e6
Parents: 1a681e8
Author: Sven Kobler <sv...@sap.com>
Authored: Wed Aug 20 13:40:57 2014 +0200
Committer: Sven Kobler <sv...@sap.com>
Committed: Wed Aug 20 13:40:57 2014 +0200

----------------------------------------------------------------------
 datajs/demo/tester.html | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/caa44a31/datajs/demo/tester.html
----------------------------------------------------------------------
diff --git a/datajs/demo/tester.html b/datajs/demo/tester.html
index bd4e513..929c6fd 100644
--- a/datajs/demo/tester.html
+++ b/datajs/demo/tester.html
@@ -27,7 +27,7 @@
             .code .comment,.code .ns{color:#666666;}
 
             .left {
-                left : 20px;
+                margin-left : 20px;
                 position:relative;
             }
 
@@ -97,15 +97,14 @@
             // Testing 
             function buttonClick(configNr) {
                 var metadata = $("input[name*='inMetadata']:checked").val();
-                var recognizeDates = $("#inRecognizeDates:checked").val();
+                var recognizeDates  = ($("#inRecognizeDates:checked").val() ==='on') ? true : false;
+                var inMinimalToFull = ($("#inMinimalToFull:checked").val() ==='on') ? true : false;
 
                 var requestUri = {
                     requestUri : config[configNr].url
                 };
 
-                if (recognizeDates==='on') {
-                    requestUri.recognizeDates = true;
-                }
+                requestUri.recognizeDates = recognizeDates;
 
                 var metaDatasuccess = function(metadata){
                     odatajs.oData.read(requestUri, success, errorFunc, null, null, metadata);
@@ -116,7 +115,11 @@
                     odatajs.oData.read(requestUri, success, errorFunc);
                 } else if ( metadata === 'minimal') {
                     requestUri.headers =  { Accept : 'application/json;odata.metadata=minimal' };
-                    getMetaData(metaDatasuccess);
+                    if (inMinimalToFull) {
+                        getMetaData(metaDatasuccess);
+                    } else {
+                        odatajs.oData.read(requestUri, success, errorFunc);   
+                    }
                 } else {
                     requestUri.headers =  { Accept : 'application/json;odata.metadata=none' };
                     odatajs.oData.read(requestUri, success, errorFunc);