diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java index 9104a40bb..3e552f263 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java @@ -611,10 +611,15 @@ public class FTPTest { performConfigTest("configuration.3", expectedCounts); } - @Test(expected = BuildException.class) - public void testConfigurationLang() { + @Test + public void testConfigurationGoodLang() { int[] expectedCounts = {1, 1, 0, 0, 0, 0, 1}; performConfigTest("configuration.lang.good", expectedCounts); + } + + @Test(expected = BuildException.class) + public void testConfigurationBadLang() { + int[] expectedCounts = {1, 1, 0, 0, 0, 0, 1}; performConfigTest("configuration.lang.bad", expectedCounts); } /** diff --git a/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java b/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java index 8cb20aad3..9bfe0c86d 100644 --- a/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java @@ -75,7 +75,7 @@ public class LazyResourceCollectionTest { } } - @Test(expected = NoSuchElementException.class) + @Test public void testLazyLoading() { StringResourceCollection collectionTest = new StringResourceCollection(); LazyResourceCollectionWrapper lazyCollection = new LazyResourceCollectionWrapper(); @@ -101,7 +101,18 @@ public class LazyResourceCollectionTest { assertOneCreatedIterator(collectionTest); assertEquals("Iterating 3 times load more than 3 resources", 3, stringResourceIterator.cursor); + } + @Test(expected = NoSuchElementException.class) + public void testLazyLoadingFailsOnceWrappedCollectionIsExhausted() { + StringResourceCollection collectionTest = new StringResourceCollection(); + LazyResourceCollectionWrapper lazyCollection = new LazyResourceCollectionWrapper(); + lazyCollection.add(collectionTest); + + Iterator it = lazyCollection.iterator(); + it.next(); + it.next(); + it.next(); it.next(); } @@ -111,7 +122,7 @@ public class LazyResourceCollectionTest { testCollection.createdIterators.size()); } - @Test(expected = NoSuchElementException.class) + @Test public void testCaching() { StringResourceCollection collectionTest = new StringResourceCollection(); LazyResourceCollectionWrapper lazyCollection = new LazyResourceCollectionWrapper(); @@ -153,6 +164,23 @@ public class LazyResourceCollectionTest { assertEquals( "The first iterator did not lookup in the cache for a resource", 3, stringResourceIterator.cursor); + } + + @Test(expected = NoSuchElementException.class) + public void testCachingFailsOnceWrappedCollectionIsExhausted() { + StringResourceCollection collectionTest = new StringResourceCollection(); + LazyResourceCollectionWrapper lazyCollection = new LazyResourceCollectionWrapper(); + lazyCollection.add(collectionTest); + + Iterator it1 = lazyCollection.iterator(); + Iterator it2 = lazyCollection.iterator(); + + it1.next(); + it2.next(); + it2.next(); + it1.next(); + it2.next(); + it1.next(); // next() must throw the expected NoSuchElementException; // if that does not happen, assertions throw the unexpected Assertion error diff --git a/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java b/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java index 0785631d3..6eaf35c71 100644 --- a/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java @@ -107,11 +107,15 @@ public class VectorSetTest { assertEquals(1, v.size()); } - @Test(expected = ArrayIndexOutOfBoundsException.class) + @Test public void testRemoveIndex() { v.add(O); assertSame(O, v.remove(0)); assertEquals(0, v.size()); + } + + @Test(expected = ArrayIndexOutOfBoundsException.class) + public void testCantRemoveByIndexFromEmptySet() { v.remove(0); } @@ -197,11 +201,15 @@ public class VectorSetTest { assertFalse(v.removeElement(O)); } - @Test(expected = ArrayIndexOutOfBoundsException.class) + @Test public void testRemoveElementAt() { v.add(O); v.removeElementAt(0); assertEquals(0, v.size()); + } + + @Test(expected = ArrayIndexOutOfBoundsException.class) + public void testCantRemoveAtFromEmptySet() { v.removeElementAt(0); }