1 package net.sourceforge.ejtools.management.test; 2 3 import junit.framework.AssertionFailedError; 4 import junit.framework.Test; 5 6 import org.apache.log4j.Category; 7 8 16 public class Log4jFormatter implements Formatter 17 { 18 protected int[] counters = new int[4]; 19 20 private static Category logger = Category.getInstance(Log4jFormatter.class); 21 22 25 public Log4jFormatter() 26 { 27 super(); 28 } 29 30 33 public void setName(String name) 34 { 35 } 36 37 40 public void addProperty(String key, Object value) 41 { 42 } 43 44 47 public void addResult(String message, int status) 48 { 49 } 50 51 54 public long getPercentage() 55 { 56 return 0; 57 } 58 59 62 public void addAssert(Test arg0, String arg1, boolean arg2) 63 { 64 logger.debug("[ ASSERT] (" + arg0 + ") " + arg1 + " = " + arg2); 65 if (arg2) { 66 counters[Formatter.PASSED]++; 67 } 68 } 69 70 73 public void addError(Test arg0, Throwable arg1) 74 { 75 logger.debug("[ ERROR ] (" + arg0 + ") " + arg1.getMessage()); 76 counters[Formatter.ERROR]++; 77 } 78 79 82 public void addFailure(Test arg0, AssertionFailedError arg1) 83 { 84 logger.debug("[FAILURE] (" + arg0 + ") " + arg1.getMessage()); 85 counters[Formatter.FAILED]++; 86 } 87 88 91 public void endTest(Test arg0) 92 { 93 long total = counters[Formatter.ERROR] + counters[Formatter.FAILED] + counters[Formatter.PASSED]; 94 logger.info("Total : " + total); 95 logger.info("Passed : " + counters[Formatter.PASSED] + "/" + total); 96 logger.info("Failed : " + counters[Formatter.FAILED] + "/" + total); 97 logger.info("Errors : " + counters[Formatter.ERROR] + "/" + total); 98 logger.debug("Test is ending " + arg0); 99 } 100 101 104 public void startTest(Test arg0) 105 { 106 logger.debug("Test is starting " + arg0); 107 } 108 } 109 | Popular Tags |