Я пытаюсь, чтобы один из моих смоделированных объектов выдавал проверенное исключение при вызове определенного метода. я получаю исключение ниже, может кто-нибудь помочь мне, пожалуйста
MSThread
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)