KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > codecoverage > v2 > ant > GroboReportTaskUTest


1 /*
2  * @(#)GroboReportTaskUTest.java
3  *
4  * Copyright (C) 2004 Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  */

26
27 package net.sourceforge.groboutils.codecoverage.v2.ant;
28
29 import java.io.File JavaDoc;
30 import java.io.IOException JavaDoc;
31 import java.util.Properties JavaDoc;
32
33 import junit.framework.Test;
34 import junit.framework.TestSuite;
35 import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
36
37
38 /**
39  * Tests the GroboReportTask class.
40  *
41  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
42  * @version $Date: 2004/04/15 05:48:27 $
43  * @since March 13, 2004
44  */

45 public class GroboReportTaskUTest extends AntTestA
46 {
47     //-------------------------------------------------------------------------
48
// Standard JUnit Class-specific declarations
49

50     private static final Class JavaDoc THIS_CLASS = GroboReportTaskUTest.class;
51     private static final AutoDoc DOC = new AutoDoc( THIS_CLASS );
52     
53     public GroboReportTaskUTest( String JavaDoc name )
54     {
55         super( name );
56     }
57
58
59     //-------------------------------------------------------------------------
60
// Tests
61

62     //...........................
63
// Tests that pass
64

65     public void testReport1()
66     {
67         executeTarget( "report-1" );
68     }
69     
70     public void testReport2()
71     {
72         executeTarget( "report-2" );
73     }
74     
75     public void testReport3()
76     {
77         try
78         {
79             executeTarget( "report-3" );
80         }
81         finally
82         {
83             System.out.println( getFullLog() );
84         }
85     }
86     
87     public void testReport4()
88     {
89         executeTarget( "report-4" );
90     }
91     
92     
93     //...........................
94
// Tests that fail
95

96     
97     public void testFReport1()
98     {
99         expectBuildExceptionContaining( "f-report-1",
100             "Did not fail for no destdir attribute.",
101             "Must set the 'destdir' attribute." );
102     }
103     
104     
105     //-------------------------------------------------------------------------
106
// Helpers
107

108     
109     protected void assertEquals( String JavaDoc text, Properties JavaDoc expected,
110             Properties JavaDoc actual )
111     {
112         PropertyCheckUtil.assertEquals( text, expected, actual );
113     }
114     
115
116     protected Properties JavaDoc loadGroboProperties()
117             throws IOException JavaDoc
118     {
119         return loadProperties(
120             (new File JavaDoc( getCoverageDir(),
121                 "classes" + File.separator + "grobocoverage.properties")).
122             getAbsolutePath() );
123     }
124     
125     
126     protected Properties JavaDoc loadProperties( String JavaDoc file )
127             throws IOException JavaDoc
128     {
129         return PropertyCheckUtil.loadProperties( file );
130     }
131     
132     
133     protected File JavaDoc getCoverageDir()
134     {
135         return new File JavaDoc( getProjectDir(), "instrument" +
136             File.separator + "coverage" );
137     }
138     
139     
140     //-------------------------------------------------------------------------
141
// Standard JUnit declarations
142

143     
144     public static Test suite()
145     {
146         TestSuite suite = new TestSuite( THIS_CLASS );
147         
148         return suite;
149     }
150     
151     public static void main( String JavaDoc[] args )
152     {
153         String JavaDoc[] name = { THIS_CLASS.getName() };
154         
155         // junit.textui.TestRunner.main( name );
156
// junit.swingui.TestRunner.main( name );
157

158         junit.textui.TestRunner.main( name );
159     }
160     
161     
162     /**
163      *
164      * @exception Exception thrown under any exceptional condition.
165      */

166     protected void setUp() throws Exception JavaDoc
167     {
168         super.setUp();
169         
170         // set ourself up
171
configureProject( "report.xml" );
172     }
173     
174     
175     /**
176      *
177      * @exception Exception thrown under any exceptional condition.
178      */

179     protected void tearDown() throws Exception JavaDoc
180     {
181         // tear ourself down
182
executeTarget( "test-teardown" );
183         
184         super.tearDown();
185     }
186 }
187
188
Popular Tags