You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by eb...@apache.org on 2013/11/11 22:58:28 UTC
svn commit: r1540860 - in
/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4:
./ bag/ bidimap/ collection/ comparators/ iterators/ keyvalue/ list/ map/
queue/ sequence/ set/
Author: ebourg
Date: Mon Nov 11 21:58:27 2013
New Revision: 1540860
URL: http://svn.apache.org/r1540860
Log:
Code simplification
Modified:
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/BulkTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SetUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractIterableMapTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/IdentityMap.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/BulkTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/BulkTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/BulkTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/BulkTest.java Mon Nov 11 21:58:27 2013
@@ -426,7 +426,7 @@ class BulkTestSuiteMaker {
private static <T extends BulkTest> BulkTest makeTestCase(final Class<T> c, final Method m) {
final Constructor<T> con = getTestCaseConstructor(c);
try {
- return con.newInstance(new Object[] { m.getName() });
+ return con.newInstance(m.getName());
} catch (final InvocationTargetException e) {
e.printStackTrace();
throw new RuntimeException(); // FIXME;
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java Mon Nov 11 21:58:27 2013
@@ -673,7 +673,7 @@ public class CollectionUtilsTest extends
lastElement = CollectionUtils.forAllButLastDo(col, testClosure);
assertNull(lastElement);
- Collection<String> strings = Arrays.asList(new String[]{"a", "b", "c"});
+ Collection<String> strings = Arrays.asList("a", "b", "c");
final StringBuffer result = new StringBuffer();
result.append(CollectionUtils.forAllButLastDo(strings, new Closure<String>() {
public void execute(String input) {
@@ -682,7 +682,7 @@ public class CollectionUtilsTest extends
}));
assertEquals("a;b;c", result.toString());
- Collection<String> oneString = Arrays.asList(new String[]{"a"});
+ Collection<String> oneString = Arrays.asList("a");
final StringBuffer resultOne = new StringBuffer();
resultOne.append(CollectionUtils.forAllButLastDo(oneString, new Closure<String>() {
public void execute(String input) {
@@ -690,8 +690,8 @@ public class CollectionUtilsTest extends
}
}));
assertEquals("a", resultOne.toString());
- assertNull(CollectionUtils.forAllButLastDo(strings, (Closure<String>) null));
- assertNull(CollectionUtils.forAllButLastDo((Collection<String>) null, (Closure<String>) null));
+ assertNull(CollectionUtils.forAllButLastDo(strings, null));
+ assertNull(CollectionUtils.forAllButLastDo((Collection<String>) null, null));
}
@Test
@@ -705,7 +705,7 @@ public class CollectionUtilsTest extends
assertTrue(collectionA.isEmpty() && !collectionB.isEmpty());
assertNull(CollectionUtils.forAllButLastDo(col.iterator(), (Closure<List<? extends Number>>) null));
- assertNull(CollectionUtils.forAllButLastDo((Iterator<String>) null, (Closure<String>) null));
+ assertNull(CollectionUtils.forAllButLastDo((Iterator<String>) null, null));
}
@Test
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ListUtilsTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ListUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ListUtilsTest.java Mon Nov 11 21:58:27 2013
@@ -179,7 +179,7 @@ public class ListUtilsTest extends BulkT
}
public void testEquals() {
- final Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+ final Collection<String> data = Arrays.asList("a", "b", "c");
final List<String> a = new ArrayList<String>( data );
final List<String> b = new ArrayList<String>( data );
@@ -194,7 +194,7 @@ public class ListUtilsTest extends BulkT
}
public void testHashCode() {
- final Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+ final Collection<String> data = Arrays.asList("a", "b", "c");
final List<String> a = new ArrayList<String>(data);
final List<String> b = new ArrayList<String>(data);
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SetUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SetUtilsTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SetUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SetUtilsTest.java Mon Nov 11 21:58:27 2013
@@ -73,7 +73,7 @@ public class SetUtilsTest extends BulkTe
}
public void testEquals() {
- final Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+ final Collection<String> data = Arrays.asList("a", "b", "c");
final Set<String> a = new HashSet<String>(data);
final Set<String> b = new HashSet<String>(data);
@@ -88,7 +88,7 @@ public class SetUtilsTest extends BulkTe
}
public void testHashCode() {
- final Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+ final Collection<String> data = Arrays.asList("a", "b", "c");
final Set<String> a = new HashSet<String>(data);
final Set<String> b = new HashSet<String>(data);
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java Mon Nov 11 21:58:27 2013
@@ -357,7 +357,7 @@ public abstract class AbstractBagTest<T>
final String element = (String) i.next();
// ignore the first A, remove the second via Iterator.remove()
if (element.equals("A")) {
- if (foundA == false) {
+ if (!foundA) {
foundA = true;
} else {
i.remove();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java Mon Nov 11 21:58:27 2013
@@ -80,7 +80,7 @@ public abstract class AbstractBidiMapTes
//-----------------------------------------------------------------------
@SuppressWarnings("unchecked")
public void testBidiPut() {
- if (isPutAddSupported() == false || isPutChangeSupported() == false) {
+ if (!isPutAddSupported() || !isPutChangeSupported()) {
return;
}
@@ -152,7 +152,7 @@ public abstract class AbstractBidiMapTes
getSampleKeys()[0]);
}
- private final void doTestGetKey(final BidiMap<?, ?> map, final Object key, final Object value) {
+ private void doTestGetKey(final BidiMap<?, ?> map, final Object key, final Object value) {
assertEquals("Value not found for key.", value, map.get(key));
assertEquals("Key not found for value.", key, map.getKey(value));
}
@@ -181,7 +181,7 @@ public abstract class AbstractBidiMapTes
//-----------------------------------------------------------------------
public void testBidiModifyEntrySet() {
- if (isSetValueSupported() == false) {
+ if (!isSetValueSupported()) {
return;
}
@@ -190,7 +190,7 @@ public abstract class AbstractBidiMapTes
}
@SuppressWarnings("unchecked")
- private final <T> void modifyEntrySet(final BidiMap<?, T> map) {
+ private <T> void modifyEntrySet(final BidiMap<?, T> map) {
// Gets first entry
final Map.Entry<?, T> entry = map.entrySet().iterator().next();
@@ -214,7 +214,7 @@ public abstract class AbstractBidiMapTes
//-----------------------------------------------------------------------
public void testBidiClear() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
try {
makeFullMap().clear();
fail();
@@ -237,7 +237,7 @@ public abstract class AbstractBidiMapTes
//-----------------------------------------------------------------------
public void testBidiRemove() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
try {
makeFullMap().remove(getSampleKeys()[0]);
fail();
@@ -258,13 +258,13 @@ public abstract class AbstractBidiMapTes
assertEquals(null, makeFullMap().removeValue("NotPresent"));
}
- private final void remove(final BidiMap<?, ?> map, final Object key) {
+ private void remove(final BidiMap<?, ?> map, final Object key) {
final Object value = map.remove(key);
assertTrue("Key was not removed.", !map.containsKey(key));
assertNull("Value was not removed.", map.getKey(value));
}
- private final void removeValue(final BidiMap<?, ?> map, final Object value) {
+ private void removeValue(final BidiMap<?, ?> map, final Object value) {
final Object key = map.removeValue(value);
assertTrue("Key was not removed.", !map.containsKey(key));
assertNull("Value was not removed.", map.getKey(value));
@@ -286,7 +286,7 @@ public abstract class AbstractBidiMapTes
//-----------------------------------------------------------------------
public void testBidiRemoveByKeySet() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
@@ -294,7 +294,7 @@ public abstract class AbstractBidiMapTes
removeByKeySet(makeFullMap().inverseBidiMap(), getSampleValues()[0], getSampleKeys()[0]);
}
- private final void removeByKeySet(final BidiMap<?, ?> map, final Object key, final Object value) {
+ private void removeByKeySet(final BidiMap<?, ?> map, final Object key, final Object value) {
map.keySet().remove(key);
assertTrue("Key was not removed.", !map.containsKey(key));
@@ -310,7 +310,7 @@ public abstract class AbstractBidiMapTes
//-----------------------------------------------------------------------
public void testBidiRemoveByEntrySet() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
@@ -318,7 +318,7 @@ public abstract class AbstractBidiMapTes
removeByEntrySet(makeFullMap().inverseBidiMap(), getSampleValues()[0], getSampleKeys()[0]);
}
- private final void removeByEntrySet(final BidiMap<?, ?> map, final Object key, final Object value) {
+ private void removeByEntrySet(final BidiMap<?, ?> map, final Object key, final Object value) {
final Map<Object, Object> temp = new HashMap<Object, Object>();
temp.put(key, value);
map.entrySet().remove(temp.entrySet().iterator().next());
@@ -371,7 +371,7 @@ public abstract class AbstractBidiMapTes
final Map.Entry<K, V> entryConfirmed2 = getEntry(itConfirmed, key2);
TestBidiMapEntrySet.this.verify();
- if (isSetValueSupported() == false) {
+ if (!isSetValueSupported()) {
try {
entry1.setValue(newValue1);
} catch (final UnsupportedOperationException ex) {
@@ -545,7 +545,7 @@ public abstract class AbstractBidiMapTes
assertEquals(true, it.hasNext());
final K key1 = it.next();
- if (isSetValueSupported() == false) {
+ if (!isSetValueSupported()) {
try {
it.setValue(newValue1);
fail();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java Mon Nov 11 21:58:27 2013
@@ -80,7 +80,7 @@ public abstract class AbstractOrderedBid
resetEmpty();
OrderedBidiMap<K, V> bidi = (OrderedBidiMap<K, V>) map;
assertEquals(null, bidi.nextKey(getOtherKeys()[0]));
- if (isAllowNullKey() == false) {
+ if (!isAllowNullKey()) {
try {
assertEquals(null, bidi.nextKey(null)); // this is allowed too
} catch (final NullPointerException ex) {}
@@ -99,7 +99,7 @@ public abstract class AbstractOrderedBid
}
assertEquals(null, bidi.nextKey(confirmedLast));
- if (isAllowNullKey() == false) {
+ if (!isAllowNullKey()) {
try {
bidi.nextKey(null);
fail();
@@ -113,7 +113,7 @@ public abstract class AbstractOrderedBid
resetEmpty();
OrderedBidiMap<K, V> bidi = getMap();
assertEquals(null, bidi.previousKey(getOtherKeys()[0]));
- if (isAllowNullKey() == false) {
+ if (!isAllowNullKey()) {
try {
assertEquals(null, bidi.previousKey(null)); // this is allowed too
} catch (final NullPointerException ex) {}
@@ -134,7 +134,7 @@ public abstract class AbstractOrderedBid
}
assertEquals(null, bidi.previousKey(confirmedLast));
- if (isAllowNullKey() == false) {
+ if (!isAllowNullKey()) {
try {
bidi.previousKey(null);
fail();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java Mon Nov 11 21:58:27 2013
@@ -129,7 +129,7 @@ public abstract class AbstractSortedBidi
//-----------------------------------------------------------------------
public void testBidiClearByHeadMap() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
@@ -176,7 +176,7 @@ public abstract class AbstractSortedBidi
//-----------------------------------------------------------------------
public void testBidiRemoveByHeadMap() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
@@ -220,7 +220,7 @@ public abstract class AbstractSortedBidi
//-----------------------------------------------------------------------
public void testBidiRemoveByHeadMapEntrySet() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
@@ -303,7 +303,7 @@ public abstract class AbstractSortedBidi
//-----------------------------------------------------------------------
public void testBidiClearByTailMap() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
@@ -352,7 +352,7 @@ public abstract class AbstractSortedBidi
//-----------------------------------------------------------------------
public void testBidiRemoveByTailMap() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
@@ -397,7 +397,7 @@ public abstract class AbstractSortedBidi
//-----------------------------------------------------------------------
public void testBidiRemoveByTailMapEntrySet() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
@@ -487,7 +487,7 @@ public abstract class AbstractSortedBidi
//-----------------------------------------------------------------------
public void testBidiClearBySubMap() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
@@ -544,7 +544,7 @@ public abstract class AbstractSortedBidi
//-----------------------------------------------------------------------
public void testBidiRemoveBySubMap() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
@@ -590,7 +590,7 @@ public abstract class AbstractSortedBidi
//-----------------------------------------------------------------------
public void testBidiRemoveBySubMapEntrySet() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java Mon Nov 11 21:58:27 2013
@@ -672,9 +672,9 @@ public abstract class AbstractCollection
resetFull();
elements = getOtherElements();
- for (int i = 0; i < elements.length; i++) {
+ for (Object element : elements) {
assertTrue("Full collection shouldn't contain element",
- !getCollection().contains(elements[i]));
+ !getCollection().contains(element));
}
}
@@ -862,16 +862,16 @@ public abstract class AbstractCollection
resetEmpty();
final E[] elements = getFullElements();
- for (int i = 0; i < elements.length; i++) {
- assertTrue("Shouldn't remove nonexistent element", !getCollection().remove(elements[i]));
+ for (E element : elements) {
+ assertTrue("Shouldn't remove nonexistent element", !getCollection().remove(element));
verify();
}
final E[] other = getOtherElements();
resetFull();
- for (int i = 0; i < other.length; i++) {
- assertTrue("Shouldn't remove nonexistent other element", !getCollection().remove(other[i]));
+ for (E element : other) {
+ assertTrue("Shouldn't remove nonexistent other element", !getCollection().remove(element));
verify();
}
@@ -940,10 +940,8 @@ public abstract class AbstractCollection
verify();
assertTrue("Collection should shrink after removeAll", getCollection().size() < size);
- final Iterator<E> iter = all.iterator();
- while (iter.hasNext()) {
- assertTrue("Collection shouldn't contain removed element",
- !getCollection().contains(iter.next()));
+ for (E element : all) {
+ assertTrue("Collection shouldn't contain removed element", !getCollection().contains(element));
}
}
@@ -994,10 +992,8 @@ public abstract class AbstractCollection
getConfirmed().retainAll(elements.subList(min, max));
verify();
- final Iterator<E> iter = getCollection().iterator();
- while (iter.hasNext()) {
- assertTrue("Collection only contains retained element",
- elements.subList(min, max).contains(iter.next()));
+ for (E element : getCollection()) {
+ assertTrue("Collection only contains retained element", elements.subList(min, max).contains(element));
}
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java Mon Nov 11 21:58:27 2013
@@ -19,6 +19,7 @@ package org.apache.commons.collections4.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.apache.commons.collections4.Transformer;
@@ -86,32 +87,30 @@ public class TransformedCollectionTest e
public void testTransformedCollection() {
final Collection<Object> coll = TransformedCollection.transformingCollection(new ArrayList<Object>(), STRING_TO_INTEGER_TRANSFORMER);
assertEquals(0, coll.size());
- final Object[] els = getFullElements();
- for (int i = 0; i < els.length; i++) {
- coll.add(els[i]);
+ final Object[] elements = getFullElements();
+ for (int i = 0; i < elements.length; i++) {
+ coll.add(elements[i]);
assertEquals(i + 1, coll.size());
- assertEquals(true, coll.contains(Integer.valueOf((String) els[i])));
- assertEquals(false, coll.contains(els[i]));
+ assertEquals(true, coll.contains(Integer.valueOf((String) elements[i])));
+ assertEquals(false, coll.contains(elements[i]));
}
- assertEquals(true, coll.remove(Integer.valueOf((String) els[0])));
+ assertEquals(true, coll.remove(Integer.valueOf((String) elements[0])));
}
public void testTransformedCollection_decorateTransform() {
final Collection<Object> originalCollection = new ArrayList<Object>();
- final Object[] els = getFullElements();
- for (final Object el : els) {
- originalCollection.add(el);
- }
+ final Object[] elements = getFullElements();
+ Collections.addAll(originalCollection, elements);
final Collection<Object> collection = TransformedCollection.transformedCollection(originalCollection, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
- assertEquals(els.length, collection.size());
- for (final Object el : els) {
- assertEquals(true, collection.contains(Integer.valueOf((String) el)));
- assertEquals(false, collection.contains(el));
+ assertEquals(elements.length, collection.size());
+ for (final Object element : elements) {
+ assertEquals(true, collection.contains(Integer.valueOf((String) element)));
+ assertEquals(false, collection.contains(element));
}
- assertEquals(false, collection.remove(els[0]));
- assertEquals(true, collection.remove(Integer.valueOf((String) els[0])));
+ assertEquals(false, collection.remove(elements[0]));
+ assertEquals(true, collection.remove(Integer.valueOf((String) elements[0])));
}
@Override
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java Mon Nov 11 21:58:27 2013
@@ -216,7 +216,7 @@ public class FixedOrderComparatorTest ex
boolean isInNewOrder = false;
final Random rand = new Random();
- while (keys.length > 1 && isInNewOrder == false) {
+ while (keys.length > 1 && !isInNewOrder) {
// shuffle:
for (int i = keys.length-1; i > 0; i--) {
final String swap = keys[i];
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java Mon Nov 11 21:58:27 2013
@@ -101,7 +101,7 @@ public abstract class AbstractIteratorTe
* Test the empty iterator.
*/
public void testEmptyIterator() {
- if (supportsEmptyIterator() == false) {
+ if (!supportsEmptyIterator()) {
return;
}
@@ -125,7 +125,7 @@ public abstract class AbstractIteratorTe
* Test normal iteration behaviour.
*/
public void testFullIterator() {
- if (supportsFullIterator() == false) {
+ if (!supportsFullIterator()) {
return;
}
@@ -163,7 +163,7 @@ public abstract class AbstractIteratorTe
public void testRemove() {
final Iterator<E> it = makeObject();
- if (supportsRemove() == false) {
+ if (!supportsRemove()) {
// check for UnsupportedOperationException if not supported
try {
it.remove();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java Mon Nov 11 21:58:27 2013
@@ -92,7 +92,7 @@ public abstract class AbstractListIterat
* Test that the empty list iterator contract is correct.
*/
public void testEmptyListIteratorIsIndeedEmpty() {
- if (supportsEmptyIterator() == false) {
+ if (!supportsEmptyIterator()) {
return;
}
@@ -163,7 +163,7 @@ public abstract class AbstractListIterat
ListIterator<E> it = makeObject();
final E addValue = addSetValue();
- if (supportsAdd() == false) {
+ if (!supportsAdd()) {
// check for UnsupportedOperationException if not supported
try {
it.add(addValue);
@@ -198,7 +198,7 @@ public abstract class AbstractListIterat
public void testSet() {
final ListIterator<E> it = makeObject();
- if (supportsSet() == false) {
+ if (!supportsSet()) {
// check for UnsupportedOperationException if not supported
try {
it.set(addSetValue());
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java Mon Nov 11 21:58:27 2013
@@ -112,7 +112,7 @@ public abstract class AbstractMapIterato
* Test that the empty list iterator contract is correct.
*/
public void testEmptyMapIterator() {
- if (supportsEmptyIterator() == false) {
+ if (!supportsEmptyIterator()) {
return;
}
@@ -137,7 +137,7 @@ public abstract class AbstractMapIterato
fail();
} catch (final IllegalStateException ex) {}
- if (supportsSetValue() == false) {
+ if (!supportsSetValue()) {
// setValue() should throw an UnsupportedOperationException/IllegalStateException
try {
it.setValue(addSetValues()[0]);
@@ -158,7 +158,7 @@ public abstract class AbstractMapIterato
* Test that the full list iterator contract is correct.
*/
public void testFullMapIterator() {
- if (supportsFullIterator() == false) {
+ if (!supportsFullIterator()) {
return;
}
@@ -177,7 +177,7 @@ public abstract class AbstractMapIterato
// getValue
final V value = it.getValue();
- if (isGetStructuralModify() == false) {
+ if (!isGetStructuralModify()) {
assertSame("Value must be mapped to key", map.get(key), value);
}
assertTrue("Value must be in map", map.containsValue(value));
@@ -188,7 +188,7 @@ public abstract class AbstractMapIterato
//-----------------------------------------------------------------------
public void testMapIteratorSet() {
- if (supportsFullIterator() == false) {
+ if (!supportsFullIterator()) {
return;
}
@@ -201,7 +201,7 @@ public abstract class AbstractMapIterato
final K key = it.next();
final V value = it.getValue();
- if (supportsSetValue() == false) {
+ if (!supportsSetValue()) {
try {
it.setValue(newValue);
fail();
@@ -242,7 +242,7 @@ public abstract class AbstractMapIterato
assertEquals(true, it.hasNext());
final K key = it.next();
- if (supportsRemove() == false) {
+ if (!supportsRemove()) {
try {
it.remove();
fail();
@@ -265,7 +265,7 @@ public abstract class AbstractMapIterato
//-----------------------------------------------------------------------
public void testMapIteratorSetRemoveSet() {
- if (supportsSetValue() == false || supportsRemove() == false) {
+ if (!supportsSetValue() || !supportsRemove()) {
return;
}
final V newValue = addSetValues()[0];
@@ -289,7 +289,7 @@ public abstract class AbstractMapIterato
//-----------------------------------------------------------------------
public void testMapIteratorRemoveGetKey() {
- if (supportsRemove() == false) {
+ if (!supportsRemove()) {
return;
}
final MapIterator<K, V> it = makeObject();
@@ -311,7 +311,7 @@ public abstract class AbstractMapIterato
//-----------------------------------------------------------------------
public void testMapIteratorRemoveGetValue() {
- if (supportsRemove() == false) {
+ if (!supportsRemove()) {
return;
}
final MapIterator<K, V> it = makeObject();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java Mon Nov 11 21:58:27 2013
@@ -61,7 +61,7 @@ public abstract class AbstractOrderedMap
*/
@Override
public void testEmptyMapIterator() {
- if (supportsEmptyIterator() == false) {
+ if (!supportsEmptyIterator()) {
return;
}
@@ -81,7 +81,7 @@ public abstract class AbstractOrderedMap
*/
@Override
public void testFullMapIterator() {
- if (supportsFullIterator() == false) {
+ if (!supportsFullIterator()) {
return;
}
@@ -102,7 +102,7 @@ public abstract class AbstractOrderedMap
// getValue
final V value = it.getValue();
- if (isGetStructuralModify() == false) {
+ if (!isGetStructuralModify()) {
assertSame("Value must be mapped to key", map.get(key), value);
}
assertTrue("Value must be in map", map.containsValue(value));
@@ -120,7 +120,7 @@ public abstract class AbstractOrderedMap
// getValue
final Object value = it.getValue();
- if (isGetStructuralModify() == false) {
+ if (!isGetStructuralModify()) {
assertSame("Value must be mapped to key", map.get(key), value);
}
assertTrue("Value must be in map", map.containsValue(value));
@@ -136,7 +136,7 @@ public abstract class AbstractOrderedMap
* Test that the iterator order matches the keySet order.
*/
public void testMapIteratorOrder() {
- if (supportsFullIterator() == false) {
+ if (!supportsFullIterator()) {
return;
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java Mon Nov 11 21:58:27 2013
@@ -48,7 +48,7 @@ public class LoopingIteratorTest extends
public void testLooping0() throws Exception {
final List<Object> list = new ArrayList<Object>();
final LoopingIterator<Object> loop = new LoopingIterator<Object>(list);
- assertTrue("hasNext should return false", loop.hasNext() == false);
+ assertTrue("hasNext should return false", !loop.hasNext());
try {
loop.next();
@@ -62,7 +62,7 @@ public class LoopingIteratorTest extends
* @throws Exception If something unexpected occurs.
*/
public void testLooping1() throws Exception {
- final List<String> list = Arrays.asList(new String[] { "a" });
+ final List<String> list = Arrays.asList("a");
final LoopingIterator<String> loop = new LoopingIterator<String>(list);
assertTrue("1st hasNext should return true", loop.hasNext());
@@ -81,7 +81,7 @@ public class LoopingIteratorTest extends
* @throws Exception If something unexpected occurs.
*/
public void testLooping2() throws Exception {
- final List<String> list = Arrays.asList(new String[] { "a", "b" });
+ final List<String> list = Arrays.asList("a", "b");
final LoopingIterator<String> loop = new LoopingIterator<String>(list);
assertTrue("1st hasNext should return true", loop.hasNext());
@@ -100,7 +100,7 @@ public class LoopingIteratorTest extends
* @throws Exception If something unexpected occurs.
*/
public void testLooping3() throws Exception {
- final List<String> list = Arrays.asList(new String[] { "a", "b", "c" });
+ final List<String> list = Arrays.asList("a", "b", "c");
final LoopingIterator<String> loop = new LoopingIterator<String>(list);
assertTrue("1st hasNext should return true", loop.hasNext());
@@ -122,7 +122,7 @@ public class LoopingIteratorTest extends
* @throws Exception If something unexpected occurs.
*/
public void testRemoving1() throws Exception {
- final List<String> list = new ArrayList<String>(Arrays.asList(new String[] { "a", "b", "c" }));
+ final List<String> list = new ArrayList<String>(Arrays.asList("a", "b", "c"));
final LoopingIterator<String> loop = new LoopingIterator<String>(list);
assertEquals("list should have 3 elements.", 3, list.size());
@@ -141,7 +141,7 @@ public class LoopingIteratorTest extends
loop.remove(); // removes c
assertEquals("list should have 0 elements.", 0, list.size());
- assertTrue("4th hasNext should return false", loop.hasNext() == false);
+ assertFalse("4th hasNext should return false", loop.hasNext());
try {
loop.next();
fail("Expected NoSuchElementException to be thrown.");
@@ -154,7 +154,7 @@ public class LoopingIteratorTest extends
* @throws Exception If something unexpected occurs.
*/
public void testReset() throws Exception {
- final List<String> list = Arrays.asList(new String[] { "a", "b", "c" });
+ final List<String> list = Arrays.asList("a", "b", "c");
final LoopingIterator<String> loop = new LoopingIterator<String>(list);
assertEquals("a", loop.next());
@@ -176,7 +176,7 @@ public class LoopingIteratorTest extends
* @throws Exception If something unexpected occurs.
*/
public void testSize() throws Exception {
- final List<String> list = new ArrayList<String>(Arrays.asList(new String[] { "a", "b", "c" }));
+ final List<String> list = new ArrayList<String>(Arrays.asList("a", "b", "c"));
final LoopingIterator<String> loop = new LoopingIterator<String>(list);
assertEquals(3, loop.size());
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java Mon Nov 11 21:58:27 2013
@@ -68,7 +68,7 @@ public class LoopingListIteratorTest ext
* one element.
*/
public void testLooping1() throws Exception {
- final List<String> list = Arrays.asList(new String[] { "a" });
+ final List<String> list = Arrays.asList("a");
final LoopingListIterator<String> loop = new LoopingListIterator<String>(list); // <a>
assertTrue(loop.hasNext());
@@ -95,7 +95,7 @@ public class LoopingListIteratorTest ext
* elements.
*/
public void testLooping2() throws Exception {
- final List<String> list = Arrays.asList(new String[] { "a", "b" });
+ final List<String> list = Arrays.asList("a", "b");
final LoopingListIterator<String> loop = new LoopingListIterator<String>(list); // <a> b
assertTrue(loop.hasNext());
@@ -125,7 +125,7 @@ public class LoopingListIteratorTest ext
* the begin/end boundary of the list.
*/
public void testJoggingNotOverBoundary() {
- final List<String> list = Arrays.asList(new String[] { "a", "b" });
+ final List<String> list = Arrays.asList("a", "b");
final LoopingListIterator<String> loop = new LoopingListIterator<String>(list); // <a> b
// Try jogging back and forth between the elements, but not
@@ -145,7 +145,7 @@ public class LoopingListIteratorTest ext
* begin/end boundary of the list.
*/
public void testJoggingOverBoundary() {
- final List<String> list = Arrays.asList(new String[] { "a", "b" });
+ final List<String> list = Arrays.asList("a", "b");
final LoopingListIterator<String> loop = new LoopingListIterator<String>(list); // <a> b
// Try jogging back and forth between the elements, but not
@@ -163,7 +163,7 @@ public class LoopingListIteratorTest ext
* Tests removing an element from a wrapped ArrayList.
*/
public void testRemovingElementsAndIteratingForward() {
- final List<String> list = new ArrayList<String>(Arrays.asList(new String[] { "a", "b", "c" }));
+ final List<String> list = new ArrayList<String>(Arrays.asList("a", "b", "c"));
final LoopingListIterator<String> loop = new LoopingListIterator<String>(list); // <a> b c
assertTrue(loop.hasNext());
@@ -193,7 +193,7 @@ public class LoopingListIteratorTest ext
* Tests removing an element from a wrapped ArrayList.
*/
public void testRemovingElementsAndIteratingBackwards() {
- final List<String> list = new ArrayList<String>(Arrays.asList(new String[] { "a", "b", "c" }));
+ final List<String> list = new ArrayList<String>(Arrays.asList("a", "b", "c"));
final LoopingListIterator<String> loop = new LoopingListIterator<String>(list); // <a> b c
assertTrue(loop.hasPrevious());
@@ -223,7 +223,7 @@ public class LoopingListIteratorTest ext
* Tests the reset method.
*/
public void testReset() {
- final List<String> list = Arrays.asList(new String[] { "a", "b", "c" });
+ final List<String> list = Arrays.asList("a", "b", "c");
final LoopingListIterator<String> loop = new LoopingListIterator<String>(list); // <a> b c
assertEquals("a", loop.next()); // a <b> c
@@ -250,7 +250,7 @@ public class LoopingListIteratorTest ext
* Tests the add method.
*/
public void testAdd() {
- List<String> list = new ArrayList<String>(Arrays.asList(new String[] { "b", "e", "f" }));
+ List<String> list = new ArrayList<String>(Arrays.asList("b", "e", "f"));
LoopingListIterator<String> loop = new LoopingListIterator<String>(list); // <b> e f
loop.add("a"); // <a> b e f
@@ -275,7 +275,7 @@ public class LoopingListIteratorTest ext
assertEquals("f", loop.next()); // <a> b c d e f
assertEquals("a", loop.next()); // a <b> c d e f
- list = new ArrayList<String>(Arrays.asList(new String[] { "b", "e", "f" }));
+ list = new ArrayList<String>(Arrays.asList("b", "e", "f"));
loop = new LoopingListIterator<String>(list); // <b> e f
loop.add("a"); // a <b> e f
@@ -304,7 +304,7 @@ public class LoopingListIteratorTest ext
* Tests nextIndex and previousIndex.
*/
public void testNextAndPreviousIndex() {
- final List<String> list = Arrays.asList(new String[] { "a", "b", "c" });
+ final List<String> list = Arrays.asList("a", "b", "c");
final LoopingListIterator<String> loop = new LoopingListIterator<String>(list); // <a> b c
assertEquals(0, loop.nextIndex());
@@ -335,7 +335,7 @@ public class LoopingListIteratorTest ext
* Tests using the set method to change elements.
*/
public void testSet() {
- final List<String> list = Arrays.asList(new String[] { "q", "r", "z" });
+ final List<String> list = Arrays.asList("q", "r", "z");
final LoopingListIterator<String> loop = new LoopingListIterator<String>(list); // <q> r z
assertEquals("z", loop.previous()); // q r <z>
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java Mon Nov 11 21:58:27 2013
@@ -53,7 +53,7 @@ public class MultiKeyTest extends TestCa
//-----------------------------------------------------------------------
public void testConstructors() throws Exception {
- MultiKey<Integer> mk = null;
+ MultiKey<Integer> mk;
mk = new MultiKey<Integer>(ONE, TWO);
assertTrue(Arrays.equals(new Object[] { ONE, TWO }, mk.getKeys()));
@@ -71,7 +71,7 @@ public class MultiKeyTest extends TestCa
}
public void testConstructorsByArray() throws Exception {
- MultiKey<Integer> mk = null;
+ MultiKey<Integer> mk;
Integer[] keys = new Integer[] { THREE, FOUR, ONE, TWO };
mk = new MultiKey<Integer>(keys);
assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
@@ -193,9 +193,9 @@ public class MultiKeyTest extends TestCa
assertEquals(mk1, mk1);
assertEquals(mk1, mk2);
- assertTrue(mk1.equals(mk3) == false);
- assertTrue(mk1.equals("") == false);
- assertTrue(mk1.equals(null) == false);
+ assertFalse(mk1.equals(mk3));
+ assertFalse(mk1.equals(""));
+ assertFalse(mk1.equals(null));
}
static class SystemHashCodeSimulatingKey implements Serializable {
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java Mon Nov 11 21:58:27 2013
@@ -34,7 +34,7 @@ public abstract class AbstractLinkedList
public void testRemoveFirst() {
resetEmpty();
final AbstractLinkedList<E> list = getCollection();
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
try {
list.removeFirst();
} catch (final UnsupportedOperationException ex) {}
@@ -58,7 +58,7 @@ public abstract class AbstractLinkedList
public void testRemoveLast() {
resetEmpty();
final AbstractLinkedList<E> list = getCollection();
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
try {
list.removeLast();
} catch (final UnsupportedOperationException ex) {}
@@ -79,7 +79,7 @@ public abstract class AbstractLinkedList
public void testAddNodeAfter() {
resetEmpty();
final AbstractLinkedList<E> list = getCollection();
- if (isAddSupported() == false) {
+ if (!isAddSupported()) {
try {
list.addFirst(null);
} catch (final UnsupportedOperationException ex) {}
@@ -111,7 +111,7 @@ public abstract class AbstractLinkedList
@SuppressWarnings("unchecked")
public void testRemoveNode() {
resetEmpty();
- if (isAddSupported() == false || isRemoveSupported() == false) {
+ if (!isAddSupported() || !isRemoveSupported()) {
return;
}
final AbstractLinkedList<E> list = getCollection();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java Mon Nov 11 21:58:27 2013
@@ -473,11 +473,9 @@ public abstract class AbstractListTest<E
final List<E> list1 = getCollection();
final List<E> list2 = getConfirmed();
- final Iterator<E> iterator = list2.iterator();
- while (iterator.hasNext()) {
- final Object element = iterator.next();
+ for (E element : list2) {
assertEquals("indexOf should return correct result",
- list1.indexOf(element), list2.indexOf(element));
+ list1.indexOf(element), list2.indexOf(element));
verify();
}
@@ -793,7 +791,7 @@ public abstract class AbstractListTest<E
* Tests remove on list iterator is correct.
*/
public void testListListIteratorPreviousRemoveNext() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
resetFull();
@@ -825,7 +823,7 @@ public abstract class AbstractListTest<E
* Tests remove on list iterator is correct.
*/
public void testListListIteratorPreviousRemovePrevious() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
resetFull();
@@ -857,7 +855,7 @@ public abstract class AbstractListTest<E
* Tests remove on list iterator is correct.
*/
public void testListListIteratorNextRemoveNext() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
resetFull();
@@ -886,7 +884,7 @@ public abstract class AbstractListTest<E
* Tests remove on list iterator is correct.
*/
public void testListListIteratorNextRemovePrevious() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
resetFull();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java Mon Nov 11 21:58:27 2013
@@ -52,7 +52,7 @@ public class NodeCachingLinkedListTest<E
//-----------------------------------------------------------------------
@SuppressWarnings("unchecked")
public void testShrinkCache() {
- if (isRemoveSupported() == false || isAddSupported() == false) {
+ if (!isRemoveSupported() || !isAddSupported()) {
return;
}
resetEmpty();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java Mon Nov 11 21:58:27 2013
@@ -148,7 +148,7 @@ public class SetUniqueListTest<E> extend
// add two new unique elements at index 0
final Integer firstNewElement = Integer.valueOf(2);
final Integer secondNewElement = Integer.valueOf(3);
- Collection<Integer> collection = Arrays.asList(new Integer[] {firstNewElement, secondNewElement});
+ Collection<Integer> collection = Arrays.asList(firstNewElement, secondNewElement);
list.addAll(0, collection);
assertEquals("Unique elements should be added.", 3, list.size());
assertEquals("First new element should be at index 0", firstNewElement, list.get(0));
@@ -157,7 +157,7 @@ public class SetUniqueListTest<E> extend
// add a duplicate element and a unique element at index 0
final Integer thirdNewElement = Integer.valueOf(4);
- collection = Arrays.asList(new Integer[] {existingElement, thirdNewElement});
+ collection = Arrays.asList(existingElement, thirdNewElement);
list.addAll(0, collection);
assertEquals("Duplicate element should not be added, unique element should be added.",
4, list.size());
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractIterableMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractIterableMapTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractIterableMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractIterableMapTest.java Mon Nov 11 21:58:27 2013
@@ -57,10 +57,10 @@ public abstract class AbstractIterableMa
//-----------------------------------------------------------------------
public void testFailFastEntrySet() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
- if (isFailFastExpected() == false) {
+ if (!isFailFastExpected()) {
return;
}
resetFull();
@@ -83,10 +83,10 @@ public abstract class AbstractIterableMa
}
public void testFailFastKeySet() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
- if (isFailFastExpected() == false) {
+ if (!isFailFastExpected()) {
return;
}
resetFull();
@@ -109,10 +109,10 @@ public abstract class AbstractIterableMa
}
public void testFailFastValues() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
- if (isFailFastExpected() == false) {
+ if (!isFailFastExpected()) {
return;
}
resetFull();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java Mon Nov 11 21:58:27 2013
@@ -621,14 +621,14 @@ public abstract class AbstractMapTest<K,
final Object[] keys = getSampleKeys();
resetEmpty();
- for(int i = 0; i < keys.length; i++) {
+ for (Object key : keys) {
assertTrue("Map must not contain key when map is empty",
- !getMap().containsKey(keys[i]));
+ !getMap().containsKey(key));
}
verify();
resetFull();
- for (final Object key : keys) {
+ for (Object key : keys) {
assertTrue("Map must contain key for a mapping in the map. " +
"Missing: " + key, getMap().containsKey(key));
}
@@ -1614,7 +1614,7 @@ public abstract class AbstractMapTest<K,
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) {
+ if (!isGetStructuralModify()) {
assertEquals(AbstractMapTest.this.getMap().get(entry.getKey()), entry.getValue());
}
count++;
@@ -1641,7 +1641,7 @@ public abstract class AbstractMapTest<K,
final Map.Entry<K, V> entryConfirmed2 = getEntry(itConfirmed, key2);
verify();
- if (isSetValueSupported() == false) {
+ if (!isSetValueSupported()) {
try {
entry1.setValue(newValue1);
} catch (final UnsupportedOperationException ex) {
@@ -1693,7 +1693,7 @@ public abstract class AbstractMapTest<K,
}
public void testMapEntrySetRemoveNonMapEntry() {
- if (isRemoveSupported() == false) {
+ if (!isRemoveSupported()) {
return;
}
resetFull();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java Mon Nov 11 21:58:27 2013
@@ -140,7 +140,7 @@ public abstract class AbstractOrderedMap
}
assertEquals(null, ordered.nextKey(confirmedLast));
- if (isAllowNullKey() == false) {
+ if (!isAllowNullKey()) {
try {
ordered.nextKey(null);
fail();
@@ -154,7 +154,7 @@ public abstract class AbstractOrderedMap
resetEmpty();
OrderedMap<K, V> ordered = getMap();
assertEquals(null, ordered.previousKey(getOtherKeys()[0]));
- if (isAllowNullKey() == false) {
+ if (!isAllowNullKey()) {
try {
assertEquals(null, ordered.previousKey(null)); // this is allowed too
} catch (final NullPointerException ex) {}
@@ -175,13 +175,13 @@ public abstract class AbstractOrderedMap
}
assertEquals(null, ordered.previousKey(confirmedLast));
- if (isAllowNullKey() == false) {
+ if (!isAllowNullKey()) {
try {
ordered.previousKey(null);
fail();
} catch (final NullPointerException ex) {}
} else {
- if (isAllowNullKey() == false) {
+ if (!isAllowNullKey()) {
assertEquals(null, ordered.previousKey(null));
}
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java Mon Nov 11 21:58:27 2013
@@ -18,7 +18,6 @@ package org.apache.commons.collections4.
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -92,8 +91,8 @@ public abstract class AbstractSortedMapT
public void testLastKey() {
final SortedMap<K, V> sm = makeFullMap();
K obj = null;
- for (final Iterator<K> it = sm.keySet().iterator(); it.hasNext();) {
- obj = it.next();
+ for (K k : sm.keySet()) {
+ obj = k;
}
assertSame(obj, sm.lastKey());
}
@@ -236,7 +235,7 @@ public abstract class AbstractSortedMapT
return ((SortedMap<K, V>) main.makeFullMap()).headMap(toKey);
}
public void testHeadMapOutOfRange() {
- if (isPutAddSupported() == false) {
+ if (!isPutAddSupported()) {
return;
}
resetEmpty();
@@ -291,7 +290,7 @@ public abstract class AbstractSortedMapT
return ((SortedMap<K, V>) main.makeFullMap()).tailMap(fromKey);
}
public void testTailMapOutOfRange() {
- if (isPutAddSupported() == false) {
+ if (!isPutAddSupported()) {
return;
}
resetEmpty();
@@ -353,7 +352,7 @@ public abstract class AbstractSortedMapT
return ((SortedMap<K, V>) main.makeFullMap()).subMap(fromKey, toKey);
}
public void testSubMapOutOfRange() {
- if (isPutAddSupported() == false) {
+ if (!isPutAddSupported()) {
return;
}
resetEmpty();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/IdentityMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/IdentityMap.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/IdentityMap.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/IdentityMap.java Mon Nov 11 21:58:27 2013
@@ -159,7 +159,7 @@ public class IdentityMap<K, V>
if (obj == this) {
return true;
}
- if (obj instanceof Map.Entry == false) {
+ if (!(obj instanceof Entry)) {
return false;
}
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java Mon Nov 11 21:58:27 2013
@@ -69,7 +69,7 @@ public class LRUMapTest<K, V> extends Ab
//-----------------------------------------------------------------------
public void testLRU() {
- if (isPutAddSupported() == false || isPutChangeSupported() == false) {
+ if (!isPutAddSupported() || !isPutChangeSupported()) {
return;
}
final K[] keys = getSampleKeys();
@@ -151,7 +151,7 @@ public class LRUMapTest<K, V> extends Ab
//-----------------------------------------------------------------------
public void testAccessOrder() {
- if (isPutAddSupported() == false || isPutChangeSupported() == false) {
+ if (!isPutAddSupported() || !isPutChangeSupported()) {
return;
}
final K[] keys = getSampleKeys();
@@ -378,7 +378,7 @@ public class LRUMapTest<K, V> extends Ab
@SuppressWarnings("unchecked")
public void testInternalState_Buckets() {
- if (isPutAddSupported() == false || isPutChangeSupported() == false) {
+ if (!isPutAddSupported() || !isPutChangeSupported()) {
return;
}
final SingleHashCode one = new SingleHashCode("1");
@@ -468,7 +468,7 @@ public class LRUMapTest<K, V> extends Ab
@SuppressWarnings("unchecked")
public void testInternalState_getEntry_int() {
- if (isPutAddSupported() == false || isPutChangeSupported() == false) {
+ if (!isPutAddSupported() || !isPutChangeSupported()) {
return;
}
final SingleHashCode one = new SingleHashCode("1");
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java Mon Nov 11 21:58:27 2013
@@ -81,7 +81,7 @@ public class LinkedMapTest<K, V> extends
//-----------------------------------------------------------------------
public void testInsertionOrder() {
- if (isPutAddSupported() == false || isPutChangeSupported() == false) {
+ if (!isPutAddSupported() || !isPutChangeSupported()) {
return;
}
final K[] keys = getSampleKeys();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java Mon Nov 11 21:58:27 2013
@@ -121,7 +121,7 @@ public class MultiValueMapTest<K, V> ext
public void testKeyedIterator() {
final MultiValueMap<K, V> map = createTestMap();
final ArrayList<Object> actual = new ArrayList<Object>(IteratorUtils.toList(map.iterator("one")));
- final ArrayList<Object> expected = new ArrayList<Object>(Arrays.asList(new String[]{ "uno", "un" }));
+ final ArrayList<Object> expected = new ArrayList<Object>(Arrays.asList("uno", "un"));
assertEquals(expected, actual);
}
@@ -342,7 +342,7 @@ public class MultiValueMapTest<K, V> ext
@SuppressWarnings("unchecked")
public void testPutAll_KeyCollection() {
final MultiValueMap<K, V> map = new MultiValueMap<K, V>();
- Collection<V> coll = (Collection<V>) Arrays.asList(new Object[] { "X", "Y", "Z" });
+ Collection<V> coll = (Collection<V>) Arrays.asList("X", "Y", "Z");
assertEquals(true, map.putAll((K) "A", coll));
assertEquals(3, map.size("A"));
@@ -362,7 +362,7 @@ public class MultiValueMapTest<K, V> ext
assertEquals(true, map.containsValue("A", "Y"));
assertEquals(true, map.containsValue("A", "Z"));
- coll = (Collection<V>) Arrays.asList(new Object[] { "M" });
+ coll = (Collection<V>) Arrays.asList("M");
assertEquals(true, map.putAll((K) "A", coll));
assertEquals(4, map.size("A"));
assertEquals(true, map.containsValue("A", "X"));
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java Mon Nov 11 21:58:27 2013
@@ -73,11 +73,10 @@ public abstract class AbstractQueueTest<
public void verify() {
super.verify();
final Iterator<E> iterator1 = getCollection().iterator();
- final Iterator<E> iterator2 = getConfirmed().iterator();
- while (iterator2.hasNext()) {
+ for (E e : getConfirmed()) {
assertTrue(iterator1.hasNext());
final Object o1 = iterator1.next();
- final Object o2 = iterator2.next();
+ final Object o2 = e;
assertEquals(o1, o2);
}
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java Mon Nov 11 21:58:27 2013
@@ -49,11 +49,10 @@ public class CircularFifoQueueTest<E> ex
public void verify() {
super.verify();
final Iterator<E> iterator1 = getCollection().iterator();
- final Iterator<E> iterator2 = getConfirmed().iterator();
- while (iterator2.hasNext()) {
+ for (E e : getConfirmed()) {
assertTrue(iterator1.hasNext());
final Object o1 = iterator1.next();
- final Object o2 = iterator2.next();
+ final Object o2 = e;
assertEquals(o1, o2);
}
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java Mon Nov 11 21:58:27 2013
@@ -17,6 +17,7 @@
package org.apache.commons.collections4.queue;
import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.Queue;
@@ -70,36 +71,34 @@ public class TransformedQueueTest<E> ext
final Queue<Object> queue = TransformedQueue.transformingQueue(new LinkedList<Object>(),
TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(0, queue.size());
- final Object[] els = new Object[] { "1", "3", "5", "7", "2", "4", "6" };
- for (int i = 0; i < els.length; i++) {
- queue.add(els[i]);
+ final Object[] elements = new Object[] { "1", "3", "5", "7", "2", "4", "6" };
+ for (int i = 0; i < elements.length; i++) {
+ queue.add(elements[i]);
assertEquals(i + 1, queue.size());
- assertEquals(true, queue.contains(Integer.valueOf((String) els[i])));
- assertEquals(false, queue.contains(els[i]));
+ assertEquals(true, queue.contains(Integer.valueOf((String) elements[i])));
+ assertEquals(false, queue.contains(elements[i]));
}
- assertEquals(false, queue.remove(els[0]));
- assertEquals(true, queue.remove(Integer.valueOf((String) els[0])));
+ assertEquals(false, queue.remove(elements[0]));
+ assertEquals(true, queue.remove(Integer.valueOf((String) elements[0])));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testTransformedQueue_decorateTransform() {
final Queue originalQueue = new LinkedList();
- final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
- for (final Object el : els) {
- originalQueue.add(el);
- }
+ final Object[] elements = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
+ Collections.addAll(originalQueue, elements);
final Queue<?> queue = TransformedQueue.transformedQueue(originalQueue,
TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
- assertEquals(els.length, queue.size());
- for (final Object el : els) {
+ assertEquals(elements.length, queue.size());
+ for (final Object el : elements) {
assertEquals(true, queue.contains(Integer.valueOf((String) el)));
assertEquals(false, queue.contains(el));
}
- assertEquals(false, queue.remove(els[0]));
- assertEquals(true, queue.remove(Integer.valueOf((String) els[0])));
+ assertEquals(false, queue.remove(elements[0]));
+ assertEquals(true, queue.remove(Integer.valueOf((String) elements[0])));
}
@Override
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java Mon Nov 11 21:58:27 2013
@@ -130,13 +130,13 @@ public class SequencesComparatorTest {
final ExecutionVisitor<String> ev = new ExecutionVisitor<String>();
for (int i = 0; i < shadokSentences.size(); ++i) {
- for (int j = 0; j < shadokSentences.size(); ++j) {
+ for (List<String> shadokSentence : shadokSentences) {
ev.setList(shadokSentences.get(i));
new SequencesComparator<String>(shadokSentences.get(i),
- shadokSentences.get(j)).getScript().visit(ev);
+ shadokSentence).getScript().visit(ev);
final StringBuilder concat = new StringBuilder();
- for (final String s : shadokSentences.get(j)) {
+ for (final String s : shadokSentence) {
concat.append(s);
}
Assert.assertEquals(concat.toString(), ev.getString());
@@ -175,7 +175,7 @@ public class SequencesComparatorTest {
}
public String getString() {
- final StringBuffer buffer = new StringBuffer();
+ final StringBuilder buffer = new StringBuilder();
for (final T c : v) {
buffer.append(c);
}
@@ -187,7 +187,7 @@ public class SequencesComparatorTest {
@Before
public void setUp() {
- before = Arrays.asList(new String[] {
+ before = Arrays.asList(
"bottle",
"nematode knowledge",
"",
@@ -196,10 +196,9 @@ public class SequencesComparatorTest {
"ABCABBA",
"glop glop",
"coq",
- "spider-man"
- });
+ "spider-man");
- after = Arrays.asList(new String[] {
+ after = Arrays.asList(
"noodle",
"empty bottle",
"",
@@ -208,8 +207,7 @@ public class SequencesComparatorTest {
"CBABAC",
"pas glop pas glop",
"ane",
- "klingon"
- });
+ "klingon");
length = new int[] {
6,
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java Mon Nov 11 21:58:27 2013
@@ -64,9 +64,8 @@ public abstract class AbstractSetTest<E>
assertEquals("Sets should have equal hashCodes",
getConfirmed().hashCode(), getCollection().hashCode());
final Collection<E> set = makeConfirmedCollection();
- final Iterator<E> iterator = getCollection().iterator();
- while (iterator.hasNext()) {
- assertTrue("Set.iterator should only return unique elements", set.add(iterator.next()));
+ for (E element : getCollection()) {
+ assertTrue("Set.iterator should only return unique elements", set.add(element));
}
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java Mon Nov 11 21:58:27 2013
@@ -17,6 +17,7 @@
package org.apache.commons.collections4.set;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -85,9 +86,7 @@ public class TransformedSetTest<E> exten
public void testTransformedSet_decorateTransform() {
final Set<Object> originalSet = new HashSet<Object>();
final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
- for (final Object el : els) {
- originalSet.add(el);
- }
+ Collections.addAll(originalSet, els);
final Set<?> set = TransformedSet.transformedSet(originalSet, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(els.length, set.size());
for (final Object el : els) {
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java?rev=1540860&r1=1540859&r2=1540860&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java Mon Nov 11 21:58:27 2013
@@ -17,6 +17,7 @@
package org.apache.commons.collections4.set;
import java.util.Arrays;
+import java.util.Collections;
import java.util.TreeSet;
import java.util.Set;
import java.util.SortedSet;
@@ -78,9 +79,7 @@ public class TransformedSortedSetTest<E>
public void testTransformedSet_decorateTransform() {
final Set<Object> originalSet = new TreeSet<Object>();
final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
- for (final Object el : els) {
- originalSet.add(el);
- }
+ Collections.addAll(originalSet, els);
final Set<?> set = TransformedSortedSet.transformedSet(originalSet, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(els.length, set.size());
for (final Object el : els) {