[utilities COMMIT] in /java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection: CollectionT...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Jan 18 10:43:42 GMT 2012
Author: rdw
Date: Wed Jan 18 10:43:42 2012
New Revision: 210
URL: http://svn.shibboleth.net/view/utilities?rev=210&view=rev
Log:
Refactor Collection and List tests prior to adding tests for the TransformedInputCollections
Added:
java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/CollectionTestSupport.java (with props)
java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/ListTestSupport.java (with props)
Modified:
java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/LazyListTest.java
java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/LazySetTest.java
Modified: java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/LazyListTest.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/LazyListTest.java?rev=210&r1=209&r2=210&view=diff
==============================================================================
--- java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/LazyListTest.java (original)
+++ java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/LazyListTest.java Wed Jan 18 10:43:42 2012
@@ -18,9 +18,9 @@
package net.shibboleth.utilities.java.support.collection;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
-import org.testng.Assert;
import org.testng.annotations.Test;
/**
@@ -28,16 +28,13 @@
*/
public class LazyListTest {
- private final static String [] TEST_ARRAY = {"Zero", "One", "Two", "Three"};
- private final static String TEST_VALUE = "tWO";
-
/**
* Test the test method with a known good List and then with a LazyList
*/
@Test
public void testSimple() {
- LazySetTest.testSimpleCollection(new ArrayList<String>(), true);
- LazySetTest.testSimpleCollection(new LazyList<String>(), true);
+ CollectionTestSupport.testSimpleCollection(new ArrayList<String>(), true);
+ CollectionTestSupport.testSimpleCollection(new LazyList<String>(), true);
}
/**
@@ -45,8 +42,8 @@
*/
@Test
public void testArray() {
- LazySetTest.testArrayCollection(new ArrayList<String>(), new ArrayList<String>());
- LazySetTest.testArrayCollection(new LazyList<String>(), new ArrayList<String>());
+ CollectionTestSupport.testArrayCollection(new ArrayList<String>(), new ArrayList<String>());
+ CollectionTestSupport.testArrayCollection(new LazyList<String>(), new ArrayList<String>());
}
/**
@@ -54,166 +51,16 @@
*/
@Test
public void testIterator() {
- LazySetTest.testIteratorCollection(new LazyList<String>(), new ArrayList<String>());
+ CollectionTestSupport.testIteratorCollection(new LazyList<String>(), new ArrayList<String>());
}
- /**
- * Test those things that distinguish the {@link List} API from the {@link Collection} one.
- * Generic function to allow us to test the test with an ArrayList
- */
- public void testListFunctions(List<String> list) {
- boolean thrown = false;
-
- try {
- list.get(0);
- } catch (IndexOutOfBoundsException e) {
- thrown = true;
- }
- Assert.assertTrue(thrown, "Should throw exception when lookup up after the end");
-
- thrown = false;
- try {
- list.get(1);
- } catch (IndexOutOfBoundsException e) {
- thrown = true;
- }
- Assert.assertTrue(thrown, "Should throw exception when lookup up after the end");
-
- list.add(TEST_ARRAY[0]);
- Assert.assertEquals(list.get(0), TEST_ARRAY[0], "Single insert");
-
- thrown = false;
- try {
- list.get(1);
- } catch (IndexOutOfBoundsException e) {
- thrown = true;
- }
- Assert.assertTrue(thrown, "Should throw exception when lookup up after the end");
-
- for (int i = 1 ; i < TEST_ARRAY.length; i++) {
- list.add(TEST_ARRAY[i]);
- }
-
- for (int i = 0 ; i < TEST_ARRAY.length; i++) {
- Assert.assertEquals(list.get(i), TEST_ARRAY[i], "Contents not as expected at " + i);
- }
-
- Assert.assertEquals(list.set(2, TEST_VALUE), TEST_ARRAY[2], "Replaced contents not as expected");
- Assert.assertEquals(list.get(2), TEST_VALUE, "Contents not as expected after replace");
- for (int i = 0; i < TEST_ARRAY.length; i++) {
- if (i != 2) {
- Assert.assertEquals(list.get(i), TEST_ARRAY[i], "Contents not as expected at " + i);
- }
- }
-
- Assert.assertEquals(list.size(), TEST_ARRAY.length, "Size matches after in place replace");
-
- Assert.assertEquals(list.set(2, TEST_ARRAY[2]), TEST_VALUE, "Replaced contents not as expected");
- list.add(2, TEST_VALUE);
[... 353 lines stripped ...]
More information about the commits
mailing list