开发者

Grails Services / Transactions / RuntimeException / Testing

I'm testing come code in a service with transactional set to true , which talks to a customer supplied web service the main part of which looks like

class BarcodeService { 
..  
/// some stuff  ...  

try{
      cancelBarCodeResponse = cancelBarCode(cancelBarcodeRequest)
} catch(myCommsException e) {
  throw new RuntimeException(e)
}
... 

where myCommsException extends Exception ..

I have a test which looks like

// As no connection from my machine, it should fail ..

shouldFailWithCause(RuntimeException){
  barcodeServices.cancelBarcodeDetails()
}

The test fails cause it's catching a myCommsException rather than th开发者_如何学Ce RuntimeException i thought i'd converted it to .. Anyone care to point out what i'm doing wrong ? Also will the fact that it's not a RuntimeException mean any transaction related info done before my try/catch actually be written out rather than thrown away ??

Thanks


From what I see, it looks ok. The problem might be in the ///some stuff and the ... parts of the code. Use a debugger to find out exactly where the exception is being thrown.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜