KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > test > integration > TestListenerImpl


1 package org.sapia.ubik.rmi.test.integration;
2
3 import junit.framework.AssertionFailedError;
4 import junit.framework.Test;
5 import junit.framework.TestListener;
6
7 import java.util.ArrayList JavaDoc;
8 import java.util.List JavaDoc;
9
10
11 /**
12  * @author Yanick Duchesne
13  *
14  * <dl>
15  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
16  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
17  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
18  * </dl>
19  */

20 public class TestListenerImpl implements TestListener {
21   public List JavaDoc errors = new ArrayList JavaDoc();
22   public List JavaDoc failures = new ArrayList JavaDoc();
23
24   /**
25    * @see junit.framework.TestListener#addError(junit.framework.Test, java.lang.Throwable)
26    */

27   public void addError(Test arg0, Throwable JavaDoc arg1) {
28     arg1.printStackTrace(System.out);
29     errors.add(arg1);
30   }
31
32   /**
33    * @see junit.framework.TestListener#addFailure(junit.framework.Test, junit.framework.AssertionFailedError)
34    */

35   public void addFailure(Test arg0, AssertionFailedError arg1) {
36     arg1.printStackTrace(System.out);
37     failures.add(arg1);
38   }
39
40   /**
41    * @see junit.framework.TestListener#startTest(junit.framework.Test)
42    */

43   public void startTest(Test arg0) {
44     System.out.println("========> " + arg0.toString());
45   }
46
47   /**
48    * @see junit.framework.TestListener#endTest(junit.framework.Test)
49    */

50   public void endTest(Test arg0) {
51     System.out.println(" ... SUCCESSFUL ...");
52   }
53
54   public void throwExc() throws Exception JavaDoc {
55     if (errors.size() > 0) {
56       throw (Exception JavaDoc) errors.get(0);
57     } else if (failures.size() > 0) {
58       throw (AssertionFailedError) failures.get(0);
59     }
60   }
61 }
62
Popular Tags