Skip to content

Commit 5db08cb

Browse files
authored
Merge pull request openjdk#33 from stefanbirkner/system-lambda
Use System Lambda instead of System Rules
2 parents 76ce5a1 + cdd1cf1 commit 5db08cb

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
</dependency>
6868
<dependency>
6969
<groupId>com.github.stefanbirkner</groupId>
70-
<artifactId>system-rules</artifactId>
71-
<version>1.19.0</version>
70+
<artifactId>system-lambda</artifactId>
71+
<version>1.0.0</version>
7272
</dependency>
7373
<dependency>
7474
<groupId>org.hamcrest</groupId>
@@ -90,7 +90,7 @@
9090
</dependency>
9191
<dependency>
9292
<groupId>com.github.stefanbirkner</groupId>
93-
<artifactId>system-rules</artifactId>
93+
<artifactId>system-lambda</artifactId>
9494
</dependency>
9595
<dependency>
9696
<groupId>org.hamcrest</groupId>
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.amazon.corretto.benchmark.heapothesys;
22

3-
import org.junit.Rule;
43
import org.junit.Test;
5-
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
4+
5+
import static com.github.stefanbirkner.systemlambda.SystemLambda.catchSystemExit;
6+
import static org.hamcrest.MatcherAssert.assertThat;
7+
import static org.hamcrest.Matchers.is;
68

79
public class HypothesysTest {
8-
@Rule
9-
public final ExpectedSystemExit exit = ExpectedSystemExit.none();
1010

1111
@Test
1212
public void SimpleRunTest() {
@@ -19,8 +19,9 @@ public void DefaultRunTypeTest() {
1919
}
2020

2121
@Test
22-
public void UnknownRunTypeTest() {
23-
exit.expectSystemExitWithStatus(1);
24-
Heapothesys.main(new String[]{"-u", "unknown", "-a", "5"});
22+
public void UnknownRunTypeTest() throws Exception {
23+
int status = catchSystemExit(
24+
() -> Heapothesys.main(new String[]{"-u", "unknown", "-a", "5"}));
25+
assertThat(status, is(1));
2526
}
2627
}

src/test/java/com/amazon/corretto/benchmark/heapothesys/SimpleRunConfigTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.amazon.corretto.benchmark.heapothesys;
22

3-
import org.junit.Rule;
43
import org.junit.Test;
4+
5+
import static com.github.stefanbirkner.systemlambda.SystemLambda.catchSystemExit;
56
import static org.hamcrest.CoreMatchers.is;
67
import static org.junit.Assert.*;
7-
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
88

99
public class SimpleRunConfigTest {
1010
@Test
@@ -66,13 +66,11 @@ public void StringArgsTest() {
6666
assertFalse(config.isUseCompressedOops());
6767
}
6868

69-
@Rule
70-
public final ExpectedSystemExit exit = ExpectedSystemExit.none();
71-
7269
@Test
73-
public void UnknownParameterShouldExitTest() {
74-
exit.expectSystemExitWithStatus(1);
70+
public void UnknownParameterShouldExitTest() throws Exception {
71+
int status = catchSystemExit(
72+
() -> new SimpleRunConfig(new String[]{"-w", "who"}));
7573

76-
final SimpleRunConfig config = new SimpleRunConfig(new String[]{"-w", "who"});
74+
assertThat(status, is(1));
7775
}
7876
}

src/test/java/com/amazon/corretto/benchmark/heapothesys/SimpleRunnerTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
package com.amazon.corretto.benchmark.heapothesys;
22

3-
import org.junit.Rule;
43
import org.junit.Test;
5-
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
64

75
public class SimpleRunnerTest {
8-
@Rule
9-
public final ExpectedSystemExit exit = ExpectedSystemExit.none();
106

117
@Test
128
public void DefaultRunTest() {

0 commit comments

Comments
 (0)