You can make fun of any block sentence tryto throw an exception that you want to catch.
KeyManagerFactory.getInstance, NoSuchAlgorithmException. catch, (KeyStoreException, UnrecoverableKeyException CertificateException).
( getInstance is static, PowerMockito Mockito, . question )
@PrepareForTest(KeyManagerFactory.class)
@RunWith(PowerMockRunner.class)
public class FooTest {
@Test
public void testGetKeyStore() throws Exception {
PowerMockito.mockStatic(KeyManagerFactory.class);
when(KeyManagerFactory.getInstance(anyString())).thenThrow(new NoSuchAlgorithmException());
}
}
,