1 18 package org.apache.batik.test; 19 20 30 public class SimpleTestRunner { 31 34 public static final String ERROR_CLASS_CAST = 35 "Messages.SimpleTestRuner.error.class.cast"; 36 37 public static final String ERROR_CLASS_NOT_FOUND = 38 "Messages.SimpleTestRuner.error.class.not.found"; 39 40 public static final String ERROR_INSTANTIATION = 41 "Messages.SimpleTestRunner.error.instantiation"; 42 43 public static final String ERROR_ILLEGAL_ACCESS = 44 "Messages.SimpleTestRunner.error.illegal.access"; 45 46 49 public static final String USAGE 50 = "Messages.SimpleTestRunner.usage"; 51 52 public static void main(String args[]) throws Exception { 53 if(args.length < 1){ 54 System.err.println(Messages.formatMessage(USAGE, null)); 55 System.exit(0); 56 } 57 58 String className = args[0]; 59 60 Class cl = null; 61 62 try{ 63 cl = Class.forName(className); 64 }catch(ClassNotFoundException e){ 65 System.err.println(Messages.formatMessage(ERROR_CLASS_NOT_FOUND, 66 new Object []{className, 67 e.getClass().getName(), 68 e.getMessage()})); 69 System.exit(0); 70 } 71 72 Test t = null; 73 74 try{ 75 t = (Test)cl.newInstance(); 76 }catch(ClassCastException e){ 77 System.err.println(Messages.formatMessage(ERROR_CLASS_CAST, 78 new Object []{ className, 79 e.getClass().getName(), 80 e.getMessage() 81 })); 82 System.exit(0); 83 }catch(InstantiationException e){ 84 System.err.println(Messages.formatMessage(ERROR_INSTANTIATION, 85 new Object []{ className, 86 e.getClass().getName(), 87 e.getMessage() } )); 88 System.exit(0); 89 }catch(IllegalAccessException e){ 90 System.err.println(Messages.formatMessage(ERROR_ILLEGAL_ACCESS, 91 new Object [] { className, 92 e.getClass().getName(), 93 e.getMessage() })); 94 95 System.exit(0); 96 } 97 98 99 TestReport tr = t.run(); 104 105 try{ 106 TestReportProcessor p 107 = new org.apache.batik.test.xml.XMLTestReportProcessor(); 108 109 p.processReport(tr); 110 }catch(TestException e){ 111 System.out.println(e.getClass().getName()); 112 System.out.println(e.getMessage()); 113 Exception source = e.getSourceError(); 114 if(source != null) { 115 System.out.println(source); 116 System.out.println(source.getMessage()); 117 source.printStackTrace(); 118 } 119 } 120 System.exit(1); 121 122 } 123 } 124 | Popular Tags |