Reputation: 9411
I am getting NoSuchAlgorithmException
in the following code:
@RunWith(PowerMockRunner.class)
@PrepareForTest({CloudWatchHelper.class})
class MyTest {
....
final SSLContext sslcontext = SSLContext.getInstance("TLS");
...
}
Stack trace:
[junit] class configured for SSLContext: sun.security.ssl.SSLContextImpl$TLSContext not a SSLContext
[junit] java.security.NoSuchAlgorithmException: class configured for SSLContext: sun.security.ssl.SSLContextImpl$TLSContext not a SSLContext
[junit] at sun.security.jca.GetInstance.checkSuperClass(GetInstance.java:260)
[junit] at sun.security.jca.GetInstance.getInstance(GetInstance.java:237)
[junit] at sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
[junit] at javax.net.ssl.SSLContext.getInstance(SSLContext.java:156)
I want to know what is the reason behind NoSuchAlgorithmException
.
Upvotes: 8
Views: 7605
Reputation: 9411
I realized that I got exception because of:
@RunWith(PowerMockRunner.class)
@PrepareForTest({CloudWatchHelper.class})
Upvotes: -5
Reputation: 2440
Adding the following annotation to my test class fixed this issue for me:
@PowerMockIgnore({ "javax.net.ssl.*", "javax.security.*" })
Upvotes: 18