1 26 27 package net.sourceforge.groboutils.codecoverage.v2.logger; 28 29 import java.io.File ; 30 31 import junit.framework.Test; 32 import junit.framework.TestCase; 33 import junit.framework.TestSuite; 34 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 35 import net.sourceforge.groboutils.codecoverage.v2.CCCreatorUtil; 36 37 38 45 public class DirectoryChannelLoggerUTest extends TestCase 46 { 47 50 private static final Class THIS_CLASS = DirectoryChannelLoggerUTest.class; 51 private static final AutoDoc DOC = new AutoDoc( THIS_CLASS ); 52 53 public DirectoryChannelLoggerUTest( String name ) 54 { 55 super( name ); 56 } 57 58 59 62 63 public void testConstructor1() 64 { 65 new DirectoryChannelLogger( null ); 66 } 67 68 69 public void testNullDir1() 70 { 71 DirectoryChannelLogger dcl = new DirectoryChannelLogger( null ); 72 short a = (short)1; 73 dcl.cover( "a", a, a ); 74 dcl.cover( "b", a, a ); 75 dcl.cover( "c", a, a ); 76 } 77 78 79 public void testCreateFile1() 80 { 81 File basedir = CCCreatorUtil.createNewDirectory(); 83 File otherDir = new File ( basedir, "1" ); 84 otherDir = new File ( otherDir, "2" ); 85 DirectoryChannelLogger dcl = new DirectoryChannelLogger( otherDir ); 86 dcl.cover( "a", (short)1, (short)1 ); 87 File outputFile = new File ( otherDir, "a.class.log" ); 88 assertTrue( 89 "Incorrectly was able to create output file.", 90 !outputFile.exists() ); 91 } 92 93 94 public void testCreateFile2() 95 { 96 File basedir = CCCreatorUtil.createNewDirectory(); 98 DirectoryChannelLogger dcl = new DirectoryChannelLogger( basedir ); 99 dcl.cover( "a", (short)1, (short)1 ); 100 File outputFile = new File ( basedir, "a.class.log" ); 101 assertTrue( 102 "Did not create output file.", 103 outputFile.exists() ); 104 } 105 106 107 public void testCreateFile3() 108 { 109 File basedir = CCCreatorUtil.createNewDirectory(); 111 File otherDir = new File ( basedir, "1" ); 112 DirectoryChannelLogger dcl = new DirectoryChannelLogger( otherDir ); 113 dcl.cover( "a", (short)1, (short)1 ); 114 File outputFile = new File ( otherDir, "a.class.log" ); 115 assertTrue( 116 "Did not create output file.", 117 outputFile.exists() ); 118 } 119 120 121 public void testCreateCoverString1() 122 { 123 assertEquals( 124 "Didn't convert right", 125 "0001 0004\n", 126 coverString( 0x1, 0x4 ) ); 127 } 128 129 130 public void testCreateCoverString2() 131 { 132 assertEquals( 133 "Didn't convert right", 134 "0030 FFDD\n", 135 coverString( 0x30, 0xFFDD ) ); 136 } 137 138 139 public void testCreateCoverString3() 140 { 141 assertEquals( 142 "Didn't convert right", 143 "0000 0000\n", 144 coverString( 0x0, 0x0 ) ); 145 } 146 147 148 151 152 protected String coverString( int a, int b ) 153 { 154 char c[] = DirectoryChannelLogger.createCoverString( 155 (short)a, (short)b ); 156 return new String ( c ); 157 } 158 159 160 161 164 165 public static Test suite() 166 { 167 TestSuite suite = new TestSuite( THIS_CLASS ); 168 169 return suite; 170 } 171 172 public static void main( String [] args ) 173 { 174 String [] name = { THIS_CLASS.getName() }; 175 176 179 junit.textui.TestRunner.main( name ); 180 } 181 182 183 187 protected void setUp() throws Exception 188 { 189 super.setUp(); 190 191 192 } 194 195 196 200 protected void tearDown() throws Exception 201 { 202 204 205 super.tearDown(); 206 } 207 } 208 209 | Popular Tags |