1 26 27 package net.sourceforge.groboutils.codecoverage.v2.ant; 28 29 30 import junit.framework.Test; 31 import junit.framework.TestSuite; 32 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 33 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule; 34 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModuleUTestI; 35 import net.sourceforge.groboutils.codecoverage.v2.module.LineCountMeasure; 36 import net.sourceforge.groboutils.junit.v1.SubTestTestCase; 37 import net.sourceforge.groboutils.junit.v1.iftc.CxFactory; 38 import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestSuite; 39 40 import org.apache.tools.ant.BuildException; 41 42 43 50 public class AnalysisModuleTypeUTest extends SubTestTestCase 51 { 52 55 private static final Class THIS_CLASS = AnalysisModuleTypeUTest.class; 56 private static final AutoDoc DOC = new AutoDoc( THIS_CLASS ); 57 58 public AnalysisModuleTypeUTest( String name ) 59 { 60 super( name ); 61 } 62 63 64 67 public void testSetName1() 68 { 69 AnalysisModuleType atm = createAnalysisModuleType(); 70 71 atm.setName( null ); 72 } 73 74 75 76 public void testCreateModule1() 77 { 78 AnalysisModuleType atm = createAnalysisModuleType(); 79 try 80 { 81 atm.getAnalysisModule(); 82 fail( "Did not throw BuildException." ); 83 } 84 catch (BuildException be) 85 { 86 } 88 } 89 90 public void testCreateModule2() 91 { 92 AnalysisModuleType atm = createAnalysisModuleType(); 93 atm.setName( null ); 94 try 95 { 96 atm.getAnalysisModule(); 97 fail( "Did not throw BuildException." ); 98 } 99 catch (BuildException be) 100 { 101 } 103 } 104 105 public void testCreateModule3() 106 { 107 AnalysisModuleType atm = createAnalysisModuleType(); 108 atm.setName( "" ); 109 try 110 { 111 atm.getAnalysisModule(); 112 fail( "Did not throw BuildException." ); 113 } 114 catch (BuildException be) 115 { 116 } 118 } 119 120 121 public void testCreateModule4() 122 { 123 AnalysisModuleType atm = createAnalysisModuleType(); 124 atm.setName( "line" ); 125 IAnalysisModule am = atm.getAnalysisModule(); 126 assertNotNull( 127 "returned null module.", 128 am ); 129 assertTrue( 130 "Not a LineCountMeasure module.", 131 am instanceof LineCountMeasure ); 132 addAnalysisModuleTest( am, "CreateModule4" ); 133 } 134 135 136 public void testCreateModule5() 137 { 138 AnalysisModuleType atm = createAnalysisModuleType(); 139 atm.setName( "linecount" ); 140 IAnalysisModule am = atm.getAnalysisModule(); 141 assertNotNull( 142 "returned null module.", 143 am ); 144 assertTrue( 145 "Not a LineCountMeasure module.", 146 am instanceof LineCountMeasure ); 147 addAnalysisModuleTest( am, "CreateModule5" ); 148 } 149 150 151 154 155 protected AnalysisModuleType createAnalysisModuleType() 156 { 157 return new AnalysisModuleType(); 158 } 159 160 161 protected void addAnalysisModuleTest( final IAnalysisModule am, 162 String testName ) 163 { 164 InterfaceTestSuite its = IAnalysisModuleUTestI.suite(); 165 its.addFactory( new CxFactory( testName ) { 166 public Object createImplObject() throws Exception 167 { 168 return am; 169 } 170 } ); 171 addSubTest( its ); 172 } 173 174 175 176 179 180 public static Test suite() 181 { 182 TestSuite suite = new TestSuite( THIS_CLASS ); 183 184 return suite; 185 } 186 187 public static void main( String [] args ) 188 { 189 String [] name = { THIS_CLASS.getName() }; 190 191 194 junit.textui.TestRunner.main( name ); 195 } 196 197 198 202 protected void setUp() throws Exception 203 { 204 super.setUp(); 205 206 } 208 209 210 214 protected void tearDown() throws Exception 215 { 216 218 219 super.tearDown(); 220 } 221 } 222 223 | Popular Tags |