1 28 29 package com.idaremedia.antx.feedback.tests; 30 31 import junit.framework.TestSuite; 32 33 import com.idaremedia.antx.ut.HTCUtils; 34 35 44 45 public final class EmitConfigureTaskTest extends EmitTestSkeleton 46 { 47 48 public static final String TEST_CATEGORY="CLASS"; 49 50 51 54 public EmitConfigureTaskTest(String methodName) 55 { 56 super("EmitConfigureTask::",methodName); 57 } 58 59 60 63 public static TestSuite suite() 64 { 65 return new TestSuite(EmitConfigureTaskTest.class); 66 } 67 68 69 72 public static TestSuite baseline() 73 { 74 return suite(); } 76 77 78 81 public static void main(String [] argv) 82 { 83 HTCUtils.quickCheck(suite()); 84 } 85 86 87 91 protected String getDefaultConfigureXMLFileName() 92 { 93 return "emitconf.xml"; 94 } 95 96 100 static final String EMITCOUNT= "EmitCount"; 101 static final String TIMESTAMP_MARKER= "Helloworld from task"; 102 static final String HELLOWORLD_MARKER= "Helloworld"; 103 static final String BYEWORLD_MARKER= "Byeworld"; 104 105 public void testEmptyOK() 106 { 107 runTarget("testEmptyOK"); 108 } 109 110 public void testDefaultEchoesToAnt_NOT() 111 { 112 String log= runTarget("testDefaultEchoesToAnt_NOT"); 113 assertFalse(log.indexOf("log4j")>=0, "Log4j-message *NOT* echoed to Ant"); 114 } 115 116 public void testDefaultFroms_NOT() 117 { 118 String log = runTarget("testDefaultFroms_NOT"); 119 verifyOccurances(log,"From: ",0); 120 } 121 122 private void verifyTimestamping(String target) 123 { 124 String today = getTodayString(); 125 println("TODAY = ("+today+")"); 126 127 String log = runEchoedTarget(target,null); 128 verifyOccurances(log,TIMESTAMP_MARKER,0); 129 130 int N= getIntegerProperty(EMITCOUNT); 131 String log4jLog = testAppender().getLog(); 132 verifyOccurances(log4jLog,TIMESTAMP_MARKER,N); 133 verifyOccurances(log4jLog,today,getIntegerProperty("TimestampCount")); 134 } 135 136 public void testDefaultTimestamping() 137 { 138 verifyTimestamping("testTimestamping"); 139 } 140 141 public void testDefaultTimestampingNested() 142 { 143 verifyTimestamping("testTimestampingNested"); 144 } 145 146 public void testDefaultNoiseLevel() 147 { 148 String log = runEchoedTarget("testNoiseLevel",null); 149 verifyOccurances(log,HELLOWORLD_MARKER,getIntegerProperty("AntLogCount")); 150 String log4jLog = testAppender().getLog(); 151 verifyOccurances(log4jLog, HELLOWORLD_MARKER, getIntegerProperty(EMITCOUNT)); 152 153 testAppender().clearLog(); 154 155 log = runEchoedTarget("testNoiseLevelNested",null); 156 verifyOccurances(log,HELLOWORLD_MARKER,getIntegerProperty("AntLogCount")); 157 log4jLog = testAppender().getLog(); 158 verifyOccurances(log4jLog, HELLOWORLD_MARKER, getIntegerProperty(EMITCOUNT)); 159 160 } 161 162 public void testUnwindingAfterFault() 163 { 164 String log = runEchoedTarget("testUnwindingAfterFault",null); 165 verifyOccurances(log,BYEWORLD_MARKER,getIntegerProperty("AntLogCount")); 166 String log4jLog= testAppender().getLog(); 167 verifyOccurances(log4jLog,BYEWORLD_MARKER,getIntegerProperty(EMITCOUNT)); 168 } 169 170 public void testDefaultFrom() 171 { 172 String log = runEchoedTarget("testEmitterPassthru"); 173 int N= getIntegerProperty(EMITCOUNT); 174 verifyOccurances(log,HELLOWORLD_MARKER,N); 175 verifyOccurances(testAppender().getLog(), HELLOWORLD_MARKER, N); 176 } 177 178 public void testBlockingInheritance() 179 { 180 String log = runEchoedTarget("testBlockingInheritance"); 181 verifyOccurances(log,"From:",1); 182 verifyOccurances(log,HELLOWORLD_MARKER,3); 183 String log4jLog = testAppender().getLog(); 184 verifyOccurances(log4jLog,"From:",2); verifyOccurances(log4jLog,HELLOWORLD_MARKER,0); } 187 188 public void testUnableToLoadBrokenConfiguration() 189 { 190 verifyCantLoadFile("broken_conf0.xml","Conflicting use of refid"); 191 } 192 193 public void testCanUseFromParallelTasks() 194 { 195 runEchoedTarget("testCanUseFromParallelTasks"); 196 } 197 198 public void testUsingDefaultsRef() 199 { 200 runEchoedTarget("testUsingDefaultsRef"); 201 String log4jLog = testAppender().getLog(); 202 verifyOccurances(log4jLog,HELLOWORLD_MARKER,3); verifyOccurances(log4jLog,"ant.version",3); 204 } 205 206 public void testTimestampFormat() 207 { 208 runEchoedTarget("testTimestampFormat",null); 209 String log4jLog = testAppender().getLog(); 210 verifyOccurances(log4jLog,"Kaabllaamm:",getIntegerProperty("TimestampCount")); 211 } 212 213 public void testIncludeProperties() 214 { 215 runEchoedTarget("testIncludedProperties"); 216 int N= getIntegerProperty(EMITCOUNT); 217 String log4jLog = testAppender().getLog(); 218 verifyOccurances(log4jLog,"p.outer=",N); 219 verifyOccurances(log4jLog,"p.outer=Outside",2); 220 verifyOccurances(log4jLog,"p.inner=",N); 221 verifyOccurances(log4jLog,"p.inner=null",N-1); 222 } 223 224 public void testCannotReferToSelf() 225 { 226 runTarget("testCannotReferToSelf"); 227 } 228 229 230 public void testCannotCallbackFromNestedTask() 231 { 232 runTarget("testCannotCallbackFromNestedTask"); 233 } 234 235 236 public void testRelativeGroupings_AntX04() 237 { 238 runEchoedTarget("testRelativeGroupings_AntX04","AntX.Local"); 239 String log4jLog = testAppender().getLog(); 240 verifyOccurances(log4jLog, "Hello From Outer Shell",2); 241 verifyOccurances(log4jLog, "Hola From Inner Shell",1); 242 verifyOccurances(log4jLog,HELLOWORLD_MARKER,3); 243 } 244 } 245 246 247 | Popular Tags |