You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2013/01/07 18:15:24 UTC
svn commit: r1429905 [23/26] - in /commons/proper/collections/trunk/src:
main/java/org/apache/commons/collections/
main/java/org/apache/commons/collections/bag/
main/java/org/apache/commons/collections/bidimap/
main/java/org/apache/commons/collections/...
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/PredicatedListTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/PredicatedListTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/PredicatedListTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/PredicatedListTest.java Mon Jan 7 17:15:14 2013
@@ -33,7 +33,7 @@ import org.apache.commons.collections.fu
*/
public class PredicatedListTest<E> extends AbstractListTest<E> {
- public PredicatedListTest(String testName) {
+ public PredicatedListTest(final String testName) {
super(testName);
}
@@ -41,7 +41,7 @@ public class PredicatedListTest<E> exten
protected Predicate<E> truePredicate = TruePredicate.<E>truePredicate();
- protected List<E> decorateList(List<E> list, Predicate<E> predicate) {
+ protected List<E> decorateList(final List<E> list, final Predicate<E> predicate) {
return PredicatedList.predicatedList(list, predicate);
}
@@ -60,7 +60,7 @@ public class PredicatedListTest<E> exten
protected Predicate<E> testPredicate =
new Predicate<E>() {
- public boolean evaluate(E o) {
+ public boolean evaluate(final E o) {
return o instanceof String;
}
};
@@ -71,12 +71,12 @@ public class PredicatedListTest<E> exten
@SuppressWarnings("unchecked")
public void testIllegalAdd() {
- List<E> list = makeTestList();
- Integer i = new Integer(3);
+ final List<E> list = makeTestList();
+ final Integer i = new Integer(3);
try {
list.add((E) i);
fail("Integer should fail string predicate.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
assertTrue("Collection shouldn't contain illegal element",
@@ -85,8 +85,8 @@ public class PredicatedListTest<E> exten
@SuppressWarnings("unchecked")
public void testIllegalAddAll() {
- List<E> list = makeTestList();
- List<E> elements = new ArrayList<E>();
+ final List<E> list = makeTestList();
+ final List<E> elements = new ArrayList<E>();
elements.add((E) "one");
elements.add((E) "two");
elements.add((E) new Integer(3));
@@ -94,7 +94,7 @@ public class PredicatedListTest<E> exten
try {
list.addAll(0, elements);
fail("Integer should fail string predicate.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
assertTrue("List shouldn't contain illegal element",
@@ -109,20 +109,20 @@ public class PredicatedListTest<E> exten
@SuppressWarnings("unchecked")
public void testIllegalSet() {
- List<E> list = makeTestList();
+ final List<E> list = makeTestList();
try {
list.set(0, (E) new Integer(3));
fail("Integer should fail string predicate.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@SuppressWarnings("unchecked")
public void testLegalAddAll() {
- List<E> list = makeTestList();
+ final List<E> list = makeTestList();
list.add((E) "zero");
- List<E> elements = new ArrayList<E>();
+ final List<E> elements = new ArrayList<E>();
elements.add((E) "one");
elements.add((E) "two");
elements.add((E) "three");
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/SetUniqueListTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/SetUniqueListTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/SetUniqueListTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/SetUniqueListTest.java Mon Jan 7 17:15:14 2013
@@ -36,7 +36,7 @@ import java.util.Set;
*/
public class SetUniqueListTest<E> extends AbstractListTest<E> {
- public SetUniqueListTest(String testName) {
+ public SetUniqueListTest(final String testName) {
super(testName);
}
@@ -50,12 +50,12 @@ public class SetUniqueListTest<E> extend
public void testListIteratorSet() {
// override to block
resetFull();
- ListIterator<E> it = getCollection().listIterator();
+ final ListIterator<E> it = getCollection().listIterator();
it.next();
try {
it.set(null);
fail();
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
}
@Override
@@ -87,14 +87,14 @@ public class SetUniqueListTest<E> extend
public void testListIteratorAdd() {
// override to cope with Set behaviour
resetEmpty();
- List<E> list1 = getCollection();
- List<E> list2 = getConfirmed();
+ final List<E> list1 = getCollection();
+ final List<E> list2 = getConfirmed();
- E[] elements = getOtherElements(); // changed here
+ final E[] elements = getOtherElements(); // changed here
ListIterator<E> iter1 = list1.listIterator();
ListIterator<E> iter2 = list2.listIterator();
- for (E element : elements) {
+ for (final E element : elements) {
iter1.add(element);
iter2.add(element);
super.verify(); // changed here
@@ -103,7 +103,7 @@ public class SetUniqueListTest<E> extend
resetFull();
iter1 = getCollection().listIterator();
iter2 = getConfirmed().listIterator();
- for (E element : elements) {
+ for (final E element : elements) {
iter1.next();
iter2.next();
iter1.add(element);
@@ -121,13 +121,13 @@ public class SetUniqueListTest<E> extend
getConfirmed().addAll(Arrays.asList(elements));
verify();
assertTrue("Empty collection should change after addAll", r);
- for (E element : elements) {
+ for (final E element : elements) {
assertTrue("Collection should contain added element",
getCollection().contains(element));
}
resetFull();
- int size = getCollection().size();
+ final int size = getCollection().size();
elements = getOtherElements();
r = getCollection().addAll(Arrays.asList(elements));
getConfirmed().addAll(Arrays.asList(elements));
@@ -143,7 +143,7 @@ public class SetUniqueListTest<E> extend
public void testIntCollectionAddAll() {
// make a SetUniqueList with one element
- List<Integer> list = new SetUniqueList<Integer>(new ArrayList<Integer>(), new HashSet<Integer>());
+ final List<Integer> list = new SetUniqueList<Integer>(new ArrayList<Integer>(), new HashSet<Integer>());
final Integer existingElement = new Integer(1);
list.add(existingElement);
@@ -171,7 +171,7 @@ public class SetUniqueListTest<E> extend
public void testListSetByIndex() {
// override for set behaviour
resetFull();
- int size = getCollection().size();
+ final int size = getCollection().size();
getCollection().set(0, (E) new Long(1000));
assertEquals(size, getCollection().size());
@@ -197,7 +197,7 @@ public class SetUniqueListTest<E> extend
super.verify();
if (extraVerify) {
- int size = getCollection().size();
+ final int size = getCollection().size();
getCollection().add((E) new Long(1000));
assertEquals(size + 1, getCollection().size());
@@ -211,8 +211,8 @@ public class SetUniqueListTest<E> extend
//-----------------------------------------------------------------------
public void testFactory() {
- Integer[] array = new Integer[] { new Integer(1), new Integer(2), new Integer(1) };
- ArrayList<Integer> list = new ArrayList<Integer>(Arrays.asList(array));
+ final Integer[] array = new Integer[] { new Integer(1), new Integer(2), new Integer(1) };
+ final ArrayList<Integer> list = new ArrayList<Integer>(Arrays.asList(array));
final SetUniqueList<Integer> lset = SetUniqueList.setUniqueList(list);
assertEquals("Duplicate element was added.", 2, lset.size());
@@ -310,11 +310,11 @@ public class SetUniqueListTest<E> extend
@SuppressWarnings("unchecked")
public void testUniqueListReInsert() {
- List<E> l = SetUniqueList.setUniqueList(new LinkedList<E>());
+ final List<E> l = SetUniqueList.setUniqueList(new LinkedList<E>());
l.add((E) new Object());
l.add((E) new Object());
- E a = l.get(0);
+ final E a = l.get(0);
// duplicate is removed
l.set(0, l.get(1));
@@ -327,7 +327,7 @@ public class SetUniqueListTest<E> extend
@SuppressWarnings("unchecked")
public void testUniqueListDoubleInsert() {
- List<E> l = SetUniqueList.setUniqueList(new LinkedList<E>());
+ final List<E> l = SetUniqueList.setUniqueList(new LinkedList<E>());
l.add((E) new Object());
l.add((E) new Object());
@@ -348,12 +348,12 @@ public class SetUniqueListTest<E> extend
* set(0,b): [b]->a
* So UniqList contains [b] and a is returned
*/
- ArrayList<E> l = new ArrayList<E>();
- HashSet<E> s = new HashSet<E>();
+ final ArrayList<E> l = new ArrayList<E>();
+ final HashSet<E> s = new HashSet<E>();
final SetUniqueList<E> ul = new SetUniqueList<E>(l, s);
- E a = (E) new Object();
- E b = (E) new Object();
+ final E a = (E) new Object();
+ final E b = (E) new Object();
ul.add(a);
ul.add(b);
assertEquals(a, l.get(0));
@@ -377,13 +377,13 @@ public class SetUniqueListTest<E> extend
* set(0,b): [b,c]->a
* So UniqList contains [b,c] and a is returned
*/
- ArrayList<E> l = new ArrayList<E>();
- HashSet<E> s = new HashSet<E>();
+ final ArrayList<E> l = new ArrayList<E>();
+ final HashSet<E> s = new HashSet<E>();
final SetUniqueList<E> ul = new SetUniqueList<E>(l, s);
- E a = (E) new Object();
- E b = (E) new Object();
- E c = (E) new Object();
+ final E a = (E) new Object();
+ final E b = (E) new Object();
+ final E c = (E) new Object();
ul.add(a);
ul.add(b);
@@ -413,13 +413,13 @@ public class SetUniqueListTest<E> extend
* set(1,a): [a,c]->b
* So UniqList contains [a,c] and b is returned
*/
- ArrayList<E> l = new ArrayList<E>();
- HashSet<E> s = new HashSet<E>();
+ final ArrayList<E> l = new ArrayList<E>();
+ final HashSet<E> s = new HashSet<E>();
final SetUniqueList<E> ul = new SetUniqueList<E>(l, s);
- E a = (E) new String("A");
- E b = (E) new String("B");
- E c = (E) new String("C");
+ final E a = (E) new String("A");
+ final E b = (E) new String("B");
+ final E c = (E) new String("C");
ul.add(a);
ul.add(b);
@@ -456,12 +456,12 @@ public class SetUniqueListTest<E> extend
// TODO: Generics
public void testCollections304() {
- List<String> list = new LinkedList<String>();
- SetUniqueList<String> decoratedList = SetUniqueList.setUniqueList(list);
- String s1 = "Apple";
- String s2 = "Lemon";
- String s3 = "Orange";
- String s4 = "Strawberry";
+ final List<String> list = new LinkedList<String>();
+ final SetUniqueList<String> decoratedList = SetUniqueList.setUniqueList(list);
+ final String s1 = "Apple";
+ final String s2 = "Lemon";
+ final String s3 = "Orange";
+ final String s4 = "Strawberry";
decoratedList.add(s1);
decoratedList.add(s2);
@@ -487,8 +487,8 @@ public class SetUniqueListTest<E> extend
List<E> list = new ArrayList<E>();
List<E> uniqueList = SetUniqueList.setUniqueList(list);
- String hello = "Hello";
- String world = "World";
+ final String hello = "Hello";
+ final String world = "World";
uniqueList.add((E) hello);
uniqueList.add((E) world);
@@ -525,13 +525,13 @@ public class SetUniqueListTest<E> extend
@SuppressWarnings("unchecked")
public void testRetainAll() {
- List<E> list = new ArrayList<E>(10);
- SetUniqueList<E> uniqueList = SetUniqueList.setUniqueList(list);
+ final List<E> list = new ArrayList<E>(10);
+ final SetUniqueList<E> uniqueList = SetUniqueList.setUniqueList(list);
for (int i = 0; i < 10; ++i) {
uniqueList.add((E)Integer.valueOf(i));
}
- Collection<E> retained = new ArrayList<E>(5);
+ final Collection<E> retained = new ArrayList<E>(5);
for (int i = 0; i < 5; ++i) {
retained.add((E)Integer.valueOf(i * 2));
}
@@ -548,16 +548,16 @@ public class SetUniqueListTest<E> extend
@SuppressWarnings("unchecked")
public void testRetainAllWithInitialList() {
// initialized with empty list
- List<E> list = new ArrayList<E>(10);
+ final List<E> list = new ArrayList<E>(10);
for (int i = 0; i < 5; ++i) {
list.add((E)Integer.valueOf(i));
}
- SetUniqueList<E> uniqueList = SetUniqueList.setUniqueList(list);
+ final SetUniqueList<E> uniqueList = SetUniqueList.setUniqueList(list);
for (int i = 5; i < 10; ++i) {
uniqueList.add((E)Integer.valueOf(i));
}
- Collection<E> retained = new ArrayList<E>(5);
+ final Collection<E> retained = new ArrayList<E>(5);
for (int i = 0; i < 5; ++i) {
retained.add((E)Integer.valueOf(i * 2));
}
@@ -575,20 +575,20 @@ public class SetUniqueListTest<E> extend
* test case for https://issues.apache.org/jira/browse/COLLECTIONS-427
*/
public void testRetainAllCollections427() {
- int size = 50000;
- ArrayList<Integer> list = new ArrayList<Integer>();
+ final int size = 50000;
+ final ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < size; i++) {
list.add(i);
}
- SetUniqueList<Integer> uniqueList = SetUniqueList.setUniqueList(list);
- ArrayList<Integer> toRetain = new ArrayList<Integer>();
+ final SetUniqueList<Integer> uniqueList = SetUniqueList.setUniqueList(list);
+ final ArrayList<Integer> toRetain = new ArrayList<Integer>();
for (int i = size; i < 2*size; i++) {
toRetain.add(i);
}
- long start = System.currentTimeMillis();
+ final long start = System.currentTimeMillis();
uniqueList.retainAll(toRetain);
- long stop = System.currentTimeMillis();
+ final long stop = System.currentTimeMillis();
// make sure retainAll completes under 5 seconds
// TODO if test is migrated to JUnit 4, add a Timeout rule.
@@ -598,7 +598,7 @@ public class SetUniqueListTest<E> extend
@SuppressWarnings("serial")
class SetUniqueList307 extends SetUniqueList<E> {
- public SetUniqueList307(List<E> list, Set<E> set) {
+ public SetUniqueList307(final List<E> list, final Set<E> set) {
super(list, set);
}
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/SynchronizedListTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/SynchronizedListTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/SynchronizedListTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/SynchronizedListTest.java Mon Jan 7 17:15:14 2013
@@ -30,7 +30,7 @@ import java.util.List;
*/
public class SynchronizedListTest<E> extends AbstractListTest<E> {
- public SynchronizedListTest(String testName) {
+ public SynchronizedListTest(final String testName) {
super(testName);
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/TransformedListTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/TransformedListTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/TransformedListTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/TransformedListTest.java Mon Jan 7 17:15:14 2013
@@ -35,7 +35,7 @@ import org.apache.commons.collections.co
*/
public class TransformedListTest<E> extends AbstractListTest<E> {
- public TransformedListTest(String testName) {
+ public TransformedListTest(final String testName) {
super(testName);
}
@@ -46,7 +46,7 @@ public class TransformedListTest<E> exte
@Override
public List<E> makeConfirmedFullCollection() {
- List<E> list = new ArrayList<E>();
+ final List<E> list = new ArrayList<E>();
list.addAll(Arrays.asList(getFullElements()));
return list;
}
@@ -60,16 +60,16 @@ public class TransformedListTest<E> exte
@Override
@SuppressWarnings("unchecked")
public List<E> makeFullCollection() {
- List<E> list = new ArrayList<E>();
+ final List<E> list = new ArrayList<E>();
list.addAll(Arrays.asList(getFullElements()));
return TransformedList.transformingList(list, (Transformer<E, E>) TransformedCollectionTest.NOOP_TRANSFORMER);
}
@SuppressWarnings("unchecked")
public void testTransformedList() {
- List<E> list = TransformedList.transformingList(new ArrayList<E>(), (Transformer<E, E>) TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
+ final List<E> list = TransformedList.transformingList(new ArrayList<E>(), (Transformer<E, E>) TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(0, list.size());
- E[] els = (E[]) new Object[] {"1", "3", "5", "7", "2", "4", "6"};
+ final E[] els = (E[]) new Object[] {"1", "3", "5", "7", "2", "4", "6"};
for (int i = 0; i < els.length; i++) {
list.add(els[i]);
assertEquals(i + 1, list.size());
@@ -90,14 +90,14 @@ public class TransformedListTest<E> exte
list.set(0, (E) "22");
assertEquals(new Integer(22), list.get(0));
- ListIterator<E> it = list.listIterator();
+ final ListIterator<E> it = list.listIterator();
it.next();
it.set((E) "33");
assertEquals(new Integer(33), list.get(0));
it.add((E) "44");
assertEquals(new Integer(44), list.get(1));
- List<E> adds = new ArrayList<E>();
+ final List<E> adds = new ArrayList<E>();
adds.add((E) "1");
adds.add((E) "2");
list.clear();
@@ -114,14 +114,14 @@ public class TransformedListTest<E> exte
}
public void testTransformedList_decorateTransform() {
- List<Object> originalList = new ArrayList<Object>();
- Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
- for (Object el : els) {
+ final List<Object> originalList = new ArrayList<Object>();
+ final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
+ for (final Object el : els) {
originalList.add(el);
}
- List<?> list = TransformedList.transformedList(originalList, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
+ final List<?> list = TransformedList.transformedList(originalList, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(els.length, list.size());
- for (Object el : els) {
+ for (final Object el : els) {
assertEquals(true, list.contains(new Integer((String) el)));
assertEquals(false, list.contains(el));
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/TreeListTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/TreeListTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/TreeListTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/TreeListTest.java Mon Jan 7 17:15:14 2013
@@ -33,7 +33,7 @@ import org.apache.commons.collections.Bu
*/
public class TreeListTest<E> extends AbstractListTest<E> {
- public TreeListTest(String name) {
+ public TreeListTest(final String name) {
super(name);
}
@@ -53,7 +53,7 @@ public class TreeListTest<E> extends Abs
return BulkTest.makeSuite(TreeListTest.class);
}
- public static void benchmark(List<? super Integer> l) {
+ public static void benchmark(final List<? super Integer> l) {
long start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) {
l.add(new Integer(i));
@@ -68,7 +68,7 @@ public class TreeListTest<E> extends Abs
start = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
- java.util.Iterator<? super Integer> it = l.iterator();
+ final java.util.Iterator<? super Integer> it = l.iterator();
while (it.hasNext()) {
it.next();
}
@@ -77,28 +77,28 @@ public class TreeListTest<E> extends Abs
start = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
- int j = (int) (Math.random() * 100000);
+ final int j = (int) (Math.random() * 100000);
l.add(j, new Integer(-j));
}
System.out.print(System.currentTimeMillis() - start + ";");
start = System.currentTimeMillis();
for (int i = 0; i < 50000; i++) {
- int j = (int) (Math.random() * 110000);
+ final int j = (int) (Math.random() * 110000);
l.get(j);
}
System.out.print(System.currentTimeMillis() - start + ";");
start = System.currentTimeMillis();
for (int i = 0; i < 200; i++) {
- int j = (int) (Math.random() * 100000);
+ final int j = (int) (Math.random() * 100000);
l.indexOf(new Integer(j));
}
System.out.print(System.currentTimeMillis() - start + ";");
start = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
- int j = (int) (Math.random() * 100000);
+ final int j = (int) (Math.random() * 100000);
l.remove(j);
}
System.out.print(System.currentTimeMillis() - start + ";");
@@ -113,7 +113,7 @@ public class TreeListTest<E> extends Abs
//-----------------------------------------------------------------------
@SuppressWarnings("unchecked")
public void testAddMultiple() {
- List<E> l = makeObject();
+ final List<E> l = makeObject();
l.add((E) "hugo");
l.add((E) "erna");
l.add((E) "daniel");
@@ -130,7 +130,7 @@ public class TreeListTest<E> extends Abs
@SuppressWarnings("unchecked")
public void testRemove() {
- List<E> l = makeObject();
+ final List<E> l = makeObject();
l.add((E) "hugo");
l.add((E) "erna");
l.add((E) "daniel");
@@ -169,7 +169,7 @@ public class TreeListTest<E> extends Abs
@SuppressWarnings("unchecked")
public void testInsertBefore() {
- List<E> l = makeObject();
+ final List<E> l = makeObject();
l.add((E) "erna");
l.add(0, (E) "hugo");
assertEquals("hugo", l.get(0));
@@ -178,7 +178,7 @@ public class TreeListTest<E> extends Abs
@SuppressWarnings("unchecked")
public void testIndexOf() {
- List<E> l = makeObject();
+ final List<E> l = makeObject();
l.add((E) "0");
l.add((E) "1");
l.add((E) "2");
@@ -218,9 +218,9 @@ public class TreeListTest<E> extends Abs
// }
public void testBug35258() {
- Object objectToRemove = new Integer(3);
+ final Object objectToRemove = new Integer(3);
- List<Integer> treelist = new TreeList<Integer>();
+ final List<Integer> treelist = new TreeList<Integer>();
treelist.add(new Integer(0));
treelist.add(new Integer(1));
treelist.add(new Integer(2));
@@ -230,7 +230,7 @@ public class TreeListTest<E> extends Abs
// this cause inconsistence of ListIterator()
treelist.remove(objectToRemove);
- ListIterator<Integer> li = treelist.listIterator();
+ final ListIterator<Integer> li = treelist.listIterator();
assertEquals(new Integer(0), li.next());
assertEquals(new Integer(0), li.previous());
assertEquals(new Integer(0), li.next());
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/UnmodifiableListTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/UnmodifiableListTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/UnmodifiableListTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/list/UnmodifiableListTest.java Mon Jan 7 17:15:14 2013
@@ -32,7 +32,7 @@ import java.util.List;
*/
public class UnmodifiableListTest<E> extends AbstractListTest<E> {
- public UnmodifiableListTest(String testName) {
+ public UnmodifiableListTest(final String testName) {
super(testName);
}
@@ -44,7 +44,7 @@ public class UnmodifiableListTest<E> ext
@Override
public UnmodifiableList<E> makeFullCollection() {
- ArrayList<E> list = new ArrayList<E>();
+ final ArrayList<E> list = new ArrayList<E>();
list.addAll(Arrays.asList(getFullElements()));
return new UnmodifiableList<E>(list);
}
@@ -85,65 +85,65 @@ public class UnmodifiableListTest<E> ext
}
@SuppressWarnings("unchecked")
- protected void verifyUnmodifiable(List<E> list) {
+ protected void verifyUnmodifiable(final List<E> list) {
try {
list.add(0, (E) new Integer(0));
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
try {
list.add((E) new Integer(0));
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
try {
list.addAll(0, array);
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
try {
list.addAll(array);
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
try {
list.clear();
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
try {
list.remove(0);
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
try {
list.remove(new Integer(0));
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
try {
list.removeAll(array);
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
try {
list.retainAll(array);
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
try {
list.set(0, (E) new Integer(0));
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
}
@@ -153,12 +153,12 @@ public class UnmodifiableListTest<E> ext
*/
public void testUnmodifiableIterator() {
setupList();
- Iterator<E> iterator = list.iterator();
+ final Iterator<E> iterator = list.iterator();
try {
iterator.next();
iterator.remove();
fail("Expecting UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// expected
}
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractIterableMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractIterableMapTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractIterableMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractIterableMapTest.java Mon Jan 7 17:15:14 2013
@@ -39,7 +39,7 @@ public abstract class AbstractIterableMa
*
* @param testName the test name
*/
- public AbstractIterableMapTest(String testName) {
+ public AbstractIterableMapTest(final String testName) {
super(testName);
}
@@ -67,12 +67,12 @@ public abstract class AbstractIterableMa
}
resetFull();
Iterator<Map.Entry<K, V>> it = getMap().entrySet().iterator();
- Map.Entry<K, V> val = it.next();
+ final Map.Entry<K, V> val = it.next();
getMap().remove(val.getKey());
try {
it.next();
fail();
- } catch (ConcurrentModificationException ex) {}
+ } catch (final ConcurrentModificationException ex) {}
resetFull();
it = getMap().entrySet().iterator();
@@ -81,7 +81,7 @@ public abstract class AbstractIterableMa
try {
it.next();
fail();
- } catch (ConcurrentModificationException ex) {}
+ } catch (final ConcurrentModificationException ex) {}
}
public void testFailFastKeySet() {
@@ -93,12 +93,12 @@ public abstract class AbstractIterableMa
}
resetFull();
Iterator<K> it = getMap().keySet().iterator();
- K val = it.next();
+ final K val = it.next();
getMap().remove(val);
try {
it.next();
fail();
- } catch (ConcurrentModificationException ex) {}
+ } catch (final ConcurrentModificationException ex) {}
resetFull();
it = getMap().keySet().iterator();
@@ -107,7 +107,7 @@ public abstract class AbstractIterableMa
try {
it.next();
fail();
- } catch (ConcurrentModificationException ex) {}
+ } catch (final ConcurrentModificationException ex) {}
}
public void testFailFastValues() {
@@ -124,7 +124,7 @@ public abstract class AbstractIterableMa
try {
it.next();
fail();
- } catch (ConcurrentModificationException ex) {}
+ } catch (final ConcurrentModificationException ex) {}
resetFull();
it = getMap().values().iterator();
@@ -133,7 +133,7 @@ public abstract class AbstractIterableMa
try {
it.next();
fail();
- } catch (ConcurrentModificationException ex) {}
+ } catch (final ConcurrentModificationException ex) {}
}
//-----------------------------------------------------------------------
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java Mon Jan 7 17:15:14 2013
@@ -133,7 +133,7 @@ public abstract class AbstractMapTest<K,
*/
private static final boolean JDK12;
static {
- String str = System.getProperty("java.version");
+ final String str = System.getProperty("java.version");
JDK12 = str.startsWith("1.2");
}
@@ -165,7 +165,7 @@ public abstract class AbstractMapTest<K,
*
* @param testName the test name
*/
- public AbstractMapTest(String testName) {
+ public AbstractMapTest(final String testName) {
super(testName);
}
@@ -300,7 +300,7 @@ public abstract class AbstractMapTest<K,
*/
@SuppressWarnings("unchecked")
public K[] getSampleKeys() {
- Object[] result = new Object[] {
+ final Object[] result = new Object[] {
"blah", "foo", "bar", "baz", "tmp", "gosh", "golly", "gee",
"hello", "goodbye", "we'll", "see", "you", "all", "again",
"key",
@@ -321,9 +321,9 @@ public abstract class AbstractMapTest<K,
}
@SuppressWarnings("unchecked")
- protected <E> List<E> getAsList(Object[] o) {
- ArrayList<E> result = new ArrayList<E>();
- for (Object element : o) {
+ protected <E> List<E> getAsList(final Object[] o) {
+ final ArrayList<E> result = new ArrayList<E>();
+ for (final Object element : o) {
result.add((E) element);
}
return result;
@@ -355,7 +355,7 @@ public abstract class AbstractMapTest<K,
*/
@SuppressWarnings("unchecked")
public V[] getSampleValues() {
- Object[] result = new Object[] {
+ final Object[] result = new Object[] {
"blahv", "foov", "barv", "bazv", "tmpv", "goshv", "gollyv", "geev",
"hellov", "goodbyev", "we'llv", "seev", "youv", "allv", "againv",
isAllowNullValue() && !JDK12 ? null : "nonnullvalue",
@@ -378,7 +378,7 @@ public abstract class AbstractMapTest<K,
*/
@SuppressWarnings("unchecked")
public V[] getNewSampleValues() {
- Object[] result = new Object[] {
+ final Object[] result = new Object[] {
isAllowNullValue() && !JDK12 && isAllowDuplicateValues() ? null : "newnonnullvalue",
"newvalue",
isAllowDuplicateValues() ? "newvalue" : "newvalue2",
@@ -393,15 +393,15 @@ public abstract class AbstractMapTest<K,
* Helper method to add all the mappings described by
* {@link #getSampleKeys()} and {@link #getSampleValues()}.
*/
- public void addSampleMappings(Map<? super K, ? super V> m) {
+ public void addSampleMappings(final Map<? super K, ? super V> m) {
- K[] keys = getSampleKeys();
- V[] values = getSampleValues();
+ final K[] keys = getSampleKeys();
+ final V[] values = getSampleValues();
for (int i = 0; i < keys.length; i++) {
try {
m.put(keys[i], values[i]);
- } catch (NullPointerException exception) {
+ } catch (final NullPointerException exception) {
assertTrue("NullPointerException only allowed to be thrown " +
"if either the key or value is null.",
keys[i] == null || values[i] == null);
@@ -440,7 +440,7 @@ public abstract class AbstractMapTest<K,
* @return the map to be tested
*/
public Map<K, V> makeFullMap() {
- Map<K, V> m = makeObject();
+ final Map<K, V> m = makeObject();
addSampleMappings(m);
return m;
}
@@ -457,8 +457,8 @@ public abstract class AbstractMapTest<K,
/**
* Creates a new Map Entry that is independent of the first and the map.
*/
- public static <K, V> Map.Entry<K, V> cloneMapEntry(Map.Entry<K, V> entry) {
- HashMap<K, V> map = new HashMap<K, V>();
+ public static <K, V> Map.Entry<K, V> cloneMapEntry(final Map.Entry<K, V> entry) {
+ final HashMap<K, V> map = new HashMap<K, V>();
map.put(entry.getKey(), entry.getValue());
return map.entrySet().iterator().next();
}
@@ -483,9 +483,9 @@ public abstract class AbstractMapTest<K,
* isAllowDuplicateValues() returns true.
*/
public void testSampleMappings() {
- Object[] keys = getSampleKeys();
- Object[] values = getSampleValues();
- Object[] newValues = getNewSampleValues();
+ final Object[] keys = getSampleKeys();
+ final Object[] values = getSampleValues();
+ final Object[] newValues = getNewSampleValues();
assertNotNull("failure in test: Must have keys returned from " +
"getSampleKeys.", keys);
@@ -534,22 +534,22 @@ public abstract class AbstractMapTest<K,
* map with each invocation.
*/
public void testMakeMap() {
- Map<K, V> em = makeObject();
+ final Map<K, V> em = makeObject();
assertTrue("failure in test: makeEmptyMap must return a non-null map.",
em != null);
- Map<K, V> em2 = makeObject();
+ final Map<K, V> em2 = makeObject();
assertTrue("failure in test: makeEmptyMap must return a non-null map.",
em != null);
assertTrue("failure in test: makeEmptyMap must return a new map " +
"with each invocation.", em != em2);
- Map<K, V> fm = makeFullMap();
+ final Map<K, V> fm = makeFullMap();
assertTrue("failure in test: makeFullMap must return a non-null map.",
fm != null);
- Map<K, V> fm2 = makeFullMap();
+ final Map<K, V> fm2 = makeFullMap();
assertTrue("failure in test: makeFullMap must return a non-null map.",
fm != null);
@@ -601,7 +601,7 @@ public abstract class AbstractMapTest<K,
resetFull();
getMap().clear();
fail("Expected UnsupportedOperationException on clear");
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
return;
}
@@ -622,7 +622,7 @@ public abstract class AbstractMapTest<K,
* all sample keys returned on a full map.
*/
public void testMapContainsKey() {
- Object[] keys = getSampleKeys();
+ final Object[] keys = getSampleKeys();
resetEmpty();
for(int i = 0; i < keys.length; i++) {
@@ -632,7 +632,7 @@ public abstract class AbstractMapTest<K,
verify();
resetFull();
- for (Object key : keys) {
+ for (final Object key : keys) {
assertTrue("Map must contain key for a mapping in the map. " +
"Missing: " + key, getMap().containsKey(key));
}
@@ -645,7 +645,7 @@ public abstract class AbstractMapTest<K,
* a full map.
*/
public void testMapContainsValue() {
- Object[] values = getSampleValues();
+ final Object[] values = getSampleValues();
resetEmpty();
for(int i = 0; i < values.length; i++) {
@@ -655,7 +655,7 @@ public abstract class AbstractMapTest<K,
verify();
resetFull();
- for (Object value : values) {
+ for (final Object value : values) {
assertTrue("Map must contain value for a mapping in the map.",
getMap().containsValue(value));
}
@@ -678,7 +678,7 @@ public abstract class AbstractMapTest<K,
resetFull();
// modify the HashMap created from the full map and make sure this
// change results in map.equals() to return false.
- Iterator<K> iter = confirmed.keySet().iterator();
+ final Iterator<K> iter = confirmed.keySet().iterator();
iter.next();
iter.remove();
assertTrue("Different maps equal.", !getMap().equals(confirmed));
@@ -696,10 +696,10 @@ public abstract class AbstractMapTest<K,
public void testMapGet() {
resetEmpty();
- Object[] keys = getSampleKeys();
- Object[] values = getSampleValues();
+ final Object[] keys = getSampleKeys();
+ final Object[] values = getSampleValues();
- for (Object key : keys) {
+ for (final Object key : keys) {
assertTrue("Empty map.get() should return null.",
getMap().get(key) == null);
}
@@ -760,9 +760,10 @@ public abstract class AbstractMapTest<K,
*/
// test to make sure the canonical form has been preserved
- Map<K, V> map = makeObject();
+ final Map<K, V> map = makeObject();
if (map instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
@SuppressWarnings("unchecked")
+ final
Map<K, V> map2 = (Map<K, V>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map));
assertEquals("Map is empty", 0, map2.size());
}
@@ -782,9 +783,10 @@ public abstract class AbstractMapTest<K,
*/
// test to make sure the canonical form has been preserved
- Map<K, V> map = makeFullMap();
+ final Map<K, V> map = makeFullMap();
if (map instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
@SuppressWarnings("unchecked")
+ final
Map<K, V> map2 = (Map<K, V>) readExternalFormFromDisk(getCanonicalFullCollectionName(map));
assertEquals("Map is the right size", getSampleKeys().length, map2.size());
}
@@ -795,13 +797,13 @@ public abstract class AbstractMapTest<K,
*/
public void testMapPut() {
resetEmpty();
- K[] keys = getSampleKeys();
- V[] values = getSampleValues();
- V[] newValues = getNewSampleValues();
+ final K[] keys = getSampleKeys();
+ final V[] values = getSampleValues();
+ final V[] newValues = getNewSampleValues();
if (isPutAddSupported()) {
for (int i = 0; i < keys.length; i++) {
- Object o = getMap().put(keys[i], values[i]);
+ final Object o = getMap().put(keys[i], values[i]);
getConfirmed().put(keys[i], values[i]);
verify();
assertTrue("First map.put should return null", o == null);
@@ -812,7 +814,7 @@ public abstract class AbstractMapTest<K,
}
if (isPutChangeSupported()) {
for (int i = 0; i < keys.length; i++) {
- Object o = getMap().put(keys[i], newValues[i]);
+ final Object o = getMap().put(keys[i], newValues[i]);
getConfirmed().put(keys[i], newValues[i]);
verify();
assertEquals("Map.put should return previous value when changed", values[i], o);
@@ -833,8 +835,8 @@ public abstract class AbstractMapTest<K,
// two possible exception here, either valid
getMap().put(keys[0], newValues[0]);
fail("Expected IllegalArgumentException or UnsupportedOperationException on put (change)");
- } catch (IllegalArgumentException ex) {
- } catch (UnsupportedOperationException ex) {}
+ } catch (final IllegalArgumentException ex) {
+ } catch (final UnsupportedOperationException ex) {}
}
} else if (isPutChangeSupported()) {
@@ -842,16 +844,16 @@ public abstract class AbstractMapTest<K,
try {
getMap().put(keys[0], values[0]);
fail("Expected UnsupportedOperationException or IllegalArgumentException on put (add) when fixed size");
- } catch (IllegalArgumentException ex) {
- } catch (UnsupportedOperationException ex) {
+ } catch (final IllegalArgumentException ex) {
+ } catch (final UnsupportedOperationException ex) {
}
resetFull();
int i = 0;
- for (Iterator<K> it = getMap().keySet().iterator(); it.hasNext() && i < newValues.length; i++) {
- K key = it.next();
- V o = getMap().put(key, newValues[i]);
- V value = getConfirmed().put(key, newValues[i]);
+ for (final Iterator<K> it = getMap().keySet().iterator(); it.hasNext() && i < newValues.length; i++) {
+ final K key = it.next();
+ final V o = getMap().put(key, newValues[i]);
+ final V value = getConfirmed().put(key, newValues[i]);
verify();
assertEquals("Map.put should return previous value when changed", value, o);
assertTrue("Map should still contain key after put when changed", getMap()
@@ -870,7 +872,7 @@ public abstract class AbstractMapTest<K,
try {
getMap().put(keys[0], values[0]);
fail("Expected UnsupportedOperationException on put (add)");
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
}
}
@@ -879,7 +881,7 @@ public abstract class AbstractMapTest<K,
*/
public void testMapPutNullKey() {
resetFull();
- V[] values = getSampleValues();
+ final V[] values = getSampleValues();
if (isPutAddSupported()) {
if (isAllowNullKey()) {
@@ -888,8 +890,8 @@ public abstract class AbstractMapTest<K,
try {
getMap().put(null, values[0]);
fail("put(null, value) should throw NPE/IAE");
- } catch (NullPointerException ex) {
- } catch (IllegalArgumentException ex) {}
+ } catch (final NullPointerException ex) {
+ } catch (final IllegalArgumentException ex) {}
}
}
}
@@ -899,7 +901,7 @@ public abstract class AbstractMapTest<K,
*/
public void testMapPutNullValue() {
resetFull();
- K[] keys = getSampleKeys();
+ final K[] keys = getSampleKeys();
if (isPutAddSupported()) {
if (isAllowNullValue()) {
@@ -908,8 +910,8 @@ public abstract class AbstractMapTest<K,
try {
getMap().put(keys[0], null);
fail("put(key, null) should throw NPE/IAE");
- } catch (NullPointerException ex) {
- } catch (IllegalArgumentException ex) {}
+ } catch (final NullPointerException ex) {
+ } catch (final IllegalArgumentException ex) {}
}
}
}
@@ -920,12 +922,12 @@ public abstract class AbstractMapTest<K,
public void testMapPutAll() {
if (!isPutAddSupported()) {
if (!isPutChangeSupported()) {
- Map<K, V> temp = makeFullMap();
+ final Map<K, V> temp = makeFullMap();
resetEmpty();
try {
getMap().putAll(temp);
fail("Expected UnsupportedOperationException on putAll");
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
}
return;
}
@@ -938,7 +940,7 @@ public abstract class AbstractMapTest<K,
// check putAll OK adding empty map to non-empty map
resetFull();
- int size = getMap().size();
+ final int size = getMap().size();
getMap().putAll(new HashMap<K, V>());
assertEquals(size, getMap().size());
@@ -952,8 +954,8 @@ public abstract class AbstractMapTest<K,
// check putAll OK adding non-empty JDK map to empty map
resetEmpty();
m2 = makeConfirmedMap();
- K[] keys = getSampleKeys();
- V[] values = getSampleValues();
+ final K[] keys = getSampleKeys();
+ final V[] values = getSampleValues();
for(int i = 0; i < keys.length; i++) {
m2.put(keys[i], values[i]);
}
@@ -984,16 +986,16 @@ public abstract class AbstractMapTest<K,
resetFull();
getMap().remove(getMap().keySet().iterator().next());
fail("Expected UnsupportedOperationException on remove");
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
return;
}
resetEmpty();
- Object[] keys = getSampleKeys();
- Object[] values = getSampleValues();
- for (Object key : keys) {
- Object o = getMap().remove(key);
+ final Object[] keys = getSampleKeys();
+ final Object[] values = getSampleValues();
+ for (final Object key : keys) {
+ final Object o = getMap().remove(key);
assertTrue("First map.remove should return null", o == null);
}
verify();
@@ -1001,7 +1003,7 @@ public abstract class AbstractMapTest<K,
resetFull();
for (int i = 0; i < keys.length; i++) {
- Object o = getMap().remove(keys[i]);
+ final Object o = getMap().remove(keys[i]);
getConfirmed().remove(keys[i]);
verify();
@@ -1009,12 +1011,12 @@ public abstract class AbstractMapTest<K,
values[i], o);
}
- Object[] other = getOtherKeys();
+ final Object[] other = getOtherKeys();
resetFull();
- int size = getMap().size();
- for (Object element : other) {
- Object o = getMap().remove(element);
+ final int size = getMap().size();
+ for (final Object element : other) {
+ final Object o = getMap().remove(element);
assertNull("map.remove for nonexistent key should return null", o);
assertEquals("map.remove for nonexistent key should not " +
"shrink map", size, getMap().size());
@@ -1110,27 +1112,27 @@ public abstract class AbstractMapTest<K,
//-----------------------------------------------------------------------
public void testEntrySetContains1() {
resetFull();
- Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
- Map.Entry<K, V> entry = entrySet.iterator().next();
+ final Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
+ final Map.Entry<K, V> entry = entrySet.iterator().next();
assertEquals(true, entrySet.contains(entry));
}
public void testEntrySetContains2() {
resetFull();
- Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
- Map.Entry<K, V> entry = entrySet.iterator().next();
- Map.Entry<K, V> test = cloneMapEntry(entry);
+ final Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
+ final Map.Entry<K, V> entry = entrySet.iterator().next();
+ final Map.Entry<K, V> test = cloneMapEntry(entry);
assertEquals(true, entrySet.contains(test));
}
@SuppressWarnings("unchecked")
public void testEntrySetContains3() {
resetFull();
- Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
- Map.Entry<K, V> entry = entrySet.iterator().next();
- HashMap<K, V> temp = new HashMap<K, V>();
+ final Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
+ final Map.Entry<K, V> entry = entrySet.iterator().next();
+ final HashMap<K, V> temp = new HashMap<K, V>();
temp.put(entry.getKey(), (V) "A VERY DIFFERENT VALUE");
- Map.Entry<K, V> test = temp.entrySet().iterator().next();
+ final Map.Entry<K, V> test = temp.entrySet().iterator().next();
assertEquals(false, entrySet.contains(test));
}
@@ -1139,10 +1141,10 @@ public abstract class AbstractMapTest<K,
return;
}
resetFull();
- int size = getMap().size();
- Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
- Map.Entry<K, V> entry = entrySet.iterator().next();
- K key = entry.getKey();
+ final int size = getMap().size();
+ final Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
+ final Map.Entry<K, V> entry = entrySet.iterator().next();
+ final K key = entry.getKey();
assertEquals(true, entrySet.remove(entry));
assertEquals(false, getMap().containsKey(key));
@@ -1154,11 +1156,11 @@ public abstract class AbstractMapTest<K,
return;
}
resetFull();
- int size = getMap().size();
- Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
- Map.Entry<K, V> entry = entrySet.iterator().next();
- K key = entry.getKey();
- Map.Entry<K, V> test = cloneMapEntry(entry);
+ final int size = getMap().size();
+ final Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
+ final Map.Entry<K, V> entry = entrySet.iterator().next();
+ final K key = entry.getKey();
+ final Map.Entry<K, V> test = cloneMapEntry(entry);
assertEquals(true, entrySet.remove(test));
assertEquals(false, getMap().containsKey(key));
@@ -1171,13 +1173,13 @@ public abstract class AbstractMapTest<K,
return;
}
resetFull();
- int size = getMap().size();
- Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
- Map.Entry<K, V> entry = entrySet.iterator().next();
- K key = entry.getKey();
- HashMap<K, V> temp = new HashMap<K, V>();
+ final int size = getMap().size();
+ final Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
+ final Map.Entry<K, V> entry = entrySet.iterator().next();
+ final K key = entry.getKey();
+ final HashMap<K, V> temp = new HashMap<K, V>();
temp.put(entry.getKey(), (V) "A VERY DIFFERENT VALUE");
- Map.Entry<K, V> test = temp.entrySet().iterator().next();
+ final Map.Entry<K, V> test = temp.entrySet().iterator().next();
assertEquals(false, entrySet.remove(test));
assertEquals(true, getMap().containsKey(key));
@@ -1202,15 +1204,15 @@ public abstract class AbstractMapTest<K,
*/
public void testValuesRemoveChangesMap() {
resetFull();
- V[] sampleValues = getSampleValues();
- Collection<V> values = getMap().values();
+ final V[] sampleValues = getSampleValues();
+ final Collection<V> values = getMap().values();
for (int i = 0; i < sampleValues.length; i++) {
if (map.containsValue(sampleValues[i])) {
int j = 0; // loop counter prevents infinite loops when remove is broken
while (values.contains(sampleValues[i]) && j < 10000) {
try {
values.remove(sampleValues[i]);
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// if values.remove is unsupported, just skip this test
return;
}
@@ -1229,21 +1231,21 @@ public abstract class AbstractMapTest<K,
*/
public void testValuesRemoveAll() {
resetFull();
- Collection<V> values = getMap().values();
- List<V> sampleValuesAsList = Arrays.asList(getSampleValues());
+ final Collection<V> values = getMap().values();
+ final List<V> sampleValuesAsList = Arrays.asList(getSampleValues());
if (!values.equals(sampleValuesAsList)) {
return;
}
try {
assertFalse(values.removeAll(Collections.<V> emptySet()));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// if values.removeAll is unsupported, just skip this test
return;
}
assertEquals(sampleValuesAsList.size(), getMap().size());
try {
assertTrue(values.removeAll(sampleValuesAsList));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// if values.removeAll is unsupported, just skip this test
return;
}
@@ -1255,21 +1257,21 @@ public abstract class AbstractMapTest<K,
*/
public void testValuesRetainAll() {
resetFull();
- Collection<V> values = getMap().values();
- List<V> sampleValuesAsList = Arrays.asList(getSampleValues());
+ final Collection<V> values = getMap().values();
+ final List<V> sampleValuesAsList = Arrays.asList(getSampleValues());
if (!values.equals(sampleValuesAsList)) {
return;
}
try {
assertFalse(values.retainAll(sampleValuesAsList));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// if values.retainAll is unsupported, just skip this test
return;
}
assertEquals(sampleValuesAsList.size(), getMap().size());
try {
assertTrue(values.retainAll(Collections.<V> emptySet()));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// if values.retainAll is unsupported, just skip this test
return;
}
@@ -1281,11 +1283,11 @@ public abstract class AbstractMapTest<K,
*/
public void testValuesIteratorRemoveChangesMap() {
resetFull();
- List<V> sampleValuesAsList = Arrays.asList(getSampleValues());
- Map<V, Integer> cardinality = CollectionUtils.getCardinalityMap(sampleValuesAsList);
- Collection<V> values = getMap().values();
- for (Iterator<V> iter = values.iterator(); iter.hasNext();) {
- V value = iter.next();
+ final List<V> sampleValuesAsList = Arrays.asList(getSampleValues());
+ final Map<V, Integer> cardinality = CollectionUtils.getCardinalityMap(sampleValuesAsList);
+ final Collection<V> values = getMap().values();
+ for (final Iterator<V> iter = values.iterator(); iter.hasNext();) {
+ final V value = iter.next();
Integer count = cardinality.get(value);
if (count == null) {
return;
@@ -1293,12 +1295,12 @@ public abstract class AbstractMapTest<K,
try {
iter.remove();
cardinality.put(value, --count);
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// if values.iterator.remove is unsupported, just skip this test
return;
}
- boolean expected = count > 0;
- StringBuilder msg = new StringBuilder("Value should ");
+ final boolean expected = count > 0;
+ final StringBuilder msg = new StringBuilder("Value should ");
msg.append(expected ? "yet " : "no longer ");
msg.append("be present in the underlying map");
assertEquals(msg.toString(), expected, getMap().containsValue(value));
@@ -1313,12 +1315,12 @@ public abstract class AbstractMapTest<K,
*/
public void testKeySetRemoveChangesMap() {
resetFull();
- K[] sampleKeys = getSampleKeys();
- Set<K> keys = getMap().keySet();
+ final K[] sampleKeys = getSampleKeys();
+ final Set<K> keys = getMap().keySet();
for (int i = 0; i < sampleKeys.length; i++) {
try {
keys.remove(sampleKeys[i]);
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// if key.remove is unsupported, just skip this test
return;
}
@@ -1333,20 +1335,20 @@ public abstract class AbstractMapTest<K,
*/
public void testKeySetRemoveAll() {
resetFull();
- Set<K> keys = getMap().keySet();
- List<K> sampleKeysAsList = Arrays.asList(getSampleKeys());
+ final Set<K> keys = getMap().keySet();
+ final List<K> sampleKeysAsList = Arrays.asList(getSampleKeys());
if (!keys.equals(sampleKeysAsList)) {
return;
}
try {
assertFalse(keys.removeAll(Collections.<K> emptySet()));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
return;
}
assertEquals(sampleKeysAsList, keys);
try {
assertTrue(keys.removeAll(sampleKeysAsList));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
return;
}
assertTrue(getMap().isEmpty());
@@ -1357,20 +1359,20 @@ public abstract class AbstractMapTest<K,
*/
public void testKeySetRetainAll() {
resetFull();
- Set<K> keys = getMap().keySet();
- List<K> sampleKeysAsList = Arrays.asList(getSampleKeys());
+ final Set<K> keys = getMap().keySet();
+ final List<K> sampleKeysAsList = Arrays.asList(getSampleKeys());
if (!keys.equals(sampleKeysAsList)) {
return;
}
try {
assertFalse(keys.retainAll(sampleKeysAsList));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
return;
}
assertEquals(sampleKeysAsList, keys);
try {
assertTrue(keys.retainAll(Collections.<K> emptySet()));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
return;
}
assertTrue(getMap().isEmpty());
@@ -1381,11 +1383,11 @@ public abstract class AbstractMapTest<K,
*/
public void testKeySetIteratorRemoveChangesMap() {
resetFull();
- for (Iterator<K> iter = getMap().keySet().iterator(); iter.hasNext();) {
- K key = iter.next();
+ for (final Iterator<K> iter = getMap().keySet().iterator(); iter.hasNext();) {
+ final K key = iter.next();
try {
iter.remove();
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
return;
}
assertFalse(getMap().containsKey(key));
@@ -1399,13 +1401,13 @@ public abstract class AbstractMapTest<K,
*/
public void testEntrySetRemoveChangesMap() {
resetFull();
- K[] sampleKeys = getSampleKeys();
- V[] sampleValues = getSampleValues();
- Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
+ final K[] sampleKeys = getSampleKeys();
+ final V[] sampleValues = getSampleValues();
+ final Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
for (int i = 0; i < sampleKeys.length; i++) {
try {
entrySet.remove(new DefaultMapEntry<K, V>(sampleKeys[i], sampleValues[i]));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// if entrySet removal is unsupported, just skip this test
return;
}
@@ -1420,31 +1422,31 @@ public abstract class AbstractMapTest<K,
*/
public void testEntrySetRemoveAll() {
resetFull();
- K[] sampleKeys = getSampleKeys();
- V[] sampleValues = getSampleValues();
+ final K[] sampleKeys = getSampleKeys();
+ final V[] sampleValues = getSampleValues();
//verify map looks as expected:
for (int i = 0; i < sampleKeys.length; i++) {
if (!getMap().containsKey(sampleKeys[i])) {
return;
}
- V value = sampleValues[i];
- V test = getMap().get(sampleKeys[i]);
+ final V value = sampleValues[i];
+ final V test = getMap().get(sampleKeys[i]);
if (value == test || value != null && value.equals(test)) {
continue;
}
return;
}
- Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
- HashSet<Map.Entry<K, V>> comparisonSet = new HashSet<Map.Entry<K, V>>(entrySet);
+ final Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
+ final HashSet<Map.Entry<K, V>> comparisonSet = new HashSet<Map.Entry<K, V>>(entrySet);
try {
assertFalse(entrySet.removeAll(Collections.<Map.Entry<K, V>> emptySet()));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
return;
}
assertEquals(sampleKeys.length, getMap().size());
try {
assertTrue(entrySet.removeAll(comparisonSet));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
return;
}
assertTrue(getMap().isEmpty());
@@ -1455,31 +1457,31 @@ public abstract class AbstractMapTest<K,
*/
public void testEntrySetRetainAll() {
resetFull();
- K[] sampleKeys = getSampleKeys();
- V[] sampleValues = getSampleValues();
+ final K[] sampleKeys = getSampleKeys();
+ final V[] sampleValues = getSampleValues();
//verify map looks as expected:
for (int i = 0; i < sampleKeys.length; i++) {
if (!getMap().containsKey(sampleKeys[i])) {
return;
}
- V value = sampleValues[i];
- V test = getMap().get(sampleKeys[i]);
+ final V value = sampleValues[i];
+ final V test = getMap().get(sampleKeys[i]);
if (value == test || value != null && value.equals(test)) {
continue;
}
return;
}
- Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
- HashSet<Map.Entry<K, V>> comparisonSet = new HashSet<Map.Entry<K, V>>(entrySet);
+ final Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
+ final HashSet<Map.Entry<K, V>> comparisonSet = new HashSet<Map.Entry<K, V>>(entrySet);
try {
assertFalse(entrySet.retainAll(comparisonSet));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
return;
}
assertEquals(sampleKeys.length, getMap().size());
try {
assertTrue(entrySet.retainAll(Collections.<Map.Entry<K, V>> emptySet()));
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
return;
}
assertTrue(getMap().isEmpty());
@@ -1490,11 +1492,11 @@ public abstract class AbstractMapTest<K,
*/
public void testEntrySetIteratorRemoveChangesMap() {
resetFull();
- for (Iterator<Map.Entry<K, V>> iter = getMap().entrySet().iterator(); iter.hasNext();) {
- K key = iter.next().getKey();
+ for (final Iterator<Map.Entry<K, V>> iter = getMap().entrySet().iterator(); iter.hasNext();) {
+ final K key = iter.next().getKey();
try {
iter.remove();
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
return;
}
assertFalse(getMap().containsKey(key));
@@ -1510,10 +1512,10 @@ public abstract class AbstractMapTest<K,
* @return an array of Map.Entry of those keys to those values
*/
@SuppressWarnings("unchecked")
- private Map.Entry<K, V>[] makeEntryArray(K[] keys, V[] values) {
- Map.Entry<K, V>[] result = new Map.Entry[keys.length];
+ private Map.Entry<K, V>[] makeEntryArray(final K[] keys, final V[] values) {
+ final Map.Entry<K, V>[] result = new Map.Entry[keys.length];
for (int i = 0; i < keys.length; i++) {
- Map<K, V> map = makeConfirmedMap();
+ final Map<K, V> map = makeConfirmedMap();
map.put(keys[i], values[i]);
result[i] = map.entrySet().iterator().next();
}
@@ -1551,16 +1553,16 @@ public abstract class AbstractMapTest<K,
*/
@Override
public Map.Entry<K, V>[] getFullNonNullElements() {
- K[] k = getSampleKeys();
- V[] v = getSampleValues();
+ final K[] k = getSampleKeys();
+ final V[] v = getSampleValues();
return makeEntryArray(k, v);
}
// Have to implement manually; entrySet doesn't support addAll
@Override
public Map.Entry<K, V>[] getOtherElements() {
- K[] k = getOtherKeys();
- V[] v = getOtherValues();
+ final K[] k = getOtherKeys();
+ final V[] v = getOtherValues();
return makeEntryArray(k, v);
}
@@ -1611,10 +1613,10 @@ public abstract class AbstractMapTest<K,
public void testMapEntrySetIteratorEntry() {
resetFull();
- Iterator<Map.Entry<K, V>> it = getCollection().iterator();
+ final Iterator<Map.Entry<K, V>> it = getCollection().iterator();
int count = 0;
while (it.hasNext()) {
- Map.Entry<K, V> entry = it.next();
+ final Map.Entry<K, V> entry = it.next();
assertEquals(true, AbstractMapTest.this.getMap().containsKey(entry.getKey()));
assertEquals(true, AbstractMapTest.this.getMap().containsValue(entry.getValue()));
if (isGetStructuralModify() == false) {
@@ -1626,28 +1628,28 @@ public abstract class AbstractMapTest<K,
}
public void testMapEntrySetIteratorEntrySetValue() {
- K key1 = getSampleKeys()[0];
- K key2 = getSampleKeys().length == 1 ? getSampleKeys()[0] : getSampleKeys()[1];
- V newValue1 = getNewSampleValues()[0];
- V newValue2 = getNewSampleValues().length ==1 ? getNewSampleValues()[0] : getNewSampleValues()[1];
+ final K key1 = getSampleKeys()[0];
+ final K key2 = getSampleKeys().length == 1 ? getSampleKeys()[0] : getSampleKeys()[1];
+ final V newValue1 = getNewSampleValues()[0];
+ final V newValue2 = getNewSampleValues().length ==1 ? getNewSampleValues()[0] : getNewSampleValues()[1];
resetFull();
// explicitly get entries as sample values/keys are connected for some maps
// such as BeanMap
Iterator<Map.Entry<K, V>> it = TestMapEntrySet.this.getCollection().iterator();
- Map.Entry<K, V> entry1 = getEntry(it, key1);
+ final Map.Entry<K, V> entry1 = getEntry(it, key1);
it = TestMapEntrySet.this.getCollection().iterator();
- Map.Entry<K, V> entry2 = getEntry(it, key2);
+ final Map.Entry<K, V> entry2 = getEntry(it, key2);
Iterator<Map.Entry<K, V>> itConfirmed = TestMapEntrySet.this.getConfirmed().iterator();
- Map.Entry<K, V> entryConfirmed1 = getEntry(itConfirmed, key1);
+ final Map.Entry<K, V> entryConfirmed1 = getEntry(itConfirmed, key1);
itConfirmed = TestMapEntrySet.this.getConfirmed().iterator();
- Map.Entry<K, V> entryConfirmed2 = getEntry(itConfirmed, key2);
+ final Map.Entry<K, V> entryConfirmed2 = getEntry(itConfirmed, key2);
verify();
if (isSetValueSupported() == false) {
try {
entry1.setValue(newValue1);
- } catch (UnsupportedOperationException ex) {
+ } catch (final UnsupportedOperationException ex) {
}
return;
}
@@ -1677,10 +1679,10 @@ public abstract class AbstractMapTest<K,
verify();
}
- public Map.Entry<K, V> getEntry(Iterator<Map.Entry<K, V>> itConfirmed, K key) {
+ public Map.Entry<K, V> getEntry(final Iterator<Map.Entry<K, V>> itConfirmed, final K key) {
Map.Entry<K, V> entry = null;
while (itConfirmed.hasNext()) {
- Map.Entry<K, V> temp = itConfirmed.next();
+ final Map.Entry<K, V> temp = itConfirmed.next();
if (temp.getKey() == null) {
if (key == null) {
entry = temp;
@@ -1911,8 +1913,8 @@ public abstract class AbstractMapTest<K,
this.map = makeFullMap();
views();
this.confirmed = makeConfirmedMap();
- K[] k = getSampleKeys();
- V[] v = getSampleValues();
+ final K[] k = getSampleKeys();
+ final V[] v = getSampleValues();
for (int i = 0; i < k.length; i++) {
confirmed.put(k[i], v[i]);
}
@@ -1945,8 +1947,8 @@ public abstract class AbstractMapTest<K,
}
public void verifyMap() {
- int size = getConfirmed().size();
- boolean empty = getConfirmed().isEmpty();
+ final int size = getConfirmed().size();
+ final boolean empty = getConfirmed().isEmpty();
assertEquals("Map should be same size as HashMap", size, getMap().size());
assertEquals("Map should be empty if HashMap is", empty, getMap().isEmpty());
assertEquals("hashCodes should be the same", getConfirmed().hashCode(), getMap().hashCode());
@@ -1962,8 +1964,8 @@ public abstract class AbstractMapTest<K,
}
public void verifyEntrySet() {
- int size = getConfirmed().size();
- boolean empty = getConfirmed().isEmpty();
+ final int size = getConfirmed().size();
+ final boolean empty = getConfirmed().isEmpty();
assertEquals("entrySet should be same size as HashMap's" +
"\nTest: " + entrySet + "\nReal: " + getConfirmed().entrySet(),
size, entrySet.size());
@@ -1981,8 +1983,8 @@ public abstract class AbstractMapTest<K,
}
public void verifyKeySet() {
- int size = getConfirmed().size();
- boolean empty = getConfirmed().isEmpty();
+ final int size = getConfirmed().size();
+ final boolean empty = getConfirmed().isEmpty();
assertEquals("keySet should be same size as HashMap's" +
"\nTest: " + keySet + "\nReal: " + getConfirmed().keySet(),
size, keySet.size());
@@ -2000,11 +2002,11 @@ public abstract class AbstractMapTest<K,
}
public void verifyValues() {
- List<V> known = new ArrayList<V>(getConfirmed().values());
- List<V> test = new ArrayList<V>(values);
+ final List<V> known = new ArrayList<V>(getConfirmed().values());
+ final List<V> test = new ArrayList<V>(values);
- int size = getConfirmed().size();
- boolean empty = getConfirmed().isEmpty();
+ final int size = getConfirmed().size();
+ final boolean empty = getConfirmed().isEmpty();
assertEquals("values should be same size as HashMap's" +
"\nTest: " + test + "\nReal: " + known,
size, values.size());
@@ -2018,8 +2020,8 @@ public abstract class AbstractMapTest<K,
"\nTest: " + test + "\nReal: " + known,
known.containsAll(test));
// originally coded to use a HashBag, but now separate jar so...
- for (V v : known) {
- boolean removed = test.remove(v);
+ for (final V v : known) {
+ final boolean removed = test.remove(v);
assertTrue("Map's values should still equal HashMap's", removed);
}
assertTrue("Map's values should still equal HashMap's", test.isEmpty());
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractOrderedMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractOrderedMapTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractOrderedMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractOrderedMapTest.java Mon Jan 7 17:15:14 2013
@@ -45,7 +45,7 @@ public abstract class AbstractOrderedMap
*
* @param testName the test name
*/
- public AbstractOrderedMapTest(String testName) {
+ public AbstractOrderedMapTest(final String testName) {
super(testName);
}
@@ -81,7 +81,7 @@ public abstract class AbstractOrderedMap
@Override
@SuppressWarnings("unchecked")
public K[] getSampleKeys() {
- List<K> list = new ArrayList<K>(Arrays.asList(super.getSampleKeys()));
+ final List<K> list = new ArrayList<K>(Arrays.asList(super.getSampleKeys()));
Collections.sort(list, new NullComparator<K>());
return (K[]) list.toArray();
}
@@ -93,11 +93,11 @@ public abstract class AbstractOrderedMap
try {
ordered.firstKey();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
resetFull();
ordered = getMap();
- K confirmedFirst = confirmed.keySet().iterator().next();
+ final K confirmedFirst = confirmed.keySet().iterator().next();
assertEquals(confirmedFirst, ordered.firstKey());
}
@@ -107,12 +107,12 @@ public abstract class AbstractOrderedMap
try {
ordered.lastKey();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
resetFull();
ordered = getMap();
K confirmedLast = null;
- for (Iterator<K> it = confirmed.keySet().iterator(); it.hasNext();) {
+ for (final Iterator<K> it = confirmed.keySet().iterator(); it.hasNext();) {
confirmedLast = it.next();
}
assertEquals(confirmedLast, ordered.lastKey());
@@ -126,17 +126,17 @@ public abstract class AbstractOrderedMap
if (!isAllowNullKey()) {
try {
assertEquals(null, ordered.nextKey(null)); // this is allowed too
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
} else {
assertEquals(null, ordered.nextKey(null));
}
resetFull();
ordered = getMap();
- Iterator<K> it = confirmed.keySet().iterator();
+ final Iterator<K> it = confirmed.keySet().iterator();
K confirmedLast = it.next();
while (it.hasNext()) {
- K confirmedObject = it.next();
+ final K confirmedObject = it.next();
assertEquals(confirmedObject, ordered.nextKey(confirmedLast));
confirmedLast = confirmedObject;
}
@@ -146,7 +146,7 @@ public abstract class AbstractOrderedMap
try {
ordered.nextKey(null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
} else {
assertEquals(null, ordered.nextKey(null));
}
@@ -159,19 +159,19 @@ public abstract class AbstractOrderedMap
if (isAllowNullKey() == false) {
try {
assertEquals(null, ordered.previousKey(null)); // this is allowed too
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
} else {
assertEquals(null, ordered.previousKey(null));
}
resetFull();
ordered = getMap();
- List<K> list = new ArrayList<K>(confirmed.keySet());
+ final List<K> list = new ArrayList<K>(confirmed.keySet());
Collections.reverse(list);
- Iterator<K> it = list.iterator();
+ final Iterator<K> it = list.iterator();
K confirmedLast = it.next();
while (it.hasNext()) {
- K confirmedObject = it.next();
+ final K confirmedObject = it.next();
assertEquals(confirmedObject, ordered.previousKey(confirmedLast));
confirmedLast = confirmedObject;
}
@@ -181,7 +181,7 @@ public abstract class AbstractOrderedMap
try {
ordered.previousKey(null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
} else {
if (isAllowNullKey() == false) {
assertEquals(null, ordered.previousKey(null));
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractSortedMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractSortedMapTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractSortedMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractSortedMapTest.java Mon Jan 7 17:15:14 2013
@@ -41,7 +41,7 @@ public abstract class AbstractSortedMapT
*
* @param testName the test name
*/
- public AbstractSortedMapTest(String testName) {
+ public AbstractSortedMapTest(final String testName) {
super(testName);
}
@@ -87,14 +87,14 @@ public abstract class AbstractSortedMapT
}
public void testFirstKey() {
- SortedMap<K, V> sm = makeFullMap();
+ final SortedMap<K, V> sm = makeFullMap();
assertSame(sm.keySet().iterator().next(), sm.firstKey());
}
public void testLastKey() {
- SortedMap<K, V> sm = makeFullMap();
+ final SortedMap<K, V> sm = makeFullMap();
K obj = null;
- for (Iterator<K> it = sm.keySet().iterator(); it.hasNext();) {
+ for (final Iterator<K> it = sm.keySet().iterator(); it.hasNext();) {
obj = it.next();
}
assertSame(obj, sm.lastKey());
@@ -119,7 +119,7 @@ public abstract class AbstractSortedMapT
protected final List<V> subSortedValues = new ArrayList<V>();
protected final List<V> subSortedNewValues = new ArrayList<V>();
- public TestViewMap(String name, AbstractMapTest<K, V> main) {
+ public TestViewMap(final String name, final AbstractMapTest<K, V> main) {
super(name);
this.main = main;
}
@@ -216,10 +216,10 @@ public abstract class AbstractSortedMapT
static final int SUBSIZE = 6;
final K toKey;
- public TestHeadMap(AbstractMapTest<K, V> main) {
+ public TestHeadMap(final AbstractMapTest<K, V> main) {
super("SortedMap.HeadMap", main);
- Map<K, V> sm = main.makeFullMap();
- for (Entry<K, V> entry : sm.entrySet()) {
+ final Map<K, V> sm = main.makeFullMap();
+ for (final Entry<K, V> entry : sm.entrySet()) {
this.subSortedKeys.add(entry.getKey());
this.subSortedValues.add(entry.getValue());
}
@@ -245,7 +245,7 @@ public abstract class AbstractSortedMapT
try {
getMap().put(toKey, subSortedValues.get(0));
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
verify();
}
@Override
@@ -270,10 +270,10 @@ public abstract class AbstractSortedMapT
final K fromKey;
final K invalidKey;
- public TestTailMap(AbstractMapTest<K, V> main) {
+ public TestTailMap(final AbstractMapTest<K, V> main) {
super("SortedMap.TailMap", main);
- Map<K, V> sm = main.makeFullMap();
- for (Entry<K, V> entry : sm.entrySet()) {
+ final Map<K, V> sm = main.makeFullMap();
+ for (final Entry<K, V> entry : sm.entrySet()) {
this.subSortedKeys.add(entry.getKey());
this.subSortedValues.add(entry.getValue());
}
@@ -300,7 +300,7 @@ public abstract class AbstractSortedMapT
try {
getMap().put(invalidKey, subSortedValues.get(0));
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
verify();
}
@Override
@@ -325,10 +325,10 @@ public abstract class AbstractSortedMapT
final K fromKey;
final K toKey;
- public TestSubMap(AbstractMapTest<K, V> main) {
+ public TestSubMap(final AbstractMapTest<K, V> main) {
super("SortedMap.SubMap", main);
- Map<K, V> sm = main.makeFullMap();
- for (Entry<K, V> entry : sm.entrySet()) {
+ final Map<K, V> sm = main.makeFullMap();
+ for (final Entry<K, V> entry : sm.entrySet()) {
this.subSortedKeys.add(entry.getKey());
this.subSortedValues.add(entry.getValue());
}
@@ -362,7 +362,7 @@ public abstract class AbstractSortedMapT
try {
getMap().put(toKey, subSortedValues.get(0));
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
verify();
}
@Override