wujun / powermock

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

Cannot instantiate com.sun.net.ssl.internal.ssl.Provider when using PowerMockRunner #441

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Run this example:

@RunWith(PowerMockRunner.class)
@PrepareForTest(Dummy.class)
public class PowerMockTest {

    @Before
    public void setUp() {
        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    }

    @Test
    public void test() {
    }
}

class Dummy {
}

What is the expected output? What do you see instead?
It throws exception:

java.lang.AssertionError: Illegal subclass: class 
com.sun.net.ssl.internal.ssl.Provider
    at sun.security.ssl.SunJSSE.subclassCheck(SunJSSE.java:232)
    at sun.security.ssl.SunJSSE.<init>(SunJSSE.java:107)
    at com.sun.net.ssl.internal.ssl.Provider.<init>(Provider.java:41)
    at PowerMockTest.setUp(PowerMockTest.java:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:129)
    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:93)

What version of the product are you using? On what operating system?
Windows 7, powermock 1.5

Here are my gradle dependencies:

testCompile 'junit:junit:4.10',
            'org.mockito:mockito-all:1.9.5',
            'org.powermock:powermock-api-mockito:1.5',
            'org.powermock:powermock-module-junit4:1.5'

Please provide any additional information below.

Original issue reported on code.google.com by rafal...@gmail.com on 13 Apr 2013 at 4:12

GoogleCodeExporter commented 9 years ago
Forgot this: it works on java 6, it doesn't work on java 7 (jdk1.7.0_17)

Original comment by rafal...@gmail.com on 13 Apr 2013 at 4:18

GoogleCodeExporter commented 9 years ago
It turned out it's easy to fix, just add this:

@PowerMockIgnore("com.sun.net.ssl.internal.ssl.Provider")

Original comment by rafal...@gmail.com on 13 Apr 2013 at 6:58