@@ -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