tiebin-zhang / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

Connecting via HttpClient with an https page throws java.net.SocketException: java.security.NoSuchAlgorithmException: class configured for SSLContext: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl not a SSLContext #288

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a junit4 test which tries to connect to a SSL enabled site with 
httpclient having a @PrepareForTest annotation.
2. Run the test.

What is the expected output? What do you see instead?
I expect to be able to connect to the site.
I see a java.net.SocketException

What version of the product are you using? On what operating system?
powermock-module-junit4 1.4.6
[mirko@borg powermockitotest]$ mvn3 -v
Apache Maven 3.0 (r1004208; 2010-10-04 13:50:56+0200)
Java version: 1.6.0_22
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: de_DE, platform encoding: MacRoman
OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"

Please provide any additional information below.
I created a test project available at 
http://github.com/mfriedenhagen/powermockitotest

Original issue reported on code.google.com by mfriedenhagen on 30 Oct 2010 at 7:22

GoogleCodeExporter commented 9 years ago
Please see http://github.com/mfriedenhagen/powermockitotest/raw/master/README 
for the stacktrace and 
http://github.com/mfriedenhagen/powermockitotest/blob/master/src/test/java/power
mockitotest/powermockitotest/SslConnectionWithPreparedClassTest.java for the 
test class.

Original comment by mfriedenhagen on 30 Oct 2010 at 8:02

GoogleCodeExporter commented 9 years ago
It could be because the algorithm is being loaded by the PowerMock classloader. 
Try using the @PowerMockIgnore annotation, e.g. 
@PowerMockIgnore("org.apache.http.client.*") or 
@PowerMockIgnore("java.security.*") or some other combinations.

Let us know if it works or not.

Original comment by johan.ha...@gmail.com on 2 Nov 2010 at 9:34

GoogleCodeExporter commented 9 years ago
Hello,

I tried different combinations and @PowerMockIgnore("javax.*") did the trick. 
Thanks for the suggestion.

Regards
Mirko

Original comment by mfriedenhagen on 2 Nov 2010 at 7:05

GoogleCodeExporter commented 9 years ago
Great to hear!

Original comment by johan.ha...@gmail.com on 2 Nov 2010 at 7:42