Changeset 418 for trunk/icedtea-web/tests
- Timestamp:
- Feb 11, 2013, 8:53:47 PM (13 years ago)
- Location:
- trunk/icedtea-web
- Files:
-
- 6 edited
- 495 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/icedtea-web
-
Property svn:mergeinfo
set to
/branches/vendor/sourceforge/icedtea-web/1.3 merged eligible /branches/vendor/sourceforge/icedtea-web/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/icedtea-web/tests/junit-runner/CommandLine.java
r348 r418 8 8 */ 9 9 10 import java.io.File; 10 11 import java.util.ArrayList; 11 12 import java.util.List; … … 35 36 for (String each : args) { 36 37 try { 38 if (each.contains("$")) continue; 39 if (each.toLowerCase().endsWith(".jnlp")) continue; 37 40 classes.add(Class.forName(each)); 38 41 } catch (ClassNotFoundException e) { … … 40 43 } 41 44 } 45 RunListener jXmlOutput = new JunitLikeXmlOutputListener(system, new File("tests-output.xml")); 46 addListener(jXmlOutput); 42 47 RunListener listener = new LessVerboseTextListener(system); 43 48 addListener(listener); -
trunk/icedtea-web/tests/junit-runner/LessVerboseTextListener.java
r348 r418 7 7 */ 8 8 import java.io.PrintStream; 9 import java.lang.reflect.Method; 10 import net.sourceforge.jnlp.annotations.KnownToFail; 9 11 10 12 import org.junit.internal.JUnitSystem; … … 18 20 private PrintStream writer; 19 21 private boolean testFailed = false; 22 private int totalK2F=0; 23 private int failedK2F=0; 24 private int passedK2F=0; 25 private int ignoredK2F=0; 20 26 21 27 public LessVerboseTextListener(JUnitSystem system) { … … 29 35 30 36 @Override 37 public void testIgnored(Description description) throws Exception { 38 writer.println("Ignored: " + description.getClassName() + "." + description.getMethodName()); 39 printK2F(writer, null, description); 40 } 41 42 43 @Override 31 44 public void testFailure(Failure failure) { 32 45 testFailed = true; 33 46 writer.println("FAILED: " + failure.getTestHeader() + " " + failure.getMessage()); 47 printK2F(writer,true,failure.getDescription()); 34 48 } 35 49 … … 38 52 if (!testFailed) { 39 53 writer.println("Passed: " + description.getClassName() + "." + description.getMethodName()); 54 printK2F(writer,false,description); 40 55 } 41 56 } … … 46 61 int failed = result.getFailureCount(); 47 62 int ignored = result.getIgnoreCount(); 63 writer.println("Total tests run: "+result.getRunCount()+"; From those : " + totalK2F + " known to fail"); 64 writer.println("Test known to fail: passed: " + passedK2F + "; failed: " + failedK2F + "; ignored: " + ignoredK2F); 48 65 writer.println("Test results: passed: " + passed + "; failed: " + failed + "; ignored: " + ignored); 66 67 } 68 69 private void printK2F(PrintStream writer, Boolean failed, Description description) { 70 try { 71 KnownToFail k2f = getK2F(description); 72 if (k2f != null) { 73 totalK2F++; 74 if (failed != null) { 75 if (failed) { 76 failedK2F++; 77 } else { 78 passedK2F++; 79 } 80 } else { 81 ignoredK2F++; 82 } 83 if (failed != null && !failed) { 84 writer.println(" - WARNING This test is known to fail, but have passed!"); 85 } else { 86 writer.println(" - This test is known to fail"); 87 } 88 } 89 90 91 } catch (Exception ex) { 92 ex.printStackTrace(); 93 } 94 } 95 96 public static KnownToFail getK2F(Description description) { 97 try { 98 Class q = description.getTestClass(); 99 if (q != null) { 100 String qs = description.getMethodName(); 101 if (qs.contains(" - ")) { 102 qs = qs.replaceAll(" - .*", ""); 103 } 104 Method qm = q.getMethod(qs); 105 if (qm != null) { 106 KnownToFail k2f = qm.getAnnotation(KnownToFail.class); 107 return k2f; 108 109 } 110 } 111 } catch (Exception ex) { 112 ex.printStackTrace(); 113 } 114 return null; 49 115 } 50 116 -
trunk/icedtea-web/tests/netx/pac/pac-funcs-test.js
r348 r418 22 22 testDnsDomainLevels(); 23 23 testShExpMatch(); 24 testWeekdayRange();25 24 testDateRange(); 26 25 testTimeRange(); 26 testWeekdayRange(); 27 testDateRange2(); 28 testDateRange3(); 27 29 28 30 java.lang.System.out.println("Test results: passed: " + testsPassed + "; failed: " + testsFailed + ";"); … … 30 32 31 33 function runTests(name, tests) { 32 33 34 var undefined_var; 34 35 35 for ( var i = 0; i < tests.length; i++) { 36 37 var expectedVal = tests[i][0]; 38 var args = tests[i].slice(1); 39 var returnVal; 40 try { 41 returnVal = name.apply(null, args); 42 } catch (e) { 43 returnVal = e; 44 } 45 if (returnVal === expectedVal) { 46 java.lang.System.out.println("Passed: " + name.name + "(" + args.join(", ") + ")"); 47 testsPassed++; 48 } else { 49 java.lang.System.out.println("FAILED: " + name.name + "(" + args.join(", ") + ")"); 50 java.lang.System.out.println(" Expected '" + expectedVal + "' but got '" + returnVal + "'"); 51 testsFailed++; 52 } 36 runTest(name, tests[i]); 53 37 } 54 38 } 39 40 function runTest(name, test) { 41 var expectedVal = test[0]; 42 var args = test.slice(1); 43 var returnVal; 44 try { 45 returnVal = name.apply(null, args); 46 } catch (e) { 47 returnVal = e; 48 } 49 if (returnVal === expectedVal) { 50 java.lang.System.out.println("Passed: " + name.name + "(" + args.join(", ") + ")"); 51 testsPassed++; 52 } else { 53 java.lang.System.out.println("FAILED: " + name.name + "(" + args.join(", ") + ")"); 54 java.lang.System.out.println(" Expected '" + expectedVal + "' but got '" + returnVal + "'"); 55 testsFailed++; 56 } 57 } 58 55 59 56 60 function testIsPlainHostName() { … … 236 240 [ false, dayToStr(day-1) ], 237 241 ]; 242 243 runTests(weekdayRange, tests); 244 } 245 246 /** Returns an array: [day, month, year] */ 247 function incDate() { 248 if ((arguments.length >= 3) && (arguments.length % 2 === 1)) { 249 var date = arguments[0]; 250 var result = date; 251 var index = 1; 252 while (index < arguments.length) { 253 var whichThing = arguments[index]; 254 var by = arguments[index+1]; 255 switch (whichThing) { 256 case 'year': 257 result = new Date(result.getFullYear()+by, result.getMonth(), result.getDate()); 258 break; 259 case 'month': 260 result = new Date(result.getFullYear(), result.getMonth()+by, result.getDate()); 261 break; 262 case 'day': 263 result = new Date(result.getFullYear(), result.getMonth(), result.getDate()+by); 264 break; 265 } 266 index += 2; 267 } 268 return [result.getDate(), result.getMonth(), result.getFullYear()]; 269 } 270 throw "Please call incDate properly"; 271 } 272 273 function monthToStr(month) { 274 switch (month) { 275 case -1: return "DEC"; 276 case 0: return "JAN"; 277 case 1: return "FEB"; 278 case 2: return "MAR"; 279 case 3: return "APR"; 280 case 4: return "MAY"; 281 case 5: return "JUN"; 282 case 6: return "JUL"; 283 case 7: return "AUG"; 284 case 8: return "SEP"; 285 case 9: return "OCT"; 286 case 10: return "NOV"; 287 case 11: return "DEC"; 288 case 12: return "JAN"; 289 default: throw "Invalid Month" + month; 290 } 238 291 } 239 292 240 293 function testDateRange() { 241 294 242 function incDate(date) { 243 return (date + 1 - 1) % 31 +1 ; 244 } 245 246 function decDate(date) { 247 return (date - 1 - 1 + 31) % 31 + 1; 248 } 249 250 function monthToStr(month) { 251 switch (month) { 252 case -1: return "DEC"; 253 case 0: return "JAN"; 254 case 1: return "FEB"; 255 case 2: return "MAR"; 256 case 3: return "APR"; 257 case 4: return "MAY"; 258 case 5: return "JUN"; 259 case 6: return "JUL"; 260 case 7: return "AUG"; 261 case 8: return "SEP"; 262 case 9: return "OCT"; 263 case 10: return "NOV"; 264 case 11: return "DEC"; 265 case 12: return "JAN"; 266 default: throw "Invalid Month"; 267 } 268 } 269 270 var today = new Date(); 271 var date = today.getDate(); 272 var month = today.getMonth(); 273 var year = today.getYear(); 274 275 var tests = [ 276 [ true, date ], 277 [ false, incDate(date) ], 278 [ false, decDate(date) ], 279 280 [ true, monthToStr(month) ], 281 [ false, monthToStr(month+1) ], 282 [ false, monthToStr(month-1) ], 283 284 [ true, year ], 285 [ false, year - 1], 286 [ false, year + 1], 287 288 [ true, date, date ], 289 [ true, date, incDate(date) ], 290 [ true, decDate(date), date ], 291 [ true, decDate(date), incDate(date) ], 292 [ false, incDate(date), decDate(date) ], 293 [ false, decDate(decDate(date)), decDate(date) ], 294 [ false, incDate(date), incDate(incDate(date)) ], 295 296 [ true, monthToStr(month), monthToStr(month) ], 297 [ true, monthToStr(month), monthToStr(month+1) ], 298 [ true, monthToStr(month-1), monthToStr(month) ], 299 [ true, monthToStr(month-1), monthToStr(month+1) ], 300 [ true, "JAN", "DEC" ], 301 [ true, "DEC", "NOV" ], 302 [ true, "JUL", "JUN"], 303 [ false, monthToStr(month+1), monthToStr(month+1) ], 304 [ false, monthToStr(month-1), monthToStr(month-1) ], 305 [ false, monthToStr(month+1), monthToStr(month-1) ], 306 307 [ true, year, year ], 308 [ true, year, year+1 ], 309 [ true, year-1, year ], 310 [ true, year-1, year+1 ], 311 [ false, year-2, year-1 ], 312 [ false, year+1, year+1 ], 313 [ false, year+1, year+2 ], 314 [ false, year+1, year-1 ], 315 316 [ true, date, monthToStr(month) , date, monthToStr(month) ], 317 [ true, decDate(date), monthToStr(month) , date, monthToStr(month) ], 318 [ false, decDate(date), monthToStr(month) , decDate(date), monthToStr(month) ], 319 [ true, date, monthToStr(month) , incDate(date), monthToStr(month) ], 320 [ false, incDate(date), monthToStr(month) , incDate(date), monthToStr(month) ], 321 [ true, decDate(date), monthToStr(month) , incDate(date), monthToStr(month) ], 322 [ false, incDate(date), monthToStr(month) , decDate(date), monthToStr(month) ], 323 [ true, date, monthToStr(month-1) , date, monthToStr(month) ], 324 [ true, date, monthToStr(month) , date, monthToStr(month+1) ], 325 [ true, date, monthToStr(month-1) , date, monthToStr(month+1) ], 326 [ true, incDate(date), monthToStr(month-1) , date, monthToStr(month+1) ], 327 [ true, date, monthToStr(month-1) , decDate(date), monthToStr(month+1) ], 328 [ false, date, monthToStr(month+1) , date, monthToStr(month-1) ], 329 [ false, incDate(date), monthToStr(month+1) , incDate(date), monthToStr(month-1) ], 330 [ false, decDate(date), monthToStr(month+1) , decDate(date), monthToStr(month-1) ], 331 [ true, 1, "JAN", 31, "DEC" ], 332 [ true, 2, "JAN", 1, "JAN" ], 333 [ false, 1, monthToStr(month+1), 31, monthToStr(month+1) ], 334 [ false, 1, monthToStr(month-1), 31, monthToStr(month-1) ], 335 336 [ true, monthToStr(month), year, monthToStr(month), year ], 337 [ true, monthToStr(month-1), year, monthToStr(month), year ], 338 [ true, monthToStr(month), year, monthToStr(month+1), year ], 339 [ true, monthToStr(month-1), year, monthToStr(month+1), year ], 340 [ true, monthToStr(0), year, monthToStr(11), year ], 341 [ false, monthToStr(month+1), year, monthToStr(month-1), year ], 342 [ false, monthToStr(month+1), year, monthToStr(month+1), year ], 343 [ false, monthToStr(month-1), year, monthToStr(month-1), year ], 344 [ false, monthToStr(month), year-1, monthToStr(month-1), year ], 345 [ true, monthToStr(month), year, monthToStr(month), year + 1 ], 346 [ true, monthToStr(month), year-1, monthToStr(month), year ], 347 [ true, monthToStr(month), year-1, monthToStr(month), year+1 ], 348 [ true, monthToStr(0), year, monthToStr(0), year+1 ], 349 [ true, monthToStr(0), year-1, monthToStr(0), year+1 ], 350 [ false, monthToStr(0), year-1, monthToStr(11), year-1 ], 351 [ false, monthToStr(0), year+1, monthToStr(11), year+1 ], 352 353 [ true, date, monthToStr(month), year, date, monthToStr(month), year ], 354 [ true, decDate(date), monthToStr(month), year, incDate(date), monthToStr(month), year ], 355 [ true, decDate(date), monthToStr(month-1), year, incDate(date), monthToStr(month+1), year ], 356 [ true, decDate(date), monthToStr(month-1), year-1, incDate(date), monthToStr(month+1), year+1 ], 357 [ true, incDate(date), monthToStr(month-1), year-1, incDate(date), monthToStr(month+1), year+1 ], 358 [ false, incDate(date), monthToStr(month), year, incDate(date), monthToStr(month+1), year+1 ], 359 [ false, date, monthToStr(month+1), year, incDate(date), monthToStr(month+1), year+1 ], 360 [ true, 1, monthToStr(0), 0, 31, monthToStr(11), 100000 ], 361 [ true, 1, monthToStr(0), year, 31, monthToStr(11), year ], 362 [ true, 1, monthToStr(0), year-1, 31, monthToStr(11), year+1 ], 363 [ false, 1, monthToStr(0), year-1, 31, monthToStr(11), year-1 ], 364 [ false, 1, monthToStr(0), year+1, 31, monthToStr(11), year+1 ], 365 366 ]; 367 368 runTests(dateRange, tests); 369 295 { 296 var current = new Date(); 297 var date = current.getDate(); 298 var month = current.getMonth(); 299 var year = current.getFullYear(); 300 301 var today = incDate(current, 'day', 0); 302 var tomorrow = incDate(current, 'day', 1); 303 var yesterday = incDate(current, 'day', -1); 304 305 runTest(dateRange, [ true, date ]); 306 runTest(dateRange, [ false, tomorrow[0] ]); 307 runTest(dateRange, [ false, yesterday[0] ]); 308 309 runTest(dateRange, [ true, monthToStr(month) ]); 310 runTest(dateRange, [ false, monthToStr(month+1) ]); 311 runTest(dateRange, [ false, monthToStr(month-1) ]); 312 313 runTest(dateRange, [ true, year ]); 314 runTest(dateRange, [ false, year - 1]); 315 runTest(dateRange, [ false, year + 1]); 316 317 runTest(dateRange, [ true, date, date ]); 318 runTest(dateRange, [ true, today[0], tomorrow[0] ]); 319 runTest(dateRange, [ true, yesterday[0], today[0] ]); 320 runTest(dateRange, [ true, yesterday[0], tomorrow[0] ]); 321 runTest(dateRange, [ false, tomorrow[0], yesterday[0] ]); 322 runTest(dateRange, [ false, incDate(current,'day',-2)[0], yesterday[0] ]); 323 runTest(dateRange, [ false, tomorrow[0], incDate(current,'day',2)[0] ]); 324 325 runTest(dateRange, [ true, monthToStr(month), monthToStr(month) ]); 326 runTest(dateRange, [ true, monthToStr(month), monthToStr(month+1) ]); 327 runTest(dateRange, [ true, monthToStr(month-1), monthToStr(month) ]); 328 runTest(dateRange, [ true, monthToStr(month-1), monthToStr(month+1) ]); 329 runTest(dateRange, [ true, "JAN", "DEC" ]); 330 runTest(dateRange, [ true, "FEB", "JAN" ]); 331 runTest(dateRange, [ true, "DEC", "NOV" ]); 332 runTest(dateRange, [ true, "JUL", "JUN"]); 333 runTest(dateRange, [ false, monthToStr(month+1), monthToStr(month+1) ]); 334 runTest(dateRange, [ false, monthToStr(month-1), monthToStr(month-1) ]); 335 runTest(dateRange, [ false, monthToStr(month+1), monthToStr(month-1) ]); 336 337 runTest(dateRange, [ true, year, year ]); 338 runTest(dateRange, [ true, year, year+1 ]); 339 runTest(dateRange, [ true, year-1, year ]); 340 runTest(dateRange, [ true, year-1, year+1 ]); 341 runTest(dateRange, [ false, year-2, year-1 ]); 342 runTest(dateRange, [ false, year+1, year+1 ]); 343 runTest(dateRange, [ false, year+1, year+2 ]); 344 runTest(dateRange, [ false, year+1, year-1 ]); 345 346 runTest(dateRange, [ true, date, monthToStr(month) , date, monthToStr(month) ]); 347 runTest(dateRange, [ true, yesterday[0], monthToStr(yesterday[1]) , date, monthToStr(month) ]); 348 runTest(dateRange, [ false, yesterday[0], monthToStr(yesterday[1]) , yesterday[0], monthToStr(yesterday[1]) ]); 349 runTest(dateRange, [ true, date, monthToStr(month) , tomorrow[0], monthToStr(tomorrow[1]) ]); 350 runTest(dateRange, [ false, tomorrow[0], monthToStr(tomorrow[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]); 351 runTest(dateRange, [ true, yesterday[0], monthToStr(yesterday[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]); 352 runTest(dateRange, [ false, tomorrow[0], monthToStr(tomorrow[1]) , yesterday[0], monthToStr(yesterday[1]) ]); 353 } 354 355 { 356 var lastMonth = incDate(new Date(), 'month', -1); 357 var thisMonth = incDate(new Date(), 'month', 0); 358 var nextMonth = incDate(new Date(), 'month', +1); 359 runTest(dateRange, [ true, lastMonth[0], monthToStr(lastMonth[1]) , thisMonth[0], monthToStr(thisMonth[1]) ]); 360 runTest(dateRange, [ true, thisMonth[0], monthToStr(thisMonth[1]) , nextMonth[0], monthToStr(nextMonth[1]) ]); 361 runTest(dateRange, [ true, lastMonth[0], monthToStr(lastMonth[1]) , nextMonth[0], monthToStr(nextMonth[1]) ]); 362 var date1 = incDate(new Date(), 'day', +1, 'month', -1); 363 var date2 = incDate(new Date(), 'day', -1, 'month', +1); 364 runTest(dateRange, [ true, date1[0], monthToStr(date1[1]) , nextMonth[0], monthToStr(nextMonth[1]) ]); 365 runTest(dateRange, [ true, lastMonth[0], monthToStr(lastMonth[1]) , date2[0], monthToStr(date2[1]) ]); 366 runTest(dateRange, [ false, nextMonth[0], monthToStr(nextMonth[1]) , lastMonth[0], monthToStr(lastMonth[1]) ]); 367 var date3 = incDate(new Date(), 'day', +1, 'month', +1); 368 var date4 = incDate(new Date(), 'day', +1, 'month', -1); 369 runTest(dateRange, [ false, date3[0], monthToStr(date3[1]) , date4[0], monthToStr(date4[1]) ]); 370 371 var date5 = incDate(new Date(), 'day', -1, 'month', -1); 372 runTest(dateRange, [ false, date2[0], monthToStr(date2[1]) , date5[0], monthToStr(date5[1]) ]); 373 374 runTest(dateRange, [ true, 1, "JAN", 31, "DEC" ]); 375 runTest(dateRange, [ true, 2, "JAN", 1, "JAN" ]); 376 377 var month = new Date().getMonth(); 378 runTest(dateRange, [ false, 1, monthToStr(month+1), 31, monthToStr(month+1) ]); 379 runTest(dateRange, [ false, 1, monthToStr(month-1), 31, monthToStr(month-1) ]); 380 } 381 382 383 { 384 var lastMonth = incDate(new Date(), 'month', -1); 385 var thisMonth = incDate(new Date(), 'month', 0); 386 var nextMonth = incDate(new Date(), 'month', +1); 387 runTest(dateRange, [ true, monthToStr(thisMonth[1]), thisMonth[2], monthToStr(thisMonth[1]), thisMonth[2] ]); 388 runTest(dateRange, [ true, monthToStr(lastMonth[1]), lastMonth[2], monthToStr(thisMonth[1]), thisMonth[2] ]); 389 runTest(dateRange, [ true, monthToStr(thisMonth[1]), thisMonth[2], monthToStr(nextMonth[1]), nextMonth[2] ]); 390 runTest(dateRange, [ true, monthToStr(lastMonth[1]), lastMonth[2], monthToStr(nextMonth[1]), nextMonth[2] ]); 391 runTest(dateRange, [ true, monthToStr(0), year, monthToStr(11), year ]); 392 393 runTest(dateRange, [ false, monthToStr(nextMonth[1]), nextMonth[2], monthToStr(lastMonth[1]), lastMonth[2] ]); 394 runTest(dateRange, [ false, monthToStr(nextMonth[1]), nextMonth[2], monthToStr(nextMonth[1]), nextMonth[2] ]); 395 runTest(dateRange, [ false, monthToStr(lastMonth[1]), lastMonth[2], monthToStr(lastMonth[1]), lastMonth[2] ]); 396 397 var lastYear = incDate(new Date(), 'year', -1); 398 var nextYear = incDate(new Date(), 'year', +1); 399 400 runTest(dateRange, [ false, monthToStr(lastYear[1]), lastYear[2], monthToStr(lastMonth[1]), lastMonth[2] ]); 401 runTest(dateRange, [ true, monthToStr(thisMonth[1]), thisMonth[2], monthToStr(nextYear[1]), nextYear[2] ]); 402 403 var year = new Date().getFullYear(); 404 var month = new Date().getMonth(); 405 406 runTest(dateRange, [ true, monthToStr(month), year-1, monthToStr(month), year ]); 407 runTest(dateRange, [ true, monthToStr(month), year-1, monthToStr(month), year+1 ]); 408 runTest(dateRange, [ true, monthToStr(0), year, monthToStr(0), year+1 ]); 409 runTest(dateRange, [ true, monthToStr(0), year-1, monthToStr(0), year+1 ]); 410 runTest(dateRange, [ false, monthToStr(0), year-1, monthToStr(11), year-1 ]); 411 runTest(dateRange, [ false, monthToStr(0), year+1, monthToStr(11), year+1 ]); 412 } 413 414 { 415 var today = incDate(new Date(), 'day', 0); 416 var yesterday = incDate(new Date(), 'day', -1); 417 var tomorrow = incDate(new Date(), 'day', +1); 418 runTest(dateRange, [ true, 419 today[0], monthToStr(today[1]), today[2], today[0], monthToStr(today[1]), today[2] ]); 420 runTest(dateRange, [ true, 421 yesterday[0], monthToStr(yesterday[1]), yesterday[2], tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2] ]); 422 } 423 424 { 425 var dayLastMonth = incDate(new Date(), 'day', -1, 'month', -1); 426 var dayNextMonth = incDate(new Date(), 'day', +1, 'month', +1); 427 runTest(dateRange, [ true, 428 dayLastMonth[0], monthToStr(dayLastMonth[1]), dayLastMonth[2], dayNextMonth[0], monthToStr(dayNextMonth[1]), dayNextMonth[2] ]); 429 } 430 431 { 432 var dayLastYear = incDate(new Date(), 'day', -1, 'month', -1, 'year', -1); 433 var dayNextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1); 434 runTest(dateRange, [ true, 435 dayLastYear[0], monthToStr(dayLastYear[1]), dayLastYear[2], dayNextYear[0], monthToStr(dayNextYear[1]), dayNextYear[2] ]); 436 } 437 438 { 439 var dayLastYear = incDate(new Date(), 'day', +1, 'month', -1, 'year', -1); 440 var dayNextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1); 441 runTest(dateRange, [ true, 442 dayLastYear[0], monthToStr(dayLastYear[1]), dayLastYear[2], dayNextYear[0], monthToStr(dayNextYear[1]), dayNextYear[2] ]); 443 } 444 445 { 446 var tomorrow = incDate(new Date(), 'day', +1); 447 var dayNextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1); 448 runTest(dateRange, [ false, 449 tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2], dayNextYear[0], monthToStr(dayNextYear[1]), dayNextYear[2] ]); 450 451 } 452 453 { 454 var nextMonth = incDate(new Date(), 'month', +1); 455 var nextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1); 456 runTest(dateRange, [ false, 457 nextMonth[0], monthToStr(nextMonth[1]), nextMonth[2], nextYear[0], monthToStr(nextYear[1]), nextYear[2] ]); 458 } 459 460 { 461 runTest(dateRange, [ true, 1, monthToStr(0), 0, 31, monthToStr(11), 100000 ]); 462 runTest(dateRange, [ true, 1, monthToStr(0), year, 31, monthToStr(11), year ]); 463 runTest(dateRange, [ true, 1, monthToStr(0), year-1, 31, monthToStr(11), year+1 ]); 464 runTest(dateRange, [ false, 1, monthToStr(0), year-1, 31, monthToStr(11), year-1 ]); 465 runTest(dateRange, [ false, 1, monthToStr(0), year+1, 31, monthToStr(11), year+1 ]); 466 } 467 468 } 469 470 function testDateRange2() { 471 472 var dates = [ 473 new Date("January 31, 2011 3:33:33"), 474 new Date("February 28, 2011 3:33:33"), 475 new Date("February 29, 2012 3:33:33"), 476 new Date("March 31, 2011 3:33:33"), 477 new Date("April 30, 2011 3:33:33"), 478 new Date("May 31, 2011 3:33:33"), 479 new Date("June 30, 2011 3:33:33"), 480 new Date("July 31, 2011 3:33:33"), 481 new Date("August 31, 2011 3:33:33"), 482 new Date("September 30, 2011 3:33:33"), 483 new Date("October 31, 2011 3:33:33"), 484 new Date("November 30, 2011 3:33:33"), 485 new Date("December 31, 2011 3:33:33"), 486 ] 487 for (var i = 0; i < dates.length; i++) { 488 var current = dates[i]; 489 var today = incDate(current, 'day', 0); 490 var yesterday = incDate(current, 'day', -1); 491 var tomorrow = incDate(current, 'day', 1); 492 var aYearFromNow = new Date(current.getFullYear()+1, current.getMonth()+1, current.getDate()+1); 493 var later = [aYearFromNow.getDate(), aYearFromNow.getMonth(), aYearFromNow.getFullYear()]; 494 495 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current, 496 today[0], monthToStr(today[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]); 497 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current, 498 yesterday[0], monthToStr(yesterday[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]); 499 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current, 500 yesterday[0], monthToStr(yesterday[1]), yesterday[2], tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2] ]); 501 runTest(isDateInRange_internallForIcedTeaWebTesting, [ false, current, 502 tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2], later[0], monthToStr(later[1]), later[2] ]); 503 } 504 505 } 506 507 function testDateRange3() { 508 var dates = [ 509 new Date("January 1, 2011 1:11:11"), 510 new Date("February 1, 2011 1:11:11"), 511 new Date("March 1, 2011 1:11:11"), 512 new Date("April 1, 2011 1:11:11"), 513 new Date("May 1, 2011 1:11:11"), 514 new Date("June 1, 2011 1:11:11"), 515 new Date("July 1, 2011 1:11:11"), 516 new Date("August 1, 2011 1:11:11"), 517 new Date("September 1, 2011 1:11:11"), 518 new Date("October 1, 2011 1:11:11"), 519 new Date("November 1, 2011 1:11:11"), 520 new Date("December 1, 2011 1:11:11"), 521 522 ] 523 524 525 526 for (var i = 0; i < dates.length; i++) { 527 var current = dates[i]; 528 var yesterday = incDate(current,'day',-1); 529 var today = incDate(current,'day',0); 530 var tomorrow = incDate(current,'day',1); 531 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current, 532 yesterday[0], monthToStr(yesterday[1]) , today[0], monthToStr(today[1]) ]); 533 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current, 534 yesterday[0], monthToStr(yesterday[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]); 535 runTest(isDateInRange_internallForIcedTeaWebTesting, [ true, current, 536 yesterday[0], monthToStr(yesterday[1]), yesterday[2], tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2] ]); 537 } 370 538 } 371 539 -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java
r348 r418 39 39 40 40 import java.io.ByteArrayInputStream; 41 import java.io.IOException; 42 import java.io.StringReader; 43 import net.sourceforge.jnlp.annotations.KnownToFail; 41 44 42 import org.junit.After; 45 import net.sourceforge.nanoxml.XMLElement; 46 import net.sourceforge.nanoxml.XMLParseException; 47 43 48 import org.junit.Assert; 44 import org.junit.Before;45 49 import org.junit.Test; 46 50 47 51 /** Test various corner cases of the parser */ 48 52 public class ParserCornerCases { 53 54 @Test 55 public void testCdata() throws ParseException, XMLParseException, IOException { 56 String data = "<argument><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> <!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\"> <properties> <entry key=\"key\">value</entry> </properties> ]]></argument>"; 57 XMLElement elem = new XMLElement(); 58 elem.parseFromReader(new StringReader(data)); 59 XMLElement target = elem; 60 Assert.assertEquals("argument", target.getName()); 61 Assert.assertTrue("too small", target.getContent().length() > 20); 62 Assert.assertTrue(target.getContent().contains("xml")); 63 Assert.assertTrue(target.getContent().contains("DOCTYPE")); 64 Assert.assertTrue(target.getContent().contains("<entry key=\"key\">value</entry>")); 65 66 Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes())); 67 Assert.assertEquals("argument", node.getNodeName()); 68 String contents = node.getNodeValue(); 69 Assert.assertTrue(contents.contains("xml")); 70 Assert.assertTrue(contents.contains("DOCTYPE")); 71 Assert.assertTrue(contents.contains("<entry key=\"key\">value</entry>")); 72 } 73 74 @Test 75 public void testCdataNested() throws ParseException, XMLParseException, IOException { 76 String data = "<jnlp>\n" + 77 "<application-desc>\n" + 78 "<argument>\n" + 79 "<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> <!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\"> <properties> <entry key=\"key\">value</entry> </properties> ]]>" + 80 "</argument>\n" + 81 "<argument>1</argument>\n" + 82 "</application-desc>\n" + 83 "</jnlp>"; 84 XMLElement elem = new XMLElement(); 85 elem.parseFromReader(new StringReader(data)); 86 XMLElement target = (XMLElement) ((XMLElement) elem.enumerateChildren().nextElement()).enumerateChildren().nextElement(); 87 Assert.assertEquals("argument", target.getName()); 88 Assert.assertTrue("too small", target.getContent().length() > 20); 89 Assert.assertTrue(target.getContent().contains("xml")); 90 Assert.assertTrue(target.getContent().contains("DOCTYPE")); 91 Assert.assertTrue(target.getContent().contains("<entry key=\"key\">value</entry>")); 92 93 Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes())); 94 node = node.getFirstChild().getFirstChild(); 95 Assert.assertEquals("argument", node.getNodeName()); 96 String contents = node.getNodeValue(); 97 Assert.assertTrue(contents.contains("xml")); 98 Assert.assertTrue(contents.contains("DOCTYPE")); 99 Assert.assertTrue(contents.contains("<entry key=\"key\">value</entry>")); 100 } 101 102 @Test 103 @KnownToFail 104 public void testCDataFirstChild() throws XMLParseException, IOException { 105 String xml = "<?xml version=\"1.0\"?>\n" + 106 "<jnlp spec=\"1.5+\">\n" + 107 "<![CDATA[Text you want to escape goes here...<test> random tag test </test>]]>\n" + 108 "<information/>\n" + 109 "</jnlp>"; 110 XMLElement elem = new XMLElement(); 111 elem.parseFromReader(new StringReader(xml)); 112 } 113 114 @Test 115 @KnownToFail 116 public void testCDataSecondChild() throws XMLParseException, IOException { 117 String xml = "<?xml version=\"1.0\"?>\n" + 118 "<jnlp spec=\"1.5+\">\n" + 119 "<information/>\n" + 120 "<![CDATA[Text you want to escape goes here...<test> random tag test </test>]]>\n" + 121 "</jnlp>"; 122 XMLElement elem = new XMLElement(); 123 elem.parseFromReader(new StringReader(xml)); 124 } 125 49 126 @Test 50 127 public void testUnsupportedSpecNumber() throws ParseException { … … 72 149 73 150 @Test 151 public void testCommentInElements2() throws ParseException { 152 String malformedJnlp = "<?xml?><jnlp <!-- comment --> spec='1.0'> </jnlp>"; 153 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes())); 154 Parser p = new Parser(null, null, root, false, false); 155 Assert.assertEquals("1.0", p.getSpecVersion().toString()); 156 } 157 158 @Test 159 @KnownToFail 74 160 public void testCommentInAttributes() throws ParseException { 75 161 String malformedJnlp = "<?xml?><jnlp spec='<!-- something -->'></jnlp>"; … … 82 168 public void testNestedComments() throws ParseException { 83 169 String malformedJnlp = "<?xml?>" + 84 "<jnlp><information><description>" + 170 "<jnlp><information><title>testNestedComments</title>" + 171 "<vendor>IcedTea</vendor><description>" + 85 172 "<!-- outer <!-- inner --> -->" + 86 173 "</description></information></jnlp>"; … … 89 176 Assert.assertEquals(" -->", p.getInfo(root).get(0).getDescription()); 90 177 } 178 179 @Test 180 public void testDoubleDashesInComments() throws ParseException { 181 String malformedJnlp = "<?xml?>" + 182 "<jnlp> <!-- \n" + 183 " -- a very very long and \n" + 184 " -- multiline comment \n" + 185 " -- that contains double dashes \n" + 186 " -->\n" + 187 " <information/>" + 188 "</jnlp>"; 189 Node root = Parser.getRootNode(new ByteArrayInputStream(malformedJnlp.getBytes())); 190 Parser p = new Parser(null, null, root, false, false); 191 } 192 91 193 } -
trunk/icedtea-web/tests/netx/unit/net/sourceforge/jnlp/ParserMalformedXml.java
r348 r418 43 43 import java.io.InputStreamReader; 44 44 import java.io.IOException; 45 import net.sourceforge.jnlp.annotations.KnownToFail; 45 46 46 47 import org.junit.BeforeClass; … … 75 76 76 77 @Test 78 @KnownToFail 77 79 public void testMalformedArguments() throws ParseException { 78 80 String malformedJnlp = originalJnlp.replace("arg2</argument", "arg2<argument"); … … 81 83 82 84 @Test 85 @KnownToFail 83 86 public void testTagNotClosed() throws ParseException { 84 87 String malformedJnlp = originalJnlp.replace("</jnlp>", "<jnlp>"); … … 87 90 88 91 @Test 92 @KnownToFail 89 93 public void testUnquotedAttributes() throws ParseException { 90 94 String malformedJnlp = originalJnlp.replace("'jnlp.jnlp'", "jnlp.jnlp"); -
trunk/icedtea-web/tests/reproducers/signed/Spaces can be everywhere signed/resources
- Property svn:mergeinfo set to
-
trunk/icedtea-web/tests/reproducers/signed/Spaces can be everywhere signed/resources/Spaces can be everywhere1 signed.jnlp
- Property svn:mergeinfo set to
-
trunk/icedtea-web/tests/reproducers/signed/Spaces can be everywhere signed/resources/Spaces can be everywhere2 signed.jnlp
- Property svn:mergeinfo set to
-
trunk/icedtea-web/tests/reproducers/signed/Spaces can be everywhere signed/resources/SpacesCanBeEverywhere1signed.jnlp
- Property svn:mergeinfo set to
-
trunk/icedtea-web/tests/reproducers/signed/Spaces can be everywhere signed/resources/spaces applet Tests signed.html
- Property svn:mergeinfo set to
-
trunk/icedtea-web/tests/reproducers/simple/Spaces can be everywhere/resources
- Property svn:mergeinfo set to
-
trunk/icedtea-web/tests/reproducers/simple/Spaces can be everywhere/resources/Spaces can be everywhere1.jnlp
- Property svn:mergeinfo set to
-
trunk/icedtea-web/tests/reproducers/simple/Spaces can be everywhere/resources/Spaces can be everywhere2.jnlp
- Property svn:mergeinfo set to
-
trunk/icedtea-web/tests/reproducers/simple/Spaces can be everywhere/resources/SpacesCanBeEverywhere1.jnlp
- Property svn:mergeinfo set to
-
trunk/icedtea-web/tests/reproducers/simple/Spaces can be everywhere/resources/spaces applet Tests.html
- Property svn:mergeinfo set to
Note:
See TracChangeset
for help on using the changeset viewer.