1 28 29 package com.idaremedia.antx.flowcontrol.tests; 30 31 import junit.framework.TestSuite; 32 33 import com.idaremedia.antx.ut.HTCUtils; 34 35 45 46 public final class ForEachTaskTest extends StepCallerTestSkeleton 47 { 48 49 public static final String TEST_CATEGORY="CLASS"; 50 51 52 55 public ForEachTaskTest(String methodName) 56 { 57 super("ForEachTask::",methodName); 58 } 59 60 61 64 public static TestSuite suiteOfOne(String testName) 65 { 66 TestSuite s = new TestSuite(); 67 s.setName("Suite-of-One:"+testName); 68 s.addTest(new ForEachTaskTest(testName)); 69 return s; 70 } 71 72 75 public static TestSuite suite() 76 { 77 return new TestSuite(ForEachTaskTest.class); 78 } 80 81 82 85 public static TestSuite baseline() 86 { 87 return suite(); } 89 90 91 94 public static void main(String [] argv) 95 { 96 HTCUtils.quickCheck(suite()); 97 } 98 99 100 104 protected String getDefaultConfigureXMLFileName() 105 { 106 return "foreach.xml"; 107 } 108 109 final int verifyTargetsRanInLoop(final String PFX, final int I, final int N, int ilastmatch) 110 { 111 String log= getLog(); 112 for (int i=I;i<N;i++) { 113 String match = PS+PFX+AT+i; 114 int imatch = log.indexOf(match,ilastmatch); 115 assertTrue("Expecting Log to contain \""+match+"\" from ["+ilastmatch+ 116 "] but Log was \"" + log + "\"", 117 imatch>=0); 118 ilastmatch = imatch; 119 } 120 return ilastmatch; 121 } 122 123 final int verifyTargetsRanInLoop(String [] cursors, int ilastmatch) 124 { 125 String log= getLog(); 126 String match; 127 int imatch; 128 for (int i=0;i<cursors.length;i++) { 129 match = "(at:"+cursors[i]+")"; 130 imatch = log.indexOf(match,ilastmatch); 131 assertTrue("Expecting Log to contain \""+match+"\" from ["+ilastmatch+ 132 "] but Log was \"" + log + "\"", 133 imatch>=0); 134 ilastmatch = imatch+match.length(); 135 } 136 return ilastmatch; 137 } 138 139 143 public void testFailEmptyForEachElement() 144 { 145 String log = runTarget("testFailEmptyElement"); 146 assertTrue(log.indexOf("phffht: it barfed")>=0,"It barfed"); 147 } 148 149 public void testFailBrokenLoopDefinitions() 150 { 151 runTarget("testBrokenLoops"); 152 } 153 154 public void testCantNestNonPropertiesInForEach() 155 { 156 verifyCantLoadFile("broken_foreach0.xml", "Invalid nested tasks"); 157 } 158 159 public void testInLoopControl() 160 { 161 runTarget("testInLoopControl"); 162 int from=0; 163 from= verifyTargetsRanInLoop(new String []{"0"},from); 164 from= verifyTargetsRanInLoop(new String []{"0","1","2"},from); 165 from= verifyTargetsRanInLoop(new String []{"0","2","4"},from); 166 from= verifyTargetsRanInLoop(new String []{"-1","0"},from); 167 } 168 169 public void testListLoopControl() 170 { 171 runTarget("testListLoopControl"); 172 int from=0; 173 from= verifyTargetsRanInLoop(new String []{"a","b","c"},from); 174 from= verifyTargetsRanInLoop(new String []{"w","x","y","z"},from); 175 from= verifyTargetsRanInLoop(new String []{"${p.unknown}"},from); 176 } 177 178 public void testItemListLoopControl_AntX03() 179 { 180 runTarget("testItemListLoopControl_AntX03"); 181 } 182 183 public void testInFileLoopControl() 184 { 185 runTarget("testInFileLoopControl"); 186 } 187 188 public void testDirsetLoopControl() 189 { 190 runTarget("testDirsetLoopControl"); 191 } 192 193 public void testPathLoopControl() 194 { 195 runTarget("testPathLoopControl"); 196 } 197 198 public void testFilesetLoopControl() 199 { 200 runTarget("testFilesetLoopControl"); 201 } 202 203 208 public void testSupportsTryEach() 209 { 210 runTarget("testSupportsTryEach"); 211 } 212 213 214 public void testNestedPropertySets_AntX04() 215 { 216 runTarget("testNestedPropertySets_AntX04"); 217 } 218 219 220 public void testLocalMode_AntX04() 221 { 222 runTarget("testLocalMode_AntX04"); 223 } 224 225 public void testCallLocalMacros_AntX05() 226 { 227 runTarget("testCallLocalMacros_AntX05"); 228 } 229 230 public void testListLoopCustomDelimiter_AntX05() 231 { 232 runTarget("testListLoopCustomDelimiter_AntX05"); 233 } 234 } 235 236 237 | Popular Tags |