Skip to content

Commit

Permalink
Test System Rules with OpenJDK 10
Browse files Browse the repository at this point in the history
Ensure that System Rules works with JDK 10. JDK 10 removed the method
"getInCheck" from SecurityManager. Therefore the test for the method
"getInCheck" is ignored when testing System Rules with JDK 10 or newer.
  • Loading branch information
stefanbirkner committed Nov 21, 2018
1 parent f4782eb commit b319ac4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ addons:
packages:
- openjdk-6-jdk
jdk:
- openjdk10
- oraclejdk9
- oraclejdk8
- openjdk7
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ System Rules supports [Travis CI](https://travis-ci.org/) (Linux) and
[AppVeyor](http://www.appveyor.com/) (Windows) for continuous
integration. Your pull request will be automatically build by both CI
servers. On Travis CI we build your pull request with OpenJDK 6 and run test
with different JDKs (Java 6 to 9).
with different JDKs (Java 6 to 10).


## Release Guide
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>system-rules</artifactId>
<version>1.19.0</version>
<version>1.20.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>System Rules</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.github.stefanbirkner.fishbowl.Fishbowl.exceptionThrownBy;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockingDetails;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -209,6 +210,8 @@ public static class with_original_SecurityManager {

@Test
public void getInCheck_is_delegated_to_original_security_manager() {
//method "getInCheck" was removed in JDK 10
skipOnJavaGreaterThan9();
when(originalSecurityManager.getInCheck()).thenReturn(true);
assertThat(managerWithOriginal.getInCheck()).isTrue();
}
Expand All @@ -233,6 +236,13 @@ public void thread_group_of_original_security_manager_is_provided() {
when(originalSecurityManager.getThreadGroup()).thenReturn(threadGroup);
assertThat(managerWithOriginal.getThreadGroup()).isSameAs(threadGroup);
}

private void skipOnJavaGreaterThan9() {
String version = System.getProperty("java.version");
assumeTrue(
version.startsWith("1.") || version.equals("9")
);
}
}

public static class without_original_SecurityManager {
Expand Down

0 comments on commit b319ac4

Please sign in to comment.