1 /*
   2  * @bug 8003471
   3  * @test TestExceptionEvents
   4  * @build ThrowableTracer
   5  * @run main/othervm ThrowableTraceTest
   6  */
   7 public class ThrowableTraceTest {
   8     
   9     public ThrowableTraceTest() throws Exception  {
  10         ThrowableTracer t = new ThrowableTracer();
  11         ThrowableTracer.enable(t);
  12 
  13         int exceptionsToThrow = 5;
  14         int errorsToThrow = 5;
  15         
  16         for (int i = 0; i < exceptionsToThrow; i++) {
  17             try {
  18                 throw new Exception();
  19             } catch (Exception e) {
  20                 
  21             }
  22         }
  23         
  24         for (int i = 0; i < errorsToThrow; i++) {
  25             try {
  26                 throw new Error();
  27             } catch (Error e) {
  28                 
  29             }
  30         }
  31         
  32         if (t.getExceptions() < exceptionsToThrow) {
  33             throw new Exception ("Not enough errors events generated!");
  34         }
  35         
  36         if (t.getErrors() < errorsToThrow) {
  37             throw new Exception ("Not enough errors events generated!");
  38         }
  39     }
  40     
  41     public static void main(String[] args) throws Exception {
  42         new ThrowableTraceTest();
  43     }
  44 }