我正在尝试让我的模拟对象之一在调用特定方法时抛出已检查的异常。我低于例外情况,有人可以帮忙吗
try {
if (command.equals("NEAT_TEST"))
url = nsReqUrl;
else if (command.equals("RETEST_FIBER"))
url = retestfiberUrl;
else
url = nsDirectTl1Url;
resultMsg = MSNeatServiceHandler.sendRequest(msg, url);
} catch (Exception e) {
s = e.toString();
if (exceptionCnt++ < _nsCmdMaxRetries) {
_logger.warn("Neat or Direct TL1 Service exception (attempt " + exceptionCnt + " of "
+ (_nsCmdMaxRetries + 1) + ").. " + e);
resultMsg = MSNeatServiceHandler.sendRequest(msg, url);
} else {
throw e;
}
}
@Test
public void testMSThread_NeatTest3() throws Exception {
String url = "";
PowerMockito.doThrow(new RuntimeException()).when(MSNeatServiceHandler.sendRequest(msg,url));
MSThread result = new MSThread(name, rh, buff, props);
result.process(msg);
}
org.mockito.exceptions.base.MockitoException:
Checked exception is invalid for this method!
Invalid: java.lang.Exception
at com.verizon.dtix.microsvcagent.MSThreadTest.testMSThread_NeatTest3(MSThreadTest.java:201)