1 26 27 package net.sourceforge.groboutils.codecoverage.v2.ant; 28 29 30 import java.io.File ; 31 import java.io.IOException ; 32 import java.util.Properties ; 33 34 import junit.framework.Test; 35 import junit.framework.TestSuite; 36 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 37 38 39 46 public class CoveragePostCompilerTaskUTest extends AntTestA 47 { 48 51 private static final Class THIS_CLASS = CoveragePostCompilerTaskUTest.class; 52 private static final AutoDoc DOC = new AutoDoc( THIS_CLASS ); 53 54 public CoveragePostCompilerTaskUTest( String name ) 55 { 56 super( name ); 57 } 58 59 60 63 64 private static final Properties EXPECTED_1 = new Properties (); 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 72 { 73 CoveragePostCompilerTask.Configuration c = 74 new CoveragePostCompilerTask.Configuration(); 75 addTempFile( new File ( "./grobocoverage.properties" ) ); 76 c.generatePropertyFile( new File ("."), 16 ); 77 Properties actual = loadGroboProperties(); 78 assertEquals( "default values weren't set right", 79 EXPECTED_1, 80 actual ); 81 } 82 83 84 private static final Properties EXPECTED_2 = new Properties (); 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 93 { 94 DOC.getIT().testsIssue( 903797 ); 95 96 CoveragePostCompilerTask.Configuration c = 97 new CoveragePostCompilerTask.Configuration(); 98 c.setCacheSize( 333 ); 99 100 addTempFile( new File ( "./grobocoverage.properties" ) ); 101 c.generatePropertyFile( new File ("."), 17 ); 102 Properties actual = loadGroboProperties(); 103 assertEquals( "cache-size set values weren't set right", 104 EXPECTED_2, 105 actual ); 106 } 107 108 109 110 113 114 protected void assertEquals( String text, Properties expected, 115 Properties actual ) 116 { 117 PropertyCheckUtil.assertEquals( text, expected, actual ); 118 } 119 120 121 protected Properties loadGroboProperties() 122 throws IOException 123 { 124 return PropertyCheckUtil.loadGroboProperties(); 125 } 126 127 128 protected Properties loadProperties( String file ) 129 throws IOException 130 { 131 return PropertyCheckUtil.loadProperties( file ); 132 } 133 134 135 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 [] args ) 147 { 148 String [] name = { THIS_CLASS.getName() }; 149 150 153 junit.textui.TestRunner.main( name ); 154 } 155 156 157 161 protected void setUp() throws Exception 162 { 163 super.setUp(); 164 165 configureProject( "postcompiler.xml" ); 167 } 168 169 170 174 protected void tearDown() throws Exception 175 { 176 178 179 super.tearDown(); 180 } 181 } 182 183 | Popular Tags |