23
23
import java .io .PrintStream ;
24
24
import java .util .ArrayList ;
25
25
import java .util .Arrays ;
26
+ import java .util .Collections ;
26
27
import java .util .List ;
27
28
28
29
import org .junit .Test ;
@@ -50,7 +51,7 @@ public void testMultipleWithSameCause() {
50
51
Throwable e1 = new Throwable ("1" , rootCause );
51
52
Throwable e2 = new Throwable ("2" , rootCause );
52
53
Throwable e3 = new Throwable ("3" , rootCause );
53
- CompositeException ce = new CompositeException ("3 failures with same root cause" , Arrays .asList (e1 , e2 , e3 ));
54
+ CompositeException ce = new CompositeException (Arrays .asList (e1 , e2 , e3 ));
54
55
55
56
System .err .println ("----------------------------- print composite stacktrace" );
56
57
ce .printStackTrace ();
@@ -174,7 +175,7 @@ public void testNullCollection() {
174
175
}
175
176
@ Test
176
177
public void testNullElement () {
177
- CompositeException composite = new CompositeException (Arrays . asList ((Throwable )null ));
178
+ CompositeException composite = new CompositeException (Collections . singletonList ((Throwable ) null ));
178
179
composite .getCause ();
179
180
composite .printStackTrace ();
180
181
}
@@ -220,4 +221,16 @@ public synchronized Throwable initCause(Throwable cause) {
220
221
System .err .println ("----------------------------- print cause stacktrace" );
221
222
cex .getCause ().printStackTrace ();
222
223
}
224
+
225
+ @ Test
226
+ public void messageCollection () {
227
+ CompositeException compositeException = new CompositeException (Arrays .asList (ex1 , ex3 ));
228
+ assertEquals ("2 exceptions occurred. " , compositeException .getMessage ());
229
+ }
230
+
231
+ @ Test
232
+ public void messageVarargs () {
233
+ CompositeException compositeException = new CompositeException (ex1 , ex2 , ex3 );
234
+ assertEquals ("3 exceptions occurred. " , compositeException .getMessage ());
235
+ }
223
236
}
0 commit comments