/* this test does the following: Always requests the same resource, while for each request getting: 1. 200 + ETag: "one" 2. 401 followed by 200 + ETag: "two" 3. 401 followed by 304 4. 407 followed by 200 + ETag: "three" 5. 407 followed by 304
*/
function handler(metadata, response) {
handlers.shift()(metadata, response);
}
// Array of tests to run, self-driven
function sync_and_run_next_test() {
syncWithCacheIOThread(function () {
tests.shift()();
});
}
var tests = [ // Test 1: 200 (cacheable) function () { var ch = makeChan();
ch.asyncOpen( new ChannelListener( function (req, body) { Assert.equal(body, "Response body 1");
sync_and_run_next_test();
}, null,
CL_NOT_FROM_CACHE
)
);
},
// Test 2: 401 and 200 + new content function () { var ch = makeChan();
ch.asyncOpen( new ChannelListener( function (req, body) { Assert.equal(body, "Response body 2");
sync_and_run_next_test();
}, null,
CL_NOT_FROM_CACHE
)
);
},
// Test 3: 401 and 304 function () { var ch = makeChan();
ch.asyncOpen( new ChannelListener( function (req, body) { Assert.equal(body, "Response body 2");
sync_and_run_next_test();
}, null,
CL_FROM_CACHE
)
);
},
// Test 4: 407 and 200 + new content function () { var ch = makeChan();
ch.asyncOpen( new ChannelListener( function (req, body) { Assert.equal(body, "Response body 3");
sync_and_run_next_test();
}, null,
CL_NOT_FROM_CACHE
)
);
},
// Test 5: 407 and 304 function () { var ch = makeChan();
ch.asyncOpen( new ChannelListener( function (req, body) { Assert.equal(body, "Response body 3");
sync_and_run_next_test();
}, null,
CL_FROM_CACHE
)
);
},
// End of test run function () {
httpserv.stop(do_test_finished);
},
];
function run_test() {
do_get_profile();
httpserv = new HttpServer();
httpserv.registerPathHandler("/", handler);
httpserv.start(-1);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.