I have a method that has another method call whose definition has a SomeIntegerObject.wait() call. Now when I run my test case, due to this wait method, the test case keeps waiting and doesn't execute.
I tried adding a timeout at @Test annotation but that causes an exception like "test timed out".
The test method:
private PastingResult result;
public PastingResult pasteImages(IIOImage[] images, byte pasteProcessType){
result = new PastingResult();
_reprocessingProvider.setListLogicHandler(this);
//--some more method calls--
waitForResult(); //causes my test case to wait forever and pauses execution
return result;
}
Test case:
@Test
public void testPasteImagesIIOImageArrayByte() throws Exception
{
ReprocessManager _reprocessingProvider1=Mockito.mock(ReprocessManager.class);
Whitebox.setInternalState(imagePasterIfImpl, "_reprocessingProvider", _reprocessingProvider1);
IIOImage[] images=new IIOImage[]{Mockito.mock(IIOImage.class),Mockito.mock(IIOImage.class)};
byte pasteProcessType = 02;
PastingResult result= imagePasterIfImpl.pasteImages(images, pasteProcessType);
Mockito.verify(_reprocessingProvider1).setListLogicHandler(imagePasterIfImpl);
System.out.println(result+"is the result");
}
Definition of waitForResult();
private Integer processingWaitMonitor = new Integer(0);
private void waitForResult() {
// synchronize to wait on the Monitor..
synchronized(processingWaitMonitor) {
try {
processingWaitMonitor.wait();
}
catch(Exception e) {
System.out.println("Exception during Wait !"+e);
}
}
}