Author: gotcha
Date: Wed Dec 26 13:08:58 2007
New Revision: 50121

Modified:
   kukit/kukit.js/branch/finish-closures/kukit/kukit.js
   kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js
   kukit/kukit.js/branch/finish-closures/tests/test_requestmanager.js
Log:
make test_requestmanager pass :

remove default value for max number of requests
reorder initialization parameters


Modified: kukit/kukit.js/branch/finish-closures/kukit/kukit.js
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/kukit.js        (original)
+++ kukit/kukit.js/branch/finish-closures/kukit/kukit.js        Wed Dec 26 
13:08:58 2007
@@ -66,7 +66,7 @@
     // State vars storage. This can be used from kss via a method.
     this.stateVariables = {};
     // instantiate request manager
-    this.requestManager = new kukit.rm.RequestManager();
+    this.requestManager = new kukit.rm.RequestManager(4);
     this.binderInfoRegistry = new kukit.er.BinderInfoRegistry();
     // instantiate a load scheduler
     this.loadScheduler = new kukit.rd.LoadActions();

Modified: kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js       
(original)
+++ kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js       Wed Dec 
26 13:08:58 2007
@@ -30,11 +30,11 @@
 rm._rid = 0;
 
 /*
-* class RequestItem
+* class _RequestItem
 *
 * Request item. Encapsulates the sendout function and data.
 */
-rm.RequestItem = function() {
+var _RequestItem = function() {
 
 this.initialize = function(sendHook, url, timeoutHook, timeout, now) {
     if (typeof(now) == 'undefined') {
@@ -80,15 +80,21 @@
 this.initialize.apply(this, arguments);
 };
 
+rm.TestRequestItem = function() {
+kukit.logWarning('Use class [rm.TestRequestItem] only in tests !');
+this.initialize.apply(this, arguments);
+};
+rm.TestRequestItem.prototype = new _RequestItem();
+
 /* 
-* class TimerQueue
+* class _TimerQueue
 *
 * the send queue. This handles timeouts, and executes
 * a callback for timed out items.
 * Callback is called with the request item as parameter.
 */
 
-rm.TimerQueue = function() {
+var _TimerQueue = function() {
 
 this.initialize = function(callback) {
     this.callback = callback;
@@ -153,12 +159,19 @@
 this.initialize.apply(this, arguments);
 };
 
+rm.TestTimerQueue = function() {
+kukit.logWarning('Use class [rm.TestTimerQueue] only in tests !');
+this.initialize.apply(this, arguments);
+};
+rm.TestTimerQueue.prototype = new _TimerQueue();
+
+
 /* 
 * class RequestManager
 */
 rm.RequestManager = function () {
 
-this.initialize = function (name, maxNr, schedulerClass) {
+this.initialize = function (maxNr, name, schedulerClass) {
     // schedulerClass is mainly provided for debugging...
     this.waitingQueue = new kukit.ut.FifoQueue();
     this.sentNr = 0;
@@ -166,7 +179,7 @@
     var timeoutItem = function(item) {
        self.timeoutItem(item);
     };
-    this.timerQueue = new rm.TimerQueue(timeoutItem);
+    this.timerQueue = new _TimerQueue(timeoutItem);
     if (typeof(name) == 'undefined') {
         name = null;
     }
@@ -192,8 +205,6 @@
     // sending timeout in millisecs
     this.sendingTimeout = 8000;
 
-    // max request number
-    this.maxNr = 4;
 };
 
 ;;; this.getInfo = function() {
@@ -350,7 +361,7 @@
         // Default value of timeout
         timeout = this.sendingTimeout;
     }
-    var item = new rm.RequestItem(sendHook, url, timeoutHook, timeout,
+    var item = new _RequestItem(sendHook, url, timeoutHook, timeout,
         now);
     // Start timing the item immediately
     this.timerQueue.push(item);

Modified: kukit/kukit.js/branch/finish-closures/tests/test_requestmanager.js
==============================================================================
--- kukit/kukit.js/branch/finish-closures/tests/test_requestmanager.js  
(original)
+++ kukit/kukit.js/branch/finish-closures/tests/test_requestmanager.js  Wed Dec 
26 13:08:58 2007
@@ -45,14 +45,14 @@
             expired.push(item);
         };
         // Push items at different timepoints, with same timeout
-        q = new kukit.rm.TimerQueue(cbe);
-        var i1 = new kukit.rm.RequestItem(null, 1, null, 10000, 1000);
+        q = new kukit.rm.TestTimerQueue(cbe);
+        var i1 = new kukit.rm.TestRequestItem(null, 1, null, 10000, 1000);
         q.push(i1);
-        var i2 = new kukit.rm.RequestItem(null, 2, null, 10000, 2000);
+        var i2 = new kukit.rm.TestRequestItem(null, 2, null, 10000, 2000);
         q.push(i2);
-        var i3 = new kukit.rm.RequestItem(null, 3, null, 10000, 3000);
+        var i3 = new kukit.rm.TestRequestItem(null, 3, null, 10000, 3000);
         q.push(i3);
-        var i4 = new kukit.rm.RequestItem(null, 4, null, 10000, 4000);
+        var i4 = new kukit.rm.TestRequestItem(null, 4, null, 10000, 4000);
         q.push(i4);
         this.assertEquals(q.count, 4);
         // pop 2, 4
@@ -79,7 +79,7 @@
 
     this.testNormalSend = function() {
         // Test a simple send situation
-        var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler);
+        var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler);
         this.assertRmQueues(rm, 0, 0);
         // queues
         var sent = [];
@@ -116,7 +116,7 @@
 
     this.testSendWithTimeouts = function() {
         // Test a simple timeout situation
-        var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler);
+        var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler);
         this.assertRmQueues(rm, 0, 0);
         // queues
         var sent = [];
@@ -161,7 +161,7 @@
  
     this.testSendWithQueuedTimeout = function() {
         // Test timeout with queues not sent out
-        var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler);
+        var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler);
         this.assertRmQueues(rm, 0, 0);
         // queues
         var sent = [];
@@ -203,7 +203,7 @@
  
     this.testSendWithQueuedSwallowed = function() {
         // If the queued element is timed out, it it not sent out
-        var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler);
+        var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler);
         this.assertRmQueues(rm, 0, 0);
         // queues
         var sent = [];
@@ -246,7 +246,7 @@
 
     this.testAllTimedOut = function() {
         // If all elements are timed out
-        var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler);
+        var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler);
         this.assertRmQueues(rm, 0, 0);
         // queues
         var sent = [];
@@ -284,7 +284,7 @@
 
     this.testTimeoutHooks = function() {
         // Test if timeout hook(s) are called
-        var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler);
+        var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler);
         this.assertRmQueues(rm, 0, 0);
         // queues
         var sent = [];
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to