Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 422071

Summary: Search crawler: Should handle cancellation in Deferred.all instead of after Deferred.Cancel call.
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: simon_kaegi
Version: 4.0   
Target Milestone: 5.0 M1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description libing wang CLA 2013-11-19 10:41:14 EST
In my unit test OrionClient/bundles/org.eclipse.orion.client.ui web/js-tests/ searchCrawler/testcase.js, there is a test case called "test_NormalCancel".

The test case passed but there is an additional Deferred.All().then call which bothered me.
My test logic is:
There are 14 deferred created and if there is no cancellation, the Deferred.All() returns a promise. But if there is a cancellation Deferred.All() returns nothing. At least, in the real crawler search by the user interruption, it works this way.

In my test case, I cancelled the all the defers when 3 are resolved. I expected that Deferred.All() returns nothing in this case. But I might be wrong on how to use cancel.
Comment 1 libing wang CLA 2013-11-19 10:49:16 EST
(In reply to libing wang from comment #0)
> In my test case, I cancelled the all the defers when 3 are resolved. I
> expected that Deferred.All() returns nothing in this case. 
I expected that Deferred.All() returns nothing but actually it returns a promise.
Comment 2 libing wang CLA 2013-11-19 11:59:56 EST
Talked to Simon, my deferred.All should handle rejection.
The previous code in searchCrawler is wrong.
Comment 3 libing wang CLA 2013-11-19 15:45:33 EST
fixed with http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=e6e57bfcdeb0a0552b2018769b4c9b36e622f752.
Also change the mockFileClient to delay 0.002 seconds to fetch children so that the test cancellation case can handle the rejection.