Skip to content

Commit dafe3cb

Browse files
Formatting
1 parent 847e881 commit dafe3cb

4 files changed

Lines changed: 35 additions & 14 deletions

File tree

‎java-checks-common/src/test/java/org/sonar/java/checks/helpers/JParserTestUtils.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
package org.sonar.java.checks.helpers;
1818

1919
import com.google.common.io.Files;
20-
2120
import java.io.File;
2221
import java.nio.charset.StandardCharsets;
2322
import java.util.Arrays;
2423
import java.util.List;
2524
import java.util.stream.Collectors;
26-
2725
import org.sonar.java.model.FrontendParser;
2826
import org.sonar.java.model.JParserConfig;
2927
import org.sonar.java.test.TestResourceScope;

‎java-checks-common/src/test/java/org/sonar/java/checks/helpers/ReassignmentFinderTest.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.lang.reflect.Constructor;
2020
import java.util.List;
21-
2221
import org.junit.jupiter.api.Test;
2322
import org.sonar.java.test.TestResourceScope;
2423
import org.sonar.plugins.java.api.semantic.Symbol;

‎java-checks-test-sources/test-classpath-reader/src/main/java/org/sonar/java/test/TestResourceScope.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
import org.junit.jupiter.api.parallel.Execution;
3131
import org.junit.jupiter.api.parallel.ExecutionMode;
3232

33-
/** Retains lazy fixtures through instance initialization, nested tests and all assertions in a test class. */
33+
/**
34+
* Retains lazy fixtures through instance initialization, nested tests and all assertions in a test class.
35+
*/
3436
public final class TestResourceScope implements BeforeAllCallback, AfterAllCallback {
3537

3638
private static final ThreadLocal<Deque<Scope>> SCOPES = ThreadLocal.withInitial(ArrayDeque::new);
@@ -85,7 +87,9 @@ public static final class Scope implements AutoCloseable {
8587
private Scope() {
8688
}
8789

88-
/** Attempts every fixture even after errors, then rethrows the first failure with later failures suppressed. */
90+
/**
91+
* Attempts every fixture even after errors, then rethrows the first failure with later failures suppressed.
92+
*/
8993
@Override
9094
public void close() throws Exception {
9195
if (closed) {

‎java-checks-test-sources/test-classpath-reader/src/test/java/org/sonar/java/test/TestResourceScopeTest.java‎

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ void scope_closes_every_resource_in_reverse_order_even_when_cleanup_fails() thro
4646
IllegalStateException first = new IllegalStateException("first");
4747
Exception second = new Exception("second");
4848
TestResourceScope.retain(() -> calls.add("last"));
49-
TestResourceScope.retain(() -> { calls.add("second"); throw second; });
50-
TestResourceScope.retain(() -> { calls.add("first"); throw first; });
49+
TestResourceScope.retain(() -> {
50+
calls.add("second");
51+
throw second;
52+
});
53+
TestResourceScope.retain(() -> {
54+
calls.add("first");
55+
throw first;
56+
});
5157
assertThatThrownBy(scope::close).isSameAs(first).hasSuppressedException(second);
5258
scope.close();
5359
assertThat(calls).containsExactly("first", "second", "last");
@@ -59,9 +65,13 @@ void scope_cleanup_attempts_every_resource_and_suppresses_errors() throws Except
5965
List<String> calls = new ArrayList<>();
6066
AssertionError failure = new AssertionError("cleanup");
6167
TestResourceScope.retain(() -> calls.add("last"));
62-
TestResourceScope.retain(() -> { throw failure; });
68+
TestResourceScope.retain(() -> {
69+
throw failure;
70+
});
6371
Exception first = new Exception("first");
64-
TestResourceScope.retain(() -> { throw first; });
72+
TestResourceScope.retain(() -> {
73+
throw first;
74+
});
6575

6676
assertThatThrownBy(scope::close).isSameAs(first).hasSuppressedException(failure);
6777
scope.close();
@@ -79,9 +89,15 @@ void scope_cleanup_rethrows_first_error_after_attempting_every_resource() throws
7989
AssertionError first = new AssertionError("first");
8090
Exception second = new Exception("second");
8191
TestResourceScope.retain(() -> calls.add("last"));
82-
TestResourceScope.retain(() -> { throw second; });
83-
TestResourceScope.retain(() -> { throw first; });
84-
TestResourceScope.retain(() -> { throw first; });
92+
TestResourceScope.retain(() -> {
93+
throw second;
94+
});
95+
TestResourceScope.retain(() -> {
96+
throw first;
97+
});
98+
TestResourceScope.retain(() -> {
99+
throw first;
100+
});
85101

86102
assertThatThrownBy(scope::close).isSameAs(first).hasSuppressedException(second);
87103
scope.close();
@@ -99,7 +115,9 @@ void missing_scope_fails_loudly_and_closes_the_unretained_fixture() {
99115
@Test
100116
void missing_scope_preserves_cleanup_exceptions_as_suppressed() {
101117
Exception failure = new Exception("cleanup failed");
102-
assertThatThrownBy(() -> TestResourceScope.retain(() -> { throw failure; }))
118+
assertThatThrownBy(() -> TestResourceScope.retain(() -> {
119+
throw failure;
120+
}))
103121
.isInstanceOf(IllegalStateException.class)
104122
.hasMessageContaining("@TestResourceScope.Scoped")
105123
.hasSuppressedException(failure);
@@ -108,7 +126,9 @@ void missing_scope_preserves_cleanup_exceptions_as_suppressed() {
108126
@Test
109127
void missing_scope_propagates_cleanup_errors() {
110128
AssertionError failure = new AssertionError("cleanup failed");
111-
assertThatThrownBy(() -> TestResourceScope.retain(() -> { throw failure; }))
129+
assertThatThrownBy(() -> TestResourceScope.retain(() -> {
130+
throw failure;
131+
}))
112132
.isSameAs(failure);
113133
}
114134
}

0 commit comments

Comments
 (0)