aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/apache/commons/lang3
diff options
context:
space:
mode:
authorGary D. Gregory <ggregory@apache.org>2013-01-22 07:09:45 +0000
committerGary D. Gregory <ggregory@apache.org>2013-01-22 07:09:45 +0000
commit5292526e476ffbb19c6613a98464054236c86ace (patch)
tree4244603481e675840f2a895abc77e02663a5f3a3 /src/test/java/org/apache/commons/lang3
parent5bd622dab027ef37001a630a7c825c5b8c19d1db (diff)
downloadapache-commons-lang-5292526e476ffbb19c6613a98464054236c86ace.tar.gz
Add final modifier to local variables.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1436770 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/test/java/org/apache/commons/lang3')
-rw-r--r--src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java12
-rw-r--r--src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java94
-rw-r--r--src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java38
-rw-r--r--src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java56
-rw-r--r--src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java521
-rw-r--r--src/test/java/org/apache/commons/lang3/BitFieldTest.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java22
-rw-r--r--src/test/java/org/apache/commons/lang3/CharRangeTest.java115
-rw-r--r--src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/CharSetTest.java36
-rw-r--r--src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/CharUtilsTest.java34
-rw-r--r--src/test/java/org/apache/commons/lang3/ClassUtilsTest.java96
-rw-r--r--src/test/java/org/apache/commons/lang3/ConversionTest.java56
-rw-r--r--src/test/java/org/apache/commons/lang3/EnumUtilsTest.java10
-rw-r--r--src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java38
-rw-r--r--src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java82
-rw-r--r--src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java100
-rw-r--r--src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java72
-rw-r--r--src/test/java/org/apache/commons/lang3/RangeTest.java18
-rw-r--r--src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java121
-rw-r--r--src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java110
-rw-r--r--src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java64
-rw-r--r--src/test/java/org/apache/commons/lang3/StringUtilsTest.java154
-rw-r--r--src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java12
-rw-r--r--src/test/java/org/apache/commons/lang3/SystemUtilsTest.java22
-rw-r--r--src/test/java/org/apache/commons/lang3/ValidateTest.java256
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java302
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java218
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java4
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java92
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java10
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java28
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java110
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java24
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java16
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java52
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java80
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java10
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java81
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java58
-rw-r--r--src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java80
-rw-r--r--src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java36
-rw-r--r--src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java26
-rw-r--r--src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java20
-rw-r--r--src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java20
-rw-r--r--src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java48
-rw-r--r--src/test/java/org/apache/commons/lang3/math/FractionTest.java148
-rw-r--r--src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java24
-rw-r--r--src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java92
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java20
-rw-r--r--src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java212
-rw-r--r--src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java38
-rw-r--r--src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java102
-rw-r--r--src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java14
-rw-r--r--src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java78
-rw-r--r--src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java194
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java228
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrLookupTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java28
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java76
-rw-r--r--src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java210
-rw-r--r--src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java10
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java16
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java26
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java12
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java2
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java18
-rw-r--r--src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java16
-rw-r--r--src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java48
-rw-r--r--src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java120
-rw-r--r--src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java40
-rw-r--r--src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java210
-rw-r--r--src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java58
-rw-r--r--src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java90
-rw-r--r--src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java114
-rw-r--r--src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java76
-rw-r--r--src/test/java/org/apache/commons/lang3/time/StopWatchTest.java80
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java18
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java18
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java22
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java22
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/PairTest.java34
-rw-r--r--src/test/java/org/apache/commons/lang3/tuple/TripleTest.java36
104 files changed, 3116 insertions, 3084 deletions
diff --git a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
index c0e081d54..446e8d916 100644
--- a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
@@ -430,14 +430,14 @@ public class AnnotationUtilsTest {
@Test
public void testIsValidAnnotationMemberType() {
- for (Class<?> type : new Class[] { byte.class, short.class, int.class, char.class,
+ for (final Class<?> type : new Class[] { byte.class, short.class, int.class, char.class,
long.class, float.class, double.class, boolean.class, String.class, Class.class,
NestAnnotation.class, TestAnnotation.class, Stooge.class, ElementType.class }) {
assertTrue(AnnotationUtils.isValidAnnotationMemberType(type));
assertTrue(AnnotationUtils.isValidAnnotationMemberType(Array.newInstance(type, 0)
.getClass()));
}
- for (Class<?> type : new Class[] { Object.class, Map.class, Collection.class }) {
+ for (final Class<?> type : new Class[] { Object.class, Map.class, Collection.class }) {
assertFalse(AnnotationUtils.isValidAnnotationMemberType(type));
assertFalse(AnnotationUtils.isValidAnnotationMemberType(Array.newInstance(type, 0)
.getClass()));
@@ -449,7 +449,7 @@ public class AnnotationUtilsTest {
final Test real = getClass().getDeclaredMethod(
"testGeneratedAnnotationEquivalentToRealAnnotation").getAnnotation(Test.class);
- InvocationHandler generatedTestInvocationHandler = new InvocationHandler() {
+ final InvocationHandler generatedTestInvocationHandler = new InvocationHandler() {
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
@@ -466,7 +466,7 @@ public class AnnotationUtilsTest {
}
};
- Test generated = (Test) Proxy.newProxyInstance(Thread.currentThread()
+ final Test generated = (Test) Proxy.newProxyInstance(Thread.currentThread()
.getContextClassLoader(), new Class[] { Test.class },
generatedTestInvocationHandler);
assertTrue(real.equals(generated));
@@ -474,7 +474,7 @@ public class AnnotationUtilsTest {
assertTrue(AnnotationUtils.equals(generated, real));
assertTrue(AnnotationUtils.equals(real, generated));
- Test generated2 = (Test) Proxy.newProxyInstance(Thread.currentThread()
+ final Test generated2 = (Test) Proxy.newProxyInstance(Thread.currentThread()
.getContextClassLoader(), new Class[] { Test.class },
generatedTestInvocationHandler);
assertFalse(generated.equals(generated2));
@@ -497,7 +497,7 @@ public class AnnotationUtilsTest {
public void testToString() throws Exception {
final Test testAnno = getClass().getDeclaredMethod("testToString")
.getAnnotation(Test.class);
- String toString = AnnotationUtils.toString(testAnno);
+ final String toString = AnnotationUtils.toString(testAnno);
assertTrue(toString.startsWith("@org.junit.Test("));
assertTrue(toString.endsWith(")"));
assertTrue(toString.contains("expected=class org.junit.Test$None"));
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
index 711b61013..6c18f6210 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
@@ -46,7 +46,7 @@ public class ArrayUtilsAddTest {
// Invalid - can't store Long in Integer array
n = ArrayUtils.addAll(new Integer[]{Integer.valueOf(1)}, new Long[]{Long.valueOf(2)});
fail("Should have generated IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
}
}
@@ -59,7 +59,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((boolean[])null, true);
assertTrue(Arrays.equals(new boolean[]{true}, newArray));
assertEquals(Boolean.TYPE, newArray.getClass().getComponentType());
- boolean[] array1 = new boolean[]{true, false, true};
+ final boolean[] array1 = new boolean[]{true, false, true};
newArray = ArrayUtils.add(array1, false);
assertTrue(Arrays.equals(new boolean[]{true, false, true, false}, newArray));
assertEquals(Boolean.TYPE, newArray.getClass().getComponentType());
@@ -74,7 +74,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((byte[])null, (byte)1);
assertTrue(Arrays.equals(new byte[]{1}, newArray));
assertEquals(Byte.TYPE, newArray.getClass().getComponentType());
- byte[] array1 = new byte[]{1, 2, 3};
+ final byte[] array1 = new byte[]{1, 2, 3};
newArray = ArrayUtils.add(array1, (byte)0);
assertTrue(Arrays.equals(new byte[]{1, 2, 3, 0}, newArray));
assertEquals(Byte.TYPE, newArray.getClass().getComponentType());
@@ -92,7 +92,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((char[])null, (char)1);
assertTrue(Arrays.equals(new char[]{1}, newArray));
assertEquals(Character.TYPE, newArray.getClass().getComponentType());
- char[] array1 = new char[]{1, 2, 3};
+ final char[] array1 = new char[]{1, 2, 3};
newArray = ArrayUtils.add(array1, (char)0);
assertTrue(Arrays.equals(new char[]{1, 2, 3, 0}, newArray));
assertEquals(Character.TYPE, newArray.getClass().getComponentType());
@@ -110,7 +110,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((double[])null, 1);
assertTrue(Arrays.equals(new double[]{1}, newArray));
assertEquals(Double.TYPE, newArray.getClass().getComponentType());
- double[] array1 = new double[]{1, 2, 3};
+ final double[] array1 = new double[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new double[]{1, 2, 3, 0}, newArray));
assertEquals(Double.TYPE, newArray.getClass().getComponentType());
@@ -128,7 +128,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((float[])null, 1);
assertTrue(Arrays.equals(new float[]{1}, newArray));
assertEquals(Float.TYPE, newArray.getClass().getComponentType());
- float[] array1 = new float[]{1, 2, 3};
+ final float[] array1 = new float[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new float[]{1, 2, 3, 0}, newArray));
assertEquals(Float.TYPE, newArray.getClass().getComponentType());
@@ -146,7 +146,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((int[])null, 1);
assertTrue(Arrays.equals(new int[]{1}, newArray));
assertEquals(Integer.TYPE, newArray.getClass().getComponentType());
- int[] array1 = new int[]{1, 2, 3};
+ final int[] array1 = new int[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new int[]{1, 2, 3, 0}, newArray));
assertEquals(Integer.TYPE, newArray.getClass().getComponentType());
@@ -164,7 +164,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((long[])null, 1);
assertTrue(Arrays.equals(new long[]{1}, newArray));
assertEquals(Long.TYPE, newArray.getClass().getComponentType());
- long[] array1 = new long[]{1, 2, 3};
+ final long[] array1 = new long[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new long[]{1, 2, 3, 0}, newArray));
assertEquals(Long.TYPE, newArray.getClass().getComponentType());
@@ -182,7 +182,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((short[])null, (short)1);
assertTrue(Arrays.equals(new short[]{1}, newArray));
assertEquals(Short.TYPE, newArray.getClass().getComponentType());
- short[] array1 = new short[]{1, 2, 3};
+ final short[] array1 = new short[]{1, 2, 3};
newArray = ArrayUtils.add(array1, (short)0);
assertTrue(Arrays.equals(new short[]{1, 2, 3, 0}, newArray));
assertEquals(Short.TYPE, newArray.getClass().getComponentType());
@@ -202,12 +202,12 @@ public class ArrayUtilsAddTest {
assertEquals(String.class, newArray.getClass().getComponentType());
//show that not casting to Object[] is okay and will assume String based on "a"
- String[] newStringArray = ArrayUtils.add(null, "a");
+ final String[] newStringArray = ArrayUtils.add(null, "a");
assertTrue(Arrays.equals(new String[]{"a"}, newStringArray));
assertTrue(Arrays.equals(new Object[]{"a"}, newStringArray));
assertEquals(String.class, newStringArray.getClass().getComponentType());
- String[] stringArray1 = new String[]{"a", "b", "c"};
+ final String[] stringArray1 = new String[]{"a", "b", "c"};
newArray = ArrayUtils.add(stringArray1, null);
assertTrue(Arrays.equals(new String[]{"a", "b", "c", null}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
@@ -229,20 +229,22 @@ public class ArrayUtilsAddTest {
@Test
public void testLANG571(){
- String[] stringArray=null;
- String aString=null;
+ final String[] stringArray=null;
+ final String aString=null;
try {
@SuppressWarnings("unused")
+ final
String[] sa = ArrayUtils.add(stringArray, aString);
fail("Should have caused IllegalArgumentException");
- } catch (IllegalArgumentException iae){
+ } catch (final IllegalArgumentException iae){
//expected
}
try {
@SuppressWarnings("unused")
+ final
String[] sa = ArrayUtils.add(stringArray, 0, aString);
fail("Should have caused IllegalArgumentException");
- } catch (IllegalArgumentException iae){
+ } catch (final IllegalArgumentException iae){
//expected
}
}
@@ -251,8 +253,8 @@ public class ArrayUtilsAddTest {
public void testAddObjectArrayToObjectArray() {
assertNull(ArrayUtils.addAll((Object[]) null, (Object[]) null));
Object[] newArray;
- String[] stringArray1 = new String[]{"a", "b", "c"};
- String[] stringArray2 = new String[]{"1", "2", "3"};
+ final String[] stringArray1 = new String[]{"a", "b", "c"};
+ final String[] stringArray2 = new String[]{"1", "2", "3"};
newArray = ArrayUtils.addAll(stringArray1, (String[]) null);
assertNotSame(stringArray1, newArray);
assertTrue(Arrays.equals(stringArray1, newArray));
@@ -278,7 +280,7 @@ public class ArrayUtilsAddTest {
assertTrue(Arrays.equals(ArrayUtils.EMPTY_STRING_ARRAY, newArray));
assertTrue(Arrays.equals(new String[]{}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
- String[] stringArrayNull = new String []{null};
+ final String[] stringArrayNull = new String []{null};
newArray = ArrayUtils.addAll(stringArrayNull, stringArrayNull);
assertTrue(Arrays.equals(new String[]{null, null}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
@@ -372,7 +374,7 @@ public class ArrayUtilsAddTest {
assertTrue(Arrays.equals(new String[]{"a"}, newArray));
assertTrue(Arrays.equals(new Object[]{"a"}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
- String[] stringArray1 = new String[]{"a", "b", "c"};
+ final String[] stringArray1 = new String[]{"a", "b", "c"};
newArray = ArrayUtils.add(stringArray1, 0, null);
assertTrue(Arrays.equals(new String[]{null, "a", "b", "c"}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
@@ -387,9 +389,9 @@ public class ArrayUtilsAddTest {
assertEquals(String.class, newArray.getClass().getComponentType());
assertEquals(String.class, newArray.getClass().getComponentType());
- Object[] o = new Object[] {"1", "2", "4"};
- Object[] result = ArrayUtils.add(o, 2, "3");
- Object[] result2 = ArrayUtils.add(o, 3, "5");
+ final Object[] o = new Object[] {"1", "2", "4"};
+ final Object[] result = ArrayUtils.add(o, 2, "3");
+ final Object[] result2 = ArrayUtils.add(o, 3, "5");
assertNotNull(result);
assertEquals(4, result.length);
@@ -409,7 +411,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new boolean[] { true }, booleanArray ) );
try {
booleanArray = ArrayUtils.add( null, -1, true );
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
booleanArray = ArrayUtils.add( new boolean[] { true }, 0, false);
@@ -420,12 +422,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new boolean[] { true, true, false }, booleanArray ) );
try {
booleanArray = ArrayUtils.add( new boolean[] { true, false }, 4, true);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
booleanArray = ArrayUtils.add( new boolean[] { true, false }, -1, true);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -434,7 +436,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new char[] { 'a' }, charArray ) );
try {
charArray = ArrayUtils.add( (char[]) null, -1, 'a' );
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
charArray = ArrayUtils.add( new char[] { 'a' }, 0, 'b');
@@ -447,12 +449,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new char[] { 'a', 't', 'b', 'c' }, charArray ) );
try {
charArray = ArrayUtils.add( new char[] { 'a', 'b' }, 4, 'c');
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
charArray = ArrayUtils.add( new char[] { 'a', 'b' }, -1, 'c');
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -461,7 +463,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new short[] { 2, 1 }, shortArray ) );
try {
shortArray = ArrayUtils.add( (short[]) null, -1, (short) 2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
shortArray = ArrayUtils.add( new short[] { 2, 6 }, 2, (short) 10);
@@ -472,12 +474,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new short[] { 2, 6, 1, 3 }, shortArray ) );
try {
shortArray = ArrayUtils.add( new short[] { 2, 6 }, 4, (short) 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
shortArray = ArrayUtils.add( new short[] { 2, 6 }, -1, (short) 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -486,7 +488,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new byte[] { 2, 1 }, byteArray ) );
try {
byteArray = ArrayUtils.add( (byte[]) null, -1, (byte) 2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
byteArray = ArrayUtils.add( new byte[] { 2, 6 }, 2, (byte) 3);
@@ -497,12 +499,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new byte[] { 2, 6, 1, 3 }, byteArray ) );
try {
byteArray = ArrayUtils.add( new byte[] { 2, 6 }, 4, (byte) 3);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
byteArray = ArrayUtils.add( new byte[] { 2, 6 }, -1, (byte) 3);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -511,7 +513,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new int[] { 2, 1 }, intArray ) );
try {
intArray = ArrayUtils.add( (int[]) null, -1, 2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
intArray = ArrayUtils.add( new int[] { 2, 6 }, 2, 10);
@@ -522,12 +524,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new int[] { 2, 6, 1, 3 }, intArray ) );
try {
intArray = ArrayUtils.add( new int[] { 2, 6 }, 4, 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
intArray = ArrayUtils.add( new int[] { 2, 6 }, -1, 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -536,7 +538,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new long[] { 2L, 1L }, longArray ) );
try {
longArray = ArrayUtils.add( (long[]) null, -1, 2L);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
longArray = ArrayUtils.add( new long[] { 2L, 6L }, 2, 10L);
@@ -547,12 +549,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new long[] { 2L, 6L, 1L, 3L }, longArray ) );
try {
longArray = ArrayUtils.add( new long[] { 2L, 6L }, 4, 10L);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
longArray = ArrayUtils.add( new long[] { 2L, 6L }, -1, 10L);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -561,7 +563,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new float[] { 2.2f, 1.1f }, floatArray ) );
try {
floatArray = ArrayUtils.add( (float[]) null, -1, 2.2f);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
floatArray = ArrayUtils.add( new float[] { 2.3f, 6.4f }, 2, 10.5f);
@@ -572,12 +574,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new float[] { 2.9f, 6.0f, 1.0f, 0.3f }, floatArray ) );
try {
floatArray = ArrayUtils.add( new float[] { 2.3f, 6.4f }, 4, 10.5f);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
floatArray = ArrayUtils.add( new float[] { 2.3f, 6.4f }, -1, 10.5f);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -586,7 +588,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new double[] { 2.2, 1.1 }, doubleArray ) );
try {
doubleArray = ArrayUtils.add( (double[]) null, -1, 2.2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
doubleArray = ArrayUtils.add( new double[] { 2.3, 6.4 }, 2, 10.5);
@@ -597,12 +599,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new double[] { 2.9, 6.0, 1.0, 0.3 }, doubleArray ) );
try {
doubleArray = ArrayUtils.add( new double[] { 2.3, 6.4 }, 4, 10.5);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
doubleArray = ArrayUtils.add( new double[] { 2.3, 6.4 }, -1, 10.5);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
}
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java
index 7b1a0561f..ba01c8092 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java
@@ -74,8 +74,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllObjectArrayRemoveNone() {
- Object[] array1 = new Object[] { "foo", "bar", "baz" };
- Object[] array2 = ArrayUtils.removeAll(array1);
+ final Object[] array1 = new Object[] { "foo", "bar", "baz" };
+ final Object[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(Object.class, array2.getClass().getComponentType());
@@ -98,7 +98,7 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllNumberArray() {
- Number[] inarray = { Integer.valueOf(1), Long.valueOf(2L), Byte.valueOf((byte) 3) };
+ final Number[] inarray = { Integer.valueOf(1), Long.valueOf(2L), Byte.valueOf((byte) 3) };
assertEquals(3, inarray.length);
Number[] outarray;
outarray = ArrayUtils.removeAll(inarray, 1);
@@ -172,8 +172,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllBooleanArrayRemoveNone() {
- boolean[] array1 = new boolean[] { true, false };
- boolean[] array2 = ArrayUtils.removeAll(array1);
+ final boolean[] array1 = new boolean[] { true, false };
+ final boolean[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertTrue(Arrays.equals(array1, array2));
assertEquals(boolean.class, array2.getClass().getComponentType());
@@ -238,8 +238,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllByteArrayRemoveNone() {
- byte[] array1 = new byte[] { 1, 2 };
- byte[] array2 = ArrayUtils.removeAll(array1);
+ final byte[] array1 = new byte[] { 1, 2 };
+ final byte[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(byte.class, array2.getClass().getComponentType());
@@ -304,8 +304,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllCharArrayRemoveNone() {
- char[] array1 = new char[] { 'a', 'b' };
- char[] array2 = ArrayUtils.removeAll(array1);
+ final char[] array1 = new char[] { 'a', 'b' };
+ final char[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(char.class, array2.getClass().getComponentType());
@@ -370,8 +370,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllDoubleArrayRemoveNone() {
- double[] array1 = new double[] { 1, 2 };
- double[] array2 = ArrayUtils.removeAll(array1);
+ final double[] array1 = new double[] { 1, 2 };
+ final double[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertTrue(Arrays.equals(array1, array2));
assertEquals(double.class, array2.getClass().getComponentType());
@@ -436,8 +436,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllFloatArrayRemoveNone() {
- float[] array1 = new float[] { 1, 2 };
- float[] array2 = ArrayUtils.removeAll(array1);
+ final float[] array1 = new float[] { 1, 2 };
+ final float[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertTrue(Arrays.equals(array1, array2));
assertEquals(float.class, array2.getClass().getComponentType());
@@ -506,8 +506,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllIntArrayRemoveNone() {
- int[] array1 = new int[] { 1, 2 };
- int[] array2 = ArrayUtils.removeAll(array1);
+ final int[] array1 = new int[] { 1, 2 };
+ final int[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(int.class, array2.getClass().getComponentType());
@@ -572,8 +572,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllLongArrayRemoveNone() {
- long[] array1 = new long[] { 1, 2 };
- long[] array2 = ArrayUtils.removeAll(array1);
+ final long[] array1 = new long[] { 1, 2 };
+ final long[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(long.class, array2.getClass().getComponentType());
@@ -638,8 +638,8 @@ public class ArrayUtilsRemoveMultipleTest {
@Test
public void testRemoveAllShortArrayRemoveNone() {
- short[] array1 = new short[] { 1, 2 };
- short[] array2 = ArrayUtils.removeAll(array1);
+ final short[] array1 = new short[] { 1, 2 };
+ final short[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(short.class, array2.getClass().getComponentType());
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java
index f4f789aff..b74c77185 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java
@@ -51,20 +51,20 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new Object[] {"a", "b"}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new Object[] {"a", "b"}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((Object[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
public void testRemoveNumberArray(){
- Number[] inarray = {Integer.valueOf(1),Long.valueOf(2),Byte.valueOf((byte) 3)};
+ final Number[] inarray = {Integer.valueOf(1),Long.valueOf(2),Byte.valueOf((byte) 3)};
assertEquals(3, inarray.length);
Number[] outarray;
outarray = ArrayUtils.remove(inarray, 1);
@@ -96,15 +96,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new boolean[] {true, false}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new boolean[] {true, false}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((boolean[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -125,15 +125,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new byte[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new byte[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((byte[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -154,15 +154,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new char[] {'a', 'b'}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new char[] {'a', 'b'}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((char[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -183,15 +183,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new double[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new double[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((double[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -212,15 +212,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new float[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new float[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((float[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -241,15 +241,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new int[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new int[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((int[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -270,15 +270,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new long[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new long[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((long[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -299,15 +299,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new short[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new short[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((short[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
index deb74e1cc..d93aa2ae6 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
@@ -45,7 +45,7 @@ public class ArrayUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new ArrayUtils());
- Constructor<?>[] cons = ArrayUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = ArrayUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ArrayUtils.class.getModifiers()));
@@ -71,18 +71,18 @@ public class ArrayUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testHashCode() {
- long[][] array1 = new long[][] {{2,5}, {4,5}};
- long[][] array2 = new long[][] {{2,5}, {4,6}};
+ final long[][] array1 = new long[][] {{2,5}, {4,5}};
+ final long[][] array2 = new long[][] {{2,5}, {4,6}};
assertTrue(ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array1));
assertFalse(ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array2));
- Object[] array3 = new Object[] {new String(new char[] {'A', 'B'})};
- Object[] array4 = new Object[] {"AB"};
+ final Object[] array3 = new Object[] {new String(new char[] {'A', 'B'})};
+ final Object[] array4 = new Object[] {"AB"};
assertTrue(ArrayUtils.hashCode(array3) == ArrayUtils.hashCode(array3));
assertTrue(ArrayUtils.hashCode(array3) == ArrayUtils.hashCode(array4));
- Object[] arrayA = new Object[] {new boolean[] {true, false}, new int[] {6, 7}};
- Object[] arrayB = new Object[] {new boolean[] {true, false}, new int[] {6, 7}};
+ final Object[] arrayA = new Object[] {new boolean[] {true, false}, new int[] {6, 7}};
+ final Object[] arrayB = new Object[] {new boolean[] {true, false}, new int[] {6, 7}};
assertTrue(ArrayUtils.hashCode(arrayB) == ArrayUtils.hashCode(arrayA));
}
@@ -101,48 +101,48 @@ public class ArrayUtilsTest {
@Test
public void testIsEquals() {
- long[][] larray1 = new long[][]{{2, 5}, {4, 5}};
- long[][] larray2 = new long[][]{{2, 5}, {4, 6}};
- long[] larray3 = new long[]{2, 5};
+ final long[][] larray1 = new long[][]{{2, 5}, {4, 5}};
+ final long[][] larray2 = new long[][]{{2, 5}, {4, 6}};
+ final long[] larray3 = new long[]{2, 5};
this.assertIsEquals(larray1, larray2, larray3);
- int[][] iarray1 = new int[][]{{2, 5}, {4, 5}};
- int[][] iarray2 = new int[][]{{2, 5}, {4, 6}};
- int[] iarray3 = new int[]{2, 5};
+ final int[][] iarray1 = new int[][]{{2, 5}, {4, 5}};
+ final int[][] iarray2 = new int[][]{{2, 5}, {4, 6}};
+ final int[] iarray3 = new int[]{2, 5};
this.assertIsEquals(iarray1, iarray2, iarray3);
- short[][] sarray1 = new short[][]{{2, 5}, {4, 5}};
- short[][] sarray2 = new short[][]{{2, 5}, {4, 6}};
- short[] sarray3 = new short[]{2, 5};
+ final short[][] sarray1 = new short[][]{{2, 5}, {4, 5}};
+ final short[][] sarray2 = new short[][]{{2, 5}, {4, 6}};
+ final short[] sarray3 = new short[]{2, 5};
this.assertIsEquals(sarray1, sarray2, sarray3);
- float[][] farray1 = new float[][]{{2, 5}, {4, 5}};
- float[][] farray2 = new float[][]{{2, 5}, {4, 6}};
- float[] farray3 = new float[]{2, 5};
+ final float[][] farray1 = new float[][]{{2, 5}, {4, 5}};
+ final float[][] farray2 = new float[][]{{2, 5}, {4, 6}};
+ final float[] farray3 = new float[]{2, 5};
this.assertIsEquals(farray1, farray2, farray3);
- double[][] darray1 = new double[][]{{2, 5}, {4, 5}};
- double[][] darray2 = new double[][]{{2, 5}, {4, 6}};
- double[] darray3 = new double[]{2, 5};
+ final double[][] darray1 = new double[][]{{2, 5}, {4, 5}};
+ final double[][] darray2 = new double[][]{{2, 5}, {4, 6}};
+ final double[] darray3 = new double[]{2, 5};
this.assertIsEquals(darray1, darray2, darray3);
- byte[][] byteArray1 = new byte[][]{{2, 5}, {4, 5}};
- byte[][] byteArray2 = new byte[][]{{2, 5}, {4, 6}};
- byte[] byteArray3 = new byte[]{2, 5};
+ final byte[][] byteArray1 = new byte[][]{{2, 5}, {4, 5}};
+ final byte[][] byteArray2 = new byte[][]{{2, 5}, {4, 6}};
+ final byte[] byteArray3 = new byte[]{2, 5};
this.assertIsEquals(byteArray1, byteArray2, byteArray3);
- char[][] charArray1 = new char[][]{{2, 5}, {4, 5}};
- char[][] charArray2 = new char[][]{{2, 5}, {4, 6}};
- char[] charArray3 = new char[]{2, 5};
+ final char[][] charArray1 = new char[][]{{2, 5}, {4, 5}};
+ final char[][] charArray2 = new char[][]{{2, 5}, {4, 6}};
+ final char[] charArray3 = new char[]{2, 5};
this.assertIsEquals(charArray1, charArray2, charArray3);
- boolean[][] barray1 = new boolean[][]{{true, false}, {true, true}};
- boolean[][] barray2 = new boolean[][]{{true, false}, {true, false}};
- boolean[] barray3 = new boolean[]{false, true};
+ final boolean[][] barray1 = new boolean[][]{{true, false}, {true, true}};
+ final boolean[][] barray2 = new boolean[][]{{true, false}, {true, false}};
+ final boolean[] barray3 = new boolean[]{false, true};
this.assertIsEquals(barray1, barray2, barray3);
- Object[] array3 = new Object[]{new String(new char[]{'A', 'B'})};
- Object[] array4 = new Object[]{"AB"};
+ final Object[] array3 = new Object[]{new String(new char[]{'A', 'B'})};
+ final Object[] array4 = new Object[]{"AB"};
assertTrue(ArrayUtils.isEquals(array3, array3));
assertTrue(ArrayUtils.isEquals(array3, array4));
@@ -234,15 +234,15 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toMap(new String[][] {{"foo", "bar"}, {"short"}});
fail("exception expected");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
ArrayUtils.toMap(new Object[] {new Object[] {"foo", "bar"}, "illegal type"});
fail("exception expected");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
ArrayUtils.toMap(new Object[] {new Object[] {"foo", "bar"}, null});
fail("exception expected");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
map = ArrayUtils.toMap(new Object[] {new Map.Entry<Object, Object>() {
@Override
@@ -278,7 +278,7 @@ public class ArrayUtilsTest {
assertTrue(Arrays.equals(original1, cloned1));
assertTrue(original1 != cloned1);
- StringBuffer buf = new StringBuffer("pick");
+ final StringBuffer buf = new StringBuffer("pick");
original1 = new Object[] {buf, "a", new String[] {"stick"}};
cloned1 = ArrayUtils.clone(original1);
assertTrue(Arrays.equals(original1, cloned1));
@@ -291,8 +291,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneBoolean() {
assertEquals(null, ArrayUtils.clone((boolean[]) null));
- boolean[] original = new boolean[] {true, false};
- boolean[] cloned = ArrayUtils.clone(original);
+ final boolean[] original = new boolean[] {true, false};
+ final boolean[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -300,8 +300,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneLong() {
assertEquals(null, ArrayUtils.clone((long[]) null));
- long[] original = new long[] {0L, 1L};
- long[] cloned = ArrayUtils.clone(original);
+ final long[] original = new long[] {0L, 1L};
+ final long[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -309,8 +309,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneInt() {
assertEquals(null, ArrayUtils.clone((int[]) null));
- int[] original = new int[] {5, 8};
- int[] cloned = ArrayUtils.clone(original);
+ final int[] original = new int[] {5, 8};
+ final int[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -318,8 +318,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneShort() {
assertEquals(null, ArrayUtils.clone((short[]) null));
- short[] original = new short[] {1, 4};
- short[] cloned = ArrayUtils.clone(original);
+ final short[] original = new short[] {1, 4};
+ final short[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -327,8 +327,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneChar() {
assertEquals(null, ArrayUtils.clone((char[]) null));
- char[] original = new char[] {'a', '4'};
- char[] cloned = ArrayUtils.clone(original);
+ final char[] original = new char[] {'a', '4'};
+ final char[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -336,8 +336,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneByte() {
assertEquals(null, ArrayUtils.clone((byte[]) null));
- byte[] original = new byte[] {1, 6};
- byte[] cloned = ArrayUtils.clone(original);
+ final byte[] original = new byte[] {1, 6};
+ final byte[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -345,8 +345,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneDouble() {
assertEquals(null, ArrayUtils.clone((double[]) null));
- double[] original = new double[] {2.4d, 5.7d};
- double[] cloned = ArrayUtils.clone(original);
+ final double[] original = new double[] {2.4d, 5.7d};
+ final double[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -354,8 +354,8 @@ public class ArrayUtilsTest {
@Test
public void testCloneFloat() {
assertEquals(null, ArrayUtils.clone((float[]) null));
- float[] original = new float[] {2.6f, 6.4f};
- float[] cloned = ArrayUtils.clone(original);
+ final float[] original = new float[] {2.6f, 6.4f};
+ final float[] cloned = ArrayUtils.clone(original);
assertTrue(Arrays.equals(original, cloned));
assertTrue(original != cloned);
}
@@ -367,11 +367,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, ArrayUtils.nullToEmpty((boolean[]) null));
// Test valid array handling
- boolean[] original = new boolean[] {true, false};
+ final boolean[] original = new boolean[] {true, false};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- boolean[] empty = new boolean[]{};
- boolean[] result = ArrayUtils.nullToEmpty(empty);
+ final boolean[] empty = new boolean[]{};
+ final boolean[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, result);
assertTrue(empty != result);
}
@@ -381,11 +381,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_LONG_ARRAY, ArrayUtils.nullToEmpty((long[]) null));
// Test valid array handling
- long[] original = new long[] {1L, 2L};
+ final long[] original = new long[] {1L, 2L};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- long[] empty = new long[]{};
- long[] result = ArrayUtils.nullToEmpty(empty);
+ final long[] empty = new long[]{};
+ final long[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_LONG_ARRAY, result);
assertTrue(empty != result);
}
@@ -395,11 +395,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_INT_ARRAY, ArrayUtils.nullToEmpty((int[]) null));
// Test valid array handling
- int[] original = new int[] {1, 2};
+ final int[] original = new int[] {1, 2};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- int[] empty = new int[]{};
- int[] result = ArrayUtils.nullToEmpty(empty);
+ final int[] empty = new int[]{};
+ final int[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_INT_ARRAY, result);
assertTrue(empty != result);
}
@@ -409,11 +409,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_SHORT_ARRAY, ArrayUtils.nullToEmpty((short[]) null));
// Test valid array handling
- short[] original = new short[] {1, 2};
+ final short[] original = new short[] {1, 2};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- short[] empty = new short[]{};
- short[] result = ArrayUtils.nullToEmpty(empty);
+ final short[] empty = new short[]{};
+ final short[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_SHORT_ARRAY, result);
assertTrue(empty != result);
}
@@ -423,11 +423,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_CHAR_ARRAY, ArrayUtils.nullToEmpty((char[]) null));
// Test valid array handling
- char[] original = new char[] {'a', 'b'};
+ final char[] original = new char[] {'a', 'b'};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- char[] empty = new char[]{};
- char[] result = ArrayUtils.nullToEmpty(empty);
+ final char[] empty = new char[]{};
+ final char[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_CHAR_ARRAY, result);
assertTrue(empty != result);
}
@@ -437,11 +437,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.nullToEmpty((byte[]) null));
// Test valid array handling
- byte[] original = new byte[] {0x0F, 0x0E};
+ final byte[] original = new byte[] {0x0F, 0x0E};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- byte[] empty = new byte[]{};
- byte[] result = ArrayUtils.nullToEmpty(empty);
+ final byte[] empty = new byte[]{};
+ final byte[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_BYTE_ARRAY, result);
assertTrue(empty != result);
}
@@ -451,11 +451,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_DOUBLE_ARRAY, ArrayUtils.nullToEmpty((double[]) null));
// Test valid array handling
- double[] original = new double[] {1L, 2L};
+ final double[] original = new double[] {1L, 2L};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- double[] empty = new double[]{};
- double[] result = ArrayUtils.nullToEmpty(empty);
+ final double[] empty = new double[]{};
+ final double[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_DOUBLE_ARRAY, result);
assertTrue(empty != result);
}
@@ -465,11 +465,11 @@ public class ArrayUtilsTest {
// Test null handling
assertEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.nullToEmpty((float[]) null));
// Test valid array handling
- float[] original = new float[] {2.6f, 3.8f};
+ final float[] original = new float[] {2.6f, 3.8f};
assertEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- float[] empty = new float[]{};
- float[] result = ArrayUtils.nullToEmpty(empty);
+ final float[] empty = new float[]{};
+ final float[] result = ArrayUtils.nullToEmpty(empty);
assertEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, result);
assertTrue(empty != result);
}
@@ -479,11 +479,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Object[]) null));
// Test valid array handling
- Object[] original = new Object[] {Boolean.TRUE, Boolean.FALSE};
+ final Object[] original = new Object[] {Boolean.TRUE, Boolean.FALSE};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Object[] empty = new Object[]{};
- Object[] result = ArrayUtils.nullToEmpty(empty);
+ final Object[] empty = new Object[]{};
+ final Object[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -493,11 +493,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_STRING_ARRAY, ArrayUtils.nullToEmpty((String[]) null));
// Test valid array handling
- String[] original = new String[] {"abc", "def"};
+ final String[] original = new String[] {"abc", "def"};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- String[] empty = new String[]{};
- String[] result = ArrayUtils.nullToEmpty(empty);
+ final String[] empty = new String[]{};
+ final String[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_STRING_ARRAY, result);
assertTrue(empty != result);
}
@@ -507,11 +507,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Boolean[]) null));
// Test valid array handling
- Boolean[] original = new Boolean[] {Boolean.TRUE, Boolean.FALSE};
+ final Boolean[] original = new Boolean[] {Boolean.TRUE, Boolean.FALSE};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Boolean[] empty = new Boolean[]{};
- Boolean[] result = ArrayUtils.nullToEmpty(empty);
+ final Boolean[] empty = new Boolean[]{};
+ final Boolean[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -522,11 +522,12 @@ public class ArrayUtilsTest {
assertArrayEquals(ArrayUtils.EMPTY_LONG_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Long[]) null));
// Test valid array handling
@SuppressWarnings("boxing")
+ final
Long[] original = new Long[] {1L, 2L};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Long[] empty = new Long[]{};
- Long[] result = ArrayUtils.nullToEmpty(empty);
+ final Long[] empty = new Long[]{};
+ final Long[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_LONG_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -536,11 +537,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Integer[]) null));
// Test valid array handling
- Integer[] original = new Integer[] {1, 2};
+ final Integer[] original = new Integer[] {1, 2};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Integer[] empty = new Integer[]{};
- Integer[] result = ArrayUtils.nullToEmpty(empty);
+ final Integer[] empty = new Integer[]{};
+ final Integer[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -551,11 +552,12 @@ public class ArrayUtilsTest {
assertArrayEquals(ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Short[]) null));
// Test valid array handling
@SuppressWarnings("boxing")
+ final
Short[] original = new Short[] {1, 2};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Short[] empty = new Short[]{};
- Short[] result = ArrayUtils.nullToEmpty(empty);
+ final Short[] empty = new Short[]{};
+ final Short[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -565,11 +567,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Character[]) null));
// Test valid array handling
- Character[] original = new Character[] {'a', 'b'};
+ final Character[] original = new Character[] {'a', 'b'};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Character[] empty = new Character[]{};
- Character[] result = ArrayUtils.nullToEmpty(empty);
+ final Character[] empty = new Character[]{};
+ final Character[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -579,11 +581,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Byte[]) null));
// Test valid array handling
- Byte[] original = new Byte[] {0x0F, 0x0E};
+ final Byte[] original = new Byte[] {0x0F, 0x0E};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Byte[] empty = new Byte[]{};
- Byte[] result = ArrayUtils.nullToEmpty(empty);
+ final Byte[] empty = new Byte[]{};
+ final Byte[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -593,11 +595,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Double[]) null));
// Test valid array handling
- Double[] original = new Double[] {1D, 2D};
+ final Double[] original = new Double[] {1D, 2D};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Double[] empty = new Double[]{};
- Double[] result = ArrayUtils.nullToEmpty(empty);
+ final Double[] empty = new Double[]{};
+ final Double[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -607,11 +609,11 @@ public class ArrayUtilsTest {
// Test null handling
assertArrayEquals(ArrayUtils.EMPTY_FLOAT_OBJECT_ARRAY, ArrayUtils.nullToEmpty((Float[]) null));
// Test valid array handling
- Float[] original = new Float[] {2.6f, 3.8f};
+ final Float[] original = new Float[] {2.6f, 3.8f};
assertArrayEquals(original, ArrayUtils.nullToEmpty(original));
// Test empty array handling
- Float[] empty = new Float[]{};
- Float[] result = ArrayUtils.nullToEmpty(empty);
+ final Float[] empty = new Float[]{};
+ final Float[] result = ArrayUtils.nullToEmpty(empty);
assertArrayEquals(ArrayUtils.EMPTY_FLOAT_OBJECT_ARRAY, result);
assertTrue(empty != result);
}
@@ -620,8 +622,8 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayObject() {
- Object[] nullArray = null;
- Object[] objectArray = { "a", "b", "c", "d", "e", "f"};
+ final Object[] nullArray = null;
+ final Object[] objectArray = { "a", "b", "c", "d", "e", "f"};
assertEquals("0 start, mid end", "abcd",
StringUtils.join(ArrayUtils.subarray(objectArray, 0, 4)));
@@ -649,7 +651,7 @@ public class ArrayUtilsTest {
StringUtils.join(ArrayUtils.subarray(objectArray, -2, 12)));
// array type tests
- Date[] dateArray = { new java.sql.Date(new Date().getTime()),
+ final Date[] dateArray = { new java.sql.Date(new Date().getTime()),
new Date(), new Date(), new Date(), new Date() };
assertSame("Object type", Object.class,
@@ -660,18 +662,19 @@ public class ArrayUtilsTest {
ArrayUtils.subarray(dateArray, 1, 4).getClass().getComponentType());
try {
@SuppressWarnings("unused")
+ final
java.sql.Date[] dummy = (java.sql.Date[])ArrayUtils.subarray(dateArray, 1,3);
fail("Invalid downcast");
- } catch (ClassCastException e) {}
+ } catch (final ClassCastException e) {}
}
@Test
public void testSubarrayLong() {
- long[] nullArray = null;
- long[] array = { 999910, 999911, 999912, 999913, 999914, 999915 };
- long[] leftSubarray = { 999910, 999911, 999912, 999913 };
- long[] midSubarray = { 999911, 999912, 999913, 999914 };
- long[] rightSubarray = { 999912, 999913, 999914, 999915 };
+ final long[] nullArray = null;
+ final long[] array = { 999910, 999911, 999912, 999913, 999914, 999915 };
+ final long[] leftSubarray = { 999910, 999911, 999912, 999913 };
+ final long[] midSubarray = { 999911, 999912, 999913, 999914 };
+ final long[] rightSubarray = { 999912, 999913, 999914, 999915 };
assertTrue("0 start, mid end",
ArrayUtils.isEquals(leftSubarray,
@@ -744,11 +747,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayInt() {
- int[] nullArray = null;
- int[] array = { 10, 11, 12, 13, 14, 15 };
- int[] leftSubarray = { 10, 11, 12, 13 };
- int[] midSubarray = { 11, 12, 13, 14 };
- int[] rightSubarray = { 12, 13, 14, 15 };
+ final int[] nullArray = null;
+ final int[] array = { 10, 11, 12, 13, 14, 15 };
+ final int[] leftSubarray = { 10, 11, 12, 13 };
+ final int[] midSubarray = { 11, 12, 13, 14 };
+ final int[] rightSubarray = { 12, 13, 14, 15 };
assertTrue("0 start, mid end",
@@ -822,11 +825,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayShort() {
- short[] nullArray = null;
- short[] array = { 10, 11, 12, 13, 14, 15 };
- short[] leftSubarray = { 10, 11, 12, 13 };
- short[] midSubarray = { 11, 12, 13, 14 };
- short[] rightSubarray = { 12, 13, 14, 15 };
+ final short[] nullArray = null;
+ final short[] array = { 10, 11, 12, 13, 14, 15 };
+ final short[] leftSubarray = { 10, 11, 12, 13 };
+ final short[] midSubarray = { 11, 12, 13, 14 };
+ final short[] rightSubarray = { 12, 13, 14, 15 };
assertTrue("0 start, mid end",
@@ -900,11 +903,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrChar() {
- char[] nullArray = null;
- char[] array = { 'a', 'b', 'c', 'd', 'e', 'f' };
- char[] leftSubarray = { 'a', 'b', 'c', 'd', };
- char[] midSubarray = { 'b', 'c', 'd', 'e', };
- char[] rightSubarray = { 'c', 'd', 'e', 'f', };
+ final char[] nullArray = null;
+ final char[] array = { 'a', 'b', 'c', 'd', 'e', 'f' };
+ final char[] leftSubarray = { 'a', 'b', 'c', 'd', };
+ final char[] midSubarray = { 'b', 'c', 'd', 'e', };
+ final char[] rightSubarray = { 'c', 'd', 'e', 'f', };
assertTrue("0 start, mid end",
@@ -978,11 +981,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayByte() {
- byte[] nullArray = null;
- byte[] array = { 10, 11, 12, 13, 14, 15 };
- byte[] leftSubarray = { 10, 11, 12, 13 };
- byte[] midSubarray = { 11, 12, 13, 14 };
- byte[] rightSubarray = { 12, 13, 14, 15 };
+ final byte[] nullArray = null;
+ final byte[] array = { 10, 11, 12, 13, 14, 15 };
+ final byte[] leftSubarray = { 10, 11, 12, 13 };
+ final byte[] midSubarray = { 11, 12, 13, 14 };
+ final byte[] rightSubarray = { 12, 13, 14, 15 };
assertTrue("0 start, mid end",
@@ -1056,11 +1059,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayDouble() {
- double[] nullArray = null;
- double[] array = { 10.123, 11.234, 12.345, 13.456, 14.567, 15.678 };
- double[] leftSubarray = { 10.123, 11.234, 12.345, 13.456, };
- double[] midSubarray = { 11.234, 12.345, 13.456, 14.567, };
- double[] rightSubarray = { 12.345, 13.456, 14.567, 15.678 };
+ final double[] nullArray = null;
+ final double[] array = { 10.123, 11.234, 12.345, 13.456, 14.567, 15.678 };
+ final double[] leftSubarray = { 10.123, 11.234, 12.345, 13.456, };
+ final double[] midSubarray = { 11.234, 12.345, 13.456, 14.567, };
+ final double[] rightSubarray = { 12.345, 13.456, 14.567, 15.678 };
assertTrue("0 start, mid end",
@@ -1134,11 +1137,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayFloat() {
- float[] nullArray = null;
- float[] array = { 10, 11, 12, 13, 14, 15 };
- float[] leftSubarray = { 10, 11, 12, 13 };
- float[] midSubarray = { 11, 12, 13, 14 };
- float[] rightSubarray = { 12, 13, 14, 15 };
+ final float[] nullArray = null;
+ final float[] array = { 10, 11, 12, 13, 14, 15 };
+ final float[] leftSubarray = { 10, 11, 12, 13 };
+ final float[] midSubarray = { 11, 12, 13, 14 };
+ final float[] rightSubarray = { 12, 13, 14, 15 };
assertTrue("0 start, mid end",
@@ -1212,11 +1215,11 @@ public class ArrayUtilsTest {
@Test
public void testSubarrayBoolean() {
- boolean[] nullArray = null;
- boolean[] array = { true, true, false, true, false, true };
- boolean[] leftSubarray = { true, true, false, true };
- boolean[] midSubarray = { true, false, true, false };
- boolean[] rightSubarray = { false, true, false, true };
+ final boolean[] nullArray = null;
+ final boolean[] array = { true, true, false, true, false, true };
+ final boolean[] leftSubarray = { true, true, false, true };
+ final boolean[] midSubarray = { true, false, true, false };
+ final boolean[] rightSubarray = { false, true, false, true };
assertTrue("0 start, mid end",
@@ -1291,10 +1294,10 @@ public class ArrayUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testSameLength() {
- Object[] nullArray = null;
- Object[] emptyArray = new Object[0];
- Object[] oneArray = new Object[] {"pick"};
- Object[] twoArray = new Object[] {"pick", "stick"};
+ final Object[] nullArray = null;
+ final Object[] emptyArray = new Object[0];
+ final Object[] oneArray = new Object[] {"pick"};
+ final Object[] twoArray = new Object[] {"pick", "stick"};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1319,10 +1322,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthBoolean() {
- boolean[] nullArray = null;
- boolean[] emptyArray = new boolean[0];
- boolean[] oneArray = new boolean[] {true};
- boolean[] twoArray = new boolean[] {true, false};
+ final boolean[] nullArray = null;
+ final boolean[] emptyArray = new boolean[0];
+ final boolean[] oneArray = new boolean[] {true};
+ final boolean[] twoArray = new boolean[] {true, false};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1347,10 +1350,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthLong() {
- long[] nullArray = null;
- long[] emptyArray = new long[0];
- long[] oneArray = new long[] {0L};
- long[] twoArray = new long[] {0L, 76L};
+ final long[] nullArray = null;
+ final long[] emptyArray = new long[0];
+ final long[] oneArray = new long[] {0L};
+ final long[] twoArray = new long[] {0L, 76L};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1375,10 +1378,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthInt() {
- int[] nullArray = null;
- int[] emptyArray = new int[0];
- int[] oneArray = new int[] {4};
- int[] twoArray = new int[] {5, 7};
+ final int[] nullArray = null;
+ final int[] emptyArray = new int[0];
+ final int[] oneArray = new int[] {4};
+ final int[] twoArray = new int[] {5, 7};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1403,10 +1406,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthShort() {
- short[] nullArray = null;
- short[] emptyArray = new short[0];
- short[] oneArray = new short[] {4};
- short[] twoArray = new short[] {6, 8};
+ final short[] nullArray = null;
+ final short[] emptyArray = new short[0];
+ final short[] oneArray = new short[] {4};
+ final short[] twoArray = new short[] {6, 8};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1431,10 +1434,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthChar() {
- char[] nullArray = null;
- char[] emptyArray = new char[0];
- char[] oneArray = new char[] {'f'};
- char[] twoArray = new char[] {'d', 't'};
+ final char[] nullArray = null;
+ final char[] emptyArray = new char[0];
+ final char[] oneArray = new char[] {'f'};
+ final char[] twoArray = new char[] {'d', 't'};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1459,10 +1462,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthByte() {
- byte[] nullArray = null;
- byte[] emptyArray = new byte[0];
- byte[] oneArray = new byte[] {3};
- byte[] twoArray = new byte[] {4, 6};
+ final byte[] nullArray = null;
+ final byte[] emptyArray = new byte[0];
+ final byte[] oneArray = new byte[] {3};
+ final byte[] twoArray = new byte[] {4, 6};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1487,10 +1490,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthDouble() {
- double[] nullArray = null;
- double[] emptyArray = new double[0];
- double[] oneArray = new double[] {1.3d};
- double[] twoArray = new double[] {4.5d, 6.3d};
+ final double[] nullArray = null;
+ final double[] emptyArray = new double[0];
+ final double[] oneArray = new double[] {1.3d};
+ final double[] twoArray = new double[] {4.5d, 6.3d};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1515,10 +1518,10 @@ public class ArrayUtilsTest {
@Test
public void testSameLengthFloat() {
- float[] nullArray = null;
- float[] emptyArray = new float[0];
- float[] oneArray = new float[] {2.5f};
- float[] twoArray = new float[] {6.4f, 5.8f};
+ final float[] nullArray = null;
+ final float[] emptyArray = new float[0];
+ final float[] oneArray = new float[] {2.5f};
+ final float[] twoArray = new float[] {6.4f, 5.8f};
assertTrue(ArrayUtils.isSameLength(nullArray, nullArray));
assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray));
@@ -1547,15 +1550,15 @@ public class ArrayUtilsTest {
try {
ArrayUtils.isSameType(null, null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
ArrayUtils.isSameType(null, new Object[0]);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
ArrayUtils.isSameType(new Object[0], null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
assertTrue(ArrayUtils.isSameType(new Object[0], new Object[0]));
assertFalse(ArrayUtils.isSameType(new String[0], new Object[0]));
@@ -1567,10 +1570,10 @@ public class ArrayUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testReverse() {
- StringBuffer str1 = new StringBuffer("pick");
- String str2 = "a";
- String[] str3 = new String[] {"stick"};
- String str4 = "up";
+ final StringBuffer str1 = new StringBuffer("pick");
+ final String str2 = "a";
+ final String[] str3 = new String[] {"stick"};
+ final String str4 = "up";
Object[] array = new Object[] {str1, str2, str3};
ArrayUtils.reverse(array);
@@ -1697,7 +1700,7 @@ public class ArrayUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testIndexOf() {
- Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
+ final Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
assertEquals(-1, ArrayUtils.indexOf(null, null));
assertEquals(-1, ArrayUtils.indexOf(null, "0"));
assertEquals(-1, ArrayUtils.indexOf(new Object[0], "0"));
@@ -1711,7 +1714,7 @@ public class ArrayUtilsTest {
@Test
public void testIndexOfWithStartIndex() {
- Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
+ final Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
assertEquals(-1, ArrayUtils.indexOf(null, null, 2));
assertEquals(-1, ArrayUtils.indexOf(new Object[0], "0", 0));
assertEquals(-1, ArrayUtils.indexOf(null, "0", 2));
@@ -1729,7 +1732,7 @@ public class ArrayUtilsTest {
@Test
public void testLastIndexOf() {
- Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
+ final Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
assertEquals(-1, ArrayUtils.lastIndexOf(null, null));
assertEquals(-1, ArrayUtils.lastIndexOf(null, "0"));
assertEquals(5, ArrayUtils.lastIndexOf(array, "0"));
@@ -1742,7 +1745,7 @@ public class ArrayUtilsTest {
@Test
public void testLastIndexOfWithStartIndex() {
- Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
+ final Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
assertEquals(-1, ArrayUtils.lastIndexOf(null, null, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(null, "0", 2));
assertEquals(0, ArrayUtils.lastIndexOf(array, "0", 2));
@@ -1760,7 +1763,7 @@ public class ArrayUtilsTest {
@Test
public void testContains() {
- Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
+ final Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
assertFalse(ArrayUtils.contains(null, null));
assertFalse(ArrayUtils.contains(null, "1"));
assertTrue(ArrayUtils.contains(array, "0"));
@@ -2414,7 +2417,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Boolean[] {Boolean.TRUE, null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2464,7 +2467,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2523,7 +2526,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2582,7 +2585,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2638,7 +2641,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2660,7 +2663,7 @@ public class ArrayUtilsTest {
@Test
public void testToPrimitive_intNull() {
- Integer[] iArray = null;
+ final Integer[] iArray = null;
assertEquals(null, ArrayUtils.toPrimitive(iArray, Integer.MIN_VALUE));
}
@@ -2702,7 +2705,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2763,7 +2766,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2824,7 +2827,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null});
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -2872,8 +2875,8 @@ public class ArrayUtilsTest {
*/
@Test
public void testIsEmptyObject() {
- Object[] emptyArray = new Object[] {};
- Object[] notEmptyArray = new Object[] { new String("Value") };
+ final Object[] emptyArray = new Object[] {};
+ final Object[] notEmptyArray = new Object[] { new String("Value") };
assertTrue(ArrayUtils.isEmpty((Object[])null));
assertTrue(ArrayUtils.isEmpty(emptyArray));
assertFalse(ArrayUtils.isEmpty(notEmptyArray));
@@ -2891,50 +2894,50 @@ public class ArrayUtilsTest {
*/
@Test
public void testIsEmptyPrimitives() {
- long[] emptyLongArray = new long[] {};
- long[] notEmptyLongArray = new long[] { 1L };
+ final long[] emptyLongArray = new long[] {};
+ final long[] notEmptyLongArray = new long[] { 1L };
assertTrue(ArrayUtils.isEmpty((long[])null));
assertTrue(ArrayUtils.isEmpty(emptyLongArray));
assertFalse(ArrayUtils.isEmpty(notEmptyLongArray));
- int[] emptyIntArray = new int[] {};
- int[] notEmptyIntArray = new int[] { 1 };
+ final int[] emptyIntArray = new int[] {};
+ final int[] notEmptyIntArray = new int[] { 1 };
assertTrue(ArrayUtils.isEmpty((int[])null));
assertTrue(ArrayUtils.isEmpty(emptyIntArray));
assertFalse(ArrayUtils.isEmpty(notEmptyIntArray));
- short[] emptyShortArray = new short[] {};
- short[] notEmptyShortArray = new short[] { 1 };
+ final short[] emptyShortArray = new short[] {};
+ final short[] notEmptyShortArray = new short[] { 1 };
assertTrue(ArrayUtils.isEmpty((short[])null));
assertTrue(ArrayUtils.isEmpty(emptyShortArray));
assertFalse(ArrayUtils.isEmpty(notEmptyShortArray));
- char[] emptyCharArray = new char[] {};
- char[] notEmptyCharArray = new char[] { 1 };
+ final char[] emptyCharArray = new char[] {};
+ final char[] notEmptyCharArray = new char[] { 1 };
assertTrue(ArrayUtils.isEmpty((char[])null));
assertTrue(ArrayUtils.isEmpty(emptyCharArray));
assertFalse(ArrayUtils.isEmpty(notEmptyCharArray));
- byte[] emptyByteArray = new byte[] {};
- byte[] notEmptyByteArray = new byte[] { 1 };
+ final byte[] emptyByteArray = new byte[] {};
+ final byte[] notEmptyByteArray = new byte[] { 1 };
assertTrue(ArrayUtils.isEmpty((byte[])null));
assertTrue(ArrayUtils.isEmpty(emptyByteArray));
assertFalse(ArrayUtils.isEmpty(notEmptyByteArray));
- double[] emptyDoubleArray = new double[] {};
- double[] notEmptyDoubleArray = new double[] { 1.0 };
+ final double[] emptyDoubleArray = new double[] {};
+ final double[] notEmptyDoubleArray = new double[] { 1.0 };
assertTrue(ArrayUtils.isEmpty((double[])null));
assertTrue(ArrayUtils.isEmpty(emptyDoubleArray));
assertFalse(ArrayUtils.isEmpty(notEmptyDoubleArray));
- float[] emptyFloatArray = new float[] {};
- float[] notEmptyFloatArray = new float[] { 1.0F };
+ final float[] emptyFloatArray = new float[] {};
+ final float[] notEmptyFloatArray = new float[] { 1.0F };
assertTrue(ArrayUtils.isEmpty((float[])null));
assertTrue(ArrayUtils.isEmpty(emptyFloatArray));
assertFalse(ArrayUtils.isEmpty(notEmptyFloatArray));
- boolean[] emptyBooleanArray = new boolean[] {};
- boolean[] notEmptyBooleanArray = new boolean[] { true };
+ final boolean[] emptyBooleanArray = new boolean[] {};
+ final boolean[] notEmptyBooleanArray = new boolean[] { true };
assertTrue(ArrayUtils.isEmpty((boolean[])null));
assertTrue(ArrayUtils.isEmpty(emptyBooleanArray));
assertFalse(ArrayUtils.isEmpty(notEmptyBooleanArray));
@@ -2945,8 +2948,8 @@ public class ArrayUtilsTest {
*/
@Test
public void testIsNotEmptyObject() {
- Object[] emptyArray = new Object[] {};
- Object[] notEmptyArray = new Object[] { new String("Value") };
+ final Object[] emptyArray = new Object[] {};
+ final Object[] notEmptyArray = new Object[] { new String("Value") };
assertFalse(ArrayUtils.isNotEmpty((Object[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyArray));
@@ -2964,50 +2967,50 @@ public class ArrayUtilsTest {
*/
@Test
public void testIsNotEmptyPrimitives() {
- long[] emptyLongArray = new long[] {};
- long[] notEmptyLongArray = new long[] { 1L };
+ final long[] emptyLongArray = new long[] {};
+ final long[] notEmptyLongArray = new long[] { 1L };
assertFalse(ArrayUtils.isNotEmpty((long[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyLongArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyLongArray));
- int[] emptyIntArray = new int[] {};
- int[] notEmptyIntArray = new int[] { 1 };
+ final int[] emptyIntArray = new int[] {};
+ final int[] notEmptyIntArray = new int[] { 1 };
assertFalse(ArrayUtils.isNotEmpty((int[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyIntArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyIntArray));
- short[] emptyShortArray = new short[] {};
- short[] notEmptyShortArray = new short[] { 1 };
+ final short[] emptyShortArray = new short[] {};
+ final short[] notEmptyShortArray = new short[] { 1 };
assertFalse(ArrayUtils.isNotEmpty((short[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyShortArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyShortArray));
- char[] emptyCharArray = new char[] {};
- char[] notEmptyCharArray = new char[] { 1 };
+ final char[] emptyCharArray = new char[] {};
+ final char[] notEmptyCharArray = new char[] { 1 };
assertFalse(ArrayUtils.isNotEmpty((char[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyCharArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyCharArray));
- byte[] emptyByteArray = new byte[] {};
- byte[] notEmptyByteArray = new byte[] { 1 };
+ final byte[] emptyByteArray = new byte[] {};
+ final byte[] notEmptyByteArray = new byte[] { 1 };
assertFalse(ArrayUtils.isNotEmpty((byte[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyByteArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyByteArray));
- double[] emptyDoubleArray = new double[] {};
- double[] notEmptyDoubleArray = new double[] { 1.0 };
+ final double[] emptyDoubleArray = new double[] {};
+ final double[] notEmptyDoubleArray = new double[] { 1.0 };
assertFalse(ArrayUtils.isNotEmpty((double[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyDoubleArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyDoubleArray));
- float[] emptyFloatArray = new float[] {};
- float[] notEmptyFloatArray = new float[] { 1.0F };
+ final float[] emptyFloatArray = new float[] {};
+ final float[] notEmptyFloatArray = new float[] { 1.0F };
assertFalse(ArrayUtils.isNotEmpty((float[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyFloatArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyFloatArray));
- boolean[] emptyBooleanArray = new boolean[] {};
- boolean[] notEmptyBooleanArray = new boolean[] { true };
+ final boolean[] emptyBooleanArray = new boolean[] {};
+ final boolean[] notEmptyBooleanArray = new boolean[] { true };
assertFalse(ArrayUtils.isNotEmpty((boolean[])null));
assertFalse(ArrayUtils.isNotEmpty(emptyBooleanArray));
assertTrue(ArrayUtils.isNotEmpty(notEmptyBooleanArray));
@@ -3017,50 +3020,50 @@ public class ArrayUtilsTest {
public void testGetLength() {
assertEquals(0, ArrayUtils.getLength(null));
- Object[] emptyObjectArray = new Object[0];
- Object[] notEmptyObjectArray = new Object[] {"aValue"};
+ final Object[] emptyObjectArray = new Object[0];
+ final Object[] notEmptyObjectArray = new Object[] {"aValue"};
assertEquals(0, ArrayUtils.getLength((Object[]) null));
assertEquals(0, ArrayUtils.getLength(emptyObjectArray));
assertEquals(1, ArrayUtils.getLength(notEmptyObjectArray));
- int[] emptyIntArray = new int[] {};
- int[] notEmptyIntArray = new int[] { 1 };
+ final int[] emptyIntArray = new int[] {};
+ final int[] notEmptyIntArray = new int[] { 1 };
assertEquals(0, ArrayUtils.getLength((int[]) null));
assertEquals(0, ArrayUtils.getLength(emptyIntArray));
assertEquals(1, ArrayUtils.getLength(notEmptyIntArray));
- short[] emptyShortArray = new short[] {};
- short[] notEmptyShortArray = new short[] { 1 };
+ final short[] emptyShortArray = new short[] {};
+ final short[] notEmptyShortArray = new short[] { 1 };
assertEquals(0, ArrayUtils.getLength((short[]) null));
assertEquals(0, ArrayUtils.getLength(emptyShortArray));
assertEquals(1, ArrayUtils.getLength(notEmptyShortArray));
- char[] emptyCharArray = new char[] {};
- char[] notEmptyCharArray = new char[] { 1 };
+ final char[] emptyCharArray = new char[] {};
+ final char[] notEmptyCharArray = new char[] { 1 };
assertEquals(0, ArrayUtils.getLength((char[]) null));
assertEquals(0, ArrayUtils.getLength(emptyCharArray));
assertEquals(1, ArrayUtils.getLength(notEmptyCharArray));
- byte[] emptyByteArray = new byte[] {};
- byte[] notEmptyByteArray = new byte[] { 1 };
+ final byte[] emptyByteArray = new byte[] {};
+ final byte[] notEmptyByteArray = new byte[] { 1 };
assertEquals(0, ArrayUtils.getLength((byte[]) null));
assertEquals(0, ArrayUtils.getLength(emptyByteArray));
assertEquals(1, ArrayUtils.getLength(notEmptyByteArray));
- double[] emptyDoubleArray = new double[] {};
- double[] notEmptyDoubleArray = new double[] { 1.0 };
+ final double[] emptyDoubleArray = new double[] {};
+ final double[] notEmptyDoubleArray = new double[] { 1.0 };
assertEquals(0, ArrayUtils.getLength((double[]) null));
assertEquals(0, ArrayUtils.getLength(emptyDoubleArray));
assertEquals(1, ArrayUtils.getLength(notEmptyDoubleArray));
- float[] emptyFloatArray = new float[] {};
- float[] notEmptyFloatArray = new float[] { 1.0F };
+ final float[] emptyFloatArray = new float[] {};
+ final float[] notEmptyFloatArray = new float[] { 1.0F };
assertEquals(0, ArrayUtils.getLength((float[]) null));
assertEquals(0, ArrayUtils.getLength(emptyFloatArray));
assertEquals(1, ArrayUtils.getLength(notEmptyFloatArray));
- boolean[] emptyBooleanArray = new boolean[] {};
- boolean[] notEmptyBooleanArray = new boolean[] { true };
+ final boolean[] emptyBooleanArray = new boolean[] {};
+ final boolean[] notEmptyBooleanArray = new boolean[] { true };
assertEquals(0, ArrayUtils.getLength((boolean[]) null));
assertEquals(0, ArrayUtils.getLength(emptyBooleanArray));
assertEquals(1, ArrayUtils.getLength(notEmptyBooleanArray));
@@ -3068,7 +3071,7 @@ public class ArrayUtilsTest {
try {
ArrayUtils.getLength("notAnArray");
fail("IllegalArgumentException should have been thrown");
- } catch (IllegalArgumentException e) {}
+ } catch (final IllegalArgumentException e) {}
}
}
diff --git a/src/test/java/org/apache/commons/lang3/BitFieldTest.java b/src/test/java/org/apache/commons/lang3/BitFieldTest.java
index 3a0de5608..dd71abda9 100644
--- a/src/test/java/org/apache/commons/lang3/BitFieldTest.java
+++ b/src/test/java/org/apache/commons/lang3/BitFieldTest.java
@@ -187,7 +187,7 @@ public class BitFieldTest {
assertEquals(0, new BitField(64).setByteBoolean((byte) 64, false));
assertEquals(0, new BitField(128).setByteBoolean((byte) 128, false));
assertEquals(-2, new BitField(1).setByteBoolean((byte) 255, false));
- byte clearedBit = new BitField(0x40).setByteBoolean((byte) - 63, false);
+ final byte clearedBit = new BitField(0x40).setByteBoolean((byte) - 63, false);
assertFalse(new BitField(0x40).isSet(clearedBit));
}
diff --git a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
index f12d97940..4d104a0ee 100644
--- a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
@@ -38,7 +38,7 @@ public class BooleanUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new BooleanUtils());
- Constructor<?>[] cons = BooleanUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = BooleanUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers()));
@@ -139,8 +139,8 @@ public class BooleanUtilsTest {
@Test
public void test_toBoolean_Integer_Integer_Integer() {
- Integer six = Integer.valueOf(6);
- Integer seven = Integer.valueOf(7);
+ final Integer six = Integer.valueOf(6);
+ final Integer seven = Integer.valueOf(7);
assertTrue(BooleanUtils.toBoolean((Integer) null, null, seven));
assertFalse(BooleanUtils.toBoolean((Integer) null, six, null));
@@ -174,9 +174,9 @@ public class BooleanUtilsTest {
@Test
public void test_toBooleanObject_Integer_Integer_Integer_Integer() {
- Integer six = Integer.valueOf(6);
- Integer seven = Integer.valueOf(7);
- Integer eight = Integer.valueOf(8);
+ final Integer six = Integer.valueOf(6);
+ final Integer seven = Integer.valueOf(7);
+ final Integer eight = Integer.valueOf(8);
assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((Integer) null, null, seven, eight));
assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((Integer) null, six, null, eight));
@@ -233,17 +233,17 @@ public class BooleanUtilsTest {
@Test
public void test_toIntegerObject_boolean_Integer_Integer() {
- Integer six = Integer.valueOf(6);
- Integer seven = Integer.valueOf(7);
+ final Integer six = Integer.valueOf(6);
+ final Integer seven = Integer.valueOf(7);
assertEquals(six, BooleanUtils.toIntegerObject(true, six, seven));
assertEquals(seven, BooleanUtils.toIntegerObject(false, six, seven));
}
@Test
public void test_toIntegerObject_Boolean_Integer_Integer_Integer() {
- Integer six = Integer.valueOf(6);
- Integer seven = Integer.valueOf(7);
- Integer eight = Integer.valueOf(8);
+ final Integer six = Integer.valueOf(6);
+ final Integer seven = Integer.valueOf(7);
+ final Integer eight = Integer.valueOf(8);
assertEquals(six, BooleanUtils.toIntegerObject(Boolean.TRUE, six, seven, eight));
assertEquals(seven, BooleanUtils.toIntegerObject(Boolean.FALSE, six, seven, eight));
assertEquals(eight, BooleanUtils.toIntegerObject((Boolean) null, six, seven, eight));
diff --git a/src/test/java/org/apache/commons/lang3/CharRangeTest.java b/src/test/java/org/apache/commons/lang3/CharRangeTest.java
index 841049464..301e6f7da 100644
--- a/src/test/java/org/apache/commons/lang3/CharRangeTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharRangeTest.java
@@ -48,7 +48,7 @@ public class CharRangeTest {
//-----------------------------------------------------------------------
@Test
public void testConstructorAccessors_is() {
- CharRange rangea = CharRange.is('a');
+ final CharRange rangea = CharRange.is('a');
assertEquals('a', rangea.getStart());
assertEquals('a', rangea.getEnd());
assertFalse(rangea.isNegated());
@@ -57,7 +57,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isNot() {
- CharRange rangea = CharRange.isNot('a');
+ final CharRange rangea = CharRange.isNot('a');
assertEquals('a', rangea.getStart());
assertEquals('a', rangea.getEnd());
assertTrue(rangea.isNegated());
@@ -66,7 +66,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isIn_Same() {
- CharRange rangea = CharRange.isIn('a', 'a');
+ final CharRange rangea = CharRange.isIn('a', 'a');
assertEquals('a', rangea.getStart());
assertEquals('a', rangea.getEnd());
assertFalse(rangea.isNegated());
@@ -75,7 +75,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isIn_Normal() {
- CharRange rangea = CharRange.isIn('a', 'e');
+ final CharRange rangea = CharRange.isIn('a', 'e');
assertEquals('a', rangea.getStart());
assertEquals('e', rangea.getEnd());
assertFalse(rangea.isNegated());
@@ -84,7 +84,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isIn_Reversed() {
- CharRange rangea = CharRange.isIn('e', 'a');
+ final CharRange rangea = CharRange.isIn('e', 'a');
assertEquals('a', rangea.getStart());
assertEquals('e', rangea.getEnd());
assertFalse(rangea.isNegated());
@@ -93,7 +93,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isNotIn_Same() {
- CharRange rangea = CharRange.isNotIn('a', 'a');
+ final CharRange rangea = CharRange.isNotIn('a', 'a');
assertEquals('a', rangea.getStart());
assertEquals('a', rangea.getEnd());
assertTrue(rangea.isNegated());
@@ -102,7 +102,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isNotIn_Normal() {
- CharRange rangea = CharRange.isNotIn('a', 'e');
+ final CharRange rangea = CharRange.isNotIn('a', 'e');
assertEquals('a', rangea.getStart());
assertEquals('e', rangea.getEnd());
assertTrue(rangea.isNegated());
@@ -111,7 +111,7 @@ public class CharRangeTest {
@Test
public void testConstructorAccessors_isNotIn_Reversed() {
- CharRange rangea = CharRange.isNotIn('e', 'a');
+ final CharRange rangea = CharRange.isNotIn('e', 'a');
assertEquals('a', rangea.getStart());
assertEquals('e', rangea.getEnd());
assertTrue(rangea.isNegated());
@@ -121,9 +121,9 @@ public class CharRangeTest {
//-----------------------------------------------------------------------
@Test
public void testEquals_Object() {
- CharRange rangea = CharRange.is('a');
- CharRange rangeae = CharRange.isIn('a', 'e');
- CharRange rangenotbf = CharRange.isIn('b', 'f');
+ final CharRange rangea = CharRange.is('a');
+ final CharRange rangeae = CharRange.isIn('a', 'e');
+ final CharRange rangenotbf = CharRange.isIn('b', 'f');
assertFalse(rangea.equals(null));
@@ -144,9 +144,9 @@ public class CharRangeTest {
@Test
public void testHashCode() {
- CharRange rangea = CharRange.is('a');
- CharRange rangeae = CharRange.isIn('a', 'e');
- CharRange rangenotbf = CharRange.isIn('b', 'f');
+ final CharRange rangea = CharRange.is('a');
+ final CharRange rangeae = CharRange.isIn('a', 'e');
+ final CharRange rangenotbf = CharRange.isIn('b', 'f');
assertTrue(rangea.hashCode() == rangea.hashCode());
assertTrue(rangea.hashCode() == CharRange.is('a').hashCode());
@@ -196,19 +196,19 @@ public class CharRangeTest {
//-----------------------------------------------------------------------
@Test
public void testContains_Charrange() {
- CharRange a = CharRange.is('a');
- CharRange b = CharRange.is('b');
- CharRange c = CharRange.is('c');
- CharRange c2 = CharRange.is('c');
- CharRange d = CharRange.is('d');
- CharRange e = CharRange.is('e');
- CharRange cd = CharRange.isIn('c', 'd');
- CharRange bd = CharRange.isIn('b', 'd');
- CharRange bc = CharRange.isIn('b', 'c');
- CharRange ab = CharRange.isIn('a', 'b');
- CharRange de = CharRange.isIn('d', 'e');
- CharRange ef = CharRange.isIn('e', 'f');
- CharRange ae = CharRange.isIn('a', 'e');
+ final CharRange a = CharRange.is('a');
+ final CharRange b = CharRange.is('b');
+ final CharRange c = CharRange.is('c');
+ final CharRange c2 = CharRange.is('c');
+ final CharRange d = CharRange.is('d');
+ final CharRange e = CharRange.is('e');
+ final CharRange cd = CharRange.isIn('c', 'd');
+ final CharRange bd = CharRange.isIn('b', 'd');
+ final CharRange bc = CharRange.isIn('b', 'c');
+ final CharRange ab = CharRange.isIn('a', 'b');
+ final CharRange de = CharRange.isIn('d', 'e');
+ final CharRange ef = CharRange.isIn('e', 'f');
+ final CharRange ae = CharRange.isIn('a', 'e');
// normal/normal
assertFalse(c.contains(b));
@@ -234,17 +234,17 @@ public class CharRangeTest {
assertTrue(ae.contains(cd));
assertTrue(ae.contains(de));
- CharRange notb = CharRange.isNot('b');
- CharRange notc = CharRange.isNot('c');
- CharRange notd = CharRange.isNot('d');
- CharRange notab = CharRange.isNotIn('a', 'b');
- CharRange notbc = CharRange.isNotIn('b', 'c');
- CharRange notbd = CharRange.isNotIn('b', 'd');
- CharRange notcd = CharRange.isNotIn('c', 'd');
- CharRange notde = CharRange.isNotIn('d', 'e');
- CharRange notae = CharRange.isNotIn('a', 'e');
- CharRange all = CharRange.isIn((char) 0, Character.MAX_VALUE);
- CharRange allbutfirst = CharRange.isIn((char) 1, Character.MAX_VALUE);
+ final CharRange notb = CharRange.isNot('b');
+ final CharRange notc = CharRange.isNot('c');
+ final CharRange notd = CharRange.isNot('d');
+ final CharRange notab = CharRange.isNotIn('a', 'b');
+ final CharRange notbc = CharRange.isNotIn('b', 'c');
+ final CharRange notbd = CharRange.isNotIn('b', 'd');
+ final CharRange notcd = CharRange.isNotIn('c', 'd');
+ final CharRange notde = CharRange.isNotIn('d', 'e');
+ final CharRange notae = CharRange.isNotIn('a', 'e');
+ final CharRange all = CharRange.isIn((char) 0, Character.MAX_VALUE);
+ final CharRange allbutfirst = CharRange.isIn((char) 1, Character.MAX_VALUE);
// normal/negated
assertFalse(c.contains(notc));
@@ -311,31 +311,32 @@ public class CharRangeTest {
@Test
public void testContainsNullArg() {
- CharRange range = CharRange.is('a');
+ final CharRange range = CharRange.is('a');
try {
@SuppressWarnings("unused")
+ final
boolean contains = range.contains(null);
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("The Range must not be null", e.getMessage());
}
}
@Test
public void testIterator() {
- CharRange a = CharRange.is('a');
- CharRange ad = CharRange.isIn('a', 'd');
- CharRange nota = CharRange.isNot('a');
- CharRange emptySet = CharRange.isNotIn((char) 0, Character.MAX_VALUE);
- CharRange notFirst = CharRange.isNotIn((char) 1, Character.MAX_VALUE);
- CharRange notLast = CharRange.isNotIn((char) 0, (char) (Character.MAX_VALUE - 1));
-
- Iterator<Character> aIt = a.iterator();
+ final CharRange a = CharRange.is('a');
+ final CharRange ad = CharRange.isIn('a', 'd');
+ final CharRange nota = CharRange.isNot('a');
+ final CharRange emptySet = CharRange.isNotIn((char) 0, Character.MAX_VALUE);
+ final CharRange notFirst = CharRange.isNotIn((char) 1, Character.MAX_VALUE);
+ final CharRange notLast = CharRange.isNotIn((char) 0, (char) (Character.MAX_VALUE - 1));
+
+ final Iterator<Character> aIt = a.iterator();
assertNotNull(aIt);
assertTrue(aIt.hasNext());
assertEquals(Character.valueOf('a'), aIt.next());
assertFalse(aIt.hasNext());
- Iterator<Character> adIt = ad.iterator();
+ final Iterator<Character> adIt = ad.iterator();
assertNotNull(adIt);
assertTrue(adIt.hasNext());
assertEquals(Character.valueOf('a'), adIt.next());
@@ -344,25 +345,25 @@ public class CharRangeTest {
assertEquals(Character.valueOf('d'), adIt.next());
assertFalse(adIt.hasNext());
- Iterator<Character> notaIt = nota.iterator();
+ final Iterator<Character> notaIt = nota.iterator();
assertNotNull(notaIt);
assertTrue(notaIt.hasNext());
while (notaIt.hasNext()) {
- Character c = notaIt.next();
+ final Character c = notaIt.next();
assertFalse('a' == c.charValue());
}
- Iterator<Character> emptySetIt = emptySet.iterator();
+ final Iterator<Character> emptySetIt = emptySet.iterator();
assertNotNull(emptySetIt);
assertFalse(emptySetIt.hasNext());
try {
emptySetIt.next();
fail("Should throw NoSuchElementException");
- } catch (NoSuchElementException e) {
+ } catch (final NoSuchElementException e) {
assertTrue(true);
}
- Iterator<Character> notFirstIt = notFirst.iterator();
+ final Iterator<Character> notFirstIt = notFirst.iterator();
assertNotNull(notFirstIt);
assertTrue(notFirstIt.hasNext());
assertEquals(Character.valueOf((char) 0), notFirstIt.next());
@@ -370,11 +371,11 @@ public class CharRangeTest {
try {
notFirstIt.next();
fail("Should throw NoSuchElementException");
- } catch (NoSuchElementException e) {
+ } catch (final NoSuchElementException e) {
assertTrue(true);
}
- Iterator<Character> notLastIt = notLast.iterator();
+ final Iterator<Character> notLastIt = notLast.iterator();
assertNotNull(notLastIt);
assertTrue(notLastIt.hasNext());
assertEquals(Character.valueOf(Character.MAX_VALUE), notLastIt.next());
@@ -382,7 +383,7 @@ public class CharRangeTest {
try {
notLastIt.next();
fail("Should throw NoSuchElementException");
- } catch (NoSuchElementException e) {
+ } catch (final NoSuchElementException e) {
assertTrue(true);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
index 875b69ccb..e68c4068f 100644
--- a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
@@ -39,7 +39,7 @@ public class CharSequenceUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new CharSequenceUtils());
- Constructor<?>[] cons = CharSequenceUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = CharSequenceUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(CharSequenceUtils.class.getModifiers()));
@@ -69,13 +69,13 @@ public class CharSequenceUtilsTest {
try {
Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, -1));
Assert.fail("Expected " + IndexOutOfBoundsException.class.getName());
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// Expected
}
try {
Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, 1));
Assert.fail("Expected " + IndexOutOfBoundsException.class.getName());
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// Expected
}
}
diff --git a/src/test/java/org/apache/commons/lang3/CharSetTest.java b/src/test/java/org/apache/commons/lang3/CharSetTest.java
index 17100073a..014d7b765 100644
--- a/src/test/java/org/apache/commons/lang3/CharSetTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharSetTest.java
@@ -343,12 +343,12 @@ public class CharSetTest {
//-----------------------------------------------------------------------
@Test
public void testEquals_Object() {
- CharSet abc = CharSet.getInstance("abc");
- CharSet abc2 = CharSet.getInstance("abc");
- CharSet atoc = CharSet.getInstance("a-c");
- CharSet atoc2 = CharSet.getInstance("a-c");
- CharSet notatoc = CharSet.getInstance("^a-c");
- CharSet notatoc2 = CharSet.getInstance("^a-c");
+ final CharSet abc = CharSet.getInstance("abc");
+ final CharSet abc2 = CharSet.getInstance("abc");
+ final CharSet atoc = CharSet.getInstance("a-c");
+ final CharSet atoc2 = CharSet.getInstance("a-c");
+ final CharSet notatoc = CharSet.getInstance("^a-c");
+ final CharSet notatoc2 = CharSet.getInstance("^a-c");
assertFalse(abc.equals(null));
@@ -370,12 +370,12 @@ public class CharSetTest {
@Test
public void testHashCode() {
- CharSet abc = CharSet.getInstance("abc");
- CharSet abc2 = CharSet.getInstance("abc");
- CharSet atoc = CharSet.getInstance("a-c");
- CharSet atoc2 = CharSet.getInstance("a-c");
- CharSet notatoc = CharSet.getInstance("^a-c");
- CharSet notatoc2 = CharSet.getInstance("^a-c");
+ final CharSet abc = CharSet.getInstance("abc");
+ final CharSet abc2 = CharSet.getInstance("abc");
+ final CharSet atoc = CharSet.getInstance("a-c");
+ final CharSet atoc2 = CharSet.getInstance("a-c");
+ final CharSet notatoc = CharSet.getInstance("^a-c");
+ final CharSet notatoc2 = CharSet.getInstance("^a-c");
assertEquals(abc.hashCode(), abc.hashCode());
assertEquals(abc.hashCode(), abc2.hashCode());
@@ -388,11 +388,11 @@ public class CharSetTest {
//-----------------------------------------------------------------------
@Test
public void testContains_Char() {
- CharSet btod = CharSet.getInstance("b-d");
- CharSet dtob = CharSet.getInstance("d-b");
- CharSet bcd = CharSet.getInstance("bcd");
- CharSet bd = CharSet.getInstance("bd");
- CharSet notbtod = CharSet.getInstance("^b-d");
+ final CharSet btod = CharSet.getInstance("b-d");
+ final CharSet dtob = CharSet.getInstance("d-b");
+ final CharSet bcd = CharSet.getInstance("bcd");
+ final CharSet bd = CharSet.getInstance("bd");
+ final CharSet notbtod = CharSet.getInstance("^b-d");
assertFalse(btod.contains('a'));
assertTrue(btod.contains('b'));
@@ -424,7 +424,7 @@ public class CharSetTest {
assertTrue(dtob.contains('d'));
assertFalse(dtob.contains('e'));
- CharRange[] array = dtob.getCharRanges();
+ final CharRange[] array = dtob.getCharRanges();
assertEquals("[b-d]", dtob.toString());
assertEquals(1, array.length);
}
diff --git a/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java
index 1faefd93c..d342a6505 100644
--- a/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java
@@ -37,7 +37,7 @@ public class CharSetUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new CharSetUtils());
- Constructor<?>[] cons = CharSetUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = CharSetUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(CharSetUtils.class.getModifiers()));
diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java b/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java
index fc5553ad8..d6b54d992 100644
--- a/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java
+++ b/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java
@@ -125,8 +125,8 @@ public class CharUtilsPerfRun {
private int run_CharSet(final int loopCount) {
int t = 0;
for (int i = 0; i < loopCount; i++) {
- for (char ch : CHAR_SAMPLES) {
- boolean b = CharSet.ASCII_NUMERIC.contains(ch);
+ for (final char ch : CHAR_SAMPLES) {
+ final boolean b = CharSet.ASCII_NUMERIC.contains(ch);
t += b ? 1 : 0;
}
}
@@ -136,8 +136,8 @@ public class CharUtilsPerfRun {
private int run_CharUtils_isAsciiNumeric(final int loopCount) {
int t = 0;
for (int i = 0; i < loopCount; i++) {
- for (char ch : CHAR_SAMPLES) {
- boolean b = CharUtils.isAsciiNumeric(ch);
+ for (final char ch : CHAR_SAMPLES) {
+ final boolean b = CharUtils.isAsciiNumeric(ch);
t += b ? 1 : 0;
}
}
@@ -147,8 +147,8 @@ public class CharUtilsPerfRun {
private int run_inlined_CharUtils_isAsciiNumeric(final int loopCount) {
int t = 0;
for (int i = 0; i < loopCount; i++) {
- for (char ch : CHAR_SAMPLES) {
- boolean b = ch >= '0' && ch <= '9';
+ for (final char ch : CHAR_SAMPLES) {
+ final boolean b = ch >= '0' && ch <= '9';
t += b ? 1 : 0;
}
}
@@ -156,7 +156,7 @@ public class CharUtilsPerfRun {
}
private void printlnTotal(final String prefix, final long start) {
- long total = System.currentTimeMillis() - start;
+ final long total = System.currentTimeMillis() - start;
System.out.println(prefix + ": " + NumberFormat.getInstance().format(total) + " milliseconds.");
}
}
diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java
index 40ec5fc93..b2adcb36d 100644
--- a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java
@@ -41,7 +41,7 @@ public class CharUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new CharUtils());
- Constructor<?>[] cons = CharUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = CharUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers()));
@@ -55,14 +55,14 @@ public class CharUtilsTest {
assertSame(CharUtils.toCharacterObject('a'), CharUtils.toCharacterObject('a'));
for (int i = 0; i < 128; i++) {
- Character ch = CharUtils.toCharacterObject((char) i);
- Character ch2 = CharUtils.toCharacterObject((char) i);
+ final Character ch = CharUtils.toCharacterObject((char) i);
+ final Character ch2 = CharUtils.toCharacterObject((char) i);
assertSame(ch, ch2);
assertEquals(i, ch.charValue());
}
for (int i = 128; i < 196; i++) {
- Character ch = CharUtils.toCharacterObject((char) i);
- Character ch2 = CharUtils.toCharacterObject((char) i);
+ final Character ch = CharUtils.toCharacterObject((char) i);
+ final Character ch2 = CharUtils.toCharacterObject((char) i);
assertEquals(ch, ch2);
assertTrue(ch != ch2);
assertEquals(i, ch.charValue());
@@ -86,7 +86,7 @@ public class CharUtilsTest {
assertEquals('B', CharUtils.toChar(CHARACTER_B));
try {
CharUtils.toChar((Character) null);
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
@Test
@@ -102,10 +102,10 @@ public class CharUtilsTest {
assertEquals('B', CharUtils.toChar("BA"));
try {
CharUtils.toChar((String) null);
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
CharUtils.toChar("");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
@Test
@@ -130,7 +130,7 @@ public class CharUtilsTest {
assertEquals(9, CharUtils.toIntValue('9'));
try {
CharUtils.toIntValue('a');
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
@Test
@@ -146,10 +146,10 @@ public class CharUtilsTest {
assertEquals(3, CharUtils.toIntValue(new Character('3')));
try {
CharUtils.toIntValue(null);
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
CharUtils.toIntValue(CHARACTER_A);
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
@Test
@@ -166,15 +166,15 @@ public class CharUtilsTest {
assertSame(CharUtils.toString('a'), CharUtils.toString('a'));
for (int i = 0; i < 128; i++) {
- String str = CharUtils.toString((char) i);
- String str2 = CharUtils.toString((char) i);
+ final String str = CharUtils.toString((char) i);
+ final String str2 = CharUtils.toString((char) i);
assertSame(str, str2);
assertEquals(1, str.length());
assertEquals(i, str.charAt(0));
}
for (int i = 128; i < 196; i++) {
- String str = CharUtils.toString((char) i);
- String str2 = CharUtils.toString((char) i);
+ final String str = CharUtils.toString((char) i);
+ final String str2 = CharUtils.toString((char) i);
assertEquals(str, str2);
assertTrue(str != str2);
assertEquals(1, str.length());
@@ -196,9 +196,9 @@ public class CharUtilsTest {
assertEquals("\\u0041", CharUtils.unicodeEscaped('A'));
for (int i = 0; i < 196; i++) {
- String str = CharUtils.unicodeEscaped((char) i);
+ final String str = CharUtils.unicodeEscaped((char) i);
assertEquals(6, str.length());
- int val = Integer.parseInt(str.substring(2), 16);
+ final int val = Integer.parseInt(str.substring(2), 16);
assertEquals(i, val);
}
assertEquals("\\u0999", CharUtils.unicodeEscaped((char) 0x999));
diff --git a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
index 057e57d61..ce6752cdb 100644
--- a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
@@ -56,7 +56,7 @@ public class ClassUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new ClassUtils());
- Constructor<?>[] cons = ClassUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = ClassUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ClassUtils.class.getModifiers()));
@@ -228,7 +228,7 @@ public class ClassUtilsTest {
// -------------------------------------------------------------------------
@Test
public void test_getAllSuperclasses_Class() {
- List<?> list = ClassUtils.getAllSuperclasses(CY.class);
+ final List<?> list = ClassUtils.getAllSuperclasses(CY.class);
assertEquals(2, list.size());
assertEquals(CX.class, list.get(0));
assertEquals(Object.class, list.get(1));
@@ -238,7 +238,7 @@ public class ClassUtilsTest {
@Test
public void test_getAllInterfaces_Class() {
- List<?> list = ClassUtils.getAllInterfaces(CY.class);
+ final List<?> list = ClassUtils.getAllInterfaces(CY.class);
assertEquals(6, list.size());
assertEquals(IB.class, list.get(0));
assertEquals(IC.class, list.get(1));
@@ -270,7 +270,7 @@ public class ClassUtilsTest {
// -------------------------------------------------------------------------
@Test
public void test_convertClassNamesToClasses_List() {
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
List<Class<?>> result = ClassUtils.convertClassNamesToClasses(list);
assertEquals(0, result.size());
@@ -284,18 +284,19 @@ public class ClassUtilsTest {
assertEquals(Object.class, result.get(2));
@SuppressWarnings("unchecked") // test what happens when non-generic code adds wrong type of element
+ final
List<Object> olist = (List<Object>)(List<?>)list;
olist.add(new Object());
try {
ClassUtils.convertClassNamesToClasses(list);
fail("Should not have been able to convert list");
- } catch (ClassCastException expected) {}
+ } catch (final ClassCastException expected) {}
assertEquals(null, ClassUtils.convertClassNamesToClasses(null));
}
@Test
public void test_convertClassesToClassNames_List() {
- List<Class<?>> list = new ArrayList<Class<?>>();
+ final List<Class<?>> list = new ArrayList<Class<?>>();
List<String> result = ClassUtils.convertClassesToClassNames(list);
assertEquals(0, result.size());
@@ -309,12 +310,13 @@ public class ClassUtilsTest {
assertEquals("java.lang.Object", result.get(2));
@SuppressWarnings("unchecked") // test what happens when non-generic code adds wrong type of element
+ final
List<Object> olist = (List<Object>)(List<?>)list;
olist.add(new Object());
try {
ClassUtils.convertClassesToClassNames(list);
fail("Should not have been able to convert list");
- } catch (ClassCastException expected) {}
+ } catch (final ClassCastException expected) {}
assertEquals(null, ClassUtils.convertClassesToClassNames(null));
}
@@ -333,12 +335,12 @@ public class ClassUtilsTest {
// -------------------------------------------------------------------------
@Test
public void test_isAssignable_ClassArray_ClassArray() throws Exception {
- Class<?>[] array2 = new Class[] {Object.class, Object.class};
- Class<?>[] array1 = new Class[] {Object.class};
- Class<?>[] array1s = new Class[] {String.class};
- Class<?>[] array0 = new Class[] {};
- Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
- Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
+ final Class<?>[] array2 = new Class[] {Object.class, Object.class};
+ final Class<?>[] array1 = new Class[] {Object.class};
+ final Class<?>[] array1s = new Class[] {String.class};
+ final Class<?>[] array0 = new Class[] {};
+ final Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
+ final Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
assertFalse(ClassUtils.isAssignable(array1, array2));
assertFalse(ClassUtils.isAssignable(null, array2));
@@ -352,7 +354,7 @@ public class ClassUtilsTest {
assertTrue(ClassUtils.isAssignable(array1s, array1s));
assertTrue(ClassUtils.isAssignable(array1s, array1));
- boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
+ final boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
assertEquals(autoboxing, ClassUtils.isAssignable(arrayPrimitives, arrayWrappers));
assertEquals(autoboxing, ClassUtils.isAssignable(arrayWrappers, arrayPrimitives));
@@ -364,12 +366,12 @@ public class ClassUtilsTest {
@Test
public void test_isAssignable_ClassArray_ClassArray_Autoboxing() throws Exception {
- Class<?>[] array2 = new Class[] {Object.class, Object.class};
- Class<?>[] array1 = new Class[] {Object.class};
- Class<?>[] array1s = new Class[] {String.class};
- Class<?>[] array0 = new Class[] {};
- Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
- Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
+ final Class<?>[] array2 = new Class[] {Object.class, Object.class};
+ final Class<?>[] array1 = new Class[] {Object.class};
+ final Class<?>[] array1s = new Class[] {String.class};
+ final Class<?>[] array0 = new Class[] {};
+ final Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
+ final Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
assertFalse(ClassUtils.isAssignable(array1, array2, true));
assertFalse(ClassUtils.isAssignable(null, array2, true));
@@ -392,12 +394,12 @@ public class ClassUtilsTest {
@Test
public void test_isAssignable_ClassArray_ClassArray_NoAutoboxing() throws Exception {
- Class<?>[] array2 = new Class[] {Object.class, Object.class};
- Class<?>[] array1 = new Class[] {Object.class};
- Class<?>[] array1s = new Class[] {String.class};
- Class<?>[] array0 = new Class[] {};
- Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
- Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
+ final Class<?>[] array2 = new Class[] {Object.class, Object.class};
+ final Class<?>[] array1 = new Class[] {Object.class};
+ final Class<?>[] array1s = new Class[] {String.class};
+ final Class<?>[] array0 = new Class[] {};
+ final Class<?>[] arrayPrimitives = { Integer.TYPE, Boolean.TYPE };
+ final Class<?>[] arrayWrappers = { Integer.class, Boolean.class };
assertFalse(ClassUtils.isAssignable(array1, array2, false));
assertFalse(ClassUtils.isAssignable(null, array2, false));
@@ -430,7 +432,7 @@ public class ClassUtilsTest {
assertTrue(ClassUtils.isAssignable(String.class, String.class));
assertFalse(ClassUtils.isAssignable(Object.class, String.class));
- boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
+ final boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
assertEquals(autoboxing, ClassUtils.isAssignable(Integer.TYPE, Integer.class));
assertEquals(autoboxing, ClassUtils.isAssignable(Integer.TYPE, Object.class));
@@ -579,7 +581,7 @@ public class ClassUtilsTest {
@Test
public void test_isAssignable_DefaultUnboxing_Widening() throws Exception {
- boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
+ final boolean autoboxing = SystemUtils.isJavaVersionAtLeast(JAVA_1_5);
// test byte conversions
assertFalse("byte -> char", ClassUtils.isAssignable(Byte.class, Character.TYPE));
@@ -849,7 +851,7 @@ public class ClassUtilsTest {
assertNull("null -> null", ClassUtils.primitivesToWrappers((Class<?>[]) null)); // equivalent cast to avoid warning
// Other possible casts for null
assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.primitivesToWrappers()));
- Class<?>[] castNull = ClassUtils.primitivesToWrappers((Class<?>)null); // == new Class<?>[]{null}
+ final Class<?>[] castNull = ClassUtils.primitivesToWrappers((Class<?>)null); // == new Class<?>[]{null}
assertTrue("(Class<?>)null -> [null]", Arrays.equals(new Class<?>[]{null}, castNull));
// test empty array is returned unchanged
// TODO this is not documented
@@ -862,12 +864,12 @@ public class ClassUtilsTest {
Integer.TYPE, Long.TYPE, Double.TYPE, Float.TYPE,
String.class, ClassUtils.class
};
- Class<?>[] wrappers= ClassUtils.primitivesToWrappers(primitives);
+ final Class<?>[] wrappers= ClassUtils.primitivesToWrappers(primitives);
for (int i=0; i < primitives.length; i++) {
// test each returned wrapper
- Class<?> primitive = primitives[i];
- Class<?> expectedWrapper = ClassUtils.primitiveToWrapper(primitive);
+ final Class<?> primitive = primitives[i];
+ final Class<?> expectedWrapper = ClassUtils.primitiveToWrapper(primitive);
assertEquals(primitive + " -> " + expectedWrapper, expectedWrapper, wrappers[i]);
}
@@ -887,8 +889,8 @@ public class ClassUtilsTest {
Boolean.TYPE, Byte.TYPE, Character.TYPE, Short.TYPE,
Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE
};
- for (Class<?> primitive : primitives) {
- Class<?> wrapperCls = ClassUtils.primitiveToWrapper(primitive);
+ for (final Class<?> primitive : primitives) {
+ final Class<?> wrapperCls = ClassUtils.primitiveToWrapper(primitive);
assertFalse("Still primitive", wrapperCls.isPrimitive());
assertEquals(wrapperCls + " -> " + primitive, primitive,
ClassUtils.wrapperToPrimitive(wrapperCls));
@@ -914,11 +916,11 @@ public class ClassUtilsTest {
String.class, ClassUtils.class, null
};
- Class<?>[] primitives = ClassUtils.wrappersToPrimitives(classes);
+ final Class<?>[] primitives = ClassUtils.wrappersToPrimitives(classes);
// now test the result
assertEquals("Wrong length of result array", classes.length, primitives.length);
for (int i = 0; i < classes.length; i++) {
- Class<?> expectedPrimitive = ClassUtils.wrapperToPrimitive(classes[i]);
+ final Class<?> expectedPrimitive = ClassUtils.wrapperToPrimitive(classes[i]);
assertEquals(classes[i] + " -> " + expectedPrimitive, expectedPrimitive,
primitives[i]);
}
@@ -930,13 +932,13 @@ public class ClassUtilsTest {
assertNull("Wrong result for null input", ClassUtils.wrappersToPrimitives((Class<?>[]) null)); // equivalent cast
// Other possible casts for null
assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.wrappersToPrimitives()));
- Class<?>[] castNull = ClassUtils.wrappersToPrimitives((Class<?>)null); // == new Class<?>[]{null}
+ final Class<?>[] castNull = ClassUtils.wrappersToPrimitives((Class<?>)null); // == new Class<?>[]{null}
assertTrue("(Class<?>)null -> [null]", Arrays.equals(new Class<?>[]{null}, castNull));
}
@Test
public void testWrappersToPrimitivesEmpty() {
- Class<?>[] empty = new Class[0];
+ final Class<?>[] empty = new Class[0];
assertArrayEquals("Wrong result for empty input", empty, ClassUtils.wrappersToPrimitives(empty));
}
@@ -1051,7 +1053,7 @@ public class ClassUtilsTest {
ClassUtils.getClass( className );
fail( "ClassUtils.getClass() should fail with an exception of type " + exceptionType.getName() + " when given class name \"" + className + "\"." );
}
- catch( Exception e ) {
+ catch( final Exception e ) {
assertTrue( exceptionType.isAssignableFrom( e.getClass() ) );
}
}
@@ -1069,12 +1071,12 @@ public class ClassUtilsTest {
@Test
public void testShowJavaBug() throws Exception {
// Tests with Collections$UnmodifiableSet
- Set<?> set = Collections.unmodifiableSet(new HashSet<Object>());
- Method isEmptyMethod = set.getClass().getMethod("isEmpty", new Class[0]);
+ final Set<?> set = Collections.unmodifiableSet(new HashSet<Object>());
+ final Method isEmptyMethod = set.getClass().getMethod("isEmpty", new Class[0]);
try {
isEmptyMethod.invoke(set, new Object[0]);
fail("Failed to throw IllegalAccessException as expected");
- } catch(IllegalAccessException iae) {
+ } catch(final IllegalAccessException iae) {
// expected
}
}
@@ -1082,18 +1084,18 @@ public class ClassUtilsTest {
@Test
public void testGetPublicMethod() throws Exception {
// Tests with Collections$UnmodifiableSet
- Set<?> set = Collections.unmodifiableSet(new HashSet<Object>());
- Method isEmptyMethod = ClassUtils.getPublicMethod(set.getClass(), "isEmpty", new Class[0]);
+ final Set<?> set = Collections.unmodifiableSet(new HashSet<Object>());
+ final Method isEmptyMethod = ClassUtils.getPublicMethod(set.getClass(), "isEmpty", new Class[0]);
assertTrue(Modifier.isPublic(isEmptyMethod.getDeclaringClass().getModifiers()));
try {
isEmptyMethod.invoke(set, new Object[0]);
- } catch(java.lang.IllegalAccessException iae) {
+ } catch(final java.lang.IllegalAccessException iae) {
fail("Should not have thrown IllegalAccessException");
}
// Tests with a public Class
- Method toStringMethod = ClassUtils.getPublicMethod(Object.class, "toString", new Class[0]);
+ final Method toStringMethod = ClassUtils.getPublicMethod(Object.class, "toString", new Class[0]);
assertEquals(Object.class.getMethod("toString", new Class[0]), toStringMethod);
}
@@ -1104,7 +1106,7 @@ public class ClassUtilsTest {
// Additional varargs tests
assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass()));
- Class<?>[] castNull = ClassUtils.toClass((Object) null); // == new Object[]{null}
+ final Class<?>[] castNull = ClassUtils.toClass((Object) null); // == new Object[]{null}
assertTrue("(Object)null -> [null]", Arrays.equals(new Object[]{null}, castNull));
assertSame(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass(ArrayUtils.EMPTY_OBJECT_ARRAY));
diff --git a/src/test/java/org/apache/commons/lang3/ConversionTest.java b/src/test/java/org/apache/commons/lang3/ConversionTest.java
index f96a0d897..4cf34d42e 100644
--- a/src/test/java/org/apache/commons/lang3/ConversionTest.java
+++ b/src/test/java/org/apache/commons/lang3/ConversionTest.java
@@ -256,11 +256,11 @@ public class ConversionTest {
*/
@Test
public void testBinaryToHexDigit_2args() {
- boolean[] shortArray = new boolean[]{false, true, true};
+ final boolean[] shortArray = new boolean[]{false, true, true};
assertEquals('6', Conversion.binaryToHexDigit(shortArray, 0));
assertEquals('3', Conversion.binaryToHexDigit(shortArray, 1));
assertEquals('1', Conversion.binaryToHexDigit(shortArray, 2));
- boolean[] longArray = new boolean[]{true, false, true, false, false, true, true};
+ final boolean[] longArray = new boolean[]{true, false, true, false, false, true, true};
assertEquals('5', Conversion.binaryToHexDigit(longArray, 0));
assertEquals('2', Conversion.binaryToHexDigit(longArray, 1));
assertEquals('9', Conversion.binaryToHexDigit(longArray, 2));
@@ -329,9 +329,9 @@ public class ConversionTest {
// assertEquals('6', Conversion.BinaryToHexDigitMsb0(shortArray,0));
// assertEquals('3', Conversion.BinaryToHexDigitMsb0(shortArray,1));
// assertEquals('1', Conversion.BinaryToHexDigitMsb0(shortArray,2));
- boolean[] shortArray = new boolean[]{true, true, false, true};
+ final boolean[] shortArray = new boolean[]{true, true, false, true};
assertEquals('d', Conversion.binaryToHexDigitMsb0_4bits(shortArray, 0));
- boolean[] longArray = new boolean[]{true, false, true, false, false, true, true};
+ final boolean[] longArray = new boolean[]{true, false, true, false, false, true, true};
assertEquals('a', Conversion.binaryToHexDigitMsb0_4bits(longArray, 0));
assertEquals('4', Conversion.binaryToHexDigitMsb0_4bits(longArray, 1));
assertEquals('9', Conversion.binaryToHexDigitMsb0_4bits(longArray, 2));
@@ -339,7 +339,7 @@ public class ConversionTest {
// assertEquals('6', Conversion.BinaryToHexDigitMsb0(longArray,4));
// assertEquals('3', Conversion.BinaryToHexDigitMsb0(longArray,5));
// assertEquals('1', Conversion.BinaryToHexDigitMsb0(longArray,6));
- boolean[] maxLengthArray = new boolean[]{
+ final boolean[] maxLengthArray = new boolean[]{
true, false, true, false, false, true, true, true};
assertEquals('a', Conversion.binaryToHexDigitMsb0_4bits(maxLengthArray, 0));
assertEquals('4', Conversion.binaryToHexDigitMsb0_4bits(maxLengthArray, 1));
@@ -349,7 +349,7 @@ public class ConversionTest {
// assertEquals('7', Conversion.BinaryToHexDigitMsb0(longArray,5));
// assertEquals('3', Conversion.BinaryToHexDigitMsb0(longArray,6));
// assertEquals('1', Conversion.BinaryToHexDigitMsb0(longArray,7));
- boolean[] javaDocCheck = new boolean[]{
+ final boolean[] javaDocCheck = new boolean[]{
true, false, false, true, true, false, true, false};
assertEquals('d', Conversion.binaryToHexDigitMsb0_4bits(javaDocCheck, 3));
@@ -416,11 +416,11 @@ public class ConversionTest {
true, false, false, false, false, false, false, false, false, false, false,
true, false, true, false, false}, 2));
- boolean[] shortArray = new boolean[]{true, true, false};
+ final boolean[] shortArray = new boolean[]{true, true, false};
assertEquals('6', Conversion.binaryBeMsb0ToHexDigit(shortArray, 0));
assertEquals('3', Conversion.binaryBeMsb0ToHexDigit(shortArray, 1));
assertEquals('1', Conversion.binaryBeMsb0ToHexDigit(shortArray, 2));
- boolean[] shortArray2 = new boolean[]{true, true, true, false, false, true, false, true};
+ final boolean[] shortArray2 = new boolean[]{true, true, true, false, false, true, false, true};
assertEquals('5', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 0));
assertEquals('2', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 1));
assertEquals('9', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 2));
@@ -429,7 +429,7 @@ public class ConversionTest {
assertEquals('7', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 5));
assertEquals('3', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 6));
assertEquals('1', Conversion.binaryBeMsb0ToHexDigit(shortArray2, 7));
- boolean[] multiBytesArray = new boolean[]{
+ final boolean[] multiBytesArray = new boolean[]{
true, true, false, false, true, false, true, false, true, true, true, false, false,
true, false, true};
assertEquals('5', Conversion.binaryBeMsb0ToHexDigit(multiBytesArray, 0));
@@ -511,15 +511,15 @@ public class ConversionTest {
}
static String dbgPrint(final boolean[] src) {
- StringBuilder sb = new StringBuilder();
- for (boolean e : src) {
+ final StringBuilder sb = new StringBuilder();
+ for (final boolean e : src) {
if (e) {
sb.append("1,");
} else {
sb.append("0,");
}
}
- String out = sb.toString();
+ final String out = sb.toString();
return out.substring(0, out.length() - 1);
}
@@ -529,8 +529,8 @@ public class ConversionTest {
for (int i = 0; i < expected.length; i++ ) {
try {
assertEquals(expected[i], actual[i]);
- } catch (Throwable e) {
- String msg = "Mismatch at index "
+ } catch (final Throwable e) {
+ final String msg = "Mismatch at index "
+ i
+ " between:\n"
+ dbgPrint(expected)
@@ -546,7 +546,7 @@ public class ConversionTest {
*/
@Test
public void testIntArrayToLong() {
- int[] src = new int[]{0xCDF1F0C1, 0x0F123456, 0x78000000};
+ final int[] src = new int[]{0xCDF1F0C1, 0x0F123456, 0x78000000};
assertEquals(0x0000000000000000L, Conversion.intArrayToLong(src, 0, 0L, 0, 0));
assertEquals(0x0000000000000000L, Conversion.intArrayToLong(src, 1, 0L, 0, 0));
assertEquals(0x00000000CDF1F0C1L, Conversion.intArrayToLong(src, 0, 0L, 0, 1));
@@ -564,7 +564,7 @@ public class ConversionTest {
*/
@Test
public void testShortArrayToLong() {
- short[] src = new short[]{
+ final short[] src = new short[]{
(short)0xCDF1, (short)0xF0C1, (short)0x0F12, (short)0x3456, (short)0x7800};
assertEquals(0x0000000000000000L, Conversion.shortArrayToLong(src, 0, 0L, 0, 0));
assertEquals(0x000000000000CDF1L, Conversion.shortArrayToLong(src, 0, 0L, 0, 1));
@@ -585,7 +585,7 @@ public class ConversionTest {
*/
@Test
public void testByteArrayToLong() {
- byte[] src = new byte[]{
+ final byte[] src = new byte[]{
(byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34,
(byte)0x56, (byte)0x78};
assertEquals(0x0000000000000000L, Conversion.byteArrayToLong(src, 0, 0L, 0, 0));
@@ -605,7 +605,7 @@ public class ConversionTest {
*/
@Test
public void testShortArrayToInt() {
- short[] src = new short[]{
+ final short[] src = new short[]{
(short)0xCDF1, (short)0xF0C1, (short)0x0F12, (short)0x3456, (short)0x7800};
assertEquals(0x00000000, Conversion.shortArrayToInt(src, 0, 0, 0, 0));
assertEquals(0x0000CDF1, Conversion.shortArrayToInt(src, 0, 0, 0, 1));
@@ -621,7 +621,7 @@ public class ConversionTest {
*/
@Test
public void testByteArrayToInt() {
- byte[] src = new byte[]{
+ final byte[] src = new byte[]{
(byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34,
(byte)0x56, (byte)0x78};
assertEquals(0x00000000, Conversion.byteArrayToInt(src, 0, 0, 0, 0));
@@ -638,7 +638,7 @@ public class ConversionTest {
*/
@Test
public void testByteArrayToShort() {
- byte[] src = new byte[]{
+ final byte[] src = new byte[]{
(byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34,
(byte)0x56, (byte)0x78};
assertEquals((short)0x0000, Conversion.byteArrayToShort(src, 0, (short)0, 0, 0));
@@ -656,7 +656,7 @@ public class ConversionTest {
*/
@Test
public void testHexToLong() {
- String src = "CDF1F0C10F12345678";
+ final String src = "CDF1F0C10F12345678";
assertEquals(0x0000000000000000L, Conversion.hexToLong(src, 0, 0L, 0, 0));
assertEquals(0x000000000000000CL, Conversion.hexToLong(src, 0, 0L, 0, 1));
assertEquals(0x000000001C0F1FDCL, Conversion.hexToLong(src, 0, 0L, 0, 8));
@@ -672,7 +672,7 @@ public class ConversionTest {
*/
@Test
public void testHexToInt() {
- String src = "CDF1F0C10F12345678";
+ final String src = "CDF1F0C10F12345678";
assertEquals(0x00000000, Conversion.hexToInt(src, 0, 0, 0, 0));
assertEquals(0x0000000C, Conversion.hexToInt(src, 0, 0, 0, 1));
assertEquals(0x1C0F1FDC, Conversion.hexToInt(src, 0, 0, 0, 8));
@@ -686,7 +686,7 @@ public class ConversionTest {
*/
@Test
public void testHexToShort() {
- String src = "CDF1F0C10F12345678";
+ final String src = "CDF1F0C10F12345678";
assertEquals((short)0x0000, Conversion.hexToShort(src, 0, (short)0, 0, 0));
assertEquals((short)0x000C, Conversion.hexToShort(src, 0, (short)0, 0, 1));
assertEquals((short)0x1FDC, Conversion.hexToShort(src, 0, (short)0, 0, 4));
@@ -700,7 +700,7 @@ public class ConversionTest {
*/
@Test
public void testHexToByte() {
- String src = "CDF1F0C10F12345678";
+ final String src = "CDF1F0C10F12345678";
assertEquals((byte)0x00, Conversion.hexToByte(src, 0, (byte)0, 0, 0));
assertEquals((byte)0x0C, Conversion.hexToByte(src, 0, (byte)0, 0, 1));
assertEquals((byte)0xDC, Conversion.hexToByte(src, 0, (byte)0, 0, 2));
@@ -714,7 +714,7 @@ public class ConversionTest {
*/
@Test
public void testBinaryToLong() {
- boolean[] src = new boolean[]{
+ final boolean[] src = new boolean[]{
false, false, true, true, true, false, true, true, true, true, true, true, true,
false, false, false, true, true, true, true, false, false, false, false, false,
false, true, true, true, false, false, false, false, false, false, false, true,
@@ -738,7 +738,7 @@ public class ConversionTest {
*/
@Test
public void testBinaryToInt() {
- boolean[] src = new boolean[]{
+ final boolean[] src = new boolean[]{
false, false, true, true, true, false, true, true, true, true, true, true, true,
false, false, false, true, true, true, true, false, false, false, false, false,
false, true, true, true, false, false, false, false, false, false, false, true,
@@ -759,7 +759,7 @@ public class ConversionTest {
*/
@Test
public void testBinaryToShort() {
- boolean[] src = new boolean[]{
+ final boolean[] src = new boolean[]{
false, false, true, true, true, false, true, true, true, true, true, true, true,
false, false, false, true, true, true, true, false, false, false, false, false,
false, true, true, true, false, false, false, false, false, false, false, true,
@@ -782,7 +782,7 @@ public class ConversionTest {
*/
@Test
public void testBinaryToByte() {
- boolean[] src = new boolean[]{
+ final boolean[] src = new boolean[]{
false, false, true, true, true, false, true, true, true, true, true, true, true,
false, false, false, true, true, true, true, false, false, false, false, false,
false, true, true, true, false, false, false, false, false, false, false, true,
diff --git a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
index 4d97d49a6..92995e76e 100644
--- a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
@@ -45,7 +45,7 @@ public class EnumUtilsTest {
@Test
public void test_getEnumMap() {
- Map<String, Traffic> test = EnumUtils.getEnumMap(Traffic.class);
+ final Map<String, Traffic> test = EnumUtils.getEnumMap(Traffic.class);
assertEquals( "getEnumMap not created correctly", "{RED=RED, AMBER=AMBER, GREEN=GREEN}", test.toString());
assertEquals(3, test.size());
assertTrue(test.containsKey("RED"));
@@ -59,7 +59,7 @@ public class EnumUtilsTest {
@Test
public void test_getEnumList() {
- List<Traffic> test = EnumUtils.getEnumList(Traffic.class);
+ final List<Traffic> test = EnumUtils.getEnumList(Traffic.class);
assertEquals(3, test.size());
assertEquals(Traffic.RED, test.get(0));
assertEquals(Traffic.AMBER, test.get(1));
@@ -168,8 +168,10 @@ public class EnumUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void test_generateBitVector_nonEnumClass() {
@SuppressWarnings("rawtypes")
+ final
Class rawType = Object.class;
@SuppressWarnings("rawtypes")
+ final
List rawList = new ArrayList();
EnumUtils.generateBitVector(rawType, rawList);
}
@@ -178,8 +180,10 @@ public class EnumUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void test_generateBitVectors_nonEnumClass() {
@SuppressWarnings("rawtypes")
+ final
Class rawType = Object.class;
@SuppressWarnings("rawtypes")
+ final
List rawList = new ArrayList();
EnumUtils.generateBitVectors(rawType, rawList);
}
@@ -188,6 +192,7 @@ public class EnumUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void test_generateBitVector_nonEnumClassWithArray() {
@SuppressWarnings("rawtypes")
+ final
Class rawType = Object.class;
EnumUtils.generateBitVector(rawType);
}
@@ -196,6 +201,7 @@ public class EnumUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void test_generateBitVectors_nonEnumClassWithArray() {
@SuppressWarnings("rawtypes")
+ final
Class rawType = Object.class;
EnumUtils.generateBitVectors(rawType);
}
diff --git a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
index f12a41f07..eb3508940 100644
--- a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
+++ b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
@@ -49,8 +49,8 @@ public class HashSetvBitSetTest {
* @return bitSet - HashSet
*/
private long printTimes(final int count) {
- long hashSet = timeHashSet(count);
- long bitSet = timeBitSet(count);
+ final long hashSet = timeHashSet(count);
+ final long bitSet = timeBitSet(count);
// If percent is less than 100, then bitset is faster
System.out.println("Ratio="+(bitSet*100/hashSet)+"% count="+count+" hash="+hashSet+" bits="+bitSet);
return bitSet - hashSet;
@@ -58,29 +58,29 @@ public class HashSetvBitSetTest {
private static long timeHashSet(final int count) {
int [] result = new int[0];
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for (int i = 0; i < LOOPS; i++) {
result = testHashSet(count);
}
- long elapsed = System.nanoTime() - start;
+ final long elapsed = System.nanoTime() - start;
Assert.assertEquals(count, result.length);
return elapsed;
}
private static long timeBitSet(final int count) {
int [] result = new int[0];
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for (int i = 0; i < LOOPS; i++) {
result = testBitSet(count);
}
- long elapsed = System.nanoTime() - start;
+ final long elapsed = System.nanoTime() - start;
Assert.assertEquals(count, result.length);
return elapsed;
}
@SuppressWarnings("boxing")
private static int[] testHashSet(final int count) {
- HashSet<Integer> toRemove = new HashSet<Integer>();
+ final HashSet<Integer> toRemove = new HashSet<Integer>();
int found = 0;
for (int i = 0; i < count; i++) {
toRemove.add(found++);
@@ -89,7 +89,7 @@ public class HashSetvBitSetTest {
}
private static int[] testBitSet(final int count) {
- BitSet toRemove = new BitSet();
+ final BitSet toRemove = new BitSet();
int found = 0;
for (int i = 0; i < count; i++) {
toRemove.set(found++);
@@ -99,16 +99,16 @@ public class HashSetvBitSetTest {
private static int[] extractIndices(final HashSet<Integer> coll) {
- int[] result = new int[coll.size()];
+ final int[] result = new int[coll.size()];
int i = 0;
- for (Integer index : coll) {
+ for (final Integer index : coll) {
result[i++] = index.intValue();
}
return result;
}
private static int[] extractIndices(final BitSet coll) {
- int[] result = new int[coll.cardinality()];
+ final int[] result = new int[coll.cardinality()];
int i = 0;
int j=0;
while((j=coll.nextSetBit(j)) != -1) {
@@ -136,13 +136,13 @@ public class HashSetvBitSetTest {
}
private long printTimes(final int arraySize, final int bitSetSize) {
- int[] array = new int[arraySize];
- BitSet remove = new BitSet();
+ final int[] array = new int[arraySize];
+ final BitSet remove = new BitSet();
for (int i = 0; i < bitSetSize; i++) {
remove.set(i);
}
- long bitSet = timeBitSetRemoveAll(array, remove );
- long extract = timeExtractRemoveAll(array, remove);
+ final long bitSet = timeBitSetRemoveAll(array, remove );
+ final long extract = timeExtractRemoveAll(array, remove);
// If percent is less than 100, then direct use of bitset is faster
System.out.println("Ratio="+(bitSet*100/extract)+"% array="+array.length+" count="+remove.cardinality()+" extract="+extract+" bitset="+bitSet);
return bitSet - extract;
@@ -150,23 +150,23 @@ public class HashSetvBitSetTest {
private long timeBitSetRemoveAll(final int[] array, final BitSet toRemove) {
int[] output = new int[0];
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for(int i = 0; i < LOOPS2; i++){
output = (int[]) ArrayUtils.removeAll(array, toRemove);
}
- long end = System.nanoTime();
+ final long end = System.nanoTime();
Assert.assertEquals(array.length-toRemove.cardinality(), output.length);
return end - start;
}
private long timeExtractRemoveAll(final int[] array, final BitSet toRemove) {
int[] output = new int[0];
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for(int i = 0; i < LOOPS2; i++){
final int[] extractIndices = extractIndices(toRemove);
output = (int[]) ArrayUtils.removeAll((Object)array, extractIndices);
}
- long end = System.nanoTime();
+ final long end = System.nanoTime();
Assert.assertEquals(array.length-toRemove.cardinality(), output.length);
return end - start;
}
diff --git a/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java b/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
index 64dd3ead0..f2d47c59d 100644
--- a/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
@@ -67,7 +67,7 @@ public class LocaleUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new LocaleUtils());
- Constructor<?>[] cons = LocaleUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = LocaleUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(LocaleUtils.class.getModifiers()));
@@ -81,7 +81,7 @@ public class LocaleUtilsTest {
* @param language the language string
*/
private void assertValidToLocale(final String language) {
- Locale locale = LocaleUtils.toLocale(language);
+ final Locale locale = LocaleUtils.toLocale(language);
assertNotNull("valid locale", locale);
assertEquals(language, locale.getLanguage());
//country and variant are empty
@@ -97,7 +97,7 @@ public class LocaleUtilsTest {
* @param country of the resulting Locale
*/
private void assertValidToLocale(final String localeString, final String language, final String country) {
- Locale locale = LocaleUtils.toLocale(localeString);
+ final Locale locale = LocaleUtils.toLocale(localeString);
assertNotNull("valid locale", locale);
assertEquals(language, locale.getLanguage());
assertEquals(country, locale.getCountry());
@@ -116,7 +116,7 @@ public class LocaleUtilsTest {
private void assertValidToLocale(
final String localeString, final String language,
final String country, final String variant) {
- Locale locale = LocaleUtils.toLocale(localeString);
+ final Locale locale = LocaleUtils.toLocale(localeString);
assertNotNull("valid locale", locale);
assertEquals(language, locale.getLanguage());
assertEquals(country, locale.getCountry());
@@ -141,34 +141,34 @@ public class LocaleUtilsTest {
try {
LocaleUtils.toLocale("Us");
fail("Should fail if not lowercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("US");
fail("Should fail if not lowercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("uS");
fail("Should fail if not lowercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("u#");
fail("Should fail if not lowercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("u");
fail("Must be 2 chars if less than 5");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("uuu");
fail("Must be 2 chars if less than 5");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("uu_U");
fail("Must be 2 chars if less than 5");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
}
/**
@@ -183,27 +183,27 @@ public class LocaleUtilsTest {
try {
LocaleUtils.toLocale("us-EN");
fail("Should fail as not underscore");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("us_En");
fail("Should fail second part not uppercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("us_en");
fail("Should fail second part not uppercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("us_eN");
fail("Should fail second part not uppercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("uS_EN");
fail("Should fail first part not lowercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("us_E3");
fail("Should fail second part not uppercase");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
}
/**
@@ -225,11 +225,11 @@ public class LocaleUtilsTest {
try {
LocaleUtils.toLocale("us_EN-a");
fail("Should fail as not underscore");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
try {
LocaleUtils.toLocale("uu_UU_");
fail("Must be 3, 5 or 7+ in length");
- } catch (IllegalArgumentException iae) {}
+ } catch (final IllegalArgumentException iae) {}
}
//-----------------------------------------------------------------------
@@ -241,7 +241,7 @@ public class LocaleUtilsTest {
* @param expected expected results
*/
private void assertLocaleLookupList(final Locale locale, final Locale defaultLocale, final Locale[] expected) {
- List<Locale> localeList = defaultLocale == null ?
+ final List<Locale> localeList = defaultLocale == null ?
LocaleUtils.localeLookupList(locale) :
LocaleUtils.localeLookupList(locale, defaultLocale);
@@ -331,14 +331,14 @@ public class LocaleUtilsTest {
*/
@Test
public void testAvailableLocaleList() {
- List<Locale> list = LocaleUtils.availableLocaleList();
- List<Locale> list2 = LocaleUtils.availableLocaleList();
+ final List<Locale> list = LocaleUtils.availableLocaleList();
+ final List<Locale> list2 = LocaleUtils.availableLocaleList();
assertNotNull(list);
assertSame(list, list2);
assertUnmodifiableCollection(list);
- Locale[] jdkLocaleArray = Locale.getAvailableLocales();
- List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray);
+ final Locale[] jdkLocaleArray = Locale.getAvailableLocales();
+ final List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray);
assertEquals(jdkLocaleList, list);
}
@@ -348,15 +348,15 @@ public class LocaleUtilsTest {
*/
@Test
public void testAvailableLocaleSet() {
- Set<Locale> set = LocaleUtils.availableLocaleSet();
- Set<Locale> set2 = LocaleUtils.availableLocaleSet();
+ final Set<Locale> set = LocaleUtils.availableLocaleSet();
+ final Set<Locale> set2 = LocaleUtils.availableLocaleSet();
assertNotNull(set);
assertSame(set, set2);
assertUnmodifiableCollection(set);
- Locale[] jdkLocaleArray = Locale.getAvailableLocales();
- List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray);
- Set<Locale> jdkLocaleSet = new HashSet<Locale>(jdkLocaleList);
+ final Locale[] jdkLocaleArray = Locale.getAvailableLocales();
+ final List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray);
+ final Set<Locale> jdkLocaleSet = new HashSet<Locale>(jdkLocaleList);
assertEquals(jdkLocaleSet, set);
}
@@ -367,7 +367,7 @@ public class LocaleUtilsTest {
@SuppressWarnings("boxing") // JUnit4 does not support primitive equality testing apart from long
@Test
public void testIsAvailableLocale() {
- Set<Locale> set = LocaleUtils.availableLocaleSet();
+ final Set<Locale> set = LocaleUtils.availableLocaleSet();
assertEquals(set.contains(LOCALE_EN), LocaleUtils.isAvailableLocale(LOCALE_EN));
assertEquals(set.contains(LOCALE_EN_US), LocaleUtils.isAvailableLocale(LOCALE_EN_US));
assertEquals(set.contains(LOCALE_EN_US_ZZZZ), LocaleUtils.isAvailableLocale(LOCALE_EN_US_ZZZZ));
@@ -388,17 +388,17 @@ public class LocaleUtilsTest {
* @param languages array of languages that should be returned
*/
private void assertLanguageByCountry(final String country, final String[] languages) {
- List<Locale> list = LocaleUtils.languagesByCountry(country);
- List<Locale> list2 = LocaleUtils.languagesByCountry(country);
+ final List<Locale> list = LocaleUtils.languagesByCountry(country);
+ final List<Locale> list2 = LocaleUtils.languagesByCountry(country);
assertNotNull(list);
assertSame(list, list2);
//search through langauges
- for (String language : languages) {
- Iterator<Locale> iterator = list.iterator();
+ for (final String language : languages) {
+ final Iterator<Locale> iterator = list.iterator();
boolean found = false;
// see if it was returned by the set
while (iterator.hasNext()) {
- Locale locale = iterator.next();
+ final Locale locale = iterator.next();
// should have an en empty variant
assertTrue(locale.getVariant() == null
|| locale.getVariant().isEmpty());
@@ -439,17 +439,17 @@ public class LocaleUtilsTest {
* @param countries array of countries that should be returned
*/
private void assertCountriesByLanguage(final String language, final String[] countries) {
- List<Locale> list = LocaleUtils.countriesByLanguage(language);
- List<Locale> list2 = LocaleUtils.countriesByLanguage(language);
+ final List<Locale> list = LocaleUtils.countriesByLanguage(language);
+ final List<Locale> list2 = LocaleUtils.countriesByLanguage(language);
assertNotNull(list);
assertSame(list, list2);
//search through langauges
- for (String countrie : countries) {
- Iterator<Locale> iterator = list.iterator();
+ for (final String countrie : countries) {
+ final Iterator<Locale> iterator = list.iterator();
boolean found = false;
// see if it was returned by the set
while (iterator.hasNext()) {
- Locale locale = iterator.next();
+ final Locale locale = iterator.next();
// should have an en empty variant
assertTrue(locale.getVariant() == null
|| locale.getVariant().isEmpty());
@@ -485,7 +485,7 @@ public class LocaleUtilsTest {
try {
coll.add(null);
fail();
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
}
/**
diff --git a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
index bdd473a24..4809cc947 100644
--- a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
@@ -51,7 +51,7 @@ public class ObjectUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new ObjectUtils());
- Constructor<?>[] cons = ObjectUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = ObjectUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ObjectUtils.class.getModifiers()));
@@ -61,8 +61,8 @@ public class ObjectUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testIsNull() {
- Object o = FOO;
- Object dflt = BAR;
+ final Object o = FOO;
+ final Object dflt = BAR;
assertSame("dflt was not returned when o was null", dflt, ObjectUtils.defaultIfNull(null, dflt));
assertSame("dflt was returned when o was not null", o, ObjectUtils.defaultIfNull(o, dflt));
}
@@ -71,7 +71,7 @@ public class ObjectUtilsTest {
public void testFirstNonNull() {
assertEquals(null, ObjectUtils.firstNonNull(null, null));
assertEquals("", ObjectUtils.firstNonNull(null, ""));
- String firstNonNullGenerics = ObjectUtils.firstNonNull(null, null, "123", "456");
+ final String firstNonNullGenerics = ObjectUtils.firstNonNull(null, null, "123", "456");
assertEquals("123", firstNonNullGenerics);
assertEquals("123", ObjectUtils.firstNonNull("123", null, "456", null));
assertEquals(null, ObjectUtils.firstNonNull());
@@ -112,28 +112,28 @@ public class ObjectUtilsTest {
@Test
public void testHashCodeMulti_multiple_emptyArray() {
- Object[] array = new Object[0];
+ final Object[] array = new Object[0];
assertEquals(1, ObjectUtils.hashCodeMulti(array));
}
@Test
public void testHashCodeMulti_multiple_nullArray() {
- Object[] array = null;
+ final Object[] array = null;
assertEquals(1, ObjectUtils.hashCodeMulti(array));
}
@Test
public void testHashCodeMulti_multiple_likeList() {
- List<Object> list0 = new ArrayList<Object>(Arrays.asList());
+ final List<Object> list0 = new ArrayList<Object>(Arrays.asList());
assertEquals(list0.hashCode(), ObjectUtils.hashCodeMulti());
- List<Object> list1 = new ArrayList<Object>(Arrays.asList("a"));
+ final List<Object> list1 = new ArrayList<Object>(Arrays.asList("a"));
assertEquals(list1.hashCode(), ObjectUtils.hashCodeMulti("a"));
- List<Object> list2 = new ArrayList<Object>(Arrays.asList("a", "b"));
+ final List<Object> list2 = new ArrayList<Object>(Arrays.asList("a", "b"));
assertEquals(list2.hashCode(), ObjectUtils.hashCodeMulti("a", "b"));
- List<Object> list3 = new ArrayList<Object>(Arrays.asList("a", "b", "c"));
+ final List<Object> list3 = new ArrayList<Object>(Arrays.asList("a", "b", "c"));
assertEquals(list3.hashCode(), ObjectUtils.hashCodeMulti("a", "b", "c"));
}
@@ -184,22 +184,22 @@ public class ObjectUtilsTest {
assertEquals(
"java.lang.String@" + Integer.toHexString(System.identityHashCode(FOO)),
ObjectUtils.identityToString(FOO));
- Integer i = Integer.valueOf(90);
- String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i));
+ final Integer i = Integer.valueOf(90);
+ final String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i));
assertEquals(expected, ObjectUtils.identityToString(i));
- StringBuffer buffer = new StringBuffer();
+ final StringBuffer buffer = new StringBuffer();
ObjectUtils.identityToString(buffer, i);
assertEquals(expected, buffer.toString());
try {
ObjectUtils.identityToString(null, "tmp");
fail("NullPointerException expected");
- } catch(NullPointerException npe) {
+ } catch(final NullPointerException npe) {
}
try {
ObjectUtils.identityToString(new StringBuffer(), null);
fail("NullPointerException expected");
- } catch(NullPointerException npe) {
+ } catch(final NullPointerException npe) {
}
}
@@ -226,13 +226,13 @@ public class ObjectUtilsTest {
@Test
public void testMax() {
- Calendar calendar = Calendar.getInstance();
- Date nonNullComparable1 = calendar.getTime();
- Date nonNullComparable2 = calendar.getTime();
- String[] nullAray = null;
+ final Calendar calendar = Calendar.getInstance();
+ final Date nonNullComparable1 = calendar.getTime();
+ final Date nonNullComparable2 = calendar.getTime();
+ final String[] nullAray = null;
calendar.set( Calendar.YEAR, calendar.get( Calendar.YEAR ) -1 );
- Date minComparable = calendar.getTime();
+ final Date minComparable = calendar.getTime();
assertNotSame( nonNullComparable1, nonNullComparable2 );
@@ -252,13 +252,13 @@ public class ObjectUtilsTest {
@Test
public void testMin() {
- Calendar calendar = Calendar.getInstance();
- Date nonNullComparable1 = calendar.getTime();
- Date nonNullComparable2 = calendar.getTime();
- String[] nullAray = null;
+ final Calendar calendar = Calendar.getInstance();
+ final Date nonNullComparable1 = calendar.getTime();
+ final Date nonNullComparable2 = calendar.getTime();
+ final String[] nullAray = null;
calendar.set( Calendar.YEAR, calendar.get( Calendar.YEAR ) -1 );
- Date minComparable = calendar.getTime();
+ final Date minComparable = calendar.getTime();
assertNotSame( nonNullComparable1, nonNullComparable2 );
@@ -281,9 +281,9 @@ public class ObjectUtilsTest {
*/
@Test
public void testCompare() {
- Integer one = Integer.valueOf(1);
- Integer two = Integer.valueOf(2);
- Integer nullValue = null;
+ final Integer one = Integer.valueOf(1);
+ final Integer two = Integer.valueOf(2);
+ final Integer nullValue = null;
assertEquals("Null Null false", 0, ObjectUtils.compare(nullValue, nullValue));
assertEquals("Null Null true", 0, ObjectUtils.compare(nullValue, nullValue, true));
@@ -327,12 +327,12 @@ public class ObjectUtilsTest {
@Test
public void testComparatorMedian() {
- CharSequenceComparator cmp = new CharSequenceComparator();
- NonComparableCharSequence foo = new NonComparableCharSequence("foo");
- NonComparableCharSequence bar = new NonComparableCharSequence("bar");
- NonComparableCharSequence baz = new NonComparableCharSequence("baz");
- NonComparableCharSequence blah = new NonComparableCharSequence("blah");
- NonComparableCharSequence wah = new NonComparableCharSequence("wah");
+ final CharSequenceComparator cmp = new CharSequenceComparator();
+ final NonComparableCharSequence foo = new NonComparableCharSequence("foo");
+ final NonComparableCharSequence bar = new NonComparableCharSequence("bar");
+ final NonComparableCharSequence baz = new NonComparableCharSequence("baz");
+ final NonComparableCharSequence blah = new NonComparableCharSequence("blah");
+ final NonComparableCharSequence wah = new NonComparableCharSequence("wah");
assertSame(foo, ObjectUtils.median(cmp, foo));
assertSame(bar, ObjectUtils.median(cmp, foo, bar));
assertSame(baz, ObjectUtils.median(cmp, foo, bar, baz));
@@ -474,18 +474,18 @@ public class ObjectUtilsTest {
// for "Can you screw this up?" The answer is, yes,
// you can even screw this up. (When you == Julius)
// .
- boolean MAGIC_FLAG = ObjectUtils.CONST(true);
- byte MAGIC_BYTE1 = ObjectUtils.CONST((byte) 127);
- byte MAGIC_BYTE2 = ObjectUtils.CONST_BYTE(127);
- char MAGIC_CHAR = ObjectUtils.CONST('a');
- short MAGIC_SHORT1 = ObjectUtils.CONST((short) 123);
- short MAGIC_SHORT2 = ObjectUtils.CONST_SHORT(127);
- int MAGIC_INT = ObjectUtils.CONST(123);
- long MAGIC_LONG1 = ObjectUtils.CONST(123L);
- long MAGIC_LONG2 = ObjectUtils.CONST(3);
- float MAGIC_FLOAT = ObjectUtils.CONST(1.0f);
- double MAGIC_DOUBLE = ObjectUtils.CONST(1.0);
- String MAGIC_STRING = ObjectUtils.CONST("abc");
+ final boolean MAGIC_FLAG = ObjectUtils.CONST(true);
+ final byte MAGIC_BYTE1 = ObjectUtils.CONST((byte) 127);
+ final byte MAGIC_BYTE2 = ObjectUtils.CONST_BYTE(127);
+ final char MAGIC_CHAR = ObjectUtils.CONST('a');
+ final short MAGIC_SHORT1 = ObjectUtils.CONST((short) 123);
+ final short MAGIC_SHORT2 = ObjectUtils.CONST_SHORT(127);
+ final int MAGIC_INT = ObjectUtils.CONST(123);
+ final long MAGIC_LONG1 = ObjectUtils.CONST(123L);
+ final long MAGIC_LONG2 = ObjectUtils.CONST(3);
+ final float MAGIC_FLOAT = ObjectUtils.CONST(1.0f);
+ final double MAGIC_DOUBLE = ObjectUtils.CONST(1.0);
+ final String MAGIC_STRING = ObjectUtils.CONST("abc");
assertTrue(MAGIC_FLAG);
assertEquals(127, MAGIC_BYTE1);
@@ -503,25 +503,25 @@ public class ObjectUtilsTest {
try {
ObjectUtils.CONST_BYTE(-129);
fail("CONST_BYTE(-129): IllegalArgumentException should have been thrown.");
- } catch (IllegalArgumentException iae) {
+ } catch (final IllegalArgumentException iae) {
}
try {
ObjectUtils.CONST_BYTE(128);
fail("CONST_BYTE(128): IllegalArgumentException should have been thrown.");
- } catch (IllegalArgumentException iae) {
+ } catch (final IllegalArgumentException iae) {
}
try {
ObjectUtils.CONST_SHORT(-32769);
fail("CONST_SHORT(-32769): IllegalArgumentException should have been thrown.");
- } catch (IllegalArgumentException iae) {
+ } catch (final IllegalArgumentException iae) {
}
try {
ObjectUtils.CONST_BYTE(32768);
fail("CONST_SHORT(32768): IllegalArgumentException should have been thrown.");
- } catch (IllegalArgumentException iae) {
+ } catch (final IllegalArgumentException iae) {
}
diff --git a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java
index b00db29d9..420d7bb69 100644
--- a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java
@@ -39,7 +39,7 @@ public class RandomStringUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new RandomStringUtils());
- Constructor<?>[] cons = RandomStringUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = RandomStringUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(RandomStringUtils.class.getModifiers()));
@@ -120,7 +120,7 @@ public class RandomStringUtilsTest {
assertEquals("random(50) length", 50, r2.length());
assertTrue("!r1.equals(r2)", !r1.equals(r2));
- long seed = System.currentTimeMillis();
+ final long seed = System.currentTimeMillis();
r1 = RandomStringUtils.random(50,0,0,true,true,null,new Random(seed));
r2 = RandomStringUtils.random(50,0,0,true,true,null,new Random(seed));
assertEquals("r1.equals(r2)", r1, r2);
@@ -131,7 +131,7 @@ public class RandomStringUtilsTest {
@Test
public void testLANG805() {
- long seed = System.currentTimeMillis();
+ final long seed = System.currentTimeMillis();
assertEquals("aaa", RandomStringUtils.random(3,0,0,false,false,new char[]{'a'},new Random(seed)));
}
@@ -140,7 +140,7 @@ public class RandomStringUtilsTest {
try {
RandomStringUtils.random(3,5,5,false,false);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException ex) { // distinguish from Random#nextInt message
+ } catch (final IllegalArgumentException ex) { // distinguish from Random#nextInt message
final String msg = ex.getMessage();
assertTrue("Message (" + msg + ") must contain 'start'", msg.contains("start"));
assertTrue("Message (" + msg + ") must contain 'end'", msg.contains("end"));
@@ -153,39 +153,39 @@ public class RandomStringUtilsTest {
try {
RandomStringUtils.random(-1);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, true, true);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, DUMMY);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(1, new char[0]); // must not provide empty array => IAE
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, "");
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, (String)null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, 'a', 'z', false, false);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, 'a', 'z', false, false, DUMMY);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
RandomStringUtils.random(-1, 'a', 'z', false, false, DUMMY, new Random());
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
/**
@@ -194,10 +194,10 @@ public class RandomStringUtilsTest {
*/
@Test
public void testRandomAlphaNumeric() {
- char[] testChars = {'a', 'z', 'A', 'Z', '0', '9'};
- boolean[] found = {false, false, false, false, false, false};
+ final char[] testChars = {'a', 'z', 'A', 'Z', '0', '9'};
+ final boolean[] found = {false, false, false, false, false, false};
for (int i = 0; i < 100; i++) {
- String randString = RandomStringUtils.randomAlphanumeric(10);
+ final String randString = RandomStringUtils.randomAlphanumeric(10);
for (int j = 0; j < testChars.length; j++) {
if (randString.indexOf(testChars[j]) > 0) {
found[j] = true;
@@ -218,10 +218,10 @@ public class RandomStringUtilsTest {
*/
@Test
public void testRandomNumeric() {
- char[] testChars = {'0','9'};
- boolean[] found = {false, false};
+ final char[] testChars = {'0','9'};
+ final boolean[] found = {false, false};
for (int i = 0; i < 100; i++) {
- String randString = RandomStringUtils.randomNumeric(10);
+ final String randString = RandomStringUtils.randomNumeric(10);
for (int j = 0; j < testChars.length; j++) {
if (randString.indexOf(testChars[j]) > 0) {
found[j] = true;
@@ -242,10 +242,10 @@ public class RandomStringUtilsTest {
*/
@Test
public void testRandomAlphabetic() {
- char[] testChars = {'a', 'z', 'A', 'Z'};
- boolean[] found = {false, false, false, false};
+ final char[] testChars = {'a', 'z', 'A', 'Z'};
+ final boolean[] found = {false, false, false, false};
for (int i = 0; i < 100; i++) {
- String randString = RandomStringUtils.randomAlphabetic(10);
+ final String randString = RandomStringUtils.randomAlphabetic(10);
for (int j = 0; j < testChars.length; j++) {
if (randString.indexOf(testChars[j]) > 0) {
found[j] = true;
@@ -266,10 +266,10 @@ public class RandomStringUtilsTest {
*/
@Test
public void testRandomAscii() {
- char[] testChars = {(char) 32, (char) 126};
- boolean[] found = {false, false};
+ final char[] testChars = {(char) 32, (char) 126};
+ final boolean[] found = {false, false};
for (int i = 0; i < 100; i++) {
- String randString = RandomStringUtils.randomAscii(10);
+ final String randString = RandomStringUtils.randomAscii(10);
for (int j = 0; j < testChars.length; j++) {
if (randString.indexOf(testChars[j]) > 0) {
found[j] = true;
@@ -293,11 +293,11 @@ public class RandomStringUtilsTest {
*/
@Test
public void testRandomStringUtilsHomog() {
- String set = "abc";
- char[] chars = set.toCharArray();
+ final String set = "abc";
+ final char[] chars = set.toCharArray();
String gen = "";
- int[] counts = {0,0,0};
- int[] expected = {200,200,200};
+ final int[] counts = {0,0,0};
+ final int[] expected = {200,200,200};
for (int i = 0; i< 100; i++) {
gen = RandomStringUtils.random(6,chars);
for (int j = 0; j < 6; j++) {
@@ -339,16 +339,16 @@ public class RandomStringUtilsTest {
*/
@Test
public void testLang100() throws Exception {
- int size = 5000;
- String encoding = "UTF-8";
- String orig = RandomStringUtils.random(size);
- byte[] bytes = orig.getBytes(encoding);
- String copy = new String(bytes, encoding);
+ final int size = 5000;
+ final String encoding = "UTF-8";
+ final String orig = RandomStringUtils.random(size);
+ final byte[] bytes = orig.getBytes(encoding);
+ final String copy = new String(bytes, encoding);
// for a verbose compare:
for (int i=0; i < orig.length() && i < copy.length(); i++) {
- char o = orig.charAt(i);
- char c = copy.charAt(i);
+ final char o = orig.charAt(i);
+ final char c = copy.charAt(i);
assertEquals("differs at " + i + "(" + Integer.toHexString(new Character(o).hashCode()) + "," +
Integer.toHexString(new Character(c).hashCode()) + ")", o, c);
}
diff --git a/src/test/java/org/apache/commons/lang3/RangeTest.java b/src/test/java/org/apache/commons/lang3/RangeTest.java
index f76ef8e60..16d49e2ad 100644
--- a/src/test/java/org/apache/commons/lang3/RangeTest.java
+++ b/src/test/java/org/apache/commons/lang3/RangeTest.java
@@ -65,22 +65,22 @@ public class RangeTest {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testComparableConstructors() {
- Comparable c =
+ final Comparable c =
new Comparable() {
@Override
public int compareTo(final Object other) {
return 1;
}
};
- Range r1 = Range.is(c);
- Range r2 = Range.between(c, c);
+ final Range r1 = Range.is(c);
+ final Range r2 = Range.between(c, c);
assertEquals(true, r1.isNaturalOrdering());
assertEquals(true, r2.isNaturalOrdering());
}
@Test
public void testIsWithCompare(){
- Comparator<Integer> c = new Comparator<Integer>(){
+ final Comparator<Integer> c = new Comparator<Integer>(){
@Override
public int compare(final Integer o1, final Integer o2) {
return 0; // all integers are equal
@@ -99,7 +99,7 @@ public class RangeTest {
@Test
public void testBetweenWithCompare(){
// TODO add tests with a better comparator
- Comparator<Integer> c = new Comparator<Integer>(){
+ final Comparator<Integer> c = new Comparator<Integer>(){
@Override
public int compare(final Integer o1, final Integer o2) {
return 0; // all integers are equal
@@ -122,7 +122,7 @@ public class RangeTest {
//-----------------------------------------------------------------------
@Test
public void testRangeOfChars() {
- Range<Character> chars = Range.between('a', 'z');
+ final Range<Character> chars = Range.between('a', 'z');
assertTrue(chars.contains('b'));
assertFalse(chars.contains('B'));
}
@@ -154,14 +154,14 @@ public class RangeTest {
public void testToString() {
assertNotNull(byteRange.toString());
- String str = intRange.toString();
+ final String str = intRange.toString();
assertEquals("[10..20]", str);
assertEquals("[-20..-10]", Range.between(-20, -10).toString());
}
@Test
public void testToStringFormat() {
- String str = intRange.toString("From %1$s to %2$s");
+ final String str = intRange.toString("From %1$s to %2$s");
assertEquals("From 10 to 20", str);
}
@@ -242,7 +242,7 @@ public class RangeTest {
try {
intRange.elementCompareTo(null);
fail("NullPointerException should have been thrown");
- } catch(NullPointerException npe) {
+ } catch(final NullPointerException npe) {
// expected
}
diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
index 9df41100b..2bb414199 100644
--- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
@@ -68,7 +68,7 @@ public class SerializationUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new SerializationUtils());
- Constructor<?>[] cons = SerializationUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = SerializationUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(SerializationUtils.class.getModifiers()));
@@ -78,7 +78,7 @@ public class SerializationUtilsTest {
@Test
public void testException() {
SerializationException serEx;
- Exception ex = new Exception();
+ final Exception ex = new Exception();
serEx = new SerializationException();
assertSame(null, serEx.getMessage());
@@ -101,17 +101,17 @@ public class SerializationUtilsTest {
@Test
public void testSerializeStream() throws Exception {
- ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
+ final ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
SerializationUtils.serialize(iMap, streamTest);
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(iMap);
oos.flush();
oos.close();
- byte[] testBytes = streamTest.toByteArray();
- byte[] realBytes = streamReal.toByteArray();
+ final byte[] testBytes = streamTest.toByteArray();
+ final byte[] realBytes = streamReal.toByteArray();
assertEquals(testBytes.length, realBytes.length);
for (int i = 0; i < realBytes.length; i++) {
assertEquals(realBytes[i], testBytes[i]);
@@ -120,11 +120,11 @@ public class SerializationUtilsTest {
@Test
public void testSerializeStreamUnserializable() throws Exception {
- ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
+ final ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
try {
iMap.put(new Object(), new Object());
SerializationUtils.serialize(iMap, streamTest);
- } catch (SerializationException ex) {
+ } catch (final SerializationException ex) {
return;
}
fail();
@@ -132,17 +132,17 @@ public class SerializationUtilsTest {
@Test
public void testSerializeStreamNullObj() throws Exception {
- ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
+ final ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
SerializationUtils.serialize(null, streamTest);
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(null);
oos.flush();
oos.close();
- byte[] testBytes = streamTest.toByteArray();
- byte[] realBytes = streamReal.toByteArray();
+ final byte[] testBytes = streamTest.toByteArray();
+ final byte[] realBytes = streamReal.toByteArray();
assertEquals(testBytes.length, realBytes.length);
for (int i = 0; i < realBytes.length; i++) {
assertEquals(realBytes[i], testBytes[i]);
@@ -153,7 +153,7 @@ public class SerializationUtilsTest {
public void testSerializeStreamObjNull() throws Exception {
try {
SerializationUtils.serialize(iMap, null);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return;
}
fail();
@@ -163,7 +163,7 @@ public class SerializationUtilsTest {
public void testSerializeStreamNullNull() throws Exception {
try {
SerializationUtils.serialize(null, null);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return;
}
fail();
@@ -173,7 +173,7 @@ public class SerializationUtilsTest {
public void testSerializeIOException() throws Exception {
// forces an IOException when the ObjectOutputStream is created, to test not closing the stream
// in the finally block
- OutputStream streamTest = new OutputStream() {
+ final OutputStream streamTest = new OutputStream() {
@Override
public void write(final int arg0) throws IOException {
throw new IOException(SERIALIZE_IO_EXCEPTION_MESSAGE);
@@ -182,7 +182,7 @@ public class SerializationUtilsTest {
try {
SerializationUtils.serialize(iMap, streamTest);
}
- catch(SerializationException e) {
+ catch(final SerializationException e) {
assertEquals("java.io.IOException: " + SERIALIZE_IO_EXCEPTION_MESSAGE, e.getMessage());
}
}
@@ -191,18 +191,18 @@ public class SerializationUtilsTest {
@Test
public void testDeserializeStream() throws Exception {
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(iMap);
oos.flush();
oos.close();
- ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
- Object test = SerializationUtils.deserialize(inTest);
+ final ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
+ final Object test = SerializationUtils.deserialize(inTest);
assertNotNull(test);
assertTrue(test instanceof HashMap<?, ?>);
assertTrue(test != iMap);
- HashMap<?, ?> testMap = (HashMap<?, ?>) test;
+ final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
assertEquals(iString, testMap.get("FOO"));
assertTrue(iString != testMap.get("FOO"));
assertEquals(iInteger, testMap.get("BAR"));
@@ -213,22 +213,22 @@ public class SerializationUtilsTest {
@Test(expected=ClassCastException.class)
public void testDeserializeClassCastException() {
final String value = "Hello";
- byte[] serialized = SerializationUtils.serialize(value);
+ final byte[] serialized = SerializationUtils.serialize(value);
Assert.assertEquals(value, SerializationUtils.deserialize(serialized));
// Causes ClassCastException in call site, not in SerializationUtils.deserialize
- Integer i = SerializationUtils.deserialize(serialized);
+ final Integer i = SerializationUtils.deserialize(serialized);
}
@Test
public void testDeserializeStreamOfNull() throws Exception {
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(null);
oos.flush();
oos.close();
- ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
- Object test = SerializationUtils.deserialize(inTest);
+ final ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
+ final Object test = SerializationUtils.deserialize(inTest);
assertNull(test);
}
@@ -236,7 +236,7 @@ public class SerializationUtilsTest {
public void testDeserializeStreamNull() throws Exception {
try {
SerializationUtils.deserialize((InputStream) null);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return;
}
fail();
@@ -246,7 +246,7 @@ public class SerializationUtilsTest {
public void testDeserializeStreamBadStream() throws Exception {
try {
SerializationUtils.deserialize(new ByteArrayInputStream(new byte[0]));
- } catch (SerializationException ex) {
+ } catch (final SerializationException ex) {
return;
}
fail();
@@ -254,17 +254,18 @@ public class SerializationUtilsTest {
@Test
public void testDeserializeStreamClassNotFound() throws Exception {
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(new ClassNotFoundSerialization());
oos.flush();
oos.close();
- ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
+ final ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
try {
@SuppressWarnings("unused")
+ final
Object test = SerializationUtils.deserialize(inTest);
- } catch(SerializationException se) {
+ } catch(final SerializationException se) {
assertEquals("java.lang.ClassNotFoundException: " + CLASS_NOT_FOUND_MESSAGE, se.getMessage());
}
}
@@ -273,15 +274,15 @@ public class SerializationUtilsTest {
@Test
public void testSerializeBytes() throws Exception {
- byte[] testBytes = SerializationUtils.serialize(iMap);
+ final byte[] testBytes = SerializationUtils.serialize(iMap);
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(iMap);
oos.flush();
oos.close();
- byte[] realBytes = streamReal.toByteArray();
+ final byte[] realBytes = streamReal.toByteArray();
assertEquals(testBytes.length, realBytes.length);
for (int i = 0; i < realBytes.length; i++) {
assertEquals(realBytes[i], testBytes[i]);
@@ -293,7 +294,7 @@ public class SerializationUtilsTest {
try {
iMap.put(new Object(), new Object());
SerializationUtils.serialize(iMap);
- } catch (SerializationException ex) {
+ } catch (final SerializationException ex) {
return;
}
fail();
@@ -301,15 +302,15 @@ public class SerializationUtilsTest {
@Test
public void testSerializeBytesNull() throws Exception {
- byte[] testBytes = SerializationUtils.serialize(null);
+ final byte[] testBytes = SerializationUtils.serialize(null);
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(null);
oos.flush();
oos.close();
- byte[] realBytes = streamReal.toByteArray();
+ final byte[] realBytes = streamReal.toByteArray();
assertEquals(testBytes.length, realBytes.length);
for (int i = 0; i < realBytes.length; i++) {
assertEquals(realBytes[i], testBytes[i]);
@@ -320,17 +321,17 @@ public class SerializationUtilsTest {
@Test
public void testDeserializeBytes() throws Exception {
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(iMap);
oos.flush();
oos.close();
- Object test = SerializationUtils.deserialize(streamReal.toByteArray());
+ final Object test = SerializationUtils.deserialize(streamReal.toByteArray());
assertNotNull(test);
assertTrue(test instanceof HashMap<?, ?>);
assertTrue(test != iMap);
- HashMap<?, ?> testMap = (HashMap<?, ?>) test;
+ final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
assertEquals(iString, testMap.get("FOO"));
assertTrue(iString != testMap.get("FOO"));
assertEquals(iInteger, testMap.get("BAR"));
@@ -340,13 +341,13 @@ public class SerializationUtilsTest {
@Test
public void testDeserializeBytesOfNull() throws Exception {
- ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(streamReal);
+ final ByteArrayOutputStream streamReal = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(streamReal);
oos.writeObject(null);
oos.flush();
oos.close();
- Object test = SerializationUtils.deserialize(streamReal.toByteArray());
+ final Object test = SerializationUtils.deserialize(streamReal.toByteArray());
assertNull(test);
}
@@ -354,7 +355,7 @@ public class SerializationUtilsTest {
public void testDeserializeBytesNull() throws Exception {
try {
SerializationUtils.deserialize((byte[]) null);
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
return;
}
fail();
@@ -364,7 +365,7 @@ public class SerializationUtilsTest {
public void testDeserializeBytesBadStream() throws Exception {
try {
SerializationUtils.deserialize(new byte[0]);
- } catch (SerializationException ex) {
+ } catch (final SerializationException ex) {
return;
}
fail();
@@ -374,11 +375,11 @@ public class SerializationUtilsTest {
@Test
public void testClone() throws Exception {
- Object test = SerializationUtils.clone(iMap);
+ final Object test = SerializationUtils.clone(iMap);
assertNotNull(test);
assertTrue(test instanceof HashMap<?,?>);
assertTrue(test != iMap);
- HashMap<?, ?> testMap = (HashMap<?, ?>) test;
+ final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
assertEquals(iString, testMap.get("FOO"));
assertTrue(iString != testMap.get("FOO"));
assertEquals(iInteger, testMap.get("BAR"));
@@ -388,7 +389,7 @@ public class SerializationUtilsTest {
@Test
public void testCloneNull() throws Exception {
- Object test = SerializationUtils.clone(null);
+ final Object test = SerializationUtils.clone(null);
assertNull(test);
}
@@ -397,7 +398,7 @@ public class SerializationUtilsTest {
try {
iMap.put(new Object(), new Object());
SerializationUtils.clone(iMap);
- } catch (SerializationException ex) {
+ } catch (final SerializationException ex) {
return;
}
fail();
@@ -405,11 +406,11 @@ public class SerializationUtilsTest {
@Test
public void testPrimitiveTypeClassSerialization() {
- Class<?>[] primitiveTypes = { byte.class, short.class, int.class, long.class, float.class, double.class,
+ final Class<?>[] primitiveTypes = { byte.class, short.class, int.class, long.class, float.class, double.class,
boolean.class, char.class, void.class };
- for (Class<?> primitiveType : primitiveTypes) {
- Class<?> clone = SerializationUtils.clone(primitiveType);
+ for (final Class<?> primitiveType : primitiveTypes) {
+ final Class<?> clone = SerializationUtils.clone(primitiveType);
assertEquals(primitiveType, clone);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
index 1b06bd5cc..f9a172c66 100644
--- a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
@@ -44,7 +44,7 @@ public class StringEscapeUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new StringEscapeUtils());
- Constructor<?>[] cons = StringEscapeUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = StringEscapeUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(StringEscapeUtils.class.getModifiers()));
@@ -57,16 +57,16 @@ public class StringEscapeUtilsTest {
try {
StringEscapeUtils.ESCAPE_JAVA.translate(null, null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
StringEscapeUtils.ESCAPE_JAVA.translate("", null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
assertEscapeJava("empty string", "", "");
@@ -111,11 +111,11 @@ public class StringEscapeUtilsTest {
}
private void assertEscapeJava(String message, final String expected, final String original) throws IOException {
- String converted = StringEscapeUtils.escapeJava(original);
+ final String converted = StringEscapeUtils.escapeJava(original);
message = "escapeJava(String) failed" + (message == null ? "" : (": " + message));
assertEquals(message, expected, converted);
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
StringEscapeUtils.ESCAPE_JAVA.translate(original, writer);
assertEquals(expected, writer.toString());
}
@@ -126,21 +126,21 @@ public class StringEscapeUtilsTest {
try {
StringEscapeUtils.UNESCAPE_JAVA.translate(null, null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
StringEscapeUtils.UNESCAPE_JAVA.translate("", null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
StringEscapeUtils.unescapeJava("\\u02-3");
fail();
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
}
assertUnescapeJava("", "");
@@ -160,8 +160,8 @@ public class StringEscapeUtilsTest {
}
private void assertUnescapeJava(final String message, final String unescaped, final String original) throws IOException {
- String expected = unescaped;
- String actual = StringEscapeUtils.unescapeJava(original);
+ final String expected = unescaped;
+ final String actual = StringEscapeUtils.unescapeJava(original);
assertEquals("unescape(String) failed" +
(message == null ? "" : (": " + message)) +
@@ -170,7 +170,7 @@ public class StringEscapeUtilsTest {
"' actual '" + StringEscapeUtils.escapeJava(actual) + "'",
expected, actual);
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
StringEscapeUtils.UNESCAPE_JAVA.translate(original, writer);
assertEquals(unescaped, writer.toString());
@@ -182,16 +182,16 @@ public class StringEscapeUtilsTest {
try {
StringEscapeUtils.ESCAPE_ECMASCRIPT.translate(null, null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
StringEscapeUtils.ESCAPE_ECMASCRIPT.translate("", null);
fail();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
assertEquals("He didn\\'t say, \\\"stop!\\\"", StringEscapeUtils.escapeEcmaScript("He didn't say, \"stop!\""));
@@ -220,16 +220,16 @@ public class StringEscapeUtilsTest {
@Test
public void testEscapeHtml() {
for (int i = 0; i < HTML_ESCAPES.length; ++i) {
- String message = HTML_ESCAPES[i][0];
- String expected = HTML_ESCAPES[i][1];
- String original = HTML_ESCAPES[i][2];
+ final String message = HTML_ESCAPES[i][0];
+ final String expected = HTML_ESCAPES[i][1];
+ final String original = HTML_ESCAPES[i][2];
assertEquals(message, expected, StringEscapeUtils.escapeHtml4(original));
- StringWriter sw = new StringWriter();
+ final StringWriter sw = new StringWriter();
try {
StringEscapeUtils.ESCAPE_HTML4.translate(original, sw);
- } catch (IOException e) {
+ } catch (final IOException e) {
}
- String actual = original == null ? null : sw.toString();
+ final String actual = original == null ? null : sw.toString();
assertEquals(message, expected, actual);
}
}
@@ -237,17 +237,17 @@ public class StringEscapeUtilsTest {
@Test
public void testUnescapeHtml4() {
for (int i = 0; i < HTML_ESCAPES.length; ++i) {
- String message = HTML_ESCAPES[i][0];
- String expected = HTML_ESCAPES[i][2];
- String original = HTML_ESCAPES[i][1];
+ final String message = HTML_ESCAPES[i][0];
+ final String expected = HTML_ESCAPES[i][2];
+ final String original = HTML_ESCAPES[i][1];
assertEquals(message, expected, StringEscapeUtils.unescapeHtml4(original));
- StringWriter sw = new StringWriter();
+ final StringWriter sw = new StringWriter();
try {
StringEscapeUtils.UNESCAPE_HTML4.translate(original, sw);
- } catch (IOException e) {
+ } catch (final IOException e) {
}
- String actual = original == null ? null : sw.toString();
+ final String actual = original == null ? null : sw.toString();
assertEquals(message, expected, actual);
}
// \u00E7 is a cedilla (c with wiggle under)
@@ -268,11 +268,11 @@ public class StringEscapeUtilsTest {
assertEquals("hex number unescape", "\u0080\u009F", StringEscapeUtils.unescapeHtml4("&#X80;&#X9F;"));
// Test all Character values:
for (char i = Character.MIN_VALUE; i < Character.MAX_VALUE; i++) {
- Character c1 = new Character(i);
- Character c2 = new Character((char)(i+1));
- String expected = c1.toString() + c2.toString();
- String escapedC1 = "&#x" + Integer.toHexString((c1.charValue())) + ";";
- String escapedC2 = "&#x" + Integer.toHexString((c2.charValue())) + ";";
+ final Character c1 = new Character(i);
+ final Character c2 = new Character((char)(i+1));
+ final String expected = c1.toString() + c2.toString();
+ final String escapedC1 = "&#x" + Integer.toHexString((c1.charValue())) + ";";
+ final String escapedC2 = "&#x" + Integer.toHexString((c2.charValue())) + ";";
assertEquals("hex number unescape index " + (int)i, expected, StringEscapeUtils.unescapeHtml4(escapedC1 + escapedC2));
}
}
@@ -315,14 +315,14 @@ public class StringEscapeUtilsTest {
StringWriter sw = new StringWriter();
try {
StringEscapeUtils.ESCAPE_XML.translate("<abc>", sw);
- } catch (IOException e) {
+ } catch (final IOException e) {
}
assertEquals("XML was escaped incorrectly", "&lt;abc&gt;", sw.toString() );
sw = new StringWriter();
try {
StringEscapeUtils.UNESCAPE_XML.translate("&lt;abc&gt;", sw);
- } catch (IOException e) {
+ } catch (final IOException e) {
}
assertEquals("XML was unescaped incorrectly", "<abc>", sw.toString() );
}
@@ -343,7 +343,7 @@ public class StringEscapeUtilsTest {
*/
@Test
public void testEscapeXmlSupplementaryCharacters() {
- CharSequenceTranslator escapeXml =
+ final CharSequenceTranslator escapeXml =
StringEscapeUtils.ESCAPE_XML.with( NumericEntityEscaper.between(0x7f, Integer.MAX_VALUE) );
assertEquals("Supplementary character must be represented using a single escape", "&#144308;",
@@ -355,7 +355,7 @@ public class StringEscapeUtilsTest {
// http://www.w3.org/TR/xml/#charsets says:
// Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character,
// excluding the surrogate blocks, FFFE, and FFFF. */
- CharSequenceTranslator escapeXml = StringEscapeUtils.ESCAPE_XML
+ final CharSequenceTranslator escapeXml = StringEscapeUtils.ESCAPE_XML
.with(NumericEntityEscaper.below(9), NumericEntityEscaper.between(0xB, 0xC), NumericEntityEscaper.between(0xE, 0x19),
NumericEntityEscaper.between(0xD800, 0xDFFF), NumericEntityEscaper.between(0xFFFE, 0xFFFF), NumericEntityEscaper.above(0x110000));
@@ -418,10 +418,10 @@ public class StringEscapeUtilsTest {
private void checkCsvEscapeWriter(final String expected, final String value) {
try {
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
StringEscapeUtils.ESCAPE_CSV.translate(value, writer);
assertEquals(expected, writer.toString());
- } catch (IOException e) {
+ } catch (final IOException e) {
fail("Threw: " + e);
}
}
@@ -454,10 +454,10 @@ public class StringEscapeUtilsTest {
private void checkCsvUnescapeWriter(final String expected, final String value) {
try {
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
StringEscapeUtils.UNESCAPE_CSV.translate(value, writer);
assertEquals(expected, writer.toString());
- } catch (IOException e) {
+ } catch (final IOException e) {
fail("Threw: " + e);
}
}
@@ -473,14 +473,14 @@ public class StringEscapeUtilsTest {
// COUNTING ROD UNIT DIGIT THREE
// in Unicode
// codepoint: U+1D362
- byte[] data = new byte[] { (byte)0xF0, (byte)0x9D, (byte)0x8D, (byte)0xA2 };
+ final byte[] data = new byte[] { (byte)0xF0, (byte)0x9D, (byte)0x8D, (byte)0xA2 };
- String original = new String(data, "UTF8");
+ final String original = new String(data, "UTF8");
- String escaped = StringEscapeUtils.escapeHtml4( original );
+ final String escaped = StringEscapeUtils.escapeHtml4( original );
assertEquals( "High Unicode should not have been escaped", original, escaped);
- String unescaped = StringEscapeUtils.unescapeHtml4( escaped );
+ final String unescaped = StringEscapeUtils.unescapeHtml4( escaped );
assertEquals( "High Unicode should have been unchanged", original, unescaped);
// TODO: I think this should hold, needs further investigation
@@ -494,12 +494,12 @@ public class StringEscapeUtilsTest {
@Test
public void testEscapeHiragana() {
// Some random Japanese Unicode characters
- String original = "\u304B\u304C\u3068";
- String escaped = StringEscapeUtils.escapeHtml4(original);
+ final String original = "\u304B\u304C\u3068";
+ final String escaped = StringEscapeUtils.escapeHtml4(original);
assertEquals( "Hiragana character Unicode behaviour should not be being escaped by escapeHtml4",
original, escaped);
- String unescaped = StringEscapeUtils.unescapeHtml4( escaped );
+ final String unescaped = StringEscapeUtils.unescapeHtml4( escaped );
assertEquals( "Hiragana character Unicode behaviour has changed - expected no unescaping", escaped, unescaped);
}
@@ -512,8 +512,8 @@ public class StringEscapeUtilsTest {
*/
@Test
public void testLang708() throws IOException {
- String input = IOUtils.toString(new FileInputStream("src/test/resources/lang-708-input.txt"), "UTF-8");
- String escaped = StringEscapeUtils.escapeEcmaScript(input);
+ final String input = IOUtils.toString(new FileInputStream("src/test/resources/lang-708-input.txt"), "UTF-8");
+ final String escaped = StringEscapeUtils.escapeEcmaScript(input);
// just the end:
assertTrue(escaped, escaped.endsWith("}]"));
// a little more:
@@ -525,8 +525,8 @@ public class StringEscapeUtilsTest {
*/
@Test
public void testLang720() {
- String input = new StringBuilder("\ud842\udfb7").append("A").toString();
- String escaped = StringEscapeUtils.escapeXml(input);
+ final String input = new StringBuilder("\ud842\udfb7").append("A").toString();
+ final String escaped = StringEscapeUtils.escapeXml(input);
assertEquals(input, escaped);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
index 461d7cab1..0bc1e6ed8 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
@@ -216,11 +216,11 @@ public class StringUtilsEqualsIndexOfTest {
@Test
public void testContainsIgnoreCase_LocaleIndependence() {
- Locale orig = Locale.getDefault();
+ final Locale orig = Locale.getDefault();
- Locale[] locales = { Locale.ENGLISH, new Locale("tr"), Locale.getDefault() };
+ final Locale[] locales = { Locale.ENGLISH, new Locale("tr"), Locale.getDefault() };
- String[][] tdata = {
+ final String[][] tdata = {
{ "i", "I" },
{ "I", "i" },
{ "\u03C2", "\u03C3" },
@@ -228,12 +228,12 @@ public class StringUtilsEqualsIndexOfTest {
{ "\u03A3", "\u03C3" },
};
- String[][] fdata = {
+ final String[][] fdata = {
{ "\u00DF", "SS" },
};
try {
- for (Locale locale : locales) {
+ for (final Locale locale : locales) {
Locale.setDefault(locale);
for (int j = 0; j < tdata.length; j++) {
assertTrue(Locale.getDefault() + ": " + j + " " + tdata[j][0] + " " + tdata[j][1], StringUtils
@@ -286,13 +286,13 @@ public class StringUtilsEqualsIndexOfTest {
@Test
public void testContainsNone_CharArray() {
- String str1 = "a";
- String str2 = "b";
- String str3 = "ab.";
- char[] chars1= {'b'};
- char[] chars2= {'.'};
- char[] chars3= {'c', 'd'};
- char[] emptyChars = new char[0];
+ final String str1 = "a";
+ final String str2 = "b";
+ final String str3 = "ab.";
+ final char[] chars1= {'b'};
+ final char[] chars2= {'.'};
+ final char[] chars3= {'c', 'd'};
+ final char[] emptyChars = new char[0];
assertTrue(StringUtils.containsNone(null, (char[]) null));
assertTrue(StringUtils.containsNone("", (char[]) null));
assertTrue(StringUtils.containsNone(null, emptyChars));
@@ -344,12 +344,12 @@ public class StringUtilsEqualsIndexOfTest {
@Test
public void testContainsNone_String() {
- String str1 = "a";
- String str2 = "b";
- String str3 = "ab.";
- String chars1= "b";
- String chars2= ".";
- String chars3= "cd";
+ final String str1 = "a";
+ final String str2 = "b";
+ final String str3 = "ab.";
+ final String chars1= "b";
+ final String chars2= ".";
+ final String chars3= "cd";
assertTrue(StringUtils.containsNone(null, (String) null));
assertTrue(StringUtils.containsNone("", (String) null));
assertTrue(StringUtils.containsNone(null, ""));
@@ -401,13 +401,13 @@ public class StringUtilsEqualsIndexOfTest {
@Test
public void testContainsOnly_CharArray() {
- String str1 = "a";
- String str2 = "b";
- String str3 = "ab";
- char[] chars1= {'b'};
- char[] chars2= {'a'};
- char[] chars3= {'a', 'b'};
- char[] emptyChars = new char[0];
+ final String str1 = "a";
+ final String str2 = "b";
+ final String str3 = "ab";
+ final char[] chars1= {'b'};
+ final char[] chars2= {'a'};
+ final char[] chars3= {'a', 'b'};
+ final char[] emptyChars = new char[0];
assertFalse(StringUtils.containsOnly(null, (char[]) null));
assertFalse(StringUtils.containsOnly("", (char[]) null));
assertFalse(StringUtils.containsOnly(null, emptyChars));
@@ -427,12 +427,12 @@ public class StringUtilsEqualsIndexOfTest {
@Test
public void testContainsOnly_String() {
- String str1 = "a";
- String str2 = "b";
- String str3 = "ab";
- String chars1= "b";
- String chars2= "a";
- String chars3= "ab";
+ final String str1 = "a";
+ final String str2 = "b";
+ final String str3 = "ab";
+ final String chars1= "b";
+ final String chars2= "a";
+ final String chars3= "ab";
assertFalse(StringUtils.containsOnly(null, (String) null));
assertFalse(StringUtils.containsOnly("", (String) null));
assertFalse(StringUtils.containsOnly(null, ""));
@@ -492,7 +492,7 @@ public class StringUtilsEqualsIndexOfTest {
if (obj == null || !(obj instanceof CustomCharSequence)) {
return false;
}
- CustomCharSequence other = (CustomCharSequence) obj;
+ final CustomCharSequence other = (CustomCharSequence) obj;
return seq.equals(other.seq);
}
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
index 8740852e5..95cdd58cd 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
@@ -111,7 +111,7 @@ public class StringUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new StringUtils());
- Constructor<?>[] cons = StringUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = StringUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(StringUtils.class.getModifiers()));
@@ -184,8 +184,8 @@ public class StringUtilsTest {
assertEquals("I AM here 123", StringUtils.swapCase("i am HERE 123") );
assertEquals("i am here 123", StringUtils.swapCase("I AM HERE 123") );
- String test = "This String contains a TitleCase character: \u01C8";
- String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9";
+ final String test = "This String contains a TitleCase character: \u01C8";
+ final String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9";
assertEquals(expect, WordUtils.swapCase(test));
}
@@ -423,14 +423,14 @@ public class StringUtilsTest {
}
String[] results;
- String[] expectedResults = {"ab", "de fg"};
+ final String[] expectedResults = {"ab", "de fg"};
results = StringUtils.split("ab de fg", null, 2);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
assertEquals(expectedResults[i], results[i]);
}
- String[] expectedResults2 = {"ab", "cd:ef"};
+ final String[] expectedResults2 = {"ab", "cd:ef"};
results = StringUtils.split("ab:cd:ef",":", 2);
assertEquals(expectedResults2.length, results.length);
for (int i = 0; i < expectedResults2.length; i++) {
@@ -439,7 +439,7 @@ public class StringUtilsTest {
}
private void innerTestSplit(final char separator, final String sepStr, final char noMatch) {
- String msg = "Failed on separator hex(" + Integer.toHexString(separator) +
+ final String msg = "Failed on separator hex(" + Integer.toHexString(separator) +
"), noMatch hex(" + Integer.toHexString(noMatch) + "), sepStr(" + sepStr + ")";
final String str = "a" + separator + "b" + separator + separator + noMatch + "c";
@@ -484,26 +484,26 @@ public class StringUtilsTest {
assertEquals( 0, StringUtils.splitByWholeSeparator( "", "." ).length ) ;
- String stringToSplitOnNulls = "ab de fg" ;
- String[] splitOnNullExpectedResults = { "ab", "de", "fg" } ;
+ final String stringToSplitOnNulls = "ab de fg" ;
+ final String[] splitOnNullExpectedResults = { "ab", "de", "fg" } ;
- String[] splitOnNullResults = StringUtils.splitByWholeSeparator( stringToSplitOnNulls, null ) ;
+ final String[] splitOnNullResults = StringUtils.splitByWholeSeparator( stringToSplitOnNulls, null ) ;
assertEquals( splitOnNullExpectedResults.length, splitOnNullResults.length ) ;
for ( int i = 0 ; i < splitOnNullExpectedResults.length ; i+= 1 ) {
assertEquals( splitOnNullExpectedResults[i], splitOnNullResults[i] ) ;
}
- String stringToSplitOnCharactersAndString = "abstemiouslyaeiouyabstemiously" ;
+ final String stringToSplitOnCharactersAndString = "abstemiouslyaeiouyabstemiously" ;
- String[] splitOnStringExpectedResults = { "abstemiously", "abstemiously" } ;
- String[] splitOnStringResults = StringUtils.splitByWholeSeparator( stringToSplitOnCharactersAndString, "aeiouy" ) ;
+ final String[] splitOnStringExpectedResults = { "abstemiously", "abstemiously" } ;
+ final String[] splitOnStringResults = StringUtils.splitByWholeSeparator( stringToSplitOnCharactersAndString, "aeiouy" ) ;
assertEquals( splitOnStringExpectedResults.length, splitOnStringResults.length ) ;
for ( int i = 0 ; i < splitOnStringExpectedResults.length ; i+= 1 ) {
assertEquals( splitOnStringExpectedResults[i], splitOnStringResults[i] ) ;
}
- String[] splitWithMultipleSeparatorExpectedResults = {"ab", "cd", "ef"};
- String[] splitWithMultipleSeparator = StringUtils.splitByWholeSeparator("ab:cd::ef", ":");
+ final String[] splitWithMultipleSeparatorExpectedResults = {"ab", "cd", "ef"};
+ final String[] splitWithMultipleSeparator = StringUtils.splitByWholeSeparator("ab:cd::ef", ":");
assertEquals( splitWithMultipleSeparatorExpectedResults.length, splitWithMultipleSeparator.length );
for( int i = 0; i < splitWithMultipleSeparatorExpectedResults.length ; i++ ) {
assertEquals( splitWithMultipleSeparatorExpectedResults[i], splitWithMultipleSeparator[i] ) ;
@@ -516,21 +516,21 @@ public class StringUtilsTest {
assertEquals( 0, StringUtils.splitByWholeSeparator( "", ".", 3 ).length ) ;
- String stringToSplitOnNulls = "ab de fg" ;
- String[] splitOnNullExpectedResults = { "ab", "de fg" } ;
+ final String stringToSplitOnNulls = "ab de fg" ;
+ final String[] splitOnNullExpectedResults = { "ab", "de fg" } ;
//String[] splitOnNullExpectedResults = { "ab", "de" } ;
- String[] splitOnNullResults = StringUtils.splitByWholeSeparator( stringToSplitOnNulls, null, 2 ) ;
+ final String[] splitOnNullResults = StringUtils.splitByWholeSeparator( stringToSplitOnNulls, null, 2 ) ;
assertEquals( splitOnNullExpectedResults.length, splitOnNullResults.length ) ;
for ( int i = 0 ; i < splitOnNullExpectedResults.length ; i+= 1 ) {
assertEquals( splitOnNullExpectedResults[i], splitOnNullResults[i] ) ;
}
- String stringToSplitOnCharactersAndString = "abstemiouslyaeiouyabstemiouslyaeiouyabstemiously" ;
+ final String stringToSplitOnCharactersAndString = "abstemiouslyaeiouyabstemiouslyaeiouyabstemiously" ;
- String[] splitOnStringExpectedResults = { "abstemiously", "abstemiouslyaeiouyabstemiously" } ;
+ final String[] splitOnStringExpectedResults = { "abstemiously", "abstemiouslyaeiouyabstemiously" } ;
//String[] splitOnStringExpectedResults = { "abstemiously", "abstemiously" } ;
- String[] splitOnStringResults = StringUtils.splitByWholeSeparator( stringToSplitOnCharactersAndString, "aeiouy", 2 ) ;
+ final String[] splitOnStringResults = StringUtils.splitByWholeSeparator( stringToSplitOnCharactersAndString, "aeiouy", 2 ) ;
assertEquals( splitOnStringExpectedResults.length, splitOnStringResults.length ) ;
for ( int i = 0 ; i < splitOnStringExpectedResults.length ; i++ ) {
assertEquals( splitOnStringExpectedResults[i], splitOnStringResults[i] ) ;
@@ -763,7 +763,7 @@ public class StringUtilsTest {
// Match example in javadoc
{
String[] results;
- String[] expectedResults = {"a", "", "b", "c"};
+ final String[] expectedResults = {"a", "", "b", "c"};
results = StringUtils.splitPreserveAllTokens("a..b.c",'.');
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -792,7 +792,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "de fg"};
+ final String[] expectedResults = {"ab", "de fg"};
results = StringUtils.splitPreserveAllTokens("ab de fg", null, 2);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -802,7 +802,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", " de fg"};
+ final String[] expectedResults = {"ab", " de fg"};
results = StringUtils.splitPreserveAllTokens("ab de fg", null, 2);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -812,7 +812,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "::de:fg"};
+ final String[] expectedResults = {"ab", "::de:fg"};
results = StringUtils.splitPreserveAllTokens("ab:::de:fg", ":", 2);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -822,7 +822,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "", " de fg"};
+ final String[] expectedResults = {"ab", "", " de fg"};
results = StringUtils.splitPreserveAllTokens("ab de fg", null, 3);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -832,7 +832,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "", "", "de fg"};
+ final String[] expectedResults = {"ab", "", "", "de fg"};
results = StringUtils.splitPreserveAllTokens("ab de fg", null, 4);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -841,7 +841,7 @@ public class StringUtilsTest {
}
{
- String[] expectedResults = {"ab", "cd:ef"};
+ final String[] expectedResults = {"ab", "cd:ef"};
String[] results;
results = StringUtils.splitPreserveAllTokens("ab:cd:ef",":", 2);
assertEquals(expectedResults.length, results.length);
@@ -852,7 +852,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", ":cd:ef"};
+ final String[] expectedResults = {"ab", ":cd:ef"};
results = StringUtils.splitPreserveAllTokens("ab::cd:ef",":", 2);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -862,7 +862,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "", ":cd:ef"};
+ final String[] expectedResults = {"ab", "", ":cd:ef"};
results = StringUtils.splitPreserveAllTokens("ab:::cd:ef",":", 3);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -872,7 +872,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"ab", "", "", "cd:ef"};
+ final String[] expectedResults = {"ab", "", "", "cd:ef"};
results = StringUtils.splitPreserveAllTokens("ab:::cd:ef",":", 4);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -882,7 +882,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"", "ab", "", "", "cd:ef"};
+ final String[] expectedResults = {"", "ab", "", "", "cd:ef"};
results = StringUtils.splitPreserveAllTokens(":ab:::cd:ef",":", 5);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -892,7 +892,7 @@ public class StringUtilsTest {
{
String[] results;
- String[] expectedResults = {"", "", "ab", "", "", "cd:ef"};
+ final String[] expectedResults = {"", "", "ab", "", "", "cd:ef"};
results = StringUtils.splitPreserveAllTokens("::ab:::cd:ef",":", 6);
assertEquals(expectedResults.length, results.length);
for (int i = 0; i < expectedResults.length; i++) {
@@ -903,7 +903,7 @@ public class StringUtilsTest {
}
private void innerTestSplitPreserveAllTokens(final char separator, final String sepStr, final char noMatch) {
- String msg = "Failed on separator hex(" + Integer.toHexString(separator) +
+ final String msg = "Failed on separator hex(" + Integer.toHexString(separator) +
"), noMatch hex(" + Integer.toHexString(noMatch) + "), sepStr(" + sepStr + ")";
final String str = "a" + separator + "b" + separator + separator + noMatch + "c";
@@ -1065,7 +1065,7 @@ public class StringUtilsTest {
assertEquals("", StringUtils.replace("", "any", null, 2));
assertEquals("", StringUtils.replace("", "any", "any", 2));
- String str = new String(new char[] {'o', 'o', 'f', 'o', 'o'});
+ final String str = new String(new char[] {'o', 'o', 'f', 'o', 'o'});
assertSame(str, StringUtils.replace(str, "x", "", -1));
assertEquals("f", StringUtils.replace("oofoo", "o", "", -1));
@@ -1155,7 +1155,7 @@ public class StringUtilsTest {
try {
StringUtils.replaceEachRepeatedly("abcde", new String[]{"ab", "d"}, new String[]{"d", "ab"});
fail("Should be a circular reference");
- } catch (IllegalStateException e) {}
+ } catch (final IllegalStateException e) {}
//JAVADOC TESTS END
}
@@ -1250,7 +1250,7 @@ public class StringUtilsTest {
assertEquals("aaa", StringUtils.repeat("a", 3));
assertEquals("ababab", StringUtils.repeat("ab", 3));
assertEquals("abcabcabc", StringUtils.repeat("abc", 3));
- String str = StringUtils.repeat("a", 10000); // bigger than pad limit
+ final String str = StringUtils.repeat("a", 10000); // bigger than pad limit
assertEquals(10000, str.length());
assertTrue(StringUtils.containsOnly(str, new char[] {'a'}));
}
@@ -1272,7 +1272,7 @@ public class StringUtilsTest {
@Test
public void testChop() {
- String[][] chopCases = {
+ final String[][] chopCases = {
{ FOO_UNCAP + "\r\n", FOO_UNCAP } ,
{ FOO_UNCAP + "\n" , FOO_UNCAP } ,
{ FOO_UNCAP + "\r", FOO_UNCAP },
@@ -1286,9 +1286,9 @@ public class StringUtilsTest {
{ "", "" },
{ "a", "" },
};
- for (String[] chopCase : chopCases) {
- String original = chopCase[0];
- String expectedResult = chopCase[1];
+ for (final String[] chopCase : chopCases) {
+ final String original = chopCase[0];
+ final String expectedResult = chopCase[1];
assertEquals("chop(String) failed",
expectedResult, StringUtils.chop(original));
}
@@ -1298,7 +1298,7 @@ public class StringUtilsTest {
@Test
public void testChomp() {
- String[][] chompCases = {
+ final String[][] chompCases = {
{ FOO_UNCAP + "\r\n", FOO_UNCAP },
{ FOO_UNCAP + "\n" , FOO_UNCAP },
{ FOO_UNCAP + "\r", FOO_UNCAP },
@@ -1316,9 +1316,9 @@ public class StringUtilsTest {
{ null, null },
{ FOO_UNCAP + "\n\r", FOO_UNCAP + "\n"}
};
- for (String[] chompCase : chompCases) {
- String original = chompCase[0];
- String expectedResult = chompCase[1];
+ for (final String[] chompCase : chompCases) {
+ final String original = chompCase[0];
+ final String expectedResult = chompCase[1];
assertEquals("chomp(String) failed",
expectedResult, StringUtils.chomp(original));
}
@@ -1371,7 +1371,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.rightPad("abc", 2, ' '));
assertEquals("abc", StringUtils.rightPad("abc", -1, ' '));
assertEquals("abcxx", StringUtils.rightPad("abc", 5, 'x'));
- String str = StringUtils.rightPad("aaa", 10000, 'a'); // bigger than pad length
+ final String str = StringUtils.rightPad("aaa", 10000, 'a'); // bigger than pad length
assertEquals(10000, str.length());
assertTrue(StringUtils.containsOnly(str, new char[] {'a'}));
}
@@ -1407,7 +1407,7 @@ public class StringUtilsTest {
assertEquals("xxabc", StringUtils.leftPad("abc", 5, 'x'));
assertEquals("\uffff\uffffabc", StringUtils.leftPad("abc", 5, '\uffff'));
assertEquals("abc", StringUtils.leftPad("abc", 2, ' '));
- String str = StringUtils.leftPad("aaa", 10000, 'a'); // bigger than pad length
+ final String str = StringUtils.leftPad("aaa", 10000, 'a'); // bigger than pad length
assertEquals(10000, str.length());
assertTrue(StringUtils.containsOnly(str, new char[] {'a'}));
}
@@ -1552,7 +1552,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfEmpty("abc", "NULL"));
assertNull(StringUtils.defaultIfEmpty("", null));
// Tests compatibility for the API return type
- String s = StringUtils.defaultIfEmpty("abc", "NULL");
+ final String s = StringUtils.defaultIfEmpty("abc", "NULL");
assertEquals("abc", s);
}
@@ -1564,7 +1564,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfBlank("abc", "NULL"));
assertNull(StringUtils.defaultIfBlank("", null));
// Tests compatibility for the API return type
- String s = StringUtils.defaultIfBlank("abc", "NULL");
+ final String s = StringUtils.defaultIfBlank("abc", "NULL");
assertEquals("abc", s);
}
@@ -1574,7 +1574,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfEmpty(new StringBuilder("abc"), new StringBuilder("NULL")).toString());
assertNull(StringUtils.defaultIfEmpty(new StringBuilder(""), null));
// Tests compatibility for the API return type
- StringBuilder s = StringUtils.defaultIfEmpty(new StringBuilder("abc"), new StringBuilder("NULL"));
+ final StringBuilder s = StringUtils.defaultIfEmpty(new StringBuilder("abc"), new StringBuilder("NULL"));
assertEquals("abc", s.toString());
}
@@ -1585,7 +1585,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfBlank(new StringBuilder("abc"), new StringBuilder("NULL")).toString());
assertNull(StringUtils.defaultIfBlank(new StringBuilder(""), null));
// Tests compatibility for the API return type
- StringBuilder s = StringUtils.defaultIfBlank(new StringBuilder("abc"), new StringBuilder("NULL"));
+ final StringBuilder s = StringUtils.defaultIfBlank(new StringBuilder("abc"), new StringBuilder("NULL"));
assertEquals("abc", s.toString());
}
@@ -1595,7 +1595,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfEmpty(new StringBuffer("abc"), new StringBuffer("NULL")).toString());
assertNull(StringUtils.defaultIfEmpty(new StringBuffer(""), null));
// Tests compatibility for the API return type
- StringBuffer s = StringUtils.defaultIfEmpty(new StringBuffer("abc"), new StringBuffer("NULL"));
+ final StringBuffer s = StringUtils.defaultIfEmpty(new StringBuffer("abc"), new StringBuffer("NULL"));
assertEquals("abc", s.toString());
}
@@ -1606,7 +1606,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfBlank(new StringBuffer("abc"), new StringBuffer("NULL")).toString());
assertNull(StringUtils.defaultIfBlank(new StringBuffer(""), null));
// Tests compatibility for the API return type
- StringBuffer s = StringUtils.defaultIfBlank(new StringBuffer("abc"), new StringBuffer("NULL"));
+ final StringBuffer s = StringUtils.defaultIfBlank(new StringBuffer("abc"), new StringBuffer("NULL"));
assertEquals("abc", s.toString());
}
@@ -1616,7 +1616,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfEmpty(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL")).toString());
assertNull(StringUtils.defaultIfEmpty(CharBuffer.wrap(""), null));
// Tests compatibility for the API return type
- CharBuffer s = StringUtils.defaultIfEmpty(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL"));
+ final CharBuffer s = StringUtils.defaultIfEmpty(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL"));
assertEquals("abc", s.toString());
}
@@ -1627,7 +1627,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.defaultIfBlank(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL")).toString());
assertNull(StringUtils.defaultIfBlank(CharBuffer.wrap(""), null));
// Tests compatibility for the API return type
- CharBuffer s = StringUtils.defaultIfBlank(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL"));
+ final CharBuffer s = StringUtils.defaultIfBlank(CharBuffer.wrap("abc"), CharBuffer.wrap("NULL"));
assertEquals("abc", s.toString());
}
@@ -1639,7 +1639,7 @@ public class StringUtilsTest {
assertEquals("short", StringUtils.abbreviate("short", 10));
assertEquals("Now is ...", StringUtils.abbreviate("Now is the time for all good men to come to the aid of their party.", 10));
- String raspberry = "raspberry peach";
+ final String raspberry = "raspberry peach";
assertEquals("raspberry p...", StringUtils.abbreviate(raspberry, 14));
assertEquals("raspberry peach", StringUtils.abbreviate("raspberry peach", 15));
assertEquals("raspberry peach", StringUtils.abbreviate("raspberry peach", 16));
@@ -1651,9 +1651,10 @@ public class StringUtilsTest {
try {
@SuppressWarnings("unused")
+ final
String res = StringUtils.abbreviate("abc", 3);
fail("StringUtils.abbreviate expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
}
@@ -1666,21 +1667,23 @@ public class StringUtilsTest {
try {
@SuppressWarnings("unused")
+ final
String res = StringUtils.abbreviate("abcdefghij", 0, 3);
fail("StringUtils.abbreviate expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
try {
@SuppressWarnings("unused")
+ final
String res = StringUtils.abbreviate("abcdefghij", 5, 6);
fail("StringUtils.abbreviate expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
- String raspberry = "raspberry peach";
+ final String raspberry = "raspberry peach";
assertEquals("raspberry peach", StringUtils.abbreviate(raspberry, 11, 15));
assertEquals(null, StringUtils.abbreviate(null, 7, 14));
@@ -1707,9 +1710,9 @@ public class StringUtilsTest {
}
private void assertAbbreviateWithOffset(final String expected, final int offset, final int maxWidth) {
- String abcdefghijklmno = "abcdefghijklmno";
- String message = "abbreviate(String,int,int) failed";
- String actual = StringUtils.abbreviate(abcdefghijklmno, offset, maxWidth);
+ final String abcdefghijklmno = "abcdefghijklmno";
+ final String message = "abbreviate(String,int,int) failed";
+ final String actual = StringUtils.abbreviate(abcdefghijklmno, offset, maxWidth);
if (offset >= 0 && offset < abcdefghijklmno.length()) {
assertTrue(message + " -- should contain offset character",
actual.indexOf((char)('a'+offset)) != -1);
@@ -1736,7 +1739,7 @@ public class StringUtilsTest {
"end to see if the text is complete.", "...", 50) );
// Test a much longer text :)
- String longText = "Start text" + StringUtils.repeat("x", 10000) + "Close text";
+ final String longText = "Start text" + StringUtils.repeat("x", 10000) + "Close text";
assertEquals(
"Start text->Close text",
StringUtils.abbreviateMiddle( longText, "->", 22 ) );
@@ -1803,16 +1806,18 @@ public class StringUtilsTest {
assertEquals(1, StringUtils.getLevenshteinDistance("hello", "hallo") );
try {
@SuppressWarnings("unused")
+ final
int d = StringUtils.getLevenshteinDistance("a", null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
try {
@SuppressWarnings("unused")
+ final
int d = StringUtils.getLevenshteinDistance(null, "a");
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
}
@@ -1875,24 +1880,27 @@ public class StringUtilsTest {
// exceptions
try {
@SuppressWarnings("unused")
+ final
int d = StringUtils.getLevenshteinDistance("a", null, 0);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
try {
@SuppressWarnings("unused")
+ final
int d = StringUtils.getLevenshteinDistance(null, "a", 0);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
try {
@SuppressWarnings("unused")
+ final
int d = StringUtils.getLevenshteinDistance("a", "a", -1);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// empty
}
}
@@ -2139,21 +2147,21 @@ public class StringUtilsTest {
// This test enforces that this is done.
@Test
public void testStringUtilsCharSequenceContract() {
- Class<StringUtils> c = StringUtils.class;
- Method[] methods = c.getMethods();
- for (Method m : methods) {
+ final Class<StringUtils> c = StringUtils.class;
+ final Method[] methods = c.getMethods();
+ for (final Method m : methods) {
if (m.getReturnType() == String.class || m.getReturnType() == String[].class) {
// Assume this is mutable and ensure the first parameter is not CharSequence.
// It may be String or it may be something else (String[], Object, Object[]) so
// don't actively test for that.
- Class<?>[] params = m.getParameterTypes();
+ final Class<?>[] params = m.getParameterTypes();
if ( params.length > 0 && (params[0] == CharSequence.class || params[0] == CharSequence[].class)) {
fail("The method " + m + " appears to be mutable in spirit and therefore must not accept a CharSequence");
}
} else {
// Assume this is immutable in spirit and ensure the first parameter is not String.
// As above, it may be something other than CharSequence.
- Class<?>[] params = m.getParameterTypes();
+ final Class<?>[] params = m.getParameterTypes();
if ( params.length > 0 && (params[0] == String.class || params[0] == String[].class)) {
fail("The method " + m + " appears to be immutable in spirit and therefore must not accept a String");
}
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java
index a5fc223e3..e020ee59f 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java
@@ -241,10 +241,10 @@ public class StringUtilsTrimEmptyTest {
@Test
public void testStripAll() {
// test stripAll method, merely an array version of the above strip
- String[] empty = new String[0];
- String[] fooSpace = new String[] { " "+FOO+" ", " "+FOO, FOO+" " };
- String[] fooDots = new String[] { ".."+FOO+"..", ".."+FOO, FOO+".." };
- String[] foo = new String[] { FOO, FOO, FOO };
+ final String[] empty = new String[0];
+ final String[] fooSpace = new String[] { " "+FOO+" ", " "+FOO, FOO+" " };
+ final String[] fooDots = new String[] { ".."+FOO+"..", ".."+FOO, FOO+".." };
+ final String[] foo = new String[] { FOO, FOO, FOO };
assertNull(StringUtils.stripAll((String[]) null));
// Additional varargs tests
@@ -261,10 +261,10 @@ public class StringUtilsTrimEmptyTest {
@Test
public void testStripAccents() {
- String cue = "\u00C7\u00FA\u00EA";
+ final String cue = "\u00C7\u00FA\u00EA";
assertEquals( "Failed to strip accents from " + cue, "Cue", StringUtils.stripAccents(cue));
- String lots = "\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C7\u00C8\u00C9" +
+ final String lots = "\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C7\u00C8\u00C9" +
"\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D1\u00D2\u00D3" +
"\u00D4\u00D5\u00D6\u00D9\u00DA\u00DB\u00DC\u00DD";
assertEquals( "Failed to strip accents from " + lots,
diff --git a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
index aabea579c..8622edb8c 100644
--- a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
@@ -42,7 +42,7 @@ public class SystemUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new SystemUtils());
- Constructor<?>[] cons = SystemUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = SystemUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(SystemUtils.class.getModifiers()));
@@ -54,7 +54,7 @@ public class SystemUtilsTest {
*/
@Test
public void testGetJavaHome() {
- File dir = SystemUtils.getJavaHome();
+ final File dir = SystemUtils.getJavaHome();
Assert.assertNotNull(dir);
Assert.assertTrue(dir.exists());
}
@@ -64,7 +64,7 @@ public class SystemUtilsTest {
*/
@Test
public void testGetJavaIoTmpDir() {
- File dir = SystemUtils.getJavaIoTmpDir();
+ final File dir = SystemUtils.getJavaIoTmpDir();
Assert.assertNotNull(dir);
Assert.assertTrue(dir.exists());
}
@@ -74,7 +74,7 @@ public class SystemUtilsTest {
*/
@Test
public void testGetUserDir() {
- File dir = SystemUtils.getUserDir();
+ final File dir = SystemUtils.getUserDir();
Assert.assertNotNull(dir);
Assert.assertTrue(dir.exists());
}
@@ -84,14 +84,14 @@ public class SystemUtilsTest {
*/
@Test
public void testGetUserHome() {
- File dir = SystemUtils.getUserHome();
+ final File dir = SystemUtils.getUserHome();
Assert.assertNotNull(dir);
Assert.assertTrue(dir.exists());
}
@Test
public void testIS_JAVA() {
- String javaVersion = System.getProperty("java.version");
+ final String javaVersion = System.getProperty("java.version");
if (javaVersion == null) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -155,7 +155,7 @@ public class SystemUtilsTest {
@Test
public void testIS_OS() {
- String osName = System.getProperty("os.name");
+ final String osName = System.getProperty("os.name");
if (osName == null) {
assertFalse(SystemUtils.IS_OS_WINDOWS);
assertFalse(SystemUtils.IS_OS_UNIX);
@@ -356,12 +356,12 @@ public class SystemUtilsTest {
@Test
public void testJavaAwtHeadless() {
- boolean atLeastJava14 = SystemUtils.isJavaVersionAtLeast(JAVA_1_4);
- String expectedStringValue = System.getProperty("java.awt.headless");
- String expectedStringValueWithDefault = System.getProperty("java.awt.headless", "false");
+ final boolean atLeastJava14 = SystemUtils.isJavaVersionAtLeast(JAVA_1_4);
+ final String expectedStringValue = System.getProperty("java.awt.headless");
+ final String expectedStringValueWithDefault = System.getProperty("java.awt.headless", "false");
assertNotNull(expectedStringValueWithDefault);
if (atLeastJava14) {
- boolean expectedValue = Boolean.valueOf(expectedStringValue).booleanValue();
+ final boolean expectedValue = Boolean.valueOf(expectedStringValue).booleanValue();
if (expectedStringValue != null) {
assertEquals(expectedStringValue, SystemUtils.JAVA_AWT_HEADLESS);
}
diff --git a/src/test/java/org/apache/commons/lang3/ValidateTest.java b/src/test/java/org/apache/commons/lang3/ValidateTest.java
index fec0eb6e4..a60a591af 100644
--- a/src/test/java/org/apache/commons/lang3/ValidateTest.java
+++ b/src/test/java/org/apache/commons/lang3/ValidateTest.java
@@ -51,7 +51,7 @@ public class ValidateTest {
try {
Validate.isTrue(false);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated expression is false", ex.getMessage());
}
}
@@ -63,7 +63,7 @@ public class ValidateTest {
try {
Validate.isTrue(false, "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
}
@@ -75,7 +75,7 @@ public class ValidateTest {
try {
Validate.isTrue(false, "MSG", 6);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
}
@@ -87,7 +87,7 @@ public class ValidateTest {
try {
Validate.isTrue(false, "MSG", 7);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
}
@@ -99,7 +99,7 @@ public class ValidateTest {
try {
Validate.isTrue(false, "MSG", 7.4d);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
}
@@ -112,12 +112,12 @@ public class ValidateTest {
try {
Validate.notNull(null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
- String str = "Hi";
- String testStr = Validate.notNull(str);
+ final String str = "Hi";
+ final String testStr = Validate.notNull(str);
assertSame(str, testStr);
}
@@ -128,12 +128,12 @@ public class ValidateTest {
try {
Validate.notNull(null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
- String str = "Hi";
- String testStr = Validate.notNull(str, "Message");
+ final String str = "Hi";
+ final String testStr = Validate.notNull(str, "Message");
assertSame(str, testStr);
}
@@ -145,18 +145,18 @@ public class ValidateTest {
try {
Validate.notEmpty((Object[]) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated array is empty", ex.getMessage());
}
try {
Validate.notEmpty(new Object[0]);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated array is empty", ex.getMessage());
}
- String[] array = new String[] {"hi"};
- String[] test = Validate.notEmpty(array);
+ final String[] array = new String[] {"hi"};
+ final String[] test = Validate.notEmpty(array);
assertSame(array, test);
}
@@ -167,18 +167,18 @@ public class ValidateTest {
try {
Validate.notEmpty((Object[]) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
Validate.notEmpty(new Object[0], "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
- String[] array = new String[] {"hi"};
- String[] test = Validate.notEmpty(array, "Message");
+ final String[] array = new String[] {"hi"};
+ final String[] test = Validate.notEmpty(array, "Message");
assertSame(array, test);
}
@@ -186,46 +186,46 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNotEmptyCollection1() {
- Collection<Integer> coll = new ArrayList<Integer>();
+ final Collection<Integer> coll = new ArrayList<Integer>();
try {
Validate.notEmpty((Collection<?>) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated collection is empty", ex.getMessage());
}
try {
Validate.notEmpty(coll);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated collection is empty", ex.getMessage());
}
coll.add(Integer.valueOf(8));
Validate.notEmpty(coll);
- Collection<Integer> test = Validate.notEmpty(coll);
+ final Collection<Integer> test = Validate.notEmpty(coll);
assertSame(coll, test);
}
//-----------------------------------------------------------------------
@Test
public void testNotEmptyCollection2() {
- Collection<Integer> coll = new ArrayList<Integer>();
+ final Collection<Integer> coll = new ArrayList<Integer>();
try {
Validate.notEmpty((Collection<?>) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
Validate.notEmpty(coll, "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
coll.add(Integer.valueOf(8));
Validate.notEmpty(coll, "MSG");
- Collection<Integer> test = Validate.notEmpty(coll, "Message");
+ final Collection<Integer> test = Validate.notEmpty(coll, "Message");
assertSame(coll, test);
}
@@ -233,46 +233,46 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNotEmptyMap1() {
- Map<String, Integer> map = new HashMap<String, Integer>();
+ final Map<String, Integer> map = new HashMap<String, Integer>();
try {
Validate.notEmpty((Map<?, ?>) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated map is empty", ex.getMessage());
}
try {
Validate.notEmpty(map);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated map is empty", ex.getMessage());
}
map.put("ll", Integer.valueOf(8));
Validate.notEmpty(map);
- Map<String, Integer> test = Validate.notEmpty(map);
+ final Map<String, Integer> test = Validate.notEmpty(map);
assertSame(map, test);
}
//-----------------------------------------------------------------------
@Test
public void testNotEmptyMap2() {
- Map<String, Integer> map = new HashMap<String, Integer>();
+ final Map<String, Integer> map = new HashMap<String, Integer>();
try {
Validate.notEmpty((Map<?, ?>) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
Validate.notEmpty(map, "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
map.put("ll", Integer.valueOf(8));
Validate.notEmpty(map, "MSG");
- Map<String, Integer> test = Validate.notEmpty(map, "Message");
+ final Map<String, Integer> test = Validate.notEmpty(map, "Message");
assertSame(map, test);
}
@@ -284,18 +284,18 @@ public class ValidateTest {
try {
Validate.notEmpty((String) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated character sequence is empty", ex.getMessage());
}
try {
Validate.notEmpty("");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated character sequence is empty", ex.getMessage());
}
- String str = "Hi";
- String testStr = Validate.notEmpty(str);
+ final String str = "Hi";
+ final String testStr = Validate.notEmpty(str);
assertSame(str, testStr);
}
@@ -306,18 +306,18 @@ public class ValidateTest {
try {
Validate.notEmpty((String) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("MSG", ex.getMessage());
}
try {
Validate.notEmpty("", "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
- String str = "Hi";
- String testStr = Validate.notEmpty(str, "Message");
+ final String str = "Hi";
+ final String testStr = Validate.notEmpty(str, "Message");
assertSame(str, testStr);
}
@@ -326,13 +326,13 @@ public class ValidateTest {
@Test
public void testNotBlankNullStringShouldThrow() {
//given
- String string = null;
+ final String string = null;
try {
//when
Validate.notBlank(string);
fail("Expecting NullPointerException");
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
@@ -342,13 +342,13 @@ public class ValidateTest {
@Test
public void testNotBlankMsgNullStringShouldThrow() {
//given
- String string = null;
+ final String string = null;
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting NullPointerException");
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
//then
assertEquals("Message", e.getMessage());
}
@@ -358,13 +358,13 @@ public class ValidateTest {
@Test
public void testNotBlankEmptyStringShouldThrow() {
//given
- String string = "";
+ final String string = "";
try {
//when
Validate.notBlank(string);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
@@ -374,13 +374,13 @@ public class ValidateTest {
@Test
public void testNotBlankBlankStringWithWhitespacesShouldThrow() {
//given
- String string = " ";
+ final String string = " ";
try {
//when
Validate.notBlank(string);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
@@ -390,13 +390,13 @@ public class ValidateTest {
@Test
public void testNotBlankBlankStringWithNewlinesShouldThrow() {
//given
- String string = " \n \t \r \n ";
+ final String string = " \n \t \r \n ";
try {
//when
Validate.notBlank(string);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("The validated character sequence is blank", e.getMessage());
}
@@ -406,13 +406,13 @@ public class ValidateTest {
@Test
public void testNotBlankMsgBlankStringShouldThrow() {
//given
- String string = " \n \t \r \n ";
+ final String string = " \n \t \r \n ";
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("Message", e.getMessage());
}
@@ -422,13 +422,13 @@ public class ValidateTest {
@Test
public void testNotBlankMsgBlankStringWithWhitespacesShouldThrow() {
//given
- String string = " ";
+ final String string = " ";
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("Message", e.getMessage());
}
@@ -438,13 +438,13 @@ public class ValidateTest {
@Test
public void testNotBlankMsgEmptyStringShouldThrow() {
//given
- String string = "";
+ final String string = "";
try {
//when
Validate.notBlank(string, "Message");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
//then
assertEquals("Message", e.getMessage());
}
@@ -454,7 +454,7 @@ public class ValidateTest {
@Test
public void testNotBlankNotBlankStringShouldNotThrow() {
//given
- String string = "abc";
+ final String string = "abc";
//when
Validate.notBlank(string);
@@ -466,7 +466,7 @@ public class ValidateTest {
@Test
public void testNotBlankNotBlankStringWithWhitespacesShouldNotThrow() {
//given
- String string = " abc ";
+ final String string = " abc ";
//when
Validate.notBlank(string);
@@ -478,7 +478,7 @@ public class ValidateTest {
@Test
public void testNotBlankNotBlankStringWithNewlinesShouldNotThrow() {
//given
- String string = " \n \t abc \r \n ";
+ final String string = " \n \t abc \r \n ";
//when
Validate.notBlank(string);
@@ -490,7 +490,7 @@ public class ValidateTest {
@Test
public void testNotBlankMsgNotBlankStringShouldNotThrow() {
//given
- String string = "abc";
+ final String string = "abc";
//when
Validate.notBlank(string, "Message");
@@ -502,7 +502,7 @@ public class ValidateTest {
@Test
public void testNotBlankMsgNotBlankStringWithWhitespacesShouldNotThrow() {
//given
- String string = " abc ";
+ final String string = " abc ";
//when
Validate.notBlank(string, "Message");
@@ -514,7 +514,7 @@ public class ValidateTest {
@Test
public void testNotBlankMsgNotBlankStringWithNewlinesShouldNotThrow() {
//given
- String string = " \n \t abc \r \n ";
+ final String string = " \n \t abc \r \n ";
//when
Validate.notBlank(string, "Message");
@@ -525,15 +525,15 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNotBlankReturnValues1() {
- String str = "Hi";
- String test = Validate.notBlank(str);
+ final String str = "Hi";
+ final String test = Validate.notBlank(str);
assertSame(str, test);
}
@Test
public void testNotBlankReturnValues2() {
- String str = "Hi";
- String test = Validate.notBlank(str, "Message");
+ final String str = "Hi";
+ final String test = Validate.notBlank(str, "Message");
assertSame(str, test);
}
@@ -546,19 +546,19 @@ public class ValidateTest {
try {
Validate.noNullElements((Object[]) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
array[1] = null;
try {
Validate.noNullElements(array);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated array contains null element at index: 1", ex.getMessage());
}
array = new String[] {"a", "b"};
- String[] test = Validate.noNullElements(array);
+ final String[] test = Validate.noNullElements(array);
assertSame(array, test);
}
@@ -570,19 +570,19 @@ public class ValidateTest {
try {
Validate.noNullElements((Object[]) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
array[1] = null;
try {
Validate.noNullElements(array, "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
array = new String[] {"a", "b"};
- String[] test = Validate.noNullElements(array, "Message");
+ final String[] test = Validate.noNullElements(array, "Message");
assertSame(array, test);
}
@@ -590,52 +590,52 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNoNullElementsCollection1() {
- List<String> coll = new ArrayList<String>();
+ final List<String> coll = new ArrayList<String>();
coll.add("a");
coll.add("b");
Validate.noNullElements(coll);
try {
Validate.noNullElements((Collection<?>) null);
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
coll.set(1, null);
try {
Validate.noNullElements(coll);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("The validated collection contains null element at index: 1", ex.getMessage());
}
coll.set(1, "b");
- List<String> test = Validate.noNullElements(coll);
+ final List<String> test = Validate.noNullElements(coll);
assertSame(coll, test);
}
//-----------------------------------------------------------------------
@Test
public void testNoNullElementsCollection2() {
- List<String> coll = new ArrayList<String>();
+ final List<String> coll = new ArrayList<String>();
coll.add("a");
coll.add("b");
Validate.noNullElements(coll, "MSG");
try {
Validate.noNullElements((Collection<?>) null, "MSG");
fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
assertEquals("The validated object is null", ex.getMessage());
}
coll.set(1, null);
try {
Validate.noNullElements(coll, "MSG");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
assertEquals("MSG", ex.getMessage());
}
coll.set(1, "b");
- List<String> test = Validate.noNullElements(coll, "Message");
+ final List<String> test = Validate.noNullElements(coll, "Message");
assertSame(coll, test);
}
@@ -644,7 +644,7 @@ public class ValidateTest {
@Test
public void testConstructor() {
assertNotNull(new Validate());
- Constructor<?>[] cons = Validate.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = Validate.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(Validate.class.getModifiers()));
@@ -655,47 +655,47 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testValidIndex_withMessage_array() {
- Object[] array = new Object[2];
+ final Object[] array = new Object[2];
Validate.validIndex(array, 0, "Broken: ");
Validate.validIndex(array, 1, "Broken: ");
try {
Validate.validIndex(array, -1, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
try {
Validate.validIndex(array, 2, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
- String[] strArray = new String[] {"Hi"};
- String[] test = Validate.noNullElements(strArray, "Message");
+ final String[] strArray = new String[] {"Hi"};
+ final String[] test = Validate.noNullElements(strArray, "Message");
assertSame(strArray, test);
}
@Test
public void testValidIndex_array() {
- Object[] array = new Object[2];
+ final Object[] array = new Object[2];
Validate.validIndex(array, 0);
Validate.validIndex(array, 1);
try {
Validate.validIndex(array, -1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated array index is invalid: -1", ex.getMessage());
}
try {
Validate.validIndex(array, 2);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated array index is invalid: 2", ex.getMessage());
}
- String[] strArray = new String[] {"Hi"};
- String[] test = Validate.noNullElements(strArray);
+ final String[] strArray = new String[] {"Hi"};
+ final String[] test = Validate.noNullElements(strArray);
assertSame(strArray, test);
}
@@ -703,7 +703,7 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testValidIndex_withMessage_collection() {
- Collection<String> coll = new ArrayList<String>();
+ final Collection<String> coll = new ArrayList<String>();
coll.add(null);
coll.add(null);
Validate.validIndex(coll, 0, "Broken: ");
@@ -711,24 +711,24 @@ public class ValidateTest {
try {
Validate.validIndex(coll, -1, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
try {
Validate.validIndex(coll, 2, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
- List<String> strColl = Arrays.asList(new String[] {"Hi"});
- List<String> test = Validate.validIndex(strColl, 0, "Message");
+ final List<String> strColl = Arrays.asList(new String[] {"Hi"});
+ final List<String> test = Validate.validIndex(strColl, 0, "Message");
assertSame(strColl, test);
}
@Test
public void testValidIndex_collection() {
- Collection<String> coll = new ArrayList<String>();
+ final Collection<String> coll = new ArrayList<String>();
coll.add(null);
coll.add(null);
Validate.validIndex(coll, 0);
@@ -736,18 +736,18 @@ public class ValidateTest {
try {
Validate.validIndex(coll, -1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated collection index is invalid: -1", ex.getMessage());
}
try {
Validate.validIndex(coll, 2);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated collection index is invalid: 2", ex.getMessage());
}
- List<String> strColl = Arrays.asList(new String[] {"Hi"});
- List<String> test = Validate.validIndex(strColl, 0);
+ final List<String> strColl = Arrays.asList(new String[] {"Hi"});
+ final List<String> test = Validate.validIndex(strColl, 0);
assertSame(strColl, test);
}
@@ -755,61 +755,61 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testValidIndex_withMessage_charSequence() {
- CharSequence str = "Hi";
+ final CharSequence str = "Hi";
Validate.validIndex(str, 0, "Broken: ");
Validate.validIndex(str, 1, "Broken: ");
try {
Validate.validIndex(str, -1, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
try {
Validate.validIndex(str, 2, "Broken: ");
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("Broken: ", ex.getMessage());
}
- String input = "Hi";
- String test = Validate.validIndex(input, 0, "Message");
+ final String input = "Hi";
+ final String test = Validate.validIndex(input, 0, "Message");
assertSame(input, test);
}
@Test
public void testValidIndex_charSequence() {
- CharSequence str = "Hi";
+ final CharSequence str = "Hi";
Validate.validIndex(str, 0);
Validate.validIndex(str, 1);
try {
Validate.validIndex(str, -1);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated character sequence index is invalid: -1", ex.getMessage());
}
try {
Validate.validIndex(str, 2);
fail("Expecting IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException ex) {
+ } catch (final IndexOutOfBoundsException ex) {
assertEquals("The validated character sequence index is invalid: 2", ex.getMessage());
}
- String input = "Hi";
- String test = Validate.validIndex(input, 0);
+ final String input = "Hi";
+ final String test = Validate.validIndex(input, 0);
assertSame(input, test);
}
@Test
public void testMatchesPattern()
{
- CharSequence str = "hi";
+ final CharSequence str = "hi";
Validate.matchesPattern(str, "[a-z]*");
try
{
Validate.matchesPattern(str, "[0-9]*");
fail("Expecting IllegalArgumentException");
}
- catch (IllegalArgumentException e)
+ catch (final IllegalArgumentException e)
{
assertEquals("The string hi does not match the pattern [0-9]*", e.getMessage());
}
@@ -818,14 +818,14 @@ public class ValidateTest {
@Test
public void testMatchesPattern_withMessage()
{
- CharSequence str = "hi";
+ final CharSequence str = "hi";
Validate.matchesPattern(str, "[a-z]*", "Does not match");
try
{
Validate.matchesPattern(str, "[0-9]*", "Does not match");
fail("Expecting IllegalArgumentException");
}
- catch (IllegalArgumentException e)
+ catch (final IllegalArgumentException e)
{
assertEquals("Does not match", e.getMessage());
}
@@ -840,7 +840,7 @@ public class ValidateTest {
try {
Validate.inclusiveBetween(0, 5, 6);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("The value 6 is not in the specified inclusive range of 0 to 5", e.getMessage());
}
}
@@ -854,7 +854,7 @@ public class ValidateTest {
try {
Validate.inclusiveBetween(0, 5, 6, "Error");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
}
@@ -867,13 +867,13 @@ public class ValidateTest {
try {
Validate.exclusiveBetween(0, 5, 6);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("The value 6 is not in the specified exclusive range of 0 to 5", e.getMessage());
}
try {
Validate.exclusiveBetween(0, 5, 5);
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("The value 5 is not in the specified exclusive range of 0 to 5", e.getMessage());
}
}
@@ -886,13 +886,13 @@ public class ValidateTest {
try {
Validate.exclusiveBetween(0, 5, 6, "Error");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
try {
Validate.exclusiveBetween(0, 5, 5, "Error");
fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
}
@@ -908,7 +908,7 @@ public class ValidateTest {
try {
Validate.isInstanceOf(List.class, "hi");
fail("Expecting IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("Expected type: java.util.List, actual: java.lang.String", e.getMessage());
}
}
@@ -920,7 +920,7 @@ public class ValidateTest {
try {
Validate.isInstanceOf(List.class, "hi", "Error");
fail("Expecting IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
}
@@ -936,7 +936,7 @@ public class ValidateTest {
try {
Validate.isAssignableFrom(List.class, String.class);
fail("Expecting IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("Cannot assign a java.lang.String to a java.util.List", e.getMessage());
}
}
@@ -948,7 +948,7 @@ public class ValidateTest {
try {
Validate.isAssignableFrom(List.class, String.class, "Error");
fail("Expecting IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
index de88ade96..294e50c48 100644
--- a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
@@ -45,7 +45,7 @@ public class CompareToBuilderTest {
if (!(o instanceof TestObject)) {
return false;
}
- TestObject rhs = (TestObject) o;
+ final TestObject rhs = (TestObject) o;
return a == rhs.a;
}
@@ -84,7 +84,7 @@ public class CompareToBuilderTest {
if (!(o instanceof TestSubObject)) {
return false;
}
- TestSubObject rhs = (TestSubObject) o;
+ final TestSubObject rhs = (TestSubObject) o;
return super.equals(o) && b == rhs.b;
}
}
@@ -100,8 +100,8 @@ public class CompareToBuilderTest {
@Test
public void testReflectionCompare() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(4);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(4);
assertTrue(CompareToBuilder.reflectionCompare(o1, o1) == 0);
assertTrue(CompareToBuilder.reflectionCompare(o1, o2) == 0);
o2.setA(5);
@@ -111,14 +111,14 @@ public class CompareToBuilderTest {
@Test(expected=NullPointerException.class)
public void testReflectionCompareEx1() {
- TestObject o1 = new TestObject(4);
+ final TestObject o1 = new TestObject(4);
CompareToBuilder.reflectionCompare(o1, null);
}
@Test(expected=ClassCastException.class)
public void testReflectionCompareEx2() {
- TestObject o1 = new TestObject(4);
- Object o2 = new Object();
+ final TestObject o1 = new TestObject(4);
+ final Object o2 = new Object();
CompareToBuilder.reflectionCompare(o1, o2);
}
@@ -129,7 +129,7 @@ public class CompareToBuilderTest {
@Test
public void testReflectionHierarchyCompareExcludeFields() {
- String[] excludeFields = new String[] { "b" };
+ final String[] excludeFields = new String[] { "b" };
testReflectionHierarchyCompare(true, excludeFields);
TestSubObject x;
@@ -181,12 +181,12 @@ public class CompareToBuilderTest {
}
private void testReflectionHierarchyCompare(final boolean testTransients, final String[] excludeFields) {
- TestObject to1 = new TestObject(1);
- TestObject to2 = new TestObject(2);
- TestObject to3 = new TestObject(3);
- TestSubObject tso1 = new TestSubObject(1, 1);
- TestSubObject tso2 = new TestSubObject(2, 2);
- TestSubObject tso3 = new TestSubObject(3, 3);
+ final TestObject to1 = new TestObject(1);
+ final TestObject to2 = new TestObject(2);
+ final TestObject to3 = new TestObject(3);
+ final TestSubObject tso1 = new TestSubObject(1, 1);
+ final TestSubObject tso2 = new TestSubObject(2, 2);
+ final TestSubObject tso3 = new TestSubObject(3, 3);
assertReflectionCompareContract(to1, to1, to1, false, excludeFields);
assertReflectionCompareContract(to1, to2, to3, false, excludeFields);
@@ -248,8 +248,8 @@ public class CompareToBuilderTest {
@Test
public void testAppendSuper() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(5);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(5);
assertTrue(new CompareToBuilder().appendSuper(0).append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().appendSuper(0).append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().appendSuper(0).append(o2, o1).toComparison() > 0);
@@ -263,8 +263,8 @@ public class CompareToBuilderTest {
@Test
public void testObject() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(4);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(4);
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() == 0);
o2.setA(5);
@@ -278,8 +278,8 @@ public class CompareToBuilderTest {
@Test
public void testObjectBuild() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(4);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(4);
assertEquals(Integer.valueOf(0), new CompareToBuilder().append(o1, o1).build());
assertEquals(Integer.valueOf(0), new CompareToBuilder().append(o1, o2).build());
o2.setA(5);
@@ -293,14 +293,14 @@ public class CompareToBuilderTest {
@Test(expected=ClassCastException.class)
public void testObjectEx2() {
- TestObject o1 = new TestObject(4);
- Object o2 = new Object();
+ final TestObject o1 = new TestObject(4);
+ final Object o2 = new Object();
new CompareToBuilder().append(o1, o2);
}
@Test
public void testObjectComparator() {
- String o1 = "Fred";
+ final String o1 = "Fred";
String o2 = "Fred";
assertTrue(new CompareToBuilder().append(o1, o1, String.CASE_INSENSITIVE_ORDER).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2, String.CASE_INSENSITIVE_ORDER).toComparison() == 0);
@@ -318,7 +318,7 @@ public class CompareToBuilderTest {
@Test
public void testObjectComparatorNull() {
- String o1 = "Fred";
+ final String o1 = "Fred";
String o2 = "Fred";
assertTrue(new CompareToBuilder().append(o1, o1, null).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2, null).toComparison() == 0);
@@ -333,8 +333,8 @@ public class CompareToBuilderTest {
@Test
public void testLong() {
- long o1 = 1L;
- long o2 = 2L;
+ final long o1 = 1L;
+ final long o2 = 2L;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -346,8 +346,8 @@ public class CompareToBuilderTest {
@Test
public void testInt() {
- int o1 = 1;
- int o2 = 2;
+ final int o1 = 1;
+ final int o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -359,8 +359,8 @@ public class CompareToBuilderTest {
@Test
public void testShort() {
- short o1 = 1;
- short o2 = 2;
+ final short o1 = 1;
+ final short o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -372,8 +372,8 @@ public class CompareToBuilderTest {
@Test
public void testChar() {
- char o1 = 1;
- char o2 = 2;
+ final char o1 = 1;
+ final char o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -385,8 +385,8 @@ public class CompareToBuilderTest {
@Test
public void testByte() {
- byte o1 = 1;
- byte o2 = 2;
+ final byte o1 = 1;
+ final byte o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -398,8 +398,8 @@ public class CompareToBuilderTest {
@Test
public void testDouble() {
- double o1 = 1;
- double o2 = 2;
+ final double o1 = 1;
+ final double o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -419,8 +419,8 @@ public class CompareToBuilderTest {
@Test
public void testFloat() {
- float o1 = 1;
- float o2 = 2;
+ final float o1 = 1;
+ final float o2 = 2;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0);
assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0);
@@ -440,8 +440,8 @@ public class CompareToBuilderTest {
@Test
public void testBoolean() {
- boolean o1 = true;
- boolean o2 = false;
+ final boolean o1 = true;
+ final boolean o2 = false;
assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o2, o2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(o1, o2).toComparison() > 0);
@@ -450,13 +450,13 @@ public class CompareToBuilderTest {
@Test
public void testObjectArray() {
- TestObject[] obj1 = new TestObject[2];
+ final TestObject[] obj1 = new TestObject[2];
obj1[0] = new TestObject(4);
obj1[1] = new TestObject(5);
- TestObject[] obj2 = new TestObject[2];
+ final TestObject[] obj2 = new TestObject[2];
obj2[0] = new TestObject(4);
obj2[1] = new TestObject(5);
- TestObject[] obj3 = new TestObject[3];
+ final TestObject[] obj3 = new TestObject[3];
obj3[0] = new TestObject(4);
obj3[1] = new TestObject(5);
obj3[2] = new TestObject(6);
@@ -477,13 +477,13 @@ public class CompareToBuilderTest {
@Test
public void testLongArray() {
- long[] obj1 = new long[2];
+ final long[] obj1 = new long[2];
obj1[0] = 5L;
obj1[1] = 6L;
- long[] obj2 = new long[2];
+ final long[] obj2 = new long[2];
obj2[0] = 5L;
obj2[1] = 6L;
- long[] obj3 = new long[3];
+ final long[] obj3 = new long[3];
obj3[0] = 5L;
obj3[1] = 6L;
obj3[2] = 7L;
@@ -504,13 +504,13 @@ public class CompareToBuilderTest {
@Test
public void testIntArray() {
- int[] obj1 = new int[2];
+ final int[] obj1 = new int[2];
obj1[0] = 5;
obj1[1] = 6;
- int[] obj2 = new int[2];
+ final int[] obj2 = new int[2];
obj2[0] = 5;
obj2[1] = 6;
- int[] obj3 = new int[3];
+ final int[] obj3 = new int[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -531,13 +531,13 @@ public class CompareToBuilderTest {
@Test
public void testShortArray() {
- short[] obj1 = new short[2];
+ final short[] obj1 = new short[2];
obj1[0] = 5;
obj1[1] = 6;
- short[] obj2 = new short[2];
+ final short[] obj2 = new short[2];
obj2[0] = 5;
obj2[1] = 6;
- short[] obj3 = new short[3];
+ final short[] obj3 = new short[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -558,13 +558,13 @@ public class CompareToBuilderTest {
@Test
public void testCharArray() {
- char[] obj1 = new char[2];
+ final char[] obj1 = new char[2];
obj1[0] = 5;
obj1[1] = 6;
- char[] obj2 = new char[2];
+ final char[] obj2 = new char[2];
obj2[0] = 5;
obj2[1] = 6;
- char[] obj3 = new char[3];
+ final char[] obj3 = new char[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -585,13 +585,13 @@ public class CompareToBuilderTest {
@Test
public void testByteArray() {
- byte[] obj1 = new byte[2];
+ final byte[] obj1 = new byte[2];
obj1[0] = 5;
obj1[1] = 6;
- byte[] obj2 = new byte[2];
+ final byte[] obj2 = new byte[2];
obj2[0] = 5;
obj2[1] = 6;
- byte[] obj3 = new byte[3];
+ final byte[] obj3 = new byte[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -612,13 +612,13 @@ public class CompareToBuilderTest {
@Test
public void testDoubleArray() {
- double[] obj1 = new double[2];
+ final double[] obj1 = new double[2];
obj1[0] = 5;
obj1[1] = 6;
- double[] obj2 = new double[2];
+ final double[] obj2 = new double[2];
obj2[0] = 5;
obj2[1] = 6;
- double[] obj3 = new double[3];
+ final double[] obj3 = new double[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -639,13 +639,13 @@ public class CompareToBuilderTest {
@Test
public void testFloatArray() {
- float[] obj1 = new float[2];
+ final float[] obj1 = new float[2];
obj1[0] = 5;
obj1[1] = 6;
- float[] obj2 = new float[2];
+ final float[] obj2 = new float[2];
obj2[0] = 5;
obj2[1] = 6;
- float[] obj3 = new float[3];
+ final float[] obj3 = new float[3];
obj3[0] = 5;
obj3[1] = 6;
obj3[2] = 7;
@@ -666,13 +666,13 @@ public class CompareToBuilderTest {
@Test
public void testBooleanArray() {
- boolean[] obj1 = new boolean[2];
+ final boolean[] obj1 = new boolean[2];
obj1[0] = true;
obj1[1] = false;
- boolean[] obj2 = new boolean[2];
+ final boolean[] obj2 = new boolean[2];
obj2[0] = true;
obj2[1] = false;
- boolean[] obj3 = new boolean[3];
+ final boolean[] obj3 = new boolean[3];
obj3[0] = true;
obj3[1] = false;
obj3[2] = true;
@@ -693,9 +693,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiLongArray() {
- long[][] array1 = new long[2][2];
- long[][] array2 = new long[2][2];
- long[][] array3 = new long[2][3];
+ final long[][] array1 = new long[2][2];
+ final long[][] array2 = new long[2][2];
+ final long[][] array3 = new long[2][3];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -717,9 +717,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiIntArray() {
- int[][] array1 = new int[2][2];
- int[][] array2 = new int[2][2];
- int[][] array3 = new int[2][3];
+ final int[][] array1 = new int[2][2];
+ final int[][] array2 = new int[2][2];
+ final int[][] array3 = new int[2][3];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -741,9 +741,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiShortArray() {
- short[][] array1 = new short[2][2];
- short[][] array2 = new short[2][2];
- short[][] array3 = new short[2][3];
+ final short[][] array1 = new short[2][2];
+ final short[][] array2 = new short[2][2];
+ final short[][] array3 = new short[2][3];
for (short i = 0; i < array1.length; ++i) {
for (short j = 0; j < array1[0].length; j++) {
array1[i][j] = (short)((i + 1) * (j + 1));
@@ -765,9 +765,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiCharArray() {
- char[][] array1 = new char[2][2];
- char[][] array2 = new char[2][2];
- char[][] array3 = new char[2][3];
+ final char[][] array1 = new char[2][2];
+ final char[][] array2 = new char[2][2];
+ final char[][] array3 = new char[2][3];
for (short i = 0; i < array1.length; ++i) {
for (short j = 0; j < array1[0].length; j++) {
array1[i][j] = (char)((i + 1) * (j + 1));
@@ -789,9 +789,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiByteArray() {
- byte[][] array1 = new byte[2][2];
- byte[][] array2 = new byte[2][2];
- byte[][] array3 = new byte[2][3];
+ final byte[][] array1 = new byte[2][2];
+ final byte[][] array2 = new byte[2][2];
+ final byte[][] array3 = new byte[2][3];
for (byte i = 0; i < array1.length; ++i) {
for (byte j = 0; j < array1[0].length; j++) {
array1[i][j] = (byte)((i + 1) * (j + 1));
@@ -813,9 +813,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiFloatArray() {
- float[][] array1 = new float[2][2];
- float[][] array2 = new float[2][2];
- float[][] array3 = new float[2][3];
+ final float[][] array1 = new float[2][2];
+ final float[][] array2 = new float[2][2];
+ final float[][] array3 = new float[2][3];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -837,9 +837,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiDoubleArray() {
- double[][] array1 = new double[2][2];
- double[][] array2 = new double[2][2];
- double[][] array3 = new double[2][3];
+ final double[][] array1 = new double[2][2];
+ final double[][] array2 = new double[2][2];
+ final double[][] array3 = new double[2][3];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -861,9 +861,9 @@ public class CompareToBuilderTest {
@Test
public void testMultiBooleanArray() {
- boolean[][] array1 = new boolean[2][2];
- boolean[][] array2 = new boolean[2][2];
- boolean[][] array3 = new boolean[2][3];
+ final boolean[][] array1 = new boolean[2][2];
+ final boolean[][] array2 = new boolean[2][2];
+ final boolean[][] array3 = new boolean[2][3];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = i == 1 ^ j == 1;
@@ -885,9 +885,9 @@ public class CompareToBuilderTest {
@Test
public void testRaggedArray() {
- long array1[][] = new long[2][];
- long array2[][] = new long[2][];
- long array3[][] = new long[3][];
+ final long array1[][] = new long[2][];
+ final long array2[][] = new long[2][];
+ final long array3[][] = new long[3][];
for (int i = 0; i < array1.length; ++i) {
array1[i] = new long[2];
array2[i] = new long[2];
@@ -913,9 +913,9 @@ public class CompareToBuilderTest {
@Test
public void testMixedArray() {
- Object array1[] = new Object[2];
- Object array2[] = new Object[2];
- Object array3[] = new Object[2];
+ final Object array1[] = new Object[2];
+ final Object array2[] = new Object[2];
+ final Object array3[] = new Object[2];
for (int i = 0; i < array1.length; ++i) {
array1[i] = new long[2];
array2[i] = new long[2];
@@ -939,20 +939,20 @@ public class CompareToBuilderTest {
@Test
public void testObjectArrayHiddenByObject() {
- TestObject[] array1 = new TestObject[2];
+ final TestObject[] array1 = new TestObject[2];
array1[0] = new TestObject(4);
array1[1] = new TestObject(5);
- TestObject[] array2 = new TestObject[2];
+ final TestObject[] array2 = new TestObject[2];
array2[0] = new TestObject(4);
array2[1] = new TestObject(5);
- TestObject[] array3 = new TestObject[3];
+ final TestObject[] array3 = new TestObject[3];
array3[0] = new TestObject(4);
array3[1] = new TestObject(5);
array3[2] = new TestObject(6);
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
@@ -966,19 +966,19 @@ public class CompareToBuilderTest {
@Test
public void testLongArrayHiddenByObject() {
- long[] array1 = new long[2];
+ final long[] array1 = new long[2];
array1[0] = 5L;
array1[1] = 6L;
- long[] array2 = new long[2];
+ final long[] array2 = new long[2];
array2[0] = 5L;
array2[1] = 6L;
- long[] array3 = new long[3];
+ final long[] array3 = new long[3];
array3[0] = 5L;
array3[1] = 6L;
array3[2] = 7L;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -991,19 +991,19 @@ public class CompareToBuilderTest {
@Test
public void testIntArrayHiddenByObject() {
- int[] array1 = new int[2];
+ final int[] array1 = new int[2];
array1[0] = 5;
array1[1] = 6;
- int[] array2 = new int[2];
+ final int[] array2 = new int[2];
array2[0] = 5;
array2[1] = 6;
- int[] array3 = new int[3];
+ final int[] array3 = new int[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1016,19 +1016,19 @@ public class CompareToBuilderTest {
@Test
public void testShortArrayHiddenByObject() {
- short[] array1 = new short[2];
+ final short[] array1 = new short[2];
array1[0] = 5;
array1[1] = 6;
- short[] array2 = new short[2];
+ final short[] array2 = new short[2];
array2[0] = 5;
array2[1] = 6;
- short[] array3 = new short[3];
+ final short[] array3 = new short[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1041,19 +1041,19 @@ public class CompareToBuilderTest {
@Test
public void testCharArrayHiddenByObject() {
- char[] array1 = new char[2];
+ final char[] array1 = new char[2];
array1[0] = 5;
array1[1] = 6;
- char[] array2 = new char[2];
+ final char[] array2 = new char[2];
array2[0] = 5;
array2[1] = 6;
- char[] array3 = new char[3];
+ final char[] array3 = new char[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1066,19 +1066,19 @@ public class CompareToBuilderTest {
@Test
public void testByteArrayHiddenByObject() {
- byte[] array1 = new byte[2];
+ final byte[] array1 = new byte[2];
array1[0] = 5;
array1[1] = 6;
- byte[] array2 = new byte[2];
+ final byte[] array2 = new byte[2];
array2[0] = 5;
array2[1] = 6;
- byte[] array3 = new byte[3];
+ final byte[] array3 = new byte[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1091,19 +1091,19 @@ public class CompareToBuilderTest {
@Test
public void testDoubleArrayHiddenByObject() {
- double[] array1 = new double[2];
+ final double[] array1 = new double[2];
array1[0] = 5;
array1[1] = 6;
- double[] array2 = new double[2];
+ final double[] array2 = new double[2];
array2[0] = 5;
array2[1] = 6;
- double[] array3 = new double[3];
+ final double[] array3 = new double[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1116,19 +1116,19 @@ public class CompareToBuilderTest {
@Test
public void testFloatArrayHiddenByObject() {
- float[] array1 = new float[2];
+ final float[] array1 = new float[2];
array1[0] = 5;
array1[1] = 6;
- float[] array2 = new float[2];
+ final float[] array2 = new float[2];
array2[0] = 5;
array2[1] = 6;
- float[] array3 = new float[3];
+ final float[] array3 = new float[3];
array3[0] = 5;
array3[1] = 6;
array3[2] = 7;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
@@ -1141,19 +1141,19 @@ public class CompareToBuilderTest {
@Test
public void testBooleanArrayHiddenByObject() {
- boolean[] array1 = new boolean[2];
+ final boolean[] array1 = new boolean[2];
array1[0] = true;
array1[1] = false;
- boolean[] array2 = new boolean[2];
+ final boolean[] array2 = new boolean[2];
array2[0] = true;
array2[1] = false;
- boolean[] array3 = new boolean[3];
+ final boolean[] array3 = new boolean[3];
array3[0] = true;
array3[1] = false;
array3[2] = true;
- Object obj1 = array1;
- Object obj2 = array2;
- Object obj3 = array3;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
+ final Object obj3 = array3;
assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0);
assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0);
diff --git a/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java
index d1310d6ad..e1511b7b1 100644
--- a/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java
@@ -65,8 +65,8 @@ public class DefaultToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -83,11 +83,11 @@ public class DefaultToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "John Doe";
p.age = 33;
p.smoker = false;
- String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
+ final String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
assertEquals(pBaseStr + "[name=John Doe,age=33,smoker=false]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
index 7c9fb4cde..a708af837 100644
--- a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
@@ -49,7 +49,7 @@ public class EqualsBuilderTest {
return false;
}
- TestObject rhs = (TestObject) o;
+ final TestObject rhs = (TestObject) o;
return a == rhs.a;
}
@@ -84,7 +84,7 @@ public class EqualsBuilderTest {
return false;
}
- TestSubObject rhs = (TestSubObject) o;
+ final TestSubObject rhs = (TestSubObject) o;
return super.equals(o) && b == rhs.b;
}
@@ -150,8 +150,8 @@ public class EqualsBuilderTest {
@Test
public void testReflectionEquals() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(5);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(5);
assertTrue(EqualsBuilder.reflectionEquals(o1, o1));
assertTrue(!EqualsBuilder.reflectionEquals(o1, o2));
o2.setA(4);
@@ -177,18 +177,18 @@ public class EqualsBuilderTest {
}
private void testReflectionHierarchyEquals(final boolean testTransients) {
- TestObject to1 = new TestObject(4);
- TestObject to1Bis = new TestObject(4);
- TestObject to1Ter = new TestObject(4);
- TestObject to2 = new TestObject(5);
- TestEmptySubObject teso = new TestEmptySubObject(4);
- TestTSubObject ttso = new TestTSubObject(4, 1);
- TestTTSubObject tttso = new TestTTSubObject(4, 1, 2);
- TestTTLeafObject ttlo = new TestTTLeafObject(4, 1, 2, 3);
- TestSubObject tso1 = new TestSubObject(1, 4);
- TestSubObject tso1bis = new TestSubObject(1, 4);
- TestSubObject tso1ter = new TestSubObject(1, 4);
- TestSubObject tso2 = new TestSubObject(2, 5);
+ final TestObject to1 = new TestObject(4);
+ final TestObject to1Bis = new TestObject(4);
+ final TestObject to1Ter = new TestObject(4);
+ final TestObject to2 = new TestObject(5);
+ final TestEmptySubObject teso = new TestEmptySubObject(4);
+ final TestTSubObject ttso = new TestTSubObject(4, 1);
+ final TestTTSubObject tttso = new TestTTSubObject(4, 1, 2);
+ final TestTTLeafObject ttlo = new TestTTLeafObject(4, 1, 2, 3);
+ final TestSubObject tso1 = new TestSubObject(1, 4);
+ final TestSubObject tso1bis = new TestSubObject(1, 4);
+ final TestSubObject tso1ter = new TestSubObject(1, 4);
+ final TestSubObject tso2 = new TestSubObject(2, 5);
testReflectionEqualsEquivalenceRelationship(to1, to1Bis, to1Ter, to2, new TestObject(), testTransients);
testReflectionEqualsEquivalenceRelationship(tso1, tso1bis, tso1ter, tso2, new TestSubObject(), testTransients);
@@ -293,8 +293,8 @@ public class EqualsBuilderTest {
@Test
public void testSuper() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(5);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(5);
assertTrue(new EqualsBuilder().appendSuper(true).append(o1, o1).isEquals());
assertFalse(new EqualsBuilder().appendSuper(false).append(o1, o1).isEquals());
assertFalse(new EqualsBuilder().appendSuper(true).append(o1, o2).isEquals());
@@ -303,8 +303,8 @@ public class EqualsBuilderTest {
@Test
public void testObject() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(5);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(5);
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
o2.setA(4);
@@ -319,8 +319,8 @@ public class EqualsBuilderTest {
@Test
public void testObjectBuild() {
- TestObject o1 = new TestObject(4);
- TestObject o2 = new TestObject(5);
+ final TestObject o1 = new TestObject(4);
+ final TestObject o2 = new TestObject(5);
assertEquals(Boolean.TRUE, new EqualsBuilder().append(o1, o1).build());
assertEquals(Boolean.FALSE, new EqualsBuilder().append(o1, o2).build());
o2.setA(4);
@@ -335,48 +335,48 @@ public class EqualsBuilderTest {
@Test
public void testLong() {
- long o1 = 1L;
- long o2 = 2L;
+ final long o1 = 1L;
+ final long o2 = 2L;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@Test
public void testInt() {
- int o1 = 1;
- int o2 = 2;
+ final int o1 = 1;
+ final int o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@Test
public void testShort() {
- short o1 = 1;
- short o2 = 2;
+ final short o1 = 1;
+ final short o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@Test
public void testChar() {
- char o1 = 1;
- char o2 = 2;
+ final char o1 = 1;
+ final char o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@Test
public void testByte() {
- byte o1 = 1;
- byte o2 = 2;
+ final byte o1 = 1;
+ final byte o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@Test
public void testDouble() {
- double o1 = 1;
- double o2 = 2;
+ final double o1 = 1;
+ final double o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
assertTrue(!new EqualsBuilder().append(o1, Double.NaN).isEquals());
@@ -386,8 +386,8 @@ public class EqualsBuilderTest {
@Test
public void testFloat() {
- float o1 = 1;
- float o2 = 2;
+ final float o1 = 1;
+ final float o2 = 2;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
assertTrue(!new EqualsBuilder().append(o1, Float.NaN).isEquals());
@@ -397,7 +397,7 @@ public class EqualsBuilderTest {
@Test
public void testAccessors() {
- EqualsBuilder equalsBuilder = new EqualsBuilder();
+ final EqualsBuilder equalsBuilder = new EqualsBuilder();
assertTrue(equalsBuilder.isEquals());
equalsBuilder.setEquals(true);
assertTrue(equalsBuilder.isEquals());
@@ -407,7 +407,7 @@ public class EqualsBuilderTest {
@Test
public void testReset() {
- EqualsBuilder equalsBuilder = new EqualsBuilder();
+ final EqualsBuilder equalsBuilder = new EqualsBuilder();
assertTrue(equalsBuilder.isEquals());
equalsBuilder.setEquals(false);
assertFalse(equalsBuilder.isEquals());
@@ -417,8 +417,8 @@ public class EqualsBuilderTest {
@Test
public void testBoolean() {
- boolean o1 = true;
- boolean o2 = false;
+ final boolean o1 = true;
+ final boolean o2 = false;
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
}
@@ -606,8 +606,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiLongArray() {
- long[][] array1 = new long[2][2];
- long[][] array2 = new long[2][2];
+ final long[][] array1 = new long[2][2];
+ final long[][] array2 = new long[2][2];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -622,8 +622,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiIntArray() {
- int[][] array1 = new int[2][2];
- int[][] array2 = new int[2][2];
+ final int[][] array1 = new int[2][2];
+ final int[][] array2 = new int[2][2];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -638,8 +638,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiShortArray() {
- short[][] array1 = new short[2][2];
- short[][] array2 = new short[2][2];
+ final short[][] array1 = new short[2][2];
+ final short[][] array2 = new short[2][2];
for (short i = 0; i < array1.length; ++i) {
for (short j = 0; j < array1[0].length; j++) {
array1[i][j] = i;
@@ -654,8 +654,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiCharArray() {
- char[][] array1 = new char[2][2];
- char[][] array2 = new char[2][2];
+ final char[][] array1 = new char[2][2];
+ final char[][] array2 = new char[2][2];
for (char i = 0; i < array1.length; ++i) {
for (char j = 0; j < array1[0].length; j++) {
array1[i][j] = i;
@@ -670,8 +670,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiByteArray() {
- byte[][] array1 = new byte[2][2];
- byte[][] array2 = new byte[2][2];
+ final byte[][] array1 = new byte[2][2];
+ final byte[][] array2 = new byte[2][2];
for (byte i = 0; i < array1.length; ++i) {
for (byte j = 0; j < array1[0].length; j++) {
array1[i][j] = i;
@@ -686,8 +686,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiFloatArray() {
- float[][] array1 = new float[2][2];
- float[][] array2 = new float[2][2];
+ final float[][] array1 = new float[2][2];
+ final float[][] array2 = new float[2][2];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -702,8 +702,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiDoubleArray() {
- double[][] array1 = new double[2][2];
- double[][] array2 = new double[2][2];
+ final double[][] array1 = new double[2][2];
+ final double[][] array2 = new double[2][2];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = (i + 1) * (j + 1);
@@ -718,8 +718,8 @@ public class EqualsBuilderTest {
@Test
public void testMultiBooleanArray() {
- boolean[][] array1 = new boolean[2][2];
- boolean[][] array2 = new boolean[2][2];
+ final boolean[][] array1 = new boolean[2][2];
+ final boolean[][] array2 = new boolean[2][2];
for (int i = 0; i < array1.length; ++i) {
for (int j = 0; j < array1[0].length; j++) {
array1[i][j] = i == 1 || j == 1;
@@ -732,7 +732,7 @@ public class EqualsBuilderTest {
assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
// compare 1 dim to 2.
- boolean[] array3 = new boolean[]{true, true};
+ final boolean[] array3 = new boolean[]{true, true};
assertFalse(new EqualsBuilder().append(array1, array3).isEquals());
assertFalse(new EqualsBuilder().append(array3, array1).isEquals());
assertFalse(new EqualsBuilder().append(array2, array3).isEquals());
@@ -741,8 +741,8 @@ public class EqualsBuilderTest {
@Test
public void testRaggedArray() {
- long array1[][] = new long[2][];
- long array2[][] = new long[2][];
+ final long array1[][] = new long[2][];
+ final long array2[][] = new long[2][];
for (int i = 0; i < array1.length; ++i) {
array1[i] = new long[2];
array2[i] = new long[2];
@@ -759,8 +759,8 @@ public class EqualsBuilderTest {
@Test
public void testMixedArray() {
- Object array1[] = new Object[2];
- Object array2[] = new Object[2];
+ final Object array1[] = new Object[2];
+ final Object array2[] = new Object[2];
for (int i = 0; i < array1.length; ++i) {
array1[i] = new long[2];
array2[i] = new long[2];
@@ -777,14 +777,14 @@ public class EqualsBuilderTest {
@Test
public void testObjectArrayHiddenByObject() {
- TestObject[] array1 = new TestObject[2];
+ final TestObject[] array1 = new TestObject[2];
array1[0] = new TestObject(4);
array1[1] = new TestObject(5);
- TestObject[] array2 = new TestObject[2];
+ final TestObject[] array2 = new TestObject[2];
array2[0] = new TestObject(4);
array2[1] = new TestObject(5);
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -795,14 +795,14 @@ public class EqualsBuilderTest {
@Test
public void testLongArrayHiddenByObject() {
- long[] array1 = new long[2];
+ final long[] array1 = new long[2];
array1[0] = 5L;
array1[1] = 6L;
- long[] array2 = new long[2];
+ final long[] array2 = new long[2];
array2[0] = 5L;
array2[1] = 6L;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -813,14 +813,14 @@ public class EqualsBuilderTest {
@Test
public void testIntArrayHiddenByObject() {
- int[] array1 = new int[2];
+ final int[] array1 = new int[2];
array1[0] = 5;
array1[1] = 6;
- int[] array2 = new int[2];
+ final int[] array2 = new int[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -831,14 +831,14 @@ public class EqualsBuilderTest {
@Test
public void testShortArrayHiddenByObject() {
- short[] array1 = new short[2];
+ final short[] array1 = new short[2];
array1[0] = 5;
array1[1] = 6;
- short[] array2 = new short[2];
+ final short[] array2 = new short[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -849,14 +849,14 @@ public class EqualsBuilderTest {
@Test
public void testCharArrayHiddenByObject() {
- char[] array1 = new char[2];
+ final char[] array1 = new char[2];
array1[0] = 5;
array1[1] = 6;
- char[] array2 = new char[2];
+ final char[] array2 = new char[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -867,14 +867,14 @@ public class EqualsBuilderTest {
@Test
public void testByteArrayHiddenByObject() {
- byte[] array1 = new byte[2];
+ final byte[] array1 = new byte[2];
array1[0] = 5;
array1[1] = 6;
- byte[] array2 = new byte[2];
+ final byte[] array2 = new byte[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -885,14 +885,14 @@ public class EqualsBuilderTest {
@Test
public void testDoubleArrayHiddenByObject() {
- double[] array1 = new double[2];
+ final double[] array1 = new double[2];
array1[0] = 5;
array1[1] = 6;
- double[] array2 = new double[2];
+ final double[] array2 = new double[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -903,14 +903,14 @@ public class EqualsBuilderTest {
@Test
public void testFloatArrayHiddenByObject() {
- float[] array1 = new float[2];
+ final float[] array1 = new float[2];
array1[0] = 5;
array1[1] = 6;
- float[] array2 = new float[2];
+ final float[] array2 = new float[2];
array2[0] = 5;
array2[1] = 6;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -921,14 +921,14 @@ public class EqualsBuilderTest {
@Test
public void testBooleanArrayHiddenByObject() {
- boolean[] array1 = new boolean[2];
+ final boolean[] array1 = new boolean[2];
array1[0] = true;
array1[1] = false;
- boolean[] array2 = new boolean[2];
+ final boolean[] array2 = new boolean[2];
array2[0] = true;
array2[1] = false;
- Object obj1 = array1;
- Object obj2 = array2;
+ final Object obj1 = array1;
+ final Object obj2 = array2;
assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, array1).isEquals());
assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
@@ -1006,8 +1006,8 @@ public class EqualsBuilderTest {
*/
@Test
public void testUnrelatedClasses() {
- Object[] x = new Object[]{new TestACanEqualB(1)};
- Object[] y = new Object[]{new TestBCanEqualA(1)};
+ final Object[] x = new Object[]{new TestACanEqualB(1)};
+ final Object[] y = new Object[]{new TestBCanEqualA(1)};
// sanity checks:
assertTrue(Arrays.equals(x, x));
@@ -1030,8 +1030,8 @@ public class EqualsBuilderTest {
*/
@Test
public void testNpeForNullElement() {
- Object[] x1 = new Object[] { Integer.valueOf(1), null, Integer.valueOf(3) };
- Object[] x2 = new Object[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };
+ final Object[] x1 = new Object[] { Integer.valueOf(1), null, Integer.valueOf(3) };
+ final Object[] x2 = new Object[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };
// causes an NPE in 2.0 according to:
// http://issues.apache.org/bugzilla/show_bug.cgi?id=33067
@@ -1040,8 +1040,8 @@ public class EqualsBuilderTest {
@Test
public void testReflectionEqualsExcludeFields() throws Exception {
- TestObjectWithMultipleFields x1 = new TestObjectWithMultipleFields(1, 2, 3);
- TestObjectWithMultipleFields x2 = new TestObjectWithMultipleFields(1, 3, 4);
+ final TestObjectWithMultipleFields x1 = new TestObjectWithMultipleFields(1, 2, 3);
+ final TestObjectWithMultipleFields x2 = new TestObjectWithMultipleFields(1, 3, 4);
// not equal when including all fields
assertTrue(!EqualsBuilder.reflectionEquals(x1, x2));
@@ -1084,18 +1084,18 @@ public class EqualsBuilderTest {
*/
@Test
public void testCyclicalObjectReferences() {
- TestObjectReference refX1 = new TestObjectReference(1);
- TestObjectReference x1 = new TestObjectReference(1);
+ final TestObjectReference refX1 = new TestObjectReference(1);
+ final TestObjectReference x1 = new TestObjectReference(1);
x1.setObjectReference(refX1);
refX1.setObjectReference(x1);
- TestObjectReference refX2 = new TestObjectReference(1);
- TestObjectReference x2 = new TestObjectReference(1);
+ final TestObjectReference refX2 = new TestObjectReference(1);
+ final TestObjectReference x2 = new TestObjectReference(1);
x2.setObjectReference(refX2);
refX2.setObjectReference(x2);
- TestObjectReference refX3 = new TestObjectReference(2);
- TestObjectReference x3 = new TestObjectReference(2);
+ final TestObjectReference refX3 = new TestObjectReference(2);
+ final TestObjectReference x3 = new TestObjectReference(2);
x3.setObjectReference(refX3);
refX3.setObjectReference(x3);
diff --git a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java
index 9c959f762..1a3959bac 100644
--- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java
@@ -32,8 +32,8 @@ public class HashCodeBuilderAndEqualsBuilderTest {
//-----------------------------------------------------------------------
private void testInteger(final boolean testTransients) {
- Integer i1 = Integer.valueOf(12345);
- Integer i2 = Integer.valueOf(12345);
+ final Integer i1 = Integer.valueOf(12345);
+ final Integer i2 = Integer.valueOf(12345);
assertEqualsAndHashCodeContract(i1, i2, testTransients);
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
index fbbf66d3a..9156974a0 100644
--- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
@@ -79,7 +79,7 @@ public class HashCodeBuilderTest {
if (!(o instanceof TestObject)) {
return false;
}
- TestObject rhs = (TestObject) o;
+ final TestObject rhs = (TestObject) o;
return a == rhs.a;
}
@@ -121,7 +121,7 @@ public class HashCodeBuilderTest {
if (!(o instanceof TestSubObject)) {
return false;
}
- TestSubObject rhs = (TestSubObject) o;
+ final TestSubObject rhs = (TestSubObject) o;
return super.equals(o) && b == rhs.b;
}
@@ -175,7 +175,7 @@ public class HashCodeBuilderTest {
@Test
public void testSuper() {
- Object obj = new Object();
+ final Object obj = new Object();
assertEquals(17 * 37 + 19 * 41 + obj.hashCode(), new HashCodeBuilder(17, 37).appendSuper(
new HashCodeBuilder(19, 41).append(obj).toHashCode()).toHashCode());
}
@@ -233,8 +233,8 @@ public class HashCodeBuilderTest {
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
public void testDouble() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double) 0d).toHashCode());
- double d = 1234567.89;
- long l = Double.doubleToLongBits(d);
+ final double d = 1234567.89;
+ final long l = Double.doubleToLongBits(d);
assertEquals(17 * 37 + (int) (l ^ l >> 32), new HashCodeBuilder(17, 37).append(d).toHashCode());
}
@@ -242,8 +242,8 @@ public class HashCodeBuilderTest {
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
public void testFloat() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float) 0f).toHashCode());
- float f = 1234.89f;
- int i = Float.floatToIntBits(f);
+ final float f = 1234.89f;
+ final int i = Float.floatToIntBits(f);
assertEquals(17 * 37 + i, new HashCodeBuilder(17, 37).append(f).toHashCode());
}
@@ -256,7 +256,7 @@ public class HashCodeBuilderTest {
@Test
public void testObjectArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((Object[]) null).toHashCode());
- Object[] obj = new Object[2];
+ final Object[] obj = new Object[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = new Object();
assertEquals((17 * 37 + obj[0].hashCode()) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -267,7 +267,7 @@ public class HashCodeBuilderTest {
@Test
public void testObjectArrayAsObject() {
- Object[] obj = new Object[2];
+ final Object[] obj = new Object[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = new Object();
assertEquals((17 * 37 + obj[0].hashCode()) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -279,32 +279,32 @@ public class HashCodeBuilderTest {
@Test
public void testLongArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((long[]) null).toHashCode());
- long[] obj = new long[2];
+ final long[] obj = new long[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = 5L;
- int h1 = (int) (5L ^ 5L >> 32);
+ final int h1 = (int) (5L ^ 5L >> 32);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[1] = 6L;
- int h2 = (int) (6L ^ 6L >> 32);
+ final int h2 = (int) (6L ^ 6L >> 32);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
}
@Test
public void testLongArrayAsObject() {
- long[] obj = new long[2];
+ final long[] obj = new long[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = 5L;
- int h1 = (int) (5L ^ 5L >> 32);
+ final int h1 = (int) (5L ^ 5L >> 32);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[1] = 6L;
- int h2 = (int) (6L ^ 6L >> 32);
+ final int h2 = (int) (6L ^ 6L >> 32);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
}
@Test
public void testIntArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((int[]) null).toHashCode());
- int[] obj = new int[2];
+ final int[] obj = new int[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -314,7 +314,7 @@ public class HashCodeBuilderTest {
@Test
public void testIntArrayAsObject() {
- int[] obj = new int[2];
+ final int[] obj = new int[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -325,7 +325,7 @@ public class HashCodeBuilderTest {
@Test
public void testShortArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((short[]) null).toHashCode());
- short[] obj = new short[2];
+ final short[] obj = new short[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = (short) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -335,7 +335,7 @@ public class HashCodeBuilderTest {
@Test
public void testShortArrayAsObject() {
- short[] obj = new short[2];
+ final short[] obj = new short[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = (short) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -346,7 +346,7 @@ public class HashCodeBuilderTest {
@Test
public void testCharArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((char[]) null).toHashCode());
- char[] obj = new char[2];
+ final char[] obj = new char[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = (char) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -356,7 +356,7 @@ public class HashCodeBuilderTest {
@Test
public void testCharArrayAsObject() {
- char[] obj = new char[2];
+ final char[] obj = new char[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = (char) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -367,7 +367,7 @@ public class HashCodeBuilderTest {
@Test
public void testByteArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((byte[]) null).toHashCode());
- byte[] obj = new byte[2];
+ final byte[] obj = new byte[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = (byte) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -377,7 +377,7 @@ public class HashCodeBuilderTest {
@Test
public void testByteArrayAsObject() {
- byte[] obj = new byte[2];
+ final byte[] obj = new byte[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = (byte) 5;
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -388,61 +388,61 @@ public class HashCodeBuilderTest {
@Test
public void testDoubleArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double[]) null).toHashCode());
- double[] obj = new double[2];
+ final double[] obj = new double[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = 5.4d;
- long l1 = Double.doubleToLongBits(5.4d);
- int h1 = (int) (l1 ^ l1 >> 32);
+ final long l1 = Double.doubleToLongBits(5.4d);
+ final int h1 = (int) (l1 ^ l1 >> 32);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[1] = 6.3d;
- long l2 = Double.doubleToLongBits(6.3d);
- int h2 = (int) (l2 ^ l2 >> 32);
+ final long l2 = Double.doubleToLongBits(6.3d);
+ final int h2 = (int) (l2 ^ l2 >> 32);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
}
@Test
public void testDoubleArrayAsObject() {
- double[] obj = new double[2];
+ final double[] obj = new double[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = 5.4d;
- long l1 = Double.doubleToLongBits(5.4d);
- int h1 = (int) (l1 ^ l1 >> 32);
+ final long l1 = Double.doubleToLongBits(5.4d);
+ final int h1 = (int) (l1 ^ l1 >> 32);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[1] = 6.3d;
- long l2 = Double.doubleToLongBits(6.3d);
- int h2 = (int) (l2 ^ l2 >> 32);
+ final long l2 = Double.doubleToLongBits(6.3d);
+ final int h2 = (int) (l2 ^ l2 >> 32);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
}
@Test
public void testFloatArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float[]) null).toHashCode());
- float[] obj = new float[2];
+ final float[] obj = new float[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = 5.4f;
- int h1 = Float.floatToIntBits(5.4f);
+ final int h1 = Float.floatToIntBits(5.4f);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[1] = 6.3f;
- int h2 = Float.floatToIntBits(6.3f);
+ final int h2 = Float.floatToIntBits(6.3f);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
}
@Test
public void testFloatArrayAsObject() {
- float[] obj = new float[2];
+ final float[] obj = new float[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = 5.4f;
- int h1 = Float.floatToIntBits(5.4f);
+ final int h1 = Float.floatToIntBits(5.4f);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[1] = 6.3f;
- int h2 = Float.floatToIntBits(6.3f);
+ final int h2 = Float.floatToIntBits(6.3f);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
}
@Test
public void testBooleanArray() {
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((boolean[]) null).toHashCode());
- boolean[] obj = new boolean[2];
+ final boolean[] obj = new boolean[2];
assertEquals((17 * 37 + 1) * 37 + 1, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = true;
assertEquals((17 * 37 + 0) * 37 + 1, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -452,7 +452,7 @@ public class HashCodeBuilderTest {
@Test
public void testBooleanArrayAsObject() {
- boolean[] obj = new boolean[2];
+ final boolean[] obj = new boolean[2];
assertEquals((17 * 37 + 1) * 37 + 1, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = true;
assertEquals((17 * 37 + 0) * 37 + 1, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -462,7 +462,7 @@ public class HashCodeBuilderTest {
@Test
public void testBooleanMultiArray() {
- boolean[][] obj = new boolean[2][];
+ final boolean[][] obj = new boolean[2][];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
obj[0] = new boolean[0];
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -478,7 +478,7 @@ public class HashCodeBuilderTest {
@Test
public void testReflectionHashCodeExcludeFields() throws Exception {
- TestObjectWithMultipleFields x = new TestObjectWithMultipleFields(1, 2, 3);
+ final TestObjectWithMultipleFields x = new TestObjectWithMultipleFields(1, 2, 3);
assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x));
@@ -517,8 +517,8 @@ public class HashCodeBuilderTest {
*/
@Test
public void testReflectionObjectCycle() {
- ReflectionTestCycleA a = new ReflectionTestCycleA();
- ReflectionTestCycleB b = new ReflectionTestCycleB();
+ final ReflectionTestCycleA a = new ReflectionTestCycleA();
+ final ReflectionTestCycleB b = new ReflectionTestCycleB();
a.b = b;
b.a = a;
@@ -550,7 +550,7 @@ public class HashCodeBuilderTest {
*/
@Test
public void testToHashCodeEqualsHashCode() {
- HashCodeBuilder hcb = new HashCodeBuilder(17, 37).append(new Object()).append('a');
+ final HashCodeBuilder hcb = new HashCodeBuilder(17, 37).append(new Object()).append('a');
assertEquals("hashCode() is no longer returning the same value as toHashCode() - see LANG-520",
hcb.toHashCode(), hcb.hashCode());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java
index f4bf7d2c6..3a506a077 100644
--- a/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java
@@ -66,8 +66,8 @@ public class MultiLineToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " 3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -84,11 +84,11 @@ public class MultiLineToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "Jane Doe";
p.age = 25;
p.smoker = true;
- String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
+ final String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
assertEquals(pBaseStr + "[" + SystemUtils.LINE_SEPARATOR + " name=Jane Doe" + SystemUtils.LINE_SEPARATOR + " age=25" + SystemUtils.LINE_SEPARATOR + " smoker=true" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java
index d94c8fdc2..7d64e8ff6 100644
--- a/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java
@@ -65,8 +65,8 @@ public class NoFieldNamesToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -83,11 +83,11 @@ public class NoFieldNamesToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "Ron Paul";
p.age = 72;
p.smoker = false;
- String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
+ final String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
assertEquals(pBaseStr + "[Ron Paul,72,false]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java
index 696cd9a0e..9e589d95a 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java
@@ -89,18 +89,18 @@ public class ReflectionToStringBuilderConcurrencyTest {
// Create a thread pool with two threads to cause the most contention on the underlying resource.
final ExecutorService threadPool = Executors.newFixedThreadPool(2);
// Consumes toStrings
- Callable<Integer> consumer = new Callable<Integer>() {
+ final Callable<Integer> consumer = new Callable<Integer>() {
@Override
public Integer call() {
for (int i = 0; i < REPEAT; i++) {
- String s = ReflectionToStringBuilder.toString(holder);
+ final String s = ReflectionToStringBuilder.toString(holder);
Assert.assertNotNull(s);
}
return Integer.valueOf(REPEAT);
}
};
// Produces changes in the list
- Callable<Integer> producer = new Callable<Integer>() {
+ final Callable<Integer> producer = new Callable<Integer>() {
@Override
public Integer call() {
for (int i = 0; i < DATA_SIZE; i++) {
@@ -109,11 +109,11 @@ public class ReflectionToStringBuilderConcurrencyTest {
return Integer.valueOf(REPEAT);
}
};
- Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
+ final Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
tasks.add(consumer);
tasks.add(producer);
final List<Future<Integer>> futures = threadPool.invokeAll(tasks);
- for (Future<Integer> future : futures) {
+ for (final Future<Integer> future : futures) {
Assert.assertEquals(REPEAT, future.get().intValue());
}
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
index e563234ac..7b87c25d7 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
@@ -49,74 +49,74 @@ public class ReflectionToStringBuilderExcludeTest {
@Test
public void test_toStringExclude() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), SECRET_FIELD);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), SECRET_FIELD);
this.validateSecretFieldAbsent(toString);
}
@Test
public void test_toStringExcludeArray() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{SECRET_FIELD});
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{SECRET_FIELD});
this.validateSecretFieldAbsent(toString);
}
@Test
public void test_toStringExcludeArrayWithNull() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null});
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null});
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeArrayWithNulls() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null, null});
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null, null});
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeCollection() {
- List<String> excludeList = new ArrayList<String>();
+ final List<String> excludeList = new ArrayList<String>();
excludeList.add(SECRET_FIELD);
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
this.validateSecretFieldAbsent(toString);
}
@Test
public void test_toStringExcludeCollectionWithNull() {
- List<String> excludeList = new ArrayList<String>();
+ final List<String> excludeList = new ArrayList<String>();
excludeList.add(null);
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeCollectionWithNulls() {
- List<String> excludeList = new ArrayList<String>();
+ final List<String> excludeList = new ArrayList<String>();
excludeList.add(null);
excludeList.add(null);
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeEmptyArray() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), ArrayUtils.EMPTY_STRING_ARRAY);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), ArrayUtils.EMPTY_STRING_ARRAY);
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeEmptyCollection() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new ArrayList<String>());
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new ArrayList<String>());
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeNullArray() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (String[]) null);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (String[]) null);
this.validateSecretFieldPresent(toString);
}
@Test
public void test_toStringExcludeNullCollection() {
- String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (Collection<String>) null);
+ final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), (Collection<String>) null);
this.validateSecretFieldPresent(toString);
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java
index 84eb71c53..c4899117e 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java
@@ -93,14 +93,14 @@ public class ReflectionToStringBuilderMutateInspectConcurrencyTest {
@Test
@Ignore
public void testConcurrency() throws Exception {
- TestFixture testFixture = new TestFixture();
+ final TestFixture testFixture = new TestFixture();
final int numMutators = 10;
final int numIterations = 10;
for (int i = 0; i < numIterations; i++) {
for (int j = 0; j < numMutators; j++) {
- Thread t = new Thread(new MutatingClient(testFixture));
+ final Thread t = new Thread(new MutatingClient(testFixture));
t.start();
- Thread s = new Thread(new InspectingClient(testFixture));
+ final Thread s = new Thread(new InspectingClient(testFixture));
s.start();
}
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java
index 8a782455d..124cb1a1e 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java
@@ -65,8 +65,8 @@ public class ShortPrefixToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -83,11 +83,11 @@ public class ShortPrefixToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "John Q. Public";
p.age = 45;
p.smoker = true;
- String pBaseStr = "ToStringStyleTest.Person";
+ final String pBaseStr = "ToStringStyleTest.Person";
assertEquals(pBaseStr + "[name=John Q. Public,age=45,smoker=true]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java
index 6bf5a2272..93e0b8505 100644
--- a/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java
@@ -64,8 +64,8 @@ public class SimpleToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals("<null>", new ToStringBuilder(base).append((Object) null).toString());
assertEquals("3", new ToStringBuilder(base).append(i3).toString());
assertEquals("<null>", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -82,7 +82,7 @@ public class SimpleToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "Jane Q. Public";
p.age = 47;
p.smoker = false;
diff --git a/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java
index 91db43b39..70363951d 100644
--- a/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java
@@ -80,8 +80,8 @@ public class StandardToStringStyleTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[%NULL%]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=%NULL%]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -98,11 +98,11 @@ public class StandardToStringStyleTest {
@Test
public void testPerson() {
- Person p = new Person();
+ final Person p = new Person();
p.name = "Suzy Queue";
p.age = 19;
p.smoker = false;
- String pBaseStr = "ToStringStyleTest.Person";
+ final String pBaseStr = "ToStringStyleTest.Person";
assertEquals(pBaseStr + "[name=Suzy Queue,age=19,smoker=false]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
index 8c25c2882..ba74ef643 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
@@ -100,7 +100,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionCharacter() {
- Character c = new Character('A');
+ final Character c = new Character('A');
assertEquals(this.toBaseString(c) + "[value=A]", ToStringBuilder.reflectionToString(c));
}
@@ -154,7 +154,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionObjectArray() {
Object[] array = new Object[] { null, base, new int[] { 3, 6 } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{<null>,5,{3,6}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -163,7 +163,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionLongArray() {
long[] array = new long[] { 1, 2, -3, 4 };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1,2,-3,4}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -172,7 +172,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionIntArray() {
int[] array = new int[] { 1, 2, -3, 4 };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1,2,-3,4}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -181,7 +181,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionShortArray() {
short[] array = new short[] { 1, 2, -3, 4 };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1,2,-3,4}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -190,7 +190,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionyteArray() {
byte[] array = new byte[] { 1, 2, -3, 4 };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1,2,-3,4}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -199,7 +199,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionCharArray() {
char[] array = new char[] { 'A', '2', '_', 'D' };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{A,2,_,D}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -208,7 +208,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionDoubleArray() {
double[] array = new double[] { 1.0, 2.9876, -3.00001, 4.3 };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1.0,2.9876,-3.00001,4.3}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -217,7 +217,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionFloatArray() {
float[] array = new float[] { 1.0f, 2.9876f, -3.00001f, 4.3f };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{1.0,2.9876,-3.00001,4.3}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -226,7 +226,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionBooleanArray() {
boolean[] array = new boolean[] { true, false, false };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{true,false,false}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -237,7 +237,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionFloatArrayArray() {
float[][] array = new float[][] { { 1.0f, 2.29686f }, null, { Float.NaN } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1.0,2.29686},<null>,{NaN}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -247,7 +247,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionLongArrayArray() {
long[][] array = new long[][] { { 1, 2 }, null, { 5 } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1,2},<null>,{5}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -256,7 +256,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionIntArrayArray() {
int[][] array = new int[][] { { 1, 2 }, null, { 5 } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1,2},<null>,{5}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -265,7 +265,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionhortArrayArray() {
short[][] array = new short[][] { { 1, 2 }, null, { 5 } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1,2},<null>,{5}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -274,7 +274,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionByteArrayArray() {
byte[][] array = new byte[][] { { 1, 2 }, null, { 5 } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1,2},<null>,{5}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -283,7 +283,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionCharArrayArray() {
char[][] array = new char[][] { { 'A', 'B' }, null, { 'p' } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{A,B},<null>,{p}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -292,7 +292,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionDoubleArrayArray() {
double[][] array = new double[][] { { 1.0, 2.29686 }, null, { Double.NaN } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{1.0,2.29686},<null>,{NaN}}]", ToStringBuilder.reflectionToString(array));
array = null;
assertReflectionArray("<null>", array);
@@ -301,7 +301,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionBooleanArrayArray() {
boolean[][] array = new boolean[][] { { true, false }, null, { false } };
- String baseStr = this.toBaseString(array);
+ final String baseStr = this.toBaseString(array);
assertEquals(baseStr + "[{{true,false},<null>,{false}}]", ToStringBuilder.reflectionToString(array));
assertEquals(baseStr + "[{{true,false},<null>,{false}}]", ToStringBuilder.reflectionToString(array));
array = null;
@@ -311,19 +311,19 @@ public class ToStringBuilderTest {
// Reflection hierarchy tests
@Test
public void testReflectionHierarchyArrayList() {
- List<Object> base = new ArrayList<Object>();
- String baseStr = this.toBaseString(base);
+ final List<Object> base = new ArrayList<Object>();
+ final String baseStr = this.toBaseString(base);
// note, the test data depends on the internal representation of the ArrayList, which may differ between JDK versions and vendors
- String expectedWithTransients = baseStr + "[elementData={<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>},size=0,modCount=0]";
- String toStringWithTransients = ToStringBuilder.reflectionToString(base, null, true);
+ final String expectedWithTransients = baseStr + "[elementData={<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>},size=0,modCount=0]";
+ final String toStringWithTransients = ToStringBuilder.reflectionToString(base, null, true);
if (!expectedWithTransients.equals(toStringWithTransients)) {
// representation different for IBM JDK 1.6.0, LANG-727
if (!("IBM Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".equals(SystemUtils.JAVA_SPECIFICATION_VERSION))) {
assertEquals(expectedWithTransients, toStringWithTransients);
}
}
- String expectedWithoutTransients = baseStr + "[size=0]";
- String toStringWithoutTransients = ToStringBuilder.reflectionToString(base, null, false);
+ final String expectedWithoutTransients = baseStr + "[size=0]";
+ final String toStringWithoutTransients = ToStringBuilder.reflectionToString(base, null, false);
if (!expectedWithoutTransients.equals(toStringWithoutTransients)) {
// representation different for IBM JDK 1.6.0, LANG-727
if (!("IBM Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".equals(SystemUtils.JAVA_SPECIFICATION_VERSION))) {
@@ -334,7 +334,7 @@ public class ToStringBuilderTest {
@Test
public void testReflectionHierarchy() {
- ReflectionTestFixtureA baseA = new ReflectionTestFixtureA();
+ final ReflectionTestFixtureA baseA = new ReflectionTestFixtureA();
String baseStr = this.toBaseString(baseA);
assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA));
assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA, null));
@@ -344,7 +344,7 @@ public class ToStringBuilderTest {
assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA, null, false, Object.class));
assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA, null, false, ReflectionTestFixtureA.class));
- ReflectionTestFixtureB baseB = new ReflectionTestFixtureB();
+ final ReflectionTestFixtureB baseB = new ReflectionTestFixtureB();
baseStr = this.toBaseString(baseB);
assertEquals(baseStr + "[b=b,a=a]", ToStringBuilder.reflectionToString(baseB));
assertEquals(baseStr + "[b=b,a=a]", ToStringBuilder.reflectionToString(baseB));
@@ -373,7 +373,7 @@ public class ToStringBuilderTest {
@Test
public void testInnerClassReflection() {
- Outer outer = new Outer();
+ final Outer outer = new Outer();
assertEquals(toBaseString(outer) + "[inner=" + toBaseString(outer.inner) + "[]]", outer.toString());
}
@@ -398,7 +398,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionArrayCycle() throws Exception {
- Object[] objects = new Object[1];
+ final Object[] objects = new Object[1];
objects[0] = objects;
assertEquals(
this.toBaseString(objects) + "[{" + this.toBaseString(objects) + "}]",
@@ -410,8 +410,8 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionArrayCycleLevel2() throws Exception {
- Object[] objects = new Object[1];
- Object[] objectsLevel2 = new Object[1];
+ final Object[] objects = new Object[1];
+ final Object[] objectsLevel2 = new Object[1];
objects[0] = objectsLevel2;
objectsLevel2[0] = objects;
assertEquals(
@@ -424,12 +424,12 @@ public class ToStringBuilderTest {
@Test
public void testReflectionArrayArrayCycle() throws Exception {
- Object[][] objects = new Object[2][2];
+ final Object[][] objects = new Object[2][2];
objects[0][0] = objects;
objects[0][1] = objects;
objects[1][0] = objects;
objects[1][1] = objects;
- String basicToString = this.toBaseString(objects);
+ final String basicToString = this.toBaseString(objects);
assertEquals(
basicToString
+ "[{{"
@@ -528,7 +528,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testSimpleReflectionObjectCycle() throws Exception {
- SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture();
+ final SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture();
simple.o = simple;
assertEquals(this.toBaseString(simple) + "[o=" + this.toBaseString(simple) + "]", simple.toString());
}
@@ -540,7 +540,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testSelfInstanceVarReflectionObjectCycle() throws Exception {
- SelfInstanceVarReflectionTestFixture test = new SelfInstanceVarReflectionTestFixture();
+ final SelfInstanceVarReflectionTestFixture test = new SelfInstanceVarReflectionTestFixture();
assertEquals(this.toBaseString(test) + "[typeIsSelf=" + this.toBaseString(test) + "]", test.toString());
}
@@ -552,7 +552,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testSelfInstanceTwoVarsReflectionObjectCycle() throws Exception {
- SelfInstanceTwoVarsReflectionTestFixture test = new SelfInstanceTwoVarsReflectionTestFixture();
+ final SelfInstanceTwoVarsReflectionTestFixture test = new SelfInstanceTwoVarsReflectionTestFixture();
assertEquals(this.toBaseString(test) + "[typeIsSelf=" + this.toBaseString(test) + ",otherType=" + test.getOtherType().toString() + "]", test.toString());
}
@@ -564,8 +564,8 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionObjectCycle() throws Exception {
- ReflectionTestCycleA a = new ReflectionTestCycleA();
- ReflectionTestCycleB b = new ReflectionTestCycleB();
+ final ReflectionTestCycleA a = new ReflectionTestCycleA();
+ final ReflectionTestCycleB b = new ReflectionTestCycleB();
a.b = b;
b.a = a;
assertEquals(
@@ -581,8 +581,8 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionArrayAndObjectCycle() throws Exception {
- Object[] objects = new Object[1];
- SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture(objects);
+ final Object[] objects = new Object[1];
+ final SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture(objects);
objects[0] = simple;
assertEquals(
this.toBaseString(objects)
@@ -629,8 +629,8 @@ public class ToStringBuilderTest {
@Test
public void testObject() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
@@ -647,8 +647,8 @@ public class ToStringBuilderTest {
@Test
public void testObjectBuild() {
- Integer i3 = Integer.valueOf(3);
- Integer i4 = Integer.valueOf(4);
+ final Integer i3 = Integer.valueOf(3);
+ final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).build());
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).build());
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).build());
@@ -894,12 +894,12 @@ public class ToStringBuilderTest {
@Test
public void testObjectCycle() {
- ObjectCycle a = new ObjectCycle();
- ObjectCycle b = new ObjectCycle();
+ final ObjectCycle a = new ObjectCycle();
+ final ObjectCycle b = new ObjectCycle();
a.obj = b;
b.obj = a;
- String expected = toBaseString(a) + "[" + toBaseString(b) + "[" + toBaseString(a) + "]]";
+ final String expected = toBaseString(a) + "[" + toBaseString(b) + "[" + toBaseString(a) + "]]";
assertEquals(expected, a.toString());
}
@@ -914,7 +914,7 @@ public class ToStringBuilderTest {
@Test
public void testSimpleReflectionStatics() {
- SimpleReflectionStaticFieldsFixture instance1 = new SimpleReflectionStaticFieldsFixture();
+ final SimpleReflectionStaticFieldsFixture instance1 = new SimpleReflectionStaticFieldsFixture();
assertEquals(
this.toBaseString(instance1) + "[staticString=staticString,staticInt=12345]",
ReflectionToStringBuilder.toString(instance1, null, false, true, SimpleReflectionStaticFieldsFixture.class));
@@ -934,7 +934,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testReflectionStatics() {
- ReflectionStaticFieldsFixture instance1 = new ReflectionStaticFieldsFixture();
+ final ReflectionStaticFieldsFixture instance1 = new ReflectionStaticFieldsFixture();
assertEquals(
this.toBaseString(instance1) + "[staticString=staticString,staticInt=12345,instanceString=instanceString,instanceInt=67890]",
ReflectionToStringBuilder.toString(instance1, null, false, true, ReflectionStaticFieldsFixture.class));
@@ -954,7 +954,7 @@ public class ToStringBuilderTest {
*/
@Test
public void testInheritedReflectionStatics() {
- InheritedReflectionStaticFieldsFixture instance1 = new InheritedReflectionStaticFieldsFixture();
+ final InheritedReflectionStaticFieldsFixture instance1 = new InheritedReflectionStaticFieldsFixture();
assertEquals(
this.toBaseString(instance1) + "[staticString2=staticString2,staticInt2=67890]",
ReflectionToStringBuilder.toString(instance1, null, false, true, InheritedReflectionStaticFieldsFixture.class));
@@ -1003,8 +1003,8 @@ public class ToStringBuilderTest {
*/
@Test
public void test_setUpToClass_valid() {
- Integer val = Integer.valueOf(5);
- ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
+ final Integer val = Integer.valueOf(5);
+ final ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
test.setUpToClass(Number.class);
test.toString();
}
@@ -1014,8 +1014,8 @@ public class ToStringBuilderTest {
*/
@Test(expected=IllegalArgumentException.class)
public void test_setUpToClass_invalid() {
- Integer val = Integer.valueOf(5);
- ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
+ final Integer val = Integer.valueOf(5);
+ final ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
try {
test.setUpToClass(String.class);
} finally {
@@ -1072,8 +1072,8 @@ public class ToStringBuilderTest {
@Test
public void testAppendToStringUsingMultiLineStyle() {
- MultiLineTestObject obj = new MultiLineTestObject();
- ToStringBuilder testBuilder = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+ final MultiLineTestObject obj = new MultiLineTestObject();
+ final ToStringBuilder testBuilder = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.appendToString(obj.toString());
assertEquals(testBuilder.toString().indexOf("testInt=31337"), -1);
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java
index 010a5ae03..16659bfcb 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java
@@ -89,7 +89,7 @@ public class ToStringStyleConcurrencyTest {
// Create a thread pool with two threads to cause the most contention on the underlying resource.
final ExecutorService threadPool = Executors.newFixedThreadPool(2);
// Consumes toStrings
- Callable<Integer> consumer = new Callable<Integer>() {
+ final Callable<Integer> consumer = new Callable<Integer>() {
@Override
public Integer call() {
for (int i = 0; i < REPEAT; i++) {
@@ -99,11 +99,11 @@ public class ToStringStyleConcurrencyTest {
return Integer.valueOf(REPEAT);
}
};
- Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
+ final Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
tasks.add(consumer);
tasks.add(consumer);
final List<Future<Integer>> futures = threadPool.invokeAll(tasks);
- for (Future<Integer> future : futures) {
+ for (final Future<Integer> future : futures) {
future.get();
}
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java
index 014860bcb..485e969e2 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java
@@ -33,84 +33,84 @@ public class ToStringStyleTest {
//-----------------------------------------------------------------------
@Test
public void testSetArrayStart() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setArrayStart(null);
assertEquals("", style.getArrayStart());
}
@Test
public void testSetArrayEnd() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setArrayEnd(null);
assertEquals("", style.getArrayEnd());
}
@Test
public void testSetArraySeparator() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setArraySeparator(null);
assertEquals("", style.getArraySeparator());
}
@Test
public void testSetContentStart() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setContentStart(null);
assertEquals("", style.getContentStart());
}
@Test
public void testSetContentEnd() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setContentEnd(null);
assertEquals("", style.getContentEnd());
}
@Test
public void testSetFieldNameValueSeparator() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setFieldNameValueSeparator(null);
assertEquals("", style.getFieldNameValueSeparator());
}
@Test
public void testSetFieldSeparator() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setFieldSeparator(null);
assertEquals("", style.getFieldSeparator());
}
@Test
public void testSetNullText() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setNullText(null);
assertEquals("", style.getNullText());
}
@Test
public void testSetSizeStartText() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setSizeStartText(null);
assertEquals("", style.getSizeStartText());
}
@Test
public void testSetSizeEndText() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setSizeEndText(null);
assertEquals("", style.getSizeEndText());
}
@Test
public void testSetSummaryObjectStartText() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setSummaryObjectStartText(null);
assertEquals("", style.getSummaryObjectStartText());
}
@Test
public void testSetSummaryObjectEndText() {
- ToStringStyle style = new ToStringStyleImpl();
+ final ToStringStyle style = new ToStringStyleImpl();
style.setSummaryObjectEndText(null);
assertEquals("", style.getSummaryObjectEndText());
}
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java
index 87135a081..4744e5904 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/AbstractConcurrentInitializerTest.java
@@ -51,8 +51,8 @@ public abstract class AbstractConcurrentInitializerTest {
*/
@Test
public void testGetMultipleTimes() throws ConcurrentException {
- ConcurrentInitializer<Object> initializer = createInitializer();
- Object obj = initializer.get();
+ final ConcurrentInitializer<Object> initializer = createInitializer();
+ final Object obj = initializer.get();
for (int i = 0; i < 10; i++) {
assertEquals("Got different object at " + i, obj, initializer.get());
}
@@ -78,15 +78,15 @@ public abstract class AbstractConcurrentInitializerTest {
startLatch.await();
// access the initializer
object = initializer.get();
- } catch (InterruptedException iex) {
+ } catch (final InterruptedException iex) {
// ignore
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
object = cex;
}
}
}
- GetThread[] threads = new GetThread[threadCount];
+ final GetThread[] threads = new GetThread[threadCount];
for (int i = 0; i < threadCount; i++) {
threads[i] = new GetThread();
threads[i].start();
@@ -94,13 +94,13 @@ public abstract class AbstractConcurrentInitializerTest {
// fire all threads and wait until they are ready
startLatch.countDown();
- for (Thread t : threads) {
+ for (final Thread t : threads) {
t.join();
}
// check results
- Object managedObject = initializer.get();
- for (GetThread t : threads) {
+ final Object managedObject = initializer.get();
+ for (final GetThread t : threads) {
assertEquals("Wrong object", managedObject, t.object);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java
index 388729a7e..e8a6e5ed5 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java
@@ -33,11 +33,11 @@ public class BackgroundInitializerTest {
*/
private void checkInitialize(final BackgroundInitializerTestImpl init) {
try {
- Integer result = init.get();
+ final Integer result = init.get();
assertEquals("Wrong result", 1, result.intValue());
assertEquals("Wrong number of invocations", 1, init.initializeCalls);
assertNotNull("No future", init.getFuture());
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
fail("Unexpected exception: " + cex);
}
}
@@ -47,7 +47,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testInitialize() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
checkInitialize(init);
}
@@ -58,7 +58,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetActiveExecutorBeforeStart() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertNull("Got an executor", init.getActiveExecutor());
}
@@ -67,9 +67,9 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetActiveExecutorExternal() {
- ExecutorService exec = Executors.newSingleThreadExecutor();
+ final ExecutorService exec = Executors.newSingleThreadExecutor();
try {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(
exec);
init.start();
assertSame("Wrong executor", exec, init.getActiveExecutor());
@@ -84,7 +84,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetActiveExecutorTemp() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
assertNotNull("No active executor", init.getActiveExecutor());
checkInitialize(init);
@@ -96,7 +96,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testInitializeTempExecutor() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertTrue("Wrong result of start()", init.start());
checkInitialize(init);
assertTrue("Executor not shutdown", init.getActiveExecutor()
@@ -109,9 +109,9 @@ public class BackgroundInitializerTest {
*/
@Test
public void testSetExternalExecutor() throws Exception {
- ExecutorService exec = Executors.newCachedThreadPool();
+ final ExecutorService exec = Executors.newCachedThreadPool();
try {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.setExternalExecutor(exec);
assertEquals("Wrong executor service", exec, init
.getExternalExecutor());
@@ -129,12 +129,12 @@ public class BackgroundInitializerTest {
*/
@Test
public void testSetExternalExecutorAfterStart() throws ConcurrentException {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
try {
init.setExternalExecutor(Executors.newSingleThreadExecutor());
fail("Could set executor after start()!");
- } catch (IllegalStateException istex) {
+ } catch (final IllegalStateException istex) {
init.get();
}
}
@@ -145,7 +145,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testStartMultipleTimes() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertTrue("Wrong result for start()", init.start());
for (int i = 0; i < 10; i++) {
assertFalse("Could start again", init.start());
@@ -158,7 +158,7 @@ public class BackgroundInitializerTest {
*/
@Test(expected=IllegalStateException.class)
public void testGetBeforeStart() throws ConcurrentException {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.get();
}
@@ -168,14 +168,14 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetRuntimeException() throws Exception {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
- RuntimeException rex = new RuntimeException();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final RuntimeException rex = new RuntimeException();
init.ex = rex;
init.start();
try {
init.get();
fail("Exception not thrown!");
- } catch (Exception ex) {
+ } catch (final Exception ex) {
assertEquals("Runtime exception not thrown", rex, ex);
}
}
@@ -186,14 +186,14 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetCheckedException() throws Exception {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
- Exception ex = new Exception();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final Exception ex = new Exception();
init.ex = ex;
init.start();
try {
init.get();
fail("Exception not thrown!");
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
assertEquals("Exception not thrown", ex, cex.getCause());
}
}
@@ -203,19 +203,19 @@ public class BackgroundInitializerTest {
*/
@Test
public void testGetInterruptedException() throws Exception {
- ExecutorService exec = Executors.newSingleThreadExecutor();
+ final ExecutorService exec = Executors.newSingleThreadExecutor();
final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(
exec);
final CountDownLatch latch1 = new CountDownLatch(1);
init.shouldSleep = true;
init.start();
final AtomicReference<InterruptedException> iex = new AtomicReference<InterruptedException>();
- Thread getThread = new Thread() {
+ final Thread getThread = new Thread() {
@Override
public void run() {
try {
init.get();
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
if (cex.getCause() instanceof InterruptedException) {
iex.set((InterruptedException) cex.getCause());
}
@@ -238,7 +238,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testIsStartedFalse() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertFalse("Already started", init.isStarted());
}
@@ -247,7 +247,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testIsStartedTrue() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
assertTrue("Not started", init.isStarted());
}
@@ -257,7 +257,7 @@ public class BackgroundInitializerTest {
*/
@Test
public void testIsStartedAfterGet() {
- BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
+ final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
checkInitialize(init);
assertTrue("Not started", init.isStarted());
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java b/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java
index 764a20a03..3bf8a867a 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java
@@ -66,7 +66,7 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testBuildDefaults() {
- BasicThreadFactory factory = builder.build();
+ final BasicThreadFactory factory = builder.build();
checkFactoryDefaults(factory);
}
@@ -99,15 +99,15 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testBuilderReset() {
- ThreadFactory wrappedFactory = EasyMock.createMock(ThreadFactory.class);
- Thread.UncaughtExceptionHandler exHandler = EasyMock
+ final ThreadFactory wrappedFactory = EasyMock.createMock(ThreadFactory.class);
+ final Thread.UncaughtExceptionHandler exHandler = EasyMock
.createMock(Thread.UncaughtExceptionHandler.class);
EasyMock.replay(wrappedFactory, exHandler);
builder.namingPattern(PATTERN).daemon(true).priority(
Thread.MAX_PRIORITY).uncaughtExceptionHandler(exHandler)
.wrappedFactory(wrappedFactory);
builder.reset();
- BasicThreadFactory factory = builder.build();
+ final BasicThreadFactory factory = builder.build();
checkFactoryDefaults(factory);
assertNotSame("Wrapped factory not reset", wrappedFactory, factory
.getWrappedFactory());
@@ -129,17 +129,17 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadNamingPattern() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
final int count = 12;
for (int i = 0; i < count; i++) {
EasyMock.expect(wrapped.newThread(r)).andReturn(new Thread());
}
EasyMock.replay(wrapped, r);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped)
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped)
.namingPattern(PATTERN).build();
for (int i = 0; i < count; i++) {
- Thread t = factory.newThread(r);
+ final Thread t = factory.newThread(r);
assertEquals("Wrong thread name", String.format(PATTERN, Long
.valueOf(i + 1)), t.getName());
assertEquals("Wrong thread count", i + 1, factory.getThreadCount());
@@ -153,13 +153,13 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadNoNamingPattern() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
final String name = "unchangedThreadName";
- Thread t = new Thread(name);
+ final Thread t = new Thread(name);
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Name was changed", name, t.getName());
EasyMock.verify(wrapped, r);
@@ -171,12 +171,12 @@ public class BasicThreadFactoryTest {
* @param flag the value of the flag
*/
private void checkDaemonFlag(final boolean flag) {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
- Thread t = new Thread();
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
+ final Thread t = new Thread();
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).daemon(
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).daemon(
flag).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertTrue("Wrong daemon flag", flag == t.isDaemon());
@@ -205,16 +205,16 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadNoDaemonFlag() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r1 = EasyMock.createMock(Runnable.class);
- Runnable r2 = EasyMock.createMock(Runnable.class);
- Thread t1 = new Thread();
- Thread t2 = new Thread();
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r1 = EasyMock.createMock(Runnable.class);
+ final Runnable r2 = EasyMock.createMock(Runnable.class);
+ final Thread t1 = new Thread();
+ final Thread t2 = new Thread();
t1.setDaemon(true);
EasyMock.expect(wrapped.newThread(r1)).andReturn(t1);
EasyMock.expect(wrapped.newThread(r2)).andReturn(t2);
EasyMock.replay(wrapped, r1, r2);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
assertSame("Wrong thread 1", t1, factory.newThread(r1));
assertTrue("No daemon thread", t1.isDaemon());
assertSame("Wrong thread 2", t2, factory.newThread(r2));
@@ -227,13 +227,13 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadPriority() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
- Thread t = new Thread();
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
+ final Thread t = new Thread();
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r);
final int priority = Thread.NORM_PRIORITY + 1;
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).priority(
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).priority(
priority).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Wrong priority", priority, t.getPriority());
@@ -246,14 +246,14 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadNoPriority() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
final int orgPriority = Thread.NORM_PRIORITY + 1;
- Thread t = new Thread();
+ final Thread t = new Thread();
t.setPriority(orgPriority);
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Wrong priority", orgPriority, t.getPriority());
EasyMock.verify(wrapped, r);
@@ -264,14 +264,14 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadExHandler() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
- Thread.UncaughtExceptionHandler handler = EasyMock
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
+ final Thread.UncaughtExceptionHandler handler = EasyMock
.createMock(Thread.UncaughtExceptionHandler.class);
- Thread t = new Thread();
+ final Thread t = new Thread();
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r, handler);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped)
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped)
.uncaughtExceptionHandler(handler).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Wrong exception handler", handler, t
@@ -285,15 +285,15 @@ public class BasicThreadFactoryTest {
*/
@Test
public void testNewThreadNoExHandler() {
- ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
- Runnable r = EasyMock.createMock(Runnable.class);
- Thread.UncaughtExceptionHandler handler = EasyMock
+ final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
+ final Runnable r = EasyMock.createMock(Runnable.class);
+ final Thread.UncaughtExceptionHandler handler = EasyMock
.createMock(Thread.UncaughtExceptionHandler.class);
- Thread t = new Thread();
+ final Thread t = new Thread();
t.setUncaughtExceptionHandler(handler);
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r, handler);
- BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
+ final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Wrong exception handler", handler, t
.getUncaughtExceptionHandler());
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
index af80f2f93..3e966c273 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
@@ -48,8 +48,8 @@ public class CallableBackgroundInitializerTest {
*/
@Test
public void testInitExecutor() {
- ExecutorService exec = Executors.newSingleThreadExecutor();
- CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
+ final ExecutorService exec = Executors.newSingleThreadExecutor();
+ final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
new TestCallable(), exec);
assertEquals("Executor not set", exec, init.getExternalExecutor());
}
@@ -60,7 +60,7 @@ public class CallableBackgroundInitializerTest {
*/
@Test(expected=IllegalArgumentException.class)
public void testInitExecutorNullCallable() {
- ExecutorService exec = Executors.newSingleThreadExecutor();
+ final ExecutorService exec = Executors.newSingleThreadExecutor();
new CallableBackgroundInitializer<Integer>(null, exec);
}
@@ -69,8 +69,8 @@ public class CallableBackgroundInitializerTest {
*/
@Test
public void testInitialize() throws Exception {
- TestCallable call = new TestCallable();
- CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
+ final TestCallable call = new TestCallable();
+ final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
call);
assertEquals("Wrong result", RESULT, init.initialize());
assertEquals("Wrong number of invocations", 1, call.callCount);
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java b/src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java
index d0aff7544..602573128 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/ConcurrentUtilsTest.java
@@ -108,11 +108,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseError() {
- Error err = new AssertionError("Test");
+ final Error err = new AssertionError("Test");
try {
ConcurrentUtils.extractCause(new ExecutionException(err));
fail("Error not thrown!");
- } catch (Error e) {
+ } catch (final Error e) {
assertEquals("Wrong error", err, e);
}
}
@@ -122,11 +122,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseUncheckedException() {
- RuntimeException rex = new RuntimeException("Test");
+ final RuntimeException rex = new RuntimeException("Test");
try {
ConcurrentUtils.extractCause(new ExecutionException(rex));
fail("Runtime exception not thrown!");
- } catch (RuntimeException r) {
+ } catch (final RuntimeException r) {
assertEquals("Wrong exception", rex, r);
}
}
@@ -136,8 +136,8 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseChecked() {
- Exception ex = new Exception("Test");
- ConcurrentException cex = ConcurrentUtils
+ final Exception ex = new Exception("Test");
+ final ConcurrentException cex = ConcurrentUtils
.extractCause(new ExecutionException(ex));
assertSame("Wrong cause", ex, cex.getCause());
}
@@ -164,11 +164,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseUncheckedError() {
- Error err = new AssertionError("Test");
+ final Error err = new AssertionError("Test");
try {
ConcurrentUtils.extractCauseUnchecked(new ExecutionException(err));
fail("Error not thrown!");
- } catch (Error e) {
+ } catch (final Error e) {
assertEquals("Wrong error", err, e);
}
}
@@ -178,11 +178,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseUncheckedUncheckedException() {
- RuntimeException rex = new RuntimeException("Test");
+ final RuntimeException rex = new RuntimeException("Test");
try {
ConcurrentUtils.extractCauseUnchecked(new ExecutionException(rex));
fail("Runtime exception not thrown!");
- } catch (RuntimeException r) {
+ } catch (final RuntimeException r) {
assertEquals("Wrong exception", rex, r);
}
}
@@ -192,8 +192,8 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testExtractCauseUncheckedChecked() {
- Exception ex = new Exception("Test");
- ConcurrentRuntimeException cex = ConcurrentUtils
+ final Exception ex = new Exception("Test");
+ final ConcurrentRuntimeException cex = ConcurrentUtils
.extractCauseUnchecked(new ExecutionException(ex));
assertSame("Wrong cause", ex, cex.getCause());
}
@@ -203,11 +203,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseError() throws ConcurrentException {
- Error err = new AssertionError("Test");
+ final Error err = new AssertionError("Test");
try {
ConcurrentUtils.handleCause(new ExecutionException(err));
fail("Error not thrown!");
- } catch (Error e) {
+ } catch (final Error e) {
assertEquals("Wrong error", err, e);
}
}
@@ -217,11 +217,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseUncheckedException() throws ConcurrentException {
- RuntimeException rex = new RuntimeException("Test");
+ final RuntimeException rex = new RuntimeException("Test");
try {
ConcurrentUtils.handleCause(new ExecutionException(rex));
fail("Runtime exception not thrown!");
- } catch (RuntimeException r) {
+ } catch (final RuntimeException r) {
assertEquals("Wrong exception", rex, r);
}
}
@@ -231,11 +231,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseChecked() {
- Exception ex = new Exception("Test");
+ final Exception ex = new Exception("Test");
try {
ConcurrentUtils.handleCause(new ExecutionException(ex));
fail("ConcurrentException not thrown!");
- } catch (ConcurrentException cex) {
+ } catch (final ConcurrentException cex) {
assertEquals("Wrong cause", ex, cex.getCause());
}
}
@@ -256,11 +256,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseUncheckedError() {
- Error err = new AssertionError("Test");
+ final Error err = new AssertionError("Test");
try {
ConcurrentUtils.handleCauseUnchecked(new ExecutionException(err));
fail("Error not thrown!");
- } catch (Error e) {
+ } catch (final Error e) {
assertEquals("Wrong error", err, e);
}
}
@@ -270,11 +270,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseUncheckedUncheckedException() {
- RuntimeException rex = new RuntimeException("Test");
+ final RuntimeException rex = new RuntimeException("Test");
try {
ConcurrentUtils.handleCauseUnchecked(new ExecutionException(rex));
fail("Runtime exception not thrown!");
- } catch (RuntimeException r) {
+ } catch (final RuntimeException r) {
assertEquals("Wrong exception", rex, r);
}
}
@@ -284,11 +284,11 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testHandleCauseUncheckedChecked() {
- Exception ex = new Exception("Test");
+ final Exception ex = new Exception("Test");
try {
ConcurrentUtils.handleCauseUnchecked(new ExecutionException(ex));
fail("ConcurrentRuntimeException not thrown!");
- } catch (ConcurrentRuntimeException crex) {
+ } catch (final ConcurrentRuntimeException crex) {
assertEquals("Wrong cause", ex, crex.getCause());
}
}
@@ -320,6 +320,7 @@ public class ConcurrentUtilsTest {
@Test
public void testInitialize() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Object> init = EasyMock
.createMock(ConcurrentInitializer.class);
final Object result = new Object();
@@ -344,6 +345,7 @@ public class ConcurrentUtilsTest {
@Test
public void testInitializeUnchecked() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Object> init = EasyMock
.createMock(ConcurrentInitializer.class);
final Object result = new Object();
@@ -360,6 +362,7 @@ public class ConcurrentUtilsTest {
@Test
public void testInitializeUncheckedEx() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Object> init = EasyMock
.createMock(ConcurrentInitializer.class);
final Exception cause = new Exception();
@@ -368,7 +371,7 @@ public class ConcurrentUtilsTest {
try {
ConcurrentUtils.initializeUnchecked(init);
fail("Exception not thrown!");
- } catch (ConcurrentRuntimeException crex) {
+ } catch (final ConcurrentRuntimeException crex) {
assertSame("Wrong cause", cause, crex.getCause());
}
EasyMock.verify(init);
@@ -380,8 +383,8 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testConstantFuture_Integer() throws Exception {
- Integer value = Integer.valueOf(5);
- Future<Integer> test = ConcurrentUtils.constantFuture(value);
+ final Integer value = Integer.valueOf(5);
+ final Future<Integer> test = ConcurrentUtils.constantFuture(value);
assertTrue(test.isDone());
assertSame(value, test.get());
assertSame(value, test.get(1000, TimeUnit.SECONDS));
@@ -396,8 +399,8 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testConstantFuture_null() throws Exception {
- Integer value = null;
- Future<Integer> test = ConcurrentUtils.constantFuture(value);
+ final Integer value = null;
+ final Future<Integer> test = ConcurrentUtils.constantFuture(value);
assertTrue(test.isDone());
assertSame(value, test.get());
assertSame(value, test.get(1000, TimeUnit.SECONDS));
@@ -415,7 +418,7 @@ public class ConcurrentUtilsTest {
public void testPutIfAbsentKeyPresent() {
final String key = "testKey";
final Integer value = 42;
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
map.put(key, value);
assertEquals("Wrong result", value,
ConcurrentUtils.putIfAbsent(map, key, 0));
@@ -429,7 +432,7 @@ public class ConcurrentUtilsTest {
public void testPutIfAbsentKeyNotPresent() {
final String key = "testKey";
final Integer value = 42;
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
assertEquals("Wrong result", value,
ConcurrentUtils.putIfAbsent(map, key, value));
assertEquals("Wrong value in map", value, map.get(key));
@@ -450,12 +453,13 @@ public class ConcurrentUtilsTest {
@Test
public void testCreateIfAbsentKeyPresent() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Integer> init = EasyMock
.createMock(ConcurrentInitializer.class);
EasyMock.replay(init);
final String key = "testKey";
final Integer value = 42;
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
map.put(key, value);
assertEquals("Wrong result", value,
ConcurrentUtils.createIfAbsent(map, key, init));
@@ -469,13 +473,14 @@ public class ConcurrentUtilsTest {
@Test
public void testCreateIfAbsentKeyNotPresent() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Integer> init = EasyMock
.createMock(ConcurrentInitializer.class);
final String key = "testKey";
final Integer value = 42;
EasyMock.expect(init.get()).andReturn(value);
EasyMock.replay(init);
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
assertEquals("Wrong result", value,
ConcurrentUtils.createIfAbsent(map, key, init));
assertEquals("Wrong value in map", value, map.get(key));
@@ -488,6 +493,7 @@ public class ConcurrentUtilsTest {
@Test
public void testCreateIfAbsentNullMap() throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Integer> init = EasyMock
.createMock(ConcurrentInitializer.class);
EasyMock.replay(init);
@@ -501,7 +507,7 @@ public class ConcurrentUtilsTest {
*/
@Test
public void testCreateIfAbsentNullInit() throws ConcurrentException {
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
final String key = "testKey";
final Integer value = 42;
map.put(key, value);
@@ -517,7 +523,7 @@ public class ConcurrentUtilsTest {
public void testCreateIfAbsentUncheckedSuccess() {
final String key = "testKey";
final Integer value = 42;
- ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
+ final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
assertEquals("Wrong result", value,
ConcurrentUtils.createIfAbsentUnchecked(map, key,
new ConstantInitializer<Integer>(value)));
@@ -531,16 +537,17 @@ public class ConcurrentUtilsTest {
public void testCreateIfAbsentUncheckedException()
throws ConcurrentException {
@SuppressWarnings("unchecked")
+ final
ConcurrentInitializer<Integer> init = EasyMock
.createMock(ConcurrentInitializer.class);
- Exception ex = new Exception();
+ final Exception ex = new Exception();
EasyMock.expect(init.get()).andThrow(new ConcurrentException(ex));
EasyMock.replay(init);
try {
ConcurrentUtils.createIfAbsentUnchecked(
new ConcurrentHashMap<String, Integer>(), "test", init);
fail("Exception not thrown!");
- } catch (ConcurrentRuntimeException crex) {
+ } catch (final ConcurrentRuntimeException crex) {
assertEquals("Wrong cause", ex, crex.getCause());
}
EasyMock.verify(init);
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java
index 08ca837d2..bfde80e15 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java
@@ -115,8 +115,8 @@ public class ConstantInitializerTest {
*/
@Test
public void testToString() {
- String s = init.toString();
- Pattern pattern = Pattern
+ final String s = init.toString();
+ final Pattern pattern = Pattern
.compile("ConstantInitializer@\\d+ \\[ object = " + VALUE
+ " \\]");
assertTrue("Wrong string: " + s, pattern.matcher(s).matches());
@@ -127,7 +127,7 @@ public class ConstantInitializerTest {
*/
@Test
public void testToStringNull() {
- String s = new ConstantInitializer<Object>(null).toString();
+ final String s = new ConstantInitializer<Object>(null).toString();
assertTrue("Object not found: " + s, s.indexOf("object = null") > 0);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
index 6ca12ae29..40009d3ac 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
@@ -58,8 +58,8 @@ public class MultiBackgroundInitializerTest {
*/
private void checkChild(final BackgroundInitializer<?> child,
final ExecutorService expExec) throws ConcurrentException {
- ChildBackgroundInitializer cinit = (ChildBackgroundInitializer) child;
- Integer result = cinit.get();
+ final ChildBackgroundInitializer cinit = (ChildBackgroundInitializer) child;
+ final Integer result = cinit.get();
assertEquals("Wrong result", 1, result.intValue());
assertEquals("Wrong number of executions", 1, cinit.initializeCalls);
if (expExec != null) {
@@ -92,7 +92,7 @@ public class MultiBackgroundInitializerTest {
@Test
public void testInitializeNoChildren() throws ConcurrentException {
assertTrue("Wrong result of start()", initializer.start());
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
assertTrue("Got child initializers", res.initializerNames().isEmpty());
assertTrue("Executor not shutdown", initializer.getActiveExecutor()
@@ -113,12 +113,12 @@ public class MultiBackgroundInitializerTest {
new ChildBackgroundInitializer());
}
initializer.start();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
assertEquals("Wrong number of child initializers", count, res
.initializerNames().size());
for (int i = 0; i < count; i++) {
- String key = CHILD_INIT + i;
+ final String key = CHILD_INIT + i;
assertTrue("Name not found: " + key, res.initializerNames()
.contains(key));
assertEquals("Wrong result object", Integer.valueOf(1), res
@@ -145,7 +145,7 @@ public class MultiBackgroundInitializerTest {
*/
@Test
public void testInitializeExternalExec() throws ConcurrentException {
- ExecutorService exec = Executors.newCachedThreadPool();
+ final ExecutorService exec = Executors.newCachedThreadPool();
try {
initializer = new MultiBackgroundInitializer(exec);
checkInitialize();
@@ -164,10 +164,10 @@ public class MultiBackgroundInitializerTest {
@Test
public void testInitializeChildWithExecutor() throws ConcurrentException {
final String initExec = "childInitializerWithExecutor";
- ExecutorService exec = Executors.newSingleThreadExecutor();
+ final ExecutorService exec = Executors.newSingleThreadExecutor();
try {
- ChildBackgroundInitializer c1 = new ChildBackgroundInitializer();
- ChildBackgroundInitializer c2 = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer c1 = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer c2 = new ChildBackgroundInitializer();
c2.setExternalExecutor(exec);
initializer.addInitializer(CHILD_INIT, c1);
initializer.addInitializer(initExec, c2);
@@ -191,7 +191,7 @@ public class MultiBackgroundInitializerTest {
initializer.addInitializer(CHILD_INIT,
new ChildBackgroundInitializer());
fail("Could add initializer after start()!");
- } catch (IllegalStateException istex) {
+ } catch (final IllegalStateException istex) {
initializer.get();
}
}
@@ -202,7 +202,7 @@ public class MultiBackgroundInitializerTest {
*/
@Test(expected = NoSuchElementException.class)
public void testResultGetInitializerUnknown() throws ConcurrentException {
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
res.getInitializer("unknown");
}
@@ -212,7 +212,7 @@ public class MultiBackgroundInitializerTest {
*/
@Test(expected = NoSuchElementException.class)
public void testResultGetResultObjectUnknown() throws ConcurrentException {
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
res.getResultObject("unknown");
}
@@ -222,7 +222,7 @@ public class MultiBackgroundInitializerTest {
*/
@Test(expected = NoSuchElementException.class)
public void testResultGetExceptionUnknown() throws ConcurrentException {
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
res.getException("unknown");
}
@@ -232,7 +232,7 @@ public class MultiBackgroundInitializerTest {
*/
@Test(expected = NoSuchElementException.class)
public void testResultIsExceptionUnknown() throws ConcurrentException {
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = checkInitialize();
res.isException("unknown");
}
@@ -242,9 +242,9 @@ public class MultiBackgroundInitializerTest {
@Test(expected = UnsupportedOperationException.class)
public void testResultInitializerNamesModify() throws ConcurrentException {
checkInitialize();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
- Iterator<String> it = res.initializerNames().iterator();
+ final Iterator<String> it = res.initializerNames().iterator();
it.next();
it.remove();
}
@@ -255,14 +255,14 @@ public class MultiBackgroundInitializerTest {
*/
@Test
public void testInitializeRuntimeEx() {
- ChildBackgroundInitializer child = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer child = new ChildBackgroundInitializer();
child.ex = new RuntimeException();
initializer.addInitializer(CHILD_INIT, child);
initializer.start();
try {
initializer.get();
fail("Runtime exception not thrown!");
- } catch (Exception ex) {
+ } catch (final Exception ex) {
assertEquals("Wrong exception", child.ex, ex);
}
}
@@ -273,15 +273,15 @@ public class MultiBackgroundInitializerTest {
*/
@Test
public void testInitializeEx() throws ConcurrentException {
- ChildBackgroundInitializer child = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer child = new ChildBackgroundInitializer();
child.ex = new Exception();
initializer.addInitializer(CHILD_INIT, child);
initializer.start();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
assertTrue("No exception flag", res.isException(CHILD_INIT));
assertNull("Got a results object", res.getResultObject(CHILD_INIT));
- ConcurrentException cex = res.getException(CHILD_INIT);
+ final ConcurrentException cex = res.getException(CHILD_INIT);
assertEquals("Wrong cause", child.ex, cex.getCause());
}
@@ -292,10 +292,10 @@ public class MultiBackgroundInitializerTest {
@Test
public void testInitializeResultsIsSuccessfulTrue()
throws ConcurrentException {
- ChildBackgroundInitializer child = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer child = new ChildBackgroundInitializer();
initializer.addInitializer(CHILD_INIT, child);
initializer.start();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
assertTrue("Wrong success flag", res.isSuccessful());
}
@@ -307,11 +307,11 @@ public class MultiBackgroundInitializerTest {
@Test
public void testInitializeResultsIsSuccessfulFalse()
throws ConcurrentException {
- ChildBackgroundInitializer child = new ChildBackgroundInitializer();
+ final ChildBackgroundInitializer child = new ChildBackgroundInitializer();
child.ex = new Exception();
initializer.addInitializer(CHILD_INIT, child);
initializer.start();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
assertFalse("Wrong success flag", res.isSuccessful());
}
@@ -325,7 +325,7 @@ public class MultiBackgroundInitializerTest {
final String nameMulti = "multiChildInitializer";
initializer
.addInitializer(CHILD_INIT, new ChildBackgroundInitializer());
- MultiBackgroundInitializer mi2 = new MultiBackgroundInitializer();
+ final MultiBackgroundInitializer mi2 = new MultiBackgroundInitializer();
final int count = 3;
for (int i = 0; i < count; i++) {
mi2
@@ -334,11 +334,11 @@ public class MultiBackgroundInitializerTest {
}
initializer.addInitializer(nameMulti, mi2);
initializer.start();
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res = initializer
.get();
- ExecutorService exec = initializer.getActiveExecutor();
+ final ExecutorService exec = initializer.getActiveExecutor();
checkChild(res.getInitializer(CHILD_INIT), exec);
- MultiBackgroundInitializer.MultiBackgroundInitializerResults res2 = (MultiBackgroundInitializer.MultiBackgroundInitializerResults) res
+ final MultiBackgroundInitializer.MultiBackgroundInitializerResults res2 = (MultiBackgroundInitializer.MultiBackgroundInitializerResults) res
.getResultObject(nameMulti);
assertEquals("Wrong number of initializers", count, res2
.initializerNames().size());
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java b/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java
index 36ddcfb2b..c9bd68b62 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java
@@ -51,10 +51,10 @@ public class TimedSemaphoreTest {
*/
@Test
public void testInit() {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
EasyMock.replay(service);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
EasyMock.verify(service);
assertEquals("Wrong service", service, semaphore.getExecutorService());
@@ -83,8 +83,8 @@ public class TimedSemaphoreTest {
*/
@Test
public void testInitDefaultService() {
- TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
- ScheduledThreadPoolExecutor exec = (ScheduledThreadPoolExecutor) semaphore
+ final TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
+ final ScheduledThreadPoolExecutor exec = (ScheduledThreadPoolExecutor) semaphore
.getExecutorService();
assertFalse("Wrong periodic task policy", exec
.getContinueExistingPeriodicTasksAfterShutdownPolicy());
@@ -99,9 +99,9 @@ public class TimedSemaphoreTest {
*/
@Test
public void testStartTimer() throws InterruptedException {
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(PERIOD,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(PERIOD,
UNIT, LIMIT);
- ScheduledFuture<?> future = semaphore.startTimer();
+ final ScheduledFuture<?> future = semaphore.startTimer();
assertNotNull("No future returned", future);
Thread.sleep(PERIOD);
final int trials = 10;
@@ -121,7 +121,7 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownOwnExecutor() {
- TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
+ final TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
semaphore.shutdown();
assertTrue("Not shutdown", semaphore.isShutdown());
assertTrue("Executor not shutdown", semaphore.getExecutorService()
@@ -134,10 +134,10 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownSharedExecutorNoTask() {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
EasyMock.replay(service);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
semaphore.shutdown();
assertTrue("Not shutdown", semaphore.isShutdown());
@@ -163,13 +163,13 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownSharedExecutorTask() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.expect(Boolean.valueOf(future.cancel(false))).andReturn(Boolean.TRUE);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, LIMIT);
semaphore.acquire();
semaphore.shutdown();
@@ -182,13 +182,13 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownMultipleTimes() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.expect(Boolean.valueOf(future.cancel(false))).andReturn(Boolean.TRUE);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, LIMIT);
semaphore.acquire();
for (int i = 0; i < 10; i++) {
@@ -202,15 +202,15 @@ public class TimedSemaphoreTest {
*/
@Test
public void testAcquireLimit() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
final int count = 10;
- CountDownLatch latch = new CountDownLatch(count - 1);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT, 1);
- SemaphoreThread t = new SemaphoreThread(semaphore, latch, count,
+ final CountDownLatch latch = new CountDownLatch(count - 1);
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT, 1);
+ final SemaphoreThread t = new SemaphoreThread(semaphore, latch, count,
count - 1);
semaphore.setLimit(count - 1);
@@ -239,16 +239,16 @@ public class TimedSemaphoreTest {
*/
@Test
public void testAcquireMultipleThreads() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, 1);
semaphore.latch = new CountDownLatch(1);
final int count = 10;
- SemaphoreThread[] threads = new SemaphoreThread[count];
+ final SemaphoreThread[] threads = new SemaphoreThread[count];
for (int i = 0; i < count; i++) {
threads[i] = new SemaphoreThread(semaphore, null, 1, 0);
threads[i].start();
@@ -274,16 +274,16 @@ public class TimedSemaphoreTest {
*/
@Test
public void testAcquireNoLimit() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, TimedSemaphore.NO_LIMIT);
final int count = 1000;
- CountDownLatch latch = new CountDownLatch(count);
- SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
+ final CountDownLatch latch = new CountDownLatch(count);
+ final SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
t.start();
latch.await();
EasyMock.verify(service, future);
@@ -294,7 +294,7 @@ public class TimedSemaphoreTest {
*/
@Test(expected = IllegalStateException.class)
public void testPassAfterShutdown() throws InterruptedException {
- TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
+ final TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
semaphore.shutdown();
semaphore.acquire();
}
@@ -308,11 +308,11 @@ public class TimedSemaphoreTest {
@Test
public void testAcquireMultiplePeriods() throws InterruptedException {
final int count = 1000;
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(
PERIOD / 10, TimeUnit.MILLISECONDS, 1);
semaphore.setLimit(count / 4);
- CountDownLatch latch = new CountDownLatch(count);
- SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
+ final CountDownLatch latch = new CountDownLatch(count);
+ final SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
t.start();
latch.await();
semaphore.shutdown();
@@ -324,12 +324,12 @@ public class TimedSemaphoreTest {
*/
@Test
public void testGetAverageCallsPerPeriod() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
semaphore.acquire();
semaphore.endOfPeriod();
@@ -348,12 +348,12 @@ public class TimedSemaphoreTest {
*/
@Test
public void testGetAvailablePermits() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
for (int i = 0; i < LIMIT; i++) {
assertEquals("Wrong available count at " + i, LIMIT - i, semaphore
@@ -470,7 +470,7 @@ public class TimedSemaphoreTest {
latch.countDown();
}
}
- } catch (InterruptedException iex) {
+ } catch (final InterruptedException iex) {
Thread.currentThread().interrupt();
}
}
diff --git a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
index 1e3b0f095..1685d4895 100644
--- a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
+++ b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
@@ -45,21 +45,21 @@ public class EventListenerSupportTest
@Test(expected=NullPointerException.class)
public void testAddNullListener()
{
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.addListener(null);
}
@Test(expected=NullPointerException.class)
public void testRemoveNullListener()
{
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.removeListener(null);
}
@Test
public void testEventDispatchOrder() throws PropertyVetoException
{
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
final List<VetoableChangeListener> calledListeners = new ArrayList<VetoableChangeListener>();
final VetoableChangeListener listener1 = createListener(calledListeners);
@@ -101,17 +101,17 @@ public class EventListenerSupportTest
public void testGetListeners() {
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
- VetoableChangeListener[] listeners = listenerSupport.getListeners();
+ final VetoableChangeListener[] listeners = listenerSupport.getListeners();
assertEquals(0, listeners.length);
assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType());
- VetoableChangeListener[] empty = listeners;
+ final VetoableChangeListener[] empty = listeners;
//for fun, show that the same empty instance is used
assertSame(empty, listenerSupport.getListeners());
- VetoableChangeListener listener1 = EasyMock.createNiceMock(VetoableChangeListener.class);
+ final VetoableChangeListener listener1 = EasyMock.createNiceMock(VetoableChangeListener.class);
listenerSupport.addListener(listener1);
assertEquals(1, listenerSupport.getListeners().length);
- VetoableChangeListener listener2 = EasyMock.createNiceMock(VetoableChangeListener.class);
+ final VetoableChangeListener listener2 = EasyMock.createNiceMock(VetoableChangeListener.class);
listenerSupport.addListener(listener2);
assertEquals(2, listenerSupport.getListeners().length);
listenerSupport.removeListener(listener1);
@@ -122,7 +122,7 @@ public class EventListenerSupportTest
@Test
public void testSerialization() throws IOException, ClassNotFoundException, PropertyVetoException {
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.addListener(new VetoableChangeListener() {
@Override
@@ -132,25 +132,26 @@ public class EventListenerSupportTest
listenerSupport.addListener(EasyMock.createNiceMock(VetoableChangeListener.class));
//serialize:
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ final ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
objectOutputStream.writeObject(listenerSupport);
objectOutputStream.close();
//deserialize:
@SuppressWarnings("unchecked")
+ final
EventListenerSupport<VetoableChangeListener> deserializedListenerSupport = (EventListenerSupport<VetoableChangeListener>) new ObjectInputStream(
new ByteArrayInputStream(outputStream.toByteArray())).readObject();
//make sure we get a listener array back, of the correct component type, and that it contains only the serializable mock
- VetoableChangeListener[] listeners = deserializedListenerSupport.getListeners();
+ final VetoableChangeListener[] listeners = deserializedListenerSupport.getListeners();
assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType());
assertEquals(1, listeners.length);
//now verify that the mock still receives events; we can infer that the proxy was correctly reconstituted
- VetoableChangeListener listener = listeners[0];
- PropertyChangeEvent evt = new PropertyChangeEvent(new Date(), "Day", 7, 9);
+ final VetoableChangeListener listener = listeners[0];
+ final PropertyChangeEvent evt = new PropertyChangeEvent(new Date(), "Day", 7, 9);
listener.vetoableChange(evt);
EasyMock.replay(listener);
deserializedListenerSupport.fire().vetoableChange(evt);
@@ -165,6 +166,7 @@ public class EventListenerSupportTest
public void testSubclassInvocationHandling() throws PropertyVetoException {
@SuppressWarnings("serial")
+ final
EventListenerSupport<VetoableChangeListener> eventListenerSupport = new EventListenerSupport<VetoableChangeListener>(
VetoableChangeListener.class) {
@Override
@@ -184,11 +186,11 @@ public class EventListenerSupportTest
}
};
- VetoableChangeListener listener = EasyMock.createNiceMock(VetoableChangeListener.class);
+ final VetoableChangeListener listener = EasyMock.createNiceMock(VetoableChangeListener.class);
eventListenerSupport.addListener(listener);
- Object source = new Date();
- PropertyChangeEvent ignore = new PropertyChangeEvent(source, "Hour", 5, 6);
- PropertyChangeEvent respond = new PropertyChangeEvent(source, "Day", 6, 7);
+ final Object source = new Date();
+ final PropertyChangeEvent ignore = new PropertyChangeEvent(source, "Hour", 5, 6);
+ final PropertyChangeEvent respond = new PropertyChangeEvent(source, "Day", 6, 7);
listener.vetoableChange(respond);
EasyMock.replay(listener);
eventListenerSupport.fire().vetoableChange(ignore);
diff --git a/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java b/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
index a7b44e307..2178ea455 100644
--- a/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
@@ -48,7 +48,7 @@ public class EventUtilsTest
@Test
public void testConstructor() {
assertNotNull(new EventUtils());
- Constructor<?>[] cons = EventUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = EventUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(EventUtils.class.getModifiers()));
@@ -59,8 +59,8 @@ public class EventUtilsTest
public void testAddEventListener()
{
final PropertyChangeSource src = new PropertyChangeSource();
- EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
- PropertyChangeListener listener = handler.createListener(PropertyChangeListener.class);
+ final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
+ final PropertyChangeListener listener = handler.createListener(PropertyChangeListener.class);
assertEquals(0, handler.getEventCount("propertyChange"));
EventUtils.addEventListener(src, PropertyChangeListener.class, listener);
assertEquals(0, handler.getEventCount("propertyChange"));
@@ -72,14 +72,14 @@ public class EventUtilsTest
public void testAddEventListenerWithNoAddMethod()
{
final PropertyChangeSource src = new PropertyChangeSource();
- EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
- ObjectChangeListener listener = handler.createListener(ObjectChangeListener.class);
+ final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
+ final ObjectChangeListener listener = handler.createListener(ObjectChangeListener.class);
try
{
EventUtils.addEventListener(src, ObjectChangeListener.class, listener);
fail("Should not be allowed to add a listener to an object that doesn't support it.");
}
- catch (IllegalArgumentException e)
+ catch (final IllegalArgumentException e)
{
assertEquals("Class " + src.getClass().getName() + " does not have a public add" + ObjectChangeListener.class.getSimpleName() + " method which takes a parameter of type " + ObjectChangeListener.class.getName() + ".", e.getMessage());
}
@@ -101,7 +101,7 @@ public class EventUtilsTest
});
fail("Add method should have thrown an exception, so method should fail.");
}
- catch (RuntimeException e)
+ catch (final RuntimeException e)
{
}
@@ -111,14 +111,14 @@ public class EventUtilsTest
public void testAddEventListenerWithPrivateAddMethod()
{
final PropertyChangeSource src = new PropertyChangeSource();
- EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
- VetoableChangeListener listener = handler.createListener(VetoableChangeListener.class);
+ final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
+ final VetoableChangeListener listener = handler.createListener(VetoableChangeListener.class);
try
{
EventUtils.addEventListener(src, VetoableChangeListener.class, listener);
fail("Should not be allowed to add a listener to an object that doesn't support it.");
}
- catch (IllegalArgumentException e)
+ catch (final IllegalArgumentException e)
{
assertEquals("Class " + src.getClass().getName() + " does not have a public add" + VetoableChangeListener.class.getSimpleName() + " method which takes a parameter of type " + VetoableChangeListener.class.getName() + ".", e.getMessage());
}
@@ -212,14 +212,14 @@ public class EventUtilsTest
public int getEventCount(final String eventName)
{
- Integer count = eventCounts.get(eventName);
+ final Integer count = eventCounts.get(eventName);
return count == null ? 0 : count.intValue();
}
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable
{
- Integer count = eventCounts.get(method.getName());
+ final Integer count = eventCounts.get(method.getName());
if (count == null)
{
eventCounts.put(method.getName(), Integer.valueOf(1));
@@ -258,7 +258,7 @@ public class EventUtilsTest
public void setProperty(final String property)
{
- String oldValue = this.property;
+ final String oldValue = this.property;
this.property = property;
listeners.fire().propertyChange(new PropertyChangeEvent(this, "property", oldValue, property));
}
diff --git a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
index 457de710d..cf9035c6b 100644
--- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
@@ -59,7 +59,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
@Test
public void testAddContextValue() {
- String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
+ final String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
assertTrue(message.indexOf(TEST_MESSAGE) >= 0);
assertTrue(message.indexOf("test1") >= 0);
assertTrue(message.indexOf("test2") >= 0);
@@ -81,7 +81,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
assertEquals(5, exceptionContext.getContextLabels().size());
assertTrue(exceptionContext.getContextLabels().contains("test2"));
- String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
+ final String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
}
@@ -90,7 +90,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
exceptionContext.addContextValue("test2", "different value");
exceptionContext.setContextValue("test3", "3");
- String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
+ final String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
assertTrue(message.indexOf(TEST_MESSAGE) >= 0);
assertTrue(message.indexOf("test Poorly written obj") >= 0);
assertTrue(message.indexOf("Crap") >= 0);
@@ -114,7 +114,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
assertEquals(6, exceptionContext.getContextEntries().size());
assertEquals(6, exceptionContext.getContextLabels().size());
- String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
+ final String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
}
@@ -149,7 +149,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
exceptionContext.addContextValue("test2", "different value");
- Set<String> labels = exceptionContext.getContextLabels();
+ final Set<String> labels = exceptionContext.getContextLabels();
assertEquals(6, exceptionContext.getContextEntries().size());
assertEquals(5, labels.size());
assertTrue(labels.contains("test1"));
@@ -164,7 +164,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
exceptionContext.addContextValue("test2", "different value");
- List<Pair<String, Object>> entries = exceptionContext.getContextEntries();
+ final List<Pair<String, Object>> entries = exceptionContext.getContextEntries();
assertEquals(6, entries.size());
assertEquals("test1", entries.get(0).getKey());
assertEquals("test2", entries.get(1).getKey());
@@ -178,7 +178,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
public void testJavaSerialization() {
exceptionContext.setContextValue("test Poorly written obj", "serializable replacement");
- T clone = SerializationUtils.deserialize(SerializationUtils.serialize(exceptionContext));
+ final T clone = SerializationUtils.deserialize(SerializationUtils.serialize(exceptionContext));
assertEquals(exceptionContext.getFormattedExceptionMessage(null), clone.getFormattedExceptionMessage(null));
}
}
diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
index ac5400059..48703a505 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
@@ -39,8 +39,8 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
@Test
public void testContextedException() {
exceptionContext = new ContextedException();
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(StringUtils.isEmpty(message));
}
@@ -50,15 +50,15 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
exceptionContext = new ContextedException(TEST_MESSAGE);
assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
}
@Test
public void testContextedExceptionThrowable() {
exceptionContext = new ContextedException(new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(message.indexOf(TEST_MESSAGE)>=0);
@@ -67,8 +67,8 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
@Test
public void testContextedExceptionStringThrowable() {
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -78,8 +78,8 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
@Test
public void testContextedExceptionStringThrowableContext() {
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -95,7 +95,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
- String message = exceptionContext.getMessage();
+ final String message = exceptionContext.getMessage();
assertTrue(message != null);
}
diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
index 24f2ea3b6..7eca04205 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
@@ -41,8 +41,8 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
@Test
public void testContextedException() {
exceptionContext = new ContextedRuntimeException();
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(StringUtils.isEmpty(message));
}
@@ -52,15 +52,15 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE);
assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
}
@Test
public void testContextedExceptionThrowable() {
exceptionContext = new ContextedRuntimeException(new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(message.indexOf(TEST_MESSAGE)>=0);
@@ -69,8 +69,8 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
@Test
public void testContextedExceptionStringThrowable() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -80,8 +80,8 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
@Test
public void testContextedExceptionStringThrowableContext() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext() {});
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -97,7 +97,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
- String message = exceptionContext.getMessage();
+ final String message = exceptionContext.getMessage();
assertTrue(message != null);
}
diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
index b5d5913a9..15e7e0e92 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
@@ -64,8 +64,8 @@ public class ExceptionUtilsTest {
nested = new NestableException(withoutCause);
withCause = new ExceptionWithCause(nested);
jdkNoCause = new NullPointerException();
- ExceptionWithCause a = new ExceptionWithCause(null);
- ExceptionWithCause b = new ExceptionWithCause(a);
+ final ExceptionWithCause a = new ExceptionWithCause(null);
+ final ExceptionWithCause b = new ExceptionWithCause(a);
a.setCause(b);
cyclicCause = new ExceptionWithCause(a);
}
@@ -84,7 +84,7 @@ public class ExceptionUtilsTest {
private Throwable createExceptionWithoutCause() {
try {
throw new ExceptionWithoutCause();
- } catch (Throwable t) {
+ } catch (final Throwable t) {
return t;
}
}
@@ -93,10 +93,10 @@ public class ExceptionUtilsTest {
try {
try {
throw new ExceptionWithCause(createExceptionWithoutCause());
- } catch (Throwable t) {
+ } catch (final Throwable t) {
throw new ExceptionWithCause(t);
}
- } catch (Throwable t) {
+ } catch (final Throwable t) {
return t;
}
}
@@ -106,7 +106,7 @@ public class ExceptionUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new ExceptionUtils());
- Constructor<?>[] cons = ExceptionUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = ExceptionUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ExceptionUtils.class.getModifiers()));
@@ -176,14 +176,14 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowables_Throwable_withoutCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(withoutCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(withoutCause);
assertEquals(1, throwables.length);
assertSame(withoutCause, throwables[0]);
}
@Test
public void testGetThrowables_Throwable_nested() {
- Throwable[] throwables = ExceptionUtils.getThrowables(nested);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(nested);
assertEquals(2, throwables.length);
assertSame(nested, throwables[0]);
assertSame(withoutCause, throwables[1]);
@@ -191,7 +191,7 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowables_Throwable_withCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(withCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(withCause);
assertEquals(3, throwables.length);
assertSame(withCause, throwables[0]);
assertSame(nested, throwables[1]);
@@ -200,14 +200,14 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowables_Throwable_jdkNoCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(jdkNoCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(jdkNoCause);
assertEquals(1, throwables.length);
assertSame(jdkNoCause, throwables[0]);
}
@Test
public void testGetThrowables_Throwable_recursiveCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(cyclicCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(cyclicCause);
assertEquals(3, throwables.length);
assertSame(cyclicCause, throwables[0]);
assertSame(cyclicCause.getCause(), throwables[1]);
@@ -217,20 +217,20 @@ public class ExceptionUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testGetThrowableList_Throwable_null() {
- List<?> throwables = ExceptionUtils.getThrowableList(null);
+ final List<?> throwables = ExceptionUtils.getThrowableList(null);
assertEquals(0, throwables.size());
}
@Test
public void testGetThrowableList_Throwable_withoutCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(withoutCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(withoutCause);
assertEquals(1, throwables.size());
assertSame(withoutCause, throwables.get(0));
}
@Test
public void testGetThrowableList_Throwable_nested() {
- List<?> throwables = ExceptionUtils.getThrowableList(nested);
+ final List<?> throwables = ExceptionUtils.getThrowableList(nested);
assertEquals(2, throwables.size());
assertSame(nested, throwables.get(0));
assertSame(withoutCause, throwables.get(1));
@@ -238,7 +238,7 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowableList_Throwable_withCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(withCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(withCause);
assertEquals(3, throwables.size());
assertSame(withCause, throwables.get(0));
assertSame(nested, throwables.get(1));
@@ -247,14 +247,14 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowableList_Throwable_jdkNoCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(jdkNoCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(jdkNoCause);
assertEquals(1, throwables.size());
assertSame(jdkNoCause, throwables.get(0));
}
@Test
public void testGetThrowableList_Throwable_recursiveCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(cyclicCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(cyclicCause);
assertEquals(3, throwables.size());
assertSame(cyclicCause, throwables.get(0));
assertSame(cyclicCause.getCause(), throwables.get(1));
@@ -384,11 +384,11 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.printRootCauseStackTrace(withCause, (PrintStream) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
out = new ByteArrayOutputStream(1024);
- Throwable withCause = createExceptionWithCause();
+ final Throwable withCause = createExceptionWithCause();
ExceptionUtils.printRootCauseStackTrace(withCause, new PrintStream(out));
String stackTrace = out.toString();
assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) != -1);
@@ -410,11 +410,11 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.printRootCauseStackTrace(withCause, (PrintWriter) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
writer = new StringWriter(1024);
- Throwable withCause = createExceptionWithCause();
+ final Throwable withCause = createExceptionWithCause();
ExceptionUtils.printRootCauseStackTrace(withCause, new PrintWriter(writer));
String stackTrace = writer.toString();
assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) != -1);
@@ -430,10 +430,10 @@ public class ExceptionUtilsTest {
public void testGetRootCauseStackTrace_Throwable() throws Exception {
assertEquals(0, ExceptionUtils.getRootCauseStackTrace(null).length);
- Throwable withCause = createExceptionWithCause();
+ final Throwable withCause = createExceptionWithCause();
String[] stackTrace = ExceptionUtils.getRootCauseStackTrace(withCause);
boolean match = false;
- for (String element : stackTrace) {
+ for (final String element : stackTrace) {
if (element.startsWith(ExceptionUtils.WRAPPED_MARKER)) {
match = true;
break;
@@ -443,7 +443,7 @@ public class ExceptionUtilsTest {
stackTrace = ExceptionUtils.getRootCauseStackTrace(withoutCause);
match = false;
- for (String element : stackTrace) {
+ for (final String element : stackTrace) {
if (element.startsWith(ExceptionUtils.WRAPPED_MARKER)) {
match = true;
break;
diff --git a/src/test/java/org/apache/commons/lang3/math/FractionTest.java b/src/test/java/org/apache/commons/lang3/math/FractionTest.java
index aa81f65b2..b1bca6819 100644
--- a/src/test/java/org/apache/commons/lang3/math/FractionTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/FractionTest.java
@@ -123,27 +123,27 @@ public class FractionTest {
try {
f = Fraction.getFraction(1, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(2, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-3, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// very large: can't represent as unsimplified fraction, although
try {
f = Fraction.getFraction(4, Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -172,17 +172,17 @@ public class FractionTest {
try {
f = Fraction.getFraction(1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// negative whole
f = Fraction.getFraction(-1, 6, 10);
@@ -192,43 +192,43 @@ public class FractionTest {
try {
f = Fraction.getFraction(-1, -6, 10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, 6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// zero denominator
try {
f = Fraction.getFraction(0, 1, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, 2, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, -3, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(Integer.MAX_VALUE, 1, 2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-Integer.MAX_VALUE, 1, 2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// very large
f = Fraction.getFraction(-1, 0, Integer.MAX_VALUE);
@@ -239,15 +239,15 @@ public class FractionTest {
// negative denominators not allowed in this constructor.
f = Fraction.getFraction(0, 4, Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, 1, Integer.MAX_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, 2, Integer.MAX_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
public void testReducedFactory_int_int() {
@@ -289,17 +289,17 @@ public class FractionTest {
try {
f = Fraction.getReducedFraction(1, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getReducedFraction(2, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getReducedFraction(-3, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// reduced
f = Fraction.getReducedFraction(0, 2);
@@ -332,7 +332,7 @@ public class FractionTest {
try {
f = Fraction.getReducedFraction(-7, Integer.MIN_VALUE);
fail("Expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// LANG-662
f = Fraction.getReducedFraction(Integer.MIN_VALUE, 2);
@@ -347,22 +347,22 @@ public class FractionTest {
try {
f = Fraction.getFraction(Double.NaN);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(Double.POSITIVE_INFINITY);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(Double.NEGATIVE_INFINITY);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction((double) Integer.MAX_VALUE + 1);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// zero
f = Fraction.getFraction(0.0d);
@@ -405,7 +405,7 @@ public class FractionTest {
for (int j = 1; j <= i; j++) { // numerator
try {
f = Fraction.getFraction((double) j / (double) i);
- } catch (ArithmeticException ex) {
+ } catch (final ArithmeticException ex) {
System.err.println(j + " " + i);
throw ex;
}
@@ -419,7 +419,7 @@ public class FractionTest {
for (int j = 1; j <= i; j++) { // numerator
try {
f = Fraction.getFraction((double) j / (double) i);
- } catch (ArithmeticException ex) {
+ } catch (final ArithmeticException ex) {
System.err.println(j + " " + i);
throw ex;
}
@@ -459,17 +459,17 @@ public class FractionTest {
try {
f = Fraction.getFraction("2.3R");
fail("Expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2147483648"); // too big
fail("Expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction(".");
fail("Expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
}
@Test
@@ -503,32 +503,32 @@ public class FractionTest {
try {
f = Fraction.getFraction("2 3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("a 3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2 b/4");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2 ");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction(" 3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction(" ");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
}
@Test
@@ -562,22 +562,22 @@ public class FractionTest {
try {
f = Fraction.getFraction("2/d");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2e/3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2/");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("/");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
}
@Test
@@ -686,14 +686,14 @@ public class FractionTest {
try {
f = f.invert();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// large values
f = Fraction.getFraction(Integer.MIN_VALUE, 1);
try {
f = f.invert();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f = Fraction.getFraction(Integer.MAX_VALUE, 1);
f = f.invert();
@@ -725,7 +725,7 @@ public class FractionTest {
try {
f = f.negate();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -756,7 +756,7 @@ public class FractionTest {
try {
f = f.abs();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -833,11 +833,11 @@ public class FractionTest {
try {
f = f.pow(-1);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = f.pow(Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// one to any power is still one.
f = Fraction.getFraction(1, 1);
@@ -856,20 +856,20 @@ public class FractionTest {
try {
f = f.pow(2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// Numerator growing too negative during the pow operation.
f = Fraction.getFraction(Integer.MIN_VALUE, 1);
try {
f = f.pow(3);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f = Fraction.getFraction(65536, 1);
try {
f = f.pow(2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -936,7 +936,7 @@ public class FractionTest {
try {
f.add(null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
// if this fraction is added naively, it will overflow.
// check that it doesn't.
@@ -961,7 +961,7 @@ public class FractionTest {
try {
f = f.add(Fraction.ONE); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// denominator should not be a multiple of 2 or 3 to trigger overflow
f1 = Fraction.getFraction(Integer.MIN_VALUE, 5);
@@ -969,26 +969,26 @@ public class FractionTest {
try {
f = f1.add(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(-Integer.MAX_VALUE, 1);
f = f.add(f);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(-Integer.MAX_VALUE, 1);
f = f.add(f);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f1 = Fraction.getFraction(3,327680);
f2 = Fraction.getFraction(2,59049);
try {
f = f1.add(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1047,7 +1047,7 @@ public class FractionTest {
try {
f.subtract(null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
// if this fraction is subtracted naively, it will overflow.
// check that it doesn't.
@@ -1074,7 +1074,7 @@ public class FractionTest {
f2 = Fraction.getFraction(1, Integer.MAX_VALUE - 1);
f = f1.subtract(f2);
fail("expecting ArithmeticException"); //should overflow
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// denominator should not be a multiple of 2 or 3 to trigger overflow
f1 = Fraction.getFraction(Integer.MIN_VALUE, 5);
@@ -1082,26 +1082,26 @@ public class FractionTest {
try {
f = f1.subtract(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(Integer.MIN_VALUE, 1);
f = f.subtract(Fraction.ONE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(Integer.MAX_VALUE, 1);
f = f.subtract(Fraction.ONE.negate());
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f1 = Fraction.getFraction(3,327680);
f2 = Fraction.getFraction(2,59049);
try {
f = f1.subtract(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1158,19 +1158,19 @@ public class FractionTest {
try {
f.multiplyBy(null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
f1 = Fraction.getFraction(1, Integer.MAX_VALUE);
f = f1.multiplyBy(f1); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f1 = Fraction.getFraction(1, -Integer.MAX_VALUE);
f = f1.multiplyBy(f1); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1190,7 +1190,7 @@ public class FractionTest {
try {
f = f1.divideBy(f2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f1 = Fraction.getFraction(0, 5);
f2 = Fraction.getFraction(2, 7);
@@ -1217,18 +1217,18 @@ public class FractionTest {
try {
f.divideBy(null);
fail("IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
f1 = Fraction.getFraction(1, Integer.MAX_VALUE);
f = f1.divideBy(f1.invert()); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f1 = Fraction.getFraction(1, -Integer.MAX_VALUE);
f = f1.divideBy(f1.invert()); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1256,7 +1256,7 @@ public class FractionTest {
@Test
public void testHashCode() {
- Fraction f1 = Fraction.getFraction(3, 5);
+ final Fraction f1 = Fraction.getFraction(3, 5);
Fraction f2 = Fraction.getFraction(3, 5);
assertTrue(f1.hashCode() == f2.hashCode());
@@ -1279,7 +1279,7 @@ public class FractionTest {
try {
f1.compareTo(null);
fail("expecting NullPointerException");
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
f2 = Fraction.getFraction(2, 5);
assertTrue(f1.compareTo(f2) > 0);
@@ -1308,7 +1308,7 @@ public class FractionTest {
Fraction f = null;
f = Fraction.getFraction(3, 5);
- String str = f.toString();
+ final String str = f.toString();
assertEquals("3/5", str);
assertSame(str, f.toString());
@@ -1336,7 +1336,7 @@ public class FractionTest {
Fraction f = null;
f = Fraction.getFraction(3, 5);
- String str = f.toProperString();
+ final String str = f.toProperString();
assertEquals("3/5", str);
assertSame(str, f.toProperString());
diff --git a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
index 8fbccfac1..c3dc66f24 100644
--- a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
@@ -38,19 +38,19 @@ public class IEEE754rUtilsTest {
assertEquals(2.5f, IEEE754rUtils.max(1.2f, 2.5f, Float.NaN), 0.01);
assertTrue(Float.isNaN(IEEE754rUtils.max(Float.NaN, Float.NaN, Float.NaN)));
- double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertEquals(42.0, IEEE754rUtils.max(a), 0.01);
assertEquals(1.2, IEEE754rUtils.min(a), 0.01);
- double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertEquals(42.0, IEEE754rUtils.max(b), 0.01);
assertEquals(1.2, IEEE754rUtils.min(b), 0.01);
- float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertEquals(1.2f, IEEE754rUtils.min(aF), 0.01);
assertEquals(42.0f, IEEE754rUtils.max(aF), 0.01);
- float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertEquals(1.2f, IEEE754rUtils.min(bF), 0.01);
assertEquals(42.0f, IEEE754rUtils.max(bF), 0.01);
}
@@ -60,42 +60,42 @@ public class IEEE754rUtilsTest {
try {
IEEE754rUtils.min( (float[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.min(new float[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max( (float[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max(new float[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.min( (double[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.min(new double[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max( (double[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max(new double[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
}
diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
index 8a11b520e..389cc8af7 100644
--- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
@@ -42,7 +42,7 @@ public class NumberUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new NumberUtils());
- Constructor<?>[] cons = NumberUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = NumberUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(NumberUtils.class.getModifiers()));
@@ -240,7 +240,7 @@ public class NumberUtilsTest {
try {
NumberUtils.createNumber("--1.1E-700F");
fail("Expected NumberFormatException");
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
// expected
}
}
@@ -287,9 +287,9 @@ public class NumberUtilsTest {
protected void testCreateFloatFailure(final String str) {
try {
- Float value = NumberUtils.createFloat(str);
+ final Float value = NumberUtils.createFloat(str);
fail("createFloat(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -307,9 +307,9 @@ public class NumberUtilsTest {
protected void testCreateDoubleFailure(final String str) {
try {
- Double value = NumberUtils.createDouble(str);
+ final Double value = NumberUtils.createDouble(str);
fail("createDouble(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -327,9 +327,9 @@ public class NumberUtilsTest {
protected void testCreateIntegerFailure(final String str) {
try {
- Integer value = NumberUtils.createInteger(str);
+ final Integer value = NumberUtils.createInteger(str);
fail("createInteger(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -347,9 +347,9 @@ public class NumberUtilsTest {
protected void testCreateLongFailure(final String str) {
try {
- Long value = NumberUtils.createLong(str);
+ final Long value = NumberUtils.createLong(str);
fail("createLong(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -379,9 +379,9 @@ public class NumberUtilsTest {
protected void testCreateBigIntegerFailure(final String str) {
try {
- BigInteger value = NumberUtils.createBigInteger(str);
+ final BigInteger value = NumberUtils.createBigInteger(str);
fail("createBigInteger(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -405,9 +405,9 @@ public class NumberUtilsTest {
protected void testCreateBigDecimalFailure(final String str) {
try {
- BigDecimal value = NumberUtils.createBigDecimal(str);
+ final BigDecimal value = NumberUtils.createBigDecimal(str);
fail("createBigDecimal(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -720,12 +720,12 @@ public class NumberUtilsTest {
try {
NumberUtils.max(d);
fail("No exception was thrown for null input.");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
NumberUtils.max(new double[0]);
fail("No exception was thrown for empty input.");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
assertEquals(
"max(double[]) failed for array length 1",
@@ -801,9 +801,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumShort() {
- short low = 1234;
- short mid = 1234 + 1;
- short high = 1234 + 2;
+ final short low = 1234;
+ final short mid = 1234 + 1;
+ final short high = 1234 + 2;
assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(low, mid, high));
assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(mid, low, high));
assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(mid, high, low));
@@ -812,9 +812,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumByte() {
- byte low = 123;
- byte mid = 123 + 1;
- byte high = 123 + 2;
+ final byte low = 123;
+ final byte mid = 123 + 1;
+ final byte high = 123 + 2;
assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(low, mid, high));
assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(mid, low, high));
assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(mid, high, low));
@@ -823,9 +823,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumDouble() {
- double low = 12.3;
- double mid = 12.3 + 1;
- double high = 12.3 + 2;
+ final double low = 12.3;
+ final double mid = 12.3 + 1;
+ final double high = 12.3 + 2;
assertEquals(low, NumberUtils.min(low, mid, high), 0.0001);
assertEquals(low, NumberUtils.min(mid, low, high), 0.0001);
assertEquals(low, NumberUtils.min(mid, high, low), 0.0001);
@@ -835,9 +835,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumFloat() {
- float low = 12.3f;
- float mid = 12.3f + 1;
- float high = 12.3f + 2;
+ final float low = 12.3f;
+ final float mid = 12.3f + 1;
+ final float high = 12.3f + 2;
assertEquals(low, NumberUtils.min(low, mid, high), 0.0001f);
assertEquals(low, NumberUtils.min(mid, low, high), 0.0001f);
assertEquals(low, NumberUtils.min(mid, high, low), 0.0001f);
@@ -865,9 +865,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumShort() {
- short low = 1234;
- short mid = 1234 + 1;
- short high = 1234 + 2;
+ final short low = 1234;
+ final short mid = 1234 + 1;
+ final short high = 1234 + 2;
assertEquals("maximum(short,short,short) 1 failed", high, NumberUtils.max(low, mid, high));
assertEquals("maximum(short,short,short) 1 failed", high, NumberUtils.max(mid, low, high));
assertEquals("maximum(short,short,short) 1 failed", high, NumberUtils.max(mid, high, low));
@@ -876,9 +876,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumByte() {
- byte low = 123;
- byte mid = 123 + 1;
- byte high = 123 + 2;
+ final byte low = 123;
+ final byte mid = 123 + 1;
+ final byte high = 123 + 2;
assertEquals("maximum(byte,byte,byte) 1 failed", high, NumberUtils.max(low, mid, high));
assertEquals("maximum(byte,byte,byte) 1 failed", high, NumberUtils.max(mid, low, high));
assertEquals("maximum(byte,byte,byte) 1 failed", high, NumberUtils.max(mid, high, low));
@@ -887,9 +887,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumDouble() {
- double low = 12.3;
- double mid = 12.3 + 1;
- double high = 12.3 + 2;
+ final double low = 12.3;
+ final double mid = 12.3 + 1;
+ final double high = 12.3 + 2;
assertEquals(high, NumberUtils.max(low, mid, high), 0.0001);
assertEquals(high, NumberUtils.max(mid, low, high), 0.0001);
assertEquals(high, NumberUtils.max(mid, high, low), 0.0001);
@@ -899,9 +899,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumFloat() {
- float low = 12.3f;
- float mid = 12.3f + 1;
- float high = 12.3f + 2;
+ final float low = 12.3f;
+ final float mid = 12.3f + 1;
+ final float high = 12.3f + 2;
assertEquals(high, NumberUtils.max(low, mid, high), 0.0001f);
assertEquals(high, NumberUtils.max(mid, low, high), 0.0001f);
assertEquals(high, NumberUtils.max(mid, high, low), 0.0001f);
@@ -1256,12 +1256,12 @@ public class NumberUtilsTest {
private boolean checkCreateNumber(final String val) {
try {
- Object obj = NumberUtils.createNumber(val);
+ final Object obj = NumberUtils.createNumber(val);
if (obj == null) {
return false;
}
return true;
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return false;
}
}
@@ -1322,18 +1322,18 @@ public class NumberUtilsTest {
assertTrue(Float.isNaN(NumberUtils.min(1.2f, 2.5f, Float.NaN)));
assertTrue(Float.isNaN(NumberUtils.max(1.2f, 2.5f, Float.NaN)));
- double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertTrue(Double.isNaN(NumberUtils.max(a)));
assertTrue(Double.isNaN(NumberUtils.min(a)));
- double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertTrue(Double.isNaN(NumberUtils.max(b)));
assertTrue(Double.isNaN(NumberUtils.min(b)));
- float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertTrue(Float.isNaN(NumberUtils.max(aF)));
- float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertTrue(Float.isNaN(NumberUtils.max(bF)));
}
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
index 069cc3897..12d328330 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
@@ -118,7 +118,7 @@ public class MutableByteTest {
@Test
public void testPrimitiveValues() {
- MutableByte mutNum = new MutableByte( (byte) 1 );
+ final MutableByte mutNum = new MutableByte( (byte) 1 );
assertEquals( 1.0F, mutNum.floatValue(), 0 );
assertEquals( 1.0, mutNum.doubleValue(), 0 );
@@ -136,7 +136,7 @@ public class MutableByteTest {
@Test
public void testIncrement() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -145,7 +145,7 @@ public class MutableByteTest {
@Test
public void testDecrement() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -154,7 +154,7 @@ public class MutableByteTest {
@Test
public void testAddValuePrimitive() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add((byte)1);
assertEquals((byte) 2, mutNum.byteValue());
@@ -162,7 +162,7 @@ public class MutableByteTest {
@Test
public void testAddValueObject() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add(Integer.valueOf(1));
assertEquals((byte) 2, mutNum.byteValue());
@@ -170,7 +170,7 @@ public class MutableByteTest {
@Test
public void testSubtractValuePrimitive() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract((byte) 1);
assertEquals((byte) 0, mutNum.byteValue());
@@ -178,7 +178,7 @@ public class MutableByteTest {
@Test
public void testSubtractValueObject() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract(Integer.valueOf(1));
assertEquals((byte) 0, mutNum.byteValue());
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
index 5a2b1213b..1518062c3 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
@@ -130,7 +130,7 @@ public class MutableDoubleTest {
@Test
public void testPrimitiveValues() {
- MutableDouble mutNum = new MutableDouble(1.7);
+ final MutableDouble mutNum = new MutableDouble(1.7);
assertEquals( 1.7F, mutNum.floatValue(), 0 );
assertEquals( 1.7, mutNum.doubleValue(), 0 );
@@ -148,7 +148,7 @@ public class MutableDoubleTest {
@Test
public void testIncrement() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -157,7 +157,7 @@ public class MutableDoubleTest {
@Test
public void testDecrement() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -166,7 +166,7 @@ public class MutableDoubleTest {
@Test
public void testAddValuePrimitive() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.add(1.1d);
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
@@ -174,7 +174,7 @@ public class MutableDoubleTest {
@Test
public void testAddValueObject() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.add(Double.valueOf(1.1d));
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
@@ -182,7 +182,7 @@ public class MutableDoubleTest {
@Test
public void testSubtractValuePrimitive() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(0.9d);
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
@@ -190,7 +190,7 @@ public class MutableDoubleTest {
@Test
public void testSubtractValueObject() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(Double.valueOf(0.9d));
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
index 80971ca49..f4663b19d 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
@@ -130,7 +130,7 @@ public class MutableFloatTest {
@Test
public void testPrimitiveValues() {
- MutableFloat mutNum = new MutableFloat(1.7F);
+ final MutableFloat mutNum = new MutableFloat(1.7F);
assertEquals( 1, mutNum.intValue() );
assertEquals( 1.7, mutNum.doubleValue(), 0.00001 );
@@ -148,7 +148,7 @@ public class MutableFloatTest {
@Test
public void testIncrement() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -157,7 +157,7 @@ public class MutableFloatTest {
@Test
public void testDecrement() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -166,7 +166,7 @@ public class MutableFloatTest {
@Test
public void testAddValuePrimitive() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.add(1.1f);
assertEquals(2.1f, mutNum.floatValue(), 0.01f);
@@ -174,7 +174,7 @@ public class MutableFloatTest {
@Test
public void testAddValueObject() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.add(Float.valueOf(1.1f));
assertEquals(2.1f, mutNum.floatValue(), 0.01f);
@@ -182,7 +182,7 @@ public class MutableFloatTest {
@Test
public void testSubtractValuePrimitive() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.subtract(0.9f);
assertEquals(0.1f, mutNum.floatValue(), 0.01f);
@@ -190,7 +190,7 @@ public class MutableFloatTest {
@Test
public void testSubtractValueObject() {
- MutableFloat mutNum = new MutableFloat(1);
+ final MutableFloat mutNum = new MutableFloat(1);
mutNum.subtract(Float.valueOf(0.9f));
assertEquals(0.1f, mutNum.floatValue(), 0.01f);
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
index b223c91bd..e68eede87 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
@@ -125,7 +125,7 @@ public class MutableIntTest {
@Test
public void testPrimitiveValues() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
assertEquals( (byte) 1, mutNum.byteValue() );
assertEquals( (short) 1, mutNum.shortValue() );
@@ -142,7 +142,7 @@ public class MutableIntTest {
@Test
public void testIncrement() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -151,7 +151,7 @@ public class MutableIntTest {
@Test
public void testDecrement() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -160,7 +160,7 @@ public class MutableIntTest {
@Test
public void testAddValuePrimitive() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.add(1);
assertEquals(2, mutNum.intValue());
@@ -169,7 +169,7 @@ public class MutableIntTest {
@Test
public void testAddValueObject() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.add(Integer.valueOf(1));
assertEquals(2, mutNum.intValue());
@@ -178,7 +178,7 @@ public class MutableIntTest {
@Test
public void testSubtractValuePrimitive() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.subtract(1);
assertEquals(0, mutNum.intValue());
@@ -187,7 +187,7 @@ public class MutableIntTest {
@Test
public void testSubtractValueObject() {
- MutableInt mutNum = new MutableInt(1);
+ final MutableInt mutNum = new MutableInt(1);
mutNum.subtract(Integer.valueOf(1));
assertEquals(0, mutNum.intValue());
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
index 00ada45f6..350c7c055 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
@@ -118,7 +118,7 @@ public class MutableLongTest {
@Test
public void testPrimitiveValues() {
- MutableLong mutNum = new MutableLong(1L);
+ final MutableLong mutNum = new MutableLong(1L);
assertEquals( 1.0F, mutNum.floatValue(), 0 );
assertEquals( 1.0, mutNum.doubleValue(), 0 );
@@ -136,7 +136,7 @@ public class MutableLongTest {
@Test
public void testIncrement() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -145,7 +145,7 @@ public class MutableLongTest {
@Test
public void testDecrement() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -154,7 +154,7 @@ public class MutableLongTest {
@Test
public void testAddValuePrimitive() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.add(1);
assertEquals(2, mutNum.intValue());
@@ -163,7 +163,7 @@ public class MutableLongTest {
@Test
public void testAddValueObject() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.add(Long.valueOf(1));
assertEquals(2, mutNum.intValue());
@@ -172,7 +172,7 @@ public class MutableLongTest {
@Test
public void testSubtractValuePrimitive() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.subtract(1);
assertEquals(0, mutNum.intValue());
@@ -181,7 +181,7 @@ public class MutableLongTest {
@Test
public void testSubtractValueObject() {
- MutableLong mutNum = new MutableLong(1);
+ final MutableLong mutNum = new MutableLong(1);
mutNum.subtract(Long.valueOf(1));
assertEquals(0, mutNum.intValue());
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
index 4e5a7a116..07c3c1fce 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java
@@ -32,7 +32,7 @@ public class MutableObjectTest {
public void testConstructors() {
assertEquals(null, new MutableObject<String>().getValue());
- Integer i = Integer.valueOf(6);
+ final Integer i = Integer.valueOf(6);
assertSame(i, new MutableObject<Integer>(i).getValue());
assertSame("HI", new MutableObject<String>("HI").getValue());
assertSame(null, new MutableObject<Object>(null).getValue());
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
index 051e14db9..8384542fd 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
@@ -42,7 +42,7 @@ public class MutableShortTest {
try {
new MutableShort((Number)null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -65,7 +65,7 @@ public class MutableShortTest {
try {
mutNum.setValue(null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
@@ -108,12 +108,12 @@ public class MutableShortTest {
try {
mutNum.compareTo(null);
fail();
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
}
@Test
public void testPrimitiveValues() {
- MutableShort mutNum = new MutableShort( (short) 1 );
+ final MutableShort mutNum = new MutableShort( (short) 1 );
assertEquals( 1.0F, mutNum.floatValue(), 0 );
assertEquals( 1.0, mutNum.doubleValue(), 0 );
@@ -131,7 +131,7 @@ public class MutableShortTest {
@Test
public void testIncrement() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -140,7 +140,7 @@ public class MutableShortTest {
@Test
public void testDecrement() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -149,7 +149,7 @@ public class MutableShortTest {
@Test
public void testAddValuePrimitive() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.add((short) 1);
assertEquals((short) 2, mutNum.shortValue());
@@ -157,7 +157,7 @@ public class MutableShortTest {
@Test
public void testAddValueObject() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.add(Short.valueOf((short) 1));
assertEquals((short) 2, mutNum.shortValue());
@@ -165,7 +165,7 @@ public class MutableShortTest {
@Test
public void testSubtractValuePrimitive() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.subtract((short) 1);
assertEquals((short) 0, mutNum.shortValue());
@@ -173,7 +173,7 @@ public class MutableShortTest {
@Test
public void testSubtractValueObject() {
- MutableShort mutNum = new MutableShort((short) 1);
+ final MutableShort mutNum = new MutableShort((short) 1);
mutNum.subtract(Short.valueOf((short) 1));
assertEquals((short) 0, mutNum.shortValue());
diff --git a/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java
index d97edbdce..bfa6f51de 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java
@@ -132,19 +132,19 @@ public class ConstructorUtilsTest {
ConstructorUtils.invokeExactConstructor(TestBean.class,
NumberUtils.BYTE_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
ConstructorUtils.invokeExactConstructor(TestBean.class,
NumberUtils.LONG_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
ConstructorUtils.invokeExactConstructor(TestBean.class,
Boolean.TRUE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
}
@@ -214,7 +214,7 @@ public class ConstructorUtilsTest {
private void expectMatchingAccessibleConstructorParameterTypes(final Class<?> cls,
final Class<?>[] requestTypes, final Class<?>[] actualTypes) {
- Constructor<?> c = ConstructorUtils.getMatchingAccessibleConstructor(cls,
+ final Constructor<?> c = ConstructorUtils.getMatchingAccessibleConstructor(cls,
requestTypes);
assertTrue(toString(c.getParameterTypes()) + " not equals "
+ toString(actualTypes), Arrays.equals(actualTypes, c
diff --git a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
index a7ab28d81..869a231f0 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
@@ -67,7 +67,7 @@ public class FieldUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new FieldUtils());
- Constructor<?>[] cons = FieldUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = FieldUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(FieldUtils.class.getModifiers()));
@@ -228,7 +228,7 @@ public class FieldUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void testReadStaticFieldIllegalArgumentException2() throws Exception {
assertEquals(Foo.VALUE, FieldUtils.readStaticField(FieldUtils.getField(Foo.class, "VALUE")));
- Field nonStaticField = FieldUtils.getField(PublicChild.class, "s");
+ final Field nonStaticField = FieldUtils.getField(PublicChild.class, "s");
assumeNotNull(nonStaticField);
FieldUtils.readStaticField(nonStaticField);
}
@@ -246,7 +246,7 @@ public class FieldUtilsTest {
@Test(expected=IllegalArgumentException.class)
public void testReadStaticFieldForceAccessIllegalArgumentException2() throws Exception {
- Field nonStaticField = FieldUtils.getField(PublicChild.class, "s", true);
+ final Field nonStaticField = FieldUtils.getField(PublicChild.class, "s", true);
assumeNotNull(nonStaticField);
FieldUtils.readStaticField(nonStaticField);
}
@@ -261,28 +261,28 @@ public class FieldUtilsTest {
try {
FieldUtils.readStaticField(null, "none");
fail("null class should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(Foo.class, null);
fail("null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(Foo.class, "does_not_exist");
fail("a field that doesn't exist should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(PublicChild.class, "s");
fail("non-static field should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@@ -297,28 +297,28 @@ public class FieldUtilsTest {
try {
FieldUtils.readStaticField(null, "none", true);
fail("null class should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(Foo.class, null, true);
fail("null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(Foo.class, "does_not_exist", true);
fail("a field that doesn't exist should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readStaticField(PublicChild.class, "s", false);
fail("non-static field should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@@ -329,19 +329,19 @@ public class FieldUtilsTest {
try {
assertEquals("child", FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -353,32 +353,32 @@ public class FieldUtilsTest {
try {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@Test
public void testReadField() throws Exception {
- Field parentS = FieldUtils.getDeclaredField(parentClass, "s");
+ final Field parentS = FieldUtils.getDeclaredField(parentClass, "s");
assertEquals("s", FieldUtils.readField(parentS, publicChild));
assertEquals("s", FieldUtils.readField(parentS, publiclyShadowedChild));
assertEquals("s", FieldUtils.readField(parentS, privatelyShadowedChild));
- Field parentB = FieldUtils.getDeclaredField(parentClass, "b", true);
+ final Field parentB = FieldUtils.getDeclaredField(parentClass, "b", true);
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, publicChild));
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, publiclyShadowedChild));
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, privatelyShadowedChild));
- Field parentI = FieldUtils.getDeclaredField(parentClass, "i", true);
+ final Field parentI = FieldUtils.getDeclaredField(parentClass, "i", true);
assertEquals(I0, FieldUtils.readField(parentI, publicChild));
assertEquals(I0, FieldUtils.readField(parentI, publiclyShadowedChild));
assertEquals(I0, FieldUtils.readField(parentI, privatelyShadowedChild));
- Field parentD = FieldUtils.getDeclaredField(parentClass, "d", true);
+ final Field parentD = FieldUtils.getDeclaredField(parentClass, "d", true);
assertEquals(D0, FieldUtils.readField(parentD, publicChild));
assertEquals(D0, FieldUtils.readField(parentD, publiclyShadowedChild));
assertEquals(D0, FieldUtils.readField(parentD, privatelyShadowedChild));
@@ -386,29 +386,29 @@ public class FieldUtilsTest {
try {
FieldUtils.readField((Field)null, publicChild);
fail("a null field should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@Test
public void testReadFieldForceAccess() throws Exception {
- Field parentS = FieldUtils.getDeclaredField(parentClass, "s");
+ final Field parentS = FieldUtils.getDeclaredField(parentClass, "s");
parentS.setAccessible(false);
assertEquals("s", FieldUtils.readField(parentS, publicChild, true));
assertEquals("s", FieldUtils.readField(parentS, publiclyShadowedChild, true));
assertEquals("s", FieldUtils.readField(parentS, privatelyShadowedChild, true));
- Field parentB = FieldUtils.getDeclaredField(parentClass, "b", true);
+ final Field parentB = FieldUtils.getDeclaredField(parentClass, "b", true);
parentB.setAccessible(false);
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, publicChild, true));
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, publiclyShadowedChild, true));
assertEquals(Boolean.FALSE, FieldUtils.readField(parentB, privatelyShadowedChild, true));
- Field parentI = FieldUtils.getDeclaredField(parentClass, "i", true);
+ final Field parentI = FieldUtils.getDeclaredField(parentClass, "i", true);
parentI.setAccessible(false);
assertEquals(I0, FieldUtils.readField(parentI, publicChild, true));
assertEquals(I0, FieldUtils.readField(parentI, publiclyShadowedChild, true));
assertEquals(I0, FieldUtils.readField(parentI, privatelyShadowedChild, true));
- Field parentD = FieldUtils.getDeclaredField(parentClass, "d", true);
+ final Field parentD = FieldUtils.getDeclaredField(parentClass, "d", true);
parentD.setAccessible(false);
assertEquals(D0, FieldUtils.readField(parentD, publicChild, true));
assertEquals(D0, FieldUtils.readField(parentD, publiclyShadowedChild, true));
@@ -417,7 +417,7 @@ public class FieldUtilsTest {
try {
FieldUtils.readField((Field)null, publicChild, true);
fail("a null field should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@@ -431,54 +431,54 @@ public class FieldUtilsTest {
try {
FieldUtils.readField(publicChild, null);
fail("a null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readField((Object)null, "none");
fail("a null target should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
assertEquals(Boolean.FALSE, FieldUtils.readField(publicChild, "b"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(Boolean.TRUE, FieldUtils.readField(publiclyShadowedChild, "b"));
try {
assertEquals(Boolean.FALSE, FieldUtils.readField(privatelyShadowedChild, "b"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(I0, FieldUtils.readField(publicChild, "i"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(I1, FieldUtils.readField(publiclyShadowedChild, "i"));
try {
assertEquals(I0, FieldUtils.readField(privatelyShadowedChild, "i"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(D0, FieldUtils.readField(publicChild, "d"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(D1, FieldUtils.readField(publiclyShadowedChild, "d"));
try {
assertEquals(D0, FieldUtils.readField(privatelyShadowedChild, "d"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -501,14 +501,14 @@ public class FieldUtilsTest {
try {
FieldUtils.readField(publicChild, null, true);
fail("a null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readField((Object)null, "none", true);
fail("a null target should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
}
@@ -518,67 +518,67 @@ public class FieldUtilsTest {
try {
FieldUtils.readDeclaredField(publicChild, null);
fail("a null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readDeclaredField((Object)null, "none");
fail("a null target should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
assertEquals("s", FieldUtils.readDeclaredField(publicChild, "s"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals("ss", FieldUtils.readDeclaredField(publiclyShadowedChild, "s"));
try {
assertEquals("s", FieldUtils.readDeclaredField(privatelyShadowedChild, "s"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(publicChild, "b"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(Boolean.TRUE, FieldUtils.readDeclaredField(publiclyShadowedChild, "b"));
try {
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(privatelyShadowedChild, "b"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(I0, FieldUtils.readDeclaredField(publicChild, "i"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(I1, FieldUtils.readDeclaredField(publiclyShadowedChild, "i"));
try {
assertEquals(I0, FieldUtils.readDeclaredField(privatelyShadowedChild, "i"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
assertEquals(D0, FieldUtils.readDeclaredField(publicChild, "d"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(D1, FieldUtils.readDeclaredField(publiclyShadowedChild, "d"));
try {
assertEquals(D0, FieldUtils.readDeclaredField(privatelyShadowedChild, "d"));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -588,21 +588,21 @@ public class FieldUtilsTest {
try {
FieldUtils.readDeclaredField(publicChild, null, true);
fail("a null field name should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
FieldUtils.readDeclaredField((Object)null, "none", true);
fail("a null target should cause an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// expected
}
try {
assertEquals("s", FieldUtils.readDeclaredField(publicChild, "s", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals("ss", FieldUtils.readDeclaredField(publiclyShadowedChild, "s", true));
@@ -610,7 +610,7 @@ public class FieldUtilsTest {
try {
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(publicChild, "b", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(Boolean.TRUE, FieldUtils.readDeclaredField(publiclyShadowedChild, "b", true));
@@ -618,7 +618,7 @@ public class FieldUtilsTest {
try {
assertEquals(I0, FieldUtils.readDeclaredField(publicChild, "i", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(I1, FieldUtils.readDeclaredField(publiclyShadowedChild, "i", true));
@@ -626,7 +626,7 @@ public class FieldUtilsTest {
try {
assertEquals(D0, FieldUtils.readDeclaredField(publicChild, "d", true));
fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
assertEquals(D1, FieldUtils.readDeclaredField(publiclyShadowedChild, "d", true));
@@ -642,49 +642,49 @@ public class FieldUtilsTest {
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("mutablePackage");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("mutablePrivate");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PUBLIC");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PROTECTED");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PACKAGE");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE");
try {
FieldUtils.writeStaticField(field, "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
}
@@ -707,28 +707,28 @@ public class FieldUtilsTest {
try {
FieldUtils.writeStaticField(field, "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PROTECTED");
try {
FieldUtils.writeStaticField(field, "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PACKAGE");
try {
FieldUtils.writeStaticField(field, "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE");
try {
FieldUtils.writeStaticField(field, "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
}
@@ -740,43 +740,43 @@ public class FieldUtilsTest {
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "mutableProtected", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePackage", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePrivate", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PUBLIC", "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PROTECTED", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PACKAGE", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PRIVATE", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -794,25 +794,25 @@ public class FieldUtilsTest {
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PUBLIC", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PROTECTED", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PACKAGE", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PRIVATE", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
}
@@ -824,43 +824,43 @@ public class FieldUtilsTest {
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutableProtected", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePackage", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePrivate", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PUBLIC", "new");
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PROTECTED", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PACKAGE", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PRIVATE", "new");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -878,25 +878,25 @@ public class FieldUtilsTest {
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PUBLIC", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PROTECTED", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PACKAGE", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
try {
FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PRIVATE", "new", true);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
}
@@ -910,19 +910,19 @@ public class FieldUtilsTest {
try {
FieldUtils.writeField(field, publicChild, Boolean.TRUE);
fail("Expected IllegalAccessException");
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = parentClass.getDeclaredField("i");
try {
FieldUtils.writeField(field, publicChild, Integer.valueOf(Integer.MAX_VALUE));
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
field = parentClass.getDeclaredField("d");
try {
FieldUtils.writeField(field, publicChild, Double.valueOf(Double.MAX_VALUE));
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// pass
}
}
@@ -950,19 +950,19 @@ public class FieldUtilsTest {
try {
FieldUtils.writeField(publicChild, "b", Boolean.TRUE);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeField(publicChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeField(publicChild, "d", Double.valueOf(1.0));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
@@ -980,19 +980,19 @@ public class FieldUtilsTest {
try {
FieldUtils.writeField(privatelyShadowedChild, "b", Boolean.TRUE);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeField(privatelyShadowedChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeField(privatelyShadowedChild, "d", Double.valueOf(1.0));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -1032,25 +1032,25 @@ public class FieldUtilsTest {
try {
FieldUtils.writeDeclaredField(publicChild, "s", "S");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "b", Boolean.TRUE);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "d", Double.valueOf(1.0));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
@@ -1066,25 +1066,25 @@ public class FieldUtilsTest {
try {
FieldUtils.writeDeclaredField(privatelyShadowedChild, "s", "S");
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(privatelyShadowedChild, "b", Boolean.TRUE);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", Integer.valueOf(1));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(privatelyShadowedChild, "d", Double.valueOf(1.0));
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
}
@@ -1094,25 +1094,25 @@ public class FieldUtilsTest {
try {
FieldUtils.writeDeclaredField(publicChild, "s", "S", true);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "b", Boolean.TRUE, true);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "i", Integer.valueOf(1), true);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
try {
FieldUtils.writeDeclaredField(publicChild, "d", Double.valueOf(1.0), true);
fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// pass
}
diff --git a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
index 64917e2bb..b603e70b9 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
@@ -185,18 +185,18 @@ public class MethodUtilsTest {
MethodUtils
.invokeExactMethod(testBean, "foo", NumberUtils.BYTE_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
MethodUtils
.invokeExactMethod(testBean, "foo", NumberUtils.LONG_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
MethodUtils.invokeExactMethod(testBean, "foo", Boolean.TRUE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
}
@@ -226,7 +226,7 @@ public class MethodUtilsTest {
try {
MethodUtils.invokeStaticMethod(TestBean.class, "does_not_exist");
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
}
@@ -252,28 +252,28 @@ public class MethodUtilsTest {
MethodUtils.invokeExactStaticMethod(TestBean.class, "bar",
NumberUtils.BYTE_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
MethodUtils.invokeExactStaticMethod(TestBean.class, "bar",
NumberUtils.LONG_ONE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
try {
MethodUtils.invokeExactStaticMethod(TestBean.class, "bar",
Boolean.TRUE);
fail("should throw NoSuchMethodException");
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
}
@Test
public void testGetAccessibleInterfaceMethod() throws Exception {
- Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
- for (Class<?>[] element : p) {
- Method method = TestMutable.class.getMethod("getValue", element);
- Method accessibleMethod = MethodUtils.getAccessibleMethod(method);
+ final Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
+ for (final Class<?>[] element : p) {
+ final Method method = TestMutable.class.getMethod("getValue", element);
+ final Method accessibleMethod = MethodUtils.getAccessibleMethod(method);
assertNotSame(accessibleMethod, method);
assertSame(Mutable.class, accessibleMethod.getDeclaringClass());
}
@@ -281,18 +281,18 @@ public class MethodUtilsTest {
@Test
public void testGetAccessibleMethodPrivateInterface() throws Exception {
- Method expected = TestBeanWithInterfaces.class.getMethod("foo");
+ final Method expected = TestBeanWithInterfaces.class.getMethod("foo");
assertNotNull(expected);
- Method actual = MethodUtils.getAccessibleMethod(TestBeanWithInterfaces.class, "foo");
+ final Method actual = MethodUtils.getAccessibleMethod(TestBeanWithInterfaces.class, "foo");
assertNull(actual);
}
@Test
public void testGetAccessibleInterfaceMethodFromDescription()
throws Exception {
- Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
- for (Class<?>[] element : p) {
- Method accessibleMethod = MethodUtils.getAccessibleMethod(
+ final Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
+ for (final Class<?>[] element : p) {
+ final Method accessibleMethod = MethodUtils.getAccessibleMethod(
TestMutable.class, "getValue", element);
assertSame(Mutable.class, accessibleMethod.getDeclaringClass());
}
@@ -314,8 +314,8 @@ public class MethodUtilsTest {
@Test
public void testGetAccessibleMethodInaccessible() throws Exception {
- Method expected = TestBean.class.getDeclaredMethod("privateStuff");
- Method actual = MethodUtils.getAccessibleMethod(expected);
+ final Method expected = TestBean.class.getDeclaredMethod("privateStuff");
+ final Method actual = MethodUtils.getAccessibleMethod(expected);
assertNull(actual);
}
@@ -379,7 +379,7 @@ public class MethodUtilsTest {
private void expectMatchingAccessibleMethodParameterTypes(final Class<?> cls,
final String methodName, final Class<?>[] requestTypes, final Class<?>[] actualTypes) {
- Method m = MethodUtils.getMatchingAccessibleMethod(cls, methodName,
+ final Method m = MethodUtils.getMatchingAccessibleMethod(cls, methodName,
requestTypes);
assertTrue(toString(m.getParameterTypes()) + " not equals "
+ toString(actualTypes), Arrays.equals(actualTypes, m
diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
index 9aea0bbba..187b11c05 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
@@ -121,11 +121,11 @@ public class TypeUtilsTest<B> {
List<String>[] list11 = null;
List<? extends String>[] list12 = null;
List<? super String>[] list13;
- Class<?> clazz = getClass();
- Method method = clazz.getMethod("dummyMethod", List.class, List.class, List.class,
+ final Class<?> clazz = getClass();
+ final Method method = clazz.getMethod("dummyMethod", List.class, List.class, List.class,
List.class, List.class, List.class, List.class, List[].class, List[].class,
List[].class, List[].class, List[].class, List[].class, List[].class);
- Type[] types = method.getGenericParameterTypes();
+ final Type[] types = method.getGenericParameterTypes();
// list0 = list0;
delegateBooleanAssertion(types, 0, 0, true);
list1 = list0;
@@ -323,17 +323,17 @@ public class TypeUtilsTest<B> {
delegateBooleanAssertion(types, 13, 12, false);
// list13 = list13;
delegateBooleanAssertion(types, 13, 13, true);
- Type disType = getClass().getField("dis").getGenericType();
+ final Type disType = getClass().getField("dis").getGenericType();
// Reporter.log( ( ( ParameterizedType ) disType
// ).getOwnerType().getClass().toString() );
- Type datType = getClass().getField("dat").getGenericType();
- Type daType = getClass().getField("da").getGenericType();
- Type uhderType = getClass().getField("uhder").getGenericType();
- Type dingType = getClass().getField("ding").getGenericType();
- Type testerType = getClass().getField("tester").getGenericType();
- Type tester2Type = getClass().getField("tester2").getGenericType();
- Type dat2Type = getClass().getField("dat2").getGenericType();
- Type dat3Type = getClass().getField("dat3").getGenericType();
+ final Type datType = getClass().getField("dat").getGenericType();
+ final Type daType = getClass().getField("da").getGenericType();
+ final Type uhderType = getClass().getField("uhder").getGenericType();
+ final Type dingType = getClass().getField("ding").getGenericType();
+ final Type testerType = getClass().getField("tester").getGenericType();
+ final Type tester2Type = getClass().getField("tester2").getGenericType();
+ final Type dat2Type = getClass().getField("dat2").getGenericType();
+ final Type dat3Type = getClass().getField("dat3").getGenericType();
dis = dat;
Assert.assertTrue(TypeUtils.isAssignable(datType, disType));
// dis = da;
@@ -353,13 +353,13 @@ public class TypeUtilsTest<B> {
Assert.assertFalse(TypeUtils.isAssignable(datType, dat2Type));
// dat = dat3;
Assert.assertFalse(TypeUtils.isAssignable(dat3Type, datType));
- char ch = 0;
- boolean bo = false;
- byte by = 0;
- short sh = 0;
+ final char ch = 0;
+ final boolean bo = false;
+ final byte by = 0;
+ final short sh = 0;
int in = 0;
long lo = 0;
- float fl = 0;
+ final float fl = 0;
double du = 0;
du = ch;
Assert.assertTrue(TypeUtils.isAssignable(char.class, double.class));
@@ -383,17 +383,17 @@ public class TypeUtilsTest<B> {
Assert.assertFalse(TypeUtils.isAssignable(Integer.class, Long.class));
in = Integer.valueOf(0);
Assert.assertTrue(TypeUtils.isAssignable(Integer.class, int.class));
- Integer inte = in;
+ final Integer inte = in;
Assert.assertTrue(TypeUtils.isAssignable(int.class, Integer.class));
Assert.assertTrue(TypeUtils.isAssignable(int.class, Number.class));
Assert.assertTrue(TypeUtils.isAssignable(int.class, Object.class));
- Type intComparableType = getClass().getField("intComparable").getGenericType();
+ final Type intComparableType = getClass().getField("intComparable").getGenericType();
intComparable = 1;
Assert.assertTrue(TypeUtils.isAssignable(int.class, intComparableType));
Assert.assertTrue(TypeUtils.isAssignable(int.class, Comparable.class));
- Serializable ser = 1;
+ final Serializable ser = 1;
Assert.assertTrue(TypeUtils.isAssignable(int.class, Serializable.class));
- Type longComparableType = getClass().getField("longComparable").getGenericType();
+ final Type longComparableType = getClass().getField("longComparable").getGenericType();
// longComparable = 1;
Assert.assertFalse(TypeUtils.isAssignable(int.class, longComparableType));
// longComparable = Integer.valueOf( 0 );
@@ -401,24 +401,24 @@ public class TypeUtilsTest<B> {
// int[] ia;
// long[] la = ia;
Assert.assertFalse(TypeUtils.isAssignable(int[].class, long[].class));
- Integer[] ia = null;
- Type caType = getClass().getField("intWildcardComparable").getGenericType();
+ final Integer[] ia = null;
+ final Type caType = getClass().getField("intWildcardComparable").getGenericType();
intWildcardComparable = ia;
Assert.assertTrue(TypeUtils.isAssignable(Integer[].class, caType));
// int[] ina = ia;
Assert.assertFalse(TypeUtils.isAssignable(Integer[].class, int[].class));
- int[] ina = null;
+ final int[] ina = null;
Object[] oa;
// oa = ina;
Assert.assertFalse(TypeUtils.isAssignable(int[].class, Object[].class));
oa = new Integer[0];
Assert.assertTrue(TypeUtils.isAssignable(Integer[].class, Object[].class));
- Type bClassType = AClass.class.getField("bClass").getGenericType();
- Type cClassType = AClass.class.getField("cClass").getGenericType();
- Type dClassType = AClass.class.getField("dClass").getGenericType();
- Type eClassType = AClass.class.getField("eClass").getGenericType();
- Type fClassType = AClass.class.getField("fClass").getGenericType();
- AClass aClass = new AClass(new AAClass<String>());
+ final Type bClassType = AClass.class.getField("bClass").getGenericType();
+ final Type cClassType = AClass.class.getField("cClass").getGenericType();
+ final Type dClassType = AClass.class.getField("dClass").getGenericType();
+ final Type eClassType = AClass.class.getField("eClass").getGenericType();
+ final Type fClassType = AClass.class.getField("fClass").getGenericType();
+ final AClass aClass = new AClass(new AAClass<String>());
aClass.bClass = aClass.cClass;
Assert.assertTrue(TypeUtils.isAssignable(cClassType, bClassType));
aClass.bClass = aClass.dClass;
@@ -442,9 +442,9 @@ public class TypeUtilsTest<B> {
}
public void delegateBooleanAssertion(final Type[] types, final int i2, final int i1, final boolean expected) {
- Type type1 = types[i1];
- Type type2 = types[i2];
- boolean isAssignable = TypeUtils.isAssignable(type2, type1);
+ final Type type1 = types[i1];
+ final Type type2 = types[i2];
+ final boolean isAssignable = TypeUtils.isAssignable(type2, type1);
if (expected) {
Assert.assertTrue("[" + i1 + ", " + i2 + "]: From "
@@ -460,8 +460,8 @@ public class TypeUtilsTest<B> {
@SuppressWarnings("boxing") // boxing is deliberate here
@Test
public void testIsInstance() throws SecurityException, NoSuchFieldException {
- Type intComparableType = getClass().getField("intComparable").getGenericType();
- Type uriComparableType = getClass().getField("uriComparable").getGenericType();
+ final Type intComparableType = getClass().getField("intComparable").getGenericType();
+ final Type uriComparableType = getClass().getField("uriComparable").getGenericType();
intComparable = 1;
Assert.assertTrue(TypeUtils.isInstance(1, intComparableType));
// uriComparable = 1;
@@ -490,7 +490,7 @@ public class TypeUtilsTest<B> {
Assert.assertEquals("Type argument of Comparable from int: " + typeArg, Integer.class,
typeVarAssigns.get(treeSetTypeVar));
- Collection<Integer> col = Arrays.asList(new Integer[0]);
+ final Collection<Integer> col = Arrays.asList(new Integer[0]);
typeVarAssigns = TypeUtils.getTypeArguments(List.class, Collection.class);
treeSetTypeVar = Comparable.class.getTypeParameters()[0];
Assert.assertFalse("Type var assigns for Collection from List: " + typeVarAssigns,
@@ -510,8 +510,8 @@ public class TypeUtilsTest<B> {
@Test
public void testTypesSatisfyVariables() throws SecurityException, NoSuchFieldException,
NoSuchMethodException {
- Map<TypeVariable<?>, Type> typeVarAssigns = new HashMap<TypeVariable<?>, Type>();
- Integer max = TypeUtilsTest.stub();
+ final Map<TypeVariable<?>, Type> typeVarAssigns = new HashMap<TypeVariable<?>, Type>();
+ final Integer max = TypeUtilsTest.stub();
typeVarAssigns.put(getClass().getMethod("stub").getTypeParameters()[0], Integer.class);
Assert.assertTrue(TypeUtils.typesSatisfyVariables(typeVarAssigns));
typeVarAssigns.clear();
@@ -525,11 +525,11 @@ public class TypeUtilsTest<B> {
@Test
public void testDetermineTypeVariableAssignments() throws SecurityException,
NoSuchFieldException, NoSuchMethodException {
- ParameterizedType iterableType = (ParameterizedType) getClass().getField("iterable")
+ final ParameterizedType iterableType = (ParameterizedType) getClass().getField("iterable")
.getGenericType();
- Map<TypeVariable<?>, Type> typeVarAssigns = TypeUtils.determineTypeArguments(TreeSet.class,
+ final Map<TypeVariable<?>, Type> typeVarAssigns = TypeUtils.determineTypeArguments(TreeSet.class,
iterableType);
- TypeVariable<?> treeSetTypeVar = TreeSet.class.getTypeParameters()[0];
+ final TypeVariable<?> treeSetTypeVar = TreeSet.class.getTypeParameters()[0];
Assert.assertTrue(typeVarAssigns.containsKey(treeSetTypeVar));
Assert.assertEquals(iterableType.getActualTypeArguments()[0], typeVarAssigns
.get(treeSetTypeVar));
@@ -537,12 +537,12 @@ public class TypeUtilsTest<B> {
@Test
public void testGetRawType() throws SecurityException, NoSuchFieldException {
- Type stringParentFieldType = GenericTypeHolder.class.getDeclaredField("stringParent")
+ final Type stringParentFieldType = GenericTypeHolder.class.getDeclaredField("stringParent")
.getGenericType();
- Type integerParentFieldType = GenericTypeHolder.class.getDeclaredField("integerParent")
+ final Type integerParentFieldType = GenericTypeHolder.class.getDeclaredField("integerParent")
.getGenericType();
- Type foosFieldType = GenericTypeHolder.class.getDeclaredField("foos").getGenericType();
- Type genericParentT = GenericParent.class.getTypeParameters()[0];
+ final Type foosFieldType = GenericTypeHolder.class.getDeclaredField("foos").getGenericType();
+ final Type genericParentT = GenericParent.class.getTypeParameters()[0];
Assert.assertEquals(GenericParent.class, TypeUtils.getRawType(stringParentFieldType, null));
Assert
.assertEquals(GenericParent.class, TypeUtils.getRawType(integerParentFieldType,
@@ -588,11 +588,11 @@ public class TypeUtilsTest<B> {
@Test
public void testIsArrayGenericTypes() throws Exception {
- Method method = getClass().getMethod("dummyMethod", List.class, List.class, List.class,
+ final Method method = getClass().getMethod("dummyMethod", List.class, List.class, List.class,
List.class, List.class, List.class, List.class, List[].class, List[].class,
List[].class, List[].class, List[].class, List[].class, List[].class);
- Type[] types = method.getGenericParameterTypes();
+ final Type[] types = method.getGenericParameterTypes();
Assert.assertFalse(TypeUtils.isArrayType(types[0]));
Assert.assertFalse(TypeUtils.isArrayType(types[1]));
@@ -633,11 +633,11 @@ public class TypeUtilsTest<B> {
@Test
public void testGetArrayComponentType() throws Exception {
- Method method = getClass().getMethod("dummyMethod", List.class, List.class, List.class,
+ final Method method = getClass().getMethod("dummyMethod", List.class, List.class, List.class,
List.class, List.class, List.class, List.class, List[].class, List[].class,
List[].class, List[].class, List[].class, List[].class, List[].class);
- Type[] types = method.getGenericParameterTypes();
+ final Type[] types = method.getGenericParameterTypes();
Assert.assertNull(TypeUtils.getArrayComponentType(types[0]));
Assert.assertNull(TypeUtils.getArrayComponentType(types[1]));
@@ -657,8 +657,8 @@ public class TypeUtilsTest<B> {
@Test
public void testLang820() throws Exception {
- Type[] typeArray = {String.class, String.class};
- Type[] expectedArray = {String.class};
+ final Type[] typeArray = {String.class, String.class};
+ final Type[] expectedArray = {String.class};
Assert.assertArrayEquals(expectedArray, TypeUtils.normalizeUpperBounds(typeArray));
}
diff --git a/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java b/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java
index b8b13036c..c4329d320 100644
--- a/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java
@@ -36,7 +36,7 @@ public class CompositeFormatTest {
@Test
public void testCompositeFormat() {
- Format parser = new Format() {
+ final Format parser = new Format() {
@Override
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
throw new UnsupportedOperationException("Not implemented");
@@ -48,7 +48,7 @@ public class CompositeFormatTest {
}
};
- Format formatter = new Format() {
+ final Format formatter = new Format() {
@Override
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
return null; // do nothing
@@ -60,7 +60,7 @@ public class CompositeFormatTest {
}
};
- CompositeFormat composite = new CompositeFormat(parser, formatter);
+ final CompositeFormat composite = new CompositeFormat(parser, formatter);
composite.parseObject("", null);
composite.format(new Object(), new StringBuffer(), null);
@@ -70,10 +70,10 @@ public class CompositeFormatTest {
@Test
public void testUsage() throws Exception {
- Format f1 = new SimpleDateFormat("MMddyyyy", Locale.ENGLISH);
- Format f2 = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
- CompositeFormat c = new CompositeFormat(f1, f2);
- String testString = "January 3, 2005";
+ final Format f1 = new SimpleDateFormat("MMddyyyy", Locale.ENGLISH);
+ final Format f2 = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
+ final CompositeFormat c = new CompositeFormat(f1, f2);
+ final String testString = "January 3, 2005";
assertEquals(testString, c.format(c.parseObject("01032005")));
assertEquals(testString, c.reformat("01032005"));
}
diff --git a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
index 5b519767b..aa9845a75 100644
--- a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
@@ -59,8 +59,8 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testExtendedFormats() {
- String pattern = "Lower: {0,lower} Upper: {1,upper}";
- ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
+ final String pattern = "Lower: {0,lower} Upper: {1,upper}";
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
assertPatternsEqual("TOPATTERN", pattern, emf.toPattern());
assertEquals("Lower: foo Upper: BAR", emf.format(new Object[] {"foo", "bar"}));
assertEquals("Lower: foo Upper: BAR", emf.format(new Object[] {"Foo", "Bar"}));
@@ -74,8 +74,8 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testEscapedQuote_LANG_477() {
- String pattern = "it''s a {0,lower} 'test'!";
- ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
+ final String pattern = "it''s a {0,lower} 'test'!";
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
assertEquals("it's a dummy test!", emf.format(new Object[] {"DUMMY"}));
}
@@ -84,21 +84,21 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testExtendedAndBuiltInFormats() {
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 23, 18, 33, 05);
- Object[] args = new Object[] {"John Doe", cal.getTime(), Double.valueOf("12345.67")};
- String builtinsPattern = "DOB: {1,date,short} Salary: {2,number,currency}";
- String extendedPattern = "Name: {0,upper} ";
- String pattern = extendedPattern + builtinsPattern;
+ final Object[] args = new Object[] {"John Doe", cal.getTime(), Double.valueOf("12345.67")};
+ final String builtinsPattern = "DOB: {1,date,short} Salary: {2,number,currency}";
+ final String extendedPattern = "Name: {0,upper} ";
+ final String pattern = extendedPattern + builtinsPattern;
- HashSet<Locale> testLocales = new HashSet<Locale>();
+ final HashSet<Locale> testLocales = new HashSet<Locale>();
testLocales.addAll(Arrays.asList(DateFormat.getAvailableLocales()));
testLocales.retainAll(Arrays.asList(NumberFormat.getAvailableLocales()));
testLocales.add(null);
- for (Locale locale : testLocales) {
- MessageFormat builtins = createMessageFormat(builtinsPattern, locale);
- String expectedPattern = extendedPattern + builtins.toPattern();
+ for (final Locale locale : testLocales) {
+ final MessageFormat builtins = createMessageFormat(builtinsPattern, locale);
+ final String expectedPattern = extendedPattern + builtins.toPattern();
DateFormat df = null;
NumberFormat nf = null;
ExtendedMessageFormat emf = null;
@@ -111,7 +111,7 @@ public class ExtendedMessageFormatTest {
nf = NumberFormat.getCurrencyInstance(locale);
emf = new ExtendedMessageFormat(pattern, locale, registry);
}
- StringBuilder expected = new StringBuilder();
+ final StringBuilder expected = new StringBuilder();
expected.append("Name: ");
expected.append(args[0].toString().toUpperCase());
expected.append(" DOB: ");
@@ -183,17 +183,17 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testBuiltInChoiceFormat() {
- Object[] values = new Number[] {Integer.valueOf(1), Double.valueOf("2.2"), Double.valueOf("1234.5")};
+ final Object[] values = new Number[] {Integer.valueOf(1), Double.valueOf("2.2"), Double.valueOf("1234.5")};
String choicePattern = null;
- Locale[] availableLocales = ChoiceFormat.getAvailableLocales();
+ final Locale[] availableLocales = ChoiceFormat.getAvailableLocales();
choicePattern = "{0,choice,1#One|2#Two|3#Many {0,number}}";
- for (Object value : values) {
+ for (final Object value : values) {
checkBuiltInFormat(value + ": " + choicePattern, new Object[] {value}, availableLocales);
}
choicePattern = "{0,choice,1#''One''|2#\"Two\"|3#''{Many}'' {0,number}}";
- for (Object value : values) {
+ for (final Object value : values) {
checkBuiltInFormat(value + ": " + choicePattern, new Object[] {value}, availableLocales);
}
}
@@ -203,10 +203,10 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testBuiltInDateTimeFormat() {
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 23, 18, 33, 05);
- Object[] args = new Object[] {cal.getTime()};
- Locale[] availableLocales = DateFormat.getAvailableLocales();
+ final Object[] args = new Object[] {cal.getTime()};
+ final Locale[] availableLocales = DateFormat.getAvailableLocales();
checkBuiltInFormat("1: {0,date,short}", args, availableLocales);
checkBuiltInFormat("2: {0,date,medium}", args, availableLocales);
@@ -224,11 +224,11 @@ public class ExtendedMessageFormatTest {
@Test
public void testOverriddenBuiltinFormat() {
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 23);
- Object[] args = new Object[] {cal.getTime()};
- Locale[] availableLocales = DateFormat.getAvailableLocales();
- Map<String, ? extends FormatFactory> registry = Collections.singletonMap("date", new OverrideShortDateFormatFactory());
+ final Object[] args = new Object[] {cal.getTime()};
+ final Locale[] availableLocales = DateFormat.getAvailableLocales();
+ final Map<String, ? extends FormatFactory> registry = Collections.singletonMap("date", new OverrideShortDateFormatFactory());
//check the non-overridden builtins:
checkBuiltInFormat("1: {0,date}", registry, args, availableLocales);
@@ -239,10 +239,10 @@ public class ExtendedMessageFormatTest {
//check the overridden format:
for (int i = -1; i < availableLocales.length; i++) {
- Locale locale = i < 0 ? null : availableLocales[i];
- MessageFormat dateDefault = createMessageFormat("{0,date}", locale);
- String pattern = "{0,date,short}";
- ExtendedMessageFormat dateShort = new ExtendedMessageFormat(pattern, locale, registry);
+ final Locale locale = i < 0 ? null : availableLocales[i];
+ final MessageFormat dateDefault = createMessageFormat("{0,date}", locale);
+ final String pattern = "{0,date,short}";
+ final ExtendedMessageFormat dateShort = new ExtendedMessageFormat(pattern, locale, registry);
assertEquals("overridden date,short format", dateDefault.format(args), dateShort.format(args));
assertEquals("overridden date,short pattern", pattern, dateShort.toPattern());
}
@@ -253,8 +253,8 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testBuiltInNumberFormat() {
- Object[] args = new Object[] {Double.valueOf("6543.21")};
- Locale[] availableLocales = NumberFormat.getAvailableLocales();
+ final Object[] args = new Object[] {Double.valueOf("6543.21")};
+ final Locale[] availableLocales = NumberFormat.getAvailableLocales();
checkBuiltInFormat("1: {0,number}", args, availableLocales);
checkBuiltInFormat("2: {0,number,integer}", args, availableLocales);
checkBuiltInFormat("3: {0,number,currency}", args, availableLocales);
@@ -267,11 +267,11 @@ public class ExtendedMessageFormatTest {
*/
@Test
public void testEqualsHashcode() {
- Map<String, ? extends FormatFactory> registry = Collections.singletonMap("testfmt", new LowerCaseFormatFactory());
- Map<String, ? extends FormatFactory> otherRegitry = Collections.singletonMap("testfmt", new UpperCaseFormatFactory());
+ final Map<String, ? extends FormatFactory> registry = Collections.singletonMap("testfmt", new LowerCaseFormatFactory());
+ final Map<String, ? extends FormatFactory> otherRegitry = Collections.singletonMap("testfmt", new UpperCaseFormatFactory());
- String pattern = "Pattern: {0,testfmt}";
- ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, Locale.US, registry);
+ final String pattern = "Pattern: {0,testfmt}";
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, Locale.US, registry);
ExtendedMessageFormat other = null;
@@ -324,7 +324,7 @@ public class ExtendedMessageFormatTest {
*/
private void checkBuiltInFormat(final String pattern, final Map<String, ?> registry, final Object[] args, final Locale[] locales) {
checkBuiltInFormat(pattern, registry, args, (Locale) null);
- for (Locale locale : locales) {
+ for (final Locale locale : locales) {
checkBuiltInFormat(pattern, registry, args, locale);
}
}
@@ -338,13 +338,13 @@ public class ExtendedMessageFormatTest {
* @param locale Locale
*/
private void checkBuiltInFormat(final String pattern, final Map<String, ?> registry, final Object[] args, final Locale locale) {
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
buffer.append("Pattern=[");
buffer.append(pattern);
buffer.append("], locale=[");
buffer.append(locale);
buffer.append("]");
- MessageFormat mf = createMessageFormat(pattern, locale);
+ final MessageFormat mf = createMessageFormat(pattern, locale);
// System.out.println(buffer + ", result=[" + mf.format(args) +"]");
ExtendedMessageFormat emf = null;
if (locale == null) {
@@ -370,7 +370,7 @@ public class ExtendedMessageFormatTest {
* @return MessageFormat
*/
private MessageFormat createMessageFormat(final String pattern, final Locale locale) {
- MessageFormat result = new MessageFormat(pattern);
+ final MessageFormat result = new MessageFormat(pattern);
if (locale != null) {
result.setLocale(locale);
result.applyPattern(pattern);
diff --git a/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java b/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java
index 94919cc2e..bb847427a 100644
--- a/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java
@@ -46,7 +46,7 @@ public class FormattableUtilsTest {
@Test
public void testAlternatePadCharacter() {
- char pad='_';
+ final char pad='_';
assertEquals("foo", FormattableUtils.append("foo", new Formatter(), 0, -1, -1, pad).toString());
assertEquals("fo", FormattableUtils.append("foo", new Formatter(), 0, -1, 2, pad).toString());
assertEquals("_foo", FormattableUtils.append("foo", new Formatter(), 0, 4, -1, pad).toString());
diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java
index d1162a623..37f452bf5 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java
@@ -59,7 +59,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendWithNullText() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.setNullText("NULL");
assertEquals("", sb.toString());
@@ -91,7 +91,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppend_Object() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendNull();
assertEquals("", sb.toString());
@@ -167,42 +167,42 @@ public class StrBuilderAppendInsertTest {
try {
sb.append("bar", -1, 1);
fail("append(char[], -1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append("bar", 3, 1);
fail("append(char[], 3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append("bar", 1, -1);
fail("append(char[],, -1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append("bar", 1, 3);
fail("append(char[], 1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append("bar", -1, 3);
fail("append(char[], -1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append("bar", 4, 0);
fail("append(char[], 4, 0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -230,42 +230,42 @@ public class StrBuilderAppendInsertTest {
try {
sb.append(new StringBuilder("bar"), -1, 1);
fail("append(StringBuilder, -1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuilder("bar"), 3, 1);
fail("append(StringBuilder, 3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuilder("bar"), 1, -1);
fail("append(StringBuilder,, -1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuilder("bar"), 1, 3);
fail("append(StringBuilder, 1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuilder("bar"), -1, 3);
fail("append(StringBuilder, -1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuilder("bar"), 4, 0);
fail("append(StringBuilder, 4, 0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -311,42 +311,42 @@ public class StrBuilderAppendInsertTest {
try {
sb.append(new StringBuffer("bar"), -1, 1);
fail("append(char[], -1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuffer("bar"), 3, 1);
fail("append(char[], 3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuffer("bar"), 1, -1);
fail("append(char[],, -1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuffer("bar"), 1, 3);
fail("append(char[], 1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuffer("bar"), -1, 3);
fail("append(char[], -1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StringBuffer("bar"), 4, 0);
fail("append(char[], 4, 0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -389,42 +389,42 @@ public class StrBuilderAppendInsertTest {
try {
sb.append(new StrBuilder("bar"), -1, 1);
fail("append(char[], -1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StrBuilder("bar"), 3, 1);
fail("append(char[], 3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StrBuilder("bar"), 1, -1);
fail("append(char[],, -1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StrBuilder("bar"), 1, 3);
fail("append(char[], 1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StrBuilder("bar"), -1, 3);
fail("append(char[], -1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new StrBuilder("bar"), 4, 0);
fail("append(char[], 4, 0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -464,42 +464,42 @@ public class StrBuilderAppendInsertTest {
try {
sb.append(new char[]{'b', 'a', 'r'}, -1, 1);
fail("append(char[], -1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new char[]{'b', 'a', 'r'}, 3, 1);
fail("append(char[], 3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new char[]{'b', 'a', 'r'}, 1, -1);
fail("append(char[],, -1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new char[]{'b', 'a', 'r'}, 1, 3);
fail("append(char[], 1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new char[]{'b', 'a', 'r'}, -1, 3);
fail("append(char[], -1, 3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.append(new char[]{'b', 'a', 'r'}, 4, 0);
fail("append(char[], 4, 0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -513,7 +513,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppend_Boolean() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append(true);
assertEquals("true", sb.toString());
@@ -527,7 +527,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppend_PrimitiveNumber() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append(0);
assertEquals("0", sb.toString());
@@ -545,7 +545,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_FormattedString() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final String str) {
count[0]++;
@@ -566,7 +566,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendln_Object() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendln((Object) null);
assertEquals("" + SEP, sb.toString());
@@ -581,7 +581,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_String() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final String str) {
count[0]++;
@@ -603,7 +603,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_String_int_int() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final String str, final int startIndex, final int length) {
count[0]++;
@@ -625,7 +625,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StringBuffer() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StringBuffer str) {
count[0]++;
@@ -647,7 +647,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StringBuilder() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StringBuilder str) {
count[0]++;
@@ -669,7 +669,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StringBuffer_int_int() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StringBuffer str, final int startIndex, final int length) {
count[0]++;
@@ -691,7 +691,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StringBuilder_int_int() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StringBuilder str, final int startIndex, final int length) {
count[0]++;
@@ -713,7 +713,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StrBuilder() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StrBuilder str) {
count[0]++;
@@ -735,7 +735,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_StrBuilder_int_int() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final StrBuilder str, final int startIndex, final int length) {
count[0]++;
@@ -757,7 +757,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_CharArray() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final char[] str) {
count[0]++;
@@ -779,7 +779,7 @@ public class StrBuilderAppendInsertTest {
@Test
public void testAppendln_CharArray_int_int() {
final int[] count = new int[2];
- StrBuilder sb = new StrBuilder() {
+ final StrBuilder sb = new StrBuilder() {
@Override
public StrBuilder append(final char[] str, final int startIndex, final int length) {
count[0]++;
@@ -800,7 +800,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendln_Boolean() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendln(true);
assertEquals("true" + SEP, sb.toString());
@@ -812,7 +812,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendln_PrimitiveNumber() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendln(0);
assertEquals("0" + SEP, sb.toString());
@@ -832,7 +832,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendPadding() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append("foo");
assertEquals("foo", sb.toString());
@@ -854,7 +854,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendFixedWidthPadLeft() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadLeft("foo", -1, '-');
assertEquals("", sb.toString());
@@ -893,7 +893,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendFixedWidthPadLeft_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadLeft(123, -1, '-');
assertEquals("", sb.toString());
@@ -927,7 +927,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendFixedWidthPadRight() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadRight("foo", -1, '-');
assertEquals("", sb.toString());
@@ -966,7 +966,7 @@ public class StrBuilderAppendInsertTest {
// See: http://issues.apache.org/jira/browse/LANG-299
@Test
public void testLang299() {
- StrBuilder sb = new StrBuilder(1);
+ final StrBuilder sb = new StrBuilder(1);
sb.appendFixedWidthPadRight("foo", 1, '-');
assertEquals("f", sb.toString());
}
@@ -974,7 +974,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendFixedWidthPadRight_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadRight(123, -1, '-');
assertEquals("", sb.toString());
@@ -1030,7 +1030,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendAll_Array() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendAll((Object[]) null);
assertEquals("", sb.toString());
@@ -1050,7 +1050,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendAll_Collection() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendAll((Collection<?>) null);
assertEquals("", sb.toString());
@@ -1066,7 +1066,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendAll_Iterator() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendAll((Iterator<?>) null);
assertEquals("", sb.toString());
@@ -1082,7 +1082,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendWithSeparators_Array() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendWithSeparators((Object[]) null, ",");
assertEquals("", sb.toString());
@@ -1106,7 +1106,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendWithSeparators_Collection() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendWithSeparators((Collection<?>) null, ",");
assertEquals("", sb.toString());
@@ -1130,7 +1130,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendWithSeparators_Iterator() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendWithSeparators((Iterator<?>) null, ",");
assertEquals("", sb.toString());
@@ -1154,7 +1154,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendWithSeparatorsWithNullText() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.setNullText("null");
sb.appendWithSeparators(new Object[]{"foo", null, "baz"}, ",");
assertEquals("foo,null,baz", sb.toString());
@@ -1167,7 +1167,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendSeparator_String() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendSeparator(","); // no effect
assertEquals("", sb.toString());
sb.append("foo");
@@ -1179,7 +1179,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendSeparator_String_String() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
final String startSeparator = "order by ";
final String standardSeparator = ",";
final String foo = "foo";
@@ -1202,7 +1202,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendSeparator_char() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendSeparator(','); // no effect
assertEquals("", sb.toString());
sb.append("foo");
@@ -1212,7 +1212,7 @@ public class StrBuilderAppendInsertTest {
}
@Test
public void testAppendSeparator_char_char() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
final char startSeparator = ':';
final char standardSeparator = ',';
final String foo = "foo";
@@ -1227,7 +1227,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendSeparator_String_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendSeparator(",", 0); // no effect
assertEquals("", sb.toString());
sb.append("foo");
@@ -1242,7 +1242,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testAppendSeparator_char_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendSeparator(',', 0); // no effect
assertEquals("", sb.toString());
sb.append("foo");
@@ -1258,21 +1258,21 @@ public class StrBuilderAppendInsertTest {
@Test
public void testInsert() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append("barbaz");
assertEquals("barbaz", sb.toString());
try {
sb.insert(-1, FOO);
fail("insert(-1, Object) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, FOO);
fail("insert(7, Object) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1289,14 +1289,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, "foo");
fail("insert(-1, String) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, "foo");
fail("insert(7, String) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1313,14 +1313,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, new char[]{'f', 'o', 'o'});
fail("insert(-1, char[]) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, new char[]{'f', 'o', 'o'});
fail("insert(7, char[]) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1340,14 +1340,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, 3, 3);
fail("insert(-1, char[], 3, 3) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, 3, 3);
fail("insert(7, char[], 3, 3) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1360,28 +1360,28 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(0, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, -1, 3);
fail("insert(0, char[], -1, 3) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(0, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, 10, 3);
fail("insert(0, char[], 10, 3) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(0, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, 0, -1);
fail("insert(0, char[], 0, -1) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(0, new char[]{'a', 'b', 'c', 'f', 'o', 'o', 'd', 'e', 'f'}, 0, 10);
fail("insert(0, char[], 0, 10) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1398,14 +1398,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, true);
fail("insert(-1, boolean) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, true);
fail("insert(7, boolean) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1422,14 +1422,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, '!');
fail("insert(-1, char) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, '!');
fail("insert(7, char) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1443,14 +1443,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, 0);
fail("insert(-1, int) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, 0);
fail("insert(7, int) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1464,14 +1464,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, 1L);
fail("insert(-1, long) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, 1L);
fail("insert(7, long) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1485,14 +1485,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, 2.3F);
fail("insert(-1, float) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, 2.3F);
fail("insert(7, float) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1506,14 +1506,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, 4.5D);
fail("insert(-1, double) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, 4.5D);
fail("insert(7, double) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1524,7 +1524,7 @@ public class StrBuilderAppendInsertTest {
//-----------------------------------------------------------------------
@Test
public void testInsertWithNullText() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.setNullText("null");
sb.append("barbaz");
assertEquals("barbaz", sb.toString());
@@ -1532,14 +1532,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, FOO);
fail("insert(-1, Object) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, FOO);
fail("insert(7, Object) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -1556,14 +1556,14 @@ public class StrBuilderAppendInsertTest {
try {
sb.insert(-1, "foo");
fail("insert(-1, String) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.insert(7, "foo");
fail("insert(7, String) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
index 64fdfb0f8..c5fdfdc11 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
@@ -35,42 +35,42 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testConstructors() {
- StrBuilder sb0 = new StrBuilder();
+ final StrBuilder sb0 = new StrBuilder();
assertEquals(32, sb0.capacity());
assertEquals(0, sb0.length());
assertEquals(0, sb0.size());
- StrBuilder sb1 = new StrBuilder(32);
+ final StrBuilder sb1 = new StrBuilder(32);
assertEquals(32, sb1.capacity());
assertEquals(0, sb1.length());
assertEquals(0, sb1.size());
- StrBuilder sb2 = new StrBuilder(0);
+ final StrBuilder sb2 = new StrBuilder(0);
assertEquals(32, sb2.capacity());
assertEquals(0, sb2.length());
assertEquals(0, sb2.size());
- StrBuilder sb3 = new StrBuilder(-1);
+ final StrBuilder sb3 = new StrBuilder(-1);
assertEquals(32, sb3.capacity());
assertEquals(0, sb3.length());
assertEquals(0, sb3.size());
- StrBuilder sb4 = new StrBuilder(1);
+ final StrBuilder sb4 = new StrBuilder(1);
assertEquals(1, sb4.capacity());
assertEquals(0, sb4.length());
assertEquals(0, sb4.size());
- StrBuilder sb5 = new StrBuilder((String) null);
+ final StrBuilder sb5 = new StrBuilder((String) null);
assertEquals(32, sb5.capacity());
assertEquals(0, sb5.length());
assertEquals(0, sb5.size());
- StrBuilder sb6 = new StrBuilder("");
+ final StrBuilder sb6 = new StrBuilder("");
assertEquals(32, sb6.capacity());
assertEquals(0, sb6.length());
assertEquals(0, sb6.size());
- StrBuilder sb7 = new StrBuilder("foo");
+ final StrBuilder sb7 = new StrBuilder("foo");
assertEquals(35, sb7.capacity());
assertEquals(3, sb7.length());
assertEquals(3, sb7.size());
@@ -79,7 +79,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testChaining() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertSame(sb, sb.setNewLineText(null));
assertSame(sb, sb.setNullText(null));
assertSame(sb, sb.setLength(1));
@@ -94,7 +94,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testGetSetNewLineText() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(null, sb.getNewLineText());
sb.setNewLineText("#");
@@ -110,7 +110,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testGetSetNullText() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(null, sb.getNullText());
sb.setNullText("null");
@@ -129,7 +129,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testCapacityAndLength() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(32, sb.capacity());
assertEquals(0, sb.length());
assertEquals(0, sb.size());
@@ -180,7 +180,7 @@ public class StrBuilderTest {
try {
sb.setLength(-1);
fail("setLength(-1) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
@@ -214,7 +214,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testLength() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(0, sb.length());
sb.append("Hello");
@@ -223,7 +223,7 @@ public class StrBuilderTest {
@Test
public void testSetLength() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append("Hello");
sb.setLength(2); // shorten
assertEquals("He", sb.toString());
@@ -235,7 +235,7 @@ public class StrBuilderTest {
try {
sb.setLength(-1);
fail("setLength(-1) expected StringIndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
}
@@ -243,7 +243,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testCapacity() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(sb.buffer.length, sb.capacity());
sb.append("HelloWorldHelloWorldHelloWorldHelloWorld");
@@ -252,7 +252,7 @@ public class StrBuilderTest {
@Test
public void testEnsureCapacity() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.ensureCapacity(2);
assertTrue(sb.capacity() >= 2);
@@ -266,7 +266,7 @@ public class StrBuilderTest {
@Test
public void testMinimizeCapacity() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.minimizeCapacity();
assertEquals(0, sb.capacity());
@@ -278,7 +278,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testSize() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(0, sb.size());
sb.append("Hello");
@@ -287,7 +287,7 @@ public class StrBuilderTest {
@Test
public void testIsEmpty() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertTrue(sb.isEmpty());
sb.append("Hello");
@@ -299,7 +299,7 @@ public class StrBuilderTest {
@Test
public void testClear() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append("Hello");
sb.clear();
assertEquals(0, sb.length());
@@ -309,17 +309,17 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testCharAt() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
try {
sb.charAt(0);
fail("charAt(0) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.charAt(-1);
fail("charAt(-1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
sb.append("foo");
@@ -329,13 +329,13 @@ public class StrBuilderTest {
try {
sb.charAt(-1);
fail("charAt(-1) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.charAt(3);
fail("charAt(3) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
}
@@ -343,17 +343,17 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testSetCharAt() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
try {
sb.setCharAt(0, 'f');
fail("setCharAt(0,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
try {
sb.setCharAt(-1, 'f');
fail("setCharAt(-1,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
sb.append("foo");
@@ -363,7 +363,7 @@ public class StrBuilderTest {
try {
sb.setCharAt(3, '!');
fail("setCharAt(3,) expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
// expected
}
assertEquals("bar", sb.toString());
@@ -372,20 +372,20 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testDeleteCharAt() {
- StrBuilder sb = new StrBuilder("abc");
+ final StrBuilder sb = new StrBuilder("abc");
sb.deleteCharAt(0);
assertEquals("bc", sb.toString());
try {
sb.deleteCharAt(1000);
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
//-----------------------------------------------------------------------
@Test
public void testToCharArray() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(ArrayUtils.EMPTY_CHAR_ARRAY, sb.toCharArray());
char[] a = sb.toCharArray();
@@ -400,7 +400,7 @@ public class StrBuilderTest {
@Test
public void testToCharArrayIntInt() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(ArrayUtils.EMPTY_CHAR_ARRAY, sb.toCharArray(0, 0));
sb.append("junit");
@@ -422,19 +422,19 @@ public class StrBuilderTest {
try {
sb.toCharArray(-1, 5);
fail("no string index out of bound on -1");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
}
try {
sb.toCharArray(6, 5);
fail("no string index out of bound on -1");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
}
}
@Test
public void testGetChars ( ) {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
char[] input = new char[10];
char[] a = sb.getChars(input);
@@ -462,7 +462,7 @@ public class StrBuilderTest {
@Test
public void testGetCharsIntIntCharArrayInt( ) {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.append("junit");
char[] a = new char[5];
@@ -477,28 +477,28 @@ public class StrBuilderTest {
sb.getChars(-1,0,a,0);
fail("no exception");
}
- catch (IndexOutOfBoundsException e) {
+ catch (final IndexOutOfBoundsException e) {
}
try {
sb.getChars(0,-1,a,0);
fail("no exception");
}
- catch (IndexOutOfBoundsException e) {
+ catch (final IndexOutOfBoundsException e) {
}
try {
sb.getChars(0,20,a,0);
fail("no exception");
}
- catch (IndexOutOfBoundsException e) {
+ catch (final IndexOutOfBoundsException e) {
}
try {
sb.getChars(4,2,a,0);
fail("no exception");
}
- catch (IndexOutOfBoundsException e) {
+ catch (final IndexOutOfBoundsException e) {
}
}
@@ -518,17 +518,17 @@ public class StrBuilderTest {
try {
sb.delete(1, 2);
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
sb.delete(-1, 1);
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
sb = new StrBuilder("anything");
try {
sb.delete(2, 1);
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
//-----------------------------------------------------------------------
@@ -677,23 +677,23 @@ public class StrBuilderTest {
try {
sb.replace(2, 1, "anything");
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
sb = new StrBuilder();
try {
sb.replace(1, 2, "anything");
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
sb.replace(-1, 1, "anything");
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
//-----------------------------------------------------------------------
@Test
public void testReplaceAll_char_char() {
- StrBuilder sb = new StrBuilder("abcbccba");
+ final StrBuilder sb = new StrBuilder("abcbccba");
sb.replaceAll('x', 'y');
assertEquals("abcbccba", sb.toString());
sb.replaceAll('a', 'd');
@@ -709,7 +709,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testReplaceFirst_char_char() {
- StrBuilder sb = new StrBuilder("abcbccba");
+ final StrBuilder sb = new StrBuilder("abcbccba");
sb.replaceFirst('x', 'y');
assertEquals("abcbccba", sb.toString());
sb.replaceFirst('a', 'd');
@@ -947,14 +947,14 @@ public class StrBuilderTest {
try {
sb.replace(StrMatcher.stringMatcher("aa"), "-", 11, sb.length(), -1);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
assertEquals("aaxaaaayaa", sb.toString());
sb = new StrBuilder("aaxaaaayaa");
try {
sb.replace(StrMatcher.stringMatcher("aa"), "-", -1, sb.length(), -1);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
assertEquals("aaxaaaayaa", sb.toString());
}
@@ -1008,7 +1008,7 @@ public class StrBuilderTest {
try {
sb.replace(StrMatcher.stringMatcher("aa"), "-", 2, 1, -1);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
assertEquals("aaxaaaayaa", sb.toString());
}
@@ -1046,7 +1046,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testReverse() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals("", sb.reverse().toString());
sb.clear().append(true);
@@ -1057,7 +1057,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testTrim() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals("", sb.reverse().toString());
sb.clear().append(" \u0000 ");
@@ -1079,7 +1079,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testStartsWith() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertFalse(sb.startsWith("a"));
assertFalse(sb.startsWith(null));
assertTrue(sb.startsWith(""));
@@ -1092,7 +1092,7 @@ public class StrBuilderTest {
@Test
public void testEndsWith() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertFalse(sb.endsWith("a"));
assertFalse(sb.endsWith("c"));
assertTrue(sb.endsWith(""));
@@ -1110,30 +1110,30 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testSubSequenceIntInt() {
- StrBuilder sb = new StrBuilder ("hello goodbye");
+ final StrBuilder sb = new StrBuilder ("hello goodbye");
// Start index is negative
try {
sb.subSequence(-1, 5);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
// End index is negative
try {
sb.subSequence(2, -1);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
// End index greater than length()
try {
sb.subSequence(2, sb.length() + 1);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
// Start index greater then end index
try {
sb.subSequence(3, 2);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
// Normal cases
assertEquals ("hello", sb.subSequence(0, 5));
@@ -1144,7 +1144,7 @@ public class StrBuilderTest {
@Test
public void testSubstringInt() {
- StrBuilder sb = new StrBuilder ("hello goodbye");
+ final StrBuilder sb = new StrBuilder ("hello goodbye");
assertEquals ("goodbye", sb.substring(6));
assertEquals ("hello goodbye".substring(6), sb.substring(6));
assertEquals ("hello goodbye", sb.substring(0));
@@ -1152,18 +1152,18 @@ public class StrBuilderTest {
try {
sb.substring(-1);
fail ();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
sb.substring(15);
fail ();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
public void testSubstringIntInt() {
- StrBuilder sb = new StrBuilder ("hello goodbye");
+ final StrBuilder sb = new StrBuilder ("hello goodbye");
assertEquals ("hello", sb.substring(0, 5));
assertEquals ("hello goodbye".substring(0, 6), sb.substring(0, 6));
@@ -1175,18 +1175,18 @@ public class StrBuilderTest {
try {
sb.substring(-1, 5);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
sb.substring(15, 20);
fail();
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
// -----------------------------------------------------------------------
@Test
public void testMidString() {
- StrBuilder sb = new StrBuilder("hello goodbye hello");
+ final StrBuilder sb = new StrBuilder("hello goodbye hello");
assertEquals("goodbye", sb.midString(6, 7));
assertEquals("hello", sb.midString(0, 5));
assertEquals("hello", sb.midString(-5, 5));
@@ -1197,7 +1197,7 @@ public class StrBuilderTest {
@Test
public void testRightString() {
- StrBuilder sb = new StrBuilder("left right");
+ final StrBuilder sb = new StrBuilder("left right");
assertEquals("right", sb.rightString(5));
assertEquals("", sb.rightString(0));
assertEquals("", sb.rightString(-5));
@@ -1206,7 +1206,7 @@ public class StrBuilderTest {
@Test
public void testLeftString() {
- StrBuilder sb = new StrBuilder("left right");
+ final StrBuilder sb = new StrBuilder("left right");
assertEquals("left", sb.leftString(4));
assertEquals("", sb.leftString(0));
assertEquals("", sb.leftString(-5));
@@ -1216,7 +1216,7 @@ public class StrBuilderTest {
// -----------------------------------------------------------------------
@Test
public void testContains_char() {
- StrBuilder sb = new StrBuilder("abcdefghijklmnopqrstuvwxyz");
+ final StrBuilder sb = new StrBuilder("abcdefghijklmnopqrstuvwxyz");
assertTrue(sb.contains('a'));
assertTrue(sb.contains('o'));
assertTrue(sb.contains('z'));
@@ -1225,7 +1225,7 @@ public class StrBuilderTest {
@Test
public void testContains_String() {
- StrBuilder sb = new StrBuilder("abcdefghijklmnopqrstuvwxyz");
+ final StrBuilder sb = new StrBuilder("abcdefghijklmnopqrstuvwxyz");
assertTrue(sb.contains("a"));
assertTrue(sb.contains("pq"));
assertTrue(sb.contains("z"));
@@ -1251,7 +1251,7 @@ public class StrBuilderTest {
// -----------------------------------------------------------------------
@Test
public void testIndexOf_char() {
- StrBuilder sb = new StrBuilder("abab");
+ final StrBuilder sb = new StrBuilder("abab");
assertEquals(0, sb.indexOf('a'));
// should work like String#indexOf
@@ -1287,7 +1287,7 @@ public class StrBuilderTest {
@Test
public void testLastIndexOf_char() {
- StrBuilder sb = new StrBuilder("abab");
+ final StrBuilder sb = new StrBuilder("abab");
assertEquals (2, sb.lastIndexOf('a'));
//should work like String#lastIndexOf
@@ -1322,7 +1322,7 @@ public class StrBuilderTest {
// -----------------------------------------------------------------------
@Test
public void testIndexOf_String() {
- StrBuilder sb = new StrBuilder("abab");
+ final StrBuilder sb = new StrBuilder("abab");
assertEquals(0, sb.indexOf("a"));
//should work like String#indexOf
@@ -1382,7 +1382,7 @@ public class StrBuilderTest {
@Test
public void testLastIndexOf_String() {
- StrBuilder sb = new StrBuilder("abab");
+ final StrBuilder sb = new StrBuilder("abab");
assertEquals(2, sb.lastIndexOf("a"));
//should work like String#lastIndexOf
@@ -1443,7 +1443,7 @@ public class StrBuilderTest {
// -----------------------------------------------------------------------
@Test
public void testIndexOf_StrMatcher() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(-1, sb.indexOf((StrMatcher) null));
assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a')));
@@ -1461,7 +1461,7 @@ public class StrBuilderTest {
@Test
public void testIndexOf_StrMatcher_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(-1, sb.indexOf((StrMatcher) null, 2));
assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 2));
assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 0));
@@ -1501,7 +1501,7 @@ public class StrBuilderTest {
@Test
public void testLastIndexOf_StrMatcher() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(-1, sb.lastIndexOf((StrMatcher) null));
assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a')));
@@ -1519,7 +1519,7 @@ public class StrBuilderTest {
@Test
public void testLastIndexOf_StrMatcher_int() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(-1, sb.lastIndexOf((StrMatcher) null, 2));
assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), 2));
assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), 0));
@@ -1575,18 +1575,18 @@ public class StrBuilderTest {
@Test
public void testAsTokenizer() throws Exception {
// from Javadoc
- StrBuilder b = new StrBuilder();
+ final StrBuilder b = new StrBuilder();
b.append("a b ");
- StrTokenizer t = b.asTokenizer();
+ final StrTokenizer t = b.asTokenizer();
- String[] tokens1 = t.getTokenArray();
+ final String[] tokens1 = t.getTokenArray();
assertEquals(2, tokens1.length);
assertEquals("a", tokens1[0]);
assertEquals("b", tokens1[1]);
assertEquals(2, t.size());
b.append("c d ");
- String[] tokens2 = t.getTokenArray();
+ final String[] tokens2 = t.getTokenArray();
assertEquals(2, tokens2.length);
assertEquals("a", tokens2[0]);
assertEquals("b", tokens2[1]);
@@ -1595,7 +1595,7 @@ public class StrBuilderTest {
assertEquals("b", t.next());
t.reset();
- String[] tokens3 = t.getTokenArray();
+ final String[] tokens3 = t.getTokenArray();
assertEquals(4, tokens3.length);
assertEquals("a", tokens3[0]);
assertEquals("b", tokens3[1]);
@@ -1613,10 +1613,10 @@ public class StrBuilderTest {
// -----------------------------------------------------------------------
@Test
public void testAsReader() throws Exception {
- StrBuilder sb = new StrBuilder("some text");
+ final StrBuilder sb = new StrBuilder("some text");
Reader reader = sb.asReader();
assertTrue(reader.ready());
- char[] buf = new char[40];
+ final char[] buf = new char[40];
assertEquals(9, reader.read(buf));
assertEquals("some text", new String(buf, 0, 9));
@@ -1651,23 +1651,23 @@ public class StrBuilderTest {
try {
reader.read(array, -1, 0);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
try {
reader.read(array, 0, -1);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
try {
reader.read(array, 100, 1);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
try {
reader.read(array, 0, 100);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
try {
reader.read(array, Integer.MAX_VALUE, Integer.MAX_VALUE);
fail();
- } catch (IndexOutOfBoundsException ex) {}
+ } catch (final IndexOutOfBoundsException ex) {}
assertEquals(0, reader.read(array, 0, 0));
assertEquals(0, array[0]);
@@ -1685,8 +1685,8 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testAsWriter() throws Exception {
- StrBuilder sb = new StrBuilder("base");
- Writer writer = sb.asWriter();
+ final StrBuilder sb = new StrBuilder("base");
+ final Writer writer = sb.asWriter();
writer.write('l');
assertEquals("basel", sb.toString());
@@ -1720,8 +1720,8 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testEqualsIgnoreCase() {
- StrBuilder sb1 = new StrBuilder();
- StrBuilder sb2 = new StrBuilder();
+ final StrBuilder sb1 = new StrBuilder();
+ final StrBuilder sb2 = new StrBuilder();
assertTrue(sb1.equalsIgnoreCase(sb1));
assertTrue(sb1.equalsIgnoreCase(sb2));
assertTrue(sb2.equalsIgnoreCase(sb2));
@@ -1744,8 +1744,8 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testEquals() {
- StrBuilder sb1 = new StrBuilder();
- StrBuilder sb2 = new StrBuilder();
+ final StrBuilder sb1 = new StrBuilder();
+ final StrBuilder sb2 = new StrBuilder();
assertTrue(sb1.equals(sb2));
assertTrue(sb1.equals(sb1));
assertTrue(sb2.equals(sb2));
@@ -1770,15 +1770,15 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testHashCode() {
- StrBuilder sb = new StrBuilder();
- int hc1a = sb.hashCode();
- int hc1b = sb.hashCode();
+ final StrBuilder sb = new StrBuilder();
+ final int hc1a = sb.hashCode();
+ final int hc1b = sb.hashCode();
assertEquals(0, hc1a);
assertEquals(hc1a, hc1b);
sb.append("abc");
- int hc2a = sb.hashCode();
- int hc2b = sb.hashCode();
+ final int hc2a = sb.hashCode();
+ final int hc2b = sb.hashCode();
assertTrue(hc2a != 0);
assertEquals(hc2a, hc2b);
}
@@ -1786,14 +1786,14 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testToString() {
- StrBuilder sb = new StrBuilder("abc");
+ final StrBuilder sb = new StrBuilder("abc");
assertEquals("abc", sb.toString());
}
//-----------------------------------------------------------------------
@Test
public void testToStringBuffer() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(new StringBuffer().toString(), sb.toStringBuffer().toString());
sb.append("junit");
@@ -1803,7 +1803,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testToStringBuilder() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
assertEquals(new StringBuilder().toString(), sb.toStringBuilder().toString());
sb.append("junit");
@@ -1813,14 +1813,14 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testLang294() {
- StrBuilder sb = new StrBuilder("\n%BLAH%\nDo more stuff\neven more stuff\n%BLAH%\n");
+ final StrBuilder sb = new StrBuilder("\n%BLAH%\nDo more stuff\neven more stuff\n%BLAH%\n");
sb.deleteAll("\n%BLAH%");
assertEquals("\nDo more stuff\neven more stuff\n", sb.toString());
}
@Test
public void testIndexOfLang294() {
- StrBuilder sb = new StrBuilder("onetwothree");
+ final StrBuilder sb = new StrBuilder("onetwothree");
sb.deleteFirst("three");
assertEquals(-1, sb.indexOf("three"));
}
@@ -1828,7 +1828,7 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testLang295() {
- StrBuilder sb = new StrBuilder("onetwothree");
+ final StrBuilder sb = new StrBuilder("onetwothree");
sb.deleteFirst("three");
assertFalse( "The contains(char) method is looking beyond the end of the string", sb.contains('h'));
assertEquals( "The indexOf(char) method is looking beyond the end of the string", -1, sb.indexOf('h'));
@@ -1837,21 +1837,21 @@ public class StrBuilderTest {
//-----------------------------------------------------------------------
@Test
public void testLang412Right() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadRight(null, 10, '*');
assertEquals( "Failed to invoke appendFixedWidthPadRight correctly", "**********", sb.toString());
}
@Test
public void testLang412Left() {
- StrBuilder sb = new StrBuilder();
+ final StrBuilder sb = new StrBuilder();
sb.appendFixedWidthPadLeft(null, 10, '*');
assertEquals( "Failed to invoke appendFixedWidthPadLeft correctly", "**********", sb.toString());
}
@Test
public void testAsBuilder() {
- StrBuilder sb = new StrBuilder().appendAll("Lorem", " ", "ipsum", " ", "dolor");
+ final StrBuilder sb = new StrBuilder().appendAll("Lorem", " ", "ipsum", " ", "dolor");
assertEquals(sb.toString(), sb.build());
}
diff --git a/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java b/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java
index 592e6a9b9..e45a324c8 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java
@@ -48,14 +48,14 @@ public class StrLookupTest {
try {
StrLookup.systemPropertiesLookup().lookup(null);
fail();
- } catch (NullPointerException ex) {
+ } catch (final NullPointerException ex) {
// expected
}
}
@Test
public void testMapLookup() {
- Map<String, Object> map = new HashMap<String, Object>();
+ final Map<String, Object> map = new HashMap<String, Object>();
map.put("key", "value");
map.put("number", Integer.valueOf(2));
assertEquals("value", StrLookup.mapLookup(map).lookup("key"));
@@ -67,7 +67,7 @@ public class StrLookupTest {
@Test
public void testMapLookup_nullMap() {
- Map<String, ?> map = null;
+ final Map<String, ?> map = null;
assertEquals(null, StrLookup.mapLookup(map).lookup(null));
assertEquals(null, StrLookup.mapLookup(map).lookup(""));
assertEquals(null, StrLookup.mapLookup(map).lookup("any"));
diff --git a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java
index 0d576dcab..89bc3a741 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java
@@ -38,7 +38,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testCommaMatcher() {
- StrMatcher matcher = StrMatcher.commaMatcher();
+ final StrMatcher matcher = StrMatcher.commaMatcher();
assertSame(matcher, StrMatcher.commaMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 0));
assertEquals(1, matcher.isMatch(BUFFER1, 1));
@@ -48,7 +48,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testTabMatcher() {
- StrMatcher matcher = StrMatcher.tabMatcher();
+ final StrMatcher matcher = StrMatcher.tabMatcher();
assertSame(matcher, StrMatcher.tabMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 2));
assertEquals(1, matcher.isMatch(BUFFER1, 3));
@@ -58,7 +58,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testSpaceMatcher() {
- StrMatcher matcher = StrMatcher.spaceMatcher();
+ final StrMatcher matcher = StrMatcher.spaceMatcher();
assertSame(matcher, StrMatcher.spaceMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 4));
assertEquals(1, matcher.isMatch(BUFFER1, 5));
@@ -68,7 +68,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testSplitMatcher() {
- StrMatcher matcher = StrMatcher.splitMatcher();
+ final StrMatcher matcher = StrMatcher.splitMatcher();
assertSame(matcher, StrMatcher.splitMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 2));
assertEquals(1, matcher.isMatch(BUFFER1, 3));
@@ -84,7 +84,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testTrimMatcher() {
- StrMatcher matcher = StrMatcher.trimMatcher();
+ final StrMatcher matcher = StrMatcher.trimMatcher();
assertSame(matcher, StrMatcher.trimMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 2));
assertEquals(1, matcher.isMatch(BUFFER1, 3));
@@ -100,7 +100,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testSingleQuoteMatcher() {
- StrMatcher matcher = StrMatcher.singleQuoteMatcher();
+ final StrMatcher matcher = StrMatcher.singleQuoteMatcher();
assertSame(matcher, StrMatcher.singleQuoteMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 10));
assertEquals(1, matcher.isMatch(BUFFER1, 11));
@@ -110,7 +110,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testDoubleQuoteMatcher() {
- StrMatcher matcher = StrMatcher.doubleQuoteMatcher();
+ final StrMatcher matcher = StrMatcher.doubleQuoteMatcher();
assertSame(matcher, StrMatcher.doubleQuoteMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 11));
assertEquals(1, matcher.isMatch(BUFFER1, 12));
@@ -119,7 +119,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testQuoteMatcher() {
- StrMatcher matcher = StrMatcher.quoteMatcher();
+ final StrMatcher matcher = StrMatcher.quoteMatcher();
assertSame(matcher, StrMatcher.quoteMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 10));
assertEquals(1, matcher.isMatch(BUFFER1, 11));
@@ -129,7 +129,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testNoneMatcher() {
- StrMatcher matcher = StrMatcher.noneMatcher();
+ final StrMatcher matcher = StrMatcher.noneMatcher();
assertSame(matcher, StrMatcher.noneMatcher());
assertEquals(0, matcher.isMatch(BUFFER1, 0));
assertEquals(0, matcher.isMatch(BUFFER1, 1));
@@ -149,7 +149,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testCharMatcher_char() {
- StrMatcher matcher = StrMatcher.charMatcher('c');
+ final StrMatcher matcher = StrMatcher.charMatcher('c');
assertEquals(0, matcher.isMatch(BUFFER2, 0));
assertEquals(0, matcher.isMatch(BUFFER2, 1));
assertEquals(1, matcher.isMatch(BUFFER2, 2));
@@ -161,7 +161,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testCharSetMatcher_String() {
- StrMatcher matcher = StrMatcher.charSetMatcher("ace");
+ final StrMatcher matcher = StrMatcher.charSetMatcher("ace");
assertEquals(1, matcher.isMatch(BUFFER2, 0));
assertEquals(0, matcher.isMatch(BUFFER2, 1));
assertEquals(1, matcher.isMatch(BUFFER2, 2));
@@ -176,7 +176,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testCharSetMatcher_charArray() {
- StrMatcher matcher = StrMatcher.charSetMatcher("ace".toCharArray());
+ final StrMatcher matcher = StrMatcher.charSetMatcher("ace".toCharArray());
assertEquals(1, matcher.isMatch(BUFFER2, 0));
assertEquals(0, matcher.isMatch(BUFFER2, 1));
assertEquals(1, matcher.isMatch(BUFFER2, 2));
@@ -191,7 +191,7 @@ public class StrMatcherTest {
//-----------------------------------------------------------------------
@Test
public void testStringMatcher_String() {
- StrMatcher matcher = StrMatcher.stringMatcher("bc");
+ final StrMatcher matcher = StrMatcher.stringMatcher("bc");
assertEquals(0, matcher.isMatch(BUFFER2, 0));
assertEquals(2, matcher.isMatch(BUFFER2, 1));
assertEquals(0, matcher.isMatch(BUFFER2, 2));
@@ -208,7 +208,7 @@ public class StrMatcherTest {
// remember that the API contract is tight for the isMatch() method
// all the onus is on the caller, so invalid inputs are not
// the concern of StrMatcher, and are not bugs
- StrMatcher matcher = StrMatcher.stringMatcher("bc");
+ final StrMatcher matcher = StrMatcher.stringMatcher("bc");
assertEquals(2, matcher.isMatch(BUFFER2, 1, 1, BUFFER2.length));
assertEquals(2, matcher.isMatch(BUFFER2, 1, 0, 3));
assertEquals(0, matcher.isMatch(BUFFER2, 1, 0, 2));
diff --git a/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java b/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java
index ee2612160..013cc83c6 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java
@@ -94,7 +94,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testReplaceChangedMap() {
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
values.put("target", "moon");
assertEquals("The quick brown fox jumps over the moon.", sub.replace("The ${animal} jumps over the ${target}."));
}
@@ -114,7 +114,7 @@ public class StrSubstitutorTest {
public void testReplaceAdjacentAtStart() {
values.put("code", "GBP");
values.put("amount", "12.50");
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
assertEquals("GBP12.50 charged", sub.replace("${code}${amount} charged"));
}
@@ -125,7 +125,7 @@ public class StrSubstitutorTest {
public void testReplaceAdjacentAtEnd() {
values.put("code", "GBP");
values.put("amount", "12.50");
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
assertEquals("Amount is GBP12.50", sub.replace("Amount is ${code}${amount}"));
}
@@ -225,7 +225,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testCyclicReplacement() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("animal", "${critter}");
map.put("target", "${pet}");
map.put("pet", "${petCharacteristic} dog");
@@ -234,11 +234,11 @@ public class StrSubstitutorTest {
map.put("critterSpeed", "quick");
map.put("critterColor", "brown");
map.put("critterType", "${animal}");
- StrSubstitutor sub = new StrSubstitutor(map);
+ final StrSubstitutor sub = new StrSubstitutor(map);
try {
sub.replace("The ${animal} jumps over the ${target}.");
fail("Cyclic replacement was not detected!");
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
// expected
}
}
@@ -272,7 +272,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testReplacePartialString_noReplace() {
- StrSubstitutor sub = new StrSubstitutor();
+ final StrSubstitutor sub = new StrSubstitutor();
assertEquals("${animal} jumps", sub.replace("The ${animal} jumps over the ${target}.", 4, 15));
}
@@ -284,7 +284,7 @@ public class StrSubstitutorTest {
values.put("animal.1", "fox");
values.put("animal.2", "mouse");
values.put("species", "2");
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
sub.setEnableSubstitutionInVariables(true);
assertEquals(
"Wrong result (1)",
@@ -305,7 +305,7 @@ public class StrSubstitutorTest {
values.put("animal.1", "fox");
values.put("animal.2", "mouse");
values.put("species", "2");
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
assertEquals(
"Wrong result",
"The ${animal.${species}} jumps over the lazy dog.",
@@ -322,7 +322,7 @@ public class StrSubstitutorTest {
values.put("color", "white");
values.put("species.white", "1");
values.put("species.brown", "2");
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
sub.setEnableSubstitutionInVariables(true);
assertEquals(
"Wrong result",
@@ -337,9 +337,9 @@ public class StrSubstitutorTest {
@Test
public void testResolveVariable() {
final StrBuilder builder = new StrBuilder("Hi ${name}!");
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("name", "commons");
- StrSubstitutor sub = new StrSubstitutor(map) {
+ final StrSubstitutor sub = new StrSubstitutor(map) {
@Override
protected String resolveVariable(final String variableName, final StrBuilder buf, final int startPos, final int endPos) {
assertEquals("name", variableName);
@@ -359,7 +359,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testConstructorNoArgs() {
- StrSubstitutor sub = new StrSubstitutor();
+ final StrSubstitutor sub = new StrSubstitutor();
assertEquals("Hi ${name}", sub.replace("Hi ${name}"));
}
@@ -368,9 +368,9 @@ public class StrSubstitutorTest {
*/
@Test
public void testConstructorMapPrefixSuffix() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("name", "commons");
- StrSubstitutor sub = new StrSubstitutor(map, "<", ">");
+ final StrSubstitutor sub = new StrSubstitutor(map, "<", ">");
assertEquals("Hi < commons", sub.replace("Hi $< <name>"));
}
@@ -379,9 +379,9 @@ public class StrSubstitutorTest {
*/
@Test
public void testConstructorMapFull() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("name", "commons");
- StrSubstitutor sub = new StrSubstitutor(map, "<", ">", '!');
+ final StrSubstitutor sub = new StrSubstitutor(map, "<", ">", '!');
assertEquals("Hi < commons", sub.replace("Hi !< <name>"));
}
@@ -391,7 +391,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testGetSetEscape() {
- StrSubstitutor sub = new StrSubstitutor();
+ final StrSubstitutor sub = new StrSubstitutor();
assertEquals('$', sub.getEscapeChar());
sub.setEscapeChar('<');
assertEquals('<', sub.getEscapeChar());
@@ -402,7 +402,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testGetSetPrefix() {
- StrSubstitutor sub = new StrSubstitutor();
+ final StrSubstitutor sub = new StrSubstitutor();
assertTrue(sub.getVariablePrefixMatcher() instanceof StrMatcher.StringMatcher);
sub.setVariablePrefix('<');
assertTrue(sub.getVariablePrefixMatcher() instanceof StrMatcher.CharMatcher);
@@ -412,18 +412,18 @@ public class StrSubstitutorTest {
try {
sub.setVariablePrefix((String) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
assertTrue(sub.getVariablePrefixMatcher() instanceof StrMatcher.StringMatcher);
- StrMatcher matcher = StrMatcher.commaMatcher();
+ final StrMatcher matcher = StrMatcher.commaMatcher();
sub.setVariablePrefixMatcher(matcher);
assertSame(matcher, sub.getVariablePrefixMatcher());
try {
sub.setVariablePrefixMatcher((StrMatcher) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
assertSame(matcher, sub.getVariablePrefixMatcher());
@@ -434,7 +434,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testGetSetSuffix() {
- StrSubstitutor sub = new StrSubstitutor();
+ final StrSubstitutor sub = new StrSubstitutor();
assertTrue(sub.getVariableSuffixMatcher() instanceof StrMatcher.StringMatcher);
sub.setVariableSuffix('<');
assertTrue(sub.getVariableSuffixMatcher() instanceof StrMatcher.CharMatcher);
@@ -444,18 +444,18 @@ public class StrSubstitutorTest {
try {
sub.setVariableSuffix((String) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
assertTrue(sub.getVariableSuffixMatcher() instanceof StrMatcher.StringMatcher);
- StrMatcher matcher = StrMatcher.commaMatcher();
+ final StrMatcher matcher = StrMatcher.commaMatcher();
sub.setVariableSuffixMatcher(matcher);
assertSame(matcher, sub.getVariableSuffixMatcher());
try {
sub.setVariableSuffixMatcher((StrMatcher) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
// expected
}
assertSame(matcher, sub.getVariableSuffixMatcher());
@@ -467,7 +467,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testStaticReplace() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("name", "commons");
assertEquals("Hi commons!", StrSubstitutor.replace("Hi ${name}!", map));
}
@@ -477,7 +477,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testStaticReplacePrefixSuffix() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("name", "commons");
assertEquals("Hi commons!", StrSubstitutor.replace("Hi <name>!", map, "<", ">"));
}
@@ -487,7 +487,7 @@ public class StrSubstitutorTest {
*/
@Test
public void testStaticReplaceSystemProperties() {
- StrBuilder buf = new StrBuilder();
+ final StrBuilder buf = new StrBuilder();
buf.append("Hi ").append(System.getProperty("user.name"));
buf.append(", you are working with ");
buf.append(System.getProperty("os.name"));
@@ -503,18 +503,18 @@ public class StrSubstitutorTest {
*/
@Test
public void testSubstituteDefaultProperties(){
- String org = "${doesnotwork}";
+ final String org = "${doesnotwork}";
System.setProperty("doesnotwork", "It works!");
// create a new Properties object with the System.getProperties as default
- Properties props = new Properties(System.getProperties());
+ final Properties props = new Properties(System.getProperties());
assertEquals("It works!", StrSubstitutor.replace(org, props));
}
@Test
public void testSamePrefixAndSuffix() {
- Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<String, String>();
map.put("greeting", "Hello");
map.put(" there ", "XXX");
map.put("name", "commons");
@@ -524,8 +524,8 @@ public class StrSubstitutorTest {
//-----------------------------------------------------------------------
private void doTestReplace(final String expectedResult, final String replaceTemplate, final boolean substring) {
- String expectedShortResult = expectedResult.substring(1, expectedResult.length() - 1);
- StrSubstitutor sub = new StrSubstitutor(values);
+ final String expectedShortResult = expectedResult.substring(1, expectedResult.length() - 1);
+ final StrSubstitutor sub = new StrSubstitutor(values);
// replace using String
assertEquals(expectedResult, sub.replace(replaceTemplate));
@@ -534,7 +534,7 @@ public class StrSubstitutorTest {
}
// replace using char[]
- char[] chars = replaceTemplate.toCharArray();
+ final char[] chars = replaceTemplate.toCharArray();
assertEquals(expectedResult, sub.replace(chars));
if (substring) {
assertEquals(expectedShortResult, sub.replace(chars, 1, chars.length - 2));
@@ -555,7 +555,7 @@ public class StrSubstitutorTest {
}
// replace using object
- MutableObject<String> obj = new MutableObject<String>(replaceTemplate); // toString returns template
+ final MutableObject<String> obj = new MutableObject<String>(replaceTemplate); // toString returns template
assertEquals(expectedResult, sub.replace(obj));
// replace in StringBuffer
@@ -580,7 +580,7 @@ public class StrSubstitutorTest {
}
private void doTestNoReplace(final String replaceTemplate) {
- StrSubstitutor sub = new StrSubstitutor(values);
+ final StrSubstitutor sub = new StrSubstitutor(values);
if (replaceTemplate == null) {
assertEquals(null, sub.replace((String) null));
@@ -598,7 +598,7 @@ public class StrSubstitutorTest {
assertFalse(sub.replaceIn((StrBuilder) null, 0, 100));
} else {
assertEquals(replaceTemplate, sub.replace(replaceTemplate));
- StrBuilder bld = new StrBuilder(replaceTemplate);
+ final StrBuilder bld = new StrBuilder(replaceTemplate);
assertFalse(sub.replaceIn(bld));
assertEquals(replaceTemplate, bld.toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java
index 969c2337b..8bf434bf3 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java
@@ -46,15 +46,15 @@ public class StrTokenizerTest {
@Test
public void test1() {
- String input = "a;b;c;\"d;\"\"e\";f; ; ; ";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b;c;\"d;\"\"e\";f; ; ; ";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", "", "", "",};
+ final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", "", "", "",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -67,15 +67,15 @@ public class StrTokenizerTest {
@Test
public void test2() {
- String input = "a;b;c ;\"d;\"\"e\";f; ; ;";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b;c ;\"d;\"\"e\";f; ; ;";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(false);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", "",};
+ final String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", "",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -88,15 +88,15 @@ public class StrTokenizerTest {
@Test
public void test3() {
- String input = "a;b; c;\"d;\"\"e\";f; ; ;";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b; c;\"d;\"\"e\";f; ; ;";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(false);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", "",};
+ final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", "",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -109,15 +109,15 @@ public class StrTokenizerTest {
@Test
public void test4() {
- String input = "a;b; c;\"d;\"\"e\";f; ; ;";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b; c;\"d;\"\"e\";f; ; ;";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(true);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", "c", "d;\"e", "f",};
+ final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -130,16 +130,16 @@ public class StrTokenizerTest {
@Test
public void test5() {
- String input = "a;b; c;\"d;\"\"e\";f; ; ;";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b; c;\"d;\"\"e\";f; ; ;";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", null, null, null,};
+ final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", null, null, null,};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -152,16 +152,16 @@ public class StrTokenizerTest {
@Test
public void test6() {
- String input = "a;b; c;\"d;\"\"e\";f; ; ;";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a;b; c;\"d;\"\"e\";f; ; ;";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterChar(';');
tok.setQuoteChar('"');
tok.setIgnoredMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
// tok.setTreatingEmptyAsNull(true);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", null, null, null,};
+ final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", null, null, null,};
int nextCount = 0;
while (tok.hasNext()) {
@@ -188,15 +188,15 @@ public class StrTokenizerTest {
@Test
public void test7() {
- String input = "a b c \"d e\" f ";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a b c \"d e\" f ";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterMatcher(StrMatcher.spaceMatcher());
tok.setQuoteMatcher(StrMatcher.doubleQuoteMatcher());
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(false);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "", "", "b", "c", "d e", "f", "",};
+ final String expected[] = new String[]{"a", "", "", "b", "c", "d e", "f", "",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -209,15 +209,15 @@ public class StrTokenizerTest {
@Test
public void test8() {
- String input = "a b c \"d e\" f ";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a b c \"d e\" f ";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setDelimiterMatcher(StrMatcher.spaceMatcher());
tok.setQuoteMatcher(StrMatcher.doubleQuoteMatcher());
tok.setIgnoredMatcher(StrMatcher.noneMatcher());
tok.setIgnoreEmptyTokens(true);
- String tokens[] = tok.getTokenArray();
+ final String tokens[] = tok.getTokenArray();
- String expected[] = new String[]{"a", "b", "c", "d e", "f",};
+ final String expected[] = new String[]{"a", "b", "c", "d e", "f",};
assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length);
for (int i = 0; i < expected.length; i++) {
@@ -229,8 +229,8 @@ public class StrTokenizerTest {
@Test
public void testBasic1() {
- String input = "a b c";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a b c";
+ final StrTokenizer tok = new StrTokenizer(input);
assertEquals("a", tok.next());
assertEquals("b", tok.next());
assertEquals("c", tok.next());
@@ -239,8 +239,8 @@ public class StrTokenizerTest {
@Test
public void testBasic2() {
- String input = "a \nb\fc";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a \nb\fc";
+ final StrTokenizer tok = new StrTokenizer(input);
assertEquals("a", tok.next());
assertEquals("b", tok.next());
assertEquals("c", tok.next());
@@ -249,8 +249,8 @@ public class StrTokenizerTest {
@Test
public void testBasic3() {
- String input = "a \nb\u0001\fc";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a \nb\u0001\fc";
+ final StrTokenizer tok = new StrTokenizer(input);
assertEquals("a", tok.next());
assertEquals("b\u0001", tok.next());
assertEquals("c", tok.next());
@@ -259,8 +259,8 @@ public class StrTokenizerTest {
@Test
public void testBasic4() {
- String input = "a \"b\" c";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a \"b\" c";
+ final StrTokenizer tok = new StrTokenizer(input);
assertEquals("a", tok.next());
assertEquals("\"b\"", tok.next());
assertEquals("c", tok.next());
@@ -269,8 +269,8 @@ public class StrTokenizerTest {
@Test
public void testBasic5() {
- String input = "a:b':c";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a:b':c";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
assertEquals("a", tok.next());
assertEquals("b'", tok.next());
assertEquals("c", tok.next());
@@ -279,8 +279,8 @@ public class StrTokenizerTest {
@Test
public void testBasicDelim1() {
- String input = "a:b:c";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a:b:c";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
assertEquals("a", tok.next());
assertEquals("b", tok.next());
assertEquals("c", tok.next());
@@ -289,16 +289,16 @@ public class StrTokenizerTest {
@Test
public void testBasicDelim2() {
- String input = "a:b:c";
- StrTokenizer tok = new StrTokenizer(input, ',');
+ final String input = "a:b:c";
+ final StrTokenizer tok = new StrTokenizer(input, ',');
assertEquals("a:b:c", tok.next());
assertFalse(tok.hasNext());
}
@Test
public void testBasicEmpty1() {
- String input = "a b c";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a b c";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setIgnoreEmptyTokens(false);
assertEquals("a", tok.next());
assertEquals("", tok.next());
@@ -309,8 +309,8 @@ public class StrTokenizerTest {
@Test
public void testBasicEmpty2() {
- String input = "a b c";
- StrTokenizer tok = new StrTokenizer(input);
+ final String input = "a b c";
+ final StrTokenizer tok = new StrTokenizer(input);
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
assertEquals("a", tok.next());
@@ -322,8 +322,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted1() {
- String input = "a 'b' c";
- StrTokenizer tok = new StrTokenizer(input, ' ', '\'');
+ final String input = "a 'b' c";
+ final StrTokenizer tok = new StrTokenizer(input, ' ', '\'');
assertEquals("a", tok.next());
assertEquals("b", tok.next());
assertEquals("c", tok.next());
@@ -332,8 +332,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted2() {
- String input = "a:'b':";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a:'b':";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
assertEquals("a", tok.next());
@@ -344,8 +344,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted3() {
- String input = "a:'b''c'";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a:'b''c'";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
assertEquals("a", tok.next());
@@ -355,8 +355,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted4() {
- String input = "a: 'b' 'c' :d";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a: 'b' 'c' :d";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -368,8 +368,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted5() {
- String input = "a: 'b'x'c' :d";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a: 'b'x'c' :d";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -381,8 +381,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted6() {
- String input = "a:'b'\"c':d";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a:'b'\"c':d";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setQuoteMatcher(StrMatcher.quoteMatcher());
assertEquals("a", tok.next());
assertEquals("b\"c:d", tok.next());
@@ -391,8 +391,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuoted7() {
- String input = "a:\"There's a reason here\":b";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a:\"There's a reason here\":b";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setQuoteMatcher(StrMatcher.quoteMatcher());
assertEquals("a", tok.next());
assertEquals("There's a reason here", tok.next());
@@ -402,8 +402,8 @@ public class StrTokenizerTest {
@Test
public void testBasicQuotedTrimmed1() {
- String input = "a: 'b' :";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "a: 'b' :";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -415,8 +415,8 @@ public class StrTokenizerTest {
@Test
public void testBasicTrimmed1() {
- String input = "a: b : ";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a: b : ";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -428,8 +428,8 @@ public class StrTokenizerTest {
@Test
public void testBasicTrimmed2() {
- String input = "a: b :";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a: b :";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setTrimmerMatcher(StrMatcher.stringMatcher(" "));
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -441,8 +441,8 @@ public class StrTokenizerTest {
@Test
public void testBasicIgnoreTrimmed1() {
- String input = "a: bIGNOREc : ";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "a: bIGNOREc : ";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setIgnoredMatcher(StrMatcher.stringMatcher("IGNORE"));
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
@@ -455,8 +455,8 @@ public class StrTokenizerTest {
@Test
public void testBasicIgnoreTrimmed2() {
- String input = "IGNOREaIGNORE: IGNORE bIGNOREc IGNORE : IGNORE ";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "IGNOREaIGNORE: IGNORE bIGNOREc IGNORE : IGNORE ";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setIgnoredMatcher(StrMatcher.stringMatcher("IGNORE"));
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
@@ -469,8 +469,8 @@ public class StrTokenizerTest {
@Test
public void testBasicIgnoreTrimmed3() {
- String input = "IGNOREaIGNORE: IGNORE bIGNOREc IGNORE : IGNORE ";
- StrTokenizer tok = new StrTokenizer(input, ':');
+ final String input = "IGNOREaIGNORE: IGNORE bIGNOREc IGNORE : IGNORE ";
+ final StrTokenizer tok = new StrTokenizer(input, ':');
tok.setIgnoredMatcher(StrMatcher.stringMatcher("IGNORE"));
tok.setIgnoreEmptyTokens(false);
tok.setEmptyTokenAsNull(true);
@@ -482,8 +482,8 @@ public class StrTokenizerTest {
@Test
public void testBasicIgnoreTrimmed4() {
- String input = "IGNOREaIGNORE: IGNORE 'bIGNOREc'IGNORE'd' IGNORE : IGNORE ";
- StrTokenizer tok = new StrTokenizer(input, ':', '\'');
+ final String input = "IGNOREaIGNORE: IGNORE 'bIGNOREc'IGNORE'd' IGNORE : IGNORE ";
+ final StrTokenizer tok = new StrTokenizer(input, ':', '\'');
tok.setIgnoredMatcher(StrMatcher.stringMatcher("IGNORE"));
tok.setTrimmerMatcher(StrMatcher.trimMatcher());
tok.setIgnoreEmptyTokens(false);
@@ -497,10 +497,10 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testListArray() {
- String input = "a b c";
- StrTokenizer tok = new StrTokenizer(input);
- String[] array = tok.getTokenArray();
- List<?> list = tok.getTokenList();
+ final String input = "a b c";
+ final StrTokenizer tok = new StrTokenizer(input);
+ final String[] array = tok.getTokenArray();
+ final List<?> list = tok.getTokenList();
assertEquals(Arrays.asList(array), list);
assertEquals(3, list.size());
@@ -539,12 +539,12 @@ public class StrTokenizerTest {
try {
tokenizer.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
}
@Test
public void testGetContent() {
- String input = "a b c \"d e\" f ";
+ final String input = "a b c \"d e\" f ";
StrTokenizer tok = new StrTokenizer(input);
assertEquals(input, tok.getContent());
@@ -558,7 +558,7 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testChaining() {
- StrTokenizer tok = new StrTokenizer();
+ final StrTokenizer tok = new StrTokenizer();
assertEquals(tok, tok.reset());
assertEquals(tok, tok.reset(""));
assertEquals(tok, tok.reset(new char[0]));
@@ -580,7 +580,7 @@ public class StrTokenizerTest {
*/
@Test
public void testCloneNotSupportedException() {
- Object notCloned = new StrTokenizer() {
+ final Object notCloned = new StrTokenizer() {
@Override
Object cloneReset() throws CloneNotSupportedException {
throw new CloneNotSupportedException("test");
@@ -591,13 +591,13 @@ public class StrTokenizerTest {
@Test
public void testCloneNull() {
- StrTokenizer tokenizer = new StrTokenizer((char[]) null);
+ final StrTokenizer tokenizer = new StrTokenizer((char[]) null);
// Start sanity check
assertEquals(null, tokenizer.nextToken());
tokenizer.reset();
assertEquals(null, tokenizer.nextToken());
// End sanity check
- StrTokenizer clonedTokenizer = (StrTokenizer) tokenizer.clone();
+ final StrTokenizer clonedTokenizer = (StrTokenizer) tokenizer.clone();
tokenizer.reset();
assertEquals(null, tokenizer.nextToken());
assertEquals(null, clonedTokenizer.nextToken());
@@ -605,14 +605,14 @@ public class StrTokenizerTest {
@Test
public void testCloneReset() {
- char[] input = new char[]{'a'};
- StrTokenizer tokenizer = new StrTokenizer(input);
+ final char[] input = new char[]{'a'};
+ final StrTokenizer tokenizer = new StrTokenizer(input);
// Start sanity check
assertEquals("a", tokenizer.nextToken());
tokenizer.reset(input);
assertEquals("a", tokenizer.nextToken());
// End sanity check
- StrTokenizer clonedTokenizer = (StrTokenizer) tokenizer.clone();
+ final StrTokenizer clonedTokenizer = (StrTokenizer) tokenizer.clone();
input[0] = 'b';
tokenizer.reset(input);
assertEquals("b", tokenizer.nextToken());
@@ -718,7 +718,7 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testReset() {
- StrTokenizer tok = new StrTokenizer("a b c");
+ final StrTokenizer tok = new StrTokenizer("a b c");
assertEquals("a", tok.next());
assertEquals("b", tok.next());
assertEquals("c", tok.next());
@@ -734,7 +734,7 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testReset_String() {
- StrTokenizer tok = new StrTokenizer("x x x");
+ final StrTokenizer tok = new StrTokenizer("x x x");
tok.reset("d e");
assertEquals("d", tok.next());
assertEquals("e", tok.next());
@@ -747,9 +747,9 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testReset_charArray() {
- StrTokenizer tok = new StrTokenizer("x x x");
+ final StrTokenizer tok = new StrTokenizer("x x x");
- char[] array = new char[] {'a', 'b', 'c'};
+ final char[] array = new char[] {'a', 'b', 'c'};
tok.reset(array);
assertEquals("abc", tok.next());
assertFalse(tok.hasNext());
@@ -798,27 +798,27 @@ public class StrTokenizerTest {
@Test
public void testIteration() {
- StrTokenizer tkn = new StrTokenizer("a b c");
+ final StrTokenizer tkn = new StrTokenizer("a b c");
assertFalse(tkn.hasPrevious());
try {
tkn.previous();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
assertTrue(tkn.hasNext());
assertEquals("a", tkn.next());
try {
tkn.remove();
fail();
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
try {
tkn.set("x");
fail();
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
try {
tkn.add("y");
fail();
- } catch (UnsupportedOperationException ex) {}
+ } catch (final UnsupportedOperationException ex) {}
assertTrue(tkn.hasPrevious());
assertTrue(tkn.hasNext());
@@ -833,7 +833,7 @@ public class StrTokenizerTest {
try {
tkn.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
assertTrue(tkn.hasPrevious());
assertFalse(tkn.hasNext());
}
@@ -841,7 +841,7 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testTokenizeSubclassInputChange() {
- StrTokenizer tkn = new StrTokenizer("a b c d e") {
+ final StrTokenizer tkn = new StrTokenizer("a b c d e") {
@Override
protected List<String> tokenize(final char[] chars, final int offset, final int count) {
return super.tokenize("w x y z".toCharArray(), 2, 5);
@@ -854,10 +854,10 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testTokenizeSubclassOutputChange() {
- StrTokenizer tkn = new StrTokenizer("a b c") {
+ final StrTokenizer tkn = new StrTokenizer("a b c") {
@Override
protected List<String> tokenize(final char[] chars, final int offset, final int count) {
- List<String> list = super.tokenize(chars, offset, count);
+ final List<String> list = super.tokenize(chars, offset, count);
Collections.reverse(list);
return list;
}
@@ -870,7 +870,7 @@ public class StrTokenizerTest {
//-----------------------------------------------------------------------
@Test
public void testToString() {
- StrTokenizer tkn = new StrTokenizer("a b c d e");
+ final StrTokenizer tkn = new StrTokenizer("a b c d e");
assertEquals("StrTokenizer[not tokenized yet]", tkn.toString());
tkn.next();
assertEquals("StrTokenizer[a, b, c, d, e]", tkn.toString());
diff --git a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java
index 35806ef46..786f42133 100644
--- a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java
@@ -37,7 +37,7 @@ public class WordUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new WordUtils());
- Constructor<?>[] cons = WordUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = WordUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(WordUtils.class.getModifiers()));
@@ -54,7 +54,7 @@ public class WordUtilsTest {
assertEquals("", WordUtils.wrap("", -1));
// normal
- String systemNewLine = System.getProperty("line.separator");
+ final String systemNewLine = System.getProperty("line.separator");
String input = "Here is one line of text that is going to be wrapped after 20 columns.";
String expected = "Here is one line of" + systemNewLine + "text that is going"
+ systemNewLine + "to be wrapped after" + systemNewLine + "20 columns.";
@@ -110,7 +110,7 @@ public class WordUtilsTest {
assertEquals(expected, WordUtils.wrap(input, -1, "\n", false));
// system newline char
- String systemNewLine = System.getProperty("line.separator");
+ final String systemNewLine = System.getProperty("line.separator");
input = "Here is one line of text that is going to be wrapped after 20 columns.";
expected = "Here is one line of" + systemNewLine + "text that is going" + systemNewLine
+ "to be wrapped after" + systemNewLine + "20 columns.";
@@ -360,8 +360,8 @@ public class WordUtilsTest {
assertEquals("I AM here 123", WordUtils.swapCase("i am HERE 123") );
assertEquals("i am here 123", WordUtils.swapCase("I AM HERE 123") );
- String test = "This String contains a TitleCase character: \u01C8";
- String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9";
+ final String test = "This String contains a TitleCase character: \u01C8";
+ final String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9";
assertEquals(expect, WordUtils.swapCase(test));
}
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
index 71c369268..8d3b3fc3c 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
@@ -38,9 +38,9 @@ public class EntityArraysTest {
// LANG-659 - check arrays for duplicate entries
@Test
public void testHTML40_EXTENDED_ESCAPE(){
- Set<String> col0 = new HashSet<String>();
- Set<String> col1 = new HashSet<String>();
- String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE();
+ final Set<String> col0 = new HashSet<String>();
+ final Set<String> col1 = new HashSet<String>();
+ final String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE();
for(int i =0; i <sa.length; i++){
assertTrue("Already added entry 0: "+i+" "+sa[i][0],col0.add(sa[i][0]));
assertTrue("Already added entry 1: "+i+" "+sa[i][1],col1.add(sa[i][1]));
@@ -50,13 +50,13 @@ public class EntityArraysTest {
// LANG-658 - check arrays for duplicate entries
@Test
public void testISO8859_1_ESCAPE(){
- Set<String> col0 = new HashSet<String>();
- Set<String> col1 = new HashSet<String>();
- String [][] sa = EntityArrays.ISO8859_1_ESCAPE();
+ final Set<String> col0 = new HashSet<String>();
+ final Set<String> col1 = new HashSet<String>();
+ final String [][] sa = EntityArrays.ISO8859_1_ESCAPE();
boolean success = true;
for(int i =0; i <sa.length; i++){
- boolean add0 = col0.add(sa[i][0]);
- boolean add1 = col1.add(sa[i][1]);
+ final boolean add0 = col0.add(sa[i][0]);
+ final boolean add1 = col1.add(sa[i][1]);
if (!add0) {
success = false;
System.out.println("Already added entry 0: "+i+" "+sa[i][0]+" "+sa[i][1]);
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java b/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
index 8efb009e2..af4d6843b 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
@@ -32,9 +32,9 @@ public class LookupTranslatorTest {
@Test
public void testBasicLookup() throws IOException {
- LookupTranslator lt = new LookupTranslator(new CharSequence[][] { { "one", "two" } });
- StringWriter out = new StringWriter();
- int result = lt.translate("one", 0, out);
+ final LookupTranslator lt = new LookupTranslator(new CharSequence[][] { { "one", "two" } });
+ final StringWriter out = new StringWriter();
+ final int result = lt.translate("one", 0, out);
assertEquals("Incorrect codepoint consumption", 3, result);
assertEquals("Incorrect value", "two", out.toString());
}
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
index f3c6dff79..816d8a8d2 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
@@ -29,39 +29,39 @@ public class NumericEntityEscaperTest {
@Test
public void testBelow() {
- NumericEntityEscaper nee = NumericEntityEscaper.below('F');
+ final NumericEntityEscaper nee = NumericEntityEscaper.below('F');
- String input = "ADFGZ";
- String result = nee.translate(input);
+ final String input = "ADFGZ";
+ final String result = nee.translate(input);
assertEquals("Failed to escape numeric entities via the below method", "&#65;&#68;FGZ", result);
}
@Test
public void testBetween() {
- NumericEntityEscaper nee = NumericEntityEscaper.between('F', 'L');
+ final NumericEntityEscaper nee = NumericEntityEscaper.between('F', 'L');
- String input = "ADFGZ";
- String result = nee.translate(input);
+ final String input = "ADFGZ";
+ final String result = nee.translate(input);
assertEquals("Failed to escape numeric entities via the between method", "AD&#70;&#71;Z", result);
}
@Test
public void testAbove() {
- NumericEntityEscaper nee = NumericEntityEscaper.above('F');
+ final NumericEntityEscaper nee = NumericEntityEscaper.above('F');
- String input = "ADFGZ";
- String result = nee.translate(input);
+ final String input = "ADFGZ";
+ final String result = nee.translate(input);
assertEquals("Failed to escape numeric entities via the above method", "ADF&#71;&#90;", result);
}
// See LANG-617
@Test
public void testSupplementary() {
- NumericEntityEscaper nee = new NumericEntityEscaper();
- String input = "\uD803\uDC22";
- String expected = "&#68642;";
+ final NumericEntityEscaper nee = new NumericEntityEscaper();
+ final String input = "\uD803\uDC22";
+ final String expected = "&#68642;";
- String result = nee.translate(input);
+ final String result = nee.translate(input);
assertEquals("Failed to escape numeric entities supplementary characters", expected, result);
}
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
index cb80ef67b..4087cb9ed 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
@@ -30,17 +30,17 @@ public class NumericEntityUnescaperTest {
@Test
public void testSupplementaryUnescaping() {
- NumericEntityUnescaper neu = new NumericEntityUnescaper();
- String input = "&#68642;";
- String expected = "\uD803\uDC22";
+ final NumericEntityUnescaper neu = new NumericEntityUnescaper();
+ final String input = "&#68642;";
+ final String expected = "\uD803\uDC22";
- String result = neu.translate(input);
+ final String result = neu.translate(input);
assertEquals("Failed to unescape numeric entities supplementary characters", expected, result);
}
@Test
public void testOutOfBounds() {
- NumericEntityUnescaper neu = new NumericEntityUnescaper();
+ final NumericEntityUnescaper neu = new NumericEntityUnescaper();
assertEquals("Failed to ignore when last character is &", "Test &", neu.translate("Test &"));
assertEquals("Failed to ignore when last character is &", "Test &#", neu.translate("Test &#"));
@@ -73,7 +73,7 @@ public class NumericEntityUnescaperTest {
try {
result = neu.translate(input);
fail("IllegalArgumentException expected");
- } catch(IllegalArgumentException iae) {
+ } catch(final IllegalArgumentException iae) {
// expected
}
}
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
index 91c6479de..7cbe60ce3 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
@@ -28,7 +28,7 @@ public class OctalUnescaperTest {
@Test
public void testBetween() {
- OctalUnescaper oue = new OctalUnescaper(); //.between("1", "377");
+ final OctalUnescaper oue = new OctalUnescaper(); //.between("1", "377");
String input = "\\45";
String result = oue.translate(input);
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
index 7dfe322c9..61f2a0cc6 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
@@ -29,28 +29,28 @@ public class UnicodeEscaperTest {
@Test
public void testBelow() {
- UnicodeEscaper ue = UnicodeEscaper.below('F');
+ final UnicodeEscaper ue = UnicodeEscaper.below('F');
- String input = "ADFGZ";
- String result = ue.translate(input);
+ final String input = "ADFGZ";
+ final String result = ue.translate(input);
assertEquals("Failed to escape Unicode characters via the below method", "\\u0041\\u0044FGZ", result);
}
@Test
public void testBetween() {
- UnicodeEscaper ue = UnicodeEscaper.between('F', 'L');
+ final UnicodeEscaper ue = UnicodeEscaper.between('F', 'L');
- String input = "ADFGZ";
- String result = ue.translate(input);
+ final String input = "ADFGZ";
+ final String result = ue.translate(input);
assertEquals("Failed to escape Unicode characters via the between method", "AD\\u0046\\u0047Z", result);
}
@Test
public void testAbove() {
- UnicodeEscaper ue = UnicodeEscaper.above('F');
+ final UnicodeEscaper ue = UnicodeEscaper.above('F');
- String input = "ADFGZ";
- String result = ue.translate(input);
+ final String input = "ADFGZ";
+ final String result = ue.translate(input);
assertEquals("Failed to escape Unicode characters via the above method", "ADF\\u0047\\u005A", result);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
index ed882aa26..f003011f3 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
@@ -31,30 +31,30 @@ public class UnicodeUnescaperTest {
// Requested in LANG-507
@Test
public void testUPlus() {
- UnicodeUnescaper uu = new UnicodeUnescaper();
+ final UnicodeUnescaper uu = new UnicodeUnescaper();
- String input = "\\u+0047";
+ final String input = "\\u+0047";
assertEquals("Failed to unescape Unicode characters with 'u+' notation", "G", uu.translate(input));
}
@Test
public void testUuuuu() {
- UnicodeUnescaper uu = new UnicodeUnescaper();
+ final UnicodeUnescaper uu = new UnicodeUnescaper();
- String input = "\\uuuuuuuu0047";
- String result = uu.translate(input);
+ final String input = "\\uuuuuuuu0047";
+ final String result = uu.translate(input);
assertEquals("Failed to unescape Unicode characters with many 'u' characters", "G", result);
}
@Test
public void testLessThanFour() {
- UnicodeUnescaper uu = new UnicodeUnescaper();
+ final UnicodeUnescaper uu = new UnicodeUnescaper();
- String input = "\\0047\\u006";
+ final String input = "\\0047\\u006";
try {
uu.translate(input);
fail("A lack of digits in a Unicode escape sequence failed to throw an exception");
- } catch(IllegalArgumentException iae) {
+ } catch(final IllegalArgumentException iae) {
// expected
}
}
diff --git a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
index 6f3299fa0..2d8984218 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
@@ -34,7 +34,7 @@ public class DateFormatUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new DateFormatUtils());
- Constructor<?>[] cons = DateFormatUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = DateFormatUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(DateFormatUtils.class.getModifiers()));
@@ -44,14 +44,14 @@ public class DateFormatUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testFormat() {
- Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.set(2005,0,1,12,0,0);
c.setTimeZone(TimeZone.getDefault());
- StringBuilder buffer = new StringBuilder ();
- int year = c.get(Calendar.YEAR);
- int month = c.get(Calendar.MONTH) + 1;
- int day = c.get(Calendar.DAY_OF_MONTH);
- int hour = c.get(Calendar.HOUR_OF_DAY);
+ final StringBuilder buffer = new StringBuilder ();
+ final int year = c.get(Calendar.YEAR);
+ final int month = c.get(Calendar.MONTH) + 1;
+ final int day = c.get(Calendar.DAY_OF_MONTH);
+ final int hour = c.get(Calendar.HOUR_OF_DAY);
buffer.append (year);
buffer.append(month);
buffer.append(day);
@@ -68,14 +68,14 @@ public class DateFormatUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testFormatCalendar() {
- Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.set(2005,0,1,12,0,0);
c.setTimeZone(TimeZone.getDefault());
- StringBuilder buffer = new StringBuilder ();
- int year = c.get(Calendar.YEAR);
- int month = c.get(Calendar.MONTH) + 1;
- int day = c.get(Calendar.DAY_OF_MONTH);
- int hour = c.get(Calendar.HOUR_OF_DAY);
+ final StringBuilder buffer = new StringBuilder ();
+ final int year = c.get(Calendar.YEAR);
+ final int month = c.get(Calendar.MONTH) + 1;
+ final int day = c.get(Calendar.DAY_OF_MONTH);
+ final int hour = c.get(Calendar.HOUR_OF_DAY);
buffer.append (year);
buffer.append(month);
buffer.append(day);
@@ -91,7 +91,7 @@ public class DateFormatUtilsTest {
@Test
public void testFormatUTC() {
- Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.set(2005,0,1,12,0,0);
assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern()));
@@ -104,8 +104,8 @@ public class DateFormatUtilsTest {
@Test
public void testDateTimeISO(){
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar cal = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2002,1,23,9,11,12);
String text = DateFormatUtils.format(cal.getTime(),
DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), timeZone);
@@ -128,8 +128,8 @@ public class DateFormatUtilsTest {
@Test
public void testDateISO(){
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar cal = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2002,1,23,10,11,12);
String text = DateFormatUtils.format(cal.getTime(),
DateFormatUtils.ISO_DATE_FORMAT.getPattern(), timeZone);
@@ -152,8 +152,8 @@ public class DateFormatUtilsTest {
@Test
public void testTimeISO(){
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar cal = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2002,1,23,10,11,12);
String text = DateFormatUtils.format(cal.getTime(),
DateFormatUtils.ISO_TIME_FORMAT.getPattern(), timeZone);
@@ -176,8 +176,8 @@ public class DateFormatUtilsTest {
@Test
public void testTimeNoTISO(){
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar cal = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2002,1,23,10,11,12);
String text = DateFormatUtils.format(cal.getTime(),
DateFormatUtils.ISO_TIME_NO_T_FORMAT.getPattern(), timeZone);
@@ -200,8 +200,8 @@ public class DateFormatUtilsTest {
@Test
public void testSMTP(){
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar cal = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2003,5,8,10,11,12);
String text = DateFormatUtils.format(cal.getTime(),
DateFormatUtils.SMTP_DATETIME_FORMAT.getPattern(), timeZone,
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
index 6b05aafdd..ff9cf3369 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
@@ -48,27 +48,27 @@ public class DateUtilsFragmentTest {
try {
DateUtils.getFragmentInMilliseconds((Date) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInSeconds((Date) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInMinutes((Date) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInHours((Date) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInDays((Date) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
}
@Test
@@ -76,27 +76,27 @@ public class DateUtilsFragmentTest {
try {
DateUtils.getFragmentInMilliseconds((Calendar) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInSeconds((Calendar) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInMinutes((Calendar) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInHours((Calendar) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInDays((Calendar) null, Calendar.MILLISECOND);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
}
@Test
@@ -104,27 +104,27 @@ public class DateUtilsFragmentTest {
try {
DateUtils.getFragmentInMilliseconds(aDate, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInSeconds(aDate, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInMinutes(aDate, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInHours(aDate, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInDays(aDate, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
}
@Test
@@ -132,27 +132,27 @@ public class DateUtilsFragmentTest {
try {
DateUtils.getFragmentInMilliseconds(aCalendar, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInSeconds(aCalendar, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInMinutes(aCalendar, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInHours(aCalendar, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
try {
DateUtils.getFragmentInDays(aCalendar, 0);
fail();
- } catch(IllegalArgumentException iae) {}
+ } catch(final IllegalArgumentException iae) {}
}
@Test
@@ -239,13 +239,13 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfSecondWithDate() {
- long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.SECOND);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.SECOND);
assertEquals(millis, testResult);
}
@Test
public void testMillisecondsOfSecondWithCalendar() {
- long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.SECOND);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.SECOND);
assertEquals(millis, testResult);
assertEquals(aCalendar.get(Calendar.MILLISECOND), testResult);
}
@@ -254,25 +254,25 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfMinuteWithDate() {
- long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.MINUTE);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.MINUTE);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND), testResult);
}
@Test
public void testMillisecondsOfMinuteWithCalender() {
- long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.MINUTE);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.MINUTE);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND), testResult);
}
@Test
public void testSecondsofMinuteWithDate() {
- long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MINUTE);
+ final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MINUTE);
assertEquals(seconds, testResult);
}
@Test
public void testSecondsofMinuteWithCalendar() {
- long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.MINUTE);
+ final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.MINUTE);
assertEquals(seconds, testResult);
assertEquals(aCalendar.get(Calendar.SECOND), testResult);
}
@@ -281,19 +281,19 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfHourWithDate() {
- long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.HOUR_OF_DAY);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE), testResult);
}
@Test
public void testMillisecondsOfHourWithCalendar() {
- long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.HOUR_OF_DAY);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE), testResult);
}
@Test
public void testSecondsofHourWithDate() {
- long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.HOUR_OF_DAY);
assertEquals(
seconds
+ (minutes
@@ -303,7 +303,7 @@ public class DateUtilsFragmentTest {
@Test
public void testSecondsofHourWithCalendar() {
- long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.HOUR_OF_DAY);
assertEquals(
seconds
+ (minutes
@@ -313,13 +313,13 @@ public class DateUtilsFragmentTest {
@Test
public void testMinutesOfHourWithDate() {
- long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.HOUR_OF_DAY);
assertEquals(minutes, testResult);
}
@Test
public void testMinutesOfHourWithCalendar() {
- long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.HOUR_OF_DAY);
+ final long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.HOUR_OF_DAY);
assertEquals(minutes, testResult);
}
@@ -327,7 +327,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfDayWithDate() {
long testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DATE);
- long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
+ final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@@ -336,7 +336,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfDayWithCalendar() {
long testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DATE);
- long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
+ final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@@ -345,7 +345,7 @@ public class DateUtilsFragmentTest {
@Test
public void testSecondsOfDayWithDate() {
long testresult = DateUtils.getFragmentInSeconds(aDate, Calendar.DATE);
- long expectedValue = seconds + ((minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_SECOND;
+ final long expectedValue = seconds + ((minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_SECOND;
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInSeconds(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@@ -354,7 +354,7 @@ public class DateUtilsFragmentTest {
@Test
public void testSecondsOfDayWithCalendar() {
long testresult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.DATE);
- long expectedValue = seconds + ((minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_SECOND;
+ final long expectedValue = seconds + ((minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_SECOND;
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@@ -363,7 +363,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMinutesOfDayWithDate() {
long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DATE);
- long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
+ final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
assertEquals(expectedValue,testResult);
testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue,testResult);
@@ -372,7 +372,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMinutesOfDayWithCalendar() {
long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DATE);
- long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
+ final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
assertEquals(expectedValue, testResult);
testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testResult);
@@ -381,7 +381,7 @@ public class DateUtilsFragmentTest {
@Test
public void testHoursOfDayWithDate() {
long testResult = DateUtils.getFragmentInHours(aDate, Calendar.DATE);
- long expectedValue = hours;
+ final long expectedValue = hours;
assertEquals(expectedValue,testResult);
testResult = DateUtils.getFragmentInHours(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue,testResult);
@@ -390,7 +390,7 @@ public class DateUtilsFragmentTest {
@Test
public void testHoursOfDayWithCalendar() {
long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.DATE);
- long expectedValue = hours;
+ final long expectedValue = hours;
assertEquals(expectedValue, testResult);
testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testResult);
@@ -400,7 +400,7 @@ public class DateUtilsFragmentTest {
//Calendar.MONTH as useful fragment
@Test
public void testMillisecondsOfMonthWithDate() {
- long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.MONTH);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + (days * DateUtils.MILLIS_PER_DAY),
testResult);
@@ -408,7 +408,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfMonthWithCalendar() {
- long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.MONTH);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + (days * DateUtils.MILLIS_PER_DAY),
testResult);
@@ -416,7 +416,7 @@ testResult);
@Test
public void testSecondsOfMonthWithDate() {
- long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MONTH);
assertEquals(
seconds
+ ((minutes * DateUtils.MILLIS_PER_MINUTE)
@@ -427,7 +427,7 @@ testResult);
@Test
public void testSecondsOfMonthWithCalendar() {
- long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.MONTH);
assertEquals(
seconds
+ ((minutes * DateUtils.MILLIS_PER_MINUTE)
@@ -438,7 +438,7 @@ testResult);
@Test
public void testMinutesOfMonthWithDate() {
- long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.MONTH);
assertEquals(minutes
+ ((hours * DateUtils.MILLIS_PER_HOUR) + (days * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_MINUTE,
@@ -447,7 +447,7 @@ testResult);
@Test
public void testMinutesOfMonthWithCalendar() {
- long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.MONTH);
assertEquals( minutes +((hours * DateUtils.MILLIS_PER_HOUR) + (days * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_MINUTE,
testResult);
@@ -455,7 +455,7 @@ testResult);
@Test
public void testHoursOfMonthWithDate() {
- long testResult = DateUtils.getFragmentInHours(aDate, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInHours(aDate, Calendar.MONTH);
assertEquals(hours + ((days * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_HOUR,
testResult);
@@ -463,7 +463,7 @@ testResult);
@Test
public void testHoursOfMonthWithCalendar() {
- long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.MONTH);
+ final long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.MONTH);
assertEquals( hours +((days * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_HOUR,
testResult);
@@ -472,8 +472,8 @@ testResult);
//Calendar.YEAR as useful fragment
@Test
public void testMillisecondsOfYearWithDate() {
- long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.YEAR);
- Calendar cal = Calendar.getInstance();
+ final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.YEAR);
+ final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + (cal.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY),
@@ -482,7 +482,7 @@ testResult);
@Test
public void testMillisecondsOfYearWithCalendar() {
- long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.YEAR);
+ final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.YEAR);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + (aCalendar.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY),
testResult);
@@ -490,8 +490,8 @@ testResult);
@Test
public void testSecondsOfYearWithDate() {
- long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.YEAR);
- Calendar cal = Calendar.getInstance();
+ final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.YEAR);
+ final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(
seconds
@@ -503,7 +503,7 @@ testResult);
@Test
public void testSecondsOfYearWithCalendar() {
- long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.YEAR);
+ final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.YEAR);
assertEquals(
seconds
+ ((minutes * DateUtils.MILLIS_PER_MINUTE)
@@ -514,8 +514,8 @@ testResult);
@Test
public void testMinutesOfYearWithDate() {
- long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.YEAR);
- Calendar cal = Calendar.getInstance();
+ final long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.YEAR);
+ final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(minutes
+ ((hours * DateUtils.MILLIS_PER_HOUR) + (cal.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY))
@@ -525,7 +525,7 @@ testResult);
@Test
public void testMinutesOfYearWithCalendar() {
- long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.YEAR);
+ final long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.YEAR);
assertEquals( minutes +((hours * DateUtils.MILLIS_PER_HOUR) + (aCalendar.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_MINUTE,
testResult);
@@ -533,8 +533,8 @@ testResult);
@Test
public void testHoursOfYearWithDate() {
- long testResult = DateUtils.getFragmentInHours(aDate, Calendar.YEAR);
- Calendar cal = Calendar.getInstance();
+ final long testResult = DateUtils.getFragmentInHours(aDate, Calendar.YEAR);
+ final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(hours + ((cal.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_HOUR,
@@ -543,7 +543,7 @@ testResult);
@Test
public void testHoursOfYearWithCalendar() {
- long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.YEAR);
+ final long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.YEAR);
assertEquals( hours +((aCalendar.get(Calendar.DAY_OF_YEAR) * DateUtils.MILLIS_PER_DAY))
/ DateUtils.MILLIS_PER_HOUR,
testResult);
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
index 19af40cc7..2a3b29d5b 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
@@ -84,9 +84,9 @@ public class DateUtilsRoundingTest {
@Test
public void testRoundYear() throws Exception {
final int calendarField = Calendar.YEAR;
- Date roundedUpDate = dateTimeParser.parse("January 1, 2008 0:00:00.000");
- Date roundedDownDate = targetYearDate;
- Date lastRoundedDownDate = dateTimeParser.parse("June 30, 2007 23:59:59.999");
+ final Date roundedUpDate = dateTimeParser.parse("January 1, 2008 0:00:00.000");
+ final Date roundedDownDate = targetYearDate;
+ final Date lastRoundedDownDate = dateTimeParser.parse("June 30, 2007 23:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
}
@@ -416,7 +416,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateYear() throws Exception {
final int calendarField = Calendar.YEAR;
- Date lastTruncateDate = dateTimeParser.parse("December 31, 2007 23:59:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("December 31, 2007 23:59:59.999");
baseTruncateTest(targetYearDate, lastTruncateDate, calendarField);
}
@@ -429,8 +429,8 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateMonth() throws Exception {
final int calendarField = Calendar.MONTH;
- Date truncatedDate = dateTimeParser.parse("March 1, 2008 0:00:00.000");
- Date lastTruncateDate = dateTimeParser.parse("March 31, 2008 23:59:59.999");
+ final Date truncatedDate = dateTimeParser.parse("March 1, 2008 0:00:00.000");
+ final Date lastTruncateDate = dateTimeParser.parse("March 31, 2008 23:59:59.999");
baseTruncateTest(truncatedDate, lastTruncateDate, calendarField);
}
@@ -497,7 +497,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateDate() throws Exception {
final int calendarField = Calendar.DATE;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
baseTruncateTest(targetDateDate, lastTruncateDate, calendarField);
}
@@ -510,7 +510,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateDayOfMonth() throws Exception {
final int calendarField = Calendar.DAY_OF_MONTH;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
baseTruncateTest(targetDayOfMonthDate, lastTruncateDate, calendarField);
}
@@ -543,7 +543,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateHour() throws Exception {
final int calendarField = Calendar.HOUR;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999");
baseTruncateTest(targetHourDate, lastTruncateDate, calendarField);
}
@@ -556,7 +556,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateHourOfDay() throws Exception {
final int calendarField = Calendar.HOUR_OF_DAY;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999");
baseTruncateTest(targetHourOfDayDate, lastTruncateDate, calendarField);
}
@@ -569,7 +569,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateMinute() throws Exception {
final int calendarField = Calendar.MINUTE;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:59.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:59.999");
baseTruncateTest(targetMinuteDate, lastTruncateDate, calendarField);
}
@@ -582,7 +582,7 @@ public class DateUtilsRoundingTest {
@Test
public void testTruncateSecond() throws Exception {
final int calendarField = Calendar.SECOND;
- Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:14.999");
+ final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:14.999");
baseTruncateTest(targetSecondDate, lastTruncateDate, calendarField);
}
@@ -611,7 +611,7 @@ public class DateUtilsRoundingTest {
* @since 3.0
*/
protected void baseRoundTest(final Date roundedUpDate, final Date roundedDownDate, final Date lastRoundDownDate, final int calendarField) {
- Date firstRoundUpDate = DateUtils.addMilliseconds(lastRoundDownDate, 1);
+ final Date firstRoundUpDate = DateUtils.addMilliseconds(lastRoundDownDate, 1);
//Date-comparison
assertEquals(roundedDownDate, DateUtils.round(roundedDownDate, calendarField));
@@ -659,7 +659,7 @@ public class DateUtilsRoundingTest {
* @since 3.0
*/
protected void baseTruncateTest(final Date truncatedDate, final Date lastTruncateDate, final int calendarField) {
- Date nextTruncateDate = DateUtils.addMilliseconds(lastTruncateDate, 1);
+ final Date nextTruncateDate = DateUtils.addMilliseconds(lastTruncateDate, 1);
//Date-comparison
assertEquals("Truncating "+ fdf.format(truncatedDate) +" as Date with CalendarField-value "+ calendarField +" must return itself", truncatedDate, DateUtils.truncate(truncatedDate, calendarField));
@@ -704,22 +704,22 @@ public class DateUtilsRoundingTest {
assertEquals(januaryOneDate, DateUtils.round(minDate, calendarField));
assertEquals(januaryOneDate, DateUtils.round(maxDate, calendarField));
- Calendar minCalendar = Calendar.getInstance();
+ final Calendar minCalendar = Calendar.getInstance();
minCalendar.setTime(minDate);
- Calendar maxCalendar = Calendar.getInstance();
+ final Calendar maxCalendar = Calendar.getInstance();
maxCalendar.setTime(maxDate);
assertEquals("Rounding "+ fdf.format(januaryOneCalendar) +" as Date with CalendarField-value "+ calendarField +" must return itself", januaryOneCalendar, DateUtils.round(januaryOneCalendar, calendarField));
assertEquals(januaryOneCalendar, DateUtils.round(minCalendar, calendarField));
assertEquals(januaryOneCalendar, DateUtils.round(maxCalendar, calendarField));
- Date toPrevRoundDate = DateUtils.addMilliseconds(minDate, -1);
- Date toNextRoundDate = DateUtils.addMilliseconds(maxDate, 1);
+ final Date toPrevRoundDate = DateUtils.addMilliseconds(minDate, -1);
+ final Date toNextRoundDate = DateUtils.addMilliseconds(maxDate, 1);
assertFalse(fdf.format(minDate) +" is not an lower-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toPrevRoundDate, calendarField)));
assertFalse(fdf.format(maxDate) +" is not an upper-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toNextRoundDate, calendarField)));
- Calendar toPrevRoundCalendar = Calendar.getInstance();
+ final Calendar toPrevRoundCalendar = Calendar.getInstance();
toPrevRoundCalendar.setTime(toPrevRoundDate);
- Calendar toNextRoundCalendar = Calendar.getInstance();
+ final Calendar toNextRoundCalendar = Calendar.getInstance();
toNextRoundCalendar.setTime(toNextRoundDate);
assertFalse(fdf.format(minCalendar) +" is not an lower-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toPrevRoundDate, calendarField)));
assertFalse(fdf.format(maxCalendar) +" is not an upper-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toNextRoundDate, calendarField)));
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
index acc0cce0f..48cc3ea15 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
@@ -53,7 +53,7 @@ public class DateUtilsTest {
private static final long MILLIS_TEST;
static {
- GregorianCalendar cal = new GregorianCalendar(2000, 6, 5, 4, 3, 2);
+ final GregorianCalendar cal = new GregorianCalendar(2000, 6, 5, 4, 3, 2);
cal.set(Calendar.MILLISECOND, 1);
MILLIS_TEST = cal.getTime().getTime();
System.out.println("DateUtilsTest: Default Locale="+Locale.getDefault());
@@ -149,7 +149,7 @@ public class DateUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new DateUtils());
- Constructor<?>[] cons = DateUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = DateUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(DateUtils.class.getModifiers()));
@@ -171,14 +171,14 @@ public class DateUtilsTest {
try {
DateUtils.isSameDay((Date) null, (Date) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
//-----------------------------------------------------------------------
@Test
public void testIsSameDay_Cal() {
- GregorianCalendar cal1 = new GregorianCalendar(2004, 6, 9, 13, 45);
- GregorianCalendar cal2 = new GregorianCalendar(2004, 6, 9, 13, 45);
+ final GregorianCalendar cal1 = new GregorianCalendar(2004, 6, 9, 13, 45);
+ final GregorianCalendar cal2 = new GregorianCalendar(2004, 6, 9, 13, 45);
assertTrue(DateUtils.isSameDay(cal1, cal2));
cal2.add(Calendar.DAY_OF_YEAR, 1);
assertFalse(DateUtils.isSameDay(cal1, cal2));
@@ -189,7 +189,7 @@ public class DateUtilsTest {
try {
DateUtils.isSameDay((Calendar) null, (Calendar) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
//-----------------------------------------------------------------------
@@ -207,14 +207,14 @@ public class DateUtilsTest {
try {
DateUtils.isSameInstant((Date) null, (Date) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
//-----------------------------------------------------------------------
@Test
public void testIsSameInstant_Cal() {
- GregorianCalendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT+1"));
- GregorianCalendar cal2 = new GregorianCalendar(TimeZone.getTimeZone("GMT-1"));
+ final GregorianCalendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT+1"));
+ final GregorianCalendar cal2 = new GregorianCalendar(TimeZone.getTimeZone("GMT-1"));
cal1.set(2004, 6, 9, 13, 45, 0);
cal1.set(Calendar.MILLISECOND, 0);
cal2.set(2004, 6, 9, 13, 45, 0);
@@ -226,22 +226,22 @@ public class DateUtilsTest {
try {
DateUtils.isSameInstant((Calendar) null, (Calendar) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
//-----------------------------------------------------------------------
@Test
public void testIsSameLocalTime_Cal() {
- GregorianCalendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT+1"));
- GregorianCalendar cal2 = new GregorianCalendar(TimeZone.getTimeZone("GMT-1"));
+ final GregorianCalendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT+1"));
+ final GregorianCalendar cal2 = new GregorianCalendar(TimeZone.getTimeZone("GMT-1"));
cal1.set(2004, 6, 9, 13, 45, 0);
cal1.set(Calendar.MILLISECOND, 0);
cal2.set(2004, 6, 9, 13, 45, 0);
cal2.set(Calendar.MILLISECOND, 0);
assertTrue(DateUtils.isSameLocalTime(cal1, cal2));
- Calendar cal3 = Calendar.getInstance();
- Calendar cal4 = Calendar.getInstance();
+ final Calendar cal3 = Calendar.getInstance();
+ final Calendar cal4 = Calendar.getInstance();
cal3.set(2004, 6, 9, 4, 0, 0);
cal4.set(2004, 6, 9, 16, 0, 0);
cal3.set(Calendar.MILLISECOND, 0);
@@ -253,15 +253,15 @@ public class DateUtilsTest {
try {
DateUtils.isSameLocalTime((Calendar) null, (Calendar) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
}
//-----------------------------------------------------------------------
@Test
public void testParseDate() throws Exception {
- GregorianCalendar cal = new GregorianCalendar(1972, 11, 3);
+ final GregorianCalendar cal = new GregorianCalendar(1972, 11, 3);
String dateStr = "1972-12-03";
- String[] parsers = new String[] {"yyyy'-'DDD", "yyyy'-'MM'-'dd", "yyyyMMdd"};
+ final String[] parsers = new String[] {"yyyy'-'DDD", "yyyy'-'MM'-'dd", "yyyyMMdd"};
Date date = DateUtils.parseDate(dateStr, parsers);
assertEquals(cal.getTime(), date);
@@ -276,30 +276,30 @@ public class DateUtilsTest {
try {
DateUtils.parseDate("PURPLE", parsers);
fail();
- } catch (ParseException ex) {}
+ } catch (final ParseException ex) {}
try {
DateUtils.parseDate("197212AB", parsers);
fail();
- } catch (ParseException ex) {}
+ } catch (final ParseException ex) {}
try {
DateUtils.parseDate(null, parsers);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.parseDate(dateStr, (String[]) null);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.parseDate(dateStr, new String[0]);
fail();
- } catch (ParseException ex) {}
+ } catch (final ParseException ex) {}
}
// LANG-486
@Test
public void testParseDateWithLeniency() throws Exception {
- GregorianCalendar cal = new GregorianCalendar(1998, 6, 30);
- String dateStr = "02 942, 1996";
- String[] parsers = new String[] {"MM DDD, yyyy"};
+ final GregorianCalendar cal = new GregorianCalendar(1998, 6, 30);
+ final String dateStr = "02 942, 1996";
+ final String[] parsers = new String[] {"MM DDD, yyyy"};
Date date = DateUtils.parseDate(dateStr, parsers);
assertEquals(cal.getTime(), date);
@@ -307,13 +307,13 @@ public class DateUtilsTest {
try {
date = DateUtils.parseDateStrictly(dateStr, parsers);
fail();
- } catch (ParseException ex) {}
+ } catch (final ParseException ex) {}
}
//-----------------------------------------------------------------------
@Test
public void testAddYears() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addYears(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -333,7 +333,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddMonths() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addMonths(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -353,7 +353,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddWeeks() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addWeeks(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -373,7 +373,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddDays() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addDays(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -393,7 +393,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddHours() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addHours(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -413,7 +413,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddMinutes() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addMinutes(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -433,7 +433,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddSeconds() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addSeconds(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -453,7 +453,7 @@ public class DateUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testAddMilliseconds() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.addMilliseconds(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -473,7 +473,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetYears() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setYears(base, 2000);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -493,7 +493,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetMonths() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setMonths(base, 5);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -507,7 +507,7 @@ public class DateUtilsTest {
try {
result = DateUtils.setMonths(base, 12);
fail("DateUtils.setMonths did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
@@ -515,7 +515,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetDays() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setDays(base, 1);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -529,7 +529,7 @@ public class DateUtilsTest {
try {
result = DateUtils.setDays(base, 32);
fail("DateUtils.setDays did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
@@ -537,7 +537,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetHours() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setHours(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -551,7 +551,7 @@ public class DateUtilsTest {
try {
result = DateUtils.setHours(base, 24);
fail("DateUtils.setHours did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
@@ -559,7 +559,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetMinutes() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setMinutes(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -573,7 +573,7 @@ public class DateUtilsTest {
try {
result = DateUtils.setMinutes(base, 60);
fail("DateUtils.setMinutes did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
@@ -581,7 +581,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetSeconds() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setSeconds(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -595,7 +595,7 @@ public class DateUtilsTest {
try {
result = DateUtils.setSeconds(base, 60);
fail("DateUtils.setSeconds did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
@@ -603,7 +603,7 @@ public class DateUtilsTest {
// -----------------------------------------------------------------------
@Test
public void testSetMilliseconds() throws Exception {
- Date base = new Date(MILLIS_TEST);
+ final Date base = new Date(MILLIS_TEST);
Date result = DateUtils.setMilliseconds(base, 0);
assertNotSame(base, result);
assertDate(base, 2000, 6, 5, 4, 3, 2, 1);
@@ -617,14 +617,14 @@ public class DateUtilsTest {
try {
result = DateUtils.setMilliseconds(base, 1000);
fail("DateUtils.setMilliseconds did not throw an expected IllegalArguementException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
}
//-----------------------------------------------------------------------
private void assertDate(final Date date, final int year, final int month, final int day, final int hour, final int min, final int sec, final int mil) throws Exception {
- GregorianCalendar cal = new GregorianCalendar();
+ final GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
assertEquals(year, cal.get(Calendar.YEAR));
assertEquals(month, cal.get(Calendar.MONTH));
@@ -642,7 +642,7 @@ public class DateUtilsTest {
try {
DateUtils.toCalendar(null);
fail("Expected NullPointerException to be thrown");
- } catch(NullPointerException npe) {
+ } catch(final NullPointerException npe) {
// expected
}
}
@@ -779,23 +779,23 @@ public class DateUtilsTest {
try {
DateUtils.round((Date) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.round((Calendar) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.round((Object) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.round("", Calendar.SECOND);
fail();
- } catch (ClassCastException ex) {}
+ } catch (final ClassCastException ex) {}
try {
DateUtils.round(date1, -9999);
fail();
- } catch(IllegalArgumentException ex) {}
+ } catch(final IllegalArgumentException ex) {}
assertEquals("round ampm-1 failed",
dateTimeParser.parse("February 3, 2002 00:00:00.000"),
@@ -880,7 +880,7 @@ public class DateUtilsTest {
{
TimeZone.setDefault(defaultZone);
dateTimeParser.setTimeZone(defaultZone);
- Calendar testCalendar = Calendar.getInstance();
+ final Calendar testCalendar = Calendar.getInstance();
testCalendar.set(2007, 6, 2, 8, 8, 50);
Date date = testCalendar.getTime();
assertEquals("Minute Round Up Failed",
@@ -1075,19 +1075,19 @@ public class DateUtilsTest {
try {
DateUtils.truncate((Date) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.truncate((Calendar) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.truncate((Object) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.truncate("", Calendar.SECOND);
fail();
- } catch (ClassCastException ex) {}
+ } catch (final ClassCastException ex) {}
// Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=25560
// Test truncate across beginning of daylight saving time
@@ -1110,20 +1110,20 @@ public class DateUtilsTest {
dateTimeParser.setTimeZone(defaultZone);
// Bug 31395, large dates
- Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis
- GregorianCalendar endCal = new GregorianCalendar();
+ final Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis
+ final GregorianCalendar endCal = new GregorianCalendar();
endCal.setTime(endOfTime);
try {
DateUtils.truncate(endCal, Calendar.DATE);
fail();
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
endCal.set(Calendar.YEAR, 280000001);
try {
DateUtils.truncate(endCal, Calendar.DATE);
fail();
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
endCal.set(Calendar.YEAR, 280000000);
- Calendar cal = DateUtils.truncate(endCal, Calendar.DATE);
+ final Calendar cal = DateUtils.truncate(endCal, Calendar.DATE);
assertEquals(0, cal.get(Calendar.HOUR));
}
@@ -1140,17 +1140,17 @@ public class DateUtilsTest {
}
// Set TimeZone to Mountain Time
- TimeZone MST_MDT = TimeZone.getTimeZone("MST7MDT");
+ final TimeZone MST_MDT = TimeZone.getTimeZone("MST7MDT");
TimeZone.setDefault(MST_MDT);
- DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
+ final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
format.setTimeZone(MST_MDT);
- Date oct31_01MDT = new Date(1099206000000L);
+ final Date oct31_01MDT = new Date(1099206000000L);
- Date oct31MDT = new Date(oct31_01MDT.getTime() - 3600000L); // - 1 hour
- Date oct31_01_02MDT = new Date(oct31_01MDT.getTime() + 120000L); // + 2 minutes
- Date oct31_01_02_03MDT = new Date(oct31_01_02MDT.getTime() + 3000L); // + 3 seconds
- Date oct31_01_02_03_04MDT = new Date(oct31_01_02_03MDT.getTime() + 4L); // + 4 milliseconds
+ final Date oct31MDT = new Date(oct31_01MDT.getTime() - 3600000L); // - 1 hour
+ final Date oct31_01_02MDT = new Date(oct31_01MDT.getTime() + 120000L); // + 2 minutes
+ final Date oct31_01_02_03MDT = new Date(oct31_01_02MDT.getTime() + 3000L); // + 3 seconds
+ final Date oct31_01_02_03_04MDT = new Date(oct31_01_02_03MDT.getTime() + 4L); // + 4 milliseconds
assertEquals("Check 00:00:00.000", "2004-10-31 00:00:00.000 MDT", format.format(oct31MDT));
assertEquals("Check 01:00:00.000", "2004-10-31 01:00:00.000 MDT", format.format(oct31_01MDT));
@@ -1159,7 +1159,7 @@ public class DateUtilsTest {
assertEquals("Check 01:02:03.004", "2004-10-31 01:02:03.004 MDT", format.format(oct31_01_02_03_04MDT));
// ------- Demonstrate Problem -------
- Calendar gval = Calendar.getInstance();
+ final Calendar gval = Calendar.getInstance();
gval.setTime(new Date(oct31_01MDT.getTime()));
gval.set(Calendar.MINUTE, gval.get(Calendar.MINUTE)); // set minutes to the same value
assertEquals("Demonstrate Problem", gval.getTime().getTime(), oct31_01MDT.getTime() + 3600000L);
@@ -1210,9 +1210,9 @@ public class DateUtilsTest {
// http://issues.apache.org/jira/browse/LANG-530
@Test
public void testLang530() throws ParseException {
- Date d = new Date();
- String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(d);
- Date d2 = DateUtils.parseDate(isoDateStr, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() });
+ final Date d = new Date();
+ final String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(d);
+ final Date d2 = DateUtils.parseDate(isoDateStr, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() });
// the format loses milliseconds so have to reintroduce them
assertEquals("Date not equal to itself ISO formatted and parsed", d.getTime(), d2.getTime() + d.getTime() % 1000);
}
@@ -1369,23 +1369,23 @@ public class DateUtilsTest {
try {
DateUtils.ceiling((Date) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.ceiling((Calendar) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.ceiling((Object) null, Calendar.SECOND);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.ceiling("", Calendar.SECOND);
fail();
- } catch (ClassCastException ex) {}
+ } catch (final ClassCastException ex) {}
try {
DateUtils.ceiling(date1, -9999);
fail();
- } catch(IllegalArgumentException ex) {}
+ } catch(final IllegalArgumentException ex) {}
// Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=25560
@@ -1450,20 +1450,20 @@ public class DateUtilsTest {
dateTimeParser.setTimeZone(defaultZone);
// Bug 31395, large dates
- Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis
- GregorianCalendar endCal = new GregorianCalendar();
+ final Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis
+ final GregorianCalendar endCal = new GregorianCalendar();
endCal.setTime(endOfTime);
try {
DateUtils.ceiling(endCal, Calendar.DATE);
fail();
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
endCal.set(Calendar.YEAR, 280000001);
try {
DateUtils.ceiling(endCal, Calendar.DATE);
fail();
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
endCal.set(Calendar.YEAR, 280000000);
- Calendar cal = DateUtils.ceiling(endCal, Calendar.DATE);
+ final Calendar cal = DateUtils.ceiling(endCal, Calendar.DATE);
assertEquals(0, cal.get(Calendar.HOUR));
}
@@ -1474,23 +1474,23 @@ public class DateUtilsTest {
public void testIteratorEx() throws Exception {
try {
DateUtils.iterator(Calendar.getInstance(), -9999);
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.iterator((Date) null, DateUtils.RANGE_WEEK_CENTER);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.iterator((Calendar) null, DateUtils.RANGE_WEEK_CENTER);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.iterator((Object) null, DateUtils.RANGE_WEEK_CENTER);
fail();
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
DateUtils.iterator("", DateUtils.RANGE_WEEK_CENTER);
fail();
- } catch (ClassCastException ex) {}
+ } catch (final ClassCastException ex) {}
}
/**
@@ -1498,19 +1498,19 @@ public class DateUtilsTest {
*/
@Test
public void testWeekIterator() throws Exception {
- Calendar now = Calendar.getInstance();
+ final Calendar now = Calendar.getInstance();
for (int i = 0; i< 7; i++) {
- Calendar today = DateUtils.truncate(now, Calendar.DATE);
- Calendar sunday = DateUtils.truncate(now, Calendar.DATE);
+ final Calendar today = DateUtils.truncate(now, Calendar.DATE);
+ final Calendar sunday = DateUtils.truncate(now, Calendar.DATE);
sunday.add(Calendar.DATE, 1 - sunday.get(Calendar.DAY_OF_WEEK));
- Calendar monday = DateUtils.truncate(now, Calendar.DATE);
+ final Calendar monday = DateUtils.truncate(now, Calendar.DATE);
if (monday.get(Calendar.DAY_OF_WEEK) == 1) {
//This is sunday... roll back 6 days
monday.add(Calendar.DATE, -6);
} else {
monday.add(Calendar.DATE, 2 - monday.get(Calendar.DAY_OF_WEEK));
}
- Calendar centered = DateUtils.truncate(now, Calendar.DATE);
+ final Calendar centered = DateUtils.truncate(now, Calendar.DATE);
centered.add(Calendar.DATE, -3);
Iterator<?> it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_SUNDAY);
@@ -1529,12 +1529,12 @@ public class DateUtilsTest {
try {
it.next();
fail();
- } catch (NoSuchElementException ex) {}
+ } catch (final NoSuchElementException ex) {}
it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_CENTER);
it.next();
try {
it.remove();
- } catch( UnsupportedOperationException ex) {}
+ } catch( final UnsupportedOperationException ex) {}
now.add(Calendar.DATE,1);
}
@@ -1568,7 +1568,7 @@ public class DateUtilsTest {
@Test
public void testLANG799_EN_OK() throws ParseException {
- Locale dflt = Locale.getDefault();
+ final Locale dflt = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
try {
DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz");
@@ -1581,7 +1581,7 @@ public class DateUtilsTest {
// Parse German date with English Locale
@Test(expected=ParseException.class)
public void testLANG799_EN_FAIL() throws ParseException {
- Locale dflt = Locale.getDefault();
+ final Locale dflt = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
try {
DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz");
@@ -1592,7 +1592,7 @@ public class DateUtilsTest {
@Test
public void testLANG799_DE_OK() throws ParseException {
- Locale dflt = Locale.getDefault();
+ final Locale dflt = Locale.getDefault();
Locale.setDefault(Locale.GERMAN);
try {
DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz");
@@ -1605,7 +1605,7 @@ public class DateUtilsTest {
// Parse English date with German Locale
@Test(expected=ParseException.class)
public void testLANG799_DE_FAIL() throws ParseException {
- Locale dflt = Locale.getDefault();
+ final Locale dflt = Locale.getDefault();
Locale.setDefault(Locale.GERMAN);
try {
DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz");
@@ -1617,7 +1617,7 @@ public class DateUtilsTest {
// Parse German date with English Locale, specifying German Locale override
@Test
public void testLANG799_EN_WITH_DE_LOCALE() throws ParseException {
- Locale dflt = Locale.getDefault();
+ final Locale dflt = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
try {
DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", Locale.GERMAN, "EEE, dd MMM yyyy HH:mm:ss zzz");
@@ -1631,7 +1631,7 @@ public class DateUtilsTest {
* that are dates (no time), and exactly 1 day spaced after each other.
*/
private static void assertWeekIterator(final Iterator<?> it, final Calendar start) {
- Calendar end = (Calendar) start.clone();
+ final Calendar end = (Calendar) start.clone();
end.add(Calendar.DATE, 6);
assertWeekIterator(it, start, end);
@@ -1641,9 +1641,9 @@ public class DateUtilsTest {
* Convenience method for when working with Date objects
*/
private static void assertWeekIterator(final Iterator<?> it, final Date start, final Date end) {
- Calendar calStart = Calendar.getInstance();
+ final Calendar calStart = Calendar.getInstance();
calStart.setTime(start);
- Calendar calEnd = Calendar.getInstance();
+ final Calendar calEnd = Calendar.getInstance();
calEnd.setTime(end);
assertWeekIterator(it, calStart, calEnd);
diff --git a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
index 0e2efd9ce..c7f050b02 100644
--- a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
@@ -34,7 +34,7 @@ public class DurationFormatUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new DurationFormatUtils());
- Constructor<?>[] cons = DurationFormatUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = DurationFormatUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(DurationFormatUtils.class.getModifiers()));
@@ -132,10 +132,10 @@ public class DurationFormatUtilsTest {
*/
@Test
public void testFormatDurationPluralWords() {
- long oneSecond = 1000;
- long oneMinute = oneSecond * 60;
- long oneHour = oneMinute * 60;
- long oneDay = oneHour * 24;
+ final long oneSecond = 1000;
+ final long oneMinute = oneSecond * 60;
+ final long oneHour = oneMinute * 60;
+ final long oneDay = oneHour * 24;
String text = null;
text = DurationFormatUtils.formatDurationWords(oneSecond, false, false);
@@ -236,28 +236,28 @@ public class DurationFormatUtilsTest {
assertEquals("60000", DurationFormatUtils.formatDuration(duration, "S"));
assertEquals("01:00", DurationFormatUtils.formatDuration(duration, "mm:ss"));
- Calendar base = Calendar.getInstance();
+ final Calendar base = Calendar.getInstance();
base.set(2000, 0, 1, 0, 0, 0);
base.set(Calendar.MILLISECOND, 0);
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2003, 1, 1, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
duration = cal.getTime().getTime() - base.getTime().getTime(); // duration from 2000-01-01 to cal
// don't use 1970 in test as time zones were less reliable in 1970 than now
// remember that duration formatting ignores time zones, working on strict hour lengths
- int days = 366 + 365 + 365 + 31;
+ final int days = 366 + 365 + 365 + 31;
assertEquals("0 0 " + days, DurationFormatUtils.formatDuration(duration, "y M d"));
}
@Test
public void testFormatPeriodISO() {
- TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
- Calendar base = Calendar.getInstance(timeZone);
+ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
+ final Calendar base = Calendar.getInstance(timeZone);
base.set(1970, 0, 1, 0, 0, 0);
base.set(Calendar.MILLISECOND, 0);
- Calendar cal = Calendar.getInstance(timeZone);
+ final Calendar cal = Calendar.getInstance(timeZone);
cal.set(2002, 1, 23, 9, 11, 12);
cal.set(Calendar.MILLISECOND, 1);
String text;
@@ -280,10 +280,10 @@ public class DurationFormatUtilsTest {
@Test
public void testFormatPeriod() {
- Calendar cal1970 = Calendar.getInstance();
+ final Calendar cal1970 = Calendar.getInstance();
cal1970.set(1970, 0, 1, 0, 0, 0);
cal1970.set(Calendar.MILLISECOND, 0);
- long time1970 = cal1970.getTime().getTime();
+ final long time1970 = cal1970.getTime().getTime();
assertEquals("0", DurationFormatUtils.formatPeriod(time1970, time1970, "y"));
assertEquals("0", DurationFormatUtils.formatPeriod(time1970, time1970, "M"));
@@ -306,7 +306,7 @@ public class DurationFormatUtilsTest {
assertEquals("60000", DurationFormatUtils.formatPeriod(time1970, time, "S"));
assertEquals("01:00", DurationFormatUtils.formatPeriod(time1970, time, "mm:ss"));
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(1973, 6, 1, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
time = cal.getTime().getTime();
@@ -374,13 +374,13 @@ public class DurationFormatUtilsTest {
.lexx(DurationFormatUtils.ISO_EXTENDED_FORMAT_PATTERN));
// test failures in equals
- DurationFormatUtils.Token token = new DurationFormatUtils.Token(DurationFormatUtils.y, 4);
+ final DurationFormatUtils.Token token = new DurationFormatUtils.Token(DurationFormatUtils.y, 4);
assertFalse("Token equal to non-Token class. ", token.equals(new Object()));
assertFalse("Token equal to Token with wrong value class. ", token.equals(new DurationFormatUtils.Token(
new Object())));
assertFalse("Token equal to Token with different count. ", token.equals(new DurationFormatUtils.Token(
DurationFormatUtils.y, 1)));
- DurationFormatUtils.Token numToken = new DurationFormatUtils.Token(Integer.valueOf(1), 4);
+ final DurationFormatUtils.Token numToken = new DurationFormatUtils.Token(Integer.valueOf(1), 4);
assertTrue("Token with Number value not equal to itself. ", numToken.equals(numToken));
}
@@ -401,12 +401,12 @@ public class DurationFormatUtilsTest {
@Test
public void testLANG815() {
- Calendar calendar = Calendar.getInstance();
+ final Calendar calendar = Calendar.getInstance();
calendar.set(2012, 6, 30, 0, 0, 0);
- long startMillis = calendar.getTimeInMillis();
+ final long startMillis = calendar.getTimeInMillis();
calendar.set(2012, 8, 8);
- long endMillis = calendar.getTimeInMillis();
+ final long endMillis = calendar.getTimeInMillis();
assertEquals("1 9", DurationFormatUtils.formatPeriod(startMillis, endMillis, "M d"));
}
@@ -543,16 +543,16 @@ public class DurationFormatUtilsTest {
// }
private void bruteForce(final int year, final int month, final int day, final String format, final int calendarType) {
- String msg = year + "-" + month + "-" + day + " to ";
- Calendar c = Calendar.getInstance();
+ final String msg = year + "-" + month + "-" + day + " to ";
+ final Calendar c = Calendar.getInstance();
c.set(year, month, day, 0, 0, 0);
- int[] array1 = new int[] { year, month, day, 0, 0, 0 };
- int[] array2 = new int[] { year, month, day, 0, 0, 0 };
+ final int[] array1 = new int[] { year, month, day, 0, 0, 0 };
+ final int[] array2 = new int[] { year, month, day, 0, 0, 0 };
for (int i=0; i < FOUR_YEARS; i++) {
array2[0] = c.get(Calendar.YEAR);
array2[1] = c.get(Calendar.MONTH);
array2[2] = c.get(Calendar.DAY_OF_MONTH);
- String tmpMsg = msg + array2[0] + "-" + array2[1] + "-" + array2[2] + " at ";
+ final String tmpMsg = msg + array2[0] + "-" + array2[1] + "-" + array2[2] + " at ";
assertEqualDuration( tmpMsg + i, Integer.toString(i), array1, array2, format );
c.add(calendarType, 1);
}
@@ -562,15 +562,15 @@ public class DurationFormatUtilsTest {
assertEqualDuration(null, expected, start, end, format);
}
private void assertEqualDuration(final String message, final String expected, final int[] start, final int[] end, final String format) {
- Calendar cal1 = Calendar.getInstance();
+ final Calendar cal1 = Calendar.getInstance();
cal1.set(start[0], start[1], start[2], start[3], start[4], start[5]);
cal1.set(Calendar.MILLISECOND, 0);
- Calendar cal2 = Calendar.getInstance();
+ final Calendar cal2 = Calendar.getInstance();
cal2.set(end[0], end[1], end[2], end[3], end[4], end[5]);
cal2.set(Calendar.MILLISECOND, 0);
- long milli1 = cal1.getTime().getTime();
- long milli2 = cal2.getTime().getTime();
- String result = DurationFormatUtils.formatPeriod(milli1, milli2, format);
+ final long milli1 = cal1.getTime().getTime();
+ final long milli2 = cal2.getTime().getTime();
+ final String result = DurationFormatUtils.formatPeriod(milli1, milli2, format);
if (message == null) {
assertEquals(expected, result);
} else {
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
index b0867b915..eaf62febb 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
@@ -51,16 +51,16 @@ public class FastDateFormatTest {
*/
@Test
public void test_getInstance() {
- FastDateFormat format1 = FastDateFormat.getInstance();
- FastDateFormat format2 = FastDateFormat.getInstance();
+ final FastDateFormat format1 = FastDateFormat.getInstance();
+ final FastDateFormat format2 = FastDateFormat.getInstance();
assertSame(format1, format2);
}
@Test
public void test_getInstance_String() {
- FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy");
- FastDateFormat format2 = FastDateFormat.getInstance("MM-DD-yyyy");
- FastDateFormat format3 = FastDateFormat.getInstance("MM-DD-yyyy");
+ final FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy");
+ final FastDateFormat format2 = FastDateFormat.getInstance("MM-DD-yyyy");
+ final FastDateFormat format3 = FastDateFormat.getInstance("MM-DD-yyyy");
assertTrue(format1 != format2); // -- junit 3.8 version -- assertFalse(format1 == format2);
assertSame(format2, format3);
@@ -71,19 +71,19 @@ public class FastDateFormatTest {
@Test
public void test_getInstance_String_TimeZone() {
- Locale realDefaultLocale = Locale.getDefault();
- TimeZone realDefaultZone = TimeZone.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
+ final TimeZone realDefaultZone = TimeZone.getDefault();
try {
Locale.setDefault(Locale.US);
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
- FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy",
+ final FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy",
TimeZone.getTimeZone("Atlantic/Reykjavik"));
- FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy");
- FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy", TimeZone.getDefault());
- FastDateFormat format4 = FastDateFormat.getInstance("MM/DD/yyyy", TimeZone.getDefault());
- FastDateFormat format5 = FastDateFormat.getInstance("MM-DD-yyyy", TimeZone.getDefault());
- FastDateFormat format6 = FastDateFormat.getInstance("MM-DD-yyyy");
+ final FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy");
+ final FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy", TimeZone.getDefault());
+ final FastDateFormat format4 = FastDateFormat.getInstance("MM/DD/yyyy", TimeZone.getDefault());
+ final FastDateFormat format5 = FastDateFormat.getInstance("MM-DD-yyyy", TimeZone.getDefault());
+ final FastDateFormat format6 = FastDateFormat.getInstance("MM-DD-yyyy");
assertTrue(format1 != format2); // -- junit 3.8 version -- assertFalse(format1 == format2);
assertEquals(TimeZone.getTimeZone("Atlantic/Reykjavik"), format1.getTimeZone());
@@ -100,12 +100,12 @@ public class FastDateFormatTest {
@Test
public void test_getInstance_String_Locale() {
- Locale realDefaultLocale = Locale.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.US);
- FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
- FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy");
- FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
+ final FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
+ final FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy");
+ final FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
assertTrue(format1 != format2); // -- junit 3.8 version -- assertFalse(format1 == format2);
assertSame(format1, format3);
@@ -118,13 +118,13 @@ public class FastDateFormatTest {
@Test
public void test_changeDefault_Locale_DateInstance() {
- Locale realDefaultLocale = Locale.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.US);
- FastDateFormat format1 = FastDateFormat.getDateInstance(FastDateFormat.FULL, Locale.GERMANY);
- FastDateFormat format2 = FastDateFormat.getDateInstance(FastDateFormat.FULL);
+ final FastDateFormat format1 = FastDateFormat.getDateInstance(FastDateFormat.FULL, Locale.GERMANY);
+ final FastDateFormat format2 = FastDateFormat.getDateInstance(FastDateFormat.FULL);
Locale.setDefault(Locale.GERMANY);
- FastDateFormat format3 = FastDateFormat.getDateInstance(FastDateFormat.FULL);
+ final FastDateFormat format3 = FastDateFormat.getDateInstance(FastDateFormat.FULL);
assertSame(Locale.GERMANY, format1.getLocale());
assertSame(Locale.US, format2.getLocale());
@@ -139,13 +139,13 @@ public class FastDateFormatTest {
@Test
public void test_changeDefault_Locale_DateTimeInstance() {
- Locale realDefaultLocale = Locale.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.US);
- FastDateFormat format1 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL, Locale.GERMANY);
- FastDateFormat format2 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL);
+ final FastDateFormat format1 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL, Locale.GERMANY);
+ final FastDateFormat format2 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL);
Locale.setDefault(Locale.GERMANY);
- FastDateFormat format3 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL);
+ final FastDateFormat format3 = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL);
assertSame(Locale.GERMANY, format1.getLocale());
assertSame(Locale.US, format2.getLocale());
@@ -160,16 +160,16 @@ public class FastDateFormatTest {
@Test
public void test_getInstance_String_TimeZone_Locale() {
- Locale realDefaultLocale = Locale.getDefault();
- TimeZone realDefaultZone = TimeZone.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
+ final TimeZone realDefaultZone = TimeZone.getDefault();
try {
Locale.setDefault(Locale.US);
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
- FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy",
+ final FastDateFormat format1 = FastDateFormat.getInstance("MM/DD/yyyy",
TimeZone.getTimeZone("Atlantic/Reykjavik"), Locale.GERMANY);
- FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
- FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy",
+ final FastDateFormat format2 = FastDateFormat.getInstance("MM/DD/yyyy", Locale.GERMANY);
+ final FastDateFormat format3 = FastDateFormat.getInstance("MM/DD/yyyy",
TimeZone.getDefault(), Locale.GERMANY);
assertTrue(format1 != format2); // -- junit 3.8 version -- assertNotSame(format1, format2);
@@ -188,11 +188,11 @@ public class FastDateFormatTest {
@Test
public void testCheckDefaults() {
- FastDateFormat format = FastDateFormat.getInstance();
- FastDateFormat medium = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT);
+ final FastDateFormat format = FastDateFormat.getInstance();
+ final FastDateFormat medium = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT);
assertEquals(medium, format);
- SimpleDateFormat sdf = new SimpleDateFormat();
+ final SimpleDateFormat sdf = new SimpleDateFormat();
assertEquals(sdf.toPattern(), format.getPattern());
assertEquals(Locale.getDefault(), format.getLocale());
@@ -201,10 +201,10 @@ public class FastDateFormatTest {
@Test
public void testCheckDifferingStyles() {
- FastDateFormat shortShort = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT, Locale.US);
- FastDateFormat shortLong = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.LONG, Locale.US);
- FastDateFormat longShort = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.SHORT, Locale.US);
- FastDateFormat longLong = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.LONG, Locale.US);
+ final FastDateFormat shortShort = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT, Locale.US);
+ final FastDateFormat shortLong = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.LONG, Locale.US);
+ final FastDateFormat longShort = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.SHORT, Locale.US);
+ final FastDateFormat longLong = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.LONG, Locale.US);
assertFalse(shortShort.equals(shortLong));
assertFalse(shortShort.equals(longShort));
@@ -255,7 +255,7 @@ public class FastDateFormatTest {
final String pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS Z";
final FastDateFormat formatter= FastDateFormat.getInstance(pattern);
- long sdfTime= measureTime(formatter, new SimpleDateFormat(pattern) {
+ final long sdfTime= measureTime(formatter, new SimpleDateFormat(pattern) {
private static final long serialVersionUID = 1L; // because SimpleDateFormat is serializable
@Override
@@ -266,9 +266,9 @@ public class FastDateFormatTest {
}
});
- long fdfTime= measureTime(formatter, FastDateFormat.getInstance(pattern));
+ final long fdfTime= measureTime(formatter, FastDateFormat.getInstance(pattern));
- String times= ">>FastDateFormatTest: FastDateParser:"+fdfTime+" SimpleDateFormat:"+sdfTime;
+ final String times= ">>FastDateFormatTest: FastDateParser:"+fdfTime+" SimpleDateFormat:"+sdfTime;
System.out.println(times);
}
@@ -286,15 +286,15 @@ public class FastDateFormatTest {
public void run() {
for(int i= 0; i<NROUNDS; ++i) {
try {
- Date date= new Date();
- String formattedDate= formatter.format(date);
- long start= System.currentTimeMillis();
- Object pd= parser.parseObject(formattedDate);
+ final Date date= new Date();
+ final String formattedDate= formatter.format(date);
+ final long start= System.currentTimeMillis();
+ final Object pd= parser.parseObject(formattedDate);
totalElapsed.addAndGet(System.currentTimeMillis()-start);
if(!date.equals(pd)) {
failures.incrementAndGet();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
failures.incrementAndGet();
e.printStackTrace();
}
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
index 130503483..dc64eec1f 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
@@ -83,7 +83,7 @@ public class FastDateParserTest {
@Test
public void test_Equality_Hash() {
- DateParser[] parsers= {
+ final DateParser[] parsers= {
getInstance(yMdHmsSZ, NEW_YORK, Locale.US),
getInstance(DMY_DOT, NEW_YORK, Locale.US),
getInstance(YMD_SLASH, NEW_YORK, Locale.US),
@@ -93,25 +93,25 @@ public class FastDateParserTest {
getInstance(MDY_SLASH, REYKJAVIK, SWEDEN)
};
- Map<DateParser,Integer> map= new HashMap<DateParser,Integer>();
+ final Map<DateParser,Integer> map= new HashMap<DateParser,Integer>();
int i= 0;
- for(DateParser parser:parsers) {
+ for(final DateParser parser:parsers) {
map.put(parser, Integer.valueOf(i++));
}
i= 0;
- for(DateParser parser:parsers) {
+ for(final DateParser parser:parsers) {
assertEquals(i++, map.get(parser).intValue());
}
}
@Test
public void testParseZone() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 6, 10, 16, 33, 20);
- DateParser fdf = getInstance(yMdHmsSZ, NEW_YORK, Locale.US);
+ final DateParser fdf = getInstance(yMdHmsSZ, NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("2003-07-10T15:33:20.000 -0500"));
assertEquals(cal.getTime(), fdf.parse("2003-07-10T15:33:20.000 GMT-05:00"));
@@ -131,7 +131,7 @@ public class FastDateParserTest {
@Test
public void testParseLongShort() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10, 15, 33, 20);
cal.set(Calendar.MILLISECOND, 989);
@@ -142,7 +142,7 @@ public class FastDateParserTest {
assertEquals(cal.getTime(), fdf.parse("2003 AD February 0010 PM Monday 0015 0033 0020 0989 GMT-05:00"));
cal.set(Calendar.ERA, GregorianCalendar.BC);
- Date parse = fdf.parse("2003 BC February 0010 PM Saturday 0015 0033 0020 0989 GMT-05:00");
+ final Date parse = fdf.parse("2003 BC February 0010 PM Saturday 0015 0033 0020 0989 GMT-05:00");
assertEquals(cal.getTime(), parse);
fdf = getInstance("y G M d a E H m s S Z", NEW_YORK, Locale.US);
@@ -154,13 +154,13 @@ public class FastDateParserTest {
@Test
public void testAmPm() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
- DateParser h = getInstance("yyyy-MM-dd hh a mm:ss", NEW_YORK, Locale.US);
- DateParser K = getInstance("yyyy-MM-dd KK a mm:ss", NEW_YORK, Locale.US);
- DateParser k = getInstance("yyyy-MM-dd kk:mm:ss", NEW_YORK, Locale.US);
- DateParser H = getInstance("yyyy-MM-dd HH:mm:ss", NEW_YORK, Locale.US);
+ final DateParser h = getInstance("yyyy-MM-dd hh a mm:ss", NEW_YORK, Locale.US);
+ final DateParser K = getInstance("yyyy-MM-dd KK a mm:ss", NEW_YORK, Locale.US);
+ final DateParser k = getInstance("yyyy-MM-dd kk:mm:ss", NEW_YORK, Locale.US);
+ final DateParser H = getInstance("yyyy-MM-dd HH:mm:ss", NEW_YORK, Locale.US);
cal.set(2010, 7, 1, 0, 33, 20);
assertEquals(cal.getTime(), h.parse("2010-08-01 12 AM 33:20"));
@@ -190,10 +190,10 @@ public class FastDateParserTest {
@Test
// Check that all Locales can parse the formats we use
public void testParses() throws Exception {
- for(Locale locale : Locale.getAvailableLocales()) {
- for(TimeZone tz : new TimeZone[]{NEW_YORK, GMT}) {
- Calendar cal = Calendar.getInstance(tz);
- for(int year : new int[]{2003, 1940, 1868, 1867, 0, -1940}) {
+ for(final Locale locale : Locale.getAvailableLocales()) {
+ for(final TimeZone tz : new TimeZone[]{NEW_YORK, GMT}) {
+ final Calendar cal = Calendar.getInstance(tz);
+ for(final int year : new int[]{2003, 1940, 1868, 1867, 0, -1940}) {
// http://docs.oracle.com/javase/6/docs/technotes/guides/intl/calendar.doc.html
if (year < 1868 && locale.equals(FastDateParser.JAPANESE_IMPERIAL)) {
continue; // Japanese imperial calendar does not support eras before 1868
@@ -205,20 +205,20 @@ public class FastDateParserTest {
} else {
cal.set(year, 1, 10);
}
- Date in = cal.getTime();
- for(String format : new String[]{LONG_FORMAT, SHORT_FORMAT}) {
- SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
+ final Date in = cal.getTime();
+ for(final String format : new String[]{LONG_FORMAT, SHORT_FORMAT}) {
+ final SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
if (format.equals(SHORT_FORMAT)) {
if (year < 1930) {
sdf.set2DigitYearStart(cal.getTime());
}
}
- String fmt = sdf.format(in);
+ final String fmt = sdf.format(in);
try {
- Date out = sdf.parse(fmt);
+ final Date out = sdf.parse(fmt);
assertEquals(locale.toString()+" "+year+" "+ format+ " "+tz.getID(), in, out);
- } catch (ParseException pe) {
+ } catch (final ParseException pe) {
System.out.println(fmt+" "+locale.toString()+" "+year+" "+ format+ " "+tz.getID());
throw pe;
}
@@ -270,23 +270,23 @@ public class FastDateParserTest {
private void testLocales(final String format, final boolean eraBC) throws Exception {
- Calendar cal= Calendar.getInstance(GMT);
+ final Calendar cal= Calendar.getInstance(GMT);
cal.clear();
cal.set(2003, 1, 10);
if (eraBC) {
cal.set(Calendar.ERA, GregorianCalendar.BC);
}
- for(Locale locale : Locale.getAvailableLocales()) {
+ for(final Locale locale : Locale.getAvailableLocales()) {
// ja_JP_JP cannot handle dates before 1868 properly
if (eraBC && locale.equals(FastDateParser.JAPANESE_IMPERIAL)) {
continue;
}
- SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
- DateParser fdf = getInstance(format, locale);
+ final SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
+ final DateParser fdf = getInstance(format, locale);
try {
checkParse(locale, cal, sdf, fdf);
- } catch(ParseException ex) {
+ } catch(final ParseException ex) {
Assert.fail("Locale "+locale+ " failed with "+format+" era "+(eraBC?"BC":"AD")+"\n" + trimMessage(ex.toString()));
}
}
@@ -296,7 +296,7 @@ public class FastDateParserTest {
if (msg.length() < 100) {
return msg;
}
- int gmt = msg.indexOf("(GMT");
+ final int gmt = msg.indexOf("(GMT");
if (gmt > 0) {
return msg.substring(0, gmt+4)+"...)";
}
@@ -304,32 +304,32 @@ public class FastDateParserTest {
}
private void checkParse(final Locale locale, final Calendar cal, final SimpleDateFormat sdf, final DateParser fdf) throws ParseException {
- String formattedDate= sdf.format(cal.getTime());
- Date expectedTime = sdf.parse(formattedDate);
- Date actualTime = fdf.parse(formattedDate);
+ final String formattedDate= sdf.format(cal.getTime());
+ final Date expectedTime = sdf.parse(formattedDate);
+ final Date actualTime = fdf.parse(formattedDate);
assertEquals(locale.toString()+" "+formattedDate
+"\n",expectedTime, actualTime);
}
@Test
public void testParseNumerics() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10, 15, 33, 20);
cal.set(Calendar.MILLISECOND, 989);
- DateParser fdf = getInstance("yyyyMMddHHmmssSSS", NEW_YORK, Locale.US);
+ final DateParser fdf = getInstance("yyyyMMddHHmmssSSS", NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("20030210153320989"));
}
@Test
public void testQuotes() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10, 15, 33, 20);
cal.set(Calendar.MILLISECOND, 989);
- DateParser fdf = getInstance("''yyyyMMdd'A''B'HHmmssSSS''", NEW_YORK, Locale.US);
+ final DateParser fdf = getInstance("''yyyyMMdd'A''B'HHmmssSSS''", NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("'20030210A'B153320989'"));
}
@@ -364,13 +364,13 @@ public class FastDateParserTest {
Throwable s = null;
try {
- SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
+ final SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
sdf.setTimeZone(NEW_YORK);
dsdf = sdf.parse(date);
if (shouldFail) {
Assert.fail("Expected SDF failure, but got " + dsdf + " for ["+format+","+date+"]");
}
- } catch (Exception e) {
+ } catch (final Exception e) {
s = e;
if (!shouldFail) {
throw e;
@@ -381,12 +381,12 @@ public class FastDateParserTest {
}
try {
- DateParser fdp = getInstance(format, NEW_YORK, Locale.US);
+ final DateParser fdp = getInstance(format, NEW_YORK, Locale.US);
dfdp = fdp.parse(date);
if (shouldFail) {
Assert.fail("Expected FDF failure, but got " + dfdp + " for ["+format+","+date+"] using "+((FastDateParser)fdp).getParsePattern());
}
- } catch (Exception e) {
+ } catch (final Exception e) {
f = e;
if (!shouldFail) {
throw e;
@@ -405,11 +405,11 @@ public class FastDateParserTest {
@Test
public void testDayOf() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10);
- DateParser fdf = getInstance("W w F D y", NEW_YORK, Locale.US);
+ final DateParser fdf = getInstance("W w F D y", NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("3 7 2 41 03"));
}
@@ -420,7 +420,7 @@ public class FastDateParserTest {
@Test
public void testShortDateStyleWithLocales() throws ParseException {
DateParser fdf = getDateInstance(FastDateFormat.SHORT, Locale.US);
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(2004, 1, 3);
@@ -436,8 +436,8 @@ public class FastDateParserTest {
*/
@Test
public void testLowYearPadding() throws ParseException {
- DateParser parser = getInstance(YMD_SLASH);
- Calendar cal = Calendar.getInstance();
+ final DateParser parser = getInstance(YMD_SLASH);
+ final Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(1,0,1);
@@ -455,8 +455,8 @@ public class FastDateParserTest {
*/
@Test
public void testMilleniumBug() throws ParseException {
- DateParser parser = getInstance(DMY_DOT);
- Calendar cal = Calendar.getInstance();
+ final DateParser parser = getInstance(DMY_DOT);
+ final Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(1000,0,1);
@@ -466,10 +466,10 @@ public class FastDateParserTest {
@Test
public void testLang303() throws ParseException {
DateParser parser = getInstance(YMD_SLASH);
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2004, 11, 31);
- Date date = parser.parse("2004/11/31");
+ final Date date = parser.parse("2004/11/31");
parser = SerializationUtils.deserialize(SerializationUtils.serialize((Serializable) parser));
assertEquals(date, parser.parse("2004/11/31"));
@@ -477,9 +477,9 @@ public class FastDateParserTest {
@Test
public void testLang538() throws ParseException {
- DateParser parser = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", GMT);
+ final DateParser parser = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", GMT);
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-8"));
+ final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-8"));
cal.clear();
cal.set(2009, 9, 16, 8, 42, 16);
@@ -488,8 +488,8 @@ public class FastDateParserTest {
@Test
public void testEquals() {
- DateParser parser1= getInstance(YMD_SLASH);
- DateParser parser2= getInstance(YMD_SLASH);
+ final DateParser parser1= getInstance(YMD_SLASH);
+ final DateParser parser2= getInstance(YMD_SLASH);
assertEquals(parser1, parser2);
assertEquals(parser1.hashCode(), parser2.hashCode());
@@ -499,25 +499,25 @@ public class FastDateParserTest {
@Test
public void testToStringContainsName() {
- DateParser parser= getInstance(YMD_SLASH);
+ final DateParser parser= getInstance(YMD_SLASH);
assertTrue(parser.toString().startsWith("FastDate"));
}
@Test
public void testPatternMatches() {
- DateParser parser= getInstance(yMdHmsSZ);
+ final DateParser parser= getInstance(yMdHmsSZ);
assertEquals(yMdHmsSZ, parser.getPattern());
}
@Test
public void testLocaleMatches() {
- DateParser parser= getInstance(yMdHmsSZ, SWEDEN);
+ final DateParser parser= getInstance(yMdHmsSZ, SWEDEN);
assertEquals(SWEDEN, parser.getLocale());
}
@Test
public void testTimeZoneMatches() {
- DateParser parser= getInstance(yMdHmsSZ, REYKJAVIK);
+ final DateParser parser= getInstance(yMdHmsSZ, REYKJAVIK);
assertEquals(REYKJAVIK, parser.getTimeZone());
}
}
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java
index a6540caa9..ea0793ce3 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java
@@ -72,18 +72,18 @@ public class FastDatePrinterTest {
@Test
public void testFormat() {
- Locale realDefaultLocale = Locale.getDefault();
- TimeZone realDefaultZone = TimeZone.getDefault();
+ final Locale realDefaultLocale = Locale.getDefault();
+ final TimeZone realDefaultZone = TimeZone.getDefault();
try {
Locale.setDefault(Locale.US);
TimeZone.setDefault(NEW_YORK);
- GregorianCalendar cal1 = new GregorianCalendar(2003, 0, 10, 15, 33, 20);
- GregorianCalendar cal2 = new GregorianCalendar(2003, 6, 10, 9, 00, 00);
- Date date1 = cal1.getTime();
- Date date2 = cal2.getTime();
- long millis1 = date1.getTime();
- long millis2 = date2.getTime();
+ final GregorianCalendar cal1 = new GregorianCalendar(2003, 0, 10, 15, 33, 20);
+ final GregorianCalendar cal2 = new GregorianCalendar(2003, 6, 10, 9, 00, 00);
+ final Date date1 = cal1.getTime();
+ final Date date2 = cal2.getTime();
+ final long millis1 = date1.getTime();
+ final long millis2 = date2.getTime();
DatePrinter fdf = getInstance("yyyy-MM-dd'T'HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
@@ -113,7 +113,7 @@ public class FastDatePrinterTest {
assertEquals("-04:00", fdf.format(cal2));
assertEquals("-04:00", fdf.format(millis2));
- String pattern = "GGGG GGG GG G yyyy yyy yy y MMMM MMM MM M" +
+ final String pattern = "GGGG GGG GG G yyyy yyy yy y MMMM MMM MM M" +
" dddd ddd dd d DDDD DDD DD D EEEE EEE EE E aaaa aaa aa a zzzz zzz zz z";
fdf = getInstance(pattern);
sdf = new SimpleDateFormat(pattern);
@@ -131,9 +131,9 @@ public class FastDatePrinterTest {
*/
@Test
public void testShortDateStyleWithLocales() {
- Locale usLocale = Locale.US;
- Locale swedishLocale = new Locale("sv", "SE");
- Calendar cal = Calendar.getInstance();
+ final Locale usLocale = Locale.US;
+ final Locale swedishLocale = new Locale("sv", "SE");
+ final Calendar cal = Calendar.getInstance();
cal.set(2004, 1, 3);
DatePrinter fdf = getDateInstance(FastDateFormat.SHORT, usLocale);
assertEquals("2/3/04", fdf.format(cal));
@@ -148,8 +148,8 @@ public class FastDatePrinterTest {
*/
@Test
public void testLowYearPadding() {
- Calendar cal = Calendar.getInstance();
- DatePrinter format = getInstance(YYYY_MM_DD);
+ final Calendar cal = Calendar.getInstance();
+ final DatePrinter format = getInstance(YYYY_MM_DD);
cal.set(1,0,1);
assertEquals("0001/01/01", format.format(cal));
@@ -165,8 +165,8 @@ public class FastDatePrinterTest {
*/
@Test
public void testMilleniumBug() {
- Calendar cal = Calendar.getInstance();
- DatePrinter format = getInstance("dd.MM.yyyy");
+ final Calendar cal = Calendar.getInstance();
+ final DatePrinter format = getInstance("dd.MM.yyyy");
cal.set(1000,0,1);
assertEquals("01.01.1000", format.format(cal));
@@ -178,8 +178,8 @@ public class FastDatePrinterTest {
*/
@Test
public void testSimpleDate() {
- Calendar cal = Calendar.getInstance();
- DatePrinter format = getInstance(YYYY_MM_DD);
+ final Calendar cal = Calendar.getInstance();
+ final DatePrinter format = getInstance(YYYY_MM_DD);
cal.set(2004,11,31);
assertEquals("2004/12/31", format.format(cal));
@@ -191,11 +191,11 @@ public class FastDatePrinterTest {
@Test
public void testLang303() {
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2004, 11, 31);
DatePrinter format = getInstance(YYYY_MM_DD);
- String output = format.format(cal);
+ final String output = format.format(cal);
format = SerializationUtils.deserialize(SerializationUtils.serialize((Serializable) format));
assertEquals(output, format.format(cal));
@@ -205,32 +205,32 @@ public class FastDatePrinterTest {
public void testLang538() {
// more commonly constructed with: cal = new GregorianCalendar(2009, 9, 16, 8, 42, 16)
// for the unit test to work in any time zone, constructing with GMT-8 rather than default locale time zone
- GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT-8"));
+ final GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT-8"));
cal.clear();
cal.set(2009, 9, 16, 8, 42, 16);
- DatePrinter format = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("GMT"));
+ final DatePrinter format = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("GMT"));
assertEquals("dateTime", "2009-10-16T16:42:16.000Z", format.format(cal.getTime()));
assertEquals("dateTime", "2009-10-16T08:42:16.000Z", format.format(cal));
}
@Test
public void testLang645() {
- Locale locale = new Locale("sv", "SE");
+ final Locale locale = new Locale("sv", "SE");
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2010, 0, 1, 12, 0, 0);
- Date d = cal.getTime();
+ final Date d = cal.getTime();
- DatePrinter fdf = getInstance("EEEE', week 'ww", locale);
+ final DatePrinter fdf = getInstance("EEEE', week 'ww", locale);
assertEquals("fredag, week 53", fdf.format(d));
}
@Test
public void testEquals() {
- DatePrinter printer1= getInstance(YYYY_MM_DD);
- DatePrinter printer2= getInstance(YYYY_MM_DD);
+ final DatePrinter printer1= getInstance(YYYY_MM_DD);
+ final DatePrinter printer2= getInstance(YYYY_MM_DD);
assertEquals(printer1, printer2);
assertEquals(printer1.hashCode(), printer2.hashCode());
@@ -240,35 +240,35 @@ public class FastDatePrinterTest {
@Test
public void testToStringContainsName() {
- DatePrinter printer= getInstance(YYYY_MM_DD);
+ final DatePrinter printer= getInstance(YYYY_MM_DD);
assertTrue(printer.toString().startsWith("FastDate"));
}
@Test
public void testPatternMatches() {
- DatePrinter printer= getInstance(YYYY_MM_DD);
+ final DatePrinter printer= getInstance(YYYY_MM_DD);
assertEquals(YYYY_MM_DD, printer.getPattern());
}
@Test
public void testLocaleMatches() {
- DatePrinter printer= getInstance(YYYY_MM_DD, SWEDEN);
+ final DatePrinter printer= getInstance(YYYY_MM_DD, SWEDEN);
assertEquals(SWEDEN, printer.getLocale());
}
@Test
public void testTimeZoneMatches() {
- DatePrinter printer= getInstance(YYYY_MM_DD, NEW_YORK);
+ final DatePrinter printer= getInstance(YYYY_MM_DD, NEW_YORK);
assertEquals(NEW_YORK, printer.getTimeZone());
}
@Test
public void testCalendarTimezoneRespected() {
- String[] availableZones = TimeZone.getAvailableIDs();
- TimeZone currentZone = TimeZone.getDefault();
+ final String[] availableZones = TimeZone.getAvailableIDs();
+ final TimeZone currentZone = TimeZone.getDefault();
TimeZone anotherZone = null;
- for (String zone : availableZones) {
+ for (final String zone : availableZones) {
if (!zone.equals(currentZone.getID())) {
anotherZone = TimeZone.getTimeZone(zone);
}
@@ -279,10 +279,10 @@ public class FastDatePrinterTest {
final String pattern = "h:mma z";
final Calendar cal = Calendar.getInstance(anotherZone);
- SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+ final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
sdf.setTimeZone(anotherZone);
- String expectedValue = sdf.format(cal.getTime());
- String actualValue = FastDateFormat.getInstance(pattern).format(cal);
+ final String expectedValue = sdf.format(cal.getTime());
+ final String actualValue = FastDateFormat.getInstance(pattern).format(cal);
assertEquals(expectedValue, actualValue);
}
}
diff --git a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
index bec23b943..ad2857907 100644
--- a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
@@ -33,11 +33,11 @@ public class StopWatchTest {
//-----------------------------------------------------------------------
@Test
public void testStopWatchSimple(){
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.stop();
- long time = watch.getTime();
+ final long time = watch.getTime();
assertEquals(time, watch.getTime());
assertTrue(time >= 500);
@@ -49,28 +49,28 @@ public class StopWatchTest {
@Test
public void testStopWatchSimpleGet(){
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
assertEquals(0, watch.getTime());
assertEquals("0:00:00.000", watch.toString());
watch.start();
- try {Thread.sleep(500);} catch (InterruptedException ex) {}
+ try {Thread.sleep(500);} catch (final InterruptedException ex) {}
assertTrue(watch.getTime() < 2000);
}
@Test
public void testStopWatchSplit(){
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.split();
- long splitTime = watch.getSplitTime();
- String splitStr = watch.toSplitString();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ final long splitTime = watch.getSplitTime();
+ final String splitStr = watch.toSplitString();
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.unsplit();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.stop();
- long totalTime = watch.getTime();
+ final long totalTime = watch.getTime();
assertEquals("Formatted split string not the correct length",
splitStr.length(), 11);
@@ -82,16 +82,16 @@ public class StopWatchTest {
@Test
public void testStopWatchSuspend(){
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.suspend();
- long suspendTime = watch.getTime();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ final long suspendTime = watch.getTime();
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.resume();
- try {Thread.sleep(550);} catch (InterruptedException ex) {}
+ try {Thread.sleep(550);} catch (final InterruptedException ex) {}
watch.stop();
- long totalTime = watch.getTime();
+ final long totalTime = watch.getTime();
assertTrue(suspendTime >= 500);
assertTrue(suspendTime < 700);
@@ -101,60 +101,60 @@ public class StopWatchTest {
@Test
public void testLang315() {
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(200);} catch (InterruptedException ex) {}
+ try {Thread.sleep(200);} catch (final InterruptedException ex) {}
watch.suspend();
- long suspendTime = watch.getTime();
- try {Thread.sleep(200);} catch (InterruptedException ex) {}
+ final long suspendTime = watch.getTime();
+ try {Thread.sleep(200);} catch (final InterruptedException ex) {}
watch.stop();
- long totalTime = watch.getTime();
+ final long totalTime = watch.getTime();
assertTrue( suspendTime == totalTime );
}
// test bad states
@Test
public void testBadStates() {
- StopWatch watch = new StopWatch();
+ final StopWatch watch = new StopWatch();
try {
watch.stop();
fail("Calling stop on an unstarted StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.stop();
fail("Calling stop on an unstarted StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.suspend();
fail("Calling suspend on an unstarted StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.split();
fail("Calling split on a non-running StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.unsplit();
fail("Calling unsplit on an unsplit StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.resume();
fail("Calling resume on an unsuspended StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
@@ -163,28 +163,28 @@ public class StopWatchTest {
try {
watch.start();
fail("Calling start on a started StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.unsplit();
fail("Calling unsplit on an unsplit StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.getSplitTime();
fail("Calling getSplitTime on an unsplit StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
try {
watch.resume();
fail("Calling resume on an unsuspended StopWatch should throw an exception. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
@@ -193,33 +193,33 @@ public class StopWatchTest {
try {
watch.start();
fail("Calling start on a stopped StopWatch should throw an exception as it needs to be reset. ");
- } catch(IllegalStateException ise) {
+ } catch(final IllegalStateException ise) {
// expected
}
}
@Test
public void testGetStartTime() {
- long beforeStopWatch = System.currentTimeMillis();
- StopWatch watch = new StopWatch();
+ final long beforeStopWatch = System.currentTimeMillis();
+ final StopWatch watch = new StopWatch();
try {
watch.getStartTime();
fail("Calling getStartTime on an unstarted StopWatch should throw an exception");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
// expected
}
watch.start();
try {
watch.getStartTime();
Assert.assertTrue(watch.getStartTime() >= beforeStopWatch);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
fail("Start time should be available: " + ex.getMessage());
}
watch.reset();
try {
watch.getStartTime();
fail("Calling getStartTime on a reset, but unstarted StopWatch should throw an exception");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
// expected
}
}
diff --git a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
index 42ba48880..01661042e 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
@@ -36,12 +36,12 @@ public class ImmutablePairTest {
@Test
public void testBasic() throws Exception {
- ImmutablePair<Integer, String> pair = new ImmutablePair<Integer, String>(0, "foo");
+ final ImmutablePair<Integer, String> pair = new ImmutablePair<Integer, String>(0, "foo");
assertEquals(0, pair.left.intValue());
assertEquals(0, pair.getLeft().intValue());
assertEquals("foo", pair.right);
assertEquals("foo", pair.getRight());
- ImmutablePair<Object, String> pair2 = new ImmutablePair<Object, String>(null, "bar");
+ final ImmutablePair<Object, String> pair2 = new ImmutablePair<Object, String>(null, "bar");
assertNull(pair2.left);
assertNull(pair2.getLeft());
assertEquals("bar", pair2.right);
@@ -50,12 +50,12 @@ public class ImmutablePairTest {
@Test
public void testPairOf() throws Exception {
- ImmutablePair<Integer, String> pair = ImmutablePair.of(0, "foo");
+ final ImmutablePair<Integer, String> pair = ImmutablePair.of(0, "foo");
assertEquals(0, pair.left.intValue());
assertEquals(0, pair.getLeft().intValue());
assertEquals("foo", pair.right);
assertEquals("foo", pair.getRight());
- ImmutablePair<Object, String> pair2 = ImmutablePair.of(null, "bar");
+ final ImmutablePair<Object, String> pair2 = ImmutablePair.of(null, "bar");
assertNull(pair2.left);
assertNull(pair2.getLeft());
assertEquals("bar", pair2.right);
@@ -68,7 +68,7 @@ public class ImmutablePairTest {
assertFalse(ImmutablePair.of("foo", 0).equals(ImmutablePair.of("foo", null)));
assertFalse(ImmutablePair.of("foo", "bar").equals(ImmutablePair.of("xyz", "bar")));
- ImmutablePair<String, String> p = ImmutablePair.of("foo", "bar");
+ final ImmutablePair<String, String> p = ImmutablePair.of("foo", "bar");
assertTrue(p.equals(p));
assertFalse(p.equals(new Object()));
}
@@ -89,11 +89,11 @@ public class ImmutablePairTest {
@Test
@SuppressWarnings("unchecked")
public void testSerialization() throws Exception {
- ImmutablePair<Integer, String> origPair = ImmutablePair.of(0, "foo");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
+ final ImmutablePair<Integer, String> origPair = ImmutablePair.of(0, "foo");
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(origPair);
- ImmutablePair<Integer, String> deserializedPair = (ImmutablePair<Integer, String>) new ObjectInputStream(
+ final ImmutablePair<Integer, String> deserializedPair = (ImmutablePair<Integer, String>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
assertEquals(origPair, deserializedPair);
assertEquals(origPair.hashCode(), deserializedPair.hashCode());
diff --git a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
index 8d9d8452a..a6e7cf330 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
@@ -36,14 +36,14 @@ public class ImmutableTripleTest {
@Test
public void testBasic() throws Exception {
- ImmutableTriple<Integer, String, Boolean> triple = new ImmutableTriple<Integer, String, Boolean>(0, "foo", Boolean.TRUE);
+ final ImmutableTriple<Integer, String, Boolean> triple = new ImmutableTriple<Integer, String, Boolean>(0, "foo", Boolean.TRUE);
assertEquals(0, triple.left.intValue());
assertEquals(0, triple.getLeft().intValue());
assertEquals("foo", triple.middle);
assertEquals("foo", triple.getMiddle());
assertEquals(Boolean.TRUE, triple.right);
assertEquals(Boolean.TRUE, triple.getRight());
- ImmutableTriple<Object, String, Integer> triple2 = new ImmutableTriple<Object, String, Integer>(null, "bar", 42);
+ final ImmutableTriple<Object, String, Integer> triple2 = new ImmutableTriple<Object, String, Integer>(null, "bar", 42);
assertNull(triple2.left);
assertNull(triple2.getLeft());
assertEquals("bar", triple2.middle);
@@ -54,14 +54,14 @@ public class ImmutableTripleTest {
@Test
public void testTripleOf() throws Exception {
- ImmutableTriple<Integer, String, Boolean> triple = ImmutableTriple.of(0, "foo", Boolean.FALSE);
+ final ImmutableTriple<Integer, String, Boolean> triple = ImmutableTriple.of(0, "foo", Boolean.FALSE);
assertEquals(0, triple.left.intValue());
assertEquals(0, triple.getLeft().intValue());
assertEquals("foo", triple.middle);
assertEquals("foo", triple.getMiddle());
assertEquals(Boolean.FALSE, triple.right);
assertEquals(Boolean.FALSE, triple.getRight());
- ImmutableTriple<Object, String, Boolean> triple2 = ImmutableTriple.of(null, "bar", Boolean.TRUE);
+ final ImmutableTriple<Object, String, Boolean> triple2 = ImmutableTriple.of(null, "bar", Boolean.TRUE);
assertNull(triple2.left);
assertNull(triple2.getLeft());
assertEquals("bar", triple2.middle);
@@ -76,7 +76,7 @@ public class ImmutableTripleTest {
assertFalse(ImmutableTriple.of("foo", 0, Boolean.TRUE).equals(ImmutableTriple.of("foo", null, null)));
assertFalse(ImmutableTriple.of("foo", "bar", "baz").equals(ImmutableTriple.of("xyz", "bar", "blo")));
- ImmutableTriple<String, String, String> p = ImmutableTriple.of("foo", "bar", "baz");
+ final ImmutableTriple<String, String, String> p = ImmutableTriple.of("foo", "bar", "baz");
assertTrue(p.equals(p));
assertFalse(p.equals(new Object()));
}
@@ -100,11 +100,11 @@ public class ImmutableTripleTest {
@Test
@SuppressWarnings("unchecked")
public void testSerialization() throws Exception {
- ImmutableTriple<Integer, String, Boolean> origTriple = ImmutableTriple.of(0, "foo", Boolean.TRUE);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
+ final ImmutableTriple<Integer, String, Boolean> origTriple = ImmutableTriple.of(0, "foo", Boolean.TRUE);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(origTriple);
- ImmutableTriple<Integer, String, Boolean> deserializedTriple = (ImmutableTriple<Integer, String, Boolean>) new ObjectInputStream(
+ final ImmutableTriple<Integer, String, Boolean> deserializedTriple = (ImmutableTriple<Integer, String, Boolean>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
assertEquals(origTriple, deserializedTriple);
assertEquals(origTriple.hashCode(), deserializedTriple.hashCode());
diff --git a/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java b/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java
index ef1f72c15..0b64004a5 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java
@@ -36,24 +36,24 @@ public class MutablePairTest {
@Test
public void testBasic() throws Exception {
- MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo");
+ final MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo");
assertEquals(0, pair.getLeft().intValue());
assertEquals("foo", pair.getRight());
- MutablePair<Object, String> pair2 = new MutablePair<Object, String>(null, "bar");
+ final MutablePair<Object, String> pair2 = new MutablePair<Object, String>(null, "bar");
assertNull(pair2.getLeft());
assertEquals("bar", pair2.getRight());
}
@Test
public void testDefault() throws Exception {
- MutablePair<Integer, String> pair = new MutablePair<Integer, String>();
+ final MutablePair<Integer, String> pair = new MutablePair<Integer, String>();
assertNull(pair.getLeft());
assertNull(pair.getRight());
}
@Test
public void testMutate() throws Exception {
- MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo");
+ final MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo");
pair.setLeft(42);
pair.setRight("bar");
assertEquals(42, pair.getLeft().intValue());
@@ -62,10 +62,10 @@ public class MutablePairTest {
@Test
public void testPairOf() throws Exception {
- MutablePair<Integer, String> pair = MutablePair.of(0, "foo");
+ final MutablePair<Integer, String> pair = MutablePair.of(0, "foo");
assertEquals(0, pair.getLeft().intValue());
assertEquals("foo", pair.getRight());
- MutablePair<Object, String> pair2 = MutablePair.of(null, "bar");
+ final MutablePair<Object, String> pair2 = MutablePair.of(null, "bar");
assertNull(pair2.getLeft());
assertEquals("bar", pair2.getRight());
}
@@ -76,7 +76,7 @@ public class MutablePairTest {
assertFalse(MutablePair.of("foo", 0).equals(MutablePair.of("foo", null)));
assertFalse(MutablePair.of("foo", "bar").equals(MutablePair.of("xyz", "bar")));
- MutablePair<String, String> p = MutablePair.of("foo", "bar");
+ final MutablePair<String, String> p = MutablePair.of("foo", "bar");
assertTrue(p.equals(p));
assertFalse(p.equals(new Object()));
}
@@ -97,11 +97,11 @@ public class MutablePairTest {
@Test
@SuppressWarnings("unchecked")
public void testSerialization() throws Exception {
- MutablePair<Integer, String> origPair = MutablePair.of(0, "foo");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
+ final MutablePair<Integer, String> origPair = MutablePair.of(0, "foo");
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(origPair);
- MutablePair<Integer, String> deserializedPair = (MutablePair<Integer, String>) new ObjectInputStream(
+ final MutablePair<Integer, String> deserializedPair = (MutablePair<Integer, String>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
assertEquals(origPair, deserializedPair);
assertEquals(origPair.hashCode(), deserializedPair.hashCode());
diff --git a/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java
index 2106f37cb..210a95549 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java
@@ -36,11 +36,11 @@ public class MutableTripleTest {
@Test
public void testBasic() throws Exception {
- MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(0, "foo", Boolean.FALSE);
+ final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(0, "foo", Boolean.FALSE);
assertEquals(0, triple.getLeft().intValue());
assertEquals("foo", triple.getMiddle());
assertEquals(Boolean.FALSE, triple.getRight());
- MutableTriple<Object, String, String> triple2 = new MutableTriple<Object, String, String>(null, "bar", "hello");
+ final MutableTriple<Object, String, String> triple2 = new MutableTriple<Object, String, String>(null, "bar", "hello");
assertNull(triple2.getLeft());
assertEquals("bar", triple2.getMiddle());
assertEquals("hello", triple2.getRight());
@@ -48,7 +48,7 @@ public class MutableTripleTest {
@Test
public void testDefault() throws Exception {
- MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>();
+ final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>();
assertNull(triple.getLeft());
assertNull(triple.getMiddle());
assertNull(triple.getRight());
@@ -56,7 +56,7 @@ public class MutableTripleTest {
@Test
public void testMutate() throws Exception {
- MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(0, "foo", Boolean.TRUE);
+ final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(0, "foo", Boolean.TRUE);
triple.setLeft(42);
triple.setMiddle("bar");
triple.setRight(Boolean.FALSE);
@@ -67,11 +67,11 @@ public class MutableTripleTest {
@Test
public void testTripleOf() throws Exception {
- MutableTriple<Integer, String, Boolean> triple = MutableTriple.of(0, "foo", Boolean.TRUE);
+ final MutableTriple<Integer, String, Boolean> triple = MutableTriple.of(0, "foo", Boolean.TRUE);
assertEquals(0, triple.getLeft().intValue());
assertEquals("foo", triple.getMiddle());
assertEquals(Boolean.TRUE, triple.getRight());
- MutableTriple<Object, String, String> triple2 = MutableTriple.of(null, "bar", "hello");
+ final MutableTriple<Object, String, String> triple2 = MutableTriple.of(null, "bar", "hello");
assertNull(triple2.getLeft());
assertEquals("bar", triple2.getMiddle());
assertEquals("hello", triple2.getRight());
@@ -84,7 +84,7 @@ public class MutableTripleTest {
assertFalse(MutableTriple.of("foo", "bar", "baz").equals(MutableTriple.of("xyz", "bar", "baz")));
assertFalse(MutableTriple.of("foo", "bar", "baz").equals(MutableTriple.of("foo", "bar", "blo")));
- MutableTriple<String, String, String> p = MutableTriple.of("foo", "bar", "baz");
+ final MutableTriple<String, String, String> p = MutableTriple.of("foo", "bar", "baz");
assertTrue(p.equals(p));
assertFalse(p.equals(new Object()));
}
@@ -108,11 +108,11 @@ public class MutableTripleTest {
@Test
@SuppressWarnings("unchecked")
public void testSerialization() throws Exception {
- MutableTriple<Integer, String, Boolean> origTriple = MutableTriple.of(0, "foo", Boolean.TRUE);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
+ final MutableTriple<Integer, String, Boolean> origTriple = MutableTriple.of(0, "foo", Boolean.TRUE);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(origTriple);
- MutableTriple<Integer, String, Boolean> deserializedTriple = (MutableTriple<Integer, String, Boolean>) new ObjectInputStream(
+ final MutableTriple<Integer, String, Boolean> deserializedTriple = (MutableTriple<Integer, String, Boolean>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
assertEquals(origTriple, deserializedTriple);
assertEquals(origTriple.hashCode(), deserializedTriple.hashCode());
diff --git a/src/test/java/org/apache/commons/lang3/tuple/PairTest.java b/src/test/java/org/apache/commons/lang3/tuple/PairTest.java
index 9054d6110..365f2abe3 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/PairTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/PairTest.java
@@ -37,11 +37,11 @@ public class PairTest {
@Test
public void testPairOf() throws Exception {
- Pair<Integer, String> pair = Pair.of(0, "foo");
+ final Pair<Integer, String> pair = Pair.of(0, "foo");
assertTrue(pair instanceof ImmutablePair<?, ?>);
assertEquals(0, ((ImmutablePair<Integer, String>) pair).left.intValue());
assertEquals("foo", ((ImmutablePair<Integer, String>) pair).right);
- Pair<Object, String> pair2 = Pair.of(null, "bar");
+ final Pair<Object, String> pair2 = Pair.of(null, "bar");
assertTrue(pair2 instanceof ImmutablePair<?, ?>);
assertNull(((ImmutablePair<Object, String>) pair2).left);
assertEquals("bar", ((ImmutablePair<Object, String>) pair2).right);
@@ -49,11 +49,11 @@ public class PairTest {
@Test
public void testCompatibilityBetweenPairs() throws Exception {
- Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
- Pair<Integer, String> pair2 = MutablePair.of(0, "foo");
+ final Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
+ final Pair<Integer, String> pair2 = MutablePair.of(0, "foo");
assertEquals(pair, pair2);
assertEquals(pair.hashCode(), pair2.hashCode());
- HashSet<Pair<Integer, String>> set = new HashSet<Pair<Integer, String>>();
+ final HashSet<Pair<Integer, String>> set = new HashSet<Pair<Integer, String>>();
set.add(pair);
assertTrue(set.contains(pair2));
@@ -64,18 +64,18 @@ public class PairTest {
@Test
public void testMapEntry() throws Exception {
- Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
- HashMap<Integer, String> map = new HashMap<Integer, String>();
+ final Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
+ final HashMap<Integer, String> map = new HashMap<Integer, String>();
map.put(0, "foo");
- Entry<Integer, String> entry = map.entrySet().iterator().next();
+ final Entry<Integer, String> entry = map.entrySet().iterator().next();
assertEquals(pair, entry);
assertEquals(pair.hashCode(), entry.hashCode());
}
@Test
public void testComparable1() throws Exception {
- Pair<String, String> pair1 = Pair.of("A", "D");
- Pair<String, String> pair2 = Pair.of("B", "C");
+ final Pair<String, String> pair1 = Pair.of("A", "D");
+ final Pair<String, String> pair2 = Pair.of("B", "C");
assertTrue(pair1.compareTo(pair1) == 0);
assertTrue(pair1.compareTo(pair2) < 0);
assertTrue(pair2.compareTo(pair2) == 0);
@@ -84,8 +84,8 @@ public class PairTest {
@Test
public void testComparable2() throws Exception {
- Pair<String, String> pair1 = Pair.of("A", "C");
- Pair<String, String> pair2 = Pair.of("A", "D");
+ final Pair<String, String> pair1 = Pair.of("A", "C");
+ final Pair<String, String> pair2 = Pair.of("A", "D");
assertTrue(pair1.compareTo(pair1) == 0);
assertTrue(pair1.compareTo(pair2) < 0);
assertTrue(pair2.compareTo(pair2) == 0);
@@ -94,27 +94,27 @@ public class PairTest {
@Test
public void testToString() throws Exception {
- Pair<String, String> pair = Pair.of("Key", "Value");
+ final Pair<String, String> pair = Pair.of("Key", "Value");
assertEquals("(Key,Value)", pair.toString());
}
@Test
public void testToStringCustom() throws Exception {
- Calendar date = Calendar.getInstance();
+ final Calendar date = Calendar.getInstance();
date.set(2011, Calendar.APRIL, 25);
- Pair<String, Calendar> pair = Pair.of("DOB", date);
+ final Pair<String, Calendar> pair = Pair.of("DOB", date);
assertEquals("Test created on " + "04-25-2011", pair.toString("Test created on %2$tm-%2$td-%2$tY"));
}
@Test
public void testFormattable_simple() throws Exception {
- Pair<String, String> pair = Pair.of("Key", "Value");
+ final Pair<String, String> pair = Pair.of("Key", "Value");
assertEquals("(Key,Value)", String.format("%1$s", pair));
}
@Test
public void testFormattable_padded() throws Exception {
- Pair<String, String> pair = Pair.of("Key", "Value");
+ final Pair<String, String> pair = Pair.of("Key", "Value");
assertEquals(" (Key,Value)", String.format("%1$20s", pair));
}
diff --git a/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java
index 630776f75..d9cff33cd 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java
@@ -34,12 +34,12 @@ public class TripleTest {
@Test
public void testTripleOf() throws Exception {
- Triple<Integer, String, Boolean> triple = Triple.of(0, "foo", Boolean.TRUE);
+ final Triple<Integer, String, Boolean> triple = Triple.of(0, "foo", Boolean.TRUE);
assertTrue(triple instanceof ImmutableTriple<?, ?, ?>);
assertEquals(0, ((ImmutableTriple<Integer, String, Boolean>) triple).left.intValue());
assertEquals("foo", ((ImmutableTriple<Integer, String, Boolean>) triple).middle);
assertEquals(Boolean.TRUE, ((ImmutableTriple<Integer, String, Boolean>) triple).right);
- Triple<Object, String, Long> triple2 = Triple.of(null, "bar", Long.valueOf(200L));
+ final Triple<Object, String, Long> triple2 = Triple.of(null, "bar", Long.valueOf(200L));
assertTrue(triple2 instanceof ImmutableTriple<?, ?, ?>);
assertNull(((ImmutableTriple<Object, String, Long>) triple2).left);
assertEquals("bar", ((ImmutableTriple<Object, String, Long>) triple2).middle);
@@ -48,19 +48,19 @@ public class TripleTest {
@Test
public void testCompatibilityBetweenTriples() throws Exception {
- Triple<Integer, String, Boolean> triple = ImmutableTriple.of(0, "foo", Boolean.TRUE);
- Triple<Integer, String, Boolean> triple2 = MutableTriple.of(0, "foo", Boolean.TRUE);
+ final Triple<Integer, String, Boolean> triple = ImmutableTriple.of(0, "foo", Boolean.TRUE);
+ final Triple<Integer, String, Boolean> triple2 = MutableTriple.of(0, "foo", Boolean.TRUE);
assertEquals(triple, triple2);
assertEquals(triple.hashCode(), triple2.hashCode());
- HashSet<Triple<Integer, String, Boolean>> set = new HashSet<Triple<Integer, String, Boolean>>();
+ final HashSet<Triple<Integer, String, Boolean>> set = new HashSet<Triple<Integer, String, Boolean>>();
set.add(triple);
assertTrue(set.contains(triple2));
}
@Test
public void testComparable1() throws Exception {
- Triple<String, String, String> triple1 = Triple.of("A", "D", "A");
- Triple<String, String, String> triple2 = Triple.of("B", "C", "A");
+ final Triple<String, String, String> triple1 = Triple.of("A", "D", "A");
+ final Triple<String, String, String> triple2 = Triple.of("B", "C", "A");
assertTrue(triple1.compareTo(triple1) == 0);
assertTrue(triple1.compareTo(triple2) < 0);
assertTrue(triple2.compareTo(triple2) == 0);
@@ -69,8 +69,8 @@ public class TripleTest {
@Test
public void testComparable2() throws Exception {
- Triple<String, String, String> triple1 = Triple.of("A", "C", "B");
- Triple<String, String, String> triple2 = Triple.of("A", "D", "B");
+ final Triple<String, String, String> triple1 = Triple.of("A", "C", "B");
+ final Triple<String, String, String> triple2 = Triple.of("A", "D", "B");
assertTrue(triple1.compareTo(triple1) == 0);
assertTrue(triple1.compareTo(triple2) < 0);
assertTrue(triple2.compareTo(triple2) == 0);
@@ -79,8 +79,8 @@ public class TripleTest {
@Test
public void testComparable3() throws Exception {
- Triple<String, String, String> triple1 = Triple.of("A", "A", "D");
- Triple<String, String, String> triple2 = Triple.of("A", "B", "C");
+ final Triple<String, String, String> triple1 = Triple.of("A", "A", "D");
+ final Triple<String, String, String> triple2 = Triple.of("A", "B", "C");
assertTrue(triple1.compareTo(triple1) == 0);
assertTrue(triple1.compareTo(triple2) < 0);
assertTrue(triple2.compareTo(triple2) == 0);
@@ -89,8 +89,8 @@ public class TripleTest {
@Test
public void testComparable4() throws Exception {
- Triple<String, String, String> triple1 = Triple.of("B", "A", "C");
- Triple<String, String, String> triple2 = Triple.of("B", "A", "D");
+ final Triple<String, String, String> triple1 = Triple.of("B", "A", "C");
+ final Triple<String, String, String> triple2 = Triple.of("B", "A", "D");
assertTrue(triple1.compareTo(triple1) == 0);
assertTrue(triple1.compareTo(triple2) < 0);
assertTrue(triple2.compareTo(triple2) == 0);
@@ -99,27 +99,27 @@ public class TripleTest {
@Test
public void testToString() throws Exception {
- Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
+ final Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
assertEquals("(Key,Something,Value)", triple.toString());
}
@Test
public void testToStringCustom() throws Exception {
- Calendar date = Calendar.getInstance();
+ final Calendar date = Calendar.getInstance();
date.set(2011, Calendar.APRIL, 25);
- Triple<String, String, Calendar> triple = Triple.of("DOB", "string", date);
+ final Triple<String, String, Calendar> triple = Triple.of("DOB", "string", date);
assertEquals("Test created on " + "04-25-2011", triple.toString("Test created on %3$tm-%3$td-%3$tY"));
}
@Test
public void testFormattable_simple() throws Exception {
- Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
+ final Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
assertEquals("(Key,Something,Value)", String.format("%1$s", triple));
}
@Test
public void testFormattable_padded() throws Exception {
- Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
+ final Triple<String, String, String> triple = Triple.of("Key", "Something", "Value");
assertEquals(" (Key,Something,Value)", String.format("%1$30s", triple));
}