KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)CoveragePostCompilerTaskUTest.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
30 import java.io.File JavaDoc;
31 import java.io.IOException JavaDoc;
32 import java.util.Properties JavaDoc;
33
34 import junit.framework.Test;
35 import junit.framework.TestSuite;
36 import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
37
38
39 /**
40  * Tests the CoveragePostCompilerTask class.
41  *
42  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
43  * @version $Date: 2004/04/15 05:48:27 $
44  * @since February 25, 2004
45  */

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

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

63     
64     private static final Properties JavaDoc EXPECTED_1 = new Properties JavaDoc();
65     static {
66         EXPECTED_1.setProperty( "factory",
67             "net.sourceforge.groboutils.codecoverage.v2.logger.DirectoryChannelLoggerFactory" );
68         EXPECTED_1.setProperty( "channel-count", "16" );
69     }
70     public void testConfiguration1()
71             throws IOException JavaDoc
72     {
73         CoveragePostCompilerTask.Configuration c =
74             new CoveragePostCompilerTask.Configuration();
75         addTempFile( new File JavaDoc( "./grobocoverage.properties" ) );
76         c.generatePropertyFile( new File JavaDoc("."), 16 );
77         Properties JavaDoc actual = loadGroboProperties();
78         assertEquals( "default values weren't set right",
79             EXPECTED_1,
80             actual );
81     }
82     
83     
84     private static final Properties JavaDoc EXPECTED_2 = new Properties JavaDoc();
85     static {
86         EXPECTED_2.setProperty( "factory",
87             "net.sourceforge.groboutils.codecoverage.v2.logger.DirectoryChannelLoggerFactory" );
88         EXPECTED_2.setProperty( "channel-count", "17" );
89         EXPECTED_2.setProperty( "logger.cache-size", "333" );
90     }
91     public void testConfiguration2()
92             throws IOException JavaDoc
93     {
94         DOC.getIT().testsIssue( 903797 );
95         
96         CoveragePostCompilerTask.Configuration c =
97             new CoveragePostCompilerTask.Configuration();
98         c.setCacheSize( 333 );
99         
100         addTempFile( new File JavaDoc( "./grobocoverage.properties" ) );
101         c.generatePropertyFile( new File JavaDoc("."), 17 );
102         Properties JavaDoc actual = loadGroboProperties();
103         assertEquals( "cache-size set values weren't set right",
104             EXPECTED_2,
105             actual );
106     }
107     
108     
109     
110     //-------------------------------------------------------------------------
111
// Helpers
112

113     
114     protected void assertEquals( String JavaDoc text, Properties JavaDoc expected,
115             Properties JavaDoc actual )
116     {
117         PropertyCheckUtil.assertEquals( text, expected, actual );
118     }
119     
120
121     protected Properties JavaDoc loadGroboProperties()
122             throws IOException JavaDoc
123     {
124         return PropertyCheckUtil.loadGroboProperties();
125     }
126     
127     
128     protected Properties JavaDoc loadProperties( String JavaDoc file )
129             throws IOException JavaDoc
130     {
131         return PropertyCheckUtil.loadProperties( file );
132     }
133     
134     
135     //-------------------------------------------------------------------------
136
// Standard JUnit declarations
137

138     
139     public static Test suite()
140     {
141         TestSuite suite = new TestSuite( THIS_CLASS );
142         
143         return suite;
144     }
145     
146     public static void main( String JavaDoc[] args )
147     {
148         String JavaDoc[] name = { THIS_CLASS.getName() };
149         
150         // junit.textui.TestRunner.main( name );
151
// junit.swingui.TestRunner.main( name );
152

153         junit.textui.TestRunner.main( name );
154     }
155     
156     
157     /**
158      *
159      * @exception Exception thrown under any exceptional condition.
160      */

161     protected void setUp() throws Exception JavaDoc
162     {
163         super.setUp();
164         
165         // set ourself up
166
configureProject( "postcompiler.xml" );
167     }
168     
169     
170     /**
171      *
172      * @exception Exception thrown under any exceptional condition.
173      */

174     protected void tearDown() throws Exception JavaDoc
175     {
176         // tear ourself down
177

178         
179         super.tearDown();
180     }
181 }
182
183
Popular Tags