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 [16/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/ExtendedPropertiesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/ExtendedPropertiesTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/ExtendedPropertiesTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/ExtendedPropertiesTest.java Mon Jan 7 17:15:14 2013
@@ -39,7 +39,7 @@ public class ExtendedPropertiesTest exte
protected ExtendedProperties eprop = new ExtendedProperties();
- public ExtendedPropertiesTest(String testName) {
+ public ExtendedPropertiesTest(final String testName) {
super(testName);
}
@@ -73,12 +73,12 @@ public class ExtendedPropertiesTest exte
/*
* test comma separated string properties
*/
- String prop = "hey, that's a test";
+ final String prop = "hey, that's a test";
eprop.setProperty("prop.string", prop);
assertTrue("This returns vector", eprop.getVector("prop.string") instanceof java.util.Vector);
assertTrue("This returns list", eprop.getList("prop.string") instanceof java.util.List);
- String prop2 = "hey\\, that's a test";
+ final String prop2 = "hey\\, that's a test";
eprop.remove("prop.string");
eprop.setProperty("prop.string", prop2);
assertTrue("This returns array", eprop.getString("prop.string") instanceof java.lang.String);
@@ -88,7 +88,7 @@ public class ExtendedPropertiesTest exte
* elements when generating the subset
*/
- ExtendedProperties subEprop = eprop.subset("prop");
+ final ExtendedProperties subEprop = eprop.subset("prop");
assertTrue("Returns the full string", subEprop.getString("string").equals(prop));
assertTrue("This returns string for subset", subEprop.getString("string") instanceof java.lang.String);
@@ -100,13 +100,13 @@ public class ExtendedPropertiesTest exte
public void testInterpolation() {
eprop.setProperty("applicationRoot", "/home/applicationRoot");
eprop.setProperty("db", "${applicationRoot}/db/hypersonic");
- String dbProp = "/home/applicationRoot/db/hypersonic";
+ final String dbProp = "/home/applicationRoot/db/hypersonic";
assertTrue("Checking interpolated variable", eprop.getString("db").equals(dbProp));
}
public void testSaveAndLoad() {
- ExtendedProperties ep1 = new ExtendedProperties();
- ExtendedProperties ep2 = new ExtendedProperties();
+ final ExtendedProperties ep1 = new ExtendedProperties();
+ final ExtendedProperties ep2 = new ExtendedProperties();
try {
/* initialize value:
@@ -114,7 +114,7 @@ public class ExtendedPropertiesTest exte
two=Hello\,World
three=Hello,World
*/
- String s1 = "one=Hello\\World\ntwo=Hello\\,World\nthree=Hello,World";
+ final String s1 = "one=Hello\\World\ntwo=Hello\\,World\nthree=Hello,World";
byte[] bytes = s1.getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ep1.load(bais);
@@ -136,7 +136,7 @@ public class ExtendedPropertiesTest exte
assertEquals("Commas not interpreted properly",
"World", ep1.getList("three").get(1));
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
ep1.save(baos, null);
bytes = baos.toByteArray();
bais = new ByteArrayInputStream(bytes);
@@ -147,13 +147,13 @@ public class ExtendedPropertiesTest exte
ep1.getString("two"), ep2.getString("two"));
assertEquals("Comma not same after being saved and loaded",
ep1.getString("three"), ep2.getString("three"));
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
fail("There was an exception saving and loading the EP");
}
}
public void testTrailingBackSlash() {
- ExtendedProperties ep1 = new ExtendedProperties();
+ final ExtendedProperties ep1 = new ExtendedProperties();
try {
/*
@@ -162,30 +162,30 @@ public class ExtendedPropertiesTest exte
two=TWO \\
three=THREE
*/
- String s1 = "one=ONE\ntwo=TWO \\\\\nthree=THREE";
- byte[] bytes = s1.getBytes();
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ final String s1 = "one=ONE\ntwo=TWO \\\\\nthree=THREE";
+ final byte[] bytes = s1.getBytes();
+ final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ep1.load(bais);
assertEquals("Trailing back-slashes not interpreted properly",
3, ep1.size());
assertEquals("Back-slash not escaped properly",
"TWO \\", ep1.getString("two"));
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
fail("There was an exception loading the EP");
}
}
public void testMultipleSameKey1() throws Exception {
- ExtendedProperties ep1 = new ExtendedProperties();
+ final ExtendedProperties ep1 = new ExtendedProperties();
/*
initialize using:
one=a
one=b,c
*/
- String s1 = "one=a\none=b,c\n";
- byte[] bytes = s1.getBytes();
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ final String s1 = "one=a\none=b,c\n";
+ final byte[] bytes = s1.getBytes();
+ final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ep1.load(bais);
assertEquals(1, ep1.size());
@@ -201,16 +201,16 @@ public class ExtendedPropertiesTest exte
}
public void testMultipleSameKey2() throws Exception {
- ExtendedProperties ep1 = new ExtendedProperties();
+ final ExtendedProperties ep1 = new ExtendedProperties();
/*
initialize using:
one=a,b
one=c,d
*/
- String s1 = "one=a,b\none=c,d\n";
- byte[] bytes = s1.getBytes();
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ final String s1 = "one=a,b\none=c,d\n";
+ final byte[] bytes = s1.getBytes();
+ final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ep1.load(bais);
assertEquals(1, ep1.size());
@@ -228,16 +228,16 @@ public class ExtendedPropertiesTest exte
}
public void testMultipleSameKey3() throws Exception {
- ExtendedProperties ep1 = new ExtendedProperties();
+ final ExtendedProperties ep1 = new ExtendedProperties();
/*
initialize using:
one=a,b
one=c
*/
- String s1 = "one=a,b\none=c\n";
- byte[] bytes = s1.getBytes();
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ final String s1 = "one=a,b\none=c\n";
+ final byte[] bytes = s1.getBytes();
+ final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ep1.load(bais);
assertEquals(1, ep1.size());
@@ -253,7 +253,7 @@ public class ExtendedPropertiesTest exte
}
public void testMultipleSameKeyByCode() throws Exception {
- ExtendedProperties ep1 = new ExtendedProperties();
+ final ExtendedProperties ep1 = new ExtendedProperties();
ep1.addProperty("one", "a");
assertEquals(1, ep1.size());
@@ -292,21 +292,21 @@ public class ExtendedPropertiesTest exte
}
public void testInheritDefaultProperties() {
- Properties defaults = new Properties();
+ final Properties defaults = new Properties();
defaults.setProperty("resource.loader", "class");
- Properties properties = new Properties(defaults);
+ final Properties properties = new Properties(defaults);
properties.setProperty("test", "foo");
- ExtendedProperties extended = ExtendedProperties.convertProperties(properties);
+ final ExtendedProperties extended = ExtendedProperties.convertProperties(properties);
assertEquals("foo", extended.getString("test"));
assertEquals("class", extended.getString("resource.loader"));
}
public void testInclude() {
- ExtendedProperties a = new ExtendedProperties();
- ExtendedProperties b = new ExtendedProperties();
+ final ExtendedProperties a = new ExtendedProperties();
+ final ExtendedProperties b = new ExtendedProperties();
assertEquals("include", a.getInclude());
assertEquals("include", b.getInclude());
@@ -321,12 +321,12 @@ public class ExtendedPropertiesTest exte
}
public void testKeySet1() {
- ExtendedProperties p = new ExtendedProperties();
+ final ExtendedProperties p = new ExtendedProperties();
p.addProperty("a", "foo");
p.addProperty("b", "bar");
p.addProperty("c", "bar");
- Iterator<String> it = p.getKeys();
+ final Iterator<String> it = p.getKeys();
assertEquals("a", it.next());
assertEquals("b", it.next());
assertEquals("c", it.next());
@@ -334,12 +334,12 @@ public class ExtendedPropertiesTest exte
}
public void testKeySet2() {
- ExtendedProperties p = new ExtendedProperties();
+ final ExtendedProperties p = new ExtendedProperties();
p.put("a", "foo");
p.put("b", "bar");
p.put("c", "bar");
- Iterator<String> it = p.getKeys();
+ final Iterator<String> it = p.getKeys();
assertEquals("a", it.next());
assertEquals("b", it.next());
assertEquals("c", it.next());
@@ -348,15 +348,15 @@ public class ExtendedPropertiesTest exte
public void testKeySet3() {
- ExtendedProperties q = new ExtendedProperties();
+ final ExtendedProperties q = new ExtendedProperties();
q.addProperty("a", "foo");
q.addProperty("b", "bar");
q.addProperty("c", "bar");
- ExtendedProperties p = new ExtendedProperties();
+ final ExtendedProperties p = new ExtendedProperties();
p.putAll(q);
- Iterator<String> it = p.getKeys();
+ final Iterator<String> it = p.getKeys();
assertEquals("a", it.next());
assertEquals("b", it.next());
assertEquals("c", it.next());
@@ -364,44 +364,44 @@ public class ExtendedPropertiesTest exte
}
public void testKeySet4() {
- ExtendedProperties q = new ExtendedProperties();
+ final ExtendedProperties q = new ExtendedProperties();
q.addProperty("a", "foo");
q.addProperty("b", "bar");
q.addProperty("c", "bar");
q.remove("b");
- Iterator<String> it = q.getKeys();
+ final Iterator<String> it = q.getKeys();
assertEquals("a", it.next());
assertEquals("c", it.next());
assertFalse(it.hasNext());
}
public void testCollections271() {
- ExtendedProperties props = new ExtendedProperties();
+ final ExtendedProperties props = new ExtendedProperties();
props.setProperty("test", "\\\\\\\\192.168.1.91\\\\test");
props.getProperty("test");
assertEquals( "\\\\192.168.1.91\\test", props.getProperty("test") );
- ExtendedProperties props2 = new ExtendedProperties();
+ final ExtendedProperties props2 = new ExtendedProperties();
props2.combine(props);
assertEquals( "\\\\192.168.1.91\\test", props2.getProperty("test") );
- ExtendedProperties props3 = new ExtendedProperties();
+ final ExtendedProperties props3 = new ExtendedProperties();
props3.setProperty("sub.test", "foo");
props2.combine(props3);
assertEquals("foo", props2.getProperty("sub.test"));
- ExtendedProperties subs = props2.subset("sub");
+ final ExtendedProperties subs = props2.subset("sub");
assertNotNull(subs);
assertEquals("foo", subs.getProperty("test"));
}
public void testCollections238() throws IOException {
- ExtendedProperties props = new ExtendedProperties();
- String txt = "x=1\ny=\nz=3";
- byte[] bytes = txt.getBytes();
- ByteArrayInputStream in = new ByteArrayInputStream(bytes);
+ final ExtendedProperties props = new ExtendedProperties();
+ final String txt = "x=1\ny=\nz=3";
+ final byte[] bytes = txt.getBytes();
+ final ByteArrayInputStream in = new ByteArrayInputStream(bytes);
props.load(in);
assertEquals("1", props.getProperty("x"));
assertEquals("3", props.getProperty("z"));
@@ -410,13 +410,13 @@ public class ExtendedPropertiesTest exte
}
public void testCollections299() {
- Properties defaults = new Properties();
+ final Properties defaults = new Properties();
defaults.put("objectTrue", Boolean.TRUE);
- Properties properties = new Properties(defaults);
+ final Properties properties = new Properties(defaults);
properties.put("objectFalse", Boolean.FALSE);
- ExtendedProperties extended = ExtendedProperties.convertProperties(properties);
+ final ExtendedProperties extended = ExtendedProperties.convertProperties(properties);
assertNull(extended.getString("objectTrue"));
assertNull(extended.getString("objectFalse"));
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/FactoryUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/FactoryUtilsTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/FactoryUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/FactoryUtilsTest.java Mon Jan 7 17:15:14 2013
@@ -43,7 +43,7 @@ public class FactoryUtilsTest extends ju
/**
* Construct
*/
- public FactoryUtilsTest(String name) {
+ public FactoryUtilsTest(final String name) {
super(name);
}
@@ -69,10 +69,10 @@ public class FactoryUtilsTest extends ju
assertSame(FactoryUtils.exceptionFactory(), FactoryUtils.exceptionFactory());
try {
FactoryUtils.exceptionFactory().create();
- } catch (FunctorException ex) {
+ } catch (final FunctorException ex) {
try {
FactoryUtils.exceptionFactory().create();
- } catch (FunctorException ex2) {
+ } catch (final FunctorException ex2) {
return;
}
}
@@ -83,9 +83,9 @@ public class FactoryUtilsTest extends ju
//------------------------------------------------------------------
public void testNullFactory() {
- Factory<Object> factory = FactoryUtils.nullFactory();
+ final Factory<Object> factory = FactoryUtils.nullFactory();
assertNotNull(factory);
- Object created = factory.create();
+ final Object created = factory.create();
assertNull(created);
}
@@ -93,17 +93,17 @@ public class FactoryUtilsTest extends ju
//------------------------------------------------------------------
public void testConstantFactoryNull() {
- Factory<Object> factory = FactoryUtils.constantFactory(null);
+ final Factory<Object> factory = FactoryUtils.constantFactory(null);
assertNotNull(factory);
- Object created = factory.create();
+ final Object created = factory.create();
assertNull(created);
}
public void testConstantFactoryConstant() {
- Integer constant = new Integer(9);
- Factory<Integer> factory = FactoryUtils.constantFactory(constant);
+ final Integer constant = new Integer(9);
+ final Factory<Integer> factory = FactoryUtils.constantFactory(constant);
assertNotNull(factory);
- Integer created = factory.create();
+ final Integer created = factory.create();
assertSame(constant, created);
}
@@ -115,28 +115,28 @@ public class FactoryUtilsTest extends ju
}
public void testPrototypeFactoryPublicCloneMethod() throws Exception {
- Date proto = new Date();
- Factory<Date> factory = FactoryUtils.prototypeFactory(proto);
+ final Date proto = new Date();
+ final Factory<Date> factory = FactoryUtils.prototypeFactory(proto);
assertNotNull(factory);
- Date created = factory.create();
+ final Date created = factory.create();
assertTrue(proto != created);
assertEquals(proto, created);
// check serialisation works
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(buffer);
+ final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(buffer);
out.writeObject(factory);
out.close();
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
+ final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
in.readObject();
in.close();
}
public void testPrototypeFactoryPublicCopyConstructor() throws Exception {
- Mock1 proto = new Mock1(6);
+ final Mock1 proto = new Mock1(6);
Factory<Object> factory = FactoryUtils.<Object>prototypeFactory(proto);
assertNotNull(factory);
- Object created = factory.create();
+ final Object created = factory.create();
assertTrue(proto != created);
assertEquals(proto, created);
@@ -145,7 +145,7 @@ public class FactoryUtilsTest extends ju
ObjectOutputStream out = new ObjectOutputStream(buffer);
try {
out.writeObject(factory);
- } catch (NotSerializableException ex) {
+ } catch (final NotSerializableException ex) {
out.close();
}
factory = FactoryUtils.<Object>prototypeFactory(new Mock2("S"));
@@ -153,36 +153,36 @@ public class FactoryUtilsTest extends ju
out = new ObjectOutputStream(buffer);
out.writeObject(factory);
out.close();
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
+ final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
in.readObject();
in.close();
}
public void testPrototypeFactoryPublicSerialization() throws Exception {
- Integer proto = new Integer(9);
- Factory<Integer> factory = FactoryUtils.prototypeFactory(proto);
+ final Integer proto = new Integer(9);
+ final Factory<Integer> factory = FactoryUtils.prototypeFactory(proto);
assertNotNull(factory);
- Integer created = factory.create();
+ final Integer created = factory.create();
assertTrue(proto != created);
assertEquals(proto, created);
// check serialisation works
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(buffer);
+ final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(buffer);
out.writeObject(factory);
out.close();
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
+ final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
in.readObject();
in.close();
}
public void testPrototypeFactoryPublicSerializationError() {
- Mock2 proto = new Mock2(new Object());
- Factory<Object> factory = FactoryUtils.<Object>prototypeFactory(proto);
+ final Mock2 proto = new Mock2(new Object());
+ final Factory<Object> factory = FactoryUtils.<Object>prototypeFactory(proto);
assertNotNull(factory);
try {
factory.create();
- } catch (FunctorException ex) {
+ } catch (final FunctorException ex) {
assertTrue(ex.getCause() instanceof IOException);
return;
}
@@ -190,10 +190,10 @@ public class FactoryUtilsTest extends ju
}
public void testPrototypeFactoryPublicBad() {
- Object proto = new Object();
+ final Object proto = new Object();
try {
FactoryUtils.prototypeFactory(proto);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return;
}
fail();
@@ -201,14 +201,14 @@ public class FactoryUtilsTest extends ju
public static class Mock1 {
private final int iVal;
- public Mock1(int val) {
+ public Mock1(final int val) {
iVal = val;
}
- public Mock1(Mock1 mock) {
+ public Mock1(final Mock1 mock) {
iVal = mock.iVal;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj instanceof Mock1) {
if (iVal == ((Mock1) obj).iVal) {
return true;
@@ -221,11 +221,11 @@ public class FactoryUtilsTest extends ju
@SuppressWarnings("serial")
public static class Mock2 implements Serializable {
private final Object iVal;
- public Mock2(Object val) {
+ public Mock2(final Object val) {
iVal = val;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj instanceof Mock2) {
if (iVal == ((Mock2) obj).iVal) {
return true;
@@ -256,7 +256,7 @@ public class FactoryUtilsTest extends ju
@Test
public void instantiateFactorySimple() {
- Factory<Mock3> factory = FactoryUtils.instantiateFactory(Mock3.class);
+ final Factory<Mock3> factory = FactoryUtils.instantiateFactory(Mock3.class);
assertNotNull(factory);
Mock3 created = factory.create();
assertEquals(0, created.getValue());
@@ -278,11 +278,11 @@ public class FactoryUtilsTest extends ju
public void instantiateFactoryComplex() {
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
// 2nd Jan 1970
- Factory<Date> factory = FactoryUtils.instantiateFactory(Date.class,
+ final Factory<Date> factory = FactoryUtils.instantiateFactory(Date.class,
new Class[] {Integer.TYPE, Integer.TYPE, Integer.TYPE},
new Object[] {new Integer(70), new Integer(0), new Integer(2)});
assertNotNull(factory);
- Date created = factory.create();
+ final Date created = factory.create();
// long time of 1 day (== 2nd Jan 1970)
assertEquals(new Date(1000 * 60 * 60 * 24), created);
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/IteratorUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/IteratorUtilsTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/IteratorUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/IteratorUtilsTest.java Mon Jan 7 17:15:14 2013
@@ -40,7 +40,7 @@ import org.apache.commons.collections.it
*/
public class IteratorUtilsTest extends BulkTest {
- public IteratorUtilsTest(String name) {
+ public IteratorUtilsTest(final String name) {
super(name);
}
@@ -49,15 +49,15 @@ public class IteratorUtilsTest extends B
}
public void testAsIterable() {
- List<Integer> list = new ArrayList<Integer>();
+ final List<Integer> list = new ArrayList<Integer>();
list.add(Integer.valueOf(0));
list.add(Integer.valueOf(1));
list.add(Integer.valueOf(2));
- Iterator<Integer> iterator = list.iterator();
+ final Iterator<Integer> iterator = list.iterator();
- Iterable<Integer> iterable = IteratorUtils.asIterable(iterator);
+ final Iterable<Integer> iterable = IteratorUtils.asIterable(iterator);
int expected = 0;
- for(Integer actual : iterable) {
+ for(final Integer actual : iterable) {
assertEquals(expected, actual.intValue());
++expected;
}
@@ -65,7 +65,7 @@ public class IteratorUtilsTest extends B
assertTrue(expected > 0);
// single use iterator
- for(Integer actual : iterable) {
+ for(final Integer actual : iterable) {
fail("should not be able to iterate twice");
}
}
@@ -74,21 +74,21 @@ public class IteratorUtilsTest extends B
try {
IteratorUtils.asIterable(null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
// success
}
}
public void testAsMultipleIterable() {
- List<Integer> list = new ArrayList<Integer>();
+ final List<Integer> list = new ArrayList<Integer>();
list.add(Integer.valueOf(0));
list.add(Integer.valueOf(1));
list.add(Integer.valueOf(2));
- Iterator<Integer> iterator = list.iterator();
+ final Iterator<Integer> iterator = list.iterator();
- Iterable<Integer> iterable = IteratorUtils.asMultipleUseIterable(iterator);
+ final Iterable<Integer> iterable = IteratorUtils.asMultipleUseIterable(iterator);
int expected = 0;
- for(Integer actual : iterable) {
+ for(final Integer actual : iterable) {
assertEquals(expected, actual.intValue());
++expected;
}
@@ -97,7 +97,7 @@ public class IteratorUtilsTest extends B
// multiple use iterator
expected = 0;
- for(Integer actual : iterable) {
+ for(final Integer actual : iterable) {
assertEquals(expected, actual.intValue());
++expected;
}
@@ -109,40 +109,40 @@ public class IteratorUtilsTest extends B
try {
IteratorUtils.asMultipleUseIterable(null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
// success
}
}
public void testToList() {
- List<Object> list = new ArrayList<Object>();
+ final List<Object> list = new ArrayList<Object>();
list.add(new Integer(1));
list.add("Two");
list.add(null);
- List<Object> result = IteratorUtils.toList(list.iterator());
+ final List<Object> result = IteratorUtils.toList(list.iterator());
assertEquals(list, result);
}
public void testToArray() {
- List<Object> list = new ArrayList<Object>();
+ final List<Object> list = new ArrayList<Object>();
list.add(new Integer(1));
list.add("Two");
list.add(null);
- Object[] result = IteratorUtils.toArray(list.iterator());
+ final Object[] result = IteratorUtils.toArray(list.iterator());
assertEquals(list, Arrays.asList(result));
}
public void testToArray2() {
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
list.add("One");
list.add("Two");
list.add(null);
- String[] result = IteratorUtils.toArray(list.iterator(), String.class);
+ final String[] result = IteratorUtils.toArray(list.iterator(), String.class);
assertEquals(list, Arrays.asList(result));
}
public void testArrayIterator() {
- Object[] objArray = {"a", "b", "c"};
+ final Object[] objArray = {"a", "b", "c"};
ResettableIterator<Object> iterator = IteratorUtils.arrayIterator(objArray);
assertTrue(iterator.next().equals("a"));
assertTrue(iterator.next().equals("b"));
@@ -152,14 +152,14 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayIterator(new Integer(0));
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayIterator(null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
// expected
}
@@ -169,7 +169,7 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayIterator(objArray, -1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
@@ -180,7 +180,7 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayIterator(objArray, 4);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
@@ -190,25 +190,25 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayIterator(objArray, 2, 4);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayIterator(objArray, -1, 1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayIterator(objArray, 2, 1);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
- int[] intArray = {0, 1, 2};
+ final int[] intArray = {0, 1, 2};
iterator = IteratorUtils.arrayIterator(intArray);
assertTrue(iterator.next().equals(new Integer(0)));
assertTrue(iterator.next().equals(new Integer(1)));
@@ -221,7 +221,7 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayIterator(intArray, -1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
@@ -232,7 +232,7 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayIterator(intArray, 4);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
@@ -242,27 +242,27 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayIterator(intArray, 2, 4);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayIterator(intArray, -1, 1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayIterator(intArray, 2, 1);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
}
public void testArrayListIterator() {
- Object[] objArray = {"a", "b", "c", "d"};
+ final Object[] objArray = {"a", "b", "c", "d"};
ResettableListIterator<Object> iterator = IteratorUtils.arrayListIterator(objArray);
assertTrue(!iterator.hasPrevious());
assertTrue(iterator.previousIndex() == -1);
@@ -281,14 +281,14 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayListIterator(new Integer(0));
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayListIterator(null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
// expected
}
@@ -302,7 +302,7 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayListIterator(objArray, -1);
fail("Expecting IndexOutOfBoundsException.");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
@@ -311,14 +311,14 @@ public class IteratorUtilsTest extends B
try {
iterator.previous();
fail("Expecting NoSuchElementException.");
- } catch (NoSuchElementException ex) {
+ } catch (final NoSuchElementException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayListIterator(objArray, 5);
fail("Expecting IndexOutOfBoundsException.");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
@@ -328,25 +328,25 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayListIterator(objArray, 2, 5);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayListIterator(objArray, -1, 1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayListIterator(objArray, 2, 1);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
- int[] intArray = {0, 1, 2};
+ final int[] intArray = {0, 1, 2};
iterator = IteratorUtils.arrayListIterator(intArray);
assertTrue(iterator.previousIndex() == -1);
assertTrue(!iterator.hasPrevious());
@@ -379,7 +379,7 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayListIterator(intArray, -1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
@@ -389,7 +389,7 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayListIterator(intArray, 4);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
@@ -404,21 +404,21 @@ public class IteratorUtilsTest extends B
try {
iterator = IteratorUtils.arrayListIterator(intArray, 2, 4);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayListIterator(intArray, -1, 1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
// expected
}
try {
iterator = IteratorUtils.arrayListIterator(intArray, 2, 1);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
}
@@ -428,7 +428,7 @@ public class IteratorUtilsTest extends B
* Gets an immutable Iterator operating on the elements ["a", "b", "c", "d"].
*/
private Iterator<String> getImmutableIterator() {
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c");
@@ -440,7 +440,7 @@ public class IteratorUtilsTest extends B
* Gets an immutable ListIterator operating on the elements ["a", "b", "c", "d"].
*/
private ListIterator<String> getImmutableListIterator() {
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c");
@@ -467,11 +467,11 @@ public class IteratorUtilsTest extends B
try {
IteratorUtils.EMPTY_ITERATOR.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
try {
IteratorUtils.EMPTY_ITERATOR.remove();
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
}
//-----------------------------------------------------------------------
@@ -495,23 +495,23 @@ public class IteratorUtilsTest extends B
try {
IteratorUtils.EMPTY_LIST_ITERATOR.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
try {
IteratorUtils.EMPTY_LIST_ITERATOR.previous();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
try {
IteratorUtils.EMPTY_LIST_ITERATOR.remove();
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
try {
IteratorUtils.EMPTY_LIST_ITERATOR.set(null);
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
try {
IteratorUtils.EMPTY_LIST_ITERATOR.add(null);
fail();
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
}
//-----------------------------------------------------------------------
@@ -534,23 +534,23 @@ public class IteratorUtilsTest extends B
try {
IteratorUtils.EMPTY_MAP_ITERATOR.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
try {
IteratorUtils.EMPTY_MAP_ITERATOR.remove();
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
try {
IteratorUtils.EMPTY_MAP_ITERATOR.getKey();
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
try {
IteratorUtils.EMPTY_MAP_ITERATOR.getValue();
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
try {
IteratorUtils.EMPTY_MAP_ITERATOR.setValue(null);
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
}
//-----------------------------------------------------------------------
@@ -573,15 +573,15 @@ public class IteratorUtilsTest extends B
try {
IteratorUtils.EMPTY_ORDERED_ITERATOR.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
try {
IteratorUtils.EMPTY_ORDERED_ITERATOR.previous();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
try {
IteratorUtils.EMPTY_ORDERED_ITERATOR.remove();
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
}
//-----------------------------------------------------------------------
@@ -604,27 +604,27 @@ public class IteratorUtilsTest extends B
try {
IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
try {
IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.previous();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
try {
IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.remove();
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
try {
IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.getKey();
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
try {
IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.getValue();
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
try {
IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.setValue(null);
fail();
- } catch (IllegalStateException ex) {}
+ } catch (final IllegalStateException ex) {}
}
//-----------------------------------------------------------------------
@@ -632,7 +632,7 @@ public class IteratorUtilsTest extends B
* Test next() and hasNext() for an immutable Iterator.
*/
public void testUnmodifiableIteratorIteration() {
- Iterator<String> iterator = getImmutableIterator();
+ final Iterator<String> iterator = getImmutableIterator();
assertTrue(iterator.hasNext());
@@ -658,7 +658,7 @@ public class IteratorUtilsTest extends B
* ListIterator.
*/
public void testUnmodifiableListIteratorIteration() {
- ListIterator<String> listIterator = getImmutableListIterator();
+ final ListIterator<String> listIterator = getImmutableListIterator();
assertTrue(!listIterator.hasPrevious());
assertTrue(listIterator.hasNext());
@@ -708,13 +708,13 @@ public class IteratorUtilsTest extends B
* Test remove() for an immutable Iterator.
*/
public void testUnmodifiableIteratorImmutability() {
- Iterator<String> iterator = getImmutableIterator();
+ final Iterator<String> iterator = getImmutableIterator();
try {
iterator.remove();
// We shouldn't get to here.
fail("remove() should throw an UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// This is correct; ignore the exception.
}
@@ -724,7 +724,7 @@ public class IteratorUtilsTest extends B
iterator.remove();
// We shouldn't get to here.
fail("remove() should throw an UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// This is correct; ignore the exception.
}
@@ -734,13 +734,13 @@ public class IteratorUtilsTest extends B
* Test remove() for an immutable ListIterator.
*/
public void testUnmodifiableListIteratorImmutability() {
- ListIterator<String> listIterator = getImmutableListIterator();
+ final ListIterator<String> listIterator = getImmutableListIterator();
try {
listIterator.remove();
// We shouldn't get to here.
fail("remove() should throw an UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// This is correct; ignore the exception.
}
@@ -748,7 +748,7 @@ public class IteratorUtilsTest extends B
listIterator.set("a");
// We shouldn't get to here.
fail("set(Object) should throw an UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// This is correct; ignore the exception.
}
@@ -756,7 +756,7 @@ public class IteratorUtilsTest extends B
listIterator.add("a");
// We shouldn't get to here.
fail("add(Object) should throw an UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// This is correct; ignore the exception.
}
@@ -766,7 +766,7 @@ public class IteratorUtilsTest extends B
listIterator.remove();
// We shouldn't get to here.
fail("remove() should throw an UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// This is correct; ignore the exception.
}
@@ -774,7 +774,7 @@ public class IteratorUtilsTest extends B
listIterator.set("a");
// We shouldn't get to here.
fail("set(Object) should throw an UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// This is correct; ignore the exception.
}
@@ -782,7 +782,7 @@ public class IteratorUtilsTest extends B
listIterator.add("a");
// We shouldn't get to here.
fail("add(Object) should throw an UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
+ } catch (final UnsupportedOperationException e) {
// This is correct; ignore the exception.
}
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/ListUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/ListUtilsTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/ListUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/ListUtilsTest.java Mon Jan 7 17:15:14 2013
@@ -46,7 +46,7 @@ public class ListUtilsTest extends BulkT
private String[] fullArray;
private List<String> fullList;
- public ListUtilsTest(String name) {
+ public ListUtilsTest(final String name) {
super(name);
}
@@ -114,8 +114,8 @@ public class ListUtilsTest extends BulkT
* Tests intersecting two lists in different orders.
*/
public void testIntersectionOrderInsensitivity() {
- List<String> one = new ArrayList<String>();
- List<String> two = new ArrayList<String>();
+ final List<String> one = new ArrayList<String>();
+ final List<String> two = new ArrayList<String>();
one.add("a");
one.add("b");
two.add("a");
@@ -126,8 +126,8 @@ public class ListUtilsTest extends BulkT
}
public void testPredicatedList() {
- Predicate<Object> predicate = new Predicate<Object>() {
- public boolean evaluate(Object o) {
+ final Predicate<Object> predicate = new Predicate<Object>() {
+ public boolean evaluate(final Object o) {
return o instanceof String;
}
};
@@ -136,19 +136,19 @@ public class ListUtilsTest extends BulkT
try {
list = ListUtils.predicatedList(new ArrayStack<Object>(), null);
fail("Expecting IllegalArgumentException for null predicate.");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
try {
list = ListUtils.predicatedList(null, predicate);
fail("Expecting IllegalArgumentException for null list.");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
}
public void testLazyList() {
- List<Integer> list = ListUtils.lazyList(new ArrayList<Integer>(), new Factory<Integer>() {
+ final List<Integer> list = ListUtils.lazyList(new ArrayList<Integer>(), new Factory<Integer>() {
private int index;
@@ -168,15 +168,15 @@ public class ListUtilsTest extends BulkT
public void testEmptyIfNull() {
assertTrue(ListUtils.emptyIfNull(null).isEmpty());
- List<Long> list = new ArrayList<Long>();
+ final List<Long> list = new ArrayList<Long>();
assertSame(list, ListUtils.emptyIfNull(list));
}
public void testEquals() {
- Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+ final Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
- List<String> a = new ArrayList<String>( data );
- List<String> b = new ArrayList<String>( data );
+ final List<String> a = new ArrayList<String>( data );
+ final List<String> b = new ArrayList<String>( data );
assertEquals(true, a.equals(b));
assertEquals(true, ListUtils.isEqualList(a, b));
@@ -188,10 +188,10 @@ public class ListUtilsTest extends BulkT
}
public void testHashCode() {
- Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+ final Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
- List<String> a = new ArrayList<String>(data);
- List<String> b = new ArrayList<String>(data);
+ final List<String> a = new ArrayList<String>(data);
+ final List<String> b = new ArrayList<String>(data);
assertEquals(true, a.hashCode() == b.hashCode());
assertEquals(true, a.hashCode() == ListUtils.hashCodeForList(a));
@@ -203,12 +203,12 @@ public class ListUtilsTest extends BulkT
}
public void testRetainAll() {
- List<String> sub = new ArrayList<String>();
+ final List<String> sub = new ArrayList<String>();
sub.add(a);
sub.add(b);
sub.add(x);
- List<String> retained = ListUtils.retainAll(fullList, sub);
+ final List<String> retained = ListUtils.retainAll(fullList, sub);
assertTrue(retained.size() == 2);
sub.remove(x);
assertTrue(retained.equals(sub));
@@ -218,16 +218,16 @@ public class ListUtilsTest extends BulkT
try {
ListUtils.retainAll(null, null);
fail("expecting NullPointerException");
- } catch(NullPointerException npe){} // this is what we want
+ } catch(final NullPointerException npe){} // this is what we want
}
public void testRemoveAll() {
- List<String> sub = new ArrayList<String>();
+ final List<String> sub = new ArrayList<String>();
sub.add(a);
sub.add(b);
sub.add(x);
- List<String> remainder = ListUtils.removeAll(fullList, sub);
+ final List<String> remainder = ListUtils.removeAll(fullList, sub);
assertTrue(remainder.size() == 3);
fullList.removeAll(sub);
assertTrue(remainder.equals(fullList));
@@ -235,23 +235,23 @@ public class ListUtilsTest extends BulkT
try {
ListUtils.removeAll(null, null);
fail("expecting NullPointerException");
- } catch(NullPointerException npe) {} // this is what we want
+ } catch(final NullPointerException npe) {} // this is what we want
}
public void testSubtract() {
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
list.add(a);
list.add(b);
list.add(a);
list.add(x);
- List<String> sub = new ArrayList<String>();
+ final List<String> sub = new ArrayList<String>();
sub.add(a);
- List<String> result = ListUtils.subtract(list, sub);
+ final List<String> result = ListUtils.subtract(list, sub);
assertTrue(result.size() == 3);
- List<String> expected = new ArrayList<String>();
+ final List<String> expected = new ArrayList<String>();
expected.add(b);
expected.add(a);
expected.add(x);
@@ -261,23 +261,23 @@ public class ListUtilsTest extends BulkT
try {
ListUtils.subtract(list, null);
fail("expecting NullPointerException");
- } catch(NullPointerException npe) {} // this is what we want
+ } catch(final NullPointerException npe) {} // this is what we want
}
public void testSubtractNullElement() {
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
list.add(a);
list.add(null);
list.add(null);
list.add(x);
- List<String> sub = new ArrayList<String>();
+ final List<String> sub = new ArrayList<String>();
sub.add(null);
- List<String> result = ListUtils.subtract(list, sub);
+ final List<String> result = ListUtils.subtract(list, sub);
assertTrue(result.size() == 3);
- List<String> expected = new ArrayList<String>();
+ final List<String> expected = new ArrayList<String>();
expected.add(a);
expected.add(null);
expected.add(x);
@@ -302,7 +302,7 @@ public class ListUtilsTest extends BulkT
}
public void testPartition() {
- List<Integer> strings = new ArrayList<Integer>();
+ final List<Integer> strings = new ArrayList<Integer>();
for (int i = 0; i <= 6; i++) {
strings.add(i);
}
@@ -316,36 +316,36 @@ public class ListUtilsTest extends BulkT
try {
ListUtils.partition(null, 3);
Assert.fail("failed to check for null argument");
- } catch (IllegalArgumentException e) {}
+ } catch (final IllegalArgumentException e) {}
try {
ListUtils.partition(strings, 0);
Assert.fail("failed to check for size argument");
- } catch (IllegalArgumentException e) {}
+ } catch (final IllegalArgumentException e) {}
try {
ListUtils.partition(strings, -10);
Assert.fail("failed to check for size argument");
- } catch (IllegalArgumentException e) {}
+ } catch (final IllegalArgumentException e) {}
}
private static Predicate<Number> EQUALS_TWO = new Predicate<Number>() {
- public boolean evaluate(Number input) {
+ public boolean evaluate(final Number input) {
return input.intValue() == 2;
}
};
public void testSelect() {
- List<Integer> list = new ArrayList<Integer>();
+ final List<Integer> list = new ArrayList<Integer>();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
// Ensure that the collection is the input type or a super type
- List<Integer> output1 = ListUtils.select(list, EQUALS_TWO);
- List<Number> output2 = ListUtils.<Number>select(list, EQUALS_TWO);
- HashSet<Number> output3 = CollectionUtils.select(list, EQUALS_TWO, new HashSet<Number>());
+ final List<Integer> output1 = ListUtils.select(list, EQUALS_TWO);
+ final List<Number> output2 = ListUtils.<Number>select(list, EQUALS_TWO);
+ final HashSet<Number> output3 = CollectionUtils.select(list, EQUALS_TWO, new HashSet<Number>());
Assert.assertTrue(CollectionUtils.isEqualCollection(output1, output3));
Assert.assertEquals(4, list.size());
Assert.assertEquals(1, output1.size());
@@ -353,14 +353,14 @@ public class ListUtilsTest extends BulkT
}
public void testSelectRejected() {
- List<Long> list = new ArrayList<Long>();
+ final List<Long> list = new ArrayList<Long>();
list.add(1L);
list.add(2L);
list.add(3L);
list.add(4L);
- List<Long> output1 = ListUtils.selectRejected(list, EQUALS_TWO);
- List<? extends Number> output2 = ListUtils.selectRejected(list, EQUALS_TWO);
- HashSet<Number> output3 = CollectionUtils.selectRejected(list, EQUALS_TWO, new HashSet<Number>());
+ final List<Long> output1 = ListUtils.selectRejected(list, EQUALS_TWO);
+ final List<? extends Number> output2 = ListUtils.selectRejected(list, EQUALS_TWO);
+ final HashSet<Number> output3 = CollectionUtils.selectRejected(list, EQUALS_TWO, new HashSet<Number>());
Assert.assertTrue(CollectionUtils.isEqualCollection(output1, output2));
Assert.assertTrue(CollectionUtils.isEqualCollection(output1, output3));
Assert.assertEquals(4, list.size());
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MapPerformance.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MapPerformance.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MapPerformance.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MapPerformance.java Mon Jan 7 17:15:14 2013
@@ -38,18 +38,18 @@ public class MapPerformance {
/**
* Main method
*/
- public static void main(String[] args) {
+ public static void main(final String[] args) {
testAll();
}
private static void testAll() {
- Map<String, String> dummyMap = new DummyMap<String, String>();
- Map<String, String> hashMap = new HashMap<String, String>();
+ final Map<String, String> dummyMap = new DummyMap<String, String>();
+ final Map<String, String> hashMap = new HashMap<String, String>();
// hashMap.put("Alpha", "A");
// hashMap.put("Beta", "B");
// hashMap.put("Gamma", "C");
// hashMap.put("Delta", "D");
- Map<String, String> flatMap = new Flat3Map<String, String>(hashMap);
+ final Map<String, String> flatMap = new Flat3Map<String, String>(hashMap);
System.out.println(flatMap);
// Map<String, String> unmodHashMap = Collections.unmodifiableMap(new HashMap<String, String>(hashMap));
// Map fastHashMap = new FastHashMap(hashMap);
@@ -109,7 +109,7 @@ public class MapPerformance {
// test(doubleMap, " DoubleMap ");
}
- private static void test(Map<String, String> map, String name) {
+ private static void test(final Map<String, String> map, final String name) {
long start = 0, end = 0;
// int total = 0;
start = System.currentTimeMillis();
@@ -136,16 +136,16 @@ public class MapPerformance {
private static class DummyMap<K, V> implements Map<K, V> {
public void clear() {
}
- public boolean containsKey(Object key) {
+ public boolean containsKey(final Object key) {
return false;
}
- public boolean containsValue(Object value) {
+ public boolean containsValue(final Object value) {
return false;
}
public Set<Map.Entry<K, V>> entrySet() {
return null;
}
- public V get(Object key) {
+ public V get(final Object key) {
return null;
}
public boolean isEmpty() {
@@ -154,12 +154,12 @@ public class MapPerformance {
public Set<K> keySet() {
return null;
}
- public V put(K key, V value) {
+ public V put(final K key, final V value) {
return null;
}
- public void putAll(Map<? extends K, ? extends V> t) {
+ public void putAll(final Map<? extends K, ? extends V> t) {
}
- public V remove(Object key) {
+ public V remove(final Object key) {
return null;
}
public int size() {
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MapUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MapUtilsTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MapUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MapUtilsTest.java Mon Jan 7 17:15:14 2013
@@ -52,7 +52,7 @@ import org.apache.commons.collections.co
@SuppressWarnings("boxing")
public class MapUtilsTest extends BulkTest {
- public MapUtilsTest(String name) {
+ public MapUtilsTest(final String name) {
super(name);
}
@@ -62,60 +62,60 @@ public class MapUtilsTest extends BulkTe
public Predicate<Object> getPredicate() {
return new Predicate<Object>() {
- public boolean evaluate(Object o) {
+ public boolean evaluate(final Object o) {
return o instanceof String;
}
};
}
public void testPredicatedMap() {
- Predicate<Object> p = getPredicate();
+ final Predicate<Object> p = getPredicate();
Map<Object, Object> map = MapUtils.predicatedMap(new HashMap<Object, Object>(), p, p);
assertTrue("returned object should be a PredicatedMap", map instanceof PredicatedMap);
try {
map = MapUtils.predicatedMap(null, p, p);
fail("Expecting IllegalArgumentException for null map.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
public void testLazyMapFactory() {
- Factory<Integer> factory = FactoryUtils.constantFactory(new Integer(5));
+ final Factory<Integer> factory = FactoryUtils.constantFactory(new Integer(5));
Map<Object, Object> map = MapUtils.lazyMap(new HashMap<Object, Object>(), factory);
assertTrue(map instanceof LazyMap);
try {
map = MapUtils.lazyMap(new HashMap<Object, Object>(), (Factory<Object>) null);
fail("Expecting IllegalArgumentException for null factory");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
map = MapUtils.lazyMap((Map<Object, Object>) null, factory);
fail("Expecting IllegalArgumentException for null map");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
- Transformer<Object, Integer> transformer = TransformerUtils.asTransformer(factory);
+ final Transformer<Object, Integer> transformer = TransformerUtils.asTransformer(factory);
map = MapUtils.lazyMap(new HashMap<Object, Object>(), transformer);
assertTrue(map instanceof LazyMap);
try {
map = MapUtils.lazyMap(new HashMap<Object, Object>(), (Transformer<Object, Object>) null);
fail("Expecting IllegalArgumentException for null transformer");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
map = MapUtils.lazyMap((Map<Object, Object>) null, transformer);
fail("Expecting IllegalArgumentException for null map");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
public void testLazyMapTransformer() {
- Map<Object, Object> map = MapUtils.lazyMap(new HashMap<Object, Object>(), new Transformer<Object, Object>() {
- public Object transform(Object mapKey) {
+ final Map<Object, Object> map = MapUtils.lazyMap(new HashMap<Object, Object>(), new Transformer<Object, Object>() {
+ public Object transform(final Object mapKey) {
if (mapKey instanceof String) {
return new Integer((String) mapKey);
}
@@ -124,10 +124,10 @@ public class MapUtilsTest extends BulkTe
});
assertEquals(0, map.size());
- Integer i1 = (Integer) map.get("5");
+ final Integer i1 = (Integer) map.get("5");
assertEquals(new Integer(5), i1);
assertEquals(1, map.size());
- Integer i2 = (Integer) map.get(new String(new char[] {'5'}));
+ final Integer i2 = (Integer) map.get(new String(new char[] {'5'}));
assertEquals(new Integer(5), i2);
assertEquals(1, map.size());
assertSame(i1, i2);
@@ -163,11 +163,11 @@ public class MapUtilsTest extends BulkTe
try {
MapUtils.putAll(null, null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
try {
MapUtils.putAll(null, new Object[0]);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
Map<String, String> test = MapUtils.putAll(new HashMap<String, String>(), new String[0]);
assertEquals(0, test.size());
@@ -193,7 +193,7 @@ public class MapUtilsTest extends BulkTe
{"BLUE", "#0000FF"}
});
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
MapUtils.putAll(new HashMap<String, String>(), new String[][] {
@@ -202,7 +202,7 @@ public class MapUtilsTest extends BulkTe
{"BLUE", "#0000FF"}
});
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
MapUtils.putAll(new HashMap<String, String>(), new String[][] {
@@ -211,7 +211,7 @@ public class MapUtilsTest extends BulkTe
{"BLUE", "#0000FF"}
});
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
// flat array
test = MapUtils.putAll(new HashMap<String, String>(), new String[] {
@@ -278,7 +278,7 @@ public class MapUtilsTest extends BulkTe
in.put("4", "D");
in.put("5", "E");
- ResourceBundle b = new ListResourceBundle() {
+ final ResourceBundle b = new ListResourceBundle() {
@Override
public Object[][] getContents() {
final Object[][] contents = new Object[ in.size() ][2];
@@ -412,7 +412,7 @@ public class MapUtilsTest extends BulkTe
try {
MapUtils.verbosePrint(null, "Map", new HashMap<Object, Object>());
fail("Should generate NullPointerException");
- } catch (NullPointerException expected) {
+ } catch (final NullPointerException expected) {
}
}
@@ -420,7 +420,7 @@ public class MapUtilsTest extends BulkTe
try {
MapUtils.debugPrint(null, "Map", new HashMap<Object, Object>());
fail("Should generate NullPointerException");
- } catch (NullPointerException expected) {
+ } catch (final NullPointerException expected) {
}
}
@@ -715,45 +715,45 @@ public class MapUtilsTest extends BulkTe
public void testEmptyIfNull() {
assertTrue(MapUtils.emptyIfNull(null).isEmpty());
- Map<Long, Long> map = new HashMap<Long, Long>();
+ final Map<Long, Long> map = new HashMap<Long, Long>();
assertSame(map, MapUtils.emptyIfNull(map));
}
public void testIsEmptyWithEmptyMap() {
- Map<Object, Object> map = new HashMap<Object, Object>();
+ final Map<Object, Object> map = new HashMap<Object, Object>();
assertEquals(true, MapUtils.isEmpty(map));
}
public void testIsEmptyWithNonEmptyMap() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("item", "value");
assertEquals(false, MapUtils.isEmpty(map));
}
public void testIsEmptyWithNull() {
- Map<Object, Object> map = null;
+ final Map<Object, Object> map = null;
assertEquals(true, MapUtils.isEmpty(map));
}
public void testIsNotEmptyWithEmptyMap() {
- Map<Object, Object> map = new HashMap<Object, Object>();
+ final Map<Object, Object> map = new HashMap<Object, Object>();
assertEquals(false, MapUtils.isNotEmpty(map));
}
public void testIsNotEmptyWithNonEmptyMap() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("item", "value");
assertEquals(true, MapUtils.isNotEmpty(map));
}
public void testIsNotEmptyWithNull() {
- Map<Object, Object> map = null;
+ final Map<Object, Object> map = null;
assertEquals(false, MapUtils.isNotEmpty(map));
}
public void testPopulateMap() {
// Setup Test Data
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
list.add("1");
list.add("3");
list.add("5");
@@ -791,16 +791,16 @@ public class MapUtilsTest extends BulkTe
try {
MapUtils.iterableMap(null);
fail("Should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
- HashMap<String, String> map = new HashMap<String, String>();
+ final HashMap<String, String> map = new HashMap<String, String>();
map.put("foo", "foov");
map.put("bar", "barv");
map.put("baz", "bazv");
- IterableMap<String, String> iMap = MapUtils.iterableMap(map);
+ final IterableMap<String, String> iMap = MapUtils.iterableMap(map);
assertEquals(map, iMap);
assertNotSame(map, iMap);
- HashedMap<String, String> hMap = new HashedMap<String, String>(map);
+ final HashedMap<String, String> hMap = new HashedMap<String, String>(map);
assertSame(hMap, MapUtils.iterableMap(hMap));
}
@@ -808,13 +808,13 @@ public class MapUtilsTest extends BulkTe
try {
MapUtils.iterableSortedMap(null);
fail("Should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
- TreeMap<String, String> map = new TreeMap<String, String>();
+ final TreeMap<String, String> map = new TreeMap<String, String>();
map.put("foo", "foov");
map.put("bar", "barv");
map.put("baz", "bazv");
- IterableSortedMap<String, String> iMap = MapUtils.iterableSortedMap(map);
+ final IterableSortedMap<String, String> iMap = MapUtils.iterableSortedMap(map);
assertEquals(map, iMap);
assertNotSame(map, iMap);
assertSame(iMap, MapUtils.iterableMap(iMap));
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MockTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MockTestCase.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MockTestCase.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/MockTestCase.java Mon Jan 7 17:15:14 2013
@@ -31,34 +31,34 @@ import org.easymock.IExpectationSetters;
* @author Stephen Kestle
*/
public abstract class MockTestCase {
- private List<Object> mockObjects = new ArrayList<Object>();
+ private final List<Object> mockObjects = new ArrayList<Object>();
@SuppressWarnings("unchecked")
- protected <T> T createMock(Class<?> name) {
- T mock = (T) EasyMock.createMock(name);
+ protected <T> T createMock(final Class<?> name) {
+ final T mock = (T) EasyMock.createMock(name);
return registerMock(mock);
}
- private <T> T registerMock(T mock) {
+ private <T> T registerMock(final T mock) {
mockObjects.add(mock);
return mock;
}
- protected <T> IExpectationSetters<T> expect(T t) {
+ protected <T> IExpectationSetters<T> expect(final T t) {
return EasyMock.expect(t);
}
protected final void replay() {
- for (Object o : mockObjects) {
+ for (final Object o : mockObjects) {
EasyMock.replay(o);
}
}
protected final void verify() {
- for (ListIterator<Object> i = mockObjects.listIterator(); i.hasNext();) {
+ for (final ListIterator<Object> i = mockObjects.listIterator(); i.hasNext();) {
try {
EasyMock.verify(i.next());
- } catch (AssertionError e) {
+ } catch (final AssertionError e) {
throw new AssertionError(i.previousIndex() + 1 + ""
+ e.getMessage());
}
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/PredicateUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/PredicateUtilsTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/PredicateUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/PredicateUtilsTest.java Mon Jan 7 17:15:14 2013
@@ -71,10 +71,10 @@ public class PredicateUtilsTest extends
assertSame(PredicateUtils.exceptionPredicate(), PredicateUtils.exceptionPredicate());
try {
PredicateUtils.exceptionPredicate().evaluate(null);
- } catch (FunctorException ex) {
+ } catch (final FunctorException ex) {
try {
PredicateUtils.exceptionPredicate().evaluate(cString);
- } catch (FunctorException ex2) {
+ } catch (final FunctorException ex2) {
return;
}
}
@@ -175,7 +175,7 @@ public class PredicateUtilsTest extends
FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), TruePredicate.truePredicate()}).evaluate(null));
assertEquals(false, AllPredicate.allPredicate(new Predicate[] {
FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate()}).evaluate(null));
- Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
+ final Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
coll.add(TruePredicate.truePredicate());
coll.add(TruePredicate.truePredicate());
coll.add(TruePredicate.truePredicate());
@@ -233,7 +233,7 @@ public class PredicateUtilsTest extends
@Test(expected=IllegalArgumentException.class)
public void testAllPredicateEx6() {
- Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
+ final Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
coll.add(null);
coll.add(null);
AllPredicate.allPredicate(coll);
@@ -269,7 +269,7 @@ public class PredicateUtilsTest extends
FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), TruePredicate.truePredicate()}).evaluate(null));
assertEquals(false, PredicateUtils.anyPredicate(new Predicate[] {
FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate()}).evaluate(null));
- Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
+ final Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
coll.add(TruePredicate.truePredicate());
coll.add(TruePredicate.truePredicate());
coll.add(TruePredicate.truePredicate());
@@ -327,7 +327,7 @@ public class PredicateUtilsTest extends
@Test(expected=IllegalArgumentException.class)
public void testAnyPredicateEx6() {
- Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
+ final Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
coll.add(null);
coll.add(null);
PredicateUtils.anyPredicate(coll);
@@ -366,7 +366,7 @@ public class PredicateUtilsTest extends
FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), TruePredicate.truePredicate()}).evaluate(null));
assertEquals(false, PredicateUtils.onePredicate(new Predicate[] {
FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate()}).evaluate(null));
- Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
+ final Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
coll.add(TruePredicate.truePredicate());
coll.add(TruePredicate.truePredicate());
coll.add(TruePredicate.truePredicate());
@@ -425,7 +425,7 @@ public class PredicateUtilsTest extends
@Test(expected=IllegalArgumentException.class)
public void testOnePredicateEx6() {
- Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
+ final Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
coll.add(null);
coll.add(null);
PredicateUtils.onePredicate(coll);
@@ -460,7 +460,7 @@ public class PredicateUtilsTest extends
FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), TruePredicate.truePredicate() }).evaluate(null));
assertEquals(true, PredicateUtils.nonePredicate(new Predicate[] {
FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate() }).evaluate(null));
- Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
+ final Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
coll.add(TruePredicate.truePredicate());
coll.add(TruePredicate.truePredicate());
coll.add(TruePredicate.truePredicate());
@@ -518,7 +518,7 @@ public class PredicateUtilsTest extends
@Test(expected=IllegalArgumentException.class)
public void testNonePredicateEx6() {
- Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
+ final Collection<Predicate<Object>> coll = new ArrayList<Predicate<Object>>();
coll.add(null);
coll.add(null);
PredicateUtils.nonePredicate(coll);
@@ -539,7 +539,7 @@ public class PredicateUtilsTest extends
//------------------------------------------------------------------
@Test public void testUniquePredicate() {
- Predicate<Object> p = PredicateUtils.uniquePredicate();
+ final Predicate<Object> p = PredicateUtils.uniquePredicate();
assertEquals(true, p.evaluate(new Object()));
assertEquals(true, p.evaluate(new Object()));
assertEquals(true, p.evaluate(new Object()));
@@ -570,7 +570,7 @@ public class PredicateUtilsTest extends
//------------------------------------------------------------------
@Test public void testInvokerPredicate() {
- List<Object> list = new ArrayList<Object>();
+ final List<Object> list = new ArrayList<Object>();
assertEquals(true, PredicateUtils.invokerPredicate("isEmpty").evaluate(list));
list.add(new Object());
assertEquals(false, PredicateUtils.invokerPredicate("isEmpty").evaluate(list));
@@ -595,7 +595,7 @@ public class PredicateUtilsTest extends
//------------------------------------------------------------------
@Test public void testInvokerPredicate2() {
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
assertEquals(false, PredicateUtils.invokerPredicate(
"contains", new Class[] {Object.class}, new Object[] {cString}).evaluate(list));
list.add(cString);
@@ -669,16 +669,16 @@ public class PredicateUtilsTest extends
TransformerUtils.nopTransformer(),
TruePredicate.truePredicate()).evaluate(new Object()));
- Map<Object, Object> map = new HashMap<Object, Object>();
+ final Map<Object, Object> map = new HashMap<Object, Object>();
map.put(Boolean.TRUE, "Hello");
- Transformer<Object, Object> t = TransformerUtils.mapTransformer(map);
- Predicate<Object> p = EqualPredicate.<Object>equalPredicate("Hello");
+ final Transformer<Object, Object> t = TransformerUtils.mapTransformer(map);
+ final Predicate<Object> p = EqualPredicate.<Object>equalPredicate("Hello");
assertEquals(false, PredicateUtils.transformedPredicate(t, p).evaluate(null));
assertEquals(true, PredicateUtils.transformedPredicate(t, p).evaluate(Boolean.TRUE));
try {
PredicateUtils.transformedPredicate(null, null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
// misc tests
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/SetUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/SetUtilsTest.java?rev=1429905&r1=1429904&r2=1429905&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/SetUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/SetUtilsTest.java Mon Jan 7 17:15:14 2013
@@ -36,7 +36,7 @@ import org.apache.commons.collections.se
*/
public class SetUtilsTest extends BulkTest {
- public SetUtilsTest(String name) {
+ public SetUtilsTest(final String name) {
super(name);
}
@@ -48,8 +48,8 @@ public class SetUtilsTest extends BulkTe
}
public void testpredicatedSet() {
- Predicate<Object> predicate = new Predicate<Object>() {
- public boolean evaluate(Object o) {
+ final Predicate<Object> predicate = new Predicate<Object>() {
+ public boolean evaluate(final Object o) {
return o instanceof String;
}
};
@@ -58,13 +58,13 @@ public class SetUtilsTest extends BulkTe
try {
set = SetUtils.predicatedSet(new HashSet<Object>(), null);
fail("Expecting IllegalArgumentException for null predicate.");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
try {
set = SetUtils.predicatedSet(null, predicate);
fail("Expecting IllegalArgumentException for null set.");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
}
@@ -72,15 +72,15 @@ public class SetUtilsTest extends BulkTe
public void testEmptyIfNull() {
assertTrue(SetUtils.emptyIfNull(null).isEmpty());
- Set<Long> set = new HashSet<Long>();
+ final Set<Long> set = new HashSet<Long>();
assertSame(set, SetUtils.emptyIfNull(set));
}
public void testEquals() {
- Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+ final Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
- Set<String> a = new HashSet<String>(data);
- Set<String> b = new HashSet<String>(data);
+ final Set<String> a = new HashSet<String>(data);
+ final Set<String> b = new HashSet<String>(data);
assertEquals(true, a.equals(b));
assertEquals(true, SetUtils.isEqualSet(a, b));
@@ -92,10 +92,10 @@ public class SetUtilsTest extends BulkTe
}
public void testHashCode() {
- Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+ final Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
- Set<String> a = new HashSet<String>(data);
- Set<String> b = new HashSet<String>(data);
+ final Set<String> a = new HashSet<String>(data);
+ final Set<String> b = new HashSet<String>(data);
assertEquals(true, a.hashCode() == b.hashCode());
assertEquals(true, a.hashCode() == SetUtils.hashCodeForSet(a));