2323import java .io .PrintStream ;
2424import java .util .ArrayList ;
2525import java .util .Arrays ;
26+ import java .util .Collections ;
2627import java .util .List ;
2728
2829import org .junit .Test ;
@@ -50,7 +51,7 @@ public void testMultipleWithSameCause() {
5051 Throwable e1 = new Throwable ("1" , rootCause );
5152 Throwable e2 = new Throwable ("2" , rootCause );
5253 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 ));
5455
5556 System .err .println ("----------------------------- print composite stacktrace" );
5657 ce .printStackTrace ();
@@ -174,7 +175,7 @@ public void testNullCollection() {
174175 }
175176 @ Test
176177 public void testNullElement () {
177- CompositeException composite = new CompositeException (Arrays . asList ((Throwable )null ));
178+ CompositeException composite = new CompositeException (Collections . singletonList ((Throwable ) null ));
178179 composite .getCause ();
179180 composite .printStackTrace ();
180181 }
@@ -220,4 +221,16 @@ public synchronized Throwable initCause(Throwable cause) {
220221 System .err .println ("----------------------------- print cause stacktrace" );
221222 cex .getCause ().printStackTrace ();
222223 }
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+ }
223236}
0 commit comments