1 26 27 package net.sourceforge.groboutils.codecoverage.v2.logger; 28 29 import java.io.File ; 30 import java.io.FileWriter ; 31 import java.io.IOException ; 32 33 import junit.framework.Test; 34 import junit.framework.TestCase; 35 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 36 import net.sourceforge.groboutils.codecoverage.v2.CCCreatorUtil; 37 import net.sourceforge.groboutils.codecoverage.v2.IChannelLogRecord; 38 import net.sourceforge.groboutils.codecoverage.v2.IClassChannelLogReaderUTestI; 39 import net.sourceforge.groboutils.junit.v1.iftc.CxFactory; 40 import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestSuite; 41 42 43 50 public class DirectoryClassChannelLogReaderUTest extends TestCase 51 { 52 55 private static final Class THIS_CLASS = DirectoryClassChannelLogReaderUTest.class; 56 private static final AutoDoc DOC = new AutoDoc( THIS_CLASS ); 57 58 public DirectoryClassChannelLogReaderUTest( String name ) 59 { 60 super( name ); 61 } 62 63 64 67 68 public void testNextRecord1() throws Exception 69 { 70 String sig = "MySig-1"; 71 File log = new File ( CCCreatorUtil.createNewDirectory(), 72 "test.log" ); 73 FileWriter fw = new FileWriter ( log ); 74 fw.write( "1 0\n2 2\n0002 0002\n3 1\n" ); 75 fw.close(); 76 DirectoryClassChannelLogReader dcclr = 77 new DirectoryClassChannelLogReader( log, sig ); 78 IChannelLogRecord clr; 79 assertChannelLogRecord( 80 dcclr.nextRecord(), 81 sig, 1, 0 ); 82 assertChannelLogRecord( 83 dcclr.nextRecord(), 84 sig, 2, 2 ); 85 assertChannelLogRecord( 86 dcclr.nextRecord(), 87 sig, 2, 2 ); 88 assertChannelLogRecord( 89 dcclr.nextRecord(), 90 sig, 3, 1 ); 91 assertNull( 92 "Didn't return null clr.", 93 dcclr.nextRecord() ); 94 } 95 96 97 98 101 102 protected void assertChannelLogRecord( IChannelLogRecord clr, 103 String sig, int methodIndex, int markIndex ) 104 { 105 assertNotNull( 106 "Returned null record.", 107 clr ); 108 assertEquals( 109 "Didn't return correct signature.", 110 sig, 111 clr.getClassSignature() ); 112 assertEquals( 113 "Didn't return correct method index.", 114 methodIndex, 115 clr.getMethodIndex() ); 116 assertEquals( 117 "Didn't return correct mark index.", 118 markIndex, 119 clr.getMarkIndex() ); 120 } 121 122 123 124 127 128 public static Test suite() 129 { 130 InterfaceTestSuite suite = IClassChannelLogReaderUTestI.suite(); 131 suite.addTestSuite( THIS_CLASS ); 132 suite.addFactory( new CxFactory( "A" ) { 133 public Object createImplObject() throws IOException { 134 File log = new File ( CCCreatorUtil.createNewDirectory(), 135 "test.log" ); 136 FileWriter fw = new FileWriter ( log ); 137 fw.write( "1 0\n2 2\n0002 0002\n3 1\n" ); 138 fw.close(); 139 return new DirectoryClassChannelLogReader( log, "MySig-1" ); 140 } 141 } ); 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 166 } 168 169 170 174 protected void tearDown() throws Exception 175 { 176 178 179 super.tearDown(); 180 } 181 } 182 183 | Popular Tags |