27
27
import io .r2dbc .spi .R2dbcTransientResourceException ;
28
28
29
29
import org .junit .Test ;
30
-
31
30
import org .springframework .dao .ConcurrencyFailureException ;
32
31
import org .springframework .dao .DataAccessResourceFailureException ;
33
32
import org .springframework .dao .DataIntegrityViolationException ;
@@ -49,9 +48,10 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
49
48
@ Test // gh-57
50
49
public void shouldTranslateTransientResourceException () {
51
50
52
- Exception exception = translator .translate ("" , "" , new R2dbcTransientResourceException ());
51
+ Exception exception = translator .translate ("" , "" , new R2dbcTransientResourceException ("" ));
53
52
54
- assertThat (exception ).isInstanceOf (TransientDataAccessResourceException .class );
53
+ assertThat (exception )
54
+ .isInstanceOf (TransientDataAccessResourceException .class );
55
55
}
56
56
57
57
@ Test // gh-57
@@ -110,5 +110,35 @@ public void shouldTranslateBadSqlGrammarException() {
110
110
assertThat (exception ).isInstanceOf (BadSqlGrammarException .class );
111
111
}
112
112
113
+ @ Test // gh-57
114
+ public void messageGeneration () {
115
+
116
+ Exception exception = translator .translate ("TASK" , "SOME-SQL" , new R2dbcTransientResourceException ("MESSAGE" ));
117
+
118
+ assertThat (exception ) //
119
+ .isInstanceOf (TransientDataAccessResourceException .class ) //
120
+ .hasMessage ("TASK; SQL [SOME-SQL]; MESSAGE; nested exception is io.r2dbc.spi.R2dbcTransientResourceException: MESSAGE" );
121
+ }
122
+
123
+ @ Test // gh-57
124
+ public void messageGenerationNullSQL () {
125
+
126
+ Exception exception = translator .translate ("TASK" , null , new R2dbcTransientResourceException ("MESSAGE" ));
127
+
128
+ assertThat (exception ) //
129
+ .isInstanceOf (TransientDataAccessResourceException .class ) //
130
+ .hasMessage ("TASK; MESSAGE; nested exception is io.r2dbc.spi.R2dbcTransientResourceException: MESSAGE" );
131
+ }
132
+
133
+ @ Test // gh-57
134
+ public void messageGenerationNullMessage () {
135
+
136
+ Exception exception = translator .translate ("TASK" , "SOME-SQL" , new R2dbcTransientResourceException ());
137
+
138
+ assertThat (exception ) //
139
+ .isInstanceOf (TransientDataAccessResourceException .class ) //
140
+ .hasMessage ("TASK; SQL [SOME-SQL]; null; nested exception is io.r2dbc.spi.R2dbcTransientResourceException" );
141
+ }
142
+
113
143
private static class MyTransientExceptions extends R2dbcException {}
114
144
}
0 commit comments