1 26 27 package net.sourceforge.groboutils.codecoverage.v2.report; 28 29 import java.io.File ; 30 import java.io.IOException ; 31 32 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 33 import net.sourceforge.groboutils.codecoverage.v2.CCCreatorUtil; 34 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule; 35 import net.sourceforge.groboutils.codecoverage.v2.datastore.DirMetaDataReader; 36 import net.sourceforge.groboutils.codecoverage.v2.logger.DirectoryChannelLogReader; 37 import net.sourceforge.groboutils.junit.v1.iftc.ImplFactory; 38 import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestCase; 39 import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestSuite; 40 41 import org.w3c.dom.Element ; 42 43 44 51 public class IReportGeneratorUTestI extends InterfaceTestCase 52 { 53 56 private static final Class THIS_CLASS = IReportGeneratorUTestI.class; 57 private static final AutoDoc DOC = new AutoDoc( THIS_CLASS ); 58 59 public IReportGeneratorUTestI( String name, ImplFactory f ) 60 { 61 super( name, IReportGenerator.class, f ); 62 } 63 64 65 public IReportGenerator createIReportGenerator() 66 { 67 return (IReportGenerator)createImplObject(); 68 } 69 70 71 74 75 public void testWriteReport1() throws Exception 76 { 77 IReportGenerator rg = createIReportGenerator(); 78 79 try 80 { 81 rg.createReport( null, null ); 82 fail( "Did not throw IllegalArgumentException." ); 83 } 84 catch (IllegalArgumentException e) 85 { 86 } 88 } 89 90 91 public void testWriteReport2() throws Exception 92 { 93 IReportGenerator rg = createIReportGenerator(); 94 95 try 96 { 97 rg.createReport( createIAnalysisModule( "a", "b", "c"), null ); 98 fail( "Did not throw IllegalArgumentException." ); 99 } 100 catch (IllegalArgumentException e) 101 { 102 } 104 } 105 106 107 public void testWriteReport3() throws Exception 108 { 109 IReportGenerator rg = createIReportGenerator(); 110 111 try 112 { 113 rg.createReport( null, createAnalysisModuleData() ); 114 fail( "Did not throw IllegalArgumentException." ); 115 } 116 catch (IllegalArgumentException e) 117 { 118 } 120 } 121 122 123 public void testWriteReport4() throws Exception 124 { 125 IReportGenerator rg = createIReportGenerator(); 126 127 rg.createReport( createIAnalysisModule( "a", "b", "c"), 128 createAnalysisModuleData() ); 129 } 130 131 132 public void testWriteReport8() throws Exception 133 { 134 IReportGenerator rg = createIReportGenerator(); 135 Element el = rg.createReport( createIAnalysisModule( "a", "b", "c" ), 136 createAnalysisModuleData() ); 137 DOC.getLog().info( "Retrieved report: ["+el+"]" ); 138 assertNotNull( 139 "Didn't create an element.", 140 el ); 141 } 142 143 144 145 149 150 153 protected IAnalysisModule createIAnalysisModule( String name, String unit, 154 String mime ) 155 { 156 return CCCreatorUtil.createIAnalysisModule( name, unit, mime ); 157 } 158 159 160 166 protected AnalysisModuleData createAnalysisModuleData() throws IOException 167 { 168 IAnalysisModule am = createIAnalysisModule( "a", "b", "text/plain" ); 169 CCCreatorUtil.SimpleClassLogData[] scld = new 170 CCCreatorUtil.SimpleClassLogData[] { 171 new CCCreatorUtil.SimpleClassLogData( "a.MyClass-1138", 172 new int[] { 1,2,1 }, new int[] { 11, 2, 13 } ), 173 }; 174 File basedir = CCCreatorUtil.createNewDirectory(); 175 return CCCreatorUtil.createAnalysisModuleData( am, 176 createDirMetaDataReader( basedir ), 177 createDirectoryChannelLogReader( basedir, scld ) ); 178 } 179 180 181 protected DirMetaDataReader createDirMetaDataReader( File basedir ) 182 throws IOException 183 { 184 return CCCreatorUtil.createDirMetaDataReader( basedir, 185 new Class [] { THIS_CLASS, String .class }, 186 CCCreatorUtil.createAnalysisModules( 2 ) ); 187 } 188 189 190 protected DirectoryChannelLogReader createDirectoryChannelLogReader( 191 File basedir, CCCreatorUtil.SimpleClassLogData[] data ) 192 { 193 return CCCreatorUtil.createDirectoryChannelLogReader( basedir, data, 194 (short)100 ); 195 } 196 197 198 201 202 public static InterfaceTestSuite suite() 203 { 204 InterfaceTestSuite suite = new InterfaceTestSuite( THIS_CLASS ); 205 206 return suite; 207 } 208 209 public static void main( String [] args ) 210 { 211 String [] name = { THIS_CLASS.getName() }; 212 213 216 junit.textui.TestRunner.main( name ); 217 } 218 219 220 224 protected void setUp() throws Exception 225 { 226 super.setUp(); 227 228 } 230 231 232 236 protected void tearDown() throws Exception 237 { 238 240 241 super.tearDown(); 242 } 243 } 244 245 | Popular Tags |