11 |
|
import java.util.concurrent.*; |
12 |
|
import java.io.*; |
13 |
|
|
14 |
< |
public class CopyOnWriteArrayListTest extends JSR166TestCase{ |
14 |
> |
public class CopyOnWriteArrayListTest extends JSR166TestCase { |
15 |
|
|
16 |
|
public static void main(String[] args) { |
17 |
|
junit.textui.TestRunner.run (suite()); |
21 |
|
return new TestSuite(CopyOnWriteArrayListTest.class); |
22 |
|
} |
23 |
|
|
24 |
< |
static CopyOnWriteArrayList populatedArray(int n){ |
24 |
> |
static CopyOnWriteArrayList populatedArray(int n) { |
25 |
|
CopyOnWriteArrayList a = new CopyOnWriteArrayList(); |
26 |
|
assertTrue(a.isEmpty()); |
27 |
|
for (int i = 0; i < n; ++i) |
411 |
|
c.add("asdadasd"); |
412 |
|
c.toArray(new Long[5]); |
413 |
|
shouldThrow(); |
414 |
< |
} catch (ArrayStoreException e){} |
414 |
> |
} catch (ArrayStoreException e) {} |
415 |
|
} |
416 |
|
|
417 |
|
/** |
422 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
423 |
|
c.get(-1); |
424 |
|
shouldThrow(); |
425 |
< |
} catch (IndexOutOfBoundsException e){} |
425 |
> |
} catch (IndexOutOfBoundsException e) {} |
426 |
|
} |
427 |
|
|
428 |
|
/** |
435 |
|
c.add("asdad"); |
436 |
|
c.get(100); |
437 |
|
shouldThrow(); |
438 |
< |
} catch (IndexOutOfBoundsException e){} |
438 |
> |
} catch (IndexOutOfBoundsException e) {} |
439 |
|
} |
440 |
|
|
441 |
|
/** |
446 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
447 |
|
c.set(-1,"qwerty"); |
448 |
|
shouldThrow(); |
449 |
< |
} catch (IndexOutOfBoundsException e){} |
449 |
> |
} catch (IndexOutOfBoundsException e) {} |
450 |
|
} |
451 |
|
|
452 |
|
/** |
459 |
|
c.add("asdad"); |
460 |
|
c.set(100, "qwerty"); |
461 |
|
shouldThrow(); |
462 |
< |
} catch (IndexOutOfBoundsException e){} |
462 |
> |
} catch (IndexOutOfBoundsException e) {} |
463 |
|
} |
464 |
|
|
465 |
|
/** |
470 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
471 |
|
c.add(-1,"qwerty"); |
472 |
|
shouldThrow(); |
473 |
< |
} catch (IndexOutOfBoundsException e){} |
473 |
> |
} catch (IndexOutOfBoundsException e) {} |
474 |
|
} |
475 |
|
|
476 |
|
/** |
483 |
|
c.add("asdasdasd"); |
484 |
|
c.add(100, "qwerty"); |
485 |
|
shouldThrow(); |
486 |
< |
} catch (IndexOutOfBoundsException e){} |
486 |
> |
} catch (IndexOutOfBoundsException e) {} |
487 |
|
} |
488 |
|
|
489 |
|
/** |
494 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
495 |
|
c.remove(-1); |
496 |
|
shouldThrow(); |
497 |
< |
} catch (IndexOutOfBoundsException e){} |
497 |
> |
} catch (IndexOutOfBoundsException e) {} |
498 |
|
} |
499 |
|
|
500 |
|
/** |
507 |
|
c.add("adasdasd"); |
508 |
|
c.remove(100); |
509 |
|
shouldThrow(); |
510 |
< |
} catch (IndexOutOfBoundsException e){} |
510 |
> |
} catch (IndexOutOfBoundsException e) {} |
511 |
|
} |
512 |
|
|
513 |
|
/** |
518 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
519 |
|
c.addAll(-1,new LinkedList()); |
520 |
|
shouldThrow(); |
521 |
< |
} catch (IndexOutOfBoundsException e){} |
521 |
> |
} catch (IndexOutOfBoundsException e) {} |
522 |
|
} |
523 |
|
|
524 |
|
/** |
531 |
|
c.add("asdasdasd"); |
532 |
|
c.addAll(100, new LinkedList()); |
533 |
|
shouldThrow(); |
534 |
< |
} catch (IndexOutOfBoundsException e){} |
534 |
> |
} catch (IndexOutOfBoundsException e) {} |
535 |
|
} |
536 |
|
|
537 |
|
/** |
542 |
|
CopyOnWriteArrayList c = new CopyOnWriteArrayList(); |
543 |
|
c.listIterator(-1); |
544 |
|
shouldThrow(); |
545 |
< |
} catch (IndexOutOfBoundsException e){} |
545 |
> |
} catch (IndexOutOfBoundsException e) {} |
546 |
|
} |
547 |
|
|
548 |
|
/** |
555 |
|
c.add("asdasdas"); |
556 |
|
c.listIterator(100); |
557 |
|
shouldThrow(); |
558 |
< |
} catch (IndexOutOfBoundsException e){} |
558 |
> |
} catch (IndexOutOfBoundsException e) {} |
559 |
|
} |
560 |
|
|
561 |
|
/** |
567 |
|
c.subList(-1,100); |
568 |
|
|
569 |
|
shouldThrow(); |
570 |
< |
} catch (IndexOutOfBoundsException e){} |
570 |
> |
} catch (IndexOutOfBoundsException e) {} |
571 |
|
} |
572 |
|
|
573 |
|
/** |
579 |
|
c.add("asdasd"); |
580 |
|
c.subList(1,100); |
581 |
|
shouldThrow(); |
582 |
< |
} catch (IndexOutOfBoundsException e){} |
582 |
> |
} catch (IndexOutOfBoundsException e) {} |
583 |
|
} |
584 |
|
|
585 |
|
/** |
592 |
|
c.subList(3,1); |
593 |
|
|
594 |
|
shouldThrow(); |
595 |
< |
} catch (IndexOutOfBoundsException e){} |
595 |
> |
} catch (IndexOutOfBoundsException e) {} |
596 |
|
} |
597 |
|
|
598 |
|
/** |
613 |
|
assertEquals(q.size(), r.size()); |
614 |
|
assertTrue(q.equals(r)); |
615 |
|
assertTrue(r.equals(q)); |
616 |
< |
} catch (Exception e){ |
616 |
> |
} catch (Exception e) { |
617 |
|
unexpectedException(); |
618 |
|
} |
619 |
|
} |