-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#704 PowerMockito 1.6.5 throws java.lang.SecurityException signer inf…
…ormation mismatch (#712) Pass protection domain for mocked classes
- Loading branch information
1 parent
85d8d11
commit ed7029a
Showing
5 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...t4/src/test/java/samples/powermockito/junit4/bugs/github704/PrepareForTestSignedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package samples.powermockito.junit4.bugs.github704; | ||
|
||
import org.eclipse.core.runtime.FileLocator; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.powermock.core.classloader.annotations.PrepareForTest; | ||
import org.powermock.modules.junit4.PowerMockRunner; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.powermock.api.mockito.PowerMockito.mock; | ||
import static org.powermock.api.mockito.PowerMockito.mockStatic; | ||
import static org.powermock.api.mockito.PowerMockito.when; | ||
|
||
@RunWith(PowerMockRunner.class) | ||
@PrepareForTest({SomeClassUseSignedClasses.class, FileLocator.class}) | ||
public class PrepareForTestSignedTest { | ||
|
||
@Test | ||
public void shouldBeAbleMockSignedClasses(){ | ||
FileLocator fileLocator = mock(FileLocator.class); | ||
|
||
mockStatic(SomeClassUseSignedClasses.class); | ||
|
||
when(SomeClassUseSignedClasses.getFileLocator()).thenReturn(fileLocator); | ||
|
||
assertThat(SomeClassUseSignedClasses.getFileLocator()).isNotNull(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...4/src/test/java/samples/powermockito/junit4/bugs/github704/SomeClassUseSignedClasses.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package samples.powermockito.junit4.bugs.github704; | ||
|
||
import org.eclipse.core.runtime.FileLocator; | ||
|
||
public class SomeClassUseSignedClasses { | ||
|
||
public static FileLocator getFileLocator(){ | ||
return null; | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...mockito/junit4/src/test/java/samples/powermockito/junit4/bugs/github704/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* PowerMockito 1.6.5 throws java.lang.SecurityException signer information mismatch if in the PrepareForTest annotation affects also classes which have signatures | ||
* https://github.com/jayway/powermock/issues/704 | ||
*/ | ||
package samples.powermockito.junit4.bugs.github704; |