KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > ejtools > management > test > ResultSinkImpl


1 package net.sourceforge.ejtools.management.test;
2
3 import java.util.Vector JavaDoc;
4
5 import junit.framework.AssertionFailedError;
6 import junit.framework.Test;
7
8 import org.apache.log4j.Category;
9
10 /**
11  * @author laurent To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To enable and disable the
12  * creation of type comments go to Window>Preferences>Java>Code Generation.
13  * @created 5 août 2002
14  */

15 public class ResultSinkImpl implements ResultSink
16 {
17    /** Description of the Field */
18    protected Vector JavaDoc errors = new Vector JavaDoc();
19    /** Description of the Field */
20    protected Vector JavaDoc failed = new Vector JavaDoc();
21    /** Description of the Field */
22    protected Vector JavaDoc passed = new Vector JavaDoc();
23    /** Description of the Field */
24    private static Category logger = Category.getInstance(ResultSinkImpl.class);
25
26
27    /**
28     * Adds a feature to the Assert attribute of the ResultSinkImpl object
29     *
30     * @param arg0 The feature to be added to the Assert attribute
31     * @param arg1 The feature to be added to the Assert attribute
32     * @param arg2 The feature to be added to the Assert attribute
33     */

34    public void addAssert(Test test, String JavaDoc message, boolean condition)
35    {
36       if (condition)
37       {
38          passed.add(message);
39       }
40       else
41       {
42          failed.add(message);
43       }
44    }
45
46
47    /**
48     * @param arg0 The feature to be added to the Error attribute
49     * @param arg1 The feature to be added to the Error attribute
50     * @see junit.framework.TestListener#addError(Test, Throwable)
51     */

52    public void addError(Test test, Throwable JavaDoc t)
53    {
54       errors.add(t.getMessage());
55    }
56
57
58    /**
59     * @param arg0 The feature to be added to the Failure attribute
60     * @param arg1 The feature to be added to the Failure attribute
61     * @see junit.framework.TestListener#addFailure(Test, AssertionFailedError)
62     */

63    public void addFailure(Test test, AssertionFailedError afe) { }
64
65
66    public void dump(){
67       logger.info("--------------------");
68       for (int i = 0; i < passed.size(); i++)
69       {
70          logger.info("[ PASSED ] " + passed.elementAt(i));
71       }
72       for (int i = 0; i < failed.size(); i++)
73       {
74          logger.info("[ FAILED ] " + failed.elementAt(i));
75       }
76       for (int i = 0; i < errors.size(); i++)
77       {
78          logger.info("[ ERROR ] " + errors.elementAt(i));
79       }
80       logger.info("--------------------");
81
82       long total = passed.size() + failed.size() + errors.size();
83       logger.info("Total : " + total);
84       logger.info("Passed : " + passed.size() + "/" + total);
85       logger.info("Failed : " + failed.size() + "/" + total);
86       logger.info("Errors : " + errors.size() + "/" + total);
87
88       logger.info("--------------------");
89    }
90
91    /**
92     * @param arg0 Description of the Parameter
93     * @see junit.framework.TestListener#endTest(Test)
94     */

95    public void endTest(Test arg0)
96    {
97    }
98
99
100    /**
101     * Gets the percentage attribute of the ResultSinkImpl object
102     *
103     * @return The percentage value
104     */

105    public long getPercentage()
106    {
107       return 0;
108    }
109
110
111    /**
112     * @param arg0 Description of the Parameter
113     * @see junit.framework.TestListener#startTest(Test)
114     */

115    public void startTest(Test arg0) { }
116 }
117
Popular Tags