diff options
author | Benedikt Ritter <britter@apache.org> | 2017-06-06 15:12:06 +0200 |
---|---|---|
committer | Benedikt Ritter <britter@apache.org> | 2017-06-06 15:12:06 +0200 |
commit | 1da8ccdbfe2faa3e6801fe44eaf3c336aab48bec (patch) | |
tree | 04fad3070f3da1b65720dfb558d826e2c39d4d99 /src/test/java/org/apache/commons/lang3 | |
parent | fa91c1b28647bd4217b0c325249aff9638fbeb6a (diff) | |
download | apache-commons-lang-1da8ccdbfe2faa3e6801fe44eaf3c336aab48bec.tar.gz |
Make sure lines in files don't have trailing white spaces and remove all trailing white spaces
Diffstat (limited to 'src/test/java/org/apache/commons/lang3')
116 files changed, 2321 insertions, 2321 deletions
diff --git a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java index ee4a3618f..390b5f7e3 100644 --- a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java @@ -350,7 +350,7 @@ public class AnnotationUtilsTest { NestAnnotation nest(); NestAnnotation[] nests(); } - + @Retention(RUNTIME) public @interface NestAnnotation { String string(); diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java index 28c6bbd14..dbbcdfd59 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java @@ -224,7 +224,7 @@ public class ArrayUtilsAddTest { assertTrue(Arrays.equals(new Float[]{Float.valueOf(3)}, newArray)); assertEquals(Float.class, newArray.getClass().getComponentType()); } - + @Test public void testLANG571(){ final String[] stringArray=null; diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java index 86b091613..80ff24d10 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java @@ -28,34 +28,34 @@ import org.junit.Test; * Tests ArrayUtils insert methods. */ public class ArrayUtilsInsertTest { - + @Test public void testInsertBooleans() throws Exception { final boolean[] array = {true,false,true}; final boolean[] values = {false,true,false}; - + boolean[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); - assertArrayEquals(new boolean[0], ArrayUtils.insert(0, new boolean[0], null)); + + assertNull(ArrayUtils.insert(42, null, array)); + assertArrayEquals(new boolean[0], ArrayUtils.insert(0, new boolean[0], null)); assertNull(ArrayUtils.insert(42, (boolean[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new boolean[]{false,true,false,true}, ArrayUtils.insert(0, array, false)); assertArrayEquals(new boolean[]{true,false,false,true}, ArrayUtils.insert(1, array, false)); assertArrayEquals(new boolean[]{true,false,true,false}, ArrayUtils.insert(array.length, array, false)); @@ -69,29 +69,29 @@ public class ArrayUtilsInsertTest { public void testInsertBytes() throws Exception { final byte[] array = {1,2,3}; final byte[] values = {4,5,6}; - + byte[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new byte[0], ArrayUtils.insert(0, new byte[0], null)); assertNull(ArrayUtils.insert(42, (byte[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new byte[]{0,1,2,3}, ArrayUtils.insert(0, array, (byte) 0)); assertArrayEquals(new byte[]{1,0,2,3}, ArrayUtils.insert(1, array, (byte) 0)); assertArrayEquals(new byte[]{1,2,3,0}, ArrayUtils.insert(array.length, array, (byte) 0)); @@ -99,34 +99,34 @@ public class ArrayUtilsInsertTest { assertArrayEquals(new byte[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new byte[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); } - + @Test public void testInsertChars() throws Exception { final char[] array = {'a','b','c'}; final char[] values = {'d','e','f'}; - + char[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new char[0], ArrayUtils.insert(0, new char[0], null)); assertNull(ArrayUtils.insert(42, (char[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new char[]{'z','a','b','c'}, ArrayUtils.insert(0, array, 'z')); assertArrayEquals(new char[]{'a','z','b','c'}, ArrayUtils.insert(1, array, 'z')); assertArrayEquals(new char[]{'a','b','c','z'}, ArrayUtils.insert(array.length, array, 'z')); @@ -134,219 +134,219 @@ public class ArrayUtilsInsertTest { assertArrayEquals(new char[]{'a','d','e','f','b','c'}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new char[]{'a','b','c','d','e','f'}, ArrayUtils.insert(array.length, array, values)); } - + @Test public void testInsertDoubles() throws Exception { final double[] array = {1,2,3}; final double[] values = {4,5,6}; final double delta = 0.000001; - + double[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result, delta); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new double[0], ArrayUtils.insert(0, new double[0], null), delta); assertNull(ArrayUtils.insert(42, (double[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new double[]{0,1,2,3}, ArrayUtils.insert(0, array, 0), delta); assertArrayEquals(new double[]{1,0,2,3}, ArrayUtils.insert(1, array, 0), delta); assertArrayEquals(new double[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0), delta); assertArrayEquals(new double[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values), delta); assertArrayEquals(new double[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values), delta); assertArrayEquals(new double[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values), delta); - } - + } + @Test public void testInsertFloats() throws Exception { final float[] array = {1,2,3}; final float[] values = {4,5,6}; final float delta = 0.000001f; - + float[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result, delta); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new float[0], ArrayUtils.insert(0, new float[0], null), delta); assertNull(ArrayUtils.insert(42, (float[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new float[]{0,1,2,3}, ArrayUtils.insert(0, array, 0), delta); assertArrayEquals(new float[]{1,0,2,3}, ArrayUtils.insert(1, array, 0), delta); assertArrayEquals(new float[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0), delta); assertArrayEquals(new float[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values), delta); assertArrayEquals(new float[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values), delta); assertArrayEquals(new float[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values), delta); - } - + } + @Test public void testInsertInts() throws Exception { final int[] array = {1,2,3}; final int[] values = {4,5,6}; - + int[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new int[0], ArrayUtils.insert(0, new int[0], null)); assertNull(ArrayUtils.insert(42, (int[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new int[]{0,1,2,3}, ArrayUtils.insert(0, array, 0)); assertArrayEquals(new int[]{1,0,2,3}, ArrayUtils.insert(1, array, 0)); assertArrayEquals(new int[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0)); assertArrayEquals(new int[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values)); assertArrayEquals(new int[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new int[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); - } - - + } + + @Test public void testInsertLongs() throws Exception { final long[] array = {1,2,3}; final long[] values = {4,5,6}; - + long[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new long[0], ArrayUtils.insert(0, new long[0], null)); assertNull(ArrayUtils.insert(42, (long[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new long[]{0,1,2,3}, ArrayUtils.insert(0, array, 0)); assertArrayEquals(new long[]{1,0,2,3}, ArrayUtils.insert(1, array, 0)); assertArrayEquals(new long[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0)); assertArrayEquals(new long[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values)); assertArrayEquals(new long[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new long[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); - } - - + } + + @Test public void testInsertShorts() throws Exception { final short[] array = {1,2,3}; final short[] values = {4,5,6}; - + short[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new short[0], ArrayUtils.insert(0, new short[0], null)); assertNull(ArrayUtils.insert(42, (short[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new short[]{0,1,2,3}, ArrayUtils.insert(0, array, (short) 0)); assertArrayEquals(new short[]{1,0,2,3}, ArrayUtils.insert(1, array, (short) 0)); assertArrayEquals(new short[]{1,2,3,0}, ArrayUtils.insert(array.length, array, (short) 0)); assertArrayEquals(new short[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values)); assertArrayEquals(new short[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new short[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); - } - - + } + + @Test public void testInsertGenericArray() throws Exception { final String[] array = {"a","b","c"}; final String[] values = {"d","e","f"}; - + String[] result = ArrayUtils.insert(42, array, (String[]) null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new String[0], ArrayUtils.insert(0, new String[0], (String[]) null)); assertNull(ArrayUtils.insert(42, null, (String[]) null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new String[]{"z","a","b","c"}, ArrayUtils.insert(0, array, "z")); assertArrayEquals(new String[]{"a","z","b","c"}, ArrayUtils.insert(1, array, "z")); assertArrayEquals(new String[]{"a","b","c","z"}, ArrayUtils.insert(array.length, array, "z")); assertArrayEquals(new String[]{"d","e","f","a","b","c"}, ArrayUtils.insert(0, array, values)); assertArrayEquals(new String[]{"a","d","e","f","b","c"}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new String[]{"a","b","c","d","e","f"}, ArrayUtils.insert(array.length, array, values)); - } + } } diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java index 341402778..9e596d4a7 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java index 0572f8cef..95ea490f3 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -104,7 +104,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveByteArray() { byte[] array; @@ -133,7 +133,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveCharArray() { char[] array; @@ -162,7 +162,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveDoubleArray() { double[] array; @@ -191,7 +191,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveFloatArray() { float[] array; @@ -220,7 +220,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveIntArray() { int[] array; @@ -249,7 +249,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveLongArray() { long[] array; @@ -278,7 +278,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveShortArray() { short[] array; @@ -307,7 +307,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveElementObjectArray() { Object[] array; @@ -326,7 +326,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new Object[] {"b", "a"}, array)); assertEquals(Object.class, array.getClass().getComponentType()); } - + @Test public void testRemoveElementBooleanArray() { boolean[] array; @@ -345,7 +345,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new boolean[] {false, true}, array)); assertEquals(Boolean.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementByteArray() { byte[] array; @@ -364,7 +364,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new byte[] {2, 1}, array)); assertEquals(Byte.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementCharArray() { char[] array; @@ -383,7 +383,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new char[] {'b', 'a'}, array)); assertEquals(Character.TYPE, array.getClass().getComponentType()); } - + @Test @SuppressWarnings("cast") public void testRemoveElementDoubleArray() { @@ -403,7 +403,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new double[] {2, 1}, array)); assertEquals(Double.TYPE, array.getClass().getComponentType()); } - + @Test @SuppressWarnings("cast") public void testRemoveElementFloatArray() { @@ -423,7 +423,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new float[] {2, 1}, array)); assertEquals(Float.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementIntArray() { int[] array; @@ -442,7 +442,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new int[] {2, 1}, array)); assertEquals(Integer.TYPE, array.getClass().getComponentType()); } - + @Test @SuppressWarnings("cast") public void testRemoveElementLongArray() { @@ -462,7 +462,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new long[] {2, 1}, array)); assertEquals(Long.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementShortArray() { short[] array; @@ -481,7 +481,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new short[] {2, 1}, array)); assertEquals(Short.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveAllBooleanOccurences() { @@ -524,7 +524,7 @@ public class ArrayUtilsRemoveTest { a = new char[] { '1', '2', '2', '3', '2' }; assertTrue(Arrays.equals(new char[] { '1', '2', '2', '3', '2' }, ArrayUtils.removeAllOccurences(a, '4'))); } - + @Test public void testRemoveAllByteOccurences() { byte[] a = null; @@ -568,7 +568,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllIntOccurences() { + public void testRemoveAllIntOccurences() { int[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -586,10 +586,10 @@ public class ArrayUtilsRemoveTest { a = new int[] { 1, 2, 2, 3, 2 }; assertTrue(Arrays.equals(new int[] { 1, 2, 2, 3, 2 }, ArrayUtils.removeAllOccurences(a, 4))); - } - + } + @Test - public void testRemoveAllLongOccurences() { + public void testRemoveAllLongOccurences() { long[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -610,7 +610,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllFloatOccurences() { + public void testRemoveAllFloatOccurences() { float[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -631,7 +631,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllDoubleOccurences() { + public void testRemoveAllDoubleOccurences() { double[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -652,7 +652,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllObjectOccurences() { + public void testRemoveAllObjectOccurences() { String[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, "2")); diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java index a2d3a21ed..cffae29d9 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -52,7 +52,7 @@ public class ArrayUtilsTest { assertTrue(Modifier.isPublic(ArrayUtils.class.getModifiers())); assertFalse(Modifier.isFinal(ArrayUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testToString() { @@ -61,7 +61,7 @@ public class ArrayUtilsTest { assertEquals("{}", ArrayUtils.toString(new String[0])); assertEquals("{<null>}", ArrayUtils.toString(new String[] {null})); assertEquals("{pink,blue}", ArrayUtils.toString(new String[] {"pink","blue"})); - + assertEquals("<empty>", ArrayUtils.toString(null, "<empty>")); assertEquals("{}", ArrayUtils.toString(new Object[0], "<empty>")); assertEquals("{}", ArrayUtils.toString(new String[0], "<empty>")); @@ -76,12 +76,12 @@ public class ArrayUtilsTest { final long[][] array2 = new long[][] {{2,5}, {4,6}}; assertTrue(ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array1)); assertFalse(ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array2)); - + 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)); - + 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)); @@ -150,7 +150,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.isEquals(null, null)); assertFalse(ArrayUtils.isEquals(null, array4)); } - + //----------------------------------------------------------------------- /** * Tests generic array creation with parameters of same type. @@ -223,15 +223,15 @@ public class ArrayUtilsTest { { return ArrayUtils.toArray(items); } - + //----------------------------------------------------------------------- @Test public void testToMap() { Map<?, ?> map = ArrayUtils.toMap(new String[][] {{"foo", "bar"}, {"hello", "world"}}); - + assertEquals("bar", map.get("foo")); assertEquals("world", map.get("hello")); - + assertEquals(null, ArrayUtils.toMap(null)); try { ArrayUtils.toMap(new String[][] {{"foo", "bar"}, {"short"}}); @@ -245,7 +245,7 @@ public class ArrayUtilsTest { ArrayUtils.toMap(new Object[] {new Object[] {"foo", "bar"}, null}); fail("exception expected"); } catch (final IllegalArgumentException ex) {} - + map = ArrayUtils.toMap(new Object[] {new Map.Entry<Object, Object>() { @Override public Object getKey() { @@ -279,7 +279,7 @@ public class ArrayUtilsTest { Object[] cloned1 = ArrayUtils.clone(original1); assertTrue(Arrays.equals(original1, cloned1)); assertTrue(original1 != cloned1); - + final StringBuilder builder = new StringBuilder("pick"); original1 = new Object[] {builder, "a", new String[] {"stick"}}; cloned1 = ArrayUtils.clone(original1); @@ -298,7 +298,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneLong() { assertEquals(null, ArrayUtils.clone((long[]) null)); @@ -307,7 +307,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneInt() { assertEquals(null, ArrayUtils.clone((int[]) null)); @@ -316,7 +316,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneShort() { assertEquals(null, ArrayUtils.clone((short[]) null)); @@ -325,7 +325,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneChar() { assertEquals(null, ArrayUtils.clone((char[]) null)); @@ -334,7 +334,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneByte() { assertEquals(null, ArrayUtils.clone((byte[]) null)); @@ -343,7 +343,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneDouble() { assertEquals(null, ArrayUtils.clone((double[]) null)); @@ -352,7 +352,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneFloat() { assertEquals(null, ArrayUtils.clone((float[]) null)); @@ -365,36 +365,36 @@ public class ArrayUtilsTest { //----------------------------------------------------------------------- private class TestClass{} - + @Test public void testNullToEmptyGenericNull() { final TestClass[] output = ArrayUtils.nullToEmpty(null, TestClass[].class); - + assertTrue(output != null); assertTrue(output.length == 0); } - + @Test public void testNullToEmptyGenericEmpty() { final TestClass[] input = new TestClass[]{}; final TestClass[] output = ArrayUtils.nullToEmpty(input, TestClass[].class); - + assertSame(input, output); } - + @Test public void testNullToEmptyGeneric() { final TestClass[] input = new TestClass[]{new TestClass(), new TestClass()}; final TestClass[] output = ArrayUtils.nullToEmpty(input, TestClass[].class); - + assertSame(input, output); } - + @Test(expected=IllegalArgumentException.class) public void testNullToEmptyGenericNullType() { final TestClass[] input = new TestClass[]{}; ArrayUtils.nullToEmpty(input, null); - } + } @Test public void testNullToEmptyBooleanNull() throws Exception { @@ -790,7 +790,7 @@ public class ArrayUtilsTest { StringUtils.join(ArrayUtils.subarray(objectArray, 2, 33))); assertEquals("start undershoot, end overshoot", "abcdef", StringUtils.join(ArrayUtils.subarray(objectArray, -2, 12))); - + // array type tests final Date[] dateArray = { new java.sql.Date(new Date().getTime()), new Date(), new Date(), new Date(), new Date() }; @@ -1431,7 +1431,7 @@ public class ArrayUtilsTest { ArrayUtils.subarray(array, 2, 4).getClass().getComponentType()); } - + //----------------------------------------------------------------------- @Test public void testSameLength() { @@ -1439,22 +1439,22 @@ public class ArrayUtilsTest { 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)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); @@ -1467,224 +1467,224 @@ public class ArrayUtilsTest { 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)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthLong() { 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)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthInt() { 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)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthShort() { 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)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthChar() { 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)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthByte() { 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)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthDouble() { 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)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthFloat() { 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)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + //----------------------------------------------------------------------- @Test public void testSameType() { @@ -1700,14 +1700,14 @@ public class ArrayUtilsTest { ArrayUtils.isSameType(new Object[0], null); fail(); } catch (final IllegalArgumentException ex) {} - + assertTrue(ArrayUtils.isSameType(new Object[0], new Object[0])); assertFalse(ArrayUtils.isSameType(new String[0], new Object[0])); assertTrue(ArrayUtils.isSameType(new String[0][0], new String[0][0])); assertFalse(ArrayUtils.isSameType(new String[0], new String[0][0])); assertFalse(ArrayUtils.isSameType(new String[0][0], new String[0])); } - + //----------------------------------------------------------------------- @Test public void testReverse() { @@ -1715,13 +1715,13 @@ public class ArrayUtilsTest { final String str2 = "a"; final String[] str3 = new String[] {"stick"}; final String str4 = "up"; - + Object[] array = new Object[] {str1, str2, str3}; ArrayUtils.reverse(array); assertEquals(array[0], str3); assertEquals(array[1], str2); assertEquals(array[2], str1); - + array = new Object[] {str1, str2, str3, str4}; ArrayUtils.reverse(array); assertEquals(array[0], str4); @@ -1746,7 +1746,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseInt() { int[] array = new int[] {1, 2, 3}; @@ -1759,7 +1759,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseShort() { short[] array = new short[] {1, 2, 3}; @@ -1772,7 +1772,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseChar() { char[] array = new char[] {'a', 'f', 'C'}; @@ -1785,7 +1785,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseByte() { byte[] array = new byte[] {2, 3, 4}; @@ -1798,7 +1798,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseDouble() { double[] array = new double[] {0.3d, 0.4d, 0.5d}; @@ -1811,7 +1811,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseFloat() { float[] array = new float[] {0.3f, 0.4f, 0.5f}; @@ -1824,7 +1824,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseBoolean() { boolean[] array = new boolean[] {false, false, true}; @@ -1837,7 +1837,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseBooleanRange() { boolean[] array = new boolean[] {false, false, true}; @@ -1869,7 +1869,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseByteRange() { byte[] array = new byte[] {1, 2, 3}; @@ -1901,7 +1901,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseCharRange() { char[] array = new char[] {1, 2, 3}; @@ -1933,7 +1933,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseDoubleRange() { double[] array = new double[] {1, 2, 3}; @@ -1965,7 +1965,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseFloatRange() { float[] array = new float[] {1, 2, 3}; @@ -1997,7 +1997,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseIntRange() { int[] array = new int[] {1, 2, 3}; @@ -2029,7 +2029,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseLongRange() { long[] array = new long[] {1, 2, 3}; @@ -2061,7 +2061,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseShortRange() { short[] array = new short[] {1, 2, 3}; @@ -2093,7 +2093,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseObjectRange() { String[] array = new String[] {"1", "2", "3"}; @@ -2125,23 +2125,23 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + //----------------------------------------------------------------------- @Test public void testSwapChar() { char[] array = new char[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2); assertArrayEquals(new char[] {3, 2, 1}, array); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, 0, 0); assertArrayEquals(new char[] {1, 2, 3}, array); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, 1, 0); assertArrayEquals(new char[] {2, 1, 3}, array); } - + @Test public void testSwapCharRange() { char[] array = new char[] {1, 2, 3, 4}; @@ -2156,32 +2156,32 @@ public class ArrayUtilsTest { assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); } - + @Test public void testSwapByte() { final byte[] array = new byte[] {1, 2, 3}; @@ -2190,21 +2190,21 @@ public class ArrayUtilsTest { assertEquals(2, array[1]); assertEquals(1, array[2]); } - + @Test public void testSwapNullByteArray() { final byte[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyByteArray() { final byte[] array = new byte[0]; ArrayUtils.swap(array, 0, 2); assertEquals(0, array.length); } - + @Test public void testSwapByteRange() { byte[] array = new byte[] {1, 2, 3, 4}; @@ -2213,38 +2213,38 @@ public class ArrayUtilsTest { assertEquals(4, array[1]); assertEquals(1, array[2]); assertEquals(2, array[3]); - + array = new byte[] {1, 2, 3}; ArrayUtils.swap(array, 0, 3); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new byte[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new byte[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new byte[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new byte[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); } - + @Test public void testSwapFloat() { final float[] array = new float[] {1, 2, 3}; @@ -2253,14 +2253,14 @@ public class ArrayUtilsTest { assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); } - + @Test public void testSwapNullFloatArray() { final float[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyFloatArray() { final float[] array = new float[0]; @@ -2282,32 +2282,32 @@ public class ArrayUtilsTest { assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); - + array = new float[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0], 0); assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); - + array = new float[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0], 0); assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); - + array = new float[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); - + array = new float[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); } - + @Test public void testSwapDouble() { final double[] array = new double[] {1, 2, 3}; @@ -2316,14 +2316,14 @@ public class ArrayUtilsTest { assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); } - + @Test public void testSwapNullDoubleArray() { final double[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyDoubleArray() { final double[] array = new double[0]; @@ -2345,32 +2345,32 @@ public class ArrayUtilsTest { assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); - + array = new double[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0], 0); assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); - + array = new double[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0], 0); assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); - + array = new double[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); - + array = new double[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); } - + @Test public void testSwapInt() { final int[] array = new int[] {1, 2, 3}; @@ -2379,14 +2379,14 @@ public class ArrayUtilsTest { assertEquals(2, array[1]); assertEquals(1, array[2]); } - + @Test public void testSwapNullIntArray() { final int[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyIntArray() { final int[] array = new int[0]; @@ -2402,50 +2402,50 @@ public class ArrayUtilsTest { assertEquals(4, array[1]); assertEquals(1, array[2]); assertEquals(2, array[3]); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, 3, 0); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); } - + @Test public void testSwapIntExchangedOffsets() { int[] array; array = new int[] {1, 2, 3}; ArrayUtils.swap(array, 0, 1, 2); assertArrayEquals(new int[] {2, 3, 1}, array); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, 1, 0, 2); assertArrayEquals(new int[] {2, 3, 1}, array); } - + @Test public void testSwapShort() { final short[] array = new short[] {1, 2, 3}; @@ -2454,21 +2454,21 @@ public class ArrayUtilsTest { assertEquals(2, array[1]); assertEquals(1, array[2]); } - + @Test public void testSwapNullShortArray() { final short[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyShortArray() { final short[] array = new short[0]; ArrayUtils.swap(array, 0, 2); assertEquals(0, array.length); } - + @Test public void testSwapShortRange() { short[] array = new short[] {1, 2, 3, 4}; @@ -2477,45 +2477,45 @@ public class ArrayUtilsTest { assertEquals(4, array[1]); assertEquals(1, array[2]); assertEquals(2, array[3]); - + array = new short[] {1, 2, 3}; ArrayUtils.swap(array, 3, 0); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new short[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new short[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new short[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new short[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); } - + @Test public void testSwapNullCharArray() { final char[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyCharArray() { final char[] array = new char[0]; @@ -2531,14 +2531,14 @@ public class ArrayUtilsTest { assertEquals(2, array[1]); assertEquals(1, array[2]); } - + @Test public void testSwapNullLongArray() { final long[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyLongArray() { final long[] array = new long[0]; @@ -2554,38 +2554,38 @@ public class ArrayUtilsTest { assertEquals(4, array[1]); assertEquals(1, array[2]); assertEquals(2, array[3]); - + array = new long[] {1, 2, 3}; ArrayUtils.swap(array, 0, 3); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new long[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new long[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new long[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new long[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); } - + @Test public void testSwapBoolean() { final boolean[] array = new boolean[] {true, false, false}; @@ -2594,21 +2594,21 @@ public class ArrayUtilsTest { assertFalse(array[1]); assertTrue(array[2]); } - + @Test public void testSwapNullBooleanArray() { final boolean[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyBooleanArray() { final boolean[] array = new boolean[0]; ArrayUtils.swap(array, 0, 2); assertEquals(0, array.length); } - + @Test public void testSwapBooleanRange() { boolean[] array = new boolean[] {false, false, true, true}; @@ -2617,31 +2617,31 @@ public class ArrayUtilsTest { assertTrue(array[1]); assertFalse(array[2]); assertFalse(array[3]); - + array = new boolean[] {false, true, false}; ArrayUtils.swap(array, 0, 3); assertFalse(array[0]); assertTrue(array[1]); assertFalse(array[2]); - + array = new boolean[] {true, true, false}; ArrayUtils.swap(array, 0, 2, 2); assertFalse(array[0]); assertTrue(array[1]); assertTrue(array[2]); - + array = new boolean[] {true, true, false}; ArrayUtils.swap(array, -1, 2, 2); assertFalse(array[0]); assertTrue(array[1]); assertTrue(array[2]); - + array = new boolean[] {true, true, false}; ArrayUtils.swap(array, 0, -1, 2); assertTrue(array[0]); assertTrue(array[1]); assertFalse(array[2]); - + array = new boolean[] {true, true, false}; ArrayUtils.swap(array, -1, -1, 2); assertTrue(array[0]); @@ -2657,14 +2657,14 @@ public class ArrayUtilsTest { assertEquals("2", array[1]); assertEquals("1", array[2]); } - + @Test public void testSwapNullObjectArray() { final String[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyObjectArray() { final String[] array = new String[0]; @@ -2695,7 +2695,7 @@ public class ArrayUtilsTest { assertEquals("5", array[2]); assertEquals("2", array[3]); assertEquals("1", array[4]); - + array = new String[] {"1", "2", "3", "4", "5"}; ArrayUtils.swap(array, 2, -2, 3); assertEquals("3", array[0]); @@ -2703,11 +2703,11 @@ public class ArrayUtilsTest { assertEquals("5", array[2]); assertEquals("2", array[3]); assertEquals("1", array[4]); - + array = new String[0]; ArrayUtils.swap(array, 0, 2, 2); assertEquals(0, array.length); - + array = null; ArrayUtils.swap(array, 0, 2, 2); assertNull(array); @@ -2765,18 +2765,18 @@ public class ArrayUtilsTest { assertEquals(3, array[2], 0); assertEquals(4, array[3], 0); } - + @Test public void testShiftRangeNullDouble() { final double[] array = null; ArrayUtils.shift(array, 1, 1, 1); assertNull(array); } - + @Test public void testShiftNullDouble() { final double[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -2795,7 +2795,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2], 0); assertEquals(4, array[3], 0); } - + @Test public void testShiftFloat() { final float[] array = new float[] {1, 2, 3, 4}; @@ -2847,18 +2847,18 @@ public class ArrayUtilsTest { assertEquals(3, array[2], 0); assertEquals(4, array[3], 0); } - + @Test public void testShiftRangeNullFloat() { final float[] array = null; ArrayUtils.shift(array, 1, 1, 1); assertNull(array); } - + @Test public void testShiftNullFloat() { final float[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -2877,7 +2877,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2], 0); assertEquals(4, array[3], 0); } - + @Test public void testShiftShort() { short[] array = new short[] {1, 2, 3, 4}; @@ -2909,11 +2909,11 @@ public class ArrayUtilsTest { assertEquals(2, array[3]); assertEquals(3, array[4]); } - + @Test public void testShiftNullShort() { final short[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -2944,11 +2944,11 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftRangeNullShort() { final short[] array = null; - + ArrayUtils.shift(array, 1, 1, 1); assertNull(array); } @@ -2967,7 +2967,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftByte() { final byte[] array = new byte[] {1, 2, 3, 4}; @@ -3019,7 +3019,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftRangeNullByte() { final byte[] array = null; @@ -3041,7 +3041,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftChar() { final char[] array = new char[] {1, 2, 3, 4}; @@ -3093,7 +3093,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftRangeNullChar() { final char[] array = null; @@ -3115,7 +3115,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftLong() { final long[] array = new long[] {1, 2, 3, 4}; @@ -3167,18 +3167,18 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftRangeNullLong() { final long[] array = null; ArrayUtils.shift(array, 1, 1, 1); assertNull(array); } - + @Test public void testShiftNullLong() { final long[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -3197,7 +3197,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftInt() { final int[] array = new int[] {1, 2, 3, 4}; @@ -3222,11 +3222,11 @@ public class ArrayUtilsTest { assertEquals(1, array[2]); assertEquals(2, array[3]); } - + @Test public void testShiftNullInt() { final int[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -3257,7 +3257,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftRangeNullInt() { final int[] array = null; @@ -3304,11 +3304,11 @@ public class ArrayUtilsTest { assertEquals("1", array[2]); assertEquals("2", array[3]); } - + @Test public void testShiftNullObject() { final String[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -3339,7 +3339,7 @@ public class ArrayUtilsTest { assertEquals("3", array[2]); assertEquals("4", array[3]); } - + @Test public void testShiftRangeNullObject() { final String[] array = null; @@ -3361,44 +3361,44 @@ public class ArrayUtilsTest { assertEquals("3", array[2]); assertEquals("4", array[3]); } - + @Test public void testShiftBoolean() { final boolean[] array = new boolean[] {true, true, false, false}; - + ArrayUtils.shift(array, 1); assertFalse(array[0]); assertTrue(array[1]); assertTrue(array[2]); assertFalse(array[3]); - + ArrayUtils.shift(array, -1); assertTrue(array[0]); assertTrue(array[1]); assertFalse(array[2]); assertFalse(array[3]); - + ArrayUtils.shift(array, 5); assertFalse(array[0]); assertTrue(array[1]); assertTrue(array[2]); assertFalse(array[3]); - + ArrayUtils.shift(array, -3); assertFalse(array[0]); assertFalse(array[1]); assertTrue(array[2]); assertTrue(array[3]); } - + @Test public void testShiftNullBoolean() { final boolean[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } - + //----------------------------------------------------------------------- @Test public void testIndexOf() { @@ -3426,7 +3426,7 @@ public class ArrayUtilsTest { assertEquals(3, ArrayUtils.indexOf(array, "3", 2)); assertEquals(4, ArrayUtils.indexOf(array, null, 2)); assertEquals(-1, ArrayUtils.indexOf(array, "notInArray", 2)); - + assertEquals(4, ArrayUtils.indexOf(array, null, -1)); assertEquals(-1, ArrayUtils.indexOf(array, null, 8)); assertEquals(-1, ArrayUtils.indexOf(array, "0", 8)); @@ -3458,7 +3458,7 @@ public class ArrayUtilsTest { assertEquals(4, ArrayUtils.lastIndexOf(array, null, 5)); assertEquals(-1, ArrayUtils.lastIndexOf(array, null, 2)); assertEquals(-1, ArrayUtils.lastIndexOf(array, "notInArray", 5)); - + assertEquals(-1, ArrayUtils.lastIndexOf(array, null, -1)); assertEquals(5, ArrayUtils.lastIndexOf(array, "0", 88)); } @@ -3556,7 +3556,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, 3)); assertFalse(ArrayUtils.contains(array, 99)); } - + //----------------------------------------------------------------------- @Test public void testIndexOfInt() { @@ -3621,7 +3621,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, 3)); assertFalse(ArrayUtils.contains(array, 99)); } - + //----------------------------------------------------------------------- @Test public void testIndexOfShort() { @@ -3686,7 +3686,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, (short) 3)); assertFalse(ArrayUtils.contains(array, (short) 99)); } - + //----------------------------------------------------------------------- @Test public void testIndexOfChar() { @@ -3751,7 +3751,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, 'd')); assertFalse(ArrayUtils.contains(array, 'e')); } - + //----------------------------------------------------------------------- @Test public void testIndexOfByte() { @@ -3816,7 +3816,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, (byte) 3)); assertFalse(ArrayUtils.contains(array, (byte) 99)); } - + //----------------------------------------------------------------------- @SuppressWarnings("cast") @Test @@ -3863,7 +3863,7 @@ public class ArrayUtilsTest { assertEquals(-1, ArrayUtils.indexOf(array, (double) 99, 0)); assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, 6)); } - + @SuppressWarnings("cast") @Test public void testIndexOfDoubleWithStartIndexTolerance() { @@ -3970,7 +3970,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, 2.5, 0.50)); assertTrue(ArrayUtils.contains(array, 2.5, 0.51)); } - + //----------------------------------------------------------------------- @SuppressWarnings("cast") @Test @@ -4048,7 +4048,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, (float) 3)); assertFalse(ArrayUtils.contains(array, (float) 99)); } - + //----------------------------------------------------------------------- @Test public void testIndexOfBoolean() { @@ -4119,7 +4119,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, true)); assertFalse(ArrayUtils.contains(array, false)); } - + // testToPrimitive/Object for boolean // ----------------------------------------------------------------------- @Test @@ -4173,12 +4173,12 @@ public class ArrayUtilsTest { public void testToPrimitive_char() { final Character[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - + assertSame(ArrayUtils.EMPTY_CHAR_ARRAY, ArrayUtils.toPrimitive(new Character[0])); - + assertTrue(Arrays.equals( new char[] {Character.MIN_VALUE, Character.MAX_VALUE, '0'}, - ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), + ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), new Character(Character.MAX_VALUE), new Character('0')})) ); @@ -4192,20 +4192,20 @@ public class ArrayUtilsTest { public void testToPrimitive_char_char() { final Character[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b, Character.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_CHAR_ARRAY, + + assertSame(ArrayUtils.EMPTY_CHAR_ARRAY, ArrayUtils.toPrimitive(new Character[0], (char)0)); - + assertTrue(Arrays.equals( new char[] {Character.MIN_VALUE, Character.MAX_VALUE, '0'}, - ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), - new Character(Character.MAX_VALUE), new Character('0')}, + ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), + new Character(Character.MAX_VALUE), new Character('0')}, Character.MIN_VALUE)) ); - + assertTrue(Arrays.equals( new char[] {Character.MIN_VALUE, Character.MAX_VALUE, '0'}, - ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), null, + ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), null, new Character('0')}, Character.MAX_VALUE)) ); } @@ -4214,30 +4214,30 @@ public class ArrayUtilsTest { public void testToObject_char() { final char[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - - assertSame(ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY, + + assertSame(ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY, ArrayUtils.toObject(new char[0])); - + assertTrue(Arrays.equals( - new Character[] {new Character(Character.MIN_VALUE), + new Character[] {new Character(Character.MIN_VALUE), new Character(Character.MAX_VALUE), new Character('0')}, - ArrayUtils.toObject(new char[] {Character.MIN_VALUE, Character.MAX_VALUE, + ArrayUtils.toObject(new char[] {Character.MIN_VALUE, Character.MAX_VALUE, '0'} )) ); } - + // testToPrimitive/Object for byte // ----------------------------------------------------------------------- @Test public void testToPrimitive_byte() { final Byte[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - + assertSame(ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.toPrimitive(new Byte[0])); - + assertTrue(Arrays.equals( new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, (byte)9999999}, - ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), + ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf((byte)9999999)})) ); @@ -4251,20 +4251,20 @@ public class ArrayUtilsTest { public void testToPrimitive_byte_byte() { final Byte[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b, Byte.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_BYTE_ARRAY, + + assertSame(ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.toPrimitive(new Byte[0], (byte)1)); - + assertTrue(Arrays.equals( new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, (byte)9999999}, - ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), - Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf((byte)9999999)}, + ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), + Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf((byte)9999999)}, Byte.MIN_VALUE)) ); - + assertTrue(Arrays.equals( new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, (byte)9999999}, - ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), null, + ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), null, Byte.valueOf((byte)9999999)}, Byte.MAX_VALUE)) ); } @@ -4273,14 +4273,14 @@ public class ArrayUtilsTest { public void testToObject_byte() { final byte[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - - assertSame(ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY, + + assertSame(ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY, ArrayUtils.toObject(new byte[0])); - + assertTrue(Arrays.equals( - new Byte[] {Byte.valueOf(Byte.MIN_VALUE), + new Byte[] {Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf((byte)9999999)}, - ArrayUtils.toObject(new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, + ArrayUtils.toObject(new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, (byte)9999999})) ); } @@ -4291,12 +4291,12 @@ public class ArrayUtilsTest { public void testToPrimitive_short() { final Short[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - + assertSame(ArrayUtils.EMPTY_SHORT_ARRAY, ArrayUtils.toPrimitive(new Short[0])); - + assertTrue(Arrays.equals( new short[] {Short.MIN_VALUE, Short.MAX_VALUE, (short)9999999}, - ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), + ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MAX_VALUE), Short.valueOf((short)9999999)})) ); @@ -4310,19 +4310,19 @@ public class ArrayUtilsTest { public void testToPrimitive_short_short() { final Short[] s = null; assertEquals(null, ArrayUtils.toPrimitive(s, Short.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_SHORT_ARRAY, ArrayUtils.toPrimitive(new Short[0], + + assertSame(ArrayUtils.EMPTY_SHORT_ARRAY, ArrayUtils.toPrimitive(new Short[0], Short.MIN_VALUE)); - + assertTrue(Arrays.equals( new short[] {Short.MIN_VALUE, Short.MAX_VALUE, (short)9999999}, - ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), + ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MAX_VALUE), Short.valueOf((short)9999999)}, Short.MIN_VALUE)) ); - + assertTrue(Arrays.equals( new short[] {Short.MIN_VALUE, Short.MAX_VALUE, (short)9999999}, - ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), null, + ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), null, Short.valueOf((short)9999999)}, Short.MAX_VALUE)) ); } @@ -4331,14 +4331,14 @@ public class ArrayUtilsTest { public void testToObject_short() { final short[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - - assertSame(ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY, + + assertSame(ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY, ArrayUtils.toObject(new short[0])); - + assertTrue(Arrays.equals( - new Short[] {Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MAX_VALUE), + new Short[] {Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MAX_VALUE), Short.valueOf((short)9999999)}, - ArrayUtils.toObject(new short[] {Short.MIN_VALUE, Short.MAX_VALUE, + ArrayUtils.toObject(new short[] {Short.MIN_VALUE, Short.MAX_VALUE, (short)9999999})) ); } @@ -4352,7 +4352,7 @@ public class ArrayUtilsTest { assertSame(ArrayUtils.EMPTY_INT_ARRAY, ArrayUtils.toPrimitive(new Integer[0])); assertTrue(Arrays.equals( new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), + ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)})) ); @@ -4366,19 +4366,19 @@ public class ArrayUtilsTest { public void testToPrimitive_int_int() { final Long[] l = null; assertEquals(null, ArrayUtils.toPrimitive(l, Integer.MIN_VALUE)); - assertSame(ArrayUtils.EMPTY_INT_ARRAY, + assertSame(ArrayUtils.EMPTY_INT_ARRAY, ArrayUtils.toPrimitive(new Integer[0], 1)); assertTrue(Arrays.equals( new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), + ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)},1))); assertTrue(Arrays.equals( new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), + ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), null, Integer.valueOf(9999999)}, Integer.MAX_VALUE)) ); } - + @Test public void testToPrimitive_intNull() { final Integer[] iArray = null; @@ -4389,11 +4389,11 @@ public class ArrayUtilsTest { public void testToObject_int() { final int[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - + assertSame( ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY, ArrayUtils.toObject(new int[0])); - + assertTrue( Arrays.equals( new Integer[] { @@ -4410,13 +4410,13 @@ public class ArrayUtilsTest { public void testToPrimitive_long() { final Long[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - - assertSame(ArrayUtils.EMPTY_LONG_ARRAY, + + assertSame(ArrayUtils.EMPTY_LONG_ARRAY, ArrayUtils.toPrimitive(new Long[0])); - + assertTrue(Arrays.equals( new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), + ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MAX_VALUE), Long.valueOf(9999999)})) ); @@ -4430,31 +4430,31 @@ public class ArrayUtilsTest { public void testToPrimitive_long_long() { final Long[] l = null; assertEquals(null, ArrayUtils.toPrimitive(l, Long.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_LONG_ARRAY, + + assertSame(ArrayUtils.EMPTY_LONG_ARRAY, ArrayUtils.toPrimitive(new Long[0], 1)); - + assertTrue(Arrays.equals( new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), + ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MAX_VALUE), Long.valueOf(9999999)},1))); - + assertTrue(Arrays.equals( new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), + ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), null, Long.valueOf(9999999)}, Long.MAX_VALUE)) ); } - + @Test public void testToObject_long() { final long[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - + assertSame( ArrayUtils.EMPTY_LONG_OBJECT_ARRAY, ArrayUtils.toObject(new long[0])); - + assertTrue( Arrays.equals( new Long[] { @@ -4471,13 +4471,13 @@ public class ArrayUtilsTest { public void testToPrimitive_float() { final Float[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - - assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, + + assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.toPrimitive(new Float[0])); - + assertTrue(Arrays.equals( new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), + ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), Float.valueOf(Float.MAX_VALUE), Float.valueOf(9999999)})) ); @@ -4491,31 +4491,31 @@ public class ArrayUtilsTest { public void testToPrimitive_float_float() { final Float[] l = null; assertEquals(null, ArrayUtils.toPrimitive(l, Float.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, + + assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.toPrimitive(new Float[0], 1)); - + assertTrue(Arrays.equals( new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), + ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), Float.valueOf(Float.MAX_VALUE), Float.valueOf(9999999)},1))); - + assertTrue(Arrays.equals( new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), + ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null, Float.valueOf(9999999)}, Float.MAX_VALUE)) ); } - + @Test public void testToObject_float() { final float[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - + assertSame( ArrayUtils.EMPTY_FLOAT_OBJECT_ARRAY, ArrayUtils.toObject(new float[0])); - + assertTrue( Arrays.equals( new Float[] { @@ -4532,13 +4532,13 @@ public class ArrayUtilsTest { public void testToPrimitive_double() { final Double[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - - assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, + + assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, ArrayUtils.toPrimitive(new Double[0])); - + assertTrue(Arrays.equals( new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), + ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), Double.valueOf(Double.MAX_VALUE), Double.valueOf(9999999)})) ); @@ -4552,31 +4552,31 @@ public class ArrayUtilsTest { public void testToPrimitive_double_double() { final Double[] l = null; assertEquals(null, ArrayUtils.toPrimitive(l, Double.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, + + assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, ArrayUtils.toPrimitive(new Double[0], 1)); - + assertTrue(Arrays.equals( new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), + ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), Double.valueOf(Double.MAX_VALUE), Double.valueOf(9999999)},1))); - + assertTrue(Arrays.equals( new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), + ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), null, Double.valueOf(9999999)}, Double.MAX_VALUE)) ); } - + @Test public void testToObject_double() { final double[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - + assertSame( ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY, ArrayUtils.toObject(new double[0])); - + assertTrue( Arrays.equals( new Double[] { @@ -4660,7 +4660,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.isEmpty(emptyBooleanArray)); assertFalse(ArrayUtils.isEmpty(notEmptyBooleanArray)); } - + /** * Test for {@link ArrayUtils#isNotEmpty(java.lang.Object[])}. */ @@ -4737,13 +4737,13 @@ public class ArrayUtilsTest { @Test public void testGetLength() { assertEquals(0, ArrayUtils.getLength(null)); - + 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)); - + final int[] emptyIntArray = new int[] {}; final int[] notEmptyIntArray = new int[] { 1 }; assertEquals(0, ArrayUtils.getLength((int[]) null)); @@ -4785,7 +4785,7 @@ public class ArrayUtilsTest { assertEquals(0, ArrayUtils.getLength((boolean[]) null)); assertEquals(0, ArrayUtils.getLength(emptyBooleanArray)); assertEquals(1, ArrayUtils.getLength(notEmptyBooleanArray)); - + try { ArrayUtils.getLength("notAnArray"); fail("IllegalArgumentException should have been thrown"); @@ -4828,7 +4828,7 @@ public class ArrayUtilsTest { array = new Integer[]{1,3,2}; assertFalse(ArrayUtils.isSorted(array, c)); } - + @Test(expected = IllegalArgumentException.class) public void testIsSortedNullComparator() throws Exception { ArrayUtils.isSorted(null, null); @@ -5006,7 +5006,7 @@ public class ArrayUtilsTest { public void testShuffleBoolean() { boolean[] array1 = new boolean[]{true, false, true, true, false, false, true, false, false, true}; boolean[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); Assert.assertEquals(5, ArrayUtils.removeAllOccurences(array1, true).length); @@ -5016,7 +5016,7 @@ public class ArrayUtilsTest { public void testShuffleByte() { byte[] array1 = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; byte[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (byte element : array2) { @@ -5028,7 +5028,7 @@ public class ArrayUtilsTest { public void testShuffleChar() { char[] array1 = new char[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; char[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (char element : array2) { @@ -5040,7 +5040,7 @@ public class ArrayUtilsTest { public void testShuffleShort() { short[] array1 = new short[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; short[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (short element : array2) { @@ -5052,7 +5052,7 @@ public class ArrayUtilsTest { public void testShuffleInt() { int[] array1 = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (int element : array2) { @@ -5064,7 +5064,7 @@ public class ArrayUtilsTest { public void testShuffleLong() { long[] array1 = new long[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; long[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (long element : array2) { @@ -5076,7 +5076,7 @@ public class ArrayUtilsTest { public void testShuffleFloat() { float[] array1 = new float[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; float[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (float element : array2) { @@ -5088,7 +5088,7 @@ public class ArrayUtilsTest { public void testShuffleDouble() { double[] array1 = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; double[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (double element : array2) { diff --git a/src/test/java/org/apache/commons/lang3/BitFieldTest.java b/src/test/java/org/apache/commons/lang3/BitFieldTest.java index 7d4ae9adf..b621c89c6 100644 --- a/src/test/java/org/apache/commons/lang3/BitFieldTest.java +++ b/src/test/java/org/apache/commons/lang3/BitFieldTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java index b16a2e0f4..5d22dad66 100644 --- a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,7 +42,7 @@ public class BooleanUtilsTest { assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers())); assertFalse(Modifier.isFinal(BooleanUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void test_negate_Boolean() { @@ -107,14 +107,14 @@ public class BooleanUtilsTest { assertTrue(BooleanUtils.toBoolean(-1)); assertFalse(BooleanUtils.toBoolean(0)); } - + @Test public void test_toBooleanObject_int() { assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(1)); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(-1)); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(0)); } - + @Test public void test_toBooleanObject_Integer() { assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(1))); @@ -122,7 +122,7 @@ public class BooleanUtilsTest { assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(0))); assertEquals(null, BooleanUtils.toBooleanObject((Integer) null)); } - + //----------------------------------------------------------------------- @Test public void test_toBoolean_int_int_int() { @@ -134,7 +134,7 @@ public class BooleanUtilsTest { public void test_toBoolean_int_int_int_noMatch() { BooleanUtils.toBoolean(8, 6, 7); } - + @Test public void test_toBoolean_Integer_Integer_Integer() { final Integer six = Integer.valueOf(6); @@ -156,7 +156,7 @@ public class BooleanUtilsTest { public void test_toBoolean_Integer_Integer_Integer_noMatch() { BooleanUtils.toBoolean(Integer.valueOf(8), Integer.valueOf(6), Integer.valueOf(7)); } - + //----------------------------------------------------------------------- @Test public void test_toBooleanObject_int_int_int() { @@ -169,7 +169,7 @@ public class BooleanUtilsTest { public void test_toBooleanObject_int_int_int_noMatch() { BooleanUtils.toBooleanObject(9, 6, 7, 8); } - + @Test public void test_toBooleanObject_Integer_Integer_Integer_Integer() { final Integer six = Integer.valueOf(6); @@ -201,34 +201,34 @@ public class BooleanUtilsTest { assertEquals(1, BooleanUtils.toInteger(true)); assertEquals(0, BooleanUtils.toInteger(false)); } - + @Test public void test_toIntegerObject_boolean() { assertEquals(Integer.valueOf(1), BooleanUtils.toIntegerObject(true)); assertEquals(Integer.valueOf(0), BooleanUtils.toIntegerObject(false)); } - + @Test public void test_toIntegerObject_Boolean() { assertEquals(Integer.valueOf(1), BooleanUtils.toIntegerObject(Boolean.TRUE)); assertEquals(Integer.valueOf(0), BooleanUtils.toIntegerObject(Boolean.FALSE)); assertEquals(null, BooleanUtils.toIntegerObject(null)); } - + //----------------------------------------------------------------------- @Test public void test_toInteger_boolean_int_int() { assertEquals(6, BooleanUtils.toInteger(true, 6, 7)); assertEquals(7, BooleanUtils.toInteger(false, 6, 7)); } - + @Test public void test_toInteger_Boolean_int_int_int() { assertEquals(6, BooleanUtils.toInteger(Boolean.TRUE, 6, 7, 8)); assertEquals(7, BooleanUtils.toInteger(Boolean.FALSE, 6, 7, 8)); assertEquals(8, BooleanUtils.toInteger(null, 6, 7, 8)); } - + @Test public void test_toIntegerObject_boolean_Integer_Integer() { final Integer six = Integer.valueOf(6); @@ -236,7 +236,7 @@ public class BooleanUtilsTest { assertEquals(six, BooleanUtils.toIntegerObject(true, six, seven)); assertEquals(seven, BooleanUtils.toIntegerObject(false, six, seven)); } - + @Test public void test_toIntegerObject_Boolean_Integer_Integer_Integer() { final Integer six = Integer.valueOf(6); @@ -247,7 +247,7 @@ public class BooleanUtilsTest { assertEquals(eight, BooleanUtils.toIntegerObject(null, six, seven, eight)); assertEquals(null, BooleanUtils.toIntegerObject(null, six, seven, null)); } - + //----------------------------------------------------------------------- //----------------------------------------------------------------------- @Test @@ -285,7 +285,7 @@ public class BooleanUtilsTest { assertEquals(null, BooleanUtils.toBooleanObject("true ")); assertEquals(null, BooleanUtils.toBooleanObject("ono")); } - + @Test public void test_toBooleanObject_String_String_String_String() { assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(null, null, "N", "U")); @@ -385,53 +385,53 @@ public class BooleanUtilsTest { assertEquals("true", BooleanUtils.toStringTrueFalse(Boolean.TRUE)); assertEquals("false", BooleanUtils.toStringTrueFalse(Boolean.FALSE)); } - + @Test public void test_toStringOnOff_Boolean() { assertEquals(null, BooleanUtils.toStringOnOff(null)); assertEquals("on", BooleanUtils.toStringOnOff(Boolean.TRUE)); assertEquals("off", BooleanUtils.toStringOnOff(Boolean.FALSE)); } - + @Test public void test_toStringYesNo_Boolean() { assertEquals(null, BooleanUtils.toStringYesNo(null)); assertEquals("yes", BooleanUtils.toStringYesNo(Boolean.TRUE)); assertEquals("no", BooleanUtils.toStringYesNo(Boolean.FALSE)); } - + @Test public void test_toString_Boolean_String_String_String() { assertEquals("U", BooleanUtils.toString(null, "Y", "N", "U")); assertEquals("Y", BooleanUtils.toString(Boolean.TRUE, "Y", "N", "U")); assertEquals("N", BooleanUtils.toString(Boolean.FALSE, "Y", "N", "U")); } - + //----------------------------------------------------------------------- @Test public void test_toStringTrueFalse_boolean() { assertEquals("true", BooleanUtils.toStringTrueFalse(true)); assertEquals("false", BooleanUtils.toStringTrueFalse(false)); } - + @Test public void test_toStringOnOff_boolean() { assertEquals("on", BooleanUtils.toStringOnOff(true)); assertEquals("off", BooleanUtils.toStringOnOff(false)); } - + @Test public void test_toStringYesNo_boolean() { assertEquals("yes", BooleanUtils.toStringYesNo(true)); assertEquals("no", BooleanUtils.toStringYesNo(false)); } - + @Test public void test_toString_boolean_String_String_String() { assertEquals("Y", BooleanUtils.toString(true, "Y", "N")); assertEquals("N", BooleanUtils.toString(false, "Y", "N")); } - + // testXor // ----------------------------------------------------------------------- @Test(expected = IllegalArgumentException.class) @@ -519,7 +519,7 @@ public class BooleanUtilsTest { public void testXor_object_emptyInput() { BooleanUtils.xor(new Boolean[] {}); } - + @Test(expected = IllegalArgumentException.class) public void testXor_object_nullElementInput() { BooleanUtils.xor(new Boolean[] {null}); @@ -645,81 +645,81 @@ public class BooleanUtilsTest { public void testAnd_primitive_nullInput() { BooleanUtils.and((boolean[]) null); } - + @Test(expected = IllegalArgumentException.class) public void testAnd_primitive_emptyInput() { BooleanUtils.and(new boolean[] {}); } - + @Test public void testAnd_primitive_validInput_2items() { assertTrue( "False result for (true, true)", BooleanUtils.and(new boolean[] { true, true })); - + assertTrue( "True result for (false, false)", ! BooleanUtils.and(new boolean[] { false, false })); - + assertTrue( "True result for (true, false)", ! BooleanUtils.and(new boolean[] { true, false })); - + assertTrue( "True result for (false, true)", ! BooleanUtils.and(new boolean[] { false, true })); } - + @Test public void testAnd_primitive_validInput_3items() { assertTrue( "True result for (false, false, true)", ! BooleanUtils.and(new boolean[] { false, false, true })); - + assertTrue( "True result for (false, true, false)", ! BooleanUtils.and(new boolean[] { false, true, false })); - + assertTrue( "True result for (true, false, false)", ! BooleanUtils.and(new boolean[] { true, false, false })); - + assertTrue( "False result for (true, true, true)", BooleanUtils.and(new boolean[] { true, true, true })); - + assertTrue( "True result for (false, false)", ! BooleanUtils.and(new boolean[] { false, false, false })); - + assertTrue( "True result for (true, true, false)", ! BooleanUtils.and(new boolean[] { true, true, false })); - + assertTrue( "True result for (true, false, true)", ! BooleanUtils.and(new boolean[] { true, false, true })); - + assertTrue( "True result for (false, true, true)", ! BooleanUtils.and(new boolean[] { false, true, true })); } - + @Test(expected = IllegalArgumentException.class) public void testAnd_object_nullInput() { BooleanUtils.and((Boolean[]) null); } - + @Test(expected = IllegalArgumentException.class) public void testAnd_object_emptyInput() { BooleanUtils.and(new Boolean[] {}); } - + @Test(expected = IllegalArgumentException.class) public void testAnd_object_nullElementInput() { BooleanUtils.and(new Boolean[] {null}); } - + @Test public void testAnd_object_validInput_2items() { assertTrue( @@ -727,26 +727,26 @@ public class BooleanUtilsTest { BooleanUtils .and(new Boolean[] { Boolean.TRUE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, false)", ! BooleanUtils .and(new Boolean[] { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "True result for (true, false)", ! BooleanUtils .and(new Boolean[] { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "True result for (false, true)", ! BooleanUtils .and(new Boolean[] { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); } - + @Test public void testAnd_object_validInput_3items() { assertTrue( @@ -758,7 +758,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, true, false)", ! BooleanUtils @@ -768,7 +768,7 @@ public class BooleanUtilsTest { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "True result for (true, false, false)", ! BooleanUtils @@ -778,13 +778,13 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, true, true)", BooleanUtils .and(new Boolean[] { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, false)", ! BooleanUtils.and( @@ -793,7 +793,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "True result for (true, true, false)", ! BooleanUtils.and( @@ -802,7 +802,7 @@ public class BooleanUtilsTest { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "True result for (true, false, true)", ! BooleanUtils.and( @@ -811,7 +811,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, true, true)", ! BooleanUtils.and( @@ -821,88 +821,88 @@ public class BooleanUtilsTest { Boolean.TRUE }) .booleanValue()); } - + // testOr // ----------------------------------------------------------------------- @Test(expected = IllegalArgumentException.class) public void testOr_primitive_nullInput() { BooleanUtils.or((boolean[]) null); } - + @Test(expected = IllegalArgumentException.class) public void testOr_primitive_emptyInput() { BooleanUtils.or(new boolean[] {}); } - + @Test public void testOr_primitive_validInput_2items() { assertTrue( "False result for (true, true)", BooleanUtils.or(new boolean[] { true, true })); - + assertTrue( "True result for (false, false)", ! BooleanUtils.or(new boolean[] { false, false })); - + assertTrue( "False result for (true, false)", BooleanUtils.or(new boolean[] { true, false })); - + assertTrue( "False result for (false, true)", BooleanUtils.or(new boolean[] { false, true })); } - + @Test public void testOr_primitive_validInput_3items() { assertTrue( "False result for (false, false, true)", BooleanUtils.or(new boolean[] { false, false, true })); - + assertTrue( "False result for (false, true, false)", BooleanUtils.or(new boolean[] { false, true, false })); - + assertTrue( "False result for (true, false, false)", BooleanUtils.or(new boolean[] { true, false, false })); - + assertTrue( "False result for (true, true, true)", BooleanUtils.or(new boolean[] { true, true, true })); - + assertTrue( "True result for (false, false)", ! BooleanUtils.or(new boolean[] { false, false, false })); - + assertTrue( "False result for (true, true, false)", BooleanUtils.or(new boolean[] { true, true, false })); - + assertTrue( "False result for (true, false, true)", BooleanUtils.or(new boolean[] { true, false, true })); - + assertTrue( "False result for (false, true, true)", BooleanUtils.or(new boolean[] { false, true, true })); - + } @Test(expected = IllegalArgumentException.class) public void testOr_object_nullInput() { BooleanUtils.or((Boolean[]) null); } - + @Test(expected = IllegalArgumentException.class) public void testOr_object_emptyInput() { BooleanUtils.or(new Boolean[] {}); } - + @Test(expected = IllegalArgumentException.class) public void testOr_object_nullElementInput() { BooleanUtils.or(new Boolean[] {null}); } - + @Test public void testOr_object_validInput_2items() { assertTrue( @@ -910,26 +910,26 @@ public class BooleanUtilsTest { BooleanUtils .or(new Boolean[] { Boolean.TRUE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, false)", ! BooleanUtils .or(new Boolean[] { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, false)", BooleanUtils .or(new Boolean[] { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (false, true)", BooleanUtils .or(new Boolean[] { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); } - + @Test public void testOr_object_validInput_3items() { assertTrue( @@ -941,7 +941,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "False result for (false, true, false)", BooleanUtils @@ -951,7 +951,7 @@ public class BooleanUtilsTest { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, false, false)", BooleanUtils @@ -961,13 +961,13 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, true, true)", BooleanUtils .or(new Boolean[] { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, false)", ! BooleanUtils.or( @@ -976,7 +976,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, true, false)", BooleanUtils.or( @@ -985,7 +985,7 @@ public class BooleanUtilsTest { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, false, true)", BooleanUtils.or( @@ -994,7 +994,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "False result for (false, true, true)", BooleanUtils.or( @@ -1012,5 +1012,5 @@ public class BooleanUtilsTest { assertTrue(BooleanUtils.compare(false, false) == 0); assertTrue(BooleanUtils.compare(false, true) < 0); } - + } diff --git a/src/test/java/org/apache/commons/lang3/CharEncodingTest.java b/src/test/java/org/apache/commons/lang3/CharEncodingTest.java index 9e8e5402e..7999457f7 100644 --- a/src/test/java/org/apache/commons/lang3/CharEncodingTest.java +++ b/src/test/java/org/apache/commons/lang3/CharEncodingTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import org.junit.Test; /** * Tests CharEncoding. - * + * * @see CharEncoding */ @SuppressWarnings("deprecation") diff --git a/src/test/java/org/apache/commons/lang3/CharRangeTest.java b/src/test/java/org/apache/commons/lang3/CharRangeTest.java index b36e43e7a..83a1008df 100644 --- a/src/test/java/org/apache/commons/lang3/CharRangeTest.java +++ b/src/test/java/org/apache/commons/lang3/CharRangeTest.java @@ -390,11 +390,11 @@ public class CharRangeTest { @Test public void testSerialization() { CharRange range = CharRange.is('a'); - assertEquals(range, SerializationUtils.clone(range)); + assertEquals(range, SerializationUtils.clone(range)); range = CharRange.isIn('a', 'e'); - assertEquals(range, SerializationUtils.clone(range)); + assertEquals(range, SerializationUtils.clone(range)); range = CharRange.isNotIn('a', 'e'); - assertEquals(range, SerializationUtils.clone(range)); + assertEquals(range, SerializationUtils.clone(range)); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java index 591bf3886..824061973 100644 --- a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java @@ -43,7 +43,7 @@ public class CharSequenceUtilsTest { assertTrue(Modifier.isPublic(CharSequenceUtils.class.getModifiers())); assertFalse(Modifier.isFinal(CharSequenceUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testSubSequence() { @@ -138,9 +138,9 @@ public class CharSequenceUtilsTest { }; private static abstract class RunTest { - + abstract boolean invoke(); - + void run(final TestData data, final String id) { if (data.throwable != null) { try { @@ -156,7 +156,7 @@ public class CharSequenceUtilsTest { assertEquals(id + " Failed test " + data, data.expected, stringCheck); } } - + } @Test @@ -165,25 +165,25 @@ public class CharSequenceUtilsTest { new RunTest() { @Override boolean invoke() { - return data.source.regionMatches(data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); + return data.source.regionMatches(data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); } }.run(data, "String"); new RunTest() { @Override boolean invoke() { - return CharSequenceUtils.regionMatches(data.source, data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); + return CharSequenceUtils.regionMatches(data.source, data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); } }.run(data, "CSString"); new RunTest() { @Override boolean invoke() { - return CharSequenceUtils.regionMatches(new StringBuilder(data.source), data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); + return CharSequenceUtils.regionMatches(new StringBuilder(data.source), data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); } }.run(data, "CSNonString"); } } - - + + @Test public void testToCharArray() throws Exception { final StringBuilder builder = new StringBuilder("abcdefg"); diff --git a/src/test/java/org/apache/commons/lang3/CharSetTest.java b/src/test/java/org/apache/commons/lang3/CharSetTest.java index 2c05e9845..035dc4b74 100644 --- a/src/test/java/org/apache/commons/lang3/CharSetTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSetTest.java @@ -38,7 +38,7 @@ public class CharSetTest { assertTrue(Modifier.isPublic(CharSet.class.getModifiers())); assertFalse(Modifier.isFinal(CharSet.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testGetInstance() { @@ -59,78 +59,78 @@ public class CharSetTest { assertEquals("[]", CharSet.getInstance(new String[] {null}).toString()); assertEquals("[a-e]", CharSet.getInstance(new String[] {"a-e"}).toString()); } - + //----------------------------------------------------------------------- @Test public void testConstructor_String_simple() { CharSet set; CharRange[] array; - + set = CharSet.getInstance((String) null); array = set.getCharRanges(); assertEquals("[]", set.toString()); assertEquals(0, array.length); - + set = CharSet.getInstance(""); array = set.getCharRanges(); assertEquals("[]", set.toString()); assertEquals(0, array.length); - + set = CharSet.getInstance("a"); array = set.getCharRanges(); assertEquals("[a]", set.toString()); assertEquals(1, array.length); assertEquals("a", array[0].toString()); - + set = CharSet.getInstance("^a"); array = set.getCharRanges(); assertEquals("[^a]", set.toString()); assertEquals(1, array.length); assertEquals("^a", array[0].toString()); - + set = CharSet.getInstance("a-e"); array = set.getCharRanges(); assertEquals("[a-e]", set.toString()); assertEquals(1, array.length); assertEquals("a-e", array[0].toString()); - + set = CharSet.getInstance("^a-e"); array = set.getCharRanges(); assertEquals("[^a-e]", set.toString()); assertEquals(1, array.length); assertEquals("^a-e", array[0].toString()); } - + @Test public void testConstructor_String_combo() { CharSet set; CharRange[] array; - + set = CharSet.getInstance("abc"); array = set.getCharRanges(); assertEquals(3, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); assertTrue(ArrayUtils.contains(array, CharRange.is('b'))); assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); - + set = CharSet.getInstance("a-ce-f"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', 'c'))); assertTrue(ArrayUtils.contains(array, CharRange.isIn('e', 'f'))); - + set = CharSet.getInstance("ae-f"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); assertTrue(ArrayUtils.contains(array, CharRange.isIn('e', 'f'))); - + set = CharSet.getInstance("e-fa"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); assertTrue(ArrayUtils.contains(array, CharRange.isIn('e', 'f'))); - + set = CharSet.getInstance("ae-fm-pz"); array = set.getCharRanges(); assertEquals(4, array.length); @@ -139,26 +139,26 @@ public class CharSetTest { assertTrue(ArrayUtils.contains(array, CharRange.isIn('m', 'p'))); assertTrue(ArrayUtils.contains(array, CharRange.is('z'))); } - + @Test public void testConstructor_String_comboNegated() { CharSet set; CharRange[] array; - + set = CharSet.getInstance("^abc"); array = set.getCharRanges(); assertEquals(3, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('a'))); assertTrue(ArrayUtils.contains(array, CharRange.is('b'))); assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); - + set = CharSet.getInstance("b^ac"); array = set.getCharRanges(); assertEquals(3, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('b'))); assertTrue(ArrayUtils.contains(array, CharRange.isNot('a'))); assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); - + set = CharSet.getInstance("db^ac"); array = set.getCharRanges(); assertEquals(4, array.length); @@ -166,13 +166,13 @@ public class CharSetTest { assertTrue(ArrayUtils.contains(array, CharRange.is('b'))); assertTrue(ArrayUtils.contains(array, CharRange.isNot('a'))); assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); - + set = CharSet.getInstance("^b^a"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('b'))); assertTrue(ArrayUtils.contains(array, CharRange.isNot('a'))); - + set = CharSet.getInstance("b^a-c^z"); array = set.getCharRanges(); assertEquals(3, array.length); @@ -185,50 +185,50 @@ public class CharSetTest { public void testConstructor_String_oddDash() { CharSet set; CharRange[] array; - + set = CharSet.getInstance("-"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); - + set = CharSet.getInstance("--"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); - + set = CharSet.getInstance("---"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); - + set = CharSet.getInstance("----"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); - + set = CharSet.getInstance("-a"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); - + set = CharSet.getInstance("a-"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); - + set = CharSet.getInstance("a--"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', '-'))); - + set = CharSet.getInstance("--a"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('-', 'a'))); } - + @Test public void testConstructor_String_oddNegate() { CharSet set; @@ -237,80 +237,80 @@ public class CharSetTest { array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('^'))); // "^" - + set = CharSet.getInstance("^^"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^" - + set = CharSet.getInstance("^^^"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^" assertTrue(ArrayUtils.contains(array, CharRange.is('^'))); // "^" - + set = CharSet.getInstance("^^^^"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^" x2 - + set = CharSet.getInstance("a^"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); // "a" assertTrue(ArrayUtils.contains(array, CharRange.is('^'))); // "^" - + set = CharSet.getInstance("^a-"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('a'))); // "^a" assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); // "-" - + set = CharSet.getInstance("^^-c"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNotIn('^', 'c'))); // "^^-c" - + set = CharSet.getInstance("^c-^"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNotIn('c', '^'))); // "^c-^" - + set = CharSet.getInstance("^c-^d"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNotIn('c', '^'))); // "^c-^" assertTrue(ArrayUtils.contains(array, CharRange.is('d'))); // "d" - + set = CharSet.getInstance("^^-"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^" assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); // "-" } - + @Test public void testConstructor_String_oddCombinations() { CharSet set; CharRange[] array = null; - + set = CharSet.getInstance("a-^c"); array = set.getCharRanges(); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', '^'))); // "a-^" assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); // "c" assertFalse(set.contains('b')); - assertTrue(set.contains('^')); + assertTrue(set.contains('^')); assertTrue(set.contains('_')); // between ^ and a - assertTrue(set.contains('c')); - + assertTrue(set.contains('c')); + set = CharSet.getInstance("^a-^c"); array = set.getCharRanges(); assertTrue(ArrayUtils.contains(array, CharRange.isNotIn('a', '^'))); // "^a-^" assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); // "c" assertTrue(set.contains('b')); - assertFalse(set.contains('^')); + assertFalse(set.contains('^')); assertFalse(set.contains('_')); // between ^ and a - + set = CharSet.getInstance("a- ^-- "); //contains everything array = set.getCharRanges(); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', ' '))); // "a- " @@ -320,25 +320,25 @@ public class CharSetTest { assertTrue(set.contains('a')); assertTrue(set.contains('*')); assertTrue(set.contains('A')); - + set = CharSet.getInstance("^-b"); array = set.getCharRanges(); assertTrue(ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "^-b" assertTrue(set.contains('b')); assertTrue(set.contains('_')); // between ^ and a assertFalse(set.contains('A')); - assertTrue(set.contains('^')); - + assertTrue(set.contains('^')); + set = CharSet.getInstance("b-^"); array = set.getCharRanges(); assertTrue(ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "b-^" assertTrue(set.contains('b')); assertTrue(set.contains('^')); assertTrue(set.contains('a')); // between ^ and b - assertFalse(set.contains('c')); + assertFalse(set.contains('c')); } - - //----------------------------------------------------------------------- + + //----------------------------------------------------------------------- @Test public void testEquals_Object() { final CharSet abc = CharSet.getInstance("abc"); @@ -347,25 +347,25 @@ public class CharSetTest { 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)); - + assertTrue(abc.equals(abc)); assertTrue(abc.equals(abc2)); assertFalse(abc.equals(atoc)); assertFalse(abc.equals(notatoc)); - + assertFalse(atoc.equals(abc)); assertTrue(atoc.equals(atoc)); assertTrue(atoc.equals(atoc2)); assertFalse(atoc.equals(notatoc)); - + assertFalse(notatoc.equals(abc)); assertFalse(notatoc.equals(atoc)); assertTrue(notatoc.equals(notatoc)); assertTrue(notatoc.equals(notatoc2)); } - + @Test public void testHashCode() { final CharSet abc = CharSet.getInstance("abc"); @@ -374,7 +374,7 @@ public class CharSetTest { 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()); assertEquals(atoc.hashCode(), atoc.hashCode()); @@ -382,8 +382,8 @@ public class CharSetTest { assertEquals(notatoc.hashCode(), notatoc.hashCode()); assertEquals(notatoc.hashCode(), notatoc2.hashCode()); } - - //----------------------------------------------------------------------- + + //----------------------------------------------------------------------- @Test public void testContains_Char() { final CharSet btod = CharSet.getInstance("b-d"); @@ -391,79 +391,79 @@ public class CharSetTest { 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')); assertTrue(btod.contains('c')); assertTrue(btod.contains('d')); assertFalse(btod.contains('e')); - + assertFalse(bcd.contains('a')); assertTrue(bcd.contains('b')); assertTrue(bcd.contains('c')); assertTrue(bcd.contains('d')); assertFalse(bcd.contains('e')); - + assertFalse(bd.contains('a')); assertTrue(bd.contains('b')); assertFalse(bd.contains('c')); assertTrue(bd.contains('d')); assertFalse(bd.contains('e')); - + assertTrue(notbtod.contains('a')); assertFalse(notbtod.contains('b')); assertFalse(notbtod.contains('c')); assertFalse(notbtod.contains('d')); assertTrue(notbtod.contains('e')); - + assertFalse(dtob.contains('a')); assertTrue(dtob.contains('b')); assertTrue(dtob.contains('c')); assertTrue(dtob.contains('d')); assertFalse(dtob.contains('e')); - + final CharRange[] array = dtob.getCharRanges(); assertEquals("[b-d]", dtob.toString()); assertEquals(1, array.length); } - - //----------------------------------------------------------------------- + + //----------------------------------------------------------------------- @Test public void testSerialization() { CharSet set = CharSet.getInstance("a"); - assertEquals(set, SerializationUtils.clone(set)); + assertEquals(set, SerializationUtils.clone(set)); set = CharSet.getInstance("a-e"); - assertEquals(set, SerializationUtils.clone(set)); + assertEquals(set, SerializationUtils.clone(set)); set = CharSet.getInstance("be-f^a-z"); - assertEquals(set, SerializationUtils.clone(set)); + assertEquals(set, SerializationUtils.clone(set)); } - - //----------------------------------------------------------------------- + + //----------------------------------------------------------------------- @Test public void testStatics() { CharRange[] array; - + array = CharSet.EMPTY.getCharRanges(); assertEquals(0, array.length); - + array = CharSet.ASCII_ALPHA.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', 'z'))); assertTrue(ArrayUtils.contains(array, CharRange.isIn('A', 'Z'))); - + array = CharSet.ASCII_ALPHA_LOWER.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', 'z'))); - + array = CharSet.ASCII_ALPHA_UPPER.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('A', 'Z'))); - + array = CharSet.ASCII_NUMERIC.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('0', '9'))); } - + @Test public void testJavadocExamples() throws Exception { assertFalse(CharSet.getInstance("^a-c").contains('a')); @@ -472,6 +472,6 @@ public class CharSetTest { assertFalse(CharSet.getInstance("^^a-c").contains('^')); assertTrue(CharSet.getInstance("^a-cd-f").contains('d')); assertTrue(CharSet.getInstance("a-c^").contains('^')); - assertTrue(CharSet.getInstance("^", "a-c").contains('^')); + assertTrue(CharSet.getInstance("^", "a-c").contains('^')); } } diff --git a/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java index 9b74d3597..829ff6c16 100644 --- a/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,17 +41,17 @@ public class CharSetUtilsTest { assertTrue(Modifier.isPublic(CharSetUtils.class.getModifiers())); assertFalse(Modifier.isFinal(CharSetUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testSqueeze_StringString() { assertEquals(null, CharSetUtils.squeeze(null, (String) null)); assertEquals(null, CharSetUtils.squeeze(null, "")); - + assertEquals("", CharSetUtils.squeeze("", (String) null)); assertEquals("", CharSetUtils.squeeze("", "")); assertEquals("", CharSetUtils.squeeze("", "a-e")); - + assertEquals("hello", CharSetUtils.squeeze("hello", (String) null)); assertEquals("hello", CharSetUtils.squeeze("hello", "")); assertEquals("hello", CharSetUtils.squeeze("hello", "a-e")); @@ -59,24 +59,24 @@ public class CharSetUtilsTest { assertEquals("heloo", CharSetUtils.squeeze("helloo", "l")); assertEquals("hello", CharSetUtils.squeeze("helloo", "^l")); } - + @Test public void testSqueeze_StringStringarray() { assertEquals(null, CharSetUtils.squeeze(null, (String[]) null)); assertEquals(null, CharSetUtils.squeeze(null, new String[0])); assertEquals(null, CharSetUtils.squeeze(null, new String[] {null})); assertEquals(null, CharSetUtils.squeeze(null, new String[] {"el"})); - + assertEquals("", CharSetUtils.squeeze("", (String[]) null)); assertEquals("", CharSetUtils.squeeze("", new String[0])); assertEquals("", CharSetUtils.squeeze("", new String[] {null})); assertEquals("", CharSetUtils.squeeze("", new String[] {"a-e"})); - + assertEquals("hello", CharSetUtils.squeeze("hello", (String[]) null)); assertEquals("hello", CharSetUtils.squeeze("hello", new String[0])); assertEquals("hello", CharSetUtils.squeeze("hello", new String[] {null})); assertEquals("hello", CharSetUtils.squeeze("hello", new String[] {"a-e"})); - + assertEquals("helo", CharSetUtils.squeeze("hello", new String[] { "el" })); assertEquals("hello", CharSetUtils.squeeze("hello", new String[] { "e" })); assertEquals("fofof", CharSetUtils.squeeze("fooffooff", new String[] { "of" })); @@ -88,34 +88,34 @@ public class CharSetUtilsTest { public void testContainsAny_StringString() { assertFalse(CharSetUtils.containsAny(null, (String) null)); assertFalse(CharSetUtils.containsAny(null, "")); - + assertFalse(CharSetUtils.containsAny("", (String) null)); assertFalse(CharSetUtils.containsAny("", "")); assertFalse(CharSetUtils.containsAny("", "a-e")); - + assertFalse(CharSetUtils.containsAny("hello", (String) null)); assertFalse(CharSetUtils.containsAny("hello", "")); assertTrue(CharSetUtils.containsAny("hello", "a-e")); assertTrue(CharSetUtils.containsAny("hello", "l-p")); } - + @Test public void testContainsAny_StringStringarray() { assertFalse(CharSetUtils.containsAny(null, (String[]) null)); assertFalse(CharSetUtils.containsAny(null, new String[0])); assertFalse(CharSetUtils.containsAny(null, new String[] {null})); assertFalse(CharSetUtils.containsAny(null, new String[] {"a-e"})); - + assertFalse(CharSetUtils.containsAny("", (String[]) null)); assertFalse(CharSetUtils.containsAny("", new String[0])); assertFalse(CharSetUtils.containsAny("", new String[] {null})); assertFalse(CharSetUtils.containsAny("", new String[] {"a-e"})); - + assertFalse(CharSetUtils.containsAny("hello", (String[]) null)); assertFalse(CharSetUtils.containsAny("hello", new String[0])); assertFalse(CharSetUtils.containsAny("hello", new String[] {null})); assertTrue(CharSetUtils.containsAny("hello", new String[] {"a-e"})); - + assertTrue(CharSetUtils.containsAny("hello", new String[] { "el" })); assertFalse(CharSetUtils.containsAny("hello", new String[] { "x" })); assertTrue(CharSetUtils.containsAny("hello", new String[] { "e-i" })); @@ -128,34 +128,34 @@ public class CharSetUtilsTest { public void testCount_StringString() { assertEquals(0, CharSetUtils.count(null, (String) null)); assertEquals(0, CharSetUtils.count(null, "")); - + assertEquals(0, CharSetUtils.count("", (String) null)); assertEquals(0, CharSetUtils.count("", "")); assertEquals(0, CharSetUtils.count("", "a-e")); - + assertEquals(0, CharSetUtils.count("hello", (String) null)); assertEquals(0, CharSetUtils.count("hello", "")); assertEquals(1, CharSetUtils.count("hello", "a-e")); assertEquals(3, CharSetUtils.count("hello", "l-p")); } - + @Test public void testCount_StringStringarray() { assertEquals(0, CharSetUtils.count(null, (String[]) null)); assertEquals(0, CharSetUtils.count(null, new String[0])); assertEquals(0, CharSetUtils.count(null, new String[] {null})); assertEquals(0, CharSetUtils.count(null, new String[] {"a-e"})); - + assertEquals(0, CharSetUtils.count("", (String[]) null)); assertEquals(0, CharSetUtils.count("", new String[0])); assertEquals(0, CharSetUtils.count("", new String[] {null})); assertEquals(0, CharSetUtils.count("", new String[] {"a-e"})); - + assertEquals(0, CharSetUtils.count("hello", (String[]) null)); assertEquals(0, CharSetUtils.count("hello", new String[0])); assertEquals(0, CharSetUtils.count("hello", new String[] {null})); assertEquals(1, CharSetUtils.count("hello", new String[] {"a-e"})); - + assertEquals(3, CharSetUtils.count("hello", new String[] { "el" })); assertEquals(0, CharSetUtils.count("hello", new String[] { "x" })); assertEquals(2, CharSetUtils.count("hello", new String[] { "e-i" })); @@ -168,11 +168,11 @@ public class CharSetUtilsTest { public void testKeep_StringString() { assertEquals(null, CharSetUtils.keep(null, (String) null)); assertEquals(null, CharSetUtils.keep(null, "")); - + assertEquals("", CharSetUtils.keep("", (String) null)); assertEquals("", CharSetUtils.keep("", "")); assertEquals("", CharSetUtils.keep("", "a-e")); - + assertEquals("", CharSetUtils.keep("hello", (String) null)); assertEquals("", CharSetUtils.keep("hello", "")); assertEquals("", CharSetUtils.keep("hello", "xyz")); @@ -180,24 +180,24 @@ public class CharSetUtilsTest { assertEquals("hello", CharSetUtils.keep("hello", "oleh")); assertEquals("ell", CharSetUtils.keep("hello", "el")); } - + @Test public void testKeep_StringStringarray() { assertEquals(null, CharSetUtils.keep(null, (String[]) null)); assertEquals(null, CharSetUtils.keep(null, new String[0])); assertEquals(null, CharSetUtils.keep(null, new String[] {null})); assertEquals(null, CharSetUtils.keep(null, new String[] {"a-e"})); - + assertEquals("", CharSetUtils.keep("", (String[]) null)); assertEquals("", CharSetUtils.keep("", new String[0])); assertEquals("", CharSetUtils.keep("", new String[] {null})); assertEquals("", CharSetUtils.keep("", new String[] {"a-e"})); - + assertEquals("", CharSetUtils.keep("hello", (String[]) null)); assertEquals("", CharSetUtils.keep("hello", new String[0])); assertEquals("", CharSetUtils.keep("hello", new String[] {null})); assertEquals("e", CharSetUtils.keep("hello", new String[] {"a-e"})); - + assertEquals("e", CharSetUtils.keep("hello", new String[] { "a-e" })); assertEquals("ell", CharSetUtils.keep("hello", new String[] { "el" })); assertEquals("hello", CharSetUtils.keep("hello", new String[] { "elho" })); @@ -211,30 +211,30 @@ public class CharSetUtilsTest { public void testDelete_StringString() { assertEquals(null, CharSetUtils.delete(null, (String) null)); assertEquals(null, CharSetUtils.delete(null, "")); - + assertEquals("", CharSetUtils.delete("", (String) null)); assertEquals("", CharSetUtils.delete("", "")); assertEquals("", CharSetUtils.delete("", "a-e")); - + assertEquals("hello", CharSetUtils.delete("hello", (String) null)); assertEquals("hello", CharSetUtils.delete("hello", "")); assertEquals("hllo", CharSetUtils.delete("hello", "a-e")); assertEquals("he", CharSetUtils.delete("hello", "l-p")); assertEquals("hello", CharSetUtils.delete("hello", "z")); } - + @Test public void testDelete_StringStringarray() { assertEquals(null, CharSetUtils.delete(null, (String[]) null)); assertEquals(null, CharSetUtils.delete(null, new String[0])); assertEquals(null, CharSetUtils.delete(null, new String[] {null})); assertEquals(null, CharSetUtils.delete(null, new String[] {"el"})); - + assertEquals("", CharSetUtils.delete("", (String[]) null)); assertEquals("", CharSetUtils.delete("", new String[0])); assertEquals("", CharSetUtils.delete("", new String[] {null})); assertEquals("", CharSetUtils.delete("", new String[] {"a-e"})); - + assertEquals("hello", CharSetUtils.delete("hello", (String[]) null)); assertEquals("hello", CharSetUtils.delete("hello", new String[0])); assertEquals("hello", CharSetUtils.delete("hello", new String[] {null})); @@ -248,5 +248,5 @@ public class CharSetUtilsTest { assertEquals("", CharSetUtils.delete("----", new String[] { "-" })); assertEquals("heo", CharSetUtils.delete("hello", new String[] { "l" })); } - + } diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java b/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java index 5cc4e2fac..7ab88b2ba 100644 --- a/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java +++ b/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,7 @@ import java.util.Calendar; /** * Tests the difference in performance between CharUtils and CharSet. - * + * * Sample runs: Now: Thu Mar 18 14:29:48 PST 2004 diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java index ea68ada86..bd92c3355 100644 --- a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +35,7 @@ public class CharUtilsTest { private static final Character CHARACTER_A = new Character('A'); private static final Character CHARACTER_B = new Character('B'); private static final char CHAR_COPY = '\u00a9'; - + @Test public void testConstructor() { assertNotNull(new CharUtils()); @@ -45,13 +45,13 @@ public class CharUtilsTest { assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers())); assertFalse(Modifier.isFinal(BooleanUtils.class.getModifiers())); } - + @SuppressWarnings("deprecation") // intentional test of deprecated method @Test public void testToCharacterObject_char() { assertEquals(new Character('a'), CharUtils.toCharacterObject('a')); assertSame(CharUtils.toCharacterObject('a'), CharUtils.toCharacterObject('a')); - + for (int i = 0; i < 128; i++) { final Character ch = CharUtils.toCharacterObject((char) i); final Character ch2 = CharUtils.toCharacterObject((char) i); @@ -68,7 +68,7 @@ public class CharUtilsTest { } assertSame(CharUtils.toCharacterObject("a"), CharUtils.toCharacterObject('a')); } - + @Test public void testToCharacterObject_String() { assertEquals(null, CharUtils.toCharacterObject(null)); @@ -77,7 +77,7 @@ public class CharUtilsTest { assertEquals(new Character('a'), CharUtils.toCharacterObject("abc")); assertSame(CharUtils.toCharacterObject("a"), CharUtils.toCharacterObject("a")); } - + @Test public void testToChar_Character() { assertEquals('A', CharUtils.toChar(CHARACTER_A)); @@ -86,14 +86,14 @@ public class CharUtilsTest { CharUtils.toChar((Character) null); } catch (final IllegalArgumentException ex) {} } - + @Test public void testToChar_Character_char() { assertEquals('A', CharUtils.toChar(CHARACTER_A, 'X')); assertEquals('B', CharUtils.toChar(CHARACTER_B, 'X')); assertEquals('X', CharUtils.toChar((Character) null, 'X')); } - + @Test public void testToChar_String() { assertEquals('A', CharUtils.toChar("A")); @@ -105,7 +105,7 @@ public class CharUtilsTest { CharUtils.toChar(""); } catch (final IllegalArgumentException ex) {} } - + @Test public void testToChar_String_char() { assertEquals('A', CharUtils.toChar("A", 'X')); @@ -113,7 +113,7 @@ public class CharUtilsTest { assertEquals('X', CharUtils.toChar("", 'X')); assertEquals('X', CharUtils.toChar((String) null, 'X')); } - + @Test public void testToIntValue_char() { assertEquals(0, CharUtils.toIntValue('0')); @@ -130,14 +130,14 @@ public class CharUtilsTest { CharUtils.toIntValue('a'); } catch (final IllegalArgumentException ex) {} } - + @Test public void testToIntValue_char_int() { assertEquals(0, CharUtils.toIntValue('0', -1)); assertEquals(3, CharUtils.toIntValue('3', -1)); assertEquals(-1, CharUtils.toIntValue('a', -1)); } - + @Test public void testToIntValue_Character() { assertEquals(0, CharUtils.toIntValue(new Character('0'))); @@ -149,7 +149,7 @@ public class CharUtilsTest { CharUtils.toIntValue(CHARACTER_A); } catch (final IllegalArgumentException ex) {} } - + @Test public void testToIntValue_Character_int() { assertEquals(0, CharUtils.toIntValue(new Character('0'), -1)); @@ -157,12 +157,12 @@ public class CharUtilsTest { assertEquals(-1, CharUtils.toIntValue(new Character('A'), -1)); assertEquals(-1, CharUtils.toIntValue(null, -1)); } - + @Test public void testToString_char() { assertEquals("a", CharUtils.toString('a')); assertSame(CharUtils.toString('a'), CharUtils.toString('a')); - + for (int i = 0; i < 128; i++) { final String str = CharUtils.toString((char) i); final String str2 = CharUtils.toString((char) i); @@ -181,19 +181,19 @@ public class CharUtilsTest { assertEquals(i, str2.charAt(0)); } } - + @Test public void testToString_Character() { assertEquals(null, CharUtils.toString(null)); assertEquals("A", CharUtils.toString(CHARACTER_A)); assertSame(CharUtils.toString(CHARACTER_A), CharUtils.toString(CHARACTER_A)); } - + @Test public void testToUnicodeEscaped_char() { assertEquals("\\u0041", CharUtils.unicodeEscaped('A')); assertEquals("\\u004c", CharUtils.unicodeEscaped('L')); - + for (int i = 0; i < 196; i++) { final String str = CharUtils.unicodeEscaped((char) i); assertEquals(6, str.length()); @@ -203,13 +203,13 @@ public class CharUtilsTest { assertEquals("\\u0999", CharUtils.unicodeEscaped((char) 0x999)); assertEquals("\\u1001", CharUtils.unicodeEscaped((char) 0x1001)); } - + @Test public void testToUnicodeEscaped_Character() { assertEquals(null, CharUtils.unicodeEscaped(null)); assertEquals("\\u0041", CharUtils.unicodeEscaped(CHARACTER_A)); } - + @Test public void testIsAscii_char() { assertTrue(CharUtils.isAscii('a')); @@ -218,7 +218,7 @@ public class CharUtilsTest { assertTrue(CharUtils.isAscii('-')); assertTrue(CharUtils.isAscii('\n')); assertFalse(CharUtils.isAscii(CHAR_COPY)); - + for (int i = 0; i < 128; i++) { if (i < 128) { assertTrue(CharUtils.isAscii((char) i)); @@ -227,7 +227,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiPrintable_char() { assertTrue(CharUtils.isAsciiPrintable('a')); @@ -236,7 +236,7 @@ public class CharUtilsTest { assertTrue(CharUtils.isAsciiPrintable('-')); assertFalse(CharUtils.isAsciiPrintable('\n')); assertFalse(CharUtils.isAsciiPrintable(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if (i >= 32 && i <= 126) { assertTrue(CharUtils.isAsciiPrintable((char) i)); @@ -245,7 +245,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiControl_char() { assertFalse(CharUtils.isAsciiControl('a')); @@ -254,7 +254,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiControl('-')); assertTrue(CharUtils.isAsciiControl('\n')); assertFalse(CharUtils.isAsciiControl(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if (i < 32 || i == 127) { assertTrue(CharUtils.isAsciiControl((char) i)); @@ -263,7 +263,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiAlpha_char() { assertTrue(CharUtils.isAsciiAlpha('a')); @@ -272,7 +272,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiAlpha('-')); assertFalse(CharUtils.isAsciiAlpha('\n')); assertFalse(CharUtils.isAsciiAlpha(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if ((i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z')) { assertTrue(CharUtils.isAsciiAlpha((char) i)); @@ -281,7 +281,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiAlphaUpper_char() { assertFalse(CharUtils.isAsciiAlphaUpper('a')); @@ -290,7 +290,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiAlphaUpper('-')); assertFalse(CharUtils.isAsciiAlphaUpper('\n')); assertFalse(CharUtils.isAsciiAlphaUpper(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if (i >= 'A' && i <= 'Z') { assertTrue(CharUtils.isAsciiAlphaUpper((char) i)); @@ -299,7 +299,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiAlphaLower_char() { assertTrue(CharUtils.isAsciiAlphaLower('a')); @@ -308,7 +308,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiAlphaLower('-')); assertFalse(CharUtils.isAsciiAlphaLower('\n')); assertFalse(CharUtils.isAsciiAlphaLower(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if (i >= 'a' && i <= 'z') { assertTrue(CharUtils.isAsciiAlphaLower((char) i)); @@ -317,7 +317,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiNumeric_char() { assertFalse(CharUtils.isAsciiNumeric('a')); @@ -326,7 +326,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiNumeric('-')); assertFalse(CharUtils.isAsciiNumeric('\n')); assertFalse(CharUtils.isAsciiNumeric(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if (i >= '0' && i <= '9') { assertTrue(CharUtils.isAsciiNumeric((char) i)); @@ -335,7 +335,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiAlphanumeric_char() { assertTrue(CharUtils.isAsciiAlphanumeric('a')); @@ -344,7 +344,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiAlphanumeric('-')); assertFalse(CharUtils.isAsciiAlphanumeric('\n')); assertFalse(CharUtils.isAsciiAlphanumeric(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if ((i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z') || (i >= '0' && i <= '9')) { assertTrue(CharUtils.isAsciiAlphanumeric((char) i)); diff --git a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java index 744aaa837..a31c78ce2 100644 --- a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java @@ -114,7 +114,7 @@ public class ClassUtilsTest { assertEquals("String[][]", ClassUtils.getShortClassName(String[][].class)); assertEquals("String[][][]", ClassUtils.getShortClassName(String[][][].class)); assertEquals("String[][][][]", ClassUtils.getShortClassName(String[][][][].class)); - + // Inner types class Named {} assertEquals("ClassUtilsTest.2", ClassUtils.getShortClassName(new Object(){}.getClass())); @@ -166,7 +166,7 @@ public class ClassUtilsTest { assertEquals("String[][]", ClassUtils.getSimpleName(String[][].class)); assertEquals("String[][][]", ClassUtils.getSimpleName(String[][][].class)); assertEquals("String[][][][]", ClassUtils.getSimpleName(String[][][][].class)); - + // On-the-fly types class Named {} assertEquals("", ClassUtils.getSimpleName(new Object(){}.getClass())); @@ -212,7 +212,7 @@ public class ClassUtilsTest { assertEquals("java.lang", ClassUtils.getPackageName(String[][].class)); assertEquals("java.lang", ClassUtils.getPackageName(String[][][].class)); assertEquals("java.lang", ClassUtils.getPackageName(String[][][][].class)); - + // On-the-fly types class Named {} assertEquals("org.apache.commons.lang3", ClassUtils.getPackageName(new Object() { @@ -783,7 +783,7 @@ public class ClassUtilsTest { assertTrue("Long.class", ClassUtils.isPrimitiveOrWrapper(Long.class)); assertTrue("Double.class", ClassUtils.isPrimitiveOrWrapper(Double.class)); assertTrue("Float.class", ClassUtils.isPrimitiveOrWrapper(Float.class)); - + // test primitive classes assertTrue("boolean", ClassUtils.isPrimitiveOrWrapper(Boolean.TYPE)); assertTrue("byte", ClassUtils.isPrimitiveOrWrapper(Byte.TYPE)); @@ -794,14 +794,14 @@ public class ClassUtilsTest { assertTrue("double", ClassUtils.isPrimitiveOrWrapper(Double.TYPE)); assertTrue("float", ClassUtils.isPrimitiveOrWrapper(Float.TYPE)); assertTrue("Void.TYPE", ClassUtils.isPrimitiveOrWrapper(Void.TYPE)); - + // others assertFalse("null", ClassUtils.isPrimitiveOrWrapper(null)); assertFalse("Void.class", ClassUtils.isPrimitiveOrWrapper(Void.class)); assertFalse("String.class", ClassUtils.isPrimitiveOrWrapper(String.class)); assertFalse("this.getClass()", ClassUtils.isPrimitiveOrWrapper(this.getClass())); } - + @Test public void testIsPrimitiveWrapper() { @@ -814,7 +814,7 @@ public class ClassUtilsTest { assertTrue("Long.class", ClassUtils.isPrimitiveWrapper(Long.class)); assertTrue("Double.class", ClassUtils.isPrimitiveWrapper(Double.class)); assertTrue("Float.class", ClassUtils.isPrimitiveWrapper(Float.class)); - + // test primitive classes assertFalse("boolean", ClassUtils.isPrimitiveWrapper(Boolean.TYPE)); assertFalse("byte", ClassUtils.isPrimitiveWrapper(Byte.TYPE)); @@ -824,7 +824,7 @@ public class ClassUtilsTest { assertFalse("long", ClassUtils.isPrimitiveWrapper(Long.TYPE)); assertFalse("double", ClassUtils.isPrimitiveWrapper(Double.TYPE)); assertFalse("float", ClassUtils.isPrimitiveWrapper(Float.TYPE)); - + // others assertFalse("null", ClassUtils.isPrimitiveWrapper(null)); assertFalse("Void.class", ClassUtils.isPrimitiveWrapper(Void.class)); @@ -832,7 +832,7 @@ public class ClassUtilsTest { assertFalse("String.class", ClassUtils.isPrimitiveWrapper(String.class)); assertFalse("this.getClass()", ClassUtils.isPrimitiveWrapper(this.getClass())); } - + @Test public void testPrimitiveToWrapper() { @@ -1127,7 +1127,7 @@ public class ClassUtilsTest { public void testToClass_object() { // assertNull(ClassUtils.toClass(null)); // generates warning assertNull(ClassUtils.toClass((Object[]) null)); // equivalent explicit cast - + // Additional varargs tests assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass())); final Class<?>[] castNull = ClassUtils.toClass((Object) null); // == new Object[]{null} @@ -1165,7 +1165,7 @@ public class ClassUtilsTest { assertEquals("ClassUtils[][]", ClassUtils.getShortCanonicalName(ClassUtils[][].class)); assertEquals("int[]", ClassUtils.getShortCanonicalName(int[].class)); assertEquals("int[][]", ClassUtils.getShortCanonicalName(int[][].class)); - + // Inner types class Named {} assertEquals("ClassUtilsTest.7", ClassUtils.getShortCanonicalName(new Object(){}.getClass())); @@ -1184,7 +1184,7 @@ public class ClassUtilsTest { assertEquals("int[][]", ClassUtils.getShortCanonicalName("[[I")); assertEquals("int[]", ClassUtils.getShortCanonicalName("int[]")); assertEquals("int[][]", ClassUtils.getShortCanonicalName("int[][]")); - + // Inner types assertEquals("ClassUtilsTest.6", ClassUtils.getShortCanonicalName("org.apache.commons.lang3.ClassUtilsTest$6")); assertEquals("ClassUtilsTest.5Named", ClassUtils.getShortCanonicalName("org.apache.commons.lang3.ClassUtilsTest$5Named")); @@ -1199,7 +1199,7 @@ public class ClassUtilsTest { assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName(new ClassUtils[0][0], "<null>")); assertEquals("", ClassUtils.getPackageCanonicalName(new int[0], "<null>")); assertEquals("", ClassUtils.getPackageCanonicalName(new int[0][0], "<null>")); - + // Inner types class Named {} assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName(new Object(){}, "<null>")); @@ -1214,7 +1214,7 @@ public class ClassUtilsTest { assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName(ClassUtils[][].class)); assertEquals("", ClassUtils.getPackageCanonicalName(int[].class)); assertEquals("", ClassUtils.getPackageCanonicalName(int[][].class)); - + // Inner types class Named {} assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName(new Object(){}.getClass())); @@ -1238,7 +1238,7 @@ public class ClassUtilsTest { assertEquals("", ClassUtils.getPackageCanonicalName("[[I")); assertEquals("", ClassUtils.getPackageCanonicalName("int[]")); assertEquals("", ClassUtils.getPackageCanonicalName("int[][]")); - + // Inner types assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName("org.apache.commons.lang3.ClassUtilsTest$6")); assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName("org.apache.commons.lang3.ClassUtilsTest$5Named")); diff --git a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java index 5845ef6d5..bb425d492 100644 --- a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java @@ -32,7 +32,7 @@ import org.junit.Assert; import org.junit.Test; /** - * + * */ public class EnumUtilsTest { @@ -102,7 +102,7 @@ public class EnumUtilsTest { public void test_generateBitVectors_nullClass() { EnumUtils.generateBitVectors(null, EnumSet.of(Traffic.RED)); } - + @Test(expected=NullPointerException.class) public void test_generateBitVector_nullIterable() { EnumUtils.generateBitVector(Traffic.class, (Iterable<Traffic>) null); @@ -112,27 +112,27 @@ public class EnumUtilsTest { public void test_generateBitVectors_nullIterable() { EnumUtils.generateBitVectors(null, (Iterable<Traffic>) null); } - + @Test(expected=IllegalArgumentException.class) public void test_generateBitVector_nullElement() { EnumUtils.generateBitVector(Traffic.class, Arrays.asList(Traffic.RED, null)); } - + @Test(expected=IllegalArgumentException.class) public void test_generateBitVectors_nullElement() { EnumUtils.generateBitVectors(Traffic.class, Arrays.asList(Traffic.RED, null)); } - + @Test(expected=NullPointerException.class) public void test_generateBitVector_nullClassWithArray() { EnumUtils.generateBitVector(null, Traffic.RED); } - + @Test(expected=NullPointerException.class) public void test_generateBitVectors_nullClassWithArray() { EnumUtils.generateBitVectors(null, Traffic.RED); } - + @Test(expected=NullPointerException.class) public void test_generateBitVector_nullArray() { EnumUtils.generateBitVector(Traffic.class, (Traffic[]) null); @@ -142,17 +142,17 @@ public class EnumUtilsTest { public void test_generateBitVectors_nullArray() { EnumUtils.generateBitVectors(Traffic.class, (Traffic[]) null); } - + @Test(expected=IllegalArgumentException.class) public void test_generateBitVector_nullArrayElement() { EnumUtils.generateBitVector(Traffic.class, Traffic.RED, null); } - + @Test(expected=IllegalArgumentException.class) public void test_generateBitVectors_nullArrayElement() { EnumUtils.generateBitVectors(Traffic.class, Traffic.RED, null); } - + @Test(expected=IllegalArgumentException.class) public void test_generateBitVector_longClass() { EnumUtils.generateBitVector(TooMany.class, EnumSet.of(TooMany.A1)); @@ -174,7 +174,7 @@ public class EnumUtilsTest { List rawList = new ArrayList(); EnumUtils.generateBitVector(rawType, rawList); } - + @SuppressWarnings("unchecked") @Test(expected=IllegalArgumentException.class) public void test_generateBitVectors_nonEnumClass() { @@ -186,7 +186,7 @@ public class EnumUtilsTest { List rawList = new ArrayList(); EnumUtils.generateBitVectors(rawType, rawList); } - + @SuppressWarnings("unchecked") @Test(expected=IllegalArgumentException.class) public void test_generateBitVector_nonEnumClassWithArray() { @@ -204,7 +204,7 @@ public class EnumUtilsTest { Class rawType = Object.class; EnumUtils.generateBitVectors(rawType); } - + @Test public void test_generateBitVector() { assertEquals(0L, EnumUtils.generateBitVector(Traffic.class, EnumSet.noneOf(Traffic.class))); @@ -264,7 +264,7 @@ public class EnumUtilsTest { assertEquals((1L << 63), EnumUtils.generateBitVector(Enum64.class, Enum64.A63)); assertEquals(Long.MIN_VALUE, EnumUtils.generateBitVector(Enum64.class, Enum64.A63)); } - + @Test public void test_generateBitVectorsFromArray() { assertArrayEquals(EnumUtils.generateBitVectors(Traffic.class), 0L); @@ -365,7 +365,7 @@ public class EnumUtilsTest { public void test_processBitVector_longClass() { EnumUtils.processBitVector(TooMany.class, 0L); } - + public void test_processBitVectors_longClass() { assertEquals(EnumSet.noneOf(TooMany.class), EnumUtils.processBitVectors(TooMany.class, 0L)); assertEquals(EnumSet.of(TooMany.A), EnumUtils.processBitVectors(TooMany.class, 1L)); diff --git a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java index 97fe71492..5c04cd6ee 100644 --- a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java +++ b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -64,7 +64,7 @@ public class HashSetvBitSetTest { toRemove.set(10, 20); return (int[]) ArrayUtils.removeAll(array, toRemove); } - + @Benchmark public int[] timeExtractRemoveAll() { final BitSet toRemove = new BitSet(); @@ -89,7 +89,7 @@ public class HashSetvBitSetTest { int i = 0; int j=0; while((j=coll.nextSetBit(j)) != -1) { - result[i++] = j++; + result[i++] = j++; } return result; } diff --git a/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java b/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java index bbb93de28..1c39a7731 100644 --- a/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -49,7 +49,7 @@ public class LocaleUtilsTest { private static final Locale LOCALE_FR = new Locale("fr", ""); private static final Locale LOCALE_FR_CA = new Locale("fr", "CA"); private static final Locale LOCALE_QQ = new Locale("qq", ""); - private static final Locale LOCALE_QQ_ZZ = new Locale("qq", "ZZ"); + private static final Locale LOCALE_QQ_ZZ = new Locale("qq", "ZZ"); @Before public void setUp() throws Exception { @@ -111,7 +111,7 @@ public class LocaleUtilsTest { * @param variant of the resulting Locale */ private static void assertValidToLocale( - final String localeString, final String language, + final String localeString, final String language, final String country, final String variant) { final Locale locale = LocaleUtils.toLocale(localeString); assertNotNull("valid locale", locale); @@ -126,7 +126,7 @@ public class LocaleUtilsTest { @Test public void testToLocale_1Part() { assertNull(LocaleUtils.toLocale(null)); - + assertValidToLocale("us"); assertValidToLocale("fr"); assertValidToLocale("de"); @@ -152,7 +152,7 @@ public class LocaleUtilsTest { LocaleUtils.toLocale("u#"); fail("Should fail if not lowercase"); } catch (final IllegalArgumentException iae) {} - + try { LocaleUtils.toLocale("u"); fail("Must be 2 chars if less than 5"); @@ -162,7 +162,7 @@ public class LocaleUtilsTest { LocaleUtils.toLocale("uu_U"); fail("Must be 2 chars if less than 5"); } catch (final IllegalArgumentException iae) {} - } + } /** * Test toLocale() method. @@ -172,7 +172,7 @@ public class LocaleUtilsTest { assertValidToLocale("us_EN", "us", "EN"); //valid though doesn't exist assertValidToLocale("us_ZH", "us", "ZH"); - + try { LocaleUtils.toLocale("us-EN"); fail("Should fail as not underscore"); @@ -197,7 +197,7 @@ public class LocaleUtilsTest { LocaleUtils.toLocale("us_E3"); fail("Should fail second part not uppercase"); } catch (final IllegalArgumentException iae) {} - } + } /** * Test toLocale() method. @@ -214,7 +214,7 @@ public class LocaleUtilsTest { assertValidToLocale("us_EN_a", "us", "EN", "A"); assertValidToLocale("us_EN_SFsafdFDsdfF", "us", "EN", "SFSAFDFDSDFF"); } - + try { LocaleUtils.toLocale("us_EN-a"); fail("Should fail as not underscore"); @@ -237,7 +237,7 @@ public class LocaleUtilsTest { final List<Locale> localeList = defaultLocale == null ? LocaleUtils.localeLookupList(locale) : LocaleUtils.localeLookupList(locale, defaultLocale); - + assertEquals(expected.length, localeList.size()); assertEquals(Arrays.asList(expected), localeList); assertUnmodifiableCollection(localeList); @@ -262,19 +262,19 @@ public class LocaleUtilsTest { LOCALE_EN_US_ZZZZ, LOCALE_EN_US, LOCALE_EN}); - } + } /** * Test localeLookupList() method. */ @Test public void testLocaleLookupList_LocaleLocale() { - assertLocaleLookupList(LOCALE_QQ, LOCALE_QQ, + assertLocaleLookupList(LOCALE_QQ, LOCALE_QQ, new Locale[]{LOCALE_QQ}); - assertLocaleLookupList(LOCALE_EN, LOCALE_EN, + assertLocaleLookupList(LOCALE_EN, LOCALE_EN, new Locale[]{LOCALE_EN}); - - assertLocaleLookupList(LOCALE_EN_US, LOCALE_EN_US, + + assertLocaleLookupList(LOCALE_EN_US, LOCALE_EN_US, new Locale[]{ LOCALE_EN_US, LOCALE_EN}); @@ -288,7 +288,7 @@ public class LocaleUtilsTest { LOCALE_EN_US, LOCALE_EN, LOCALE_QQ_ZZ}); - + assertLocaleLookupList(LOCALE_EN_US_ZZZZ, null, new Locale[] { LOCALE_EN_US_ZZZZ, @@ -329,7 +329,7 @@ public class LocaleUtilsTest { assertNotNull(list); assertSame(list, list2); assertUnmodifiableCollection(list); - + final Locale[] jdkLocaleArray = Locale.getAvailableLocales(); final List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray); assertEquals(jdkLocaleList, list); @@ -346,7 +346,7 @@ public class LocaleUtilsTest { assertNotNull(set); assertSame(set, set2); assertUnmodifiableCollection(set); - + final Locale[] jdkLocaleArray = Locale.getAvailableLocales(); final List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray); final Set<Locale> jdkLocaleSet = new HashSet<>(jdkLocaleList); @@ -369,10 +369,10 @@ public class LocaleUtilsTest { assertEquals(set.contains(LOCALE_QQ), LocaleUtils.isAvailableLocale(LOCALE_QQ)); assertEquals(set.contains(LOCALE_QQ_ZZ), LocaleUtils.isAvailableLocale(LOCALE_QQ_ZZ)); } - + /** * Test for 3-chars locale, further details at LANG-915 - * + * */ @Test public void testThreeCharsLocale() { @@ -387,9 +387,9 @@ public class LocaleUtilsTest { //----------------------------------------------------------------------- /** - * Make sure the language by country is correct. It checks that - * the LocaleUtils.languagesByCountry(country) call contains the - * array of languages passed in. It may contain more due to JVM + * Make sure the language by country is correct. It checks that + * the LocaleUtils.languagesByCountry(country) call contains the + * array of languages passed in. It may contain more due to JVM * variations. * * @param country @@ -437,9 +437,9 @@ public class LocaleUtilsTest { //----------------------------------------------------------------------- /** - * Make sure the country by language is correct. It checks that - * the LocaleUtils.countryByLanguage(language) call contains the - * array of countries passed in. It may contain more due to JVM + * Make sure the country by language is correct. It checks that + * the LocaleUtils.countryByLanguage(language) call contains the + * array of countries passed in. It may contain more due to JVM * variations. * * diff --git a/src/test/java/org/apache/commons/lang3/NotImplementedExceptionTest.java b/src/test/java/org/apache/commons/lang3/NotImplementedExceptionTest.java index ff422ae61..86f4fab8d 100644 --- a/src/test/java/org/apache/commons/lang3/NotImplementedExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/NotImplementedExceptionTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java index a5f7e1a8c..c1d6dcc0e 100644 --- a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -75,13 +75,13 @@ public class ObjectUtilsTest { assertEquals("123", firstNonNullGenerics); assertEquals("123", ObjectUtils.firstNonNull("123", null, "456", null)); assertSame(Boolean.TRUE, ObjectUtils.firstNonNull(Boolean.TRUE)); - + // Explicitly pass in an empty array of Object type to ensure compiler doesn't complain of unchecked generic array creation assertNull(ObjectUtils.firstNonNull(new Object[0])); - + // Cast to Object in line below ensures compiler doesn't complain of unchecked generic array creation assertNull(ObjectUtils.firstNonNull(null, null)); - + assertNull(ObjectUtils.firstNonNull((Object) null)); assertNull(ObjectUtils.firstNonNull((Object[]) null)); } @@ -159,13 +159,13 @@ public class ObjectUtilsTest { public void testHashCodeMulti_multiple_likeList() { final List<Object> list0 = new ArrayList<>(Arrays.asList(new Object[0])); assertEquals(list0.hashCode(), ObjectUtils.hashCodeMulti()); - + final List<Object> list1 = new ArrayList<Object>(Arrays.asList("a")); assertEquals(list1.hashCode(), ObjectUtils.hashCodeMulti("a")); - + final List<Object> list2 = new ArrayList<Object>(Arrays.asList("a", "b")); assertEquals(list2.hashCode(), ObjectUtils.hashCodeMulti("a", "b")); - + final List<Object> list3 = new ArrayList<Object>(Arrays.asList("a", "b", "c")); assertEquals(list3.hashCode(), ObjectUtils.hashCodeMulti("a", "b", "c")); } @@ -190,7 +190,7 @@ public class ObjectUtilsTest { } catch(final NullPointerException npe) { } } - + @Test public void testIdentityToStringStringBuilder() { assertEquals(null, ObjectUtils.identityToString(null)); @@ -199,9 +199,9 @@ public class ObjectUtilsTest { ObjectUtils.identityToString(FOO)); final Integer i = Integer.valueOf(90); final String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i)); - + assertEquals(expected, ObjectUtils.identityToString(i)); - + final StringBuilder builder = new StringBuilder(); ObjectUtils.identityToString(builder, i); assertEquals(expected, builder.toString()); @@ -211,14 +211,14 @@ public class ObjectUtilsTest { fail("NullPointerException expected"); } catch(final NullPointerException npe) { } - + try { ObjectUtils.identityToString(new StringBuilder(), null); fail("NullPointerException expected"); } catch(final NullPointerException npe) { } } - + @Test public void testIdentityToStringStrBuilder() { final Integer i = Integer.valueOf(102); @@ -233,14 +233,14 @@ public class ObjectUtilsTest { fail("NullPointerException expected"); } catch(final NullPointerException npe) { } - + try { ObjectUtils.identityToString(new StrBuilder(), null); fail("NullPointerException expected"); } catch(final NullPointerException npe) { } } - + @Test public void testIdentityToStringAppendable() { final Integer i = Integer.valueOf(121); @@ -253,7 +253,7 @@ public class ObjectUtilsTest { } catch(final IOException ex) { fail("IOException unexpected"); } - + try { ObjectUtils.identityToString((Appendable)null, "tmp"); fail("NullPointerException expected"); @@ -298,12 +298,12 @@ public class ObjectUtilsTest { final Date nonNullComparable1 = calendar.getTime(); final Date nonNullComparable2 = calendar.getTime(); final String[] nullArray = null; - + calendar.set( Calendar.YEAR, calendar.get( Calendar.YEAR ) -1 ); final Date minComparable = calendar.getTime(); - + assertNotSame( nonNullComparable1, nonNullComparable2 ); - + assertNull(ObjectUtils.max( (String) null ) ); assertNull(ObjectUtils.max( nullArray ) ); assertSame( nonNullComparable1, ObjectUtils.max( null, nonNullComparable1 ) ); @@ -324,12 +324,12 @@ public class ObjectUtilsTest { final Date nonNullComparable1 = calendar.getTime(); final Date nonNullComparable2 = calendar.getTime(); final String[] nullArray = null; - + calendar.set( Calendar.YEAR, calendar.get( Calendar.YEAR ) -1 ); final Date minComparable = calendar.getTime(); - + assertNotSame( nonNullComparable1, nonNullComparable2 ); - + assertNull(ObjectUtils.min( (String) null ) ); assertNull(ObjectUtils.min( nullArray ) ); assertSame( nonNullComparable1, ObjectUtils.min( null, nonNullComparable1 ) ); @@ -358,7 +358,7 @@ public class ObjectUtilsTest { assertEquals("Null one false", -1, ObjectUtils.compare(nullValue, one)); assertEquals("Null one true", 1, ObjectUtils.compare(nullValue, one, true)); - + assertEquals("one Null false", 1, ObjectUtils.compare(one, nullValue)); assertEquals("one Null true", -1, ObjectUtils.compare(one, nullValue, true)); diff --git a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java index 68d10d2b0..d3ed6312d 100644 --- a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -50,7 +50,7 @@ public class RandomStringUtilsTest { assertTrue(Modifier.isPublic(RandomStringUtils.class.getModifiers())); assertFalse(Modifier.isFinal(RandomStringUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- /** * Test the implementation @@ -62,12 +62,12 @@ public class RandomStringUtilsTest { String r2 = RandomStringUtils.random(50); assertEquals("random(50) length", 50, r2.length()); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.randomAscii(50); assertEquals("randomAscii(50) length", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { assertTrue("char between 32 and 127", r1.charAt(i) >= 32 && r1.charAt(i) <= 127); - } + } r2 = RandomStringUtils.randomAscii(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); @@ -78,7 +78,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.randomAlphabetic(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.randomAlphanumeric(50); assertEquals("randomAlphanumeric(50)", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { @@ -86,7 +86,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.randomAlphabetic(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.randomGraph(50); assertEquals("randomGraph(50) length", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { @@ -94,7 +94,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.randomGraph(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.randomNumeric(50); assertEquals("randomNumeric(50)", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { @@ -102,7 +102,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.randomNumeric(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.randomPrint(50); assertEquals("randomPrint(50) length", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { @@ -110,7 +110,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.randomPrint(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + String set = "abcdefg"; r1 = RandomStringUtils.random(50, set); assertEquals("random(50, \"abcdefg\")", 50, r1.length()); @@ -119,13 +119,13 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.random(50, set); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.random(50, (String) null); assertEquals("random(50) length", 50, r1.length()); r2 = RandomStringUtils.random(50, (String) null); assertEquals("random(50) length", 50, r2.length()); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + set = "stuvwxyz"; r1 = RandomStringUtils.random(50, set.toCharArray()); assertEquals("random(50, \"stuvwxyz\")", 50, r1.length()); @@ -134,7 +134,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.random(50, set); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.random(50, (char[]) null); assertEquals("random(50) length", 50, r1.length()); r2 = RandomStringUtils.random(50, (char[]) null); @@ -216,11 +216,11 @@ public class RandomStringUtilsTest { fail(); } catch (final IllegalArgumentException ex) {} } - + /** * Make sure boundary alphanumeric characters are generated by randomAlphaNumeric * This test will fail randomly with probability = 6 * (61/62)**1000 ~ 5.2E-7 - */ + */ @Test public void testRandomAlphaNumeric() { final char[] testChars = {'a', 'z', 'A', 'Z', '0', '9'}; @@ -235,16 +235,16 @@ public class RandomStringUtilsTest { } for (int i = 0; i < testChars.length; i++) { if (!found[i]) { - fail("alphanumeric character not generated in 1000 attempts: " + fail("alphanumeric character not generated in 1000 attempts: " + testChars[i] +" -- repeated failures indicate a problem "); } } } - + /** * Make sure '0' and '9' are generated by randomNumeric * This test will fail randomly with probability = 2 * (9/10)**1000 ~ 3.5E-46 - */ + */ @Test public void testRandomNumeric() { final char[] testChars = {'0','9'}; @@ -259,16 +259,16 @@ public class RandomStringUtilsTest { } for (int i = 0; i < testChars.length; i++) { if (!found[i]) { - fail("digit not generated in 1000 attempts: " + fail("digit not generated in 1000 attempts: " + testChars[i] +" -- repeated failures indicate a problem "); } - } + } } - + /** * Make sure boundary alpha characters are generated by randomAlphabetic * This test will fail randomly with probability = 4 * (51/52)**1000 ~ 1.58E-8 - */ + */ @Test public void testRandomAlphabetic() { final char[] testChars = {'a', 'z', 'A', 'Z'}; @@ -283,16 +283,16 @@ public class RandomStringUtilsTest { } for (int i = 0; i < testChars.length; i++) { if (!found[i]) { - fail("alphanumeric character not generated in 1000 attempts: " + fail("alphanumeric character not generated in 1000 attempts: " + testChars[i] +" -- repeated failures indicate a problem "); } } } - + /** * Make sure 32 and 127 are generated by randomNumeric * This test will fail randomly with probability = 2*(95/96)**1000 ~ 5.7E-5 - */ + */ @Test public void testRandomAscii() { final char[] testChars = {(char) 32, (char) 126}; @@ -307,11 +307,11 @@ public class RandomStringUtilsTest { } for (int i = 0; i < testChars.length; i++) { if (!found[i]) { - fail("ascii character not generated in 1000 attempts: " - + (int) testChars[i] + + fail("ascii character not generated in 1000 attempts: " + + (int) testChars[i] + " -- repeated failures indicate a problem"); } - } + } } @Test @@ -463,8 +463,8 @@ public class RandomStringUtilsTest { assertThat("min generated, may fail randomly rarely", minCreatedLength, is(expectedMinLengthInclusive)); assertThat("max generated, may fail randomly rarely", maxCreatedLength, is(expectedMaxLengthExclusive - 1)); } - - /** + + /** * Test homogeneity of random strings generated -- * i.e., test that characters show up with expected frequencies * in generated strings. Will fail randomly about 1 in 1000 times. @@ -487,12 +487,12 @@ public class RandomStringUtilsTest { default: {fail("generated character not in set");} } } - } + } // Perform chi-square test with df = 3-1 = 2, testing at .001 level assertTrue("test homogeneity -- will fail about 1 in 1000 times", - chiSquare(expected,counts) < 13.82); + chiSquare(expected,counts) < 13.82); } - + /** * Computes Chi-Square statistic given observed and expected counts * @param observed array of observed frequency counts @@ -506,7 +506,7 @@ public class RandomStringUtilsTest { sumSq += dev * dev / expected[i]; } return sumSq; - } + } /** * Checks if the string got by {@link RandomStringUtils#random(int)} @@ -534,20 +534,20 @@ public class RandomStringUtilsTest { // just to be complete assertEquals(orig, copy); } - - + + /** * Test for LANG-1286. Creates situation where old code would * overflow a char and result in a code point outside the specified * range. - * + * * @throws Exception */ @Test public void testCharOverflow() throws Exception { int start = Character.MAX_VALUE; int end = Integer.MAX_VALUE; - + @SuppressWarnings("serial") Random fixedRandom = new Random() { @Override @@ -556,7 +556,7 @@ public class RandomStringUtilsTest { return super.nextInt(n - 1) + 1; } }; - + String result = RandomStringUtils.random(2, start, end, false, false, null, fixedRandom); int c = result.codePointAt(0); assertTrue(String.format("Character '%d' not in range [%d,%d).", c, start, end), c >= start && c < end); diff --git a/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java b/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java index ddbaab186..3f9604f9b 100644 --- a/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java @@ -125,7 +125,7 @@ public class RandomUtilsTest { public void testNextIntMinimalRange() { assertEquals(42, RandomUtils.nextInt(42, 42)); } - + /** * Tests next int range. */ @@ -144,23 +144,23 @@ public class RandomUtilsTest { assertTrue(randomResult > 0); assertTrue(randomResult < Integer.MAX_VALUE); } - + /** * Test next double range with minimal range. */ @Test public void testNextDoubleMinimalRange() { assertEquals(42.1, RandomUtils.nextDouble(42.1, 42.1), DELTA); - } - + } + /** * Test next float range with minimal range. */ @Test public void testNextFloatMinimalRange() { assertEquals(42.1f, RandomUtils.nextFloat(42.1f, 42.1f), DELTA); - } - + } + /** * Tests next double range. */ @@ -179,7 +179,7 @@ public class RandomUtilsTest { assertTrue(randomResult > 0); assertTrue(randomResult < Double.MAX_VALUE); } - + /** * Tests next float range. */ @@ -206,7 +206,7 @@ public class RandomUtilsTest { public void testNextLongMinimalRange() { assertEquals(42L, RandomUtils.nextLong(42L, 42L)); } - + /** * Tests next long range. */ @@ -225,7 +225,7 @@ public class RandomUtilsTest { assertTrue(randomResult > 0); assertTrue(randomResult < Long.MAX_VALUE); } - + /** * Tests extreme range. */ @@ -234,7 +234,7 @@ public class RandomUtilsTest { final int result = RandomUtils.nextInt(0, Integer.MAX_VALUE); assertTrue(result >= 0 && result < Integer.MAX_VALUE); } - + /** * Tests extreme range. */ @@ -242,8 +242,8 @@ public class RandomUtilsTest { public void testExtremeRangeLong() { final long result = RandomUtils.nextLong(0, Long.MAX_VALUE); assertTrue(result >= 0 && result < Long.MAX_VALUE); - } - + } + /** * Tests extreme range. */ @@ -251,8 +251,8 @@ public class RandomUtilsTest { public void testExtremeRangeFloat() { final float result = RandomUtils.nextFloat(0, Float.MAX_VALUE); assertTrue(result >= 0f && result <= Float.MAX_VALUE); - } - + } + /** * Tests extreme range. */ @@ -260,5 +260,5 @@ public class RandomUtilsTest { public void testExtremeRangeDouble() { final double result = RandomUtils.nextDouble(0, Double.MAX_VALUE); assertTrue(result >= 0 && result <= Double.MAX_VALUE); - } + } } diff --git a/src/test/java/org/apache/commons/lang3/RangeTest.java b/src/test/java/org/apache/commons/lang3/RangeTest.java index 03ed509ac..a8d7e1b2b 100644 --- a/src/test/java/org/apache/commons/lang3/RangeTest.java +++ b/src/test/java/org/apache/commons/lang3/RangeTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java index caa648b41..d9a5bde86 100644 --- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,7 +47,7 @@ public class SerializationUtilsTest { static final String CLASS_NOT_FOUND_MESSAGE = "ClassNotFoundSerialization.readObject fake exception"; protected static final String SERIALIZE_IO_EXCEPTION_MESSAGE = "Anonymous OutputStream I/O exception"; - + private String iString; private Integer iInteger; private HashMap<Object, Object> iMap; @@ -72,29 +72,29 @@ public class SerializationUtilsTest { assertTrue(Modifier.isPublic(SerializationUtils.class.getModifiers())); assertFalse(Modifier.isFinal(SerializationUtils.class.getModifiers())); } - + @Test public void testException() { SerializationException serEx; final Exception ex = new Exception(); - + serEx = new SerializationException(); assertSame(null, serEx.getMessage()); assertSame(null, serEx.getCause()); - + serEx = new SerializationException("Message"); assertSame("Message", serEx.getMessage()); assertSame(null, serEx.getCause()); - + serEx = new SerializationException(ex); assertEquals("java.lang.Exception", serEx.getMessage()); assertSame(ex, serEx.getCause()); - + serEx = new SerializationException("Message", ex); assertSame("Message", serEx.getMessage()); assertSame(ex, serEx.getCause()); } - + //----------------------------------------------------------------------- @Test @@ -166,7 +166,7 @@ public class SerializationUtilsTest { } fail(); } - + @Test public void testSerializeIOException() throws Exception { // forces an IOException when the ObjectOutputStream is created, to test not closing the stream @@ -268,13 +268,13 @@ public class SerializationUtilsTest { assertEquals("java.lang.ClassNotFoundException: " + CLASS_NOT_FOUND_MESSAGE, se.getMessage()); } } - - @Test + + @Test public void testRoundtrip() { final HashMap<Object, Object> newMap = SerializationUtils.roundtrip(iMap); assertEquals(iMap, newMap); } - + //----------------------------------------------------------------------- @Test @@ -408,7 +408,7 @@ public class SerializationUtilsTest { } fail(); } - + @Test public void testPrimitiveTypeClassSerialization() { final Class<?>[] primitiveTypes = { byte.class, short.class, int.class, long.class, float.class, double.class, diff --git a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java index df188a697..47e4fce3e 100644 --- a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,7 +51,7 @@ public class StringEscapeUtilsTest { assertTrue(Modifier.isPublic(StringEscapeUtils.class.getModifiers())); assertFalse(Modifier.isFinal(StringEscapeUtils.class.getModifiers())); } - + @Test public void testEscapeJava() throws IOException { assertEquals(null, StringEscapeUtils.escapeJava(null)); @@ -69,7 +69,7 @@ public class StringEscapeUtilsTest { fail(); } catch (final IllegalArgumentException ex) { } - + assertEscapeJava("empty string", "", ""); assertEscapeJava(FOO, FOO); assertEscapeJava("tab", "\\t", "\t"); @@ -106,7 +106,7 @@ public class StringEscapeUtilsTest { */ assertEquals(expected, actual); } - + private void assertEscapeJava(final String escaped, final String original) throws IOException { assertEscapeJava(null, escaped, original); } @@ -143,7 +143,7 @@ public class StringEscapeUtilsTest { fail(); } catch (final RuntimeException ex) { } - + assertUnescapeJava("", ""); assertUnescapeJava("test", "test"); assertUnescapeJava("\ntest\b", "\\ntest\\b"); @@ -194,9 +194,9 @@ public class StringEscapeUtilsTest { fail(); } catch (final IllegalArgumentException ex) { } - + assertEquals("He didn\\'t say, \\\"stop!\\\"", StringEscapeUtils.escapeEcmaScript("He didn't say, \"stop!\"")); - assertEquals("document.getElementById(\\\"test\\\").value = \\'<script>alert(\\'aaa\\');<\\/script>\\';", + assertEquals("document.getElementById(\\\"test\\\").value = \\'<script>alert(\\'aaa\\');<\\/script>\\';", StringEscapeUtils.escapeEcmaScript("document.getElementById(\"test\").value = '<script>alert('aaa');</script>';")); } @@ -265,7 +265,7 @@ public class StringEscapeUtilsTest { final String expected = element[2]; final String original = element[1]; assertEquals(message, expected, StringEscapeUtils.unescapeHtml4(original)); - + final StringWriter sw = new StringWriter(); try { StringEscapeUtils.UNESCAPE_HTML4.translate(original, sw); @@ -276,9 +276,9 @@ public class StringEscapeUtilsTest { } // \u00E7 is a cedilla (c with wiggle under) // note that the test string must be 7-bit-clean (Unicode escaped) or else it will compile incorrectly - // on some locales + // on some locales assertEquals("funny chars pass through OK", "Fran\u00E7ais", StringEscapeUtils.unescapeHtml4("Fran\u00E7ais")); - + assertEquals("Hello&;World", StringEscapeUtils.unescapeHtml4("Hello&;World")); assertEquals("Hello&#;World", StringEscapeUtils.unescapeHtml4("Hello&#;World")); assertEquals("Hello&# ;World", StringEscapeUtils.unescapeHtml4("Hello&# ;World")); @@ -287,7 +287,7 @@ public class StringEscapeUtilsTest { @Test public void testUnescapeHexCharsHtml() { - // Simple easy to grok test + // Simple easy to grok test assertEquals("hex number unescape", "\u0080\u009F", StringEscapeUtils.unescapeHtml4("€Ÿ")); assertEquals("hex number unescape", "\u0080\u009F", StringEscapeUtils.unescapeHtml4("€Ÿ")); // Test all Character values: @@ -350,7 +350,7 @@ public class StringEscapeUtilsTest { } assertEquals("XML was unescaped incorrectly", "<abc>", sw.toString() ); } - + @Test public void testEscapeXml10() throws Exception { assertEquals("a<b>c"d'e&f", StringEscapeUtils.escapeXml10("a<b>c\"d'e&f")); @@ -365,7 +365,7 @@ public class StringEscapeUtilsTest { assertEquals("XML 1.0 should escape #x7f-#x84 | #x86 - #x9f, for XML 1.1 compatibility", "a\u007e„\u0085†Ÿ\u00a0b", StringEscapeUtils.escapeXml10("a\u007e\u007f\u0084\u0085\u0086\u009f\u00a0b")); } - + @Test public void testEscapeXml11() throws Exception { assertEquals("a<b>c"d'e&f", StringEscapeUtils.escapeXml11("a<b>c\"d'e&f")); @@ -384,7 +384,7 @@ public class StringEscapeUtilsTest { } /** - * Tests Supplementary characters. + * Tests Supplementary characters. * <p> * From http://www.w3.org/International/questions/qa-escapes * </p> @@ -400,7 +400,7 @@ public class StringEscapeUtilsTest { */ @Test public void testEscapeXmlSupplementaryCharacters() { - final 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", "𣎴", @@ -409,7 +409,7 @@ public class StringEscapeUtilsTest { assertEquals("Supplementary characters mixed with basic characters should be encoded correctly", "a b c 𣎴", escapeXml.translate("a b c \uD84C\uDFB4")); } - + @Test public void testEscapeXmlAllCharacters() { // http://www.w3.org/TR/xml/#charsets says: @@ -427,7 +427,7 @@ public class StringEscapeUtilsTest { assertEquals("Hello World! Ain't this great?", escapeXml.translate("Hello World! Ain't this great?")); assertEquals("", escapeXml.translate("\u000E\u000F\u0018\u0019")); } - + /** * Reverse of the above. * @@ -441,7 +441,7 @@ public class StringEscapeUtilsTest { assertEquals("Supplementary characters mixed with basic characters should be decoded correctly", "a b c \uD84C\uDFB4", StringEscapeUtils.unescapeXml("a b c 𣎴") ); } - + // Tests issue #38569 // http://issues.apache.org/bugzilla/show_bug.cgi?id=38569 @Test @@ -583,7 +583,7 @@ public class StringEscapeUtilsTest { /** * Tests https://issues.apache.org/jira/browse/LANG-708 - * + * * @throws IOException * if an I/O error occurs */ diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java index 6fedb92ca..5cc635fe9 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java @@ -211,7 +211,7 @@ public class StringUtilsContainsTest { assertFalse(StringUtils.containsAny(CharU20000, CharU20001)); assertFalse(StringUtils.containsAny(CharU20001, CharU20000)); } - + @Test public void testContainsAny_StringStringArray() { assertFalse(StringUtils.containsAny(null, (String[]) null)); diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java index 8e88f6ea3..8e872c3e7 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java index 91c0451fe..22cf9aabb 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java @@ -294,7 +294,7 @@ public class StringUtilsEqualsIndexOfTest { assertEquals(2, StringUtils.indexOf("aabaabaa", 'b', -1)); assertEquals(5, StringUtils.indexOf(new StringBuilder("aabaabaa"), 'b', 3)); - + //LANG-1300 tests go here final int CODE_POINT = 0x2070E; StringBuilder builder = new StringBuilder(); @@ -545,7 +545,7 @@ public class StringUtilsEqualsIndexOfTest { assertEquals(0, StringUtils.lastIndexOf("aabaabaa", 'a', 0)); assertEquals(2, StringUtils.lastIndexOf(new StringBuilder("aabaabaa"), 'b', 2)); - + //LANG-1300 addition test final int CODE_POINT = 0x2070E; StringBuilder builder = new StringBuilder(); @@ -784,7 +784,7 @@ public class StringUtilsEqualsIndexOfTest { @Test public void testLANG1193() { - assertEquals(0, StringUtils.ordinalIndexOf("abc", "ab", 1)); + assertEquals(0, StringUtils.ordinalIndexOf("abc", "ab", 1)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsIsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsIsTest.java index 6932afb46..4160f1a5d 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsIsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsIsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -127,7 +127,7 @@ public class StringUtilsIsTest { assertTrue(StringUtils.isAsciiPrintable("=?iso-8859-1?Q?G=FClc=FC?=")); assertFalse(StringUtils.isAsciiPrintable("G\u00fclc\u00fc")); } - + @Test public void testIsNumeric() { assertFalse(StringUtils.isNumeric(null)); diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java index ec72c0db9..2eb5ddb58 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -99,7 +99,7 @@ public class StringUtilsStartsEndsWithTest { assertTrue("StringUtils.startsWithAny(abcxyz, StringBuilder(xyz), StringBuffer(abc))", StringUtils.startsWithAny("abcxyz", new StringBuilder("xyz"), new StringBuffer("abc"))); assertTrue("StringUtils.startsWithAny(StringBuffer(abcxyz), StringBuilder(xyz), StringBuffer(abc))", StringUtils.startsWithAny(new StringBuffer("abcxyz"), new StringBuilder("xyz"), new StringBuffer("abc"))); } - + /** * Test StringUtils.endsWith() @@ -183,7 +183,7 @@ public class StringUtilsStartsEndsWithTest { /* * Type null of the last argument to method endsWithAny(CharSequence, CharSequence...) - * doesn't exactly match the vararg parameter type. + * doesn't exactly match the vararg parameter type. * Cast to CharSequence[] to confirm the non-varargs invocation, * or pass individual arguments of type CharSequence for a varargs invocation. * diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java index f6986eedb..66d03f3db 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,7 +39,7 @@ public class StringUtilsSubstringTest { assertEquals(null, StringUtils.substring(null, 0)); assertEquals("", StringUtils.substring("", 0)); assertEquals("", StringUtils.substring("", 2)); - + assertEquals("", StringUtils.substring(SENTENCE, 80)); assertEquals(BAZ, StringUtils.substring(SENTENCE, 8)); assertEquals(BAZ, StringUtils.substring(SENTENCE, -3)); @@ -54,7 +54,7 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.substring("abc", 3)); assertEquals("", StringUtils.substring("abc", 4)); } - + @Test public void testSubstring_StringIntInt() { assertEquals(null, StringUtils.substring(null, 0, 0)); @@ -62,7 +62,7 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.substring("", 0, 0)); assertEquals("", StringUtils.substring("", 1, 2)); assertEquals("", StringUtils.substring("", -2, -1)); - + assertEquals("", StringUtils.substring(SENTENCE, 8, 6)); assertEquals(FOO, StringUtils.substring(SENTENCE, 0, 3)); assertEquals("o", StringUtils.substring(SENTENCE, -9, 3)); @@ -72,50 +72,50 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.substring(SENTENCE, 2, 2)); assertEquals("b",StringUtils.substring("abc", -2, -1)); } - + @Test public void testLeft_String() { assertSame(null, StringUtils.left(null, -1)); assertSame(null, StringUtils.left(null, 0)); assertSame(null, StringUtils.left(null, 2)); - + assertEquals("", StringUtils.left("", -1)); assertEquals("", StringUtils.left("", 0)); assertEquals("", StringUtils.left("", 2)); - + assertEquals("", StringUtils.left(FOOBAR, -1)); assertEquals("", StringUtils.left(FOOBAR, 0)); assertEquals(FOO, StringUtils.left(FOOBAR, 3)); assertSame(FOOBAR, StringUtils.left(FOOBAR, 80)); } - + @Test public void testRight_String() { assertSame(null, StringUtils.right(null, -1)); assertSame(null, StringUtils.right(null, 0)); assertSame(null, StringUtils.right(null, 2)); - + assertEquals("", StringUtils.right("", -1)); assertEquals("", StringUtils.right("", 0)); assertEquals("", StringUtils.right("", 2)); - + assertEquals("", StringUtils.right(FOOBAR, -1)); assertEquals("", StringUtils.right(FOOBAR, 0)); assertEquals(BAR, StringUtils.right(FOOBAR, 3)); assertSame(FOOBAR, StringUtils.right(FOOBAR, 80)); } - + @Test public void testMid_String() { assertSame(null, StringUtils.mid(null, -1, 0)); assertSame(null, StringUtils.mid(null, 0, -1)); assertSame(null, StringUtils.mid(null, 3, 0)); assertSame(null, StringUtils.mid(null, 3, 2)); - + assertEquals("", StringUtils.mid("", 0, -1)); assertEquals("", StringUtils.mid("", 0, 0)); assertEquals("", StringUtils.mid("", 0, 2)); - + assertEquals("", StringUtils.mid(FOOBAR, 3, -1)); assertEquals("", StringUtils.mid(FOOBAR, 3, 0)); assertEquals("b", StringUtils.mid(FOOBAR, 3, 1)); @@ -126,7 +126,7 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.mid(FOOBAR, 9, 3)); assertEquals(FOO, StringUtils.mid(FOOBAR, -1, 3)); } - + //----------------------------------------------------------------------- @Test public void testSubstringBefore_StringString() { @@ -138,7 +138,7 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.substringBefore("", null)); assertEquals("", StringUtils.substringBefore("", "")); assertEquals("", StringUtils.substringBefore("", "XX")); - + assertEquals("foo", StringUtils.substringBefore("foo", null)); assertEquals("foo", StringUtils.substringBefore("foo", "b")); assertEquals("f", StringUtils.substringBefore("foot", "o")); @@ -147,18 +147,18 @@ public class StringUtilsSubstringTest { assertEquals("ab", StringUtils.substringBefore("abc", "c")); assertEquals("", StringUtils.substringBefore("abc", "")); } - + @Test public void testSubstringAfter_StringString() { assertEquals("barXXbaz", StringUtils.substringAfter("fooXXbarXXbaz", "XX")); - + assertEquals(null, StringUtils.substringAfter(null, null)); assertEquals(null, StringUtils.substringAfter(null, "")); assertEquals(null, StringUtils.substringAfter(null, "XX")); assertEquals("", StringUtils.substringAfter("", null)); assertEquals("", StringUtils.substringAfter("", "")); assertEquals("", StringUtils.substringAfter("", "XX")); - + assertEquals("", StringUtils.substringAfter("foo", null)); assertEquals("ot", StringUtils.substringAfter("foot", "o")); assertEquals("bc", StringUtils.substringAfter("abc", "a")); @@ -191,7 +191,7 @@ public class StringUtilsSubstringTest { assertEquals("a", StringUtils.substringBeforeLast("a", "")); assertEquals("", StringUtils.substringBeforeLast("a", "a")); } - + @Test public void testSubstringAfterLast_StringString() { assertEquals("baz", StringUtils.substringAfterLast("fooXXbarXXbaz", "XX")); @@ -211,8 +211,8 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.substringAfterLast("abc", "c")); assertEquals("", StringUtils.substringAfterLast("", "d")); assertEquals("", StringUtils.substringAfterLast("abc", "")); - } - + } + //----------------------------------------------------------------------- @Test public void testSubstringBetween_StringString() { @@ -227,7 +227,7 @@ public class StringUtilsSubstringTest { assertEquals("bc", StringUtils.substringBetween("abcabca", "a")); assertEquals("bar", StringUtils.substringBetween("\nbar\n", "\n")); } - + @Test public void testSubstringBetween_StringStringString() { assertEquals(null, StringUtils.substringBetween(null, "", "")); @@ -312,11 +312,11 @@ public class StringUtilsSubstringTest { assertEquals(0, StringUtils.countMatches("x", "")); assertEquals(0, StringUtils.countMatches("", "")); - assertEquals(3, + assertEquals(3, StringUtils.countMatches("one long someone sentence of one", "one")); - assertEquals(0, + assertEquals(0, StringUtils.countMatches("one long someone sentence of one", "two")); - assertEquals(4, + assertEquals(4, StringUtils.countMatches("oooooooooooo", "ooo")); } diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java index 2b49669f4..5cda0aff9 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -3204,7 +3204,7 @@ public class StringUtilsTest { assertNull(StringUtils.unwrap(null, null)); assertNull(StringUtils.unwrap(null, '\0')); assertNull(StringUtils.unwrap(null, '1')); - + assertEquals("abc", StringUtils.unwrap("abc", null)); assertEquals("abc", StringUtils.unwrap("\'abc\'", '\'')); assertEquals("abc", StringUtils.unwrap("AabcA", 'A')); @@ -3214,18 +3214,18 @@ public class StringUtilsTest { assertEquals("A#", StringUtils.unwrap("A#", '#')); assertEquals("ABA", StringUtils.unwrap("AABAA", 'A')); } - + @Test public void testToCodePoints() throws Exception { final int orphanedHighSurrogate = 0xD801; final int orphanedLowSurrogate = 0xDC00; final int supplementary = 0x2070E; - - final int[] codePoints = {'a', orphanedHighSurrogate, 'b','c', supplementary, + + final int[] codePoints = {'a', orphanedHighSurrogate, 'b','c', supplementary, 'd', orphanedLowSurrogate, 'e'}; final String s = new String(codePoints, 0, codePoints.length); assertArrayEquals(codePoints, StringUtils.toCodePoints(s)); - + assertNull(StringUtils.toCodePoints(null)); assertArrayEquals(ArrayUtils.EMPTY_INT_ARRAY, StringUtils.toCodePoints("")); } diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java index 1a558f584..d9fdb7487 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -74,10 +74,10 @@ public class StringUtilsTrimStripTest { assertEquals("", StringUtils.strip("")); assertEquals("", StringUtils.strip(" ")); assertEquals("abc", StringUtils.strip(" abc ")); - assertEquals(StringUtilsTest.NON_WHITESPACE, + assertEquals(StringUtilsTest.NON_WHITESPACE, StringUtils.strip(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE)); } - + @Test public void testStripToNull_String() { assertEquals(null, StringUtils.stripToNull(null)); @@ -85,10 +85,10 @@ public class StringUtilsTrimStripTest { assertEquals(null, StringUtils.stripToNull(" ")); assertEquals(null, StringUtils.stripToNull(StringUtilsTest.WHITESPACE)); assertEquals("ab c", StringUtils.stripToNull(" ab c ")); - assertEquals(StringUtilsTest.NON_WHITESPACE, + assertEquals(StringUtilsTest.NON_WHITESPACE, StringUtils.stripToNull(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE)); } - + @Test public void testStripToEmpty_String() { assertEquals("", StringUtils.stripToEmpty(null)); @@ -96,10 +96,10 @@ public class StringUtilsTrimStripTest { assertEquals("", StringUtils.stripToEmpty(" ")); assertEquals("", StringUtils.stripToEmpty(StringUtilsTest.WHITESPACE)); assertEquals("ab c", StringUtils.stripToEmpty(" ab c ")); - assertEquals(StringUtilsTest.NON_WHITESPACE, + assertEquals(StringUtilsTest.NON_WHITESPACE, StringUtils.stripToEmpty(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE)); } - + @Test public void testStrip_StringString() { // null strip @@ -107,7 +107,7 @@ public class StringUtilsTrimStripTest { assertEquals("", StringUtils.strip("", null)); assertEquals("", StringUtils.strip(" ", null)); assertEquals("abc", StringUtils.strip(" abc ", null)); - assertEquals(StringUtilsTest.NON_WHITESPACE, + assertEquals(StringUtilsTest.NON_WHITESPACE, StringUtils.strip(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, null)); // "" strip @@ -116,13 +116,13 @@ public class StringUtilsTrimStripTest { assertEquals(" ", StringUtils.strip(" ", "")); assertEquals(" abc ", StringUtils.strip(" abc ", "")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.strip(StringUtilsTest.WHITESPACE, "")); - + // " " strip assertEquals(null, StringUtils.strip(null, " ")); assertEquals("", StringUtils.strip("", " ")); assertEquals("", StringUtils.strip(" ", " ")); assertEquals("abc", StringUtils.strip(" abc ", " ")); - + // "ab" strip assertEquals(null, StringUtils.strip(null, "ab")); assertEquals("", StringUtils.strip("", "ab")); @@ -131,7 +131,7 @@ public class StringUtilsTrimStripTest { assertEquals("c", StringUtils.strip("abcabab", "ab")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.strip(StringUtilsTest.WHITESPACE, "")); } - + @Test public void testStripStart_StringString() { // null stripStart @@ -139,7 +139,7 @@ public class StringUtilsTrimStripTest { assertEquals("", StringUtils.stripStart("", null)); assertEquals("", StringUtils.stripStart(" ", null)); assertEquals("abc ", StringUtils.stripStart(" abc ", null)); - assertEquals(StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, + assertEquals(StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, StringUtils.stripStart(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, null)); // "" stripStart @@ -148,13 +148,13 @@ public class StringUtilsTrimStripTest { assertEquals(" ", StringUtils.stripStart(" ", "")); assertEquals(" abc ", StringUtils.stripStart(" abc ", "")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.stripStart(StringUtilsTest.WHITESPACE, "")); - + // " " stripStart assertEquals(null, StringUtils.stripStart(null, " ")); assertEquals("", StringUtils.stripStart("", " ")); assertEquals("", StringUtils.stripStart(" ", " ")); assertEquals("abc ", StringUtils.stripStart(" abc ", " ")); - + // "ab" stripStart assertEquals(null, StringUtils.stripStart(null, "ab")); assertEquals("", StringUtils.stripStart("", "ab")); @@ -163,7 +163,7 @@ public class StringUtilsTrimStripTest { assertEquals("cabab", StringUtils.stripStart("abcabab", "ab")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.stripStart(StringUtilsTest.WHITESPACE, "")); } - + @Test public void testStripEnd_StringString() { // null stripEnd @@ -171,7 +171,7 @@ public class StringUtilsTrimStripTest { assertEquals("", StringUtils.stripEnd("", null)); assertEquals("", StringUtils.stripEnd(" ", null)); assertEquals(" abc", StringUtils.stripEnd(" abc ", null)); - assertEquals(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE, + assertEquals(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE, StringUtils.stripEnd(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, null)); // "" stripEnd @@ -180,13 +180,13 @@ public class StringUtilsTrimStripTest { assertEquals(" ", StringUtils.stripEnd(" ", "")); assertEquals(" abc ", StringUtils.stripEnd(" abc ", "")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.stripEnd(StringUtilsTest.WHITESPACE, "")); - + // " " stripEnd assertEquals(null, StringUtils.stripEnd(null, " ")); assertEquals("", StringUtils.stripEnd("", " ")); assertEquals("", StringUtils.stripEnd(" ", " ")); assertEquals(" abc", StringUtils.stripEnd(" abc ", " ")); - + // "ab" stripEnd assertEquals(null, StringUtils.stripEnd(null, "ab")); assertEquals("", StringUtils.stripEnd("", "ab")); @@ -211,7 +211,7 @@ public class StringUtilsTrimStripTest { assertArrayEquals(empty, StringUtils.stripAll(empty)); assertArrayEquals(foo, StringUtils.stripAll(fooSpace)); - + assertNull(StringUtils.stripAll(null, null)); assertArrayEquals(foo, StringUtils.stripAll(fooSpace, null)); assertArrayEquals(foo, StringUtils.stripAll(fooDots, ".")); @@ -222,11 +222,11 @@ public class StringUtilsTrimStripTest { final String cue = "\u00C7\u00FA\u00EA"; assertEquals( "Failed to strip accents from " + cue, "Cue", StringUtils.stripAccents(cue)); - final String lots = "\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C7\u00C8\u00C9" + - "\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D1\u00D2\u00D3" + + 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, - "AAAAAACEEEEIIIINOOOOOUUUUY", + assertEquals( "Failed to strip accents from " + lots, + "AAAAAACEEEEIIIINOOOOOUUUUY", StringUtils.stripAccents(lots)); assertNull( "Failed null safety", StringUtils.stripAccents(null) ); diff --git a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java index cc1d49286..3d9d024fe 100644 --- a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java @@ -43,7 +43,7 @@ import org.junit.Test; /** * Unit tests {@link org.apache.commons.lang3.SystemUtils}. - * + * * Only limited testing can be performed. */ public class SystemUtilsTest { 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 4ce0a1fa4..33deaa877 100644 --- a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -95,7 +95,7 @@ public class CompareToBuilderTest { this.t = t; } } - + @Test public void testReflectionCompare() { final TestObject o1 = new TestObject(4); @@ -124,16 +124,16 @@ public class CompareToBuilderTest { public void testReflectionHierarchyCompare() { testReflectionHierarchyCompare(false, null); } - + @Test public void testReflectionHierarchyCompareExcludeFields() { final String[] excludeFields = new String[] { "b" }; testReflectionHierarchyCompare(true, excludeFields); - + TestSubObject x; TestSubObject y; TestSubObject z; - + x = new TestSubObject(1, 1); y = new TestSubObject(2, 1); z = new TestSubObject(3, 1); @@ -144,7 +144,7 @@ public class CompareToBuilderTest { z = new TestSubObject(3, 1); assertXYZCompareOrder(x, y, z, true, excludeFields); } - + @Test public void testReflectionHierarchyCompareTransients() { testReflectionHierarchyCompare(true, null); @@ -157,27 +157,27 @@ public class CompareToBuilderTest { y = new TestTransientSubObject(2, 2); z = new TestTransientSubObject(3, 3); assertXYZCompareOrder(x, y, z, true, null); - + x = new TestTransientSubObject(1, 1); y = new TestTransientSubObject(1, 2); z = new TestTransientSubObject(1, 3); - assertXYZCompareOrder(x, y, z, true, null); + assertXYZCompareOrder(x, y, z, true, null); } - + private void assertXYZCompareOrder(final Object x, final Object y, final Object z, final boolean testTransients, final String[] excludeFields) { assertTrue(0 == CompareToBuilder.reflectionCompare(x, x, testTransients, null, excludeFields)); assertTrue(0 == CompareToBuilder.reflectionCompare(y, y, testTransients, null, excludeFields)); assertTrue(0 == CompareToBuilder.reflectionCompare(z, z, testTransients, null, excludeFields)); - + assertTrue(0 > CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields)); assertTrue(0 > CompareToBuilder.reflectionCompare(x, z, testTransients, null, excludeFields)); assertTrue(0 > CompareToBuilder.reflectionCompare(y, z, testTransients, null, excludeFields)); - + assertTrue(0 < CompareToBuilder.reflectionCompare(y, x, testTransients, null, excludeFields)); assertTrue(0 < CompareToBuilder.reflectionCompare(z, x, testTransients, null, excludeFields)); assertTrue(0 < CompareToBuilder.reflectionCompare(z, y, testTransients, null, excludeFields)); } - + private void testReflectionHierarchyCompare(final boolean testTransients, final String[] excludeFields) { final TestObject to1 = new TestObject(1); final TestObject to2 = new TestObject(2); @@ -185,26 +185,26 @@ public class CompareToBuilderTest { 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); assertReflectionCompareContract(tso1, tso1, tso1, false, excludeFields); assertReflectionCompareContract(tso1, tso2, tso3, false, excludeFields); assertReflectionCompareContract("1", "2", "3", false, excludeFields); - + assertTrue(0 != CompareToBuilder.reflectionCompare(tso1, new TestSubObject(1, 0), testTransients)); assertTrue(0 != CompareToBuilder.reflectionCompare(tso1, new TestSubObject(0, 1), testTransients)); // root class assertXYZCompareOrder(to1, to2, to3, true, null); - // subclass - assertXYZCompareOrder(tso1, tso2, tso3, true, null); + // subclass + assertXYZCompareOrder(tso1, tso2, tso3, true, null); } /** * See "Effective Java" under "Consider Implementing Comparable". - * - * @param x an object to compare + * + * @param x an object to compare * @param y an object to compare * @param z an object to compare * @param testTransients Whether to include transients in the comparison @@ -214,26 +214,26 @@ public class CompareToBuilderTest { // signum assertTrue(reflectionCompareSignum(x, y, testTransients, excludeFields) == -reflectionCompareSignum(y, x, testTransients, excludeFields)); - + // transitive - if (CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields) > 0 + if (CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields) > 0 && CompareToBuilder.reflectionCompare(y, z, testTransients, null, excludeFields) > 0){ assertTrue(CompareToBuilder.reflectionCompare(x, z, testTransients, null, excludeFields) > 0); } - + // un-named if (CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields) == 0) { assertTrue(reflectionCompareSignum(x, z, testTransients, excludeFields) == -reflectionCompareSignum(y, z, testTransients, excludeFields)); } - + // strongly recommended but not strictly required assertTrue(CompareToBuilder.reflectionCompare(x, y, testTransients) ==0 == EqualsBuilder.reflectionEquals(x, y, testTransients)); } - + /** * Returns the signum of the result of comparing x and y with * <code>CompareToBuilder.reflectionCompare</code> - * + * * @param lhs The "left-hand-side" of the comparison. * @param rhs The "right-hand-side" of the comparison. * @param testTransients Whether to include transients in the comparison @@ -243,7 +243,7 @@ public class CompareToBuilderTest { private int reflectionCompareSignum(final Object lhs, final Object rhs, final boolean testTransients, final String[] excludeFields) { return BigInteger.valueOf(CompareToBuilder.reflectionCompare(lhs, rhs, testTransients)).signum(); } - + @Test public void testAppendSuper() { final TestObject o1 = new TestObject(4); @@ -251,14 +251,14 @@ public class CompareToBuilderTest { 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); - + assertTrue(new CompareToBuilder().appendSuper(-1).append(o1, o1).toComparison() < 0); assertTrue(new CompareToBuilder().appendSuper(-1).append(o1, o2).toComparison() < 0); - + assertTrue(new CompareToBuilder().appendSuper(1).append(o1, o1).toComparison() > 0); assertTrue(new CompareToBuilder().appendSuper(1).append(o1, o2).toComparison() > 0); } - + @Test public void testObject() { final TestObject o1 = new TestObject(4); @@ -268,12 +268,12 @@ public class CompareToBuilderTest { o2.setA(5); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0); - + assertTrue(new CompareToBuilder().append(o1, null).toComparison() > 0); assertTrue(new CompareToBuilder().append((Object) null, null).toComparison() == 0); assertTrue(new CompareToBuilder().append(null, o1).toComparison() < 0); } - + @Test public void testObjectBuild() { final TestObject o1 = new TestObject(4); @@ -283,7 +283,7 @@ public class CompareToBuilderTest { o2.setA(5); assertTrue(new CompareToBuilder().append(o1, o2).build().intValue() < 0); assertTrue(new CompareToBuilder().append(o2, o1).build().intValue() > 0); - + assertTrue(new CompareToBuilder().append(o1, null).build().intValue() > 0); assertEquals(Integer.valueOf(0), new CompareToBuilder().append((Object) null, null).build()); assertTrue(new CompareToBuilder().append(null, o1).build().intValue() < 0); @@ -308,12 +308,12 @@ public class CompareToBuilderTest { o2 = "FREDA"; assertTrue(new CompareToBuilder().append(o1, o2, String.CASE_INSENSITIVE_ORDER).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1, String.CASE_INSENSITIVE_ORDER).toComparison() > 0); - + assertTrue(new CompareToBuilder().append(o1, null, String.CASE_INSENSITIVE_ORDER).toComparison() > 0); assertTrue(new CompareToBuilder().append(null, null, String.CASE_INSENSITIVE_ORDER).toComparison() == 0); assertTrue(new CompareToBuilder().append(null, o1, String.CASE_INSENSITIVE_ORDER).toComparison() < 0); } - + @Test public void testObjectComparatorNull() { final String o1 = "Fred"; @@ -323,7 +323,7 @@ public class CompareToBuilderTest { o2 = "Zebra"; assertTrue(new CompareToBuilder().append(o1, o2, null).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1, null).toComparison() > 0); - + assertTrue(new CompareToBuilder().append(o1, null, null).toComparison() > 0); assertTrue(new CompareToBuilder().append(null, null, null).toComparison() == 0); assertTrue(new CompareToBuilder().append(null, o1, null).toComparison() < 0); @@ -458,12 +458,12 @@ public class CompareToBuilderTest { obj3[0] = new TestObject(4); obj3[1] = new TestObject(5); obj3[2] = new TestObject(6); - + assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); - + obj1[1] = new TestObject(7); assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() > 0); assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); @@ -485,7 +485,7 @@ public class CompareToBuilderTest { obj3[0] = 5L; obj3[1] = 6L; obj3[2] = 7L; - + assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); @@ -703,7 +703,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -727,7 +727,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -751,7 +751,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -775,7 +775,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -799,7 +799,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -808,7 +808,7 @@ public class CompareToBuilderTest { assertTrue(new CompareToBuilder().append(array1, array2).toComparison() > 0); assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0); } - + @Test public void testMultiFloatArray() { final float[][] array1 = new float[2][2]; @@ -823,7 +823,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -847,7 +847,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -871,7 +871,7 @@ public class CompareToBuilderTest { } array3[1][2] = false; array3[1][2] = false; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -898,8 +898,8 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - - + + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -947,11 +947,11 @@ public class CompareToBuilderTest { array3[0] = new TestObject(4); array3[1] = new TestObject(5); array3[2] = new TestObject(6); - + 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); @@ -1161,5 +1161,5 @@ public class CompareToBuilderTest { assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() > 0); assertTrue(new CompareToBuilder().append(obj2, obj1).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 b8fd1f1a2..6bc92239e 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ public class DefaultToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.DEFAULT_STYLE); @@ -45,7 +45,7 @@ public class DefaultToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals(baseStr + "[]", new ToStringBuilder(base).toString()); @@ -55,12 +55,12 @@ public class DefaultToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[]", new ToStringBuilder(base).appendSuper("Integer@8888[]").toString()); assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").toString()); - + assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[]").append("a", "hello").toString()); assertEquals(baseStr + "[<null>,a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").append("a", "hello").toString()); assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java index 75bd48a5e..b2453a471 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java @@ -32,7 +32,7 @@ import org.junit.Test; * Unit tests {@link DiffBuilder}. */ public class DiffBuilderTest { - + private static final ToStringStyle SHORT_STYLE = ToStringStyle.SHORT_PREFIX_STYLE; private static class TypeTestClass implements Diffable<TypeTestClass> { @@ -78,20 +78,20 @@ public class DiffBuilderTest { .append("objectField", objectField, obj.objectField) .append("objectArrayField", objectArrayField, obj.objectArrayField) .build(); - } + } @Override public int hashCode() { return HashCodeBuilder.reflectionHashCode(this, false); } - + @Override public boolean equals(final Object obj) { return EqualsBuilder.reflectionEquals(this, obj, false); } } - - + + @Test public void testBoolean() { final TypeTestClass class1 = new TypeTestClass(); @@ -102,7 +102,7 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Boolean.class, diff.getType()); assertEquals(Boolean.TRUE, diff.getLeft()); - assertEquals(Boolean.FALSE, diff.getRight()); + assertEquals(Boolean.FALSE, diff.getRight()); } @Test @@ -113,13 +113,13 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.booleanArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.booleanArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.booleanArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.booleanArrayField), (Object[]) diff.getRight()); } - + @Test public void testByte() { final TypeTestClass class1 = new TypeTestClass(); @@ -129,9 +129,9 @@ public class DiffBuilderTest { assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); assertEquals(Byte.valueOf(class1.byteField), diff.getLeft()); - assertEquals(Byte.valueOf(class2.byteField), diff.getRight()); + assertEquals(Byte.valueOf(class2.byteField), diff.getRight()); } - + @Test public void testByteArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -140,9 +140,9 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.byteArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.byteArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.byteArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.byteArrayField), (Object[]) diff.getRight()); } @@ -157,8 +157,8 @@ public class DiffBuilderTest { assertEquals(Character.valueOf(class1.charField), diff.getLeft()); assertEquals(Character.valueOf(class2.charField), diff.getRight()); } - - + + @Test public void testCharArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -167,13 +167,13 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.charArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.charArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.charArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.charArrayField), (Object[]) diff.getRight()); } - - + + @Test public void testDouble() { final TypeTestClass class1 = new TypeTestClass(); @@ -184,9 +184,9 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Double.valueOf(class1.doubleField), diff.getLeft()); assertEquals(Double.valueOf(class2.doubleField), diff.getRight()); - } + } + - @Test public void testDoubleArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -195,12 +195,12 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.doubleArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.doubleArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.doubleArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.doubleArrayField), (Object[]) diff.getRight()); } - + @Test public void testFloat() { final TypeTestClass class1 = new TypeTestClass(); @@ -211,9 +211,9 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Float.valueOf(class1.floatField), diff.getLeft()); assertEquals(Float.valueOf(class2.floatField), diff.getRight()); - } + } + - @Test public void testFloatArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -222,13 +222,13 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.floatArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.floatArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.floatArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.floatArrayField), (Object[]) diff.getRight()); - } - - + } + + @Test public void testInt() { final TypeTestClass class1 = new TypeTestClass(); @@ -239,9 +239,9 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Integer.valueOf(class1.intField), diff.getLeft()); assertEquals(Integer.valueOf(class2.intField), diff.getRight()); - } + } + - @Test public void testIntArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -250,12 +250,12 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.intArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.intArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.intArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.intArrayField), (Object[]) diff.getRight()); } - + @Test public void testLong() { final TypeTestClass class1 = new TypeTestClass(); @@ -266,9 +266,9 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Long.valueOf(class1.longField), diff.getLeft()); assertEquals(Long.valueOf(class2.longField), diff.getRight()); - } + } + - @Test public void testLongArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -277,12 +277,12 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.longArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.longArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.longArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.longArrayField), (Object[]) diff.getRight()); } - + @Test public void testShort() { final TypeTestClass class1 = new TypeTestClass(); @@ -293,9 +293,9 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Short.valueOf(class1.shortField), diff.getLeft()); assertEquals(Short.valueOf(class2.shortField), diff.getRight()); - } + } + - @Test public void testShortArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -304,14 +304,14 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.shortArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.shortArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.shortArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.shortArrayField), (Object[]) diff.getRight()); } - + @Test - public void testObject() throws Exception { + public void testObject() throws Exception { final TypeTestClass class1 = new TypeTestClass(); final TypeTestClass class2 = new TypeTestClass(); class2.objectField = "Some string"; @@ -319,11 +319,11 @@ public class DiffBuilderTest { assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); assertEquals(class1.objectField, diff.getLeft()); - assertEquals(class2.objectField, diff.getRight()); + assertEquals(class2.objectField, diff.getRight()); } - /** - * Test that "left" and "right" are the same instance and are equal. + /** + * Test that "left" and "right" are the same instance and are equal. */ @Test public void testObjectsSameAndEqual() throws Exception { @@ -339,8 +339,8 @@ public class DiffBuilderTest { assertEquals(0, list.getNumberOfDiffs()); } - /** - * Test that "left" and "right" are the same instance but are equal. + /** + * Test that "left" and "right" are the same instance but are equal. */ @Test public void testObjectsNotSameButEqual() throws Exception { @@ -355,8 +355,8 @@ public class DiffBuilderTest { assertEquals(0, list.getNumberOfDiffs()); } - /** - * Test that "left" and "right" are not the same instance and are not equal. + /** + * Test that "left" and "right" are not the same instance and are not equal. */ @Test public void testObjectsNotSameNorEqual() throws Exception { @@ -381,8 +381,8 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertArrayEquals(class1.objectArrayField, (Object[]) diff.getLeft()); assertArrayEquals(class2.objectArrayField, (Object[]) diff.getRight()); - } - + } + @Test public void testObjectArrayEqual() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -391,9 +391,9 @@ public class DiffBuilderTest { class2.objectArrayField = new Object[] {"string", 1, 2}; final DiffResult list = class1.diff(class2); assertEquals(0, list.getNumberOfDiffs()); - } - - + } + + @Test public void testByteArrayEqualAsObject() throws Exception { final DiffResult list = new DiffBuilder("String1", "String2", SHORT_STYLE) @@ -410,7 +410,7 @@ public class DiffBuilderTest { assertEquals(0, list.getNumberOfDiffs()); } - + @Test public void testDiffResult() { final TypeTestClass class1 = new TypeTestClass(); @@ -425,25 +425,25 @@ public class DiffBuilderTest { } @Test(expected=IllegalArgumentException.class) - public void testNullLhs() { + public void testNullLhs() { new DiffBuilder(null, this, ToStringStyle.DEFAULT_STYLE); } - + @Test(expected=IllegalArgumentException.class) - public void testNullRhs() { + public void testNullRhs() { new DiffBuilder(this, null, ToStringStyle.DEFAULT_STYLE); - } - + } + @Test public void testSameObjectIgnoresAppends() { - final TypeTestClass testClass = new TypeTestClass(); + final TypeTestClass testClass = new TypeTestClass(); final DiffResult list = new DiffBuilder(testClass, testClass, SHORT_STYLE) .append("ignored", false, true) .build(); assertEquals(0, list.getNumberOfDiffs()); } - + @Test public void testSimilarObjectIgnoresAppends() { final TypeTestClass testClass1 = new TypeTestClass(); @@ -453,14 +453,14 @@ public class DiffBuilderTest { .build(); assertEquals(0, list.getNumberOfDiffs()); } - - + + @Test public void testStylePassedToDiffResult() { final TypeTestClass class1 = new TypeTestClass(); DiffResult list = class1.diff(class1); assertEquals(SHORT_STYLE, list.getToStringStyle()); - + class1.style = ToStringStyle.MULTI_LINE_STYLE; list = class1.diff(class1); assertEquals(ToStringStyle.MULTI_LINE_STYLE, list.getToStringStyle()); diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffTest.java index 26bf95a0c..1aff66ff8 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DiffTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DiffTest.java @@ -28,12 +28,12 @@ public class DiffTest { private static final String FIELD_NAME = "field"; private static final Diff<Boolean> booleanDiff = new BooleanDiff(FIELD_NAME); - - private static class BooleanDiff extends Diff<Boolean> { + + private static class BooleanDiff extends Diff<Boolean> { private static final long serialVersionUID = 1L; protected BooleanDiff(final String fieldName) { - super(fieldName); + super(fieldName); } @Override @@ -44,27 +44,27 @@ public class DiffTest { @Override public Boolean getRight() { return Boolean.FALSE; - } + } } - + @Test(expected = UnsupportedOperationException.class) public void testCannotModify() { booleanDiff.setValue(Boolean.FALSE); } - + @Test public void testGetFieldName() { assertEquals(FIELD_NAME, booleanDiff.getFieldName()); } - + @Test public void testGetType() { assertEquals(Boolean.class, booleanDiff.getType()); } - + @Test public void testToString() { - assertEquals(String.format("[%s: %s, %s]", FIELD_NAME, booleanDiff.getLeft(), + assertEquals(String.format("[%s: %s, %s]", FIELD_NAME, booleanDiff.getLeft(), booleanDiff.getRight()), booleanDiff.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 b5cfdfa0e..0e0f5f452 100644 --- a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -99,7 +99,7 @@ public class EqualsBuilderTest { return b; } } - + static class TestEmptySubObject extends TestObject { public TestEmptySubObject(final int a) { super(a); @@ -150,17 +150,17 @@ public class EqualsBuilderTest { private final TestRecursiveInnerObject a; private final TestRecursiveInnerObject b; private int z; - - public TestRecursiveObject(final TestRecursiveInnerObject a, + + public TestRecursiveObject(final TestRecursiveInnerObject a, final TestRecursiveInnerObject b, final int z) { this.a = a; this.b = b; } - + public TestRecursiveInnerObject getA() { return a; } - + public TestRecursiveInnerObject getB() { return b; } @@ -168,7 +168,7 @@ public class EqualsBuilderTest { public int getZ() { return z; } - + } static class TestRecursiveInnerObject { @@ -176,7 +176,7 @@ public class EqualsBuilderTest { public TestRecursiveInnerObject(final int n) { this.n = n; } - + public int getN() { return n; } @@ -189,20 +189,20 @@ public class EqualsBuilderTest { this.n = n; this.cycle = this; } - + public TestRecursiveCycleObject(final TestRecursiveCycleObject cycle, final int n) { this.n = n; this.cycle = cycle; } - + public int getN() { return n; } - + public TestRecursiveCycleObject getCycle() { return cycle; } - + public void setCycle(final TestRecursiveCycleObject cycle) { this.cycle = cycle; } @@ -223,7 +223,7 @@ public class EqualsBuilderTest { assertFalse(EqualsBuilder.reflectionEquals(null, o2)); assertTrue(EqualsBuilder.reflectionEquals(null, null)); } - + @Test public void testReflectionHierarchyEquals() { testReflectionHierarchyEquals(false); @@ -306,7 +306,7 @@ public class EqualsBuilderTest { * @param toTer Left hand side, equal to to and toBis * @param to2 a different TestObject * @param oToChange a TestObject that will be changed - * @param testTransients whether to test transient instance variables + * @param testTransients whether to test transient instance variables */ private void testReflectionEqualsEquivalenceRelationship( final TestObject to, @@ -371,12 +371,12 @@ public class EqualsBuilderTest { assertTrue(new EqualsBuilder().append(o1, o2).isEquals()); assertFalse(new EqualsBuilder().append(o1, this).isEquals()); - + assertFalse(new EqualsBuilder().append(o1, null).isEquals()); assertFalse(new EqualsBuilder().append(null, o2).isEquals()); assertTrue(new EqualsBuilder().append((Object) null, null).isEquals()); } - + @Test public void testObjectBuild() { final TestObject o1 = new TestObject(4); @@ -387,7 +387,7 @@ public class EqualsBuilderTest { assertEquals(Boolean.TRUE, new EqualsBuilder().append(o1, o2).build()); assertEquals(Boolean.FALSE, new EqualsBuilder().append(o1, this).build()); - + assertEquals(Boolean.FALSE, new EqualsBuilder().append(o1, null).build()); assertEquals(Boolean.FALSE, new EqualsBuilder().append(null, o2).build()); assertEquals(Boolean.TRUE, new EqualsBuilder().append((Object) null, null).build()); @@ -401,17 +401,17 @@ public class EqualsBuilderTest { final TestRecursiveInnerObject i2_2 = new TestRecursiveInnerObject(2); final TestRecursiveInnerObject i3 = new TestRecursiveInnerObject(3); final TestRecursiveInnerObject i4 = new TestRecursiveInnerObject(4); - + final TestRecursiveObject o1_a = new TestRecursiveObject(i1_1, i2_1, 1); final TestRecursiveObject o1_b = new TestRecursiveObject(i1_2, i2_2, 1); final TestRecursiveObject o2 = new TestRecursiveObject(i3, i4, 2); final TestRecursiveObject oNull = new TestRecursiveObject(null, null, 2); - + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_a).isEquals()); assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); - + assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, o2).isEquals()); - + assertTrue(new EqualsBuilder().setTestRecursive(true).append(oNull, oNull).isEquals()); assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, oNull).isEquals()); } @@ -421,7 +421,7 @@ public class EqualsBuilderTest { final TestRecursiveCycleObject o1_a = new TestRecursiveCycleObject(1); final TestRecursiveCycleObject o1_b = new TestRecursiveCycleObject(1); final TestRecursiveCycleObject o2 = new TestRecursiveCycleObject(2); - + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_a).isEquals()); assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, o2).isEquals()); @@ -432,19 +432,19 @@ public class EqualsBuilderTest { final TestRecursiveCycleObject o1_a = new TestRecursiveCycleObject(1); final TestRecursiveCycleObject i1_a = new TestRecursiveCycleObject(o1_a, 100); o1_a.setCycle(i1_a); - + final TestRecursiveCycleObject o1_b = new TestRecursiveCycleObject(1); final TestRecursiveCycleObject i1_b = new TestRecursiveCycleObject(o1_b, 100); o1_b.setCycle(i1_b); - + final TestRecursiveCycleObject o2 = new TestRecursiveCycleObject(2); final TestRecursiveCycleObject i2 = new TestRecursiveCycleObject(o1_b, 200); o2.setCycle(i2); - + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_a).isEquals()); assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, o2).isEquals()); - + assertTrue(EqualsBuilder.reflectionEquals(o1_a, o1_b, false, null, true)); assertFalse(EqualsBuilder.reflectionEquals(o1_a, o2, false, null, true)); } @@ -530,7 +530,7 @@ public class EqualsBuilderTest { equalsBuilder.reset(); assertTrue(equalsBuilder.isEquals()); } - + @Test public void testBoolean() { final boolean o1 = true; @@ -549,7 +549,7 @@ public class EqualsBuilderTest { obj2[0] = new TestObject(4); obj2[1] = new TestObject(5); obj2[2] = null; - + assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals()); assertTrue(new EqualsBuilder().append(obj2, obj2).isEquals()); assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals()); @@ -561,7 +561,7 @@ public class EqualsBuilderTest { assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals()); obj1[2] = null; assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals()); - + obj2 = null; assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals()); obj1 = null; @@ -846,7 +846,7 @@ public class EqualsBuilderTest { assertTrue(new EqualsBuilder().append(array1, array2).isEquals()); array1[1][1] = false; assertFalse(new EqualsBuilder().append(array1, array2).isEquals()); - + // compare 1 dim to 2. final boolean[] array3 = new boolean[]{true, true}; assertFalse(new EqualsBuilder().append(array1, array3).isEquals()); @@ -1052,7 +1052,7 @@ public class EqualsBuilderTest { array1[1] = true; assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals()); } - + public static class TestACanEqualB { private final int a; @@ -1114,7 +1114,7 @@ public class EqualsBuilderTest { return this.b; } } - + /** * Tests two instances of classes that can be equal and that are not "related". The two classes are not subclasses * of each other and do not share a parent aside from Object. @@ -1140,7 +1140,7 @@ public class EqualsBuilderTest { assertTrue(new EqualsBuilder().append(x, y).isEquals()); assertTrue(new EqualsBuilder().append(y, x).isEquals()); } - + /** * Test from http://issues.apache.org/bugzilla/show_bug.cgi?id=33067 */ @@ -1193,7 +1193,7 @@ public class EqualsBuilderTest { this.three = new TestObject(three); } } - + /** * Test cyclical object references which cause a StackOverflowException if * not handled properly. s. LANG-606 @@ -1242,7 +1242,7 @@ public class EqualsBuilderTest { return EqualsBuilder.reflectionEquals(this, obj); } } - + @Test public void testReflectionArrays() throws Exception { @@ -1256,11 +1256,11 @@ public class EqualsBuilderTest { assertFalse(EqualsBuilder.reflectionEquals(o1, o2)); assertTrue(EqualsBuilder.reflectionEquals(o1, o1)); assertTrue(EqualsBuilder.reflectionEquals(o1, o3)); - + final double[] d1 = { 0, 1 }; final double[] d2 = { 2, 3 }; final double[] d3 = { 0, 1 }; - + assertFalse(EqualsBuilder.reflectionEquals(d1, d2)); assertTrue(EqualsBuilder.reflectionEquals(d1, d1)); assertTrue(EqualsBuilder.reflectionEquals(d1, d3)); 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 aa61e022b..f39d26abd 100644 --- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -72,9 +72,9 @@ public class HashCodeBuilderAndEqualsBuilderTest { } /** - * Asserts that if <code>lhs</code> equals <code>rhs</code> + * Asserts that if <code>lhs</code> equals <code>rhs</code> * then their hash codes MUST be identical. - * + * * @param lhs The Left-Hand-Side of the equals test * @param rhs The Right-Hand-Side of the equals test * @param testTransients whether to test transient fields 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 633f5f566..4ded427c1 100644 --- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -61,7 +61,7 @@ public class HashCodeBuilderTest { public void testConstructorExEvenFirst() { new HashCodeBuilder(2, 3); } - + @Test(expected=IllegalArgumentException.class) public void testConstructorExEvenSecond() { new HashCodeBuilder(3, 2); @@ -195,7 +195,7 @@ public class HashCodeBuilderTest { obj = new Object(); assertEquals(17 * 37 + obj.hashCode(), new HashCodeBuilder(17, 37).append(obj).toHashCode()); } - + @Test public void testObjectBuild() { Object obj = null; @@ -529,7 +529,7 @@ public class HashCodeBuilderTest { final ReflectionTestCycleB b = new ReflectionTestCycleB(); a.b = b; b.a = a; - + // Used to caused: // java.lang.StackOverflowError // at java.lang.ClassLoader.getCallerClassLoader(Native Method) @@ -559,7 +559,7 @@ public class HashCodeBuilderTest { @Test public void testToHashCodeEqualsHashCode() { 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", + 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/JsonToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java index c60dc050c..6f76cfecf 100644 --- a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -224,7 +224,7 @@ public class JsonToStringStyleTest { .append("age", p.age).append("smoker", p.smoker) .toString()); } - + @Test public void testNestingPerson() { final Person p = new Person(){ @@ -357,10 +357,10 @@ public class JsonToStringStyleTest { } catch (final UnsupportedOperationException e) { } } - + /** * An object with nested object structures used to test {@link ToStringStyle.JsonToStringStyle}. - * + * */ static class NestingPerson { /** 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 8454c5bf7..ca02df0dd 100644 --- a/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ public class MultiLineToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.MULTI_LINE_STYLE); @@ -55,12 +55,12 @@ public class MultiLineToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + "]").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]").toString()); - + assertEquals(baseStr + "[" + System.lineSeparator() + " a=hello" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + "]").append("a", "hello").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + " a=hello" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]").append("a", "hello").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=hello" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); diff --git a/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java index 08c638230..cb08ae01e 100644 --- a/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,9 +33,9 @@ public class MultilineRecursiveToStringStyleTest { @Test public void simpleObject() { final Transaction tx = new Transaction("2014.10.15", 100); - final String expected = getClassPrefix(tx) + "[" + BR - + " amount=100.0," + BR - + " date=2014.10.15" + BR + final String expected = getClassPrefix(tx) + "[" + BR + + " amount=100.0," + BR + + " date=2014.10.15" + BR + "]"; assertEquals(expected, toString(tx)); } @@ -45,12 +45,12 @@ public class MultilineRecursiveToStringStyleTest { final Customer customer = new Customer("Douglas Adams"); final Bank bank = new Bank("ASF Bank"); customer.bank = bank; - final String exp = getClassPrefix(customer) + "[" + BR - + " name=Douglas Adams," + BR - + " bank=" + getClassPrefix(bank) + "[" + BR - + " name=ASF Bank" + BR - + " ]," + BR - + " accounts=<null>" + BR + final String exp = getClassPrefix(customer) + "[" + BR + + " name=Douglas Adams," + BR + + " bank=" + getClassPrefix(bank) + "[" + BR + + " name=ASF Bank" + BR + + " ]," + BR + + " accounts=<null>" + BR + "]"; assertEquals(exp, toString(customer)); } @@ -62,18 +62,18 @@ public class MultilineRecursiveToStringStyleTest { final Transaction tx2 = new Transaction("2014.10.15", 50); acc.transactions.add(tx1); acc.transactions.add(tx2); - final String expected = getClassPrefix(acc) + "[" + BR - + " owner=<null>," + BR - + " transactions=" + getClassPrefix(acc.transactions) + "{" + BR - + " " + getClassPrefix(tx1) + "[" + BR - + " amount=100.0," + BR - + " date=2014.10.14" + BR - + " ]," + BR + final String expected = getClassPrefix(acc) + "[" + BR + + " owner=<null>," + BR + + " transactions=" + getClassPrefix(acc.transactions) + "{" + BR + + " " + getClassPrefix(tx1) + "[" + BR + + " amount=100.0," + BR + + " date=2014.10.14" + BR + + " ]," + BR + " " + getClassPrefix(tx2) + "[" + BR - + " amount=50.0," + BR - + " date=2014.10.15" + BR - + " ]" + BR - + " }" + BR + + " amount=50.0," + BR + + " date=2014.10.15" + BR + + " ]" + BR + + " }" + BR + "]"; assertEquals(expected, toString(acc)); } @@ -81,13 +81,13 @@ public class MultilineRecursiveToStringStyleTest { @Test public void noArray() { final WithArrays wa = new WithArrays(); - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + " charArray=<null>," + BR - + " intArray=<null>," + BR - + " doubleArray=<null>," + BR - + " longArray=<null>," + BR - + " stringArray=<null>" + BR + + " intArray=<null>," + BR + + " doubleArray=<null>," + BR + + " longArray=<null>," + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -96,17 +96,17 @@ public class MultilineRecursiveToStringStyleTest { public void boolArray() { final WithArrays wa = new WithArrays(); wa.boolArray = new boolean[] { true, false, true }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray={" + BR - + " true," + BR - + " false," + BR - + " true" + BR - + " }," + BR - + " charArray=<null>," + BR - + " intArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray={" + BR + + " true," + BR + + " false," + BR + + " true" + BR + + " }," + BR + + " charArray=<null>," + BR + + " intArray=<null>," + BR + " doubleArray=<null>," + BR - + " longArray=<null>," + BR - + " stringArray=<null>" + BR + + " longArray=<null>," + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -115,16 +115,16 @@ public class MultilineRecursiveToStringStyleTest { public void charArray() { final WithArrays wa = new WithArrays(); wa.charArray = new char[] { 'a', 'A' }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR - + " charArray={" + BR - + " a," + BR - + " A" + BR - + " }," + BR - + " intArray=<null>," + BR - + " doubleArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + + " charArray={" + BR + + " a," + BR + + " A" + BR + + " }," + BR + + " intArray=<null>," + BR + + " doubleArray=<null>," + BR + " longArray=<null>," + BR - + " stringArray=<null>" + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -133,16 +133,16 @@ public class MultilineRecursiveToStringStyleTest { public void intArray() { final WithArrays wa = new WithArrays(); wa.intArray = new int[] { 1, 2 }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR - + " charArray=<null>," + BR - + " intArray={" + BR - + " 1," + BR - + " 2" + BR - + " }," + BR - + " doubleArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + + " charArray=<null>," + BR + + " intArray={" + BR + + " 1," + BR + + " 2" + BR + + " }," + BR + + " doubleArray=<null>," + BR + " longArray=<null>," + BR - + " stringArray=<null>" + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -151,16 +151,16 @@ public class MultilineRecursiveToStringStyleTest { public void doubleArray() { final WithArrays wa = new WithArrays(); wa.doubleArray = new double[] { 1, 2 }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + " charArray=<null>," + BR - + " intArray=<null>," + BR - + " doubleArray={" + BR - + " 1.0," + BR - + " 2.0" + BR + + " intArray=<null>," + BR + + " doubleArray={" + BR + + " 1.0," + BR + + " 2.0" + BR + " }," + BR - + " longArray=<null>," + BR - + " stringArray=<null>" + BR + + " longArray=<null>," + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -169,16 +169,16 @@ public class MultilineRecursiveToStringStyleTest { public void longArray() { final WithArrays wa = new WithArrays(); wa.longArray = new long[] { 1L, 2L }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + " charArray=<null>," + BR - + " intArray=<null>," + BR - + " doubleArray=<null>," + BR - + " longArray={" + BR - + " 1," + BR + + " intArray=<null>," + BR + + " doubleArray=<null>," + BR + + " longArray={" + BR + + " 1," + BR + " 2" + BR - + " }," + BR - + " stringArray=<null>" + BR + + " }," + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -187,30 +187,30 @@ public class MultilineRecursiveToStringStyleTest { public void stringArray() { final WithArrays wa = new WithArrays(); wa.stringArray = new String[] { "a", "A" }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + " charArray=<null>," + BR - + " intArray=<null>," + BR - + " doubleArray=<null>," + BR - + " longArray=<null>," + BR + + " intArray=<null>," + BR + + " doubleArray=<null>," + BR + + " longArray=<null>," + BR + " stringArray={" + BR - + " a," + BR - + " A" + BR - + " }" + BR + + " a," + BR + + " A" + BR + + " }" + BR + "]"; assertEquals(exp, toString(wa)); } - - + + @Test public void testLANG1319() throws Exception { final String[] stringArray = {"1", "2"}; - - final String exp = getClassPrefix(stringArray) + "[" + BR - + " {" + BR - + " 1," + BR - + " 2" + BR - + " }" + BR + + final String exp = getClassPrefix(stringArray) + "[" + BR + + " {" + BR + + " 1," + BR + + " 2" + BR + + " }" + BR + "]"; assertEquals(exp, toString(stringArray)); } diff --git a/src/test/java/org/apache/commons/lang3/builder/NoClassNameToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/NoClassNameToStringStyleTest.java index 73184a5d5..4865b034c 100644 --- a/src/test/java/org/apache/commons/lang3/builder/NoClassNameToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/NoClassNameToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 d5388a91b..defd998bc 100644 --- a/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ public class NoFieldNamesToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.NO_FIELD_NAMES_STYLE); @@ -45,7 +45,7 @@ public class NoFieldNamesToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals(baseStr + "[]", new ToStringBuilder(base).toString()); @@ -55,12 +55,12 @@ public class NoFieldNamesToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[]", new ToStringBuilder(base).appendSuper("Integer@8888[]").toString()); assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").toString()); - + assertEquals(baseStr + "[hello]", new ToStringBuilder(base).appendSuper("Integer@8888[]").append("a", "hello").toString()); assertEquals(baseStr + "[<null>,hello]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").append("a", "hello").toString()); assertEquals(baseStr + "[hello]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); diff --git a/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java index dbf36c1b0..d46dd6d18 100644 --- a/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,7 +32,7 @@ public class RecursiveToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(new RecursiveToStringStyle()); @@ -44,7 +44,7 @@ public class RecursiveToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals(baseStr + "[]", new ToStringBuilder(base).toString()); @@ -54,25 +54,25 @@ public class RecursiveToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[]", new ToStringBuilder(base).appendSuper("Integer@8888[]").toString()); assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").toString()); - + assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[]").append("a", "hello").toString()); assertEquals(baseStr + "[<null>,a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").append("a", "hello").toString()); assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); final Integer i4 = Integer.valueOf(4); final ArrayList<Object> emptyList = new ArrayList<>(); - + 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()); assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString()); - assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", emptyList, false).toString()); + assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", emptyList, false).toString()); assertEquals(baseStr + "[a=java.util.ArrayList@" + Integer.toHexString(System.identityHashCode(emptyList)) + "{}]", new ToStringBuilder(base).append("a", emptyList, true).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString()); @@ -147,13 +147,13 @@ public class RecursiveToStringStyleTest { * Test boolean field. */ boolean smoker; - + /** * Test Object field. */ Job job; } - + static class Job { /** * Test String field. 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 d5249d50c..7cd899e8a 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java @@ -42,7 +42,7 @@ import org.junit.Test; * <p> * The tests on the non-thread-safe collections do not pass. * </p> - * + * * @see <a href="https://issues.apache.org/jira/browse/LANG-762">[LANG-762] Handle or document ReflectionToStringBuilder * and ToStringBuilder for collections that are not thread safe</a> * @since 3.1 diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java index dd94c51a7..4250ddf18 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,26 +35,26 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { this.testStringField = b; } } - + private static final String INTEGER_FIELD_NAME = "testIntegerField"; private static final String STRING_FIELD_NAME = "testStringField"; private final TestFixture BOTH_NON_NULL = new TestFixture(0, "str"); private final TestFixture FIRST_NULL = new TestFixture(null, "str"); private final TestFixture SECOND_NULL = new TestFixture(0, null); private final TestFixture BOTH_NULL = new TestFixture(null, null); - + @Test public void test_NonExclude(){ //normal case= String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, false, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + //make one null toString = ReflectionToStringBuilder.toString(FIRST_NULL, null, false, false, false, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + //other one null toString = ReflectionToStringBuilder.toString(SECOND_NULL, null, false, false, false, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); @@ -65,31 +65,31 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); } - + @Test public void test_excludeNull(){ - + //test normal case String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, true, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + //make one null toString = ReflectionToStringBuilder.toString(FIRST_NULL, null, false, false, true, null); assertFalse(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + //other one null toString = ReflectionToStringBuilder.toString(SECOND_NULL, null, false, false, true, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertFalse(toString.contains(STRING_FIELD_NAME)); - + //both null toString = ReflectionToStringBuilder.toString(BOTH_NULL, null, false, false, true, null); assertFalse(toString.contains(INTEGER_FIELD_NAME)); assertFalse(toString.contains(STRING_FIELD_NAME)); } - + @Test public void test_ConstructorOption(){ ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL, null, null, null, false, false, true); @@ -97,23 +97,23 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { String toString = builder.toString(); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + builder = new ReflectionToStringBuilder(FIRST_NULL, null, null, null, false, false, true); toString = builder.toString(); assertFalse(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + builder = new ReflectionToStringBuilder(SECOND_NULL, null, null, null, false, false, true); toString = builder.toString(); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertFalse(toString.contains(STRING_FIELD_NAME)); - + builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, true); toString = builder.toString(); assertFalse(toString.contains(INTEGER_FIELD_NAME)); assertFalse(toString.contains(STRING_FIELD_NAME)); } - + @Test public void test_ConstructorOptionNormal(){ ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false); @@ -121,24 +121,24 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { String toString = builder.toString(); assertTrue(toString.contains(STRING_FIELD_NAME)); assertTrue(toString.contains(INTEGER_FIELD_NAME)); - + //regression test older constructors ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL); toString = oldBuilder.toString(); assertTrue(toString.contains(STRING_FIELD_NAME)); assertTrue(toString.contains(INTEGER_FIELD_NAME)); - + oldBuilder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false); toString = oldBuilder.toString(); assertTrue(toString.contains(STRING_FIELD_NAME)); assertTrue(toString.contains(INTEGER_FIELD_NAME)); - + oldBuilder = new ReflectionToStringBuilder(BOTH_NULL, null, null); toString = oldBuilder.toString(); assertTrue(toString.contains(STRING_FIELD_NAME)); assertTrue(toString.contains(INTEGER_FIELD_NAME)); } - + @Test public void test_ConstructorOption_ExcludeNull(){ ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false); @@ -147,12 +147,12 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { String toString = builder.toString(); assertFalse(toString.contains(STRING_FIELD_NAME)); assertFalse(toString.contains(INTEGER_FIELD_NAME)); - + builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, true); toString = builder.toString(); assertFalse(toString.contains(STRING_FIELD_NAME)); assertFalse(toString.contains(INTEGER_FIELD_NAME)); - + ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL); oldBuilder.setExcludeNullValues(true); assertTrue(oldBuilder.isExcludeNullValues()); 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 c36d254d8..aa8909e5b 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java index fb237a564..a28cbb146 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 8cb58e5d9..2cf240877 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,7 @@ import org.junit.Test; * The {@link ToStringStyle} class includes a registry to avoid infinite loops for objects with circular references. We * want to make sure that we do not get concurrency exceptions accessing this registry. * </p> - * + * * @see <a href="https://issues.apache.org/jira/browse/LANG-762">[LANG-762] Handle or document ReflectionToStringBuilder * and ToStringBuilder for collections that are not thread safe</a> * @since 3.1 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 e27e9f10c..62b8bac8b 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ public class ShortPrefixToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = "Integer"; - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE); @@ -45,7 +45,7 @@ public class ShortPrefixToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals(baseStr + "[]", new ToStringBuilder(base).toString()); @@ -55,12 +55,12 @@ public class ShortPrefixToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[]", new ToStringBuilder(base).appendSuper("Integer@8888[]").toString()); assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").toString()); - + assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[]").append("a", "hello").toString()); assertEquals(baseStr + "[<null>,a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").append("a", "hello").toString()); assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); @@ -125,5 +125,5 @@ public class ShortPrefixToStringStyleTest { assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(array).toString()); assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) array).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 1bf18db86..63ea46b6e 100644 --- a/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,7 +32,7 @@ import org.junit.Test; public class SimpleToStringStyleTest { private final Integer base = Integer.valueOf(5); - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.SIMPLE_STYLE); @@ -44,7 +44,7 @@ public class SimpleToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals("", new ToStringBuilder(base).toString()); @@ -54,12 +54,12 @@ public class SimpleToStringStyleTest { public void testAppendSuper() { assertEquals("", new ToStringBuilder(base).appendSuper("").toString()); assertEquals("<null>", new ToStringBuilder(base).appendSuper("<null>").toString()); - + assertEquals("hello", new ToStringBuilder(base).appendSuper("").append("a", "hello").toString()); assertEquals("<null>,hello", new ToStringBuilder(base).appendSuper("<null>").append("a", "hello").toString()); assertEquals("hello", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); 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 17b19d011..fb60bc318 100644 --- a/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,9 +33,9 @@ public class StandardToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = "Integer"; - + private static final StandardToStringStyle STYLE = new StandardToStringStyle(); - + static { STYLE.setUseShortClassName(true); STYLE.setUseIdentityHashCode(false); @@ -48,7 +48,7 @@ public class StandardToStringStyleTest { STYLE.setSummaryObjectStartText("%"); STYLE.setSummaryObjectEndText("%"); } - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(STYLE); @@ -60,7 +60,7 @@ public class StandardToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals(baseStr + "[]", new ToStringBuilder(base).toString()); @@ -70,12 +70,12 @@ public class StandardToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[]", new ToStringBuilder(base).appendSuper("Integer@8888[]").toString()); assertEquals(baseStr + "[%NULL%]", new ToStringBuilder(base).appendSuper("Integer@8888[%NULL%]").toString()); - + assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[]").append("a", "hello").toString()); assertEquals(baseStr + "[%NULL%,a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[%NULL%]").append("a", "hello").toString()); assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); 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 8e32287eb..619b9f255 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java @@ -40,7 +40,7 @@ public class ToStringBuilderTest { private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); /* - * All tests should leave the registry empty. + * All tests should leave the registry empty. */ @After public void after(){ @@ -839,7 +839,7 @@ public class ToStringBuilderTest { assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString()); assertEquals(baseStr + "[<size=4>]", new ToStringBuilder(base).append(null, array, false).toString()); } - + @Test public void testConstructToStringBuilder(){ ToStringBuilder stringBuilder1 = new ToStringBuilder(base, null, null); @@ -870,7 +870,7 @@ public class ToStringBuilderTest { assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); } - + @Test public void testObjectBuild() { final Integer i3 = Integer.valueOf(3); 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 40dd27366..83fa06836 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java @@ -40,7 +40,7 @@ import org.junit.Test; * <p> * This test passes but only tests one aspect of the issue. * </p> - * + * * @see <a href="https://issues.apache.org/jira/browse/LANG-762">[LANG-762] Handle or document ReflectionToStringBuilder * and ToStringBuilder for collections that are not thread safe</a> * @since 3.1 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 81a8b83c8..a2d9d34d4 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -117,7 +117,7 @@ public class ToStringStyleTest { /** * An object used to test {@link ToStringStyle}. - * + * */ static class Person { /** 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 caad3b38d..5d64378b1 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java @@ -68,7 +68,7 @@ public class CallableBackgroundInitializerTest { exec.shutdown(); exec.awaitTermination(1, TimeUnit.SECONDS); } - + } /** diff --git a/src/test/java/org/apache/commons/lang3/concurrent/CircuitBreakingExceptionTest.java b/src/test/java/org/apache/commons/lang3/concurrent/CircuitBreakingExceptionTest.java index a7940187b..df814788c 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/CircuitBreakingExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/CircuitBreakingExceptionTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,54 +28,54 @@ import static org.junit.Assert.assertNull; * JUnit tests for {@link CircuitBreakingException}. */ public class CircuitBreakingExceptionTest extends AbstractExceptionTest { - + @Test(expected = CircuitBreakingException.class) public void testThrowingInformativeException() throws Exception { throw new CircuitBreakingException(EXCEPTION_MESSAGE, generateCause()); } - + @Test(expected = CircuitBreakingException.class) public void testThrowingExceptionWithMessage() throws Exception { throw new CircuitBreakingException(EXCEPTION_MESSAGE); } - + @Test(expected = CircuitBreakingException.class) public void testThrowingExceptionWithCause() throws Exception { throw new CircuitBreakingException(generateCause()); } - + @Test(expected = CircuitBreakingException.class) public void testThrowingEmptyException() throws Exception { throw new CircuitBreakingException(); } - + @Test public void testWithCauseAndMessage() throws Exception { final Exception exception = new CircuitBreakingException(EXCEPTION_MESSAGE, generateCause()); assertNotNull(exception); assertEquals(WRONG_EXCEPTION_MESSAGE, EXCEPTION_MESSAGE, exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNotNull(cause); assertEquals(WRONG_CAUSE_MESSAGE, CAUSE_MESSAGE, cause.getMessage()); } - + @Test public void testWithoutCause() throws Exception { final Exception exception = new CircuitBreakingException(EXCEPTION_MESSAGE); assertNotNull(exception); assertEquals(WRONG_EXCEPTION_MESSAGE, EXCEPTION_MESSAGE, exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNull(cause); } - + @Test public void testWithoutMessage() throws Exception { final Exception exception = new CircuitBreakingException(generateCause()); assertNotNull(exception); assertNotNull(exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNotNull(cause); assertEquals(WRONG_CAUSE_MESSAGE, CAUSE_MESSAGE, cause.getMessage()); 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 f5b74ff80..ffa78d684 100644 --- a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java +++ b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java @@ -49,7 +49,7 @@ public class EventListenerSupportTest { assertEquals(0, listeners.length); assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType()); final VetoableChangeListener[] empty = listeners; - //for fun, show that the same empty instance is used + //for fun, show that the same empty instance is used assertSame(empty, listenerSupport.getListeners()); final VetoableChangeListener listener1 = EasyMock.createNiceMock(VetoableChangeListener.class); @@ -117,7 +117,7 @@ public class EventListenerSupportTest { assertEquals(0, listeners.length); assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType()); final VetoableChangeListener[] empty = listeners; - //for fun, show that the same empty instance is used + //for fun, show that the same empty instance is used assertSame(empty, listenerSupport.getListeners()); final VetoableChangeListener listener1 = EasyMock.createNiceMock(VetoableChangeListener.class); 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 4c8d6153d..db54742cc 100644 --- a/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java @@ -41,7 +41,7 @@ import org.junit.Test; /** * @since 3.0 */ -public class EventUtilsTest +public class EventUtilsTest { @Test @@ -53,7 +53,7 @@ public class EventUtilsTest assertTrue(Modifier.isPublic(EventUtils.class.getModifiers())); assertFalse(Modifier.isFinal(EventUtils.class.getModifiers())); } - + @Test public void testAddEventListener() { 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 ce9412208..8d5de1048 100644 --- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -150,7 +150,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext & @Test public void testGetContextLabels() { assertEquals(5, exceptionContext.getContextEntries().size()); - + exceptionContext.addContextValue("test2", "different value"); final Set<String> labels = exceptionContext.getContextLabels(); @@ -165,7 +165,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext & @Test public void testGetContextEntries() { assertEquals(5, exceptionContext.getContextEntries().size()); - + exceptionContext.addContextValue("test2", "different value"); final List<Pair<String, Object>> entries = exceptionContext.getContextEntries(); @@ -177,7 +177,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext & assertEquals("test Poorly written obj", entries.get(4).getKey()); assertEquals("test2", entries.get(5).getKey()); } - + @Test public void testJavaSerialization() { exceptionContext.setContextValue("test Poorly written obj", "serializable replacement"); diff --git a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java index ee5e0c5fb..e0e607174 100644 --- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java @@ -21,13 +21,13 @@ package org.apache.commons.lang3.exception; * Base class for testing {@link Exception} descendants */ public abstract class AbstractExceptionTest { - + protected static final String CAUSE_MESSAGE = "Cause message"; protected static final String EXCEPTION_MESSAGE = "Exception message"; - + protected static final String WRONG_EXCEPTION_MESSAGE = "Wrong exception message"; protected static final String WRONG_CAUSE_MESSAGE = "Wrong cause message"; - + protected Exception generateCause() { return new Exception(CAUSE_MESSAGE); } diff --git a/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java index 5406be55a..6030f89e4 100644 --- a/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java @@ -26,49 +26,49 @@ import static org.junit.Assert.assertNull; * JUnit tests for {@link CloneFailedExceptionTest}. */ public class CloneFailedExceptionTest extends AbstractExceptionTest { - + @Test(expected = CloneFailedException.class) public void testThrowingInformativeException() throws Exception { throw new CloneFailedException(EXCEPTION_MESSAGE, generateCause()); } - + @Test(expected = CloneFailedException.class) public void testThrowingExceptionWithMessage() throws Exception { throw new CloneFailedException(EXCEPTION_MESSAGE); } - + @Test(expected = CloneFailedException.class) public void testThrowingExceptionWithCause() throws Exception { throw new CloneFailedException(generateCause()); } - + @Test public void testWithCauseAndMessage() throws Exception { final Exception exception = new CloneFailedException(EXCEPTION_MESSAGE, generateCause()); assertNotNull(exception); assertEquals(WRONG_EXCEPTION_MESSAGE, EXCEPTION_MESSAGE, exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNotNull(cause); assertEquals(WRONG_CAUSE_MESSAGE, CAUSE_MESSAGE, cause.getMessage()); } - + @Test public void testWithoutCause() throws Exception { final Exception exception = new CloneFailedException(EXCEPTION_MESSAGE); assertNotNull(exception); assertEquals(WRONG_EXCEPTION_MESSAGE, EXCEPTION_MESSAGE, exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNull(cause); } - + @Test public void testWithoutMessage() throws Exception { final Exception exception = new CloneFailedException(generateCause()); assertNotNull(exception); assertNotNull(exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNotNull(cause); assertEquals(WRONG_CAUSE_MESSAGE, CAUSE_MESSAGE, cause.getMessage()); 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 75b66ab4d..9df0e7559 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,7 @@ import org.junit.Test; * JUnit tests for ContextedException. */ public class ContextedExceptionTest extends AbstractExceptionContextTest<ContextedException> { - + @Override public void setUp() throws Exception { exceptionContext = new ContextedException(new Exception(TEST_MESSAGE)); @@ -49,7 +49,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context public void testContextedExceptionString() { exceptionContext = new ContextedException(TEST_MESSAGE); assertEquals(TEST_MESSAGE, exceptionContext.getMessage()); - + final String trace = ExceptionUtils.getStackTrace(exceptionContext); assertTrue(trace.contains(TEST_MESSAGE)); } @@ -74,7 +74,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context assertTrue(trace.contains(TEST_MESSAGE_2)); assertTrue(message.contains(TEST_MESSAGE_2)); } - + @Test public void testContextedExceptionStringThrowableContext() { exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext()); @@ -94,7 +94,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context .addContextValue("test Date", new Date()) .addContextValue("test Nbr", Integer.valueOf(5)) .addContextValue("test Poorly written obj", new ObjectWithFaultyToString()); - + 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 c10b1e866..3a3217576 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,7 +30,7 @@ import org.junit.Test; * JUnit tests for ContextedRuntimeException. */ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<ContextedRuntimeException> { - + @Override @Before public void setUp() throws Exception { @@ -51,7 +51,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest< public void testContextedExceptionString() { exceptionContext = new ContextedRuntimeException(TEST_MESSAGE); assertEquals(TEST_MESSAGE, exceptionContext.getMessage()); - + final String trace = ExceptionUtils.getStackTrace(exceptionContext); assertTrue(trace.contains(TEST_MESSAGE)); } @@ -76,11 +76,11 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest< assertTrue(trace.contains(TEST_MESSAGE_2)); assertTrue(message.contains(TEST_MESSAGE_2)); } - + @Test public void testContextedExceptionStringThrowableContext() { // Use an anonymous subclass to make sure users can provide custom implementations - exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), + exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext() {private static final long serialVersionUID = 1L;}); final String message = exceptionContext.getMessage(); final String trace = ExceptionUtils.getStackTrace(exceptionContext); @@ -98,7 +98,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest< .addContextValue("test Date", new Date()) .addContextValue("test Nbr", Integer.valueOf(5)) .addContextValue("test Poorly written obj", new ObjectWithFaultyToString()); - + final String message = exceptionContext.getMessage(); assertTrue(message != null); } diff --git a/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java b/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java index 79bf3328f..5a6c292ae 100644 --- a/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,14 +23,14 @@ import org.junit.Test; * JUnit tests for DefaultExceptionContext. */ public class DefaultExceptionContextTest extends AbstractExceptionContextTest<DefaultExceptionContext> { - + @Override @Before public void setUp() throws Exception { exceptionContext = new DefaultExceptionContext(); super.setUp(); } - + @Test public void testFormattedExceptionMessageNull() { exceptionContext = new DefaultExceptionContext(); 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 af8b847b3..00ec843fd 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -43,7 +43,7 @@ import org.junit.Test; * @since 1.0 */ public class ExceptionUtilsTest { - + private NestableException nested; private Throwable withCause; private Throwable withoutCause; @@ -98,7 +98,7 @@ public class ExceptionUtilsTest { } //----------------------------------------------------------------------- - + @Test public void testConstructor() { assertNotNull(new ExceptionUtils()); @@ -108,7 +108,7 @@ public class ExceptionUtilsTest { assertTrue(Modifier.isPublic(ExceptionUtils.class.getModifiers())); assertFalse(Modifier.isFinal(ExceptionUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @SuppressWarnings("deprecation") // Specifically tests the deprecated methods @Test @@ -135,7 +135,7 @@ public class ExceptionUtilsTest { assertSame(null, ExceptionUtils.getCause(withCause, new String[0])); assertSame(null, ExceptionUtils.getCause(withCause, new String[] {null})); assertSame(nested, ExceptionUtils.getCause(withCause, new String[] {"getCause"})); - + // not known type, so match on supplied method names assertSame(null, ExceptionUtils.getCause(withoutCause, null)); assertSame(null, ExceptionUtils.getCause(withoutCause, new String[0])); @@ -263,22 +263,22 @@ public class ExceptionUtilsTest { public void testIndexOf_ThrowableClass() { assertEquals(-1, ExceptionUtils.indexOfThrowable(null, null)); assertEquals(-1, ExceptionUtils.indexOfThrowable(null, NestableException.class)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, null)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithCause.class)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, NestableException.class)); assertEquals(0, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithoutCause.class)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, null)); assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithCause.class)); assertEquals(0, ExceptionUtils.indexOfThrowable(nested, NestableException.class)); assertEquals(1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithoutCause.class)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, null)); assertEquals(0, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class)); assertEquals(1, ExceptionUtils.indexOfThrowable(withCause, NestableException.class)); assertEquals(2, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithoutCause.class)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, Exception.class)); } @@ -286,17 +286,17 @@ public class ExceptionUtilsTest { public void testIndexOf_ThrowableClassInt() { assertEquals(-1, ExceptionUtils.indexOfThrowable(null, null, 0)); assertEquals(-1, ExceptionUtils.indexOfThrowable(null, NestableException.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, null)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithCause.class, 0)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, NestableException.class, 0)); assertEquals(0, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithoutCause.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, null, 0)); assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithCause.class, 0)); assertEquals(0, ExceptionUtils.indexOfThrowable(nested, NestableException.class, 0)); assertEquals(1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithoutCause.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, null)); assertEquals(0, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 0)); assertEquals(1, ExceptionUtils.indexOfThrowable(withCause, NestableException.class, 0)); @@ -306,7 +306,7 @@ public class ExceptionUtilsTest { assertEquals(0, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 0)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 1)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 9)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, Exception.class, 0)); } @@ -315,22 +315,22 @@ public class ExceptionUtilsTest { public void testIndexOfType_ThrowableClass() { assertEquals(-1, ExceptionUtils.indexOfType(null, null)); assertEquals(-1, ExceptionUtils.indexOfType(null, NestableException.class)); - + assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, null)); assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, ExceptionWithCause.class)); assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, NestableException.class)); assertEquals(0, ExceptionUtils.indexOfType(withoutCause, ExceptionWithoutCause.class)); - + assertEquals(-1, ExceptionUtils.indexOfType(nested, null)); assertEquals(-1, ExceptionUtils.indexOfType(nested, ExceptionWithCause.class)); assertEquals(0, ExceptionUtils.indexOfType(nested, NestableException.class)); assertEquals(1, ExceptionUtils.indexOfType(nested, ExceptionWithoutCause.class)); - + assertEquals(-1, ExceptionUtils.indexOfType(withCause, null)); assertEquals(0, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class)); assertEquals(1, ExceptionUtils.indexOfType(withCause, NestableException.class)); assertEquals(2, ExceptionUtils.indexOfType(withCause, ExceptionWithoutCause.class)); - + assertEquals(0, ExceptionUtils.indexOfType(withCause, Exception.class)); } @@ -338,17 +338,17 @@ public class ExceptionUtilsTest { public void testIndexOfType_ThrowableClassInt() { assertEquals(-1, ExceptionUtils.indexOfType(null, null, 0)); assertEquals(-1, ExceptionUtils.indexOfType(null, NestableException.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, null)); assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, ExceptionWithCause.class, 0)); assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, NestableException.class, 0)); assertEquals(0, ExceptionUtils.indexOfType(withoutCause, ExceptionWithoutCause.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfType(nested, null, 0)); assertEquals(-1, ExceptionUtils.indexOfType(nested, ExceptionWithCause.class, 0)); assertEquals(0, ExceptionUtils.indexOfType(nested, NestableException.class, 0)); assertEquals(1, ExceptionUtils.indexOfType(nested, ExceptionWithoutCause.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfType(withCause, null)); assertEquals(0, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 0)); assertEquals(1, ExceptionUtils.indexOfType(withCause, NestableException.class, 0)); @@ -358,7 +358,7 @@ public class ExceptionUtilsTest { assertEquals(0, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 0)); assertEquals(-1, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 1)); assertEquals(-1, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 9)); - + assertEquals(0, ExceptionUtils.indexOfType(withCause, Exception.class, 0)); } @@ -369,27 +369,27 @@ public class ExceptionUtilsTest { // could pipe system.err to a known stream, but not much point as // internally this method calls stream method anyway } - + @Test public void testPrintRootCauseStackTrace_ThrowableStream() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(1024); ExceptionUtils.printRootCauseStackTrace(null, (PrintStream) null); ExceptionUtils.printRootCauseStackTrace(null, new PrintStream(out)); assertEquals(0, out.toString().length()); - + out = new ByteArrayOutputStream(1024); try { ExceptionUtils.printRootCauseStackTrace(withCause, (PrintStream) null); fail(); } catch (final IllegalArgumentException ex) { } - + out = new ByteArrayOutputStream(1024); final Throwable cause = createExceptionWithCause(); ExceptionUtils.printRootCauseStackTrace(cause, new PrintStream(out)); String stackTrace = out.toString(); assertTrue(stackTrace.contains(ExceptionUtils.WRAPPED_MARKER)); - + out = new ByteArrayOutputStream(1024); ExceptionUtils.printRootCauseStackTrace(withoutCause, new PrintStream(out)); stackTrace = out.toString(); @@ -402,20 +402,20 @@ public class ExceptionUtilsTest { ExceptionUtils.printRootCauseStackTrace(null, (PrintWriter) null); ExceptionUtils.printRootCauseStackTrace(null, new PrintWriter(writer)); assertEquals(0, writer.getBuffer().length()); - + writer = new StringWriter(1024); try { ExceptionUtils.printRootCauseStackTrace(withCause, (PrintWriter) null); fail(); } catch (final IllegalArgumentException ex) { } - + writer = new StringWriter(1024); final Throwable cause = createExceptionWithCause(); ExceptionUtils.printRootCauseStackTrace(cause, new PrintWriter(writer)); String stackTrace = writer.toString(); assertTrue(stackTrace.contains(ExceptionUtils.WRAPPED_MARKER)); - + writer = new StringWriter(1024); ExceptionUtils.printRootCauseStackTrace(withoutCause, new PrintWriter(writer)); stackTrace = writer.toString(); @@ -426,7 +426,7 @@ public class ExceptionUtilsTest { @Test public void testGetRootCauseStackTrace_Throwable() throws Exception { assertEquals(0, ExceptionUtils.getRootCauseStackTrace(null).length); - + final Throwable cause = createExceptionWithCause(); String[] stackTrace = ExceptionUtils.getRootCauseStackTrace(cause); boolean match = false; @@ -437,7 +437,7 @@ public class ExceptionUtilsTest { } } assertTrue(match); - + stackTrace = ExceptionUtils.getRootCauseStackTrace(withoutCause); match = false; for (final String element : stackTrace) { @@ -458,10 +458,10 @@ public class ExceptionUtilsTest { public void test_getMessage_Throwable() { Throwable th = null; assertEquals("", ExceptionUtils.getMessage(th)); - + th = new IllegalArgumentException("Base"); assertEquals("IllegalArgumentException: Base", ExceptionUtils.getMessage(th)); - + th = new ExceptionWithCause("Wrapper", th); assertEquals("ExceptionUtilsTest.ExceptionWithCause: Wrapper", ExceptionUtils.getMessage(th)); } @@ -470,10 +470,10 @@ public class ExceptionUtilsTest { public void test_getRootCauseMessage_Throwable() { Throwable th = null; assertEquals("", ExceptionUtils.getRootCauseMessage(th)); - + th = new IllegalArgumentException("Base"); assertEquals("IllegalArgumentException: Base", ExceptionUtils.getRootCauseMessage(th)); - + th = new ExceptionWithCause("Wrapper", th); assertEquals("IllegalArgumentException: Base", ExceptionUtils.getRootCauseMessage(th)); } @@ -522,9 +522,9 @@ public class ExceptionUtilsTest { } } - // Temporary classes to allow the nested exception code to be removed - // prior to a rewrite of this test class. - private static class NestableException extends Exception { + // Temporary classes to allow the nested exception code to be removed + // prior to a rewrite of this test class. + private static class NestableException extends Exception { private static final long serialVersionUID = 1L; @SuppressWarnings("unused") @@ -554,7 +554,7 @@ public class ExceptionUtilsTest { assertTrue(ioe instanceof IOException); assertEquals(1, ExceptionUtils.getThrowableCount(ioe)); } - + try { redeclareCheckedException(); Assert.fail("Exception not thrown"); 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 d55b8d81b..3c3676126 100644 --- a/src/test/java/org/apache/commons/lang3/math/FractionTest.java +++ b/src/test/java/org/apache/commons/lang3/math/FractionTest.java @@ -30,7 +30,7 @@ import org.junit.Test; * Test cases for the {@link Fraction} class */ public class FractionTest { - + private static final int SKIP = 500; //53 //-------------------------------------------------------------------------- @@ -38,37 +38,37 @@ public class FractionTest { public void testConstants() { assertEquals(0, Fraction.ZERO.getNumerator()); assertEquals(1, Fraction.ZERO.getDenominator()); - + assertEquals(1, Fraction.ONE.getNumerator()); assertEquals(1, Fraction.ONE.getDenominator()); - + assertEquals(1, Fraction.ONE_HALF.getNumerator()); assertEquals(2, Fraction.ONE_HALF.getDenominator()); - + assertEquals(1, Fraction.ONE_THIRD.getNumerator()); assertEquals(3, Fraction.ONE_THIRD.getDenominator()); - + assertEquals(2, Fraction.TWO_THIRDS.getNumerator()); assertEquals(3, Fraction.TWO_THIRDS.getDenominator()); - + assertEquals(1, Fraction.ONE_QUARTER.getNumerator()); assertEquals(4, Fraction.ONE_QUARTER.getDenominator()); - + assertEquals(2, Fraction.TWO_QUARTERS.getNumerator()); assertEquals(4, Fraction.TWO_QUARTERS.getDenominator()); - + assertEquals(3, Fraction.THREE_QUARTERS.getNumerator()); assertEquals(4, Fraction.THREE_QUARTERS.getDenominator()); - + assertEquals(1, Fraction.ONE_FIFTH.getNumerator()); assertEquals(5, Fraction.ONE_FIFTH.getDenominator()); - + assertEquals(2, Fraction.TWO_FIFTHS.getNumerator()); assertEquals(5, Fraction.TWO_FIFTHS.getDenominator()); - + assertEquals(3, Fraction.THREE_FIFTHS.getNumerator()); assertEquals(5, Fraction.THREE_FIFTHS.getDenominator()); - + assertEquals(4, Fraction.FOUR_FIFTHS.getNumerator()); assertEquals(5, Fraction.FOUR_FIFTHS.getDenominator()); } @@ -76,58 +76,58 @@ public class FractionTest { @Test public void testFactory_int_int() { Fraction f = null; - + // zero f = Fraction.getFraction(0, 1); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction(0, 2); assertEquals(0, f.getNumerator()); assertEquals(2, f.getDenominator()); - + // normal f = Fraction.getFraction(1, 1); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction(2, 1); assertEquals(2, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction(23, 345); assertEquals(23, f.getNumerator()); assertEquals(345, f.getDenominator()); - + // improper f = Fraction.getFraction(22, 7); assertEquals(22, f.getNumerator()); assertEquals(7, f.getDenominator()); - + // negatives f = Fraction.getFraction(-6, 10); assertEquals(-6, f.getNumerator()); assertEquals(10, f.getDenominator()); - + f = Fraction.getFraction(6, -10); assertEquals(-6, f.getNumerator()); assertEquals(10, f.getDenominator()); - + f = Fraction.getFraction(-6, -10); assertEquals(6, f.getNumerator()); assertEquals(10, f.getDenominator()); - + // zero denominator try { f = Fraction.getFraction(1, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(2, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(-3, 0); fail("expecting ArithmeticException"); @@ -147,25 +147,25 @@ public class FractionTest { @Test public void testFactory_int_int_int() { Fraction f = null; - + // zero f = Fraction.getFraction(0, 0, 2); assertEquals(0, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction(2, 0, 2); assertEquals(4, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction(0, 1, 2); assertEquals(1, f.getNumerator()); assertEquals(2, f.getDenominator()); - + // normal f = Fraction.getFraction(1, 1, 2); assertEquals(3, f.getNumerator()); assertEquals(2, f.getDenominator()); - + // negatives try { f = Fraction.getFraction(1, -6, -10); @@ -181,12 +181,12 @@ public class FractionTest { f = Fraction.getFraction(1, -6, -10); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + // negative whole f = Fraction.getFraction(-1, 6, 10); assertEquals(-16, f.getNumerator()); assertEquals(10, f.getDenominator()); - + try { f = Fraction.getFraction(-1, -6, 10); fail("expecting ArithmeticException"); @@ -196,33 +196,33 @@ public class FractionTest { f = Fraction.getFraction(-1, 6, -10); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(-1, -6, -10); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + // zero denominator try { f = Fraction.getFraction(0, 1, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(1, 2, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(-1, -3, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { - f = Fraction.getFraction(Integer.MAX_VALUE, 1, 2); + f = Fraction.getFraction(Integer.MAX_VALUE, 1, 2); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(-Integer.MAX_VALUE, 1, 2); fail("expecting ArithmeticException"); @@ -250,87 +250,87 @@ public class FractionTest { @Test public void testReducedFactory_int_int() { Fraction f = null; - + // zero f = Fraction.getReducedFraction(0, 1); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + // normal f = Fraction.getReducedFraction(1, 1); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getReducedFraction(2, 1); assertEquals(2, f.getNumerator()); assertEquals(1, f.getDenominator()); - + // improper f = Fraction.getReducedFraction(22, 7); assertEquals(22, f.getNumerator()); assertEquals(7, f.getDenominator()); - + // negatives f = Fraction.getReducedFraction(-6, 10); assertEquals(-3, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f = Fraction.getReducedFraction(6, -10); assertEquals(-3, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f = Fraction.getReducedFraction(-6, -10); assertEquals(3, f.getNumerator()); assertEquals(5, f.getDenominator()); - + // zero denominator try { f = Fraction.getReducedFraction(1, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getReducedFraction(2, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getReducedFraction(-3, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - // reduced + // reduced f = Fraction.getReducedFraction(0, 2); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getReducedFraction(2, 2); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getReducedFraction(2, 4); assertEquals(1, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getReducedFraction(15, 10); assertEquals(3, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getReducedFraction(121, 22); assertEquals(11, f.getNumerator()); assertEquals(2, f.getDenominator()); - - // Extreme values + + // Extreme values // OK, can reduce before negating f = Fraction.getReducedFraction(-2, Integer.MIN_VALUE); assertEquals(1, f.getNumerator()); assertEquals(-(Integer.MIN_VALUE / 2), f.getDenominator()); - + // Can't reduce, negation will throw - try { - f = Fraction.getReducedFraction(-7, Integer.MIN_VALUE); + try { + f = Fraction.getReducedFraction(-7, Integer.MIN_VALUE); fail("Expecting ArithmeticException"); - } catch (final ArithmeticException ex) {} + } catch (final ArithmeticException ex) {} // LANG-662 f = Fraction.getReducedFraction(Integer.MIN_VALUE, 2); @@ -341,62 +341,62 @@ public class FractionTest { @Test public void testFactory_double() { Fraction f = null; - + try { f = Fraction.getFraction(Double.NaN); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(Double.POSITIVE_INFINITY); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(Double.NEGATIVE_INFINITY); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction((double) Integer.MAX_VALUE + 1); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + // zero f = Fraction.getFraction(0.0d); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + // one f = Fraction.getFraction(1.0d); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + // one half f = Fraction.getFraction(0.5d); assertEquals(1, f.getNumerator()); assertEquals(2, f.getDenominator()); - + // negative f = Fraction.getFraction(-0.875d); assertEquals(-7, f.getNumerator()); assertEquals(8, f.getDenominator()); - + // over 1 f = Fraction.getFraction(1.25d); assertEquals(5, f.getNumerator()); assertEquals(4, f.getDenominator()); - + // two thirds f = Fraction.getFraction(0.66666d); assertEquals(2, f.getNumerator()); assertEquals(3, f.getDenominator()); - + // small f = Fraction.getFraction(1.0d/10001d); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + // normal Fraction f2 = null; for (int i = 1; i <= 100; i++) { // denominator @@ -432,38 +432,38 @@ public class FractionTest { public void testFactory_String() { Fraction.getFraction(null); } - - + + @Test public void testFactory_String_double() { Fraction f = null; - + f = Fraction.getFraction("0.0"); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction("0.2"); assertEquals(1, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f = Fraction.getFraction("0.5"); assertEquals(1, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction("0.66666"); assertEquals(2, f.getNumerator()); assertEquals(3, f.getDenominator()); - + try { f = Fraction.getFraction("2.3R"); fail("Expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("2147483648"); // too big fail("Expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("."); fail("Expecting NumberFormatException"); @@ -473,46 +473,46 @@ public class FractionTest { @Test public void testFactory_String_proper() { Fraction f = null; - + f = Fraction.getFraction("0 0/1"); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction("1 1/5"); assertEquals(6, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f = Fraction.getFraction("7 1/2"); assertEquals(15, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction("1 2/4"); assertEquals(6, f.getNumerator()); assertEquals(4, f.getDenominator()); - + f = Fraction.getFraction("-7 1/2"); assertEquals(-15, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction("-1 2/4"); assertEquals(-6, f.getNumerator()); assertEquals(4, f.getDenominator()); - + try { f = Fraction.getFraction("2 3"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("a 3"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("2 b/4"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("2 "); fail("expecting NumberFormatException"); @@ -522,7 +522,7 @@ public class FractionTest { f = Fraction.getFraction(" 3"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction(" "); fail("expecting NumberFormatException"); @@ -532,46 +532,46 @@ public class FractionTest { @Test public void testFactory_String_improper() { Fraction f = null; - + f = Fraction.getFraction("0/1"); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction("1/5"); assertEquals(1, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f = Fraction.getFraction("1/2"); assertEquals(1, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction("2/3"); assertEquals(2, f.getNumerator()); assertEquals(3, f.getDenominator()); - + f = Fraction.getFraction("7/3"); assertEquals(7, f.getNumerator()); assertEquals(3, f.getDenominator()); - + f = Fraction.getFraction("2/4"); assertEquals(2, f.getNumerator()); assertEquals(4, f.getDenominator()); - + try { f = Fraction.getFraction("2/d"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("2e/3"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("2/"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("/"); fail("expecting NumberFormatException"); @@ -581,13 +581,13 @@ public class FractionTest { @Test public void testGets() { Fraction f = null; - + f = Fraction.getFraction(3, 5, 6); assertEquals(23, f.getNumerator()); assertEquals(3, f.getProperWhole()); assertEquals(5, f.getProperNumerator()); assertEquals(6, f.getDenominator()); - + f = Fraction.getFraction(-3, 5, 6); assertEquals(-23, f.getNumerator()); assertEquals(-3, f.getProperWhole()); @@ -600,22 +600,22 @@ public class FractionTest { assertEquals(0, f.getProperNumerator()); assertEquals(1, f.getDenominator()); } - + @Test public void testConversions() { Fraction f = null; - + f = Fraction.getFraction(3, 7, 8); assertEquals(3, f.intValue()); assertEquals(3L, f.longValue()); assertEquals(3.875f, f.floatValue(), 0.00001f); assertEquals(3.875d, f.doubleValue(), 0.00001d); } - + @Test public void testReduce() { Fraction f = null; - + f = Fraction.getFraction(50, 75); Fraction result = f.reduce(); assertEquals(2, result.getNumerator()); @@ -660,26 +660,26 @@ public class FractionTest { assertEquals(Integer.MIN_VALUE / 2, result.getNumerator()); assertEquals(1, result.getDenominator()); } - + @Test public void testInvert() { Fraction f = null; - + f = Fraction.getFraction(50, 75); f = f.invert(); assertEquals(75, f.getNumerator()); assertEquals(50, f.getDenominator()); - + f = Fraction.getFraction(4, 3); f = f.invert(); assertEquals(3, f.getNumerator()); assertEquals(4, f.getDenominator()); - + f = Fraction.getFraction(-15, 47); f = f.invert(); assertEquals(-47, f.getNumerator()); assertEquals(15, f.getDenominator()); - + f = Fraction.getFraction(0, 3); try { f = f.invert(); @@ -698,16 +698,16 @@ public class FractionTest { assertEquals(1, f.getNumerator()); assertEquals(Integer.MAX_VALUE, f.getDenominator()); } - + @Test public void testNegate() { Fraction f = null; - + f = Fraction.getFraction(50, 75); f = f.negate(); assertEquals(-50, f.getNumerator()); assertEquals(75, f.getDenominator()); - + f = Fraction.getFraction(-50, 75); f = f.negate(); assertEquals(50, f.getNumerator()); @@ -725,16 +725,16 @@ public class FractionTest { fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} } - + @Test public void testAbs() { Fraction f = null; - + f = Fraction.getFraction(50, 75); f = f.abs(); assertEquals(50, f.getNumerator()); assertEquals(75, f.getDenominator()); - + f = Fraction.getFraction(-50, 75); f = f.abs(); assertEquals(50, f.getNumerator()); @@ -756,14 +756,14 @@ public class FractionTest { fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} } - + @Test public void testPow() { Fraction f = null; - + f = Fraction.getFraction(3, 5); assertEquals(Fraction.ONE, f.pow(0)); - + f = Fraction.getFraction(3, 5); assertSame(f, f.pow(1)); assertEquals(f, f.pow(1)); @@ -772,26 +772,26 @@ public class FractionTest { f = f.pow(2); assertEquals(9, f.getNumerator()); assertEquals(25, f.getDenominator()); - + f = Fraction.getFraction(3, 5); f = f.pow(3); assertEquals(27, f.getNumerator()); assertEquals(125, f.getDenominator()); - + f = Fraction.getFraction(3, 5); f = f.pow(-1); assertEquals(5, f.getNumerator()); assertEquals(3, f.getDenominator()); - + f = Fraction.getFraction(3, 5); f = f.pow(-2); assertEquals(25, f.getNumerator()); assertEquals(9, f.getDenominator()); - + // check unreduced fractions stay that way. f = Fraction.getFraction(6, 10); assertEquals(Fraction.ONE, f.pow(0)); - + f = Fraction.getFraction(6, 10); assertEquals(f, f.pow(1)); assertFalse(f.pow(1).equals(Fraction.getFraction(3,5))); @@ -800,22 +800,22 @@ public class FractionTest { f = f.pow(2); assertEquals(9, f.getNumerator()); assertEquals(25, f.getDenominator()); - + f = Fraction.getFraction(6, 10); f = f.pow(3); assertEquals(27, f.getNumerator()); assertEquals(125, f.getDenominator()); - + f = Fraction.getFraction(6, 10); f = f.pow(-1); assertEquals(10, f.getNumerator()); assertEquals(6, f.getDenominator()); - + f = Fraction.getFraction(6, 10); f = f.pow(-2); assertEquals(25, f.getNumerator()); assertEquals(9, f.getDenominator()); - + // zero to any positive power is still zero. f = Fraction.getFraction(0, 1231); f = f.pow(1); @@ -869,73 +869,73 @@ public class FractionTest { fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} } - + @Test public void testAdd() { Fraction f = null; Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(1, 5); f = f1.add(f2); assertEquals(4, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(2, 5); f = f1.add(f2); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(3, 5); f = f1.add(f2); assertEquals(6, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(-4, 5); f = f1.add(f2); assertEquals(-1, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(Integer.MAX_VALUE - 1, 1); f2 = Fraction.ONE; f = f1.add(f2); assertEquals(Integer.MAX_VALUE, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(1, 2); f = f1.add(f2); assertEquals(11, f.getNumerator()); assertEquals(10, f.getDenominator()); - + f1 = Fraction.getFraction(3, 8); f2 = Fraction.getFraction(1, 6); f = f1.add(f2); assertEquals(13, f.getNumerator()); assertEquals(24, f.getDenominator()); - + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(1, 5); f = f1.add(f2); assertSame(f2, f); f = f2.add(f1); assertSame(f2, f); - + f1 = Fraction.getFraction(-1, 13*13*2*2); f2 = Fraction.getFraction(-2, 13*17*2); f = f1.add(f2); assertEquals(13*13*17*2*2, f.getDenominator()); assertEquals(-17 - 2*13*2, f.getNumerator()); - + try { f.add(null); fail("expecting IllegalArgumentException"); } catch (final IllegalArgumentException ex) {} - + // if this fraction is added naively, it will overflow. // check that it doesn't. f1 = Fraction.getFraction(1,32768*3); @@ -949,18 +949,18 @@ public class FractionTest { f = f1.add(f2); assertEquals(Integer.MIN_VALUE+1, f.getNumerator()); assertEquals(3, f.getDenominator()); - + f1 = Fraction.getFraction(Integer.MAX_VALUE - 1, 1); f2 = Fraction.ONE; f = f1.add(f2); assertEquals(Integer.MAX_VALUE, f.getNumerator()); assertEquals(1, f.getDenominator()); - + try { f = f.add(Fraction.ONE); // should overflow fail("expecting ArithmeticException but got: " + f.toString()); } catch (final ArithmeticException ex) {} - + // denominator should not be a multiple of 2 or 3 to trigger overflow f1 = Fraction.getFraction(Integer.MIN_VALUE, 5); f2 = Fraction.getFraction(-1,5); @@ -968,19 +968,19 @@ public class FractionTest { f = f1.add(f2); // should overflow fail("expecting ArithmeticException but got: " + f.toString()); } catch (final ArithmeticException ex) {} - + try { f= Fraction.getFraction(-Integer.MAX_VALUE, 1); f = f.add(f); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f= Fraction.getFraction(-Integer.MAX_VALUE, 1); f = f.add(f); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + f1 = Fraction.getFraction(3,327680); f2 = Fraction.getFraction(2,59049); try { @@ -988,65 +988,65 @@ public class FractionTest { fail("expecting ArithmeticException but got: " + f.toString()); } catch (final ArithmeticException ex) {} } - + @Test public void testSubtract() { Fraction f = null; Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(1, 5); f = f1.subtract(f2); assertEquals(2, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(7, 5); f2 = Fraction.getFraction(2, 5); f = f1.subtract(f2); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(3, 5); f = f1.subtract(f2); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(-4, 5); f = f1.subtract(f2); assertEquals(7, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(4, 5); f = f1.subtract(f2); assertEquals(-4, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(-4, 5); f = f1.subtract(f2); assertEquals(4, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(1, 2); f = f1.subtract(f2); assertEquals(1, f.getNumerator()); assertEquals(10, f.getDenominator()); - + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(1, 5); f = f2.subtract(f1); assertSame(f2, f); - + try { f.subtract(null); fail("expecting IllegalArgumentException"); } catch (final IllegalArgumentException ex) {} - + // if this fraction is subtracted naively, it will overflow. // check that it doesn't. f1 = Fraction.getFraction(1,32768*3); @@ -1060,7 +1060,7 @@ public class FractionTest { f = f1.subtract(f2); assertEquals(Integer.MIN_VALUE+1, f.getNumerator()); assertEquals(3, f.getDenominator()); - + f1 = Fraction.getFraction(Integer.MAX_VALUE, 1); f2 = Fraction.ONE; f = f1.subtract(f2); @@ -1073,7 +1073,7 @@ public class FractionTest { f = f1.subtract(f2); fail("expecting ArithmeticException"); //should overflow } catch (final ArithmeticException ex) {} - + // denominator should not be a multiple of 2 or 3 to trigger overflow f1 = Fraction.getFraction(Integer.MIN_VALUE, 5); f2 = Fraction.getFraction(1,5); @@ -1081,19 +1081,19 @@ public class FractionTest { f = f1.subtract(f2); // should overflow fail("expecting ArithmeticException but got: " + f.toString()); } catch (final ArithmeticException ex) {} - + try { f= Fraction.getFraction(Integer.MIN_VALUE, 1); f = f.subtract(Fraction.ONE); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f= Fraction.getFraction(Integer.MAX_VALUE, 1); f = f.subtract(Fraction.ONE.negate()); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + f1 = Fraction.getFraction(3,327680); f2 = Fraction.getFraction(2,59049); try { @@ -1101,19 +1101,19 @@ public class FractionTest { fail("expecting ArithmeticException but got: " + f.toString()); } catch (final ArithmeticException ex) {} } - + @Test public void testMultiply() { Fraction f = null; Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(2, 5); f = f1.multiplyBy(f2); assertEquals(6, f.getNumerator()); assertEquals(25, f.getDenominator()); - + f1 = Fraction.getFraction(6, 10); f2 = Fraction.getFraction(6, 10); f = f1.multiplyBy(f2); @@ -1122,31 +1122,31 @@ public class FractionTest { f = f.multiplyBy(f2); assertEquals(27, f.getNumerator()); assertEquals(125, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(-2, 5); f = f1.multiplyBy(f2); assertEquals(-6, f.getNumerator()); assertEquals(25, f.getDenominator()); - + f1 = Fraction.getFraction(-3, 5); f2 = Fraction.getFraction(-2, 5); f = f1.multiplyBy(f2); assertEquals(6, f.getNumerator()); assertEquals(25, f.getDenominator()); - - + + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(2, 7); f = f1.multiplyBy(f2); assertSame(Fraction.ZERO, f); - + f1 = Fraction.getFraction(2, 7); f2 = Fraction.ONE; f = f1.multiplyBy(f2); assertEquals(2, f.getNumerator()); assertEquals(7, f.getDenominator()); - + f1 = Fraction.getFraction(Integer.MAX_VALUE, 1); f2 = Fraction.getFraction(Integer.MIN_VALUE, Integer.MAX_VALUE); f = f1.multiplyBy(f2); @@ -1157,55 +1157,55 @@ public class FractionTest { f.multiplyBy(null); fail("expecting IllegalArgumentException"); } catch (final IllegalArgumentException ex) {} - + try { f1 = Fraction.getFraction(1, Integer.MAX_VALUE); f = f1.multiplyBy(f1); // should overflow fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f1 = Fraction.getFraction(1, -Integer.MAX_VALUE); f = f1.multiplyBy(f1); // should overflow fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} } - + @Test public void testDivide() { Fraction f = null; Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(2, 5); f = f1.divideBy(f2); assertEquals(3, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.ZERO; try { f = f1.divideBy(f2); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(2, 7); f = f1.divideBy(f2); assertSame(Fraction.ZERO, f); - + f1 = Fraction.getFraction(2, 7); f2 = Fraction.ONE; f = f1.divideBy(f2); assertEquals(2, f.getNumerator()); assertEquals(7, f.getDenominator()); - + f1 = Fraction.getFraction(1, Integer.MAX_VALUE); - f = f1.divideBy(f1); + f = f1.divideBy(f1); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f1 = Fraction.getFraction(Integer.MIN_VALUE, Integer.MAX_VALUE); f2 = Fraction.getFraction(1, Integer.MAX_VALUE); f = f1.divideBy(f2); @@ -1216,7 +1216,7 @@ public class FractionTest { f.divideBy(null); fail("IllegalArgumentException"); } catch (final IllegalArgumentException ex) {} - + try { f1 = Fraction.getFraction(1, Integer.MAX_VALUE); f = f1.divideBy(f1.invert()); // should overflow @@ -1228,69 +1228,69 @@ public class FractionTest { fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} } - + @Test public void testEquals() { Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); assertFalse(f1.equals(null)); assertFalse(f1.equals(new Object())); assertFalse(f1.equals(Integer.valueOf(6))); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(2, 5); assertFalse(f1.equals(f2)); assertTrue(f1.equals(f1)); assertTrue(f2.equals(f2)); - + f2 = Fraction.getFraction(3, 5); assertTrue(f1.equals(f2)); - + f2 = Fraction.getFraction(6, 10); assertFalse(f1.equals(f2)); } - + @Test public void testHashCode() { final Fraction f1 = Fraction.getFraction(3, 5); Fraction f2 = Fraction.getFraction(3, 5); - + assertTrue(f1.hashCode() == f2.hashCode()); - + f2 = Fraction.getFraction(2, 5); assertTrue(f1.hashCode() != f2.hashCode()); - + f2 = Fraction.getFraction(6, 10); assertTrue(f1.hashCode() != f2.hashCode()); } - + @Test public void testCompareTo() { Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); assertTrue(f1.compareTo(f1) == 0); - + try { f1.compareTo(null); fail("expecting NullPointerException"); } catch (final NullPointerException ex) {} - + f2 = Fraction.getFraction(2, 5); assertTrue(f1.compareTo(f2) > 0); assertTrue(f2.compareTo(f2) == 0); - + f2 = Fraction.getFraction(4, 5); assertTrue(f1.compareTo(f2) < 0); assertTrue(f2.compareTo(f2) == 0); - + f2 = Fraction.getFraction(3, 5); assertTrue(f1.compareTo(f2) == 0); assertTrue(f2.compareTo(f2) == 0); - + f2 = Fraction.getFraction(6, 10); assertTrue(f1.compareTo(f2) == 0); assertTrue(f2.compareTo(f2) == 0); @@ -1300,7 +1300,7 @@ public class FractionTest { assertTrue(f2.compareTo(f2) == 0); } - + @Test public void testToString() { Fraction f = null; @@ -1309,26 +1309,26 @@ public class FractionTest { final String str = f.toString(); assertEquals("3/5", str); assertSame(str, f.toString()); - + f = Fraction.getFraction(7, 5); - assertEquals("7/5", f.toString()); - + assertEquals("7/5", f.toString()); + f = Fraction.getFraction(4, 2); - assertEquals("4/2", f.toString()); - + assertEquals("4/2", f.toString()); + f = Fraction.getFraction(0, 2); - assertEquals("0/2", f.toString()); - + assertEquals("0/2", f.toString()); + f = Fraction.getFraction(2, 2); - assertEquals("2/2", f.toString()); + assertEquals("2/2", f.toString()); f = Fraction.getFraction(Integer.MIN_VALUE, 0, 1); - assertEquals("-2147483648/1", f.toString()); + assertEquals("-2147483648/1", f.toString()); f = Fraction.getFraction(-1, 1, Integer.MAX_VALUE); assertEquals("-2147483648/2147483647", f.toString()); } - + @Test public void testToProperString() { Fraction f = null; @@ -1337,27 +1337,27 @@ public class FractionTest { final String str = f.toProperString(); assertEquals("3/5", str); assertSame(str, f.toProperString()); - + f = Fraction.getFraction(7, 5); - assertEquals("1 2/5", f.toProperString()); - + assertEquals("1 2/5", f.toProperString()); + f = Fraction.getFraction(14, 10); - assertEquals("1 4/10", f.toProperString()); - + assertEquals("1 4/10", f.toProperString()); + f = Fraction.getFraction(4, 2); - assertEquals("2", f.toProperString()); - + assertEquals("2", f.toProperString()); + f = Fraction.getFraction(0, 2); - assertEquals("0", f.toProperString()); - + assertEquals("0", f.toProperString()); + f = Fraction.getFraction(2, 2); - assertEquals("1", f.toProperString()); - + assertEquals("1", f.toProperString()); + f = Fraction.getFraction(-7, 5); - assertEquals("-1 2/5", f.toProperString()); + assertEquals("-1 2/5", f.toProperString()); f = Fraction.getFraction(Integer.MIN_VALUE, 0, 1); - assertEquals("-2147483648", f.toProperString()); + assertEquals("-2147483648", f.toProperString()); f = Fraction.getFraction(-1, 1, Integer.MAX_VALUE); assertEquals("-1 1/2147483647", 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 1c98c3ddc..026c0f72c 100644 --- a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -101,5 +101,5 @@ public class IEEE754rUtilsTest { public void testConstructorExists() { new IEEE754rUtils(); } - + } 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 e50423923..3a53c1ebb 100644 --- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java @@ -114,7 +114,7 @@ public class NumberUtilsTest { assertTrue("toFloat(String,int) 1 failed", NumberUtils.toFloat("1.2345", 5.1f) == 1.2345f); assertTrue("toFloat(String,int) 2 failed", NumberUtils.toFloat("a", 5.0f) == 5.0f); } - + /** * Test for {(@link NumberUtils#createNumber(String)} */ @@ -123,7 +123,7 @@ public class NumberUtilsTest { final String shouldBeFloat = "1.23"; final String shouldBeDouble = "3.40282354e+38"; final String shouldBeBigDecimal = "1.797693134862315759e+308"; - + assertTrue(NumberUtils.createNumber(shouldBeFloat) instanceof Float); assertTrue(NumberUtils.createNumber(shouldBeDouble) instanceof Double); assertTrue(NumberUtils.createNumber(shouldBeBigDecimal) instanceof BigDecimal); @@ -243,7 +243,7 @@ public class NumberUtilsTest { final Number bigNum = NumberUtils.createNumber("-1.1E-700F"); assertNotNull(bigNum); assertEquals(BigDecimal.class, bigNum.getClass()); - + // LANG-1018 assertEquals("createNumber(String) LANG-1018 failed", Double.valueOf("-160952.54"), NumberUtils.createNumber("-160952.54")); @@ -254,7 +254,7 @@ public class NumberUtilsTest { assertEquals("createNumber(String) LANG-1215 failed", Double.valueOf("193343.82"), NumberUtils.createNumber("193343.82")); } - + @Test public void testLang1087(){ // no sign cases @@ -1418,7 +1418,7 @@ public class NumberUtilsTest { } fail("Expecting "+ expected + " for isCreatable/createNumber using \"" + val + "\" but got " + isValid + " and " + canCreate); } - + @Test public void testIsParsable() { assertFalse( NumberUtils.isParsable(null) ); diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java index 67c6229a0..09c793c58 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @since 2.2 * @see MutableBoolean */ @@ -41,7 +41,7 @@ public class MutableBooleanTest { assertEquals(+1, mutBool.compareTo(new MutableBoolean(false))); assertEquals(0, mutBool.compareTo(new MutableBoolean(true))); } - + @Test(expected=NullPointerException.class) public void testCompareToNull() { final MutableBoolean mutBool = new MutableBoolean(false); @@ -88,7 +88,7 @@ public class MutableBooleanTest { public void testGetSet() { assertFalse(new MutableBoolean().booleanValue()); assertEquals(Boolean.FALSE, new MutableBoolean().getValue()); - + final MutableBoolean mutBool = new MutableBoolean(false); assertEquals(Boolean.FALSE, mutBool.toBoolean()); assertFalse(mutBool.booleanValue()); 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 10d9aeeed..61dfd0d9c 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @see MutableByte */ public class MutableByteTest { @@ -33,9 +33,9 @@ public class MutableByteTest { @Test public void testConstructors() { assertEquals((byte) 0, new MutableByte().byteValue()); - + assertEquals((byte) 1, new MutableByte((byte) 1).byteValue()); - + assertEquals((byte) 2, new MutableByte(Byte.valueOf((byte) 2)).byteValue()); assertEquals((byte) 3, new MutableByte(new MutableByte((byte) 3)).byteValue()); @@ -53,15 +53,15 @@ public class MutableByteTest { final MutableByte mutNum = new MutableByte((byte) 0); assertEquals((byte) 0, new MutableByte().byteValue()); assertEquals(Byte.valueOf((byte) 0), new MutableByte().getValue()); - + mutNum.setValue((byte) 1); assertEquals((byte) 1, mutNum.byteValue()); assertEquals(Byte.valueOf((byte) 1), mutNum.getValue()); - + mutNum.setValue(Byte.valueOf((byte) 2)); assertEquals((byte) 2, mutNum.byteValue()); assertEquals(Byte.valueOf((byte) 2), mutNum.getValue()); - + mutNum.setValue(new MutableByte((byte) 3)); assertEquals((byte) 3, mutNum.byteValue()); assertEquals(Byte.valueOf((byte) 3), mutNum.getValue()); @@ -121,7 +121,7 @@ public class MutableByteTest { @Test public void testPrimitiveValues() { final MutableByte mutNum = new MutableByte( (byte) 1 ); - + assertEquals( 1.0F, mutNum.floatValue(), 0 ); assertEquals( 1.0, mutNum.doubleValue(), 0 ); assertEquals( (byte) 1, mutNum.byteValue() ); @@ -140,7 +140,7 @@ public class MutableByteTest { public void testIncrement() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -169,7 +169,7 @@ public class MutableByteTest { public void testDecrement() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -198,7 +198,7 @@ public class MutableByteTest { public void testAddValuePrimitive() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.add((byte)1); - + assertEquals((byte) 2, mutNum.byteValue()); } @@ -206,7 +206,7 @@ public class MutableByteTest { public void testAddValueObject() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.add(Integer.valueOf(1)); - + assertEquals((byte) 2, mutNum.byteValue()); } @@ -250,7 +250,7 @@ public class MutableByteTest { public void testSubtractValuePrimitive() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.subtract((byte) 1); - + assertEquals((byte) 0, mutNum.byteValue()); } @@ -258,7 +258,7 @@ public class MutableByteTest { public void testSubtractValueObject() { 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 8cfb8f327..df1b6d54c 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @see MutableDouble */ public class MutableDoubleTest { @@ -33,12 +33,12 @@ public class MutableDoubleTest { @Test public void testConstructors() { assertEquals(0d, new MutableDouble().doubleValue(), 0.0001d); - + assertEquals(1d, new MutableDouble(1d).doubleValue(), 0.0001d); - + assertEquals(2d, new MutableDouble(Double.valueOf(2d)).doubleValue(), 0.0001d); assertEquals(3d, new MutableDouble(new MutableDouble(3d)).doubleValue(), 0.0001d); - + assertEquals(2d, new MutableDouble("2.0").doubleValue(), 0.0001d); } @@ -53,15 +53,15 @@ public class MutableDoubleTest { final MutableDouble mutNum = new MutableDouble(0d); assertEquals(0d, new MutableDouble().doubleValue(), 0.0001d); assertEquals(Double.valueOf(0), new MutableDouble().getValue()); - + mutNum.setValue(1); assertEquals(1d, mutNum.doubleValue(), 0.0001d); assertEquals(Double.valueOf(1d), mutNum.getValue()); - + mutNum.setValue(Double.valueOf(2d)); assertEquals(2d, mutNum.doubleValue(), 0.0001d); assertEquals(Double.valueOf(2d), mutNum.getValue()); - + mutNum.setValue(new MutableDouble(3d)); assertEquals(3d, mutNum.doubleValue(), 0.0001d); assertEquals(Double.valueOf(3d), mutNum.getValue()); @@ -77,10 +77,10 @@ public class MutableDoubleTest { public void testNanInfinite() { MutableDouble mutNum = new MutableDouble(Double.NaN); assertTrue(mutNum.isNaN()); - + mutNum = new MutableDouble(Double.POSITIVE_INFINITY); assertTrue(mutNum.isInfinite()); - + mutNum = new MutableDouble(Double.NEGATIVE_INFINITY); assertTrue(mutNum.isInfinite()); } @@ -133,7 +133,7 @@ public class MutableDoubleTest { @Test public void testPrimitiveValues() { final MutableDouble mutNum = new MutableDouble(1.7); - + assertEquals( 1.7F, mutNum.floatValue(), 0 ); assertEquals( 1.7, mutNum.doubleValue(), 0 ); assertEquals( (byte) 1, mutNum.byteValue() ); @@ -152,7 +152,7 @@ public class MutableDoubleTest { public void testIncrement() { final MutableDouble mutNum = new MutableDouble(1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -181,7 +181,7 @@ public class MutableDoubleTest { public void testDecrement() { final MutableDouble mutNum = new MutableDouble(1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -210,7 +210,7 @@ public class MutableDoubleTest { public void testAddValuePrimitive() { final MutableDouble mutNum = new MutableDouble(1); mutNum.add(1.1d); - + assertEquals(2.1d, mutNum.doubleValue(), 0.01d); } @@ -218,7 +218,7 @@ public class MutableDoubleTest { public void testAddValueObject() { final MutableDouble mutNum = new MutableDouble(1); mutNum.add(Double.valueOf(1.1d)); - + assertEquals(2.1d, mutNum.doubleValue(), 0.01d); } @@ -262,7 +262,7 @@ public class MutableDoubleTest { public void testSubtractValuePrimitive() { final MutableDouble mutNum = new MutableDouble(1); mutNum.subtract(0.9d); - + assertEquals(0.1d, mutNum.doubleValue(), 0.01d); } @@ -270,7 +270,7 @@ public class MutableDoubleTest { public void testSubtractValueObject() { 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 af4abd8da..169763a50 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @see MutableFloat */ public class MutableFloatTest { @@ -33,9 +33,9 @@ public class MutableFloatTest { @Test public void testConstructors() { assertEquals(0f, new MutableFloat().floatValue(), 0.0001f); - + assertEquals(1f, new MutableFloat(1f).floatValue(), 0.0001f); - + assertEquals(2f, new MutableFloat(Float.valueOf(2f)).floatValue(), 0.0001f); assertEquals(3f, new MutableFloat(new MutableFloat(3f)).floatValue(), 0.0001f); @@ -53,15 +53,15 @@ public class MutableFloatTest { final MutableFloat mutNum = new MutableFloat(0f); assertEquals(0f, new MutableFloat().floatValue(), 0.0001f); assertEquals(Float.valueOf(0), new MutableFloat().getValue()); - + mutNum.setValue(1); assertEquals(1f, mutNum.floatValue(), 0.0001f); assertEquals(Float.valueOf(1f), mutNum.getValue()); - + mutNum.setValue(Float.valueOf(2f)); assertEquals(2f, mutNum.floatValue(), 0.0001f); assertEquals(Float.valueOf(2f), mutNum.getValue()); - + mutNum.setValue(new MutableFloat(3f)); assertEquals(3f, mutNum.floatValue(), 0.0001f); assertEquals(Float.valueOf(3f), mutNum.getValue()); @@ -77,10 +77,10 @@ public class MutableFloatTest { public void testNanInfinite() { MutableFloat mutNum = new MutableFloat(Float.NaN); assertTrue(mutNum.isNaN()); - + mutNum = new MutableFloat(Float.POSITIVE_INFINITY); assertTrue(mutNum.isInfinite()); - + mutNum = new MutableFloat(Float.NEGATIVE_INFINITY); assertTrue(mutNum.isInfinite()); } @@ -133,7 +133,7 @@ public class MutableFloatTest { @Test public void testPrimitiveValues() { final MutableFloat mutNum = new MutableFloat(1.7F); - + assertEquals( 1, mutNum.intValue() ); assertEquals( 1.7, mutNum.doubleValue(), 0.00001 ); assertEquals( (byte) 1, mutNum.byteValue() ); @@ -152,7 +152,7 @@ public class MutableFloatTest { public void testIncrement() { final MutableFloat mutNum = new MutableFloat(1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -181,7 +181,7 @@ public class MutableFloatTest { public void testDecrement() { final MutableFloat mutNum = new MutableFloat(1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -210,7 +210,7 @@ public class MutableFloatTest { public void testAddValuePrimitive() { final MutableFloat mutNum = new MutableFloat(1); mutNum.add(1.1f); - + assertEquals(2.1f, mutNum.floatValue(), 0.01f); } @@ -218,7 +218,7 @@ public class MutableFloatTest { public void testAddValueObject() { final MutableFloat mutNum = new MutableFloat(1); mutNum.add(Float.valueOf(1.1f)); - + assertEquals(2.1f, mutNum.floatValue(), 0.01f); } @@ -262,7 +262,7 @@ public class MutableFloatTest { public void testSubtractValuePrimitive() { final MutableFloat mutNum = new MutableFloat(1); mutNum.subtract(0.9f); - + assertEquals(0.1f, mutNum.floatValue(), 0.01f); } @@ -270,7 +270,7 @@ public class MutableFloatTest { public void testSubtractValueObject() { 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 d7efefd1d..9cf711edf 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @see MutableInt */ public class MutableIntTest { @@ -33,9 +33,9 @@ public class MutableIntTest { @Test public void testConstructors() { assertEquals(0, new MutableInt().intValue()); - + assertEquals(1, new MutableInt(1).intValue()); - + assertEquals(2, new MutableInt(Integer.valueOf(2)).intValue()); assertEquals(3, new MutableInt(new MutableLong(3)).intValue()); @@ -53,15 +53,15 @@ public class MutableIntTest { final MutableInt mutNum = new MutableInt(0); assertEquals(0, new MutableInt().intValue()); assertEquals(Integer.valueOf(0), new MutableInt().getValue()); - + mutNum.setValue(1); assertEquals(1, mutNum.intValue()); assertEquals(Integer.valueOf(1), mutNum.getValue()); - + mutNum.setValue(Integer.valueOf(2)); assertEquals(2, mutNum.intValue()); assertEquals(Integer.valueOf(2), mutNum.getValue()); - + mutNum.setValue(new MutableLong(3)); assertEquals(3, mutNum.intValue()); assertEquals(Integer.valueOf(3), mutNum.getValue()); @@ -128,7 +128,7 @@ public class MutableIntTest { @Test public void testPrimitiveValues() { final MutableInt mutNum = new MutableInt(1); - + assertEquals( (byte) 1, mutNum.byteValue() ); assertEquals( (short) 1, mutNum.shortValue() ); assertEquals( 1.0F, mutNum.floatValue(), 0 ); @@ -146,7 +146,7 @@ public class MutableIntTest { public void testIncrement() { final MutableInt mutNum = new MutableInt(1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -175,7 +175,7 @@ public class MutableIntTest { public void testDecrement() { final MutableInt mutNum = new MutableInt(1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -204,7 +204,7 @@ public class MutableIntTest { public void testAddValuePrimitive() { final MutableInt mutNum = new MutableInt(1); mutNum.add(1); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -213,7 +213,7 @@ public class MutableIntTest { public void testAddValueObject() { final MutableInt mutNum = new MutableInt(1); mutNum.add(Integer.valueOf(1)); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -258,7 +258,7 @@ public class MutableIntTest { public void testSubtractValuePrimitive() { final MutableInt mutNum = new MutableInt(1); mutNum.subtract(1); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -267,7 +267,7 @@ public class MutableIntTest { public void testSubtractValueObject() { final MutableInt mutNum = new MutableInt(1); mutNum.subtract(Integer.valueOf(1)); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } 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 c65c7895b..1ec522e5c 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @see MutableLong */ public class MutableLongTest { @@ -33,9 +33,9 @@ public class MutableLongTest { @Test public void testConstructors() { assertEquals(0, new MutableLong().longValue()); - + assertEquals(1, new MutableLong(1).longValue()); - + assertEquals(2, new MutableLong(Long.valueOf(2)).longValue()); assertEquals(3, new MutableLong(new MutableLong(3)).longValue()); @@ -53,15 +53,15 @@ public class MutableLongTest { final MutableLong mutNum = new MutableLong(0); assertEquals(0, new MutableLong().longValue()); assertEquals(Long.valueOf(0), new MutableLong().getValue()); - + mutNum.setValue(1); assertEquals(1, mutNum.longValue()); assertEquals(Long.valueOf(1), mutNum.getValue()); - + mutNum.setValue(Long.valueOf(2)); assertEquals(2, mutNum.longValue()); assertEquals(Long.valueOf(2), mutNum.getValue()); - + mutNum.setValue(new MutableLong(3)); assertEquals(3, mutNum.longValue()); assertEquals(Long.valueOf(3), mutNum.getValue()); @@ -140,7 +140,7 @@ public class MutableLongTest { public void testIncrement() { final MutableLong mutNum = new MutableLong(1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -169,7 +169,7 @@ public class MutableLongTest { public void testDecrement() { final MutableLong mutNum = new MutableLong(1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -198,7 +198,7 @@ public class MutableLongTest { public void testAddValuePrimitive() { final MutableLong mutNum = new MutableLong(1); mutNum.add(1); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -207,7 +207,7 @@ public class MutableLongTest { public void testAddValueObject() { final MutableLong mutNum = new MutableLong(1); mutNum.add(Long.valueOf(1)); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -252,7 +252,7 @@ public class MutableLongTest { public void testSubtractValuePrimitive() { final MutableLong mutNum = new MutableLong(1); mutNum.subtract(1); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -261,7 +261,7 @@ public class MutableLongTest { public void testSubtractValueObject() { final MutableLong mutNum = new MutableLong(1); mutNum.subtract(Long.valueOf(1)); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } 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 7e0047b7a..505047794 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import org.junit.Test; /** * JUnit tests. - * + * * @see MutableShort */ public class MutableObjectTest { @@ -35,7 +35,7 @@ public class MutableObjectTest { @Test public void testConstructors() { assertEquals(null, new MutableObject<String>().getValue()); - + final Integer i = Integer.valueOf(6); assertSame(i, new MutableObject<>(i).getValue()); assertSame("HI", new MutableObject<>("HI").getValue()); @@ -46,10 +46,10 @@ public class MutableObjectTest { public void testGetSet() { final MutableObject<String> mutNum = new MutableObject<>(); assertEquals(null, new MutableObject<>().getValue()); - + mutNum.setValue("HELLO"); assertSame("HELLO", mutNum.getValue()); - + mutNum.setValue(null); assertSame(null, mutNum.getValue()); } @@ -70,7 +70,7 @@ public class MutableObjectTest { assertTrue(mutNumC.equals(mutNumC)); assertFalse(mutNumA.equals(mutNumD)); assertTrue(mutNumD.equals(mutNumD)); - + assertFalse(mutNumA.equals(null)); assertFalse(mutNumA.equals(new Object())); assertFalse(mutNumA.equals("0")); 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 2b91b79da..fe926fff6 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,7 @@ import static org.junit.Assert.fail; /** * JUnit tests. - * + * * @see MutableShort */ public class MutableShortTest { @@ -34,9 +34,9 @@ public class MutableShortTest { @Test public void testConstructors() { assertEquals((short) 0, new MutableShort().shortValue()); - + assertEquals((short) 1, new MutableShort((short) 1).shortValue()); - + assertEquals((short) 2, new MutableShort(Short.valueOf((short) 2)).shortValue()); assertEquals((short) 3, new MutableShort(new MutableShort((short) 3)).shortValue()); @@ -53,15 +53,15 @@ public class MutableShortTest { final MutableShort mutNum = new MutableShort((short) 0); assertEquals((short) 0, new MutableShort().shortValue()); assertEquals(Short.valueOf((short) 0), new MutableShort().getValue()); - + mutNum.setValue((short) 1); assertEquals((short) 1, mutNum.shortValue()); assertEquals(Short.valueOf((short) 1), mutNum.getValue()); - + mutNum.setValue(Short.valueOf((short) 2)); assertEquals((short) 2, mutNum.shortValue()); assertEquals(Short.valueOf((short) 2), mutNum.getValue()); - + mutNum.setValue(new MutableShort((short) 3)); assertEquals((short) 3, mutNum.shortValue()); assertEquals(Short.valueOf((short) 3), mutNum.getValue()); @@ -117,7 +117,7 @@ public class MutableShortTest { @Test public void testPrimitiveValues() { final MutableShort mutNum = new MutableShort( (short) 1 ); - + assertEquals( 1.0F, mutNum.floatValue(), 0 ); assertEquals( 1.0, mutNum.doubleValue(), 0 ); assertEquals( (byte) 1, mutNum.byteValue() ); @@ -136,7 +136,7 @@ public class MutableShortTest { public void testIncrement() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -165,7 +165,7 @@ public class MutableShortTest { public void testDecrement() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -194,7 +194,7 @@ public class MutableShortTest { public void testAddValuePrimitive() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.add((short) 1); - + assertEquals((short) 2, mutNum.shortValue()); } @@ -202,7 +202,7 @@ public class MutableShortTest { public void testAddValueObject() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.add(Short.valueOf((short) 1)); - + assertEquals((short) 2, mutNum.shortValue()); } @@ -246,7 +246,7 @@ public class MutableShortTest { public void testSubtractValuePrimitive() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.subtract((short) 1); - + assertEquals((short) 0, mutNum.shortValue()); } @@ -254,7 +254,7 @@ public class MutableShortTest { public void testSubtractValueObject() { 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/FieldUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java index 3b7ca3c5a..16a3f59f5 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java @@ -1332,7 +1332,7 @@ public class FieldUtilsTest { assertFalse(Modifier.isFinal(field.getModifiers())); assertFalse(field.isAccessible()); } - + @Test public void testRemoveFinalModifierWithAccess() throws Exception { final Field field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE_2"); 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 16069e975..b3cef7a54 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java @@ -685,14 +685,14 @@ public class TypeUtilsTest<B> { stringComparableType)); Assert.assertEquals("java.lang.Comparable<java.lang.String>", stringComparableType.toString()); } - + @Test public void testParameterizeWithOwner() throws Exception { final Type owner = TypeUtils.parameterize(TypeUtilsTest.class, String.class); final ParameterizedType dat2Type = TypeUtils.parameterizeWithOwner(owner, That.class, String.class, String.class); Assert.assertTrue(TypeUtils.equals(getClass().getField("dat2").getGenericType(), dat2Type)); } - + @Test public void testWildcardType() throws Exception { final WildcardType simpleWildcard = TypeUtils.wildcardType().withUpperBounds(String.class).build(); diff --git a/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java b/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java index e5893a2c6..0bb091254 100644 --- a/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java +++ b/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitch.java b/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitch.java index 398341c72..cc26fa465 100644 --- a/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitch.java +++ b/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitch.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,12 +26,12 @@ import org.junit.runners.model.Statement; /** * Test Rule used with {@link SystemDefaults} annotation that sets and restores the system default Locale and TimeZone. - * + * * <p> * Set up tests to use alternate system default Locale and/or TimeZone by creating an instance of this rule - * and annotating the test method with {@link SystemDefaults} + * and annotating the test method with {@link SystemDefaults} * </p> - * + * * <pre> * public class SystemDefaultsDependentTest { * @@ -48,7 +48,7 @@ import org.junit.runners.model.Statement; * public void testWithSimplifiedChinaDefaultLocale() { * // Locale.getDefault() will return Locale.CHINA until the end of this test method * } - * + * * {@literal @}Test * {@literal @}SystemDefaults(timezone="America/New_York") * public void testWithNorthAmericaEasternTimeZone() { @@ -58,7 +58,7 @@ import org.junit.runners.model.Statement; * </pre> */ public class SystemDefaultsSwitch implements TestRule { - + @Override public Statement apply(final Statement stmt, final Description description) { final SystemDefaults defaults = description.getAnnotation(SystemDefaults.class); diff --git a/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitchTest.java b/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitchTest.java index d85d6abca..f2cd6f52c 100644 --- a/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitchTest.java +++ b/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitchTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 78202ffdc..f3b6cf765 100644 --- a/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ import java.util.Locale; public class CompositeFormatTest { /** - * Ensures that the parse/format separation is correctly maintained. + * Ensures that the parse/format separation is correctly maintained. */ @Test public void testCompositeFormat() { 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 f8916f640..41468a9bb 100644 --- a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -93,12 +93,12 @@ public class ExtendedMessageFormatTest { */ @Test public void testEscapedBraces_LANG_948() { - // message without placeholder because braces are escaped by quotes + // message without placeholder because braces are escaped by quotes final String pattern = "Message without placeholders '{}'"; final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry); assertEquals("Message without placeholders {}", emf.format(new Object[] {"DUMMY"})); - // message with placeholder because quotes are escaped by quotes + // message with placeholder because quotes are escaped by quotes final String pattern2 = "Message with placeholder ''{0}''"; final ExtendedMessageFormat emf2 = new ExtendedMessageFormat(pattern2, registry); assertEquals("Message with placeholder 'DUMMY'", emf2.format(new Object[] {"DUMMY"})); @@ -313,7 +313,7 @@ public class ExtendedMessageFormatTest { other = new OtherExtendedMessageFormat(pattern, Locale.US, fmtRegistry); assertFalse("class, equals()", emf.equals(other)); assertTrue("class, hashcode()", emf.hashCode() == other.hashCode()); // same hashcode - + // Different pattern other = new ExtendedMessageFormat("X" + pattern, Locale.US, fmtRegistry); assertFalse("pattern, equals()", emf.equals(other)); @@ -471,7 +471,7 @@ public class ExtendedMessageFormatTest { final Map<String, ? extends FormatFactory> registry) { super(pattern, locale, registry); } - + } } 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 dbb38e2ee..ed86721e1 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,7 +51,7 @@ public class StrBuilderAppendInsertTest { StrBuilder sb = new StrBuilder("---"); sb.appendNewLine().append("+++"); assertEquals("---" + SEP + "+++", sb.toString()); - + sb = new StrBuilder("---"); sb.setNewLineText("#").appendNewLine().setNewLineText(null).appendNewLine(); assertEquals("---#" + SEP, sb.toString()); @@ -117,7 +117,7 @@ public class StrBuilderAppendInsertTest { sb.append(new StringBuilder("bld")); // Check it supports StringBuilder assertEquals("foobazyesSeqbld", sb.toString()); } - + //----------------------------------------------------------------------- @Test public void testAppend_StringBuilder() { @@ -216,7 +216,7 @@ public class StrBuilderAppendInsertTest { sb.append( (CharSequence)"abcbardef", 4, 3); assertEquals("foobarard", sb.toString()); } - + //----------------------------------------------------------------------- @Test public void testAppend_StringBuilder_int_int() { @@ -826,7 +826,7 @@ public class StrBuilderAppendInsertTest { final StrBuilder sb = new StrBuilder(); sb.appendln(true); assertEquals("true" + SEP, sb.toString()); - + sb.clear(); sb.appendln(false); assertEquals("false" + SEP, sb.toString()); @@ -838,15 +838,15 @@ public class StrBuilderAppendInsertTest { final StrBuilder sb = new StrBuilder(); sb.appendln(0); assertEquals("0" + SEP, sb.toString()); - + sb.clear(); sb.appendln(1L); assertEquals("1" + SEP, sb.toString()); - + sb.clear(); sb.appendln(2.3f); assertEquals("2.3" + SEP, sb.toString()); - + sb.clear(); sb.appendln(4.5d); assertEquals("4.5" + SEP, sb.toString()); @@ -1201,7 +1201,7 @@ public class StrBuilderAppendInsertTest { sb.appendSeparator(","); assertEquals("foo,", sb.toString()); } - + //----------------------------------------------------------------------- @Test public void testAppendSeparator_String_String() { @@ -1213,11 +1213,11 @@ public class StrBuilderAppendInsertTest { assertEquals("", sb.toString()); sb.appendSeparator(standardSeparator, null); assertEquals("", sb.toString()); - sb.appendSeparator(standardSeparator, startSeparator); + sb.appendSeparator(standardSeparator, startSeparator); assertEquals(startSeparator, sb.toString()); - sb.appendSeparator(null, null); + sb.appendSeparator(null, null); assertEquals(startSeparator, sb.toString()); - sb.appendSeparator(null, startSeparator); + sb.appendSeparator(null, startSeparator); assertEquals(startSeparator, sb.toString()); sb.append(foo); assertEquals(startSeparator + foo, sb.toString()); @@ -1260,7 +1260,7 @@ public class StrBuilderAppendInsertTest { assertEquals("foo", sb.toString()); sb.appendSeparator(",", 1); assertEquals("foo,", sb.toString()); - + sb.appendSeparator(",", -1); // no effect assertEquals("foo,", sb.toString()); } @@ -1275,7 +1275,7 @@ public class StrBuilderAppendInsertTest { assertEquals("foo", sb.toString()); sb.appendSeparator(',', 1); assertEquals("foo,", sb.toString()); - + sb.appendSeparator(',', -1); // no effect assertEquals("foo,", sb.toString()); } 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 09af460cb..ea684b621 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -305,7 +305,7 @@ public class StrBuilderTest { public void testLength() { final StrBuilder sb = new StrBuilder(); assertEquals(0, sb.length()); - + sb.append("Hello"); assertEquals(5, sb.length()); } @@ -334,7 +334,7 @@ public class StrBuilderTest { public void testCapacity() { final StrBuilder sb = new StrBuilder(); assertEquals(sb.buffer.length, sb.capacity()); - + sb.append("HelloWorldHelloWorldHelloWorldHelloWorld"); assertEquals(sb.buffer.length, sb.capacity()); } @@ -344,10 +344,10 @@ public class StrBuilderTest { final StrBuilder sb = new StrBuilder(); sb.ensureCapacity(2); assertTrue(sb.capacity() >= 2); - + sb.ensureCapacity(-1); assertTrue(sb.capacity() >= 0); - + sb.append("HelloWorld"); sb.ensureCapacity(40); assertTrue(sb.capacity() >= 40); @@ -358,7 +358,7 @@ public class StrBuilderTest { final StrBuilder sb = new StrBuilder(); sb.minimizeCapacity(); assertEquals(0, sb.capacity()); - + sb.append("HelloWorld"); sb.minimizeCapacity(); assertEquals(10, sb.capacity()); @@ -369,7 +369,7 @@ public class StrBuilderTest { public void testSize() { final StrBuilder sb = new StrBuilder(); assertEquals(0, sb.size()); - + sb.append("Hello"); assertEquals(5, sb.size()); } @@ -378,10 +378,10 @@ public class StrBuilderTest { public void testIsEmpty() { final StrBuilder sb = new StrBuilder(); assertTrue(sb.isEmpty()); - + sb.append("Hello"); assertFalse(sb.isEmpty()); - + sb.clear(); assertTrue(sb.isEmpty()); } @@ -463,8 +463,8 @@ public class StrBuilderTest { public void testDeleteCharAt() { final StrBuilder sb = new StrBuilder("abc"); sb.deleteCharAt(0); - assertEquals("bc", sb.toString()); - + assertEquals("bc", sb.toString()); + try { sb.deleteCharAt(1000); fail("Expected IndexOutOfBoundsException"); @@ -524,26 +524,26 @@ public class StrBuilderTest { @Test public void testGetChars ( ) { final StrBuilder sb = new StrBuilder(); - + char[] input = new char[10]; char[] a = sb.getChars(input); assertSame (input, a); assertTrue(Arrays.equals(new char[10], a)); - + sb.append("junit"); a = sb.getChars(input); assertSame(input, a); assertTrue(Arrays.equals(new char[] {'j','u','n','i','t',0,0,0,0,0},a)); - + a = sb.getChars(null); assertNotSame(input,a); assertEquals(5,a.length); assertTrue(Arrays.equals("junit".toCharArray(),a)); - + input = new char[5]; a = sb.getChars(input); assertSame(input, a); - + input = new char[4]; a = sb.getChars(input); assertNotSame(input, a); @@ -552,37 +552,37 @@ public class StrBuilderTest { @Test public void testGetCharsIntIntCharArrayInt( ) { final StrBuilder sb = new StrBuilder(); - + sb.append("junit"); char[] a = new char[5]; sb.getChars(0,5,a,0); assertTrue(Arrays.equals(new char[] {'j','u','n','i','t'},a)); - + a = new char[5]; sb.getChars(0,2,a,3); assertTrue(Arrays.equals(new char[] {0,0,0,'j','u'},a)); - + try { sb.getChars(-1,0,a,0); fail("no exception"); } catch (final IndexOutOfBoundsException e) { } - + try { sb.getChars(0,-1,a,0); fail("no exception"); } catch (final IndexOutOfBoundsException e) { } - + try { sb.getChars(0,20,a,0); fail("no exception"); } catch (final IndexOutOfBoundsException e) { } - + try { sb.getChars(4,2,a,0); fail("no exception"); @@ -596,14 +596,14 @@ public class StrBuilderTest { public void testDeleteIntInt() { StrBuilder sb = new StrBuilder("abc"); sb.delete(0, 1); - assertEquals("bc", sb.toString()); + assertEquals("bc", sb.toString()); sb.delete(1, 2); assertEquals("b", sb.toString()); sb.delete(0, 1); - assertEquals("", sb.toString()); + assertEquals("", sb.toString()); sb.delete(0, 1000); - assertEquals("", sb.toString()); - + assertEquals("", sb.toString()); + try { sb.delete(1, 2); fail("Expected IndexOutOfBoundsException"); @@ -612,7 +612,7 @@ public class StrBuilderTest { sb.delete(-1, 1); fail("Expected IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) {} - + sb = new StrBuilder("anything"); try { sb.delete(2, 1); @@ -663,7 +663,7 @@ public class StrBuilderTest { assertEquals("abcbccba", sb.toString()); sb.deleteAll(""); assertEquals("abcbccba", sb.toString()); - + sb.deleteAll("X"); assertEquals("abcbccba", sb.toString()); sb.deleteAll("a"); @@ -759,7 +759,7 @@ public class StrBuilderTest { assertEquals("btext", sb.toString()); sb.replace(0, 1000, "text"); assertEquals("text", sb.toString()); - + sb = new StrBuilder("atext"); sb.replace(1, 1, "ny"); assertEquals("anytext", sb.toString()); @@ -767,7 +767,7 @@ public class StrBuilderTest { sb.replace(2, 1, "anything"); fail("Expected IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) {} - + sb = new StrBuilder(); try { sb.replace(1, 2, "anything"); @@ -823,7 +823,7 @@ public class StrBuilderTest { assertEquals("abcbccba", sb.toString()); sb.replaceAll("", "anything"); assertEquals("abcbccba", sb.toString()); - + sb.replaceAll("x", "y"); assertEquals("abcbccba", sb.toString()); sb.replaceAll("a", "d"); @@ -832,11 +832,11 @@ public class StrBuilderTest { assertEquals("bcbccb", sb.toString()); sb.replaceAll("cb", "-"); assertEquals("b-c-", sb.toString()); - + sb = new StrBuilder("abcba"); sb.replaceAll("b", "xbx"); assertEquals("axbxcxbxa", sb.toString()); - + sb = new StrBuilder("bb"); sb.replaceAll("b", "xbx"); assertEquals("xbxxbx", sb.toString()); @@ -853,7 +853,7 @@ public class StrBuilderTest { assertEquals("abcbccba", sb.toString()); sb.replaceFirst("", "anything"); assertEquals("abcbccba", sb.toString()); - + sb.replaceFirst("x", "y"); assertEquals("abcbccba", sb.toString()); sb.replaceFirst("a", "d"); @@ -862,11 +862,11 @@ public class StrBuilderTest { assertEquals("bcbccba", sb.toString()); sb.replaceFirst("cb", "-"); assertEquals("b-ccba", sb.toString()); - + sb = new StrBuilder("abcba"); sb.replaceFirst("b", "xbx"); assertEquals("axbxcba", sb.toString()); - + sb = new StrBuilder("bb"); sb.replaceFirst("b", "xbx"); assertEquals("xbxb", sb.toString()); @@ -884,7 +884,7 @@ public class StrBuilderTest { assertEquals("abcbccba", sb.toString()); sb.replaceAll(StrMatcher.noneMatcher(), "anything"); assertEquals("abcbccba", sb.toString()); - + sb.replaceAll(StrMatcher.charMatcher('x'), "y"); assertEquals("abcbccba", sb.toString()); sb.replaceAll(StrMatcher.charMatcher('a'), "d"); @@ -893,15 +893,15 @@ public class StrBuilderTest { assertEquals("bcbccb", sb.toString()); sb.replaceAll(StrMatcher.stringMatcher("cb"), "-"); assertEquals("b-c-", sb.toString()); - + sb = new StrBuilder("abcba"); sb.replaceAll(StrMatcher.charMatcher('b'), "xbx"); assertEquals("axbxcxbxa", sb.toString()); - + sb = new StrBuilder("bb"); sb.replaceAll(StrMatcher.charMatcher('b'), "xbx"); assertEquals("xbxxbx", sb.toString()); - + sb = new StrBuilder("A1-A2A3-A4"); sb.replaceAll(A_NUMBER_MATCHER, "***"); assertEquals("***-******-***", sb.toString()); @@ -922,7 +922,7 @@ public class StrBuilderTest { assertEquals("abcbccba", sb.toString()); sb.replaceFirst(StrMatcher.noneMatcher(), "anything"); assertEquals("abcbccba", sb.toString()); - + sb.replaceFirst(StrMatcher.charMatcher('x'), "y"); assertEquals("abcbccba", sb.toString()); sb.replaceFirst(StrMatcher.charMatcher('a'), "d"); @@ -931,15 +931,15 @@ public class StrBuilderTest { assertEquals("bcbccba", sb.toString()); sb.replaceFirst(StrMatcher.stringMatcher("cb"), "-"); assertEquals("b-ccba", sb.toString()); - + sb = new StrBuilder("abcba"); sb.replaceFirst(StrMatcher.charMatcher('b'), "xbx"); assertEquals("axbxcba", sb.toString()); - + sb = new StrBuilder("bb"); sb.replaceFirst(StrMatcher.charMatcher('b'), "xbx"); assertEquals("xbxb", sb.toString()); - + sb = new StrBuilder("A1-A2A3-A4"); sb.replaceFirst(A_NUMBER_MATCHER, "***"); assertEquals("***-A2A3-A4", sb.toString()); @@ -951,17 +951,17 @@ public class StrBuilderTest { StrBuilder sb = new StrBuilder("abcbccba"); sb.replace(null, "x", 0, sb.length(), -1); assertEquals("abcbccba", sb.toString()); - + sb.replace(StrMatcher.charMatcher('a'), "x", 0, sb.length(), -1); assertEquals("xbcbccbx", sb.toString()); - + sb.replace(StrMatcher.stringMatcher("cb"), "x", 0, sb.length(), -1); assertEquals("xbxcxx", sb.toString()); - + sb = new StrBuilder("A1-A2A3-A4"); sb.replace(A_NUMBER_MATCHER, "***", 0, sb.length(), -1); assertEquals("***-******-***", sb.toString()); - + sb = new StrBuilder(); sb.replace(A_NUMBER_MATCHER, "***", 0, sb.length(), -1); assertEquals("", sb.toString()); @@ -972,19 +972,19 @@ public class StrBuilderTest { StrBuilder sb = new StrBuilder("abcbccba"); sb.replace(StrMatcher.stringMatcher("cb"), "cb", 0, sb.length(), -1); assertEquals("abcbccba", sb.toString()); - + sb = new StrBuilder("abcbccba"); sb.replace(StrMatcher.stringMatcher("cb"), "-", 0, sb.length(), -1); assertEquals("ab-c-a", sb.toString()); - + sb = new StrBuilder("abcbccba"); sb.replace(StrMatcher.stringMatcher("cb"), "+++", 0, sb.length(), -1); assertEquals("ab+++c+++a", sb.toString()); - + sb = new StrBuilder("abcbccba"); sb.replace(StrMatcher.stringMatcher("cb"), "", 0, sb.length(), -1); assertEquals("abca", sb.toString()); - + sb = new StrBuilder("abcbccba"); sb.replace(StrMatcher.stringMatcher("cb"), null, 0, sb.length(), -1); assertEquals("abca", sb.toString()); @@ -995,54 +995,54 @@ public class StrBuilderTest { StrBuilder sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, sb.length(), -1); assertEquals("-x--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 1, sb.length(), -1); assertEquals("aax--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 2, sb.length(), -1); assertEquals("aax--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 3, sb.length(), -1); assertEquals("aax--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 4, sb.length(), -1); assertEquals("aaxa-ay-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 5, sb.length(), -1); assertEquals("aaxaa-y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 6, sb.length(), -1); assertEquals("aaxaaaay-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 7, sb.length(), -1); assertEquals("aaxaaaay-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 8, sb.length(), -1); assertEquals("aaxaaaay-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 9, sb.length(), -1); assertEquals("aaxaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 10, sb.length(), -1); assertEquals("aaxaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); try { sb.replace(StrMatcher.stringMatcher("aa"), "-", 11, sb.length(), -1); fail(); } catch (final IndexOutOfBoundsException ex) {} assertEquals("aaxaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); try { sb.replace(StrMatcher.stringMatcher("aa"), "-", -1, sb.length(), -1); @@ -1056,47 +1056,47 @@ public class StrBuilderTest { StrBuilder sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 0, -1); assertEquals("aaxaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 2, -1); assertEquals("-xaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 3, -1); assertEquals("-xaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 4, -1); assertEquals("-xaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 5, -1); assertEquals("-x-aayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 6, -1); assertEquals("-x-aayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 7, -1); assertEquals("-x--yaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 8, -1); assertEquals("-x--yaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 9, -1); assertEquals("-x--yaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, -1); assertEquals("-x--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 1000, -1); assertEquals("-x--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); try { sb.replace(StrMatcher.stringMatcher("aa"), "-", 2, 1, -1); @@ -1110,27 +1110,27 @@ public class StrBuilderTest { StrBuilder sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, -1); assertEquals("-x--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 0); assertEquals("aaxaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 1); assertEquals("-xaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 2); assertEquals("-x-aayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 3); assertEquals("-x--yaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 4); assertEquals("-x--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 5); assertEquals("-x--y-", sb.toString()); @@ -1141,7 +1141,7 @@ public class StrBuilderTest { public void testReverse() { final StrBuilder sb = new StrBuilder(); assertEquals("", sb.reverse().toString()); - + sb.clear().append(true); assertEquals("eurt", sb.reverse().toString()); assertEquals("true", sb.reverse().toString()); @@ -1152,19 +1152,19 @@ public class StrBuilderTest { public void testTrim() { final StrBuilder sb = new StrBuilder(); assertEquals("", sb.reverse().toString()); - + sb.clear().append(" \u0000 "); assertEquals("", sb.trim().toString()); - + sb.clear().append(" \u0000 a b c"); assertEquals("a b c", sb.trim().toString()); - + sb.clear().append("a b c \u0000 "); assertEquals("a b c", sb.trim().toString()); - + sb.clear().append(" \u0000 a b c \u0000 "); assertEquals("a b c", sb.trim().toString()); - + sb.clear().append("a b c"); assertEquals("a b c", sb.trim().toString()); } @@ -1209,25 +1209,25 @@ public class StrBuilderTest { sb.subSequence(-1, 5); fail(); } catch (final IndexOutOfBoundsException e) {} - + // End index is negative try { sb.subSequence(2, -1); fail(); } catch (final IndexOutOfBoundsException e) {} - + // End index greater than length() try { sb.subSequence(2, sb.length() + 1); fail(); } catch (final IndexOutOfBoundsException e) {} - + // Start index greater then end index try { sb.subSequence(3, 2); fail(); } catch (final IndexOutOfBoundsException e) {} - + // Normal cases assertEquals ("hello", sb.subSequence(0, 5)); assertEquals ("hello goodbye".subSequence(0, 6), sb.subSequence(0, 6)); @@ -1246,30 +1246,30 @@ public class StrBuilderTest { sb.substring(-1); fail (); } catch (final IndexOutOfBoundsException e) {} - + try { sb.substring(15); fail (); } catch (final IndexOutOfBoundsException e) {} - + } - + @Test public void testSubstringIntInt() { final StrBuilder sb = new StrBuilder ("hello goodbye"); assertEquals ("hello", sb.substring(0, 5)); assertEquals ("hello goodbye".substring(0, 6), sb.substring(0, 6)); - + assertEquals ("goodbye", sb.substring(6, 13)); assertEquals ("hello goodbye".substring(6,13), sb.substring(6, 13)); - + assertEquals ("goodbye", sb.substring(6, 20)); - + try { sb.substring(-1, 5); fail(); } catch (final IndexOutOfBoundsException e) {} - + try { sb.substring(15, 20); fail(); @@ -1346,7 +1346,7 @@ public class StrBuilderTest { public void testIndexOf_char() { final StrBuilder sb = new StrBuilder("abab"); assertEquals(0, sb.indexOf('a')); - + // should work like String#indexOf assertEquals("abab".indexOf('a'), sb.indexOf('a')); @@ -1381,14 +1381,14 @@ public class StrBuilderTest { @Test public void testLastIndexOf_char() { final StrBuilder sb = new StrBuilder("abab"); - + assertEquals (2, sb.lastIndexOf('a')); //should work like String#lastIndexOf assertEquals ("abab".lastIndexOf('a'), sb.lastIndexOf('a')); - + assertEquals(3, sb.lastIndexOf('b')); assertEquals ("abab".lastIndexOf('b'), sb.lastIndexOf('b')); - + assertEquals (-1, sb.lastIndexOf('z')); } @@ -1416,23 +1416,23 @@ public class StrBuilderTest { @Test public void testIndexOf_String() { final StrBuilder sb = new StrBuilder("abab"); - + assertEquals(0, sb.indexOf("a")); //should work like String#indexOf assertEquals("abab".indexOf("a"), sb.indexOf("a")); - + assertEquals(0, sb.indexOf("ab")); //should work like String#indexOf assertEquals("abab".indexOf("ab"), sb.indexOf("ab")); - + assertEquals(1, sb.indexOf("b")); assertEquals("abab".indexOf("b"), sb.indexOf("b")); - + assertEquals(1, sb.indexOf("ba")); assertEquals("abab".indexOf("ba"), sb.indexOf("ba")); - + assertEquals(-1, sb.indexOf("z")); - + assertEquals(-1, sb.indexOf((String) null)); } @@ -1446,53 +1446,53 @@ public class StrBuilderTest { assertEquals(-1, sb.indexOf("a", 3)); assertEquals(-1, sb.indexOf("a", 4)); assertEquals(-1, sb.indexOf("a", 5)); - + assertEquals(-1, sb.indexOf("abcdef", 0)); assertEquals(0, sb.indexOf("", 0)); assertEquals(1, sb.indexOf("", 1)); - + //should work like String#indexOf assertEquals ("abab".indexOf("a", 1), sb.indexOf("a", 1)); - + assertEquals(2, sb.indexOf("ab", 1)); //should work like String#indexOf assertEquals("abab".indexOf("ab", 1), sb.indexOf("ab", 1)); - + assertEquals(3, sb.indexOf("b", 2)); assertEquals("abab".indexOf("b", 2), sb.indexOf("b", 2)); - + assertEquals(1, sb.indexOf("ba", 1)); assertEquals("abab".indexOf("ba", 2), sb.indexOf("ba", 2)); - + assertEquals(-1, sb.indexOf("z", 2)); - + sb = new StrBuilder("xyzabc"); assertEquals(2, sb.indexOf("za", 0)); assertEquals(-1, sb.indexOf("za", 3)); - + assertEquals(-1, sb.indexOf((String) null, 2)); } @Test public void testLastIndexOf_String() { final StrBuilder sb = new StrBuilder("abab"); - + assertEquals(2, sb.lastIndexOf("a")); //should work like String#lastIndexOf assertEquals("abab".lastIndexOf("a"), sb.lastIndexOf("a")); - + assertEquals(2, sb.lastIndexOf("ab")); //should work like String#lastIndexOf assertEquals("abab".lastIndexOf("ab"), sb.lastIndexOf("ab")); - + assertEquals(3, sb.lastIndexOf("b")); assertEquals("abab".lastIndexOf("b"), sb.lastIndexOf("b")); - + assertEquals(1, sb.lastIndexOf("ba")); assertEquals("abab".lastIndexOf("ba"), sb.lastIndexOf("ba")); - + assertEquals(-1, sb.lastIndexOf("z")); - + assertEquals(-1, sb.lastIndexOf((String) null)); } @@ -1506,30 +1506,30 @@ public class StrBuilderTest { assertEquals(2, sb.lastIndexOf("a", 3)); assertEquals(2, sb.lastIndexOf("a", 4)); assertEquals(2, sb.lastIndexOf("a", 5)); - + assertEquals(-1, sb.lastIndexOf("abcdef", 3)); assertEquals("abab".lastIndexOf("", 3), sb.lastIndexOf("", 3)); assertEquals("abab".lastIndexOf("", 1), sb.lastIndexOf("", 1)); - + //should work like String#lastIndexOf assertEquals("abab".lastIndexOf("a", 1), sb.lastIndexOf("a", 1)); - + assertEquals(0, sb.lastIndexOf("ab", 1)); //should work like String#lastIndexOf assertEquals("abab".lastIndexOf("ab", 1), sb.lastIndexOf("ab", 1)); - + assertEquals(1, sb.lastIndexOf("b", 2)); assertEquals("abab".lastIndexOf("b", 2), sb.lastIndexOf("b", 2)); - + assertEquals(1, sb.lastIndexOf("ba", 2)); assertEquals("abab".lastIndexOf("ba", 2), sb.lastIndexOf("ba", 2)); - + assertEquals(-1, sb.lastIndexOf("z", 2)); - + sb = new StrBuilder("xyzabc"); assertEquals(2, sb.lastIndexOf("za", sb.length())); assertEquals(-1, sb.lastIndexOf("za", 1)); - + assertEquals(-1, sb.lastIndexOf((String) null, 2)); } @@ -1539,7 +1539,7 @@ public class StrBuilderTest { final StrBuilder sb = new StrBuilder(); assertEquals(-1, sb.indexOf((StrMatcher) null)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'))); - + sb.append("ab bd"); assertEquals(0, sb.indexOf(StrMatcher.charMatcher('a'))); assertEquals(1, sb.indexOf(StrMatcher.charMatcher('b'))); @@ -1547,7 +1547,7 @@ public class StrBuilderTest { assertEquals(4, sb.indexOf(StrMatcher.charMatcher('d'))); assertEquals(-1, sb.indexOf(StrMatcher.noneMatcher())); assertEquals(-1, sb.indexOf((StrMatcher) null)); - + sb.append(" A1 junction"); assertEquals(6, sb.indexOf(A_NUMBER_MATCHER)); } @@ -1558,13 +1558,13 @@ public class StrBuilderTest { assertEquals(-1, sb.indexOf((StrMatcher) null, 2)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 2)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 0)); - + sb.append("ab bd"); assertEquals(0, sb.indexOf(StrMatcher.charMatcher('a'), -2)); assertEquals(0, sb.indexOf(StrMatcher.charMatcher('a'), 0)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 2)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 20)); - + assertEquals(1, sb.indexOf(StrMatcher.charMatcher('b'), -1)); assertEquals(1, sb.indexOf(StrMatcher.charMatcher('b'), 0)); assertEquals(1, sb.indexOf(StrMatcher.charMatcher('b'), 1)); @@ -1573,16 +1573,16 @@ public class StrBuilderTest { assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('b'), 4)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('b'), 5)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('b'), 6)); - + assertEquals(2, sb.indexOf(StrMatcher.spaceMatcher(), -2)); assertEquals(2, sb.indexOf(StrMatcher.spaceMatcher(), 0)); assertEquals(2, sb.indexOf(StrMatcher.spaceMatcher(), 2)); assertEquals(-1, sb.indexOf(StrMatcher.spaceMatcher(), 4)); assertEquals(-1, sb.indexOf(StrMatcher.spaceMatcher(), 20)); - + assertEquals(-1, sb.indexOf(StrMatcher.noneMatcher(), 0)); assertEquals(-1, sb.indexOf((StrMatcher) null, 0)); - + sb.append(" A1 junction with A2"); assertEquals(6, sb.indexOf(A_NUMBER_MATCHER, 5)); assertEquals(6, sb.indexOf(A_NUMBER_MATCHER, 6)); @@ -1597,7 +1597,7 @@ public class StrBuilderTest { final StrBuilder sb = new StrBuilder(); assertEquals(-1, sb.lastIndexOf((StrMatcher) null)); assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'))); - + sb.append("ab bd"); assertEquals(0, sb.lastIndexOf(StrMatcher.charMatcher('a'))); assertEquals(3, sb.lastIndexOf(StrMatcher.charMatcher('b'))); @@ -1605,7 +1605,7 @@ public class StrBuilderTest { assertEquals(4, sb.lastIndexOf(StrMatcher.charMatcher('d'))); assertEquals(-1, sb.lastIndexOf(StrMatcher.noneMatcher())); assertEquals(-1, sb.lastIndexOf((StrMatcher) null)); - + sb.append(" A1 junction"); assertEquals(6, sb.lastIndexOf(A_NUMBER_MATCHER)); } @@ -1617,13 +1617,13 @@ public class StrBuilderTest { assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), 2)); assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), 0)); assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), -1)); - + sb.append("ab bd"); assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), -2)); assertEquals(0, sb.lastIndexOf(StrMatcher.charMatcher('a'), 0)); assertEquals(0, sb.lastIndexOf(StrMatcher.charMatcher('a'), 2)); assertEquals(0, sb.lastIndexOf(StrMatcher.charMatcher('a'), 20)); - + assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('b'), -1)); assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('b'), 0)); assertEquals(1, sb.lastIndexOf(StrMatcher.charMatcher('b'), 1)); @@ -1632,16 +1632,16 @@ public class StrBuilderTest { assertEquals(3, sb.lastIndexOf(StrMatcher.charMatcher('b'), 4)); assertEquals(3, sb.lastIndexOf(StrMatcher.charMatcher('b'), 5)); assertEquals(3, sb.lastIndexOf(StrMatcher.charMatcher('b'), 6)); - + assertEquals(-1, sb.lastIndexOf(StrMatcher.spaceMatcher(), -2)); assertEquals(-1, sb.lastIndexOf(StrMatcher.spaceMatcher(), 0)); assertEquals(2, sb.lastIndexOf(StrMatcher.spaceMatcher(), 2)); assertEquals(2, sb.lastIndexOf(StrMatcher.spaceMatcher(), 4)); assertEquals(2, sb.lastIndexOf(StrMatcher.spaceMatcher(), 20)); - + assertEquals(-1, sb.lastIndexOf(StrMatcher.noneMatcher(), 0)); assertEquals(-1, sb.lastIndexOf((StrMatcher) null, 0)); - + sb.append(" A1 junction with A2"); assertEquals(-1, sb.lastIndexOf(A_NUMBER_MATCHER, 5)); assertEquals(-1, sb.lastIndexOf(A_NUMBER_MATCHER, 6)); // A matches, 1 is outside bounds @@ -1671,13 +1671,13 @@ public class StrBuilderTest { final StrBuilder b = new StrBuilder(); b.append("a b "); final StrTokenizer t = b.asTokenizer(); - + 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 "); final String[] tokens2 = t.getTokenArray(); assertEquals(2, tokens2.length); @@ -1686,7 +1686,7 @@ public class StrBuilderTest { assertEquals(2, t.size()); assertEquals("a", t.next()); assertEquals("b", t.next()); - + t.reset(); final String[] tokens3 = t.getTokenArray(); assertEquals(4, tokens3.length); @@ -1699,7 +1699,7 @@ public class StrBuilderTest { assertEquals("b", t.next()); assertEquals("c", t.next()); assertEquals("d", t.next()); - + assertEquals("a b c d ", t.getContent()); } @@ -1712,12 +1712,12 @@ public class StrBuilderTest { final char[] buf = new char[40]; assertEquals(9, reader.read(buf)); assertEquals("some text", new String(buf, 0, 9)); - + assertEquals(-1, reader.read()); assertFalse(reader.ready()); assertEquals(0, reader.skip(2)); assertEquals(0, reader.skip(-1)); - + assertTrue(reader.markSupported()); reader = sb.asReader(); assertEquals('s', reader.read()); @@ -1734,11 +1734,11 @@ public class StrBuilderTest { assertEquals('e', array[2]); assertEquals(2, reader.skip(2)); assertEquals(' ', reader.read()); - + assertTrue(reader.ready()); reader.close(); assertTrue(reader.ready()); - + reader = sb.asReader(); array = new char[3]; try { @@ -1761,15 +1761,15 @@ public class StrBuilderTest { reader.read(array, Integer.MAX_VALUE, Integer.MAX_VALUE); fail(); } catch (final IndexOutOfBoundsException ex) {} - + assertEquals(0, reader.read(array, 0, 0)); assertEquals(0, array[0]); assertEquals(0, array[1]); assertEquals(0, array[2]); - + reader.skip(9); assertEquals(-1, reader.read(array, 0, 1)); - + reader.reset(); array = new char[30]; assertEquals(9, reader.read(array, 0, 30)); @@ -1780,31 +1780,31 @@ public class StrBuilderTest { public void testAsWriter() throws Exception { final StrBuilder sb = new StrBuilder("base"); final Writer writer = sb.asWriter(); - + writer.write('l'); assertEquals("basel", sb.toString()); - + writer.write(new char[] {'i', 'n'}); assertEquals("baselin", sb.toString()); - + writer.write(new char[] {'n', 'e', 'r'}, 1, 2); assertEquals("baseliner", sb.toString()); - + writer.write(" rout"); assertEquals("baseliner rout", sb.toString()); - + writer.write("ping that server", 1, 3); assertEquals("baseliner routing", sb.toString()); - + writer.flush(); // no effect assertEquals("baseliner routing", sb.toString()); - + writer.close(); // no effect assertEquals("baseliner routing", sb.toString()); - + writer.write(" hi"); // works after close assertEquals("baseliner routing hi", sb.toString()); - + sb.setLength(4); // mix and match writer.write('d'); assertEquals("based", sb.toString()); @@ -1818,18 +1818,18 @@ public class StrBuilderTest { assertTrue(sb1.equalsIgnoreCase(sb1)); assertTrue(sb1.equalsIgnoreCase(sb2)); assertTrue(sb2.equalsIgnoreCase(sb2)); - + sb1.append("abc"); assertFalse(sb1.equalsIgnoreCase(sb2)); - + sb2.append("ABC"); assertTrue(sb1.equalsIgnoreCase(sb2)); - + sb2.clear().append("abc"); assertTrue(sb1.equalsIgnoreCase(sb2)); assertTrue(sb1.equalsIgnoreCase(sb1)); assertTrue(sb2.equalsIgnoreCase(sb2)); - + sb2.clear().append("aBc"); assertTrue(sb1.equalsIgnoreCase(sb2)); } @@ -1843,19 +1843,19 @@ public class StrBuilderTest { assertTrue(sb1.equals(sb1)); assertTrue(sb2.equals(sb2)); assertTrue(sb1.equals((Object) sb2)); - + sb1.append("abc"); assertFalse(sb1.equals(sb2)); assertFalse(sb1.equals((Object) sb2)); - + sb2.append("ABC"); assertFalse(sb1.equals(sb2)); assertFalse(sb1.equals((Object) sb2)); - + sb2.clear().append("abc"); assertTrue(sb1.equals(sb2)); assertTrue(sb1.equals((Object) sb2)); - + assertFalse(sb1.equals(Integer.valueOf(1))); assertFalse(sb1.equals("abc")); } @@ -1875,7 +1875,7 @@ public class StrBuilderTest { final int hc1b = sb.hashCode(); assertEquals(0, hc1a); assertEquals(hc1a, hc1b); - + sb.append("abc"); final int hc2a = sb.hashCode(); final int hc2b = sb.hashCode(); @@ -1895,7 +1895,7 @@ public class StrBuilderTest { public void testToStringBuffer() { final StrBuilder sb = new StrBuilder(); assertEquals(new StringBuffer().toString(), sb.toStringBuffer().toString()); - + sb.append("junit"); assertEquals(new StringBuffer("junit").toString(), sb.toStringBuffer().toString()); } @@ -1905,7 +1905,7 @@ public class StrBuilderTest { public void testToStringBuilder() { final StrBuilder sb = new StrBuilder(); assertEquals(new StringBuilder().toString(), sb.toStringBuilder().toString()); - + sb.append("junit"); assertEquals(new StringBuilder("junit").toString(), sb.toStringBuilder().toString()); } @@ -1915,7 +1915,7 @@ public class StrBuilderTest { public void testLang294() { 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()); + assertEquals("\nDo more stuff\neven more stuff\n", sb.toString()); } @Test 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 1b286ebe1..c26f22e85 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 d9afde2f6..7325b7acf 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -506,7 +506,7 @@ public class StrTokenizerTest { 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()); } @@ -555,7 +555,7 @@ public class StrTokenizerTest { tok = new StrTokenizer(input.toCharArray()); assertEquals(input, tok.getContent()); - + tok = new StrTokenizer(); assertEquals(null, tok.getContent()); } @@ -623,7 +623,7 @@ public class StrTokenizerTest { assertEquals("b", tokenizer.nextToken()); assertEquals("a", clonedTokenizer.nextToken()); } - + // ----------------------------------------------------------------------- @Test public void testConstructor_String() { @@ -631,10 +631,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer(""); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((String) null); assertFalse(tok.hasNext()); } @@ -647,10 +647,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer("", ' '); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((String) null, ' '); assertFalse(tok.hasNext()); } @@ -664,10 +664,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer("", ' ', '"'); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((String) null, ' ', '"'); assertFalse(tok.hasNext()); } @@ -679,10 +679,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer(new char[0]); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((char[]) null); assertFalse(tok.hasNext()); } @@ -695,10 +695,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer(new char[0], ' '); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((char[]) null, ' '); assertFalse(tok.hasNext()); } @@ -712,10 +712,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer(new char[0], ' ', '"'); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((char[]) null, ' ', '"'); assertFalse(tok.hasNext()); } @@ -728,7 +728,7 @@ public class StrTokenizerTest { assertEquals("b", tok.next()); assertEquals("c", tok.next()); assertFalse(tok.hasNext()); - + tok.reset(); assertEquals("a", tok.next()); assertEquals("b", tok.next()); @@ -744,7 +744,7 @@ public class StrTokenizerTest { assertEquals("d", tok.next()); assertEquals("e", tok.next()); assertFalse(tok.hasNext()); - + tok.reset((String) null); assertFalse(tok.hasNext()); } @@ -753,12 +753,12 @@ public class StrTokenizerTest { @Test public void testReset_charArray() { final StrTokenizer tok = new StrTokenizer("x x x"); - + final char[] array = new char[] {'a', 'b', 'c'}; tok.reset(array); assertEquals("abc", tok.next()); assertFalse(tok.hasNext()); - + tok.reset((char[]) null); assertFalse(tok.hasNext()); } @@ -810,7 +810,7 @@ public class StrTokenizerTest { fail(); } catch (final NoSuchElementException ex) {} assertTrue(tkn.hasNext()); - + assertEquals("a", tkn.next()); try { tkn.remove(); @@ -826,15 +826,15 @@ public class StrTokenizerTest { } catch (final UnsupportedOperationException ex) {} assertTrue(tkn.hasPrevious()); assertTrue(tkn.hasNext()); - + assertEquals("b", tkn.next()); assertTrue(tkn.hasPrevious()); assertTrue(tkn.hasNext()); - + assertEquals("c", tkn.next()); assertTrue(tkn.hasPrevious()); assertFalse(tkn.hasNext()); - + try { tkn.next(); fail(); 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 370e7547d..32cf99af1 100644 --- a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,32 +42,32 @@ public class WordUtilsTest { assertTrue(Modifier.isPublic(WordUtils.class.getModifiers())); assertFalse(Modifier.isFinal(WordUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testWrap_StringInt() { assertEquals(null, WordUtils.wrap(null, 20)); assertEquals(null, WordUtils.wrap(null, -1)); - + assertEquals("", WordUtils.wrap("", 20)); assertEquals("", WordUtils.wrap("", -1)); - + // normal final String systemNewLine = System.lineSeparator(); 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" + String expected = "Here is one line of" + systemNewLine + "text that is going" + systemNewLine + "to be wrapped after" + systemNewLine + "20 columns."; assertEquals(expected, WordUtils.wrap(input, 20)); - + // long word at end input = "Click here to jump to the commons website - http://commons.apache.org"; - expected = "Click here to jump" + systemNewLine + "to the commons" + systemNewLine + expected = "Click here to jump" + systemNewLine + "to the commons" + systemNewLine + "website -" + systemNewLine + "http://commons.apache.org"; assertEquals(expected, WordUtils.wrap(input, 20)); - + // long word in middle input = "Click here, http://commons.apache.org, to jump to the commons website"; - expected = "Click here," + systemNewLine + "http://commons.apache.org," + systemNewLine + expected = "Click here," + systemNewLine + "http://commons.apache.org," + systemNewLine + "to jump to the" + systemNewLine + "commons website"; assertEquals(expected, WordUtils.wrap(input, 20)); @@ -77,7 +77,7 @@ public class WordUtilsTest { expected = "word1 " + systemNewLine + "word2 " + systemNewLine + "word3"; assertEquals(expected, WordUtils.wrap(input, 7)); } - + @Test public void testWrap_StringIntStringBoolean() { assertEquals(null, WordUtils.wrap(null, 20, "\n", false)); @@ -86,14 +86,14 @@ public class WordUtilsTest { assertEquals(null, WordUtils.wrap(null, 20, null, false)); assertEquals(null, WordUtils.wrap(null, -1, null, true)); assertEquals(null, WordUtils.wrap(null, -1, null, false)); - + assertEquals("", WordUtils.wrap("", 20, "\n", false)); assertEquals("", WordUtils.wrap("", 20, "\n", true)); assertEquals("", WordUtils.wrap("", 20, null, false)); assertEquals("", WordUtils.wrap("", 20, null, true)); assertEquals("", WordUtils.wrap("", -1, null, false)); assertEquals("", WordUtils.wrap("", -1, null, true)); - + // normal String input = "Here is one line of text that is going to be wrapped after 20 columns."; String expected = "Here is one line of\ntext that is going\nto be wrapped after\n20 columns."; @@ -117,7 +117,7 @@ public class WordUtilsTest { // system newline char final String systemNewLine = System.lineSeparator(); 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 + expected = "Here is one line of" + systemNewLine + "text that is going" + systemNewLine + "to be wrapped after" + systemNewLine + "20 columns."; assertEquals(expected, WordUtils.wrap(input, 20, null, false)); assertEquals(expected, WordUtils.wrap(input, 20, null, true)); @@ -127,26 +127,26 @@ public class WordUtilsTest { expected = "Here: is one line\nof text that is \ngoing to be \nwrapped after 20 \ncolumns."; assertEquals(expected, WordUtils.wrap(input, 20, "\n", false)); assertEquals(expected, WordUtils.wrap(input, 20, "\n", true)); - + // with tab input = "Here is\tone line of text that is going to be wrapped after 20 columns."; expected = "Here is\tone line of\ntext that is going\nto be wrapped after\n20 columns."; assertEquals(expected, WordUtils.wrap(input, 20, "\n", false)); assertEquals(expected, WordUtils.wrap(input, 20, "\n", true)); - + // with tab at wrapColumn input = "Here is one line of\ttext that is going to be wrapped after 20 columns."; expected = "Here is one line\nof\ttext that is\ngoing to be wrapped\nafter 20 columns."; assertEquals(expected, WordUtils.wrap(input, 20, "\n", false)); assertEquals(expected, WordUtils.wrap(input, 20, "\n", true)); - + // difference because of long word input = "Click here to jump to the commons website - http://commons.apache.org"; expected = "Click here to jump\nto the commons\nwebsite -\nhttp://commons.apache.org"; assertEquals(expected, WordUtils.wrap(input, 20, "\n", false)); expected = "Click here to jump\nto the commons\nwebsite -\nhttp://commons.apach\ne.org"; assertEquals(expected, WordUtils.wrap(input, 20, "\n", true)); - + // difference because of long word in middle input = "Click here, http://commons.apache.org, to jump to the commons website"; expected = "Click here,\nhttp://commons.apache.org,\nto jump to the\ncommons website"; @@ -187,7 +187,7 @@ public class WordUtilsTest { assertEquals(null, WordUtils.capitalize(null)); assertEquals("", WordUtils.capitalize("")); assertEquals(" ", WordUtils.capitalize(" ")); - + assertEquals("I", WordUtils.capitalize("I") ); assertEquals("I", WordUtils.capitalize("i") ); assertEquals("I Am Here 123", WordUtils.capitalize("i am here 123") ); @@ -195,13 +195,13 @@ public class WordUtilsTest { assertEquals("I Am HERE 123", WordUtils.capitalize("i am HERE 123") ); assertEquals("I AM HERE 123", WordUtils.capitalize("I AM HERE 123") ); } - + @Test public void testCapitalizeWithDelimiters_String() { assertEquals(null, WordUtils.capitalize(null, null)); assertEquals("", WordUtils.capitalize("", new char[0])); assertEquals(" ", WordUtils.capitalize(" ", new char[0])); - + char[] chars = new char[] { '-', '+', ' ', '@' }; assertEquals("I", WordUtils.capitalize("I", chars) ); assertEquals("I", WordUtils.capitalize("i", chars) ); @@ -219,7 +219,7 @@ public class WordUtilsTest { assertEquals(null, WordUtils.capitalizeFully(null)); assertEquals("", WordUtils.capitalizeFully("")); assertEquals(" ", WordUtils.capitalizeFully(" ")); - + assertEquals("I", WordUtils.capitalizeFully("I") ); assertEquals("I", WordUtils.capitalizeFully("i") ); assertEquals("I Am Here 123", WordUtils.capitalizeFully("i am here 123") ); @@ -227,13 +227,13 @@ public class WordUtilsTest { assertEquals("I Am Here 123", WordUtils.capitalizeFully("i am HERE 123") ); assertEquals("I Am Here 123", WordUtils.capitalizeFully("I AM HERE 123") ); } - + @Test public void testCapitalizeFullyWithDelimiters_String() { assertEquals(null, WordUtils.capitalizeFully(null, null)); assertEquals("", WordUtils.capitalizeFully("", new char[0])); assertEquals(" ", WordUtils.capitalizeFully(" ", new char[0])); - + char[] chars = new char[] { '-', '+', ' ', '@' }; assertEquals("I", WordUtils.capitalizeFully("I", chars) ); assertEquals("I", WordUtils.capitalizeFully("i", chars) ); @@ -271,7 +271,7 @@ public class WordUtilsTest { assertEquals(null, WordUtils.uncapitalize(null)); assertEquals("", WordUtils.uncapitalize("")); assertEquals(" ", WordUtils.uncapitalize(" ")); - + assertEquals("i", WordUtils.uncapitalize("I") ); assertEquals("i", WordUtils.uncapitalize("i") ); assertEquals("i am here 123", WordUtils.uncapitalize("i am here 123") ); @@ -279,13 +279,13 @@ public class WordUtilsTest { assertEquals("i am hERE 123", WordUtils.uncapitalize("i am HERE 123") ); assertEquals("i aM hERE 123", WordUtils.uncapitalize("I AM HERE 123") ); } - + @Test public void testUncapitalizeWithDelimiters_String() { assertEquals(null, WordUtils.uncapitalize(null, null)); assertEquals("", WordUtils.uncapitalize("", new char[0])); assertEquals(" ", WordUtils.uncapitalize(" ", new char[0])); - + char[] chars = new char[] { '-', '+', ' ', '@' }; assertEquals("i", WordUtils.uncapitalize("I", chars) ); assertEquals("i", WordUtils.uncapitalize("i", chars) ); @@ -330,7 +330,7 @@ public class WordUtilsTest { assertEquals("BJ.L", WordUtils.initials(" Ben John . Lee", array)); assertEquals("KO", WordUtils.initials("Kay O'Murphy", array)); assertEquals("iah1", WordUtils.initials("i am here 123", array)); - + array = new char[0]; assertEquals(null, WordUtils.initials(null, array)); assertEquals("", WordUtils.initials("", array)); @@ -344,7 +344,7 @@ public class WordUtilsTest { assertEquals("", WordUtils.initials(" Ben John . Lee", array)); assertEquals("", WordUtils.initials("Kay O'Murphy", array)); assertEquals("", WordUtils.initials("i am here 123", array)); - + array = " ".toCharArray(); assertEquals(null, WordUtils.initials(null, array)); assertEquals("", WordUtils.initials("", array)); @@ -358,7 +358,7 @@ public class WordUtilsTest { assertEquals("BJ.L", WordUtils.initials(" Ben John . Lee", array)); assertEquals("KO", WordUtils.initials("Kay O'Murphy", array)); assertEquals("iah1", WordUtils.initials("i am here 123", array)); - + array = " .".toCharArray(); assertEquals(null, WordUtils.initials(null, array)); assertEquals("", WordUtils.initials("", array)); @@ -371,7 +371,7 @@ public class WordUtilsTest { assertEquals("BJL", WordUtils.initials(" Ben John . Lee", array)); assertEquals("KO", WordUtils.initials("Kay O'Murphy", array)); assertEquals("iah1", WordUtils.initials("i am here 123", array)); - + array = " .'".toCharArray(); assertEquals(null, WordUtils.initials(null, array)); assertEquals("", WordUtils.initials("", array)); @@ -384,7 +384,7 @@ public class WordUtilsTest { assertEquals("BJL", WordUtils.initials(" Ben John . Lee", array)); assertEquals("KOM", WordUtils.initials("Kay O'Murphy", array)); assertEquals("iah1", WordUtils.initials("i am here 123", array)); - + array = "SIJo1".toCharArray(); assertEquals(null, WordUtils.initials(null, array)); assertEquals("", WordUtils.initials("", array)); @@ -405,7 +405,7 @@ public class WordUtilsTest { assertEquals(null, WordUtils.swapCase(null)); assertEquals("", WordUtils.swapCase("")); assertEquals(" ", WordUtils.swapCase(" ")); - + assertEquals("i", WordUtils.swapCase("I") ); assertEquals("I", WordUtils.swapCase("i") ); assertEquals("I AM HERE 123", WordUtils.swapCase("i am here 123") ); @@ -417,7 +417,7 @@ public class WordUtilsTest { final String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9"; assertEquals(expect, WordUtils.swapCase(test)); } - + @Test public void testLANG1292() throws Exception { // Prior to fix, this was throwing StringIndexOutOfBoundsException 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 74e81d6a8..7cb65f88d 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 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ public class EntityArraysTest { public void testConstructorExists() { new EntityArrays(); } - + // LANG-659 - check arrays for duplicate entries @Test public void testHTML40_EXTENDED_ESCAPE(){ @@ -46,7 +46,7 @@ public class EntityArraysTest { assertTrue("Already added entry 1: "+i+" "+sa[i][1],col1.add(sa[i][1])); } } - + // LANG-658 - check arrays for duplicate entries @Test public void testISO8859_1_ESCAPE(){ @@ -57,7 +57,7 @@ public class EntityArraysTest { for(int i =0; i <sa.length; i++){ final boolean add0 = col0.add(sa[i][0]); final boolean add1 = col1.add(sa[i][1]); - if (!add0) { + if (!add0) { success = false; System.out.println("Already added entry 0: "+i+" "+sa[i][0]+" "+sa[i][1]); } @@ -68,6 +68,6 @@ public class EntityArraysTest { } assertTrue("One or more errors detected",success); } - - + + } 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 a53f77722..e9368780d 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 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 9c0594bbc..7db8fb742 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 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 07c184156..18f81c635 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 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 cbe80f3c2..c879f5f1a 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 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 e5ca40902..700607455 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 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 5ab67526a..a0ec693b6 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 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java index 457aa9bd8..fc8991166 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,14 +29,14 @@ import org.junit.Test; public class UnicodeUnpairedSurrogateRemoverTest { final UnicodeUnpairedSurrogateRemover subject = new UnicodeUnpairedSurrogateRemover(); final CharArrayWriter writer = new CharArrayWriter(); // nothing is ever written to it - + @Test public void testValidCharacters() throws IOException { assertEquals(false, subject.translate(0xd7ff, writer)); assertEquals(false, subject.translate(0xe000, writer)); assertEquals(0, writer.size()); } - + @Test public void testInvalidCharacters() throws IOException { assertEquals(true, subject.translate(0xd800, writer)); 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 0ae29ecdf..f19797423 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,7 +42,7 @@ public class DateFormatUtilsTest { @Rule public SystemDefaultsSwitch defaults = new SystemDefaultsSwitch(); - + //----------------------------------------------------------------------- @Test public void testConstructor() { @@ -53,7 +53,7 @@ public class DateFormatUtilsTest { assertTrue(Modifier.isPublic(DateFormatUtils.class.getModifiers())); assertFalse(Modifier.isFinal(DateFormatUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testFormat() { @@ -70,14 +70,14 @@ public class DateFormatUtilsTest { buffer.append(day); buffer.append(hour); assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH")); - + assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime().getTime(), "yyyyMdH")); - + assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH", Locale.US)); - + assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime().getTime(), "yyyyMdH", Locale.US)); } - + //----------------------------------------------------------------------- @Test public void testFormatCalendar() { @@ -94,24 +94,24 @@ public class DateFormatUtilsTest { buffer.append(day); buffer.append(hour); assertEquals(buffer.toString(), DateFormatUtils.format(c, "yyyyMdH")); - + assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH")); - + assertEquals(buffer.toString(), DateFormatUtils.format(c, "yyyyMdH", Locale.US)); - + assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH", Locale.US)); } - + @Test public void testFormatUTC() { final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC")); c.set(2005, Calendar.JANUARY, 1, 12, 0, 0); assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern())); - + assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime().getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern())); - + assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), Locale.US)); - + assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime().getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), Locale.US)); } @@ -142,7 +142,7 @@ public class DateFormatUtilsTest { final TimeZone timeZone = TimeZone.getTimeZone("UTC"); assertFormats(expectedValue, pattern, timeZone, createFebruaryTestDate(timeZone)); } - + @Test public void testDateTimeISO() throws Exception { testGmtMinus3("2002-02-23T09:11:12", DateFormatUtils.ISO_DATETIME_FORMAT.getPattern()); 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 519c9d2d0..7a9e114b5 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,7 +44,7 @@ public class DateUtilsFragmentTest { aCalendar.set(Calendar.MILLISECOND, millis); aDate = aCalendar.getTime(); } - + @Test public void testNullDate() { try { @@ -100,7 +100,7 @@ public class DateUtilsFragmentTest { fail(); } catch(final IllegalArgumentException iae) {} } - + @Test public void testInvalidFragmentWithDate() { try { @@ -174,7 +174,7 @@ public class DateUtilsFragmentTest { assertEquals(0, DateUtils.getFragmentInHours(aCalendar, Calendar.MILLISECOND)); assertEquals(0, DateUtils.getFragmentInDays(aCalendar, Calendar.MILLISECOND)); } - + @Test public void testSecondFragmentInLargerUnitWithDate() { assertEquals(0, DateUtils.getFragmentInSeconds(aDate, Calendar.SECOND)); @@ -190,7 +190,7 @@ public class DateUtilsFragmentTest { assertEquals(0, DateUtils.getFragmentInHours(aCalendar, Calendar.SECOND)); assertEquals(0, DateUtils.getFragmentInDays(aCalendar, Calendar.SECOND)); } - + @Test public void testMinuteFragmentInLargerUnitWithDate() { assertEquals(0, DateUtils.getFragmentInMinutes(aDate, Calendar.MINUTE)); @@ -238,7 +238,7 @@ public class DateUtilsFragmentTest { } //Calendar.SECOND as useful fragment - + @Test public void testMillisecondsOfSecondWithDate() { final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.SECOND); @@ -280,13 +280,13 @@ public class DateUtilsFragmentTest { } //Calendar.HOUR_OF_DAY as useful fragment - + @Test public void testMillisecondsOfHourWithDate() { 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() { final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.HOUR_OF_DAY); @@ -329,16 +329,16 @@ public class DateUtilsFragmentTest { @Test public void testMillisecondsOfDayWithDate() { long testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DATE); - final 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); } - + @Test public void testMillisecondsOfDayWithCalendar() { long testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DATE); - final 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); @@ -365,7 +365,7 @@ public class DateUtilsFragmentTest { @Test public void testMinutesOfDayWithDate() { long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DATE); - final 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); @@ -374,16 +374,16 @@ public class DateUtilsFragmentTest { @Test public void testMinutesOfDayWithCalendar() { long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DATE); - final 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); } - + @Test public void testHoursOfDayWithDate() { long testResult = DateUtils.getFragmentInHours(aDate, Calendar.DATE); - final long expectedValue = hours; + final long expectedValue = hours; assertEquals(expectedValue,testResult); testResult = DateUtils.getFragmentInHours(aDate, Calendar.DAY_OF_YEAR); assertEquals(expectedValue,testResult); @@ -392,13 +392,13 @@ public class DateUtilsFragmentTest { @Test public void testHoursOfDayWithCalendar() { long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.DATE); - final long expectedValue = hours; + final long expectedValue = hours; assertEquals(expectedValue, testResult); testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.DAY_OF_YEAR); assertEquals(expectedValue, testResult); } - - + + //Calendar.MONTH as useful fragment @Test public void testMillisecondsOfMonthWithDate() { @@ -415,7 +415,7 @@ public class DateUtilsFragmentTest { + (hours * DateUtils.MILLIS_PER_HOUR) + ((days - 1) * DateUtils.MILLIS_PER_DAY), testResult); } - + @Test public void testSecondsOfMonthWithDate() { final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MONTH); @@ -470,7 +470,7 @@ testResult); / DateUtils.MILLIS_PER_HOUR, testResult); } - + //Calendar.YEAR as useful fragment @Test public void testMillisecondsOfYearWithDate() { @@ -489,7 +489,7 @@ testResult); + (hours * DateUtils.MILLIS_PER_HOUR) + ((aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY), testResult); } - + @Test public void testSecondsOfYearWithDate() { final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.YEAR); @@ -563,27 +563,27 @@ testResult); / DateUtils.MILLIS_PER_HOUR, testResult); } - + @Test public void testDaysOfMonthWithCalendar() throws Exception { final long testResult = DateUtils.getFragmentInDays(aCalendar, Calendar.MONTH); assertEquals(days, testResult); } - + @Test public void testDaysOfMonthWithDate() throws Exception { final long testResult = DateUtils.getFragmentInDays(aDate, Calendar.MONTH); final Calendar cal = Calendar.getInstance(); cal.setTime(aDate); assertEquals(cal.get(Calendar.DAY_OF_MONTH), testResult); - } - + } + @Test public void testDaysOfYearWithCalendar() throws Exception { final long testResult = DateUtils.getFragmentInDays(aCalendar, Calendar.YEAR); assertEquals(aCalendar.get(Calendar.DAY_OF_YEAR), testResult); } - + @Test public void testDaysOfYearWithDate() throws Exception { final long testResult = DateUtils.getFragmentInDays(aDate, Calendar.YEAR); 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 b2a169bab..432a57438 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,19 +31,19 @@ import java.util.Locale; /** * These Unit-tests will check all possible extremes when using some rounding-methods of DateUtils. * The extremes are tested at the switch-point in milliseconds - * + * * According to the implementation SEMI_MONTH will either round/truncate to the 1st or 16th * When rounding Calendar.MONTH it depends on the number of days within that month. * A month with 28 days will be rounded up from the 15th * A month with 29 or 30 days will be rounded up from the 16th * A month with 31 days will be rounded up from the 17th - * + * * @since 3.0 */ public class DateUtilsRoundingTest { DateFormat dateTimeParser; - + Date januaryOneDate; Date targetYearDate; //No targetMonths, these must be tested for every type of month(28-31 days) @@ -62,7 +62,7 @@ public class DateUtilsRoundingTest { public void setUp() throws Exception { dateTimeParser = new SimpleDateFormat("MMM dd, yyyy H:mm:ss.SSS", Locale.ENGLISH); - + targetYearDate = dateTimeParser.parse("January 1, 2007 0:00:00.000"); targetDateDate = targetDayOfMonthDate = dateTimeParser.parse("June 1, 2008 0:00:00.000"); targetAmDate = dateTimeParser.parse("June 1, 2008 0:00:00.000"); @@ -72,7 +72,7 @@ public class DateUtilsRoundingTest { targetMinuteDate = dateTimeParser.parse("June 1, 2008 8:15:00.000"); targetSecondDate = dateTimeParser.parse("June 1, 2008 8:15:14.000"); targetMilliSecondDate = dateTimeParser.parse("June 1, 2008 8:15:14.231"); - + januaryOneDate = dateTimeParser.parse("January 1, 2008 0:00:00.000"); januaryOneCalendar = Calendar.getInstance(); januaryOneCalendar.setTime(januaryOneDate); @@ -80,7 +80,7 @@ public class DateUtilsRoundingTest { /** * Tests DateUtils.round()-method with Calendar.Year - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -92,12 +92,12 @@ public class DateUtilsRoundingTest { final Date lastRoundedDownDate = dateTimeParser.parse("June 30, 2007 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.MONTH * Includes rounding months with 28, 29, 30 and 31 days * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -106,7 +106,7 @@ public class DateUtilsRoundingTest { final int calendarField = Calendar.MONTH; Date roundedUpDate, roundedDownDate, lastRoundedDownDate; Date minDate, maxDate; - + //month with 28 days roundedUpDate = dateTimeParser.parse("March 1, 2007 0:00:00.000"); roundedDownDate = dateTimeParser.parse("February 1, 2007 0:00:00.000"); @@ -118,30 +118,30 @@ public class DateUtilsRoundingTest { roundedDownDate = dateTimeParser.parse("February 1, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("February 15, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //month with 30 days roundedUpDate = dateTimeParser.parse("May 1, 2008 0:00:00.000"); roundedDownDate = dateTimeParser.parse("April 1, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("April 15, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //month with 31 days roundedUpDate = dateTimeParser.parse("June 1, 2008 0:00:00.000"); roundedDownDate = dateTimeParser.parse("May 1, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("May 16, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 17, 2007 00:00:00.000"); maxDate = dateTimeParser.parse("January 16, 2008 23:59:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with DateUtils.SEMI_MONTH - * Includes rounding months with 28, 29, 30 and 31 days, each with first and second half + * Includes rounding months with 28, 29, 30 and 31 days, each with first and second half * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -150,7 +150,7 @@ public class DateUtilsRoundingTest { final int calendarField = DateUtils.SEMI_MONTH; Date roundedUpDate, roundedDownDate, lastRoundedDownDate; Date minDate, maxDate; - + //month with 28 days (1) roundedUpDate = dateTimeParser.parse("February 16, 2007 0:00:00.000"); roundedDownDate = dateTimeParser.parse("February 1, 2007 0:00:00.000"); @@ -168,7 +168,7 @@ public class DateUtilsRoundingTest { roundedDownDate = dateTimeParser.parse("February 1, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("February 8, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //month with 29 days (2) roundedUpDate = dateTimeParser.parse("March 1, 2008 0:00:00.000"); roundedDownDate = dateTimeParser.parse("February 16, 2008 0:00:00.000"); @@ -186,7 +186,7 @@ public class DateUtilsRoundingTest { roundedDownDate = dateTimeParser.parse("April 16, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("April 23, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //month with 31 days (1) roundedUpDate = dateTimeParser.parse("May 16, 2008 0:00:00.000"); roundedDownDate = dateTimeParser.parse("May 1, 2008 0:00:00.000"); @@ -198,18 +198,18 @@ public class DateUtilsRoundingTest { roundedDownDate = dateTimeParser.parse("May 16, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("May 23, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 24, 2007 00:00:00.000"); maxDate = dateTimeParser.parse("January 8, 2008 23:59:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.DATE - * Includes rounding the extremes of one day + * Includes rounding the extremes of one day * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -223,18 +223,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetDateDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 11:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 12:00:00.000"); maxDate = dateTimeParser.parse("January 1, 2008 11:59:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.DAY_OF_MONTH - * Includes rounding the extremes of one day + * Includes rounding the extremes of one day * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -248,18 +248,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetDayOfMonthDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 11:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 12:00:00.000"); maxDate = dateTimeParser.parse("January 1, 2008 11:59:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.AM_PM - * Includes rounding the extremes of both AM and PM of one day + * Includes rounding the extremes of both AM and PM of one day * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -286,12 +286,12 @@ public class DateUtilsRoundingTest { maxDate = dateTimeParser.parse("January 1, 2008 5:59:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.HOUR_OF_DAY - * Includes rounding the extremes of one hour + * Includes rounding the extremes of one hour * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -305,18 +305,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetHourOfDayDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:29:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 23:30:00.000"); maxDate = dateTimeParser.parse("January 1, 2008 0:29:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.HOUR - * Includes rounding the extremes of one hour + * Includes rounding the extremes of one hour * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -330,18 +330,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetHourDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:29:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 23:30:00.000"); maxDate = dateTimeParser.parse("January 1, 2008 0:29:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.MINUTE - * Includes rounding the extremes of one minute + * Includes rounding the extremes of one minute * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -355,18 +355,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetMinuteDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:15:29.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 23:59:30.000"); maxDate = dateTimeParser.parse("January 1, 2008 0:00:29.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.SECOND - * Includes rounding the extremes of one second + * Includes rounding the extremes of one second * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -380,18 +380,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetSecondDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:15:14.499"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 23:59:59.500"); maxDate = dateTimeParser.parse("January 1, 2008 0:00:00.499"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.MILLISECOND - * Includes rounding the extremes of one second + * Includes rounding the extremes of one second * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -404,15 +404,15 @@ public class DateUtilsRoundingTest { roundedDownDate = lastRoundedDownDate = targetMilliSecondDate; roundedUpDate = dateTimeParser.parse("June 1, 2008 8:15:14.232"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = maxDate = januaryOneDate; roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.YEAR - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -425,7 +425,7 @@ public class DateUtilsRoundingTest { /** * Test DateUtils.truncate()-method with Calendar.MONTH - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -440,7 +440,7 @@ public class DateUtilsRoundingTest { /** * Test DateUtils.truncate()-method with DateUtils.SEMI_MONTH * Includes truncating months with 28, 29, 30 and 31 days, each with first and second half - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -448,7 +448,7 @@ public class DateUtilsRoundingTest { public void testTruncateSemiMonth() throws Exception { final int calendarField = DateUtils.SEMI_MONTH; Date truncatedDate, lastTruncateDate; - + //month with 28 days (1) truncatedDate = dateTimeParser.parse("February 1, 2007 0:00:00.000"); lastTruncateDate = dateTimeParser.parse("February 15, 2007 23:59:59.999"); @@ -478,7 +478,7 @@ public class DateUtilsRoundingTest { truncatedDate = dateTimeParser.parse("April 16, 2008 0:00:00.000"); lastTruncateDate = dateTimeParser.parse("April 30, 2008 23:59:59.999"); baseTruncateTest(truncatedDate, lastTruncateDate, calendarField); - + //month with 31 days (1) truncatedDate = dateTimeParser.parse("March 1, 2008 0:00:00.000"); lastTruncateDate = dateTimeParser.parse("March 15, 2008 23:59:59.999"); @@ -493,7 +493,7 @@ public class DateUtilsRoundingTest { /** * Test DateUtils.truncate()-method with Calendar.DATE - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -503,10 +503,10 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999"); baseTruncateTest(targetDateDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.DAY_OF_MONTH - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -516,18 +516,18 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999"); baseTruncateTest(targetDayOfMonthDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.AM_PM - * Includes truncating the extremes of both AM and PM of one day - * + * Includes truncating the extremes of both AM and PM of one day + * * @throws Exception so we don't have to catch it * @since 3.0 */ @Test public void testTruncateAmPm() throws Exception { final int calendarField = Calendar.AM_PM; - + //AM Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 11:59:59.999"); baseTruncateTest(targetAmDate, lastTruncateDate, calendarField); @@ -536,10 +536,10 @@ public class DateUtilsRoundingTest { lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999"); baseTruncateTest(targetPmDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.HOUR - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -549,10 +549,10 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999"); baseTruncateTest(targetHourDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.HOUR_OF_DAY - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -562,10 +562,10 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999"); baseTruncateTest(targetHourOfDayDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.MINUTE - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -575,10 +575,10 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:59.999"); baseTruncateTest(targetMinuteDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.SECOND - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -588,10 +588,10 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:14.999"); baseTruncateTest(targetSecondDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.SECOND - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -600,13 +600,13 @@ public class DateUtilsRoundingTest { final int calendarField = Calendar.MILLISECOND; baseTruncateTest(targetMilliSecondDate, targetMilliSecondDate, calendarField); } - + /** - * When using this basetest all extremes are tested.<br> + * When using this basetest all extremes are tested.<br> * It will test the Date, Calendar and Object-implementation<br> * lastRoundDownDate should round down to roundedDownDate<br> * lastRoundDownDate + 1 millisecond should round up to roundedUpDate - * + * * @param roundedUpDate the next rounded date after <strong>roundedDownDate</strong> when using <strong>calendarField</strong> * @param roundedDownDate the result if <strong>lastRoundDownDate</strong> was rounded with <strong>calendarField</strong> * @param lastRoundDownDate rounding this value with <strong>calendarField</strong> will result in <strong>roundedDownDate</strong> @@ -615,15 +615,15 @@ public class DateUtilsRoundingTest { */ protected void baseRoundTest(final Date roundedUpDate, final Date roundedDownDate, final Date lastRoundDownDate, final int calendarField) { final Date firstRoundUpDate = DateUtils.addMilliseconds(lastRoundDownDate, 1); - + //Date-comparison assertEquals(roundedDownDate, DateUtils.round(roundedDownDate, calendarField)); assertEquals(roundedUpDate, DateUtils.round(roundedUpDate, calendarField)); assertEquals(roundedDownDate, DateUtils.round(lastRoundDownDate, calendarField)); assertEquals(roundedUpDate, DateUtils.round(firstRoundUpDate, calendarField)); - + //Calendar-initiations - Calendar roundedUpCalendar, roundedDownCalendar, lastRoundDownCalendar, firstRoundUpCalendar; + Calendar roundedUpCalendar, roundedDownCalendar, lastRoundDownCalendar, firstRoundUpCalendar; roundedDownCalendar = Calendar.getInstance(); roundedUpCalendar = Calendar.getInstance(); lastRoundDownCalendar = Calendar.getInstance(); @@ -649,13 +649,13 @@ public class DateUtilsRoundingTest { assertEquals(roundedDownDate, DateUtils.round((Object) lastRoundDownDate, calendarField)); assertEquals(roundedUpDate, DateUtils.round((Object) firstRoundUpDate, calendarField)); } - + /** - * When using this basetest all extremes are tested.<br> + * When using this basetest all extremes are tested.<br> * It will test the Date, Calendar and Object-implementation<br> * lastTruncateDate should round down to truncatedDate<br> * lastTruncateDate + 1 millisecond should never round down to truncatedDate - * + * * @param truncatedDate expected Date when <strong>lastTruncateDate</strong> is truncated with <strong>calendarField</strong> * @param lastTruncateDate the last possible Date which will truncate to <strong>truncatedDate</strong> with <strong>calendarField</strong> * @param calendarField a Calendar.field value @@ -663,14 +663,14 @@ public class DateUtilsRoundingTest { */ protected void baseTruncateTest(final Date truncatedDate, final Date lastTruncateDate, final int calendarField) { 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)); assertEquals(truncatedDate, DateUtils.truncate(lastTruncateDate, calendarField)); assertFalse(fdf.format(lastTruncateDate) +" is not an extreme when truncating as Date with CalendarField-value "+ calendarField, truncatedDate.equals(DateUtils.truncate(nextTruncateDate, calendarField))); - + //Calendar-initiations - Calendar truncatedCalendar, lastTruncateCalendar, nextTruncateCalendar; + Calendar truncatedCalendar, lastTruncateCalendar, nextTruncateCalendar; truncatedCalendar = Calendar.getInstance(); lastTruncateCalendar = Calendar.getInstance(); nextTruncateCalendar = Calendar.getInstance(); @@ -691,12 +691,12 @@ public class DateUtilsRoundingTest { assertEquals(truncatedDate, DateUtils.truncate((Object) lastTruncateCalendar, calendarField)); assertFalse(fdf.format(lastTruncateCalendar) +" is not an extreme when truncating as Calendar cast to Object with CalendarField-value "+ calendarField, truncatedDate.equals(DateUtils.truncate((Object) nextTruncateCalendar, calendarField))); } - + /** - * + * * Any January 1 could be considered as the ultimate extreme. - * Instead of comparing the results if the input has a difference of 1 millisecond we check the output to be exactly January first. - * + * Instead of comparing the results if the input has a difference of 1 millisecond we check the output to be exactly January first. + * * @param minDate the lower bound * @param maxDate the upper bound * @param calendarField a Calendar.field value @@ -706,7 +706,7 @@ public class DateUtilsRoundingTest { assertEquals("Rounding "+ fdf.format(januaryOneDate) +" as Date with CalendarField-value "+ calendarField +" must return itself", januaryOneDate, DateUtils.round(januaryOneDate, calendarField)); assertEquals(januaryOneDate, DateUtils.round(minDate, calendarField)); assertEquals(januaryOneDate, DateUtils.round(maxDate, calendarField)); - + final Calendar minCalendar = Calendar.getInstance(); minCalendar.setTime(minDate); final Calendar maxCalendar = Calendar.getInstance(); @@ -719,7 +719,7 @@ public class DateUtilsRoundingTest { 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))); - + final Calendar toPrevRoundCalendar = Calendar.getInstance(); toPrevRoundCalendar.setTime(toPrevRoundDate); final Calendar toNextRoundCalendar = Calendar.getInstance(); 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 964c40b94..77e110110 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -59,7 +59,7 @@ public class DateUtilsTest { @Rule public SystemDefaultsSwitch defaults = new SystemDefaultsSwitch(); - + private DateFormat dateParser = null; private DateFormat dateTimeParser = null; private Date dateAmPm1 = null; @@ -152,7 +152,7 @@ public class DateUtilsTest { assertTrue(Modifier.isPublic(DateUtils.class.getModifiers())); assertFalse(Modifier.isFinal(DateUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testIsSameDay_Date() { @@ -250,7 +250,7 @@ public class DateUtilsTest { calb.set(2004, Calendar.JULY, 9, 13, 45, 0); calb.set(Calendar.MILLISECOND, 0); assertFalse(DateUtils.isSameInstant(cala, calb)); - + calb.set(2004, Calendar.JULY, 9, 11, 45, 0); assertTrue(DateUtils.isSameInstant(cala, calb)); } @@ -288,7 +288,7 @@ public class DateUtilsTest { calc.set(Calendar.MILLISECOND, 0); cald.set(Calendar.MILLISECOND, 0); assertFalse("LANG-677", DateUtils.isSameLocalTime(calc, cald)); - + calb.set(2004, Calendar.JULY, 9, 11, 45, 0); assertFalse(DateUtils.isSameLocalTime(cala, calb)); } @@ -316,11 +316,11 @@ public class DateUtilsTest { final String[] parsers = new String[] {"yyyy'-'DDD", "yyyy'-'MM'-'dd", "yyyyMMdd"}; Date date = DateUtils.parseDate(dateStr, parsers); assertEquals(cal.getTime(), date); - + dateStr = "1972-338"; date = DateUtils.parseDate(dateStr, parsers); assertEquals(cal.getTime(), date); - + dateStr = "19721203"; date = DateUtils.parseDate(dateStr, parsers); assertEquals(cal.getTime(), date); @@ -348,7 +348,7 @@ public class DateUtilsTest { public void testParse_NullParsers() throws Exception { DateUtils.parseDate("19721203", (String[]) null); } - + @Test(expected = ParseException.class) public void testParse_EmptyParsers() throws Exception { DateUtils.parseDate("19721203"); @@ -360,10 +360,10 @@ public class DateUtilsTest { final GregorianCalendar cal = new GregorianCalendar(1998, 6, 30); final String dateStr = "02 942, 1996"; final String[] parsers = new String[] {"MM DDD, yyyy"}; - + final Date date = DateUtils.parseDate(dateStr, parsers); assertEquals(cal.getTime(), date); - + try { DateUtils.parseDateStrictly(dateStr, parsers); fail(); @@ -377,12 +377,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addYears(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2001, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addYears(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -396,12 +396,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addMonths(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 7, 5, 4, 3, 2, 1); - + result = DateUtils.addMonths(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -415,12 +415,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addWeeks(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 12, 4, 3, 2, 1); - + result = DateUtils.addWeeks(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); // july @@ -434,12 +434,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addDays(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 6, 4, 3, 2, 1); - + result = DateUtils.addDays(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -453,12 +453,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addHours(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 5, 3, 2, 1); - + result = DateUtils.addHours(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -472,12 +472,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addMinutes(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 4, 2, 1); - + result = DateUtils.addMinutes(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -491,12 +491,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addSeconds(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 3, 1); - + result = DateUtils.addSeconds(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -510,12 +510,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addMilliseconds(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 2); - + result = DateUtils.addMilliseconds(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -691,19 +691,19 @@ public class DateUtilsTest { // expected } } - + //----------------------------------------------------------------------- @Test(expected=NullPointerException.class) public void testToCalendarWithDateNull() { DateUtils.toCalendar(null, zone); } - + //----------------------------------------------------------------------- @Test(expected=NullPointerException.class) public void testToCalendarWithTimeZoneNull() { DateUtils.toCalendar(date1, null); } - + //----------------------------------------------------------------------- @Test public void testToCalendarWithDateAndTimeZoneNotNull() { @@ -711,7 +711,7 @@ public class DateUtilsTest { assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date2, c.getTime()); assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", defaultZone, c.getTimeZone()); } - + //----------------------------------------------------------------------- @Test(expected=NullPointerException.class) public void testToCalendarWithDateAndTimeZoneNull() { @@ -748,8 +748,8 @@ public class DateUtilsTest { assertEquals("round semimonth-2 failed", dateParser.parse("November 16, 2001"), DateUtils.round(date2, DateUtils.SEMI_MONTH)); - - + + assertEquals("round date-1 failed", dateParser.parse("February 13, 2002"), DateUtils.round(date1, Calendar.DATE)); @@ -882,7 +882,7 @@ public class DateUtilsTest { assertEquals("round ampm-4 failed", dateTimeParser.parse("February 4, 2002 00:00:00.000"), DateUtils.round((Object) calAmPm4, Calendar.AM_PM)); - + // Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=25560 / LANG-13 // Test rounding across the beginning of daylight saving time TimeZone.setDefault(zone); @@ -911,7 +911,7 @@ public class DateUtilsTest { assertEquals("round MET date across DST change-over", dateTimeParser.parse("March 30, 2003 00:00:00.000"), DateUtils.round((Object) cal7, Calendar.DATE)); - + assertEquals("round MET date across DST change-over", dateTimeParser.parse("March 30, 2003 01:00:00.000"), DateUtils.round(date4, Calendar.HOUR_OF_DAY)); @@ -1123,14 +1123,14 @@ public class DateUtilsTest { assertEquals("truncate ampm-4 failed", dateTimeParser.parse("February 3, 2002 12:00:00.000"), DateUtils.truncate((Object) dateAmPm4, Calendar.AM_PM)); - + assertEquals("truncate calendar second-1 failed", dateTimeParser.parse("February 12, 2002 12:34:56.000"), DateUtils.truncate((Object) cal1, Calendar.SECOND)); assertEquals("truncate calendar second-2 failed", dateTimeParser.parse("November 18, 2001 1:23:11.000"), DateUtils.truncate((Object) cal2, Calendar.SECOND)); - + assertEquals("truncate ampm-1 failed", dateTimeParser.parse("February 3, 2002 00:00:00.000"), DateUtils.truncate((Object) calAmPm1, Calendar.AM_PM)); @@ -1143,7 +1143,7 @@ public class DateUtilsTest { assertEquals("truncate ampm-4 failed", dateTimeParser.parse("February 3, 2002 12:00:00.000"), DateUtils.truncate((Object) calAmPm4, Calendar.AM_PM)); - + try { DateUtils.truncate((Date) null, Calendar.SECOND); fail(); @@ -1180,7 +1180,7 @@ public class DateUtilsTest { DateUtils.truncate((Object) cal8, Calendar.DATE)); TimeZone.setDefault(defaultZone); dateTimeParser.setTimeZone(defaultZone); - + // Bug 31395, large dates final Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis final GregorianCalendar endCal = new GregorianCalendar(); @@ -1214,7 +1214,7 @@ public class DateUtilsTest { final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z"); format.setTimeZone(MST_MDT); - final Date oct31_01MDT = new Date(1099206000000L); + final Date oct31_01MDT = new Date(1099206000000L); final Date oct31MDT = new Date(oct31_01MDT.getTime() - 3600000L); // - 1 hour final Date oct31_01_02MDT = new Date(oct31_01MDT.getTime() + 120000L); // + 2 minutes @@ -1284,9 +1284,9 @@ public class DateUtilsTest { 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); + assertEquals("Date not equal to itself ISO formatted and parsed", d.getTime(), d2.getTime() + d.getTime() % 1000); } - + /** * Tests various values with the ceiling method * @@ -1361,7 +1361,7 @@ public class DateUtilsTest { assertEquals("ceiling ampm-4 failed", dateTimeParser.parse("February 4, 2002 00:00:00.000"), DateUtils.ceiling(dateAmPm4, Calendar.AM_PM)); - + // tests public static Date ceiling(Object date, int field) assertEquals("ceiling year-1 failed", dateParser.parse("January 1, 2003"), @@ -1417,14 +1417,14 @@ public class DateUtilsTest { assertEquals("ceiling ampm-4 failed", dateTimeParser.parse("February 4, 2002 00:00:00.000"), DateUtils.ceiling((Object) dateAmPm4, Calendar.AM_PM)); - + assertEquals("ceiling calendar second-1 failed", dateTimeParser.parse("February 12, 2002 12:34:57.000"), DateUtils.ceiling((Object) cal1, Calendar.SECOND)); assertEquals("ceiling calendar second-2 failed", dateTimeParser.parse("November 18, 2001 1:23:12.000"), DateUtils.ceiling((Object) cal2, Calendar.SECOND)); - + assertEquals("ceiling ampm-1 failed", dateTimeParser.parse("February 3, 2002 12:00:00.000"), DateUtils.ceiling((Object) calAmPm1, Calendar.AM_PM)); @@ -1459,7 +1459,7 @@ public class DateUtilsTest { fail(); } catch(final IllegalArgumentException ex) {} - + // Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=25560 // Test ceiling across the beginning of daylight saving time TimeZone.setDefault(zone); @@ -1489,7 +1489,7 @@ public class DateUtilsTest { assertEquals("ceiling MET date across DST change-over", dateTimeParser.parse("March 31, 2003 00:00:00.000"), DateUtils.ceiling((Object) cal7, Calendar.DATE)); - + assertEquals("ceiling MET date across DST change-over", dateTimeParser.parse("March 30, 2003 03:00:00.000"), DateUtils.ceiling(date4, Calendar.HOUR_OF_DAY)); @@ -1516,7 +1516,7 @@ public class DateUtilsTest { DateUtils.ceiling((Object) cal7, Calendar.HOUR_OF_DAY)); TimeZone.setDefault(defaultZone); dateTimeParser.setTimeZone(defaultZone); - + // Bug 31395, large dates final Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis final GregorianCalendar endCal = new GregorianCalendar(); @@ -1584,7 +1584,7 @@ public class DateUtilsTest { } final Calendar centered = DateUtils.truncate(now, Calendar.DATE); centered.add(Calendar.DATE, -3); - + Iterator<?> it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_SUNDAY); assertWeekIterator(it, sunday); it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_MONDAY); @@ -1593,7 +1593,7 @@ public class DateUtilsTest { assertWeekIterator(it, today); it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_CENTER); assertWeekIterator(it, centered); - + it = DateUtils.iterator((Object) now, DateUtils.RANGE_WEEK_CENTER); assertWeekIterator(it, centered); it = DateUtils.iterator((Object) now.getTime(), DateUtils.RANGE_WEEK_CENTER); @@ -1607,11 +1607,11 @@ public class DateUtilsTest { try { it.remove(); } catch( final UnsupportedOperationException ex) {} - + now.add(Calendar.DATE,1); } } - + /** * Tests the calendar iterator for month-based ranges * @@ -1667,14 +1667,14 @@ public class DateUtilsTest { public void testLANG799_DE_FAIL() throws ParseException { DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz"); } - + // Parse German date with English Locale, specifying German Locale override @SystemDefaults(locale="en") @Test public void testLANG799_EN_WITH_DE_LOCALE() throws ParseException { DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", Locale.GERMAN, "EEE, dd MMM yyyy HH:mm:ss zzz"); } - + /** * This checks that this is a 7 element iterator of Calendar objects * that are dates (no time), and exactly 1 day spaced after each other. 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 2847c6d40..b5eb0fac8 100644 --- a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -409,14 +409,14 @@ public class DurationFormatUtilsTest { // http://issues.apache.org/bugzilla/show_bug.cgi?id=38401 @Test public void testBugzilla38401() { - assertEqualDuration( "0000/00/30 16:00:00 000", new int[] { 2006, 0, 26, 18, 47, 34 }, + assertEqualDuration( "0000/00/30 16:00:00 000", new int[] { 2006, 0, 26, 18, 47, 34 }, new int[] { 2006, 1, 26, 10, 47, 34 }, "yyyy/MM/dd HH:mm:ss SSS"); } // https://issues.apache.org/jira/browse/LANG-281 @Test public void testJiraLang281() { - assertEqualDuration( "09", new int[] { 2005, 11, 31, 0, 0, 0 }, + assertEqualDuration( "09", new int[] { 2005, 11, 31, 0, 0, 0 }, new int[] { 2006, 9, 6, 0, 0, 0 }, "MM"); } @@ -438,7 +438,7 @@ public class DurationFormatUtilsTest { for(int hr=0; hr < 24; hr++) { for(int min=0; min < 60; min++) { for(int sec=0; sec < 60; sec++) { - assertEqualDuration( hr + ":" + min + ":" + sec, + assertEqualDuration( hr + ":" + min + ":" + sec, new int[] { 2000, 0, 1, 0, 0, 0, 0 }, new int[] { 2000, 0, 1, hr, min, sec }, "H:m:s" @@ -453,92 +453,92 @@ public class DurationFormatUtilsTest { public void testEdgeDurations() { // This test case must use a time zone without DST TimeZone.setDefault(TimeZone.getTimeZone("UTC")); - assertEqualDuration( "01", new int[] { 2006, 0, 15, 0, 0, 0 }, + assertEqualDuration( "01", new int[] { 2006, 0, 15, 0, 0, 0 }, new int[] { 2006, 2, 10, 0, 0, 0 }, "MM"); - assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 }, + assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 }, new int[] { 2006, 0, 15, 0, 0, 0 }, "MM"); - assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 }, + assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 }, new int[] { 2006, 0, 16, 0, 0, 0 }, "MM"); - assertEqualDuration( "11", new int[] { 2005, 0, 15, 0, 0, 0 }, + assertEqualDuration( "11", new int[] { 2005, 0, 15, 0, 0, 0 }, new int[] { 2006, 0, 14, 0, 0, 0 }, "MM"); - + assertEqualDuration( "01 26", new int[] { 2006, 0, 15, 0, 0, 0 }, new int[] { 2006, 2, 10, 0, 0, 0 }, "MM dd"); assertEqualDuration( "54", new int[] { 2006, 0, 15, 0, 0, 0 }, - new int[] { 2006, 2, 10, 0, 0, 0 }, "dd"); - + new int[] { 2006, 2, 10, 0, 0, 0 }, "dd"); + assertEqualDuration( "09 12", new int[] { 2006, 1, 20, 0, 0, 0 }, new int[] { 2006, 11, 4, 0, 0, 0 }, "MM dd"); assertEqualDuration( "287", new int[] { 2006, 1, 20, 0, 0, 0 }, - new int[] { 2006, 11, 4, 0, 0, 0 }, "dd"); + new int[] { 2006, 11, 4, 0, 0, 0 }, "dd"); assertEqualDuration( "11 30", new int[] { 2006, 0, 2, 0, 0, 0 }, - new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd"); + new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd"); assertEqualDuration( "364", new int[] { 2006, 0, 2, 0, 0, 0 }, - new int[] { 2007, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2007, 0, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "12 00", new int[] { 2006, 0, 1, 0, 0, 0 }, - new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd"); + new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd"); assertEqualDuration( "365", new int[] { 2006, 0, 1, 0, 0, 0 }, - new int[] { 2007, 0, 1, 0, 0, 0 }, "dd"); - + new int[] { 2007, 0, 1, 0, 0, 0 }, "dd"); + assertEqualDuration( "31", new int[] { 2006, 0, 1, 0, 0, 0 }, - new int[] { 2006, 1, 1, 0, 0, 0 }, "dd"); - + new int[] { 2006, 1, 1, 0, 0, 0 }, "dd"); + assertEqualDuration( "92", new int[] { 2005, 9, 1, 0, 0, 0 }, - new int[] { 2006, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2006, 0, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "77", new int[] { 2005, 9, 16, 0, 0, 0 }, - new int[] { 2006, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2006, 0, 1, 0, 0, 0 }, "dd"); // test month larger in start than end assertEqualDuration( "136", new int[] { 2005, 9, 16, 0, 0, 0 }, - new int[] { 2006, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2006, 2, 1, 0, 0, 0 }, "dd"); // test when start in leap year assertEqualDuration( "136", new int[] { 2004, 9, 16, 0, 0, 0 }, - new int[] { 2005, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2005, 2, 1, 0, 0, 0 }, "dd"); // test when end in leap year assertEqualDuration( "137", new int[] { 2003, 9, 16, 0, 0, 0 }, - new int[] { 2004, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2004, 2, 1, 0, 0, 0 }, "dd"); // test when end in leap year but less than end of feb assertEqualDuration( "135", new int[] { 2003, 9, 16, 0, 0, 0 }, - new int[] { 2004, 1, 28, 0, 0, 0 }, "dd"); + new int[] { 2004, 1, 28, 0, 0, 0 }, "dd"); assertEqualDuration( "364", new int[] { 2007, 0, 2, 0, 0, 0 }, - new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "729", new int[] { 2006, 0, 2, 0, 0, 0 }, - new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "365", new int[] { 2007, 2, 2, 0, 0, 0 }, - new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "333", new int[] { 2007, 1, 2, 0, 0, 0 }, - new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "28", new int[] { 2008, 1, 2, 0, 0, 0 }, - new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "393", new int[] { 2007, 1, 2, 0, 0, 0 }, - new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "369", new int[] { 2004, 0, 29, 0, 0, 0 }, - new int[] { 2005, 1, 1, 0, 0, 0 }, "dd"); + new int[] { 2005, 1, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "338", new int[] { 2004, 1, 29, 0, 0, 0 }, - new int[] { 2005, 1, 1, 0, 0, 0 }, "dd"); + new int[] { 2005, 1, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "28", new int[] { 2004, 2, 8, 0, 0, 0 }, - new int[] { 2004, 3, 5, 0, 0, 0 }, "dd"); + new int[] { 2004, 3, 5, 0, 0, 0 }, "dd"); assertEqualDuration( "48", new int[] { 1992, 1, 29, 0, 0, 0 }, - new int[] { 1996, 1, 29, 0, 0, 0 }, "M"); - - - // this seems odd - and will fail if I throw it in as a brute force + new int[] { 1996, 1, 29, 0, 0, 0 }, "M"); + + + // this seems odd - and will fail if I throw it in as a brute force // below as it expects the answer to be 12. It's a tricky edge case assertEqualDuration( "11", new int[] { 1996, 1, 29, 0, 0, 0 }, - new int[] { 1997, 1, 28, 0, 0, 0 }, "M"); + new int[] { 1997, 1, 28, 0, 0, 0 }, "M"); // again - this seems odd assertEqualDuration( "11 28", new int[] { 1996, 1, 29, 0, 0, 0 }, - new int[] { 1997, 1, 28, 0, 0, 0 }, "M d"); - + new int[] { 1997, 1, 28, 0, 0, 0 }, "M d"); + } @Test @@ -581,7 +581,7 @@ public class DurationFormatUtilsTest { } private static final int FOUR_YEARS = 365 * 3 + 366; - + // Takes a minute to run, so generally turned off // public void testBrutally() { // Calendar c = Calendar.getInstance(); @@ -590,8 +590,8 @@ public class DurationFormatUtilsTest { // bruteForce(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), "d", Calendar.DAY_OF_MONTH ); // c.add(Calendar.DAY_OF_MONTH, 1); // } -// } - +// } + private void bruteForce(final int year, final int month, final int day, final String format, final int calendarType) { final String msg = year + "-" + month + "-" + day + " to "; final Calendar c = Calendar.getInstance(); 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 3de6df86e..7197a980a 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java @@ -162,10 +162,10 @@ public class FastDateFormatTest { final FastDateFormat format = FastDateFormat.getInstance(); final FastDateFormat medium = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT); assertEquals(medium, format); - + final SimpleDateFormat sdf = new SimpleDateFormat(); assertEquals(sdf.toPattern(), format.getPattern()); - + assertEquals(Locale.getDefault(), format.getLocale()); assertEquals(TimeZone.getDefault(), format.getTimeZone()); } @@ -176,7 +176,7 @@ public class FastDateFormatTest { 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)); assertFalse(shortShort.equals(longLong)); @@ -187,13 +187,13 @@ public class FastDateFormatTest { @Test public void testDateDefaults() { - assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, Locale.CANADA), + assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, Locale.CANADA), FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getDefault(), Locale.CANADA)); - - assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getTimeZone("America/New_York")), + + assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getTimeZone("America/New_York")), FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getTimeZone("America/New_York"), Locale.getDefault())); - assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG), + assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG), FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getDefault(), Locale.getDefault())); } @@ -255,7 +255,7 @@ public class FastDateFormatTest { final static private int NTHREADS= 10; final static private int NROUNDS= 10000; - + private AtomicLongArray measureTime(final Format printer, final Format parser) throws InterruptedException { final ExecutorService pool = Executors.newFixedThreadPool(NTHREADS); final AtomicInteger failures= new AtomicInteger(0); diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java index 78577512e..304332bf7 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java @@ -36,7 +36,7 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; /** - * Compare FastDateParser with SimpleDateFormat + * Compare FastDateParser with SimpleDateFormat */ @RunWith(Parameterized.class) public class FastDateParserSDFTest { @@ -184,9 +184,9 @@ public class FastDateParserSDFTest { fdfE = e.getClass(); } if (valid) { - assertEquals(locale.toString()+" "+formattedDate +"\n",expectedTime, actualTime); + assertEquals(locale.toString()+" "+formattedDate +"\n",expectedTime, actualTime); } else { - assertEquals(locale.toString()+" "+formattedDate + " expected same Exception ", sdfE, fdfE); + assertEquals(locale.toString()+" "+formattedDate + " expected same Exception ", sdfE, fdfE); } } private void checkParsePosition(final String formattedDate) { @@ -203,12 +203,12 @@ public class FastDateParserSDFTest { final int length = formattedDate.length(); if (endIndex != length) { // Error in test data - throw new RuntimeException("Test data error: expected SDF parse to consume entire string; endindex " + endIndex + " != " + length); + throw new RuntimeException("Test data error: expected SDF parse to consume entire string; endindex " + endIndex + " != " + length); } } else { final int errorIndex = sdfP.getErrorIndex(); if (errorIndex == -1) { - throw new RuntimeException("Test data error: expected SDF parse to fail, but got " + expectedTime); + throw new RuntimeException("Test data error: expected SDF parse to fail, but got " + expectedTime); } } @@ -225,6 +225,6 @@ public class FastDateParserSDFTest { assertNotEquals("Test data error: expected FDF parse to fail, but got " + actualTime, -1, fdferrorIndex); assertTrue("FDF error index ("+ fdferrorIndex + ") should approximate SDF index (" + sdferrorIndex + ")", sdferrorIndex - fdferrorIndex <= 4); - } + } } } 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 ed70757ce..c637f79e6 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -343,7 +343,7 @@ public class FastDateParserTest { } } } - + @Test public void testJpLocales() { @@ -421,7 +421,7 @@ public class FastDateParserTest { testSdfAndFdp("''yyyyMMdd'A''B'HHmmssSSS''", "'20030210A'B153320989'", false); // OK testSdfAndFdp("''''yyyyMMdd'A''B'HHmmssSSS''", "''20030210A'B153320989'", false); // OK testSdfAndFdp("'$\\Ed'" ,"$\\Ed", false); // OK - + // quoted charaters are case sensitive testSdfAndFdp("'QED'", "QED", false); testSdfAndFdp("'QED'", "qed", true); @@ -429,7 +429,7 @@ public class FastDateParserTest { testSdfAndFdp("yyyy-MM-dd 'QED'", "2003-02-10 QED", false); testSdfAndFdp("yyyy-MM-dd 'QED'", "2003-02-10 qed", true); } - + @Test public void testLANG_832() throws Exception { testSdfAndFdp("'d'd" ,"d3", false); // OK @@ -593,19 +593,19 @@ public class FastDateParserTest { final DateParser parser= getInstance(yMdHmsSZ, REYKJAVIK); assertEquals(REYKJAVIK, parser.getTimeZone()); } - + @Test public void testLang996() throws ParseException { final Calendar expected = Calendar.getInstance(NEW_YORK, Locale.US); expected.clear(); expected.set(2014, Calendar.MAY, 14); - final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US); + final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US); assertEquals(expected.getTime(), fdp.parse("14may2014")); assertEquals(expected.getTime(), fdp.parse("14MAY2014")); assertEquals(expected.getTime(), fdp.parse("14May2014")); } - + @Test(expected = IllegalArgumentException.class) public void test1806Argument() { getInstance("XXXX"); @@ -624,8 +624,8 @@ public class FastDateParserTest { } private static enum Expected1806 { - India(INDIA, "+05", "+0530", "+05:30", true), - Greenwich(GMT, "Z", "Z", "Z", false), + India(INDIA, "+05", "+0530", "+05:30", true), + Greenwich(GMT, "Z", "Z", "Z", false), NewYork(NEW_YORK, "-05", "-0500", "-05:00", false); private Expected1806(final TimeZone zone, final String one, final String two, final String three, final boolean hasHalfHourOffset) { @@ -642,17 +642,17 @@ public class FastDateParserTest { final String three; final long offset; } - + @Test public void test1806() throws ParseException { final String formatStub = "yyyy-MM-dd'T'HH:mm:ss.SSS"; final String dateStub = "2001-02-04T12:08:56.235"; - + for (final Expected1806 trial : Expected1806.values()) { final Calendar cal = initializeCalendar(trial.zone); final String message = trial.zone.getDisplayName()+";"; - + DateParser parser = getInstance(formatStub+"X", trial.zone); assertEquals(message+trial.one, cal.getTime().getTime(), parser.parse(dateStub+trial.one).getTime()-trial.offset); diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java index 970deb750..699bac74a 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java @@ -28,15 +28,15 @@ import org.junit.Test; public class FastDateParser_MoreOrLessTest { private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York"); - + @Test public void testInputHasPrecedingCharacters() { final FastDateParser parser = new FastDateParser("MM/dd", TimeZone.getDefault(), Locale.getDefault()); final ParsePosition parsePosition = new ParsePosition(0); final Date date = parser.parse("A 3/23/61", parsePosition); Assert.assertNull(date); - Assert.assertEquals(0, parsePosition.getIndex()); - Assert.assertEquals(0, parsePosition.getErrorIndex()); + Assert.assertEquals(0, parsePosition.getIndex()); + Assert.assertEquals(0, parsePosition.getErrorIndex()); } @Test @@ -51,7 +51,7 @@ public class FastDateParser_MoreOrLessTest { calendar.setTime(date); Assert.assertEquals(1961, calendar.get(Calendar.YEAR)); Assert.assertEquals(2, calendar.get(Calendar.MONTH)); - Assert.assertEquals(23, calendar.get(Calendar.DATE)); + Assert.assertEquals(23, calendar.get(Calendar.DATE)); } @Test @@ -64,9 +64,9 @@ public class FastDateParser_MoreOrLessTest { final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); Assert.assertEquals(2, calendar.get(Calendar.MONTH)); - Assert.assertEquals(23, calendar.get(Calendar.DATE)); + Assert.assertEquals(23, calendar.get(Calendar.DATE)); } - + @Test public void testInputHasWrongCharacters() { final FastDateParser parser = new FastDateParser("MM-dd-yyy", TimeZone.getDefault(), Locale.getDefault()); @@ -74,7 +74,7 @@ public class FastDateParser_MoreOrLessTest { Assert.assertNull(parser.parse("03/23/1961", parsePosition)); Assert.assertEquals(2, parsePosition.getErrorIndex()); } - + @Test public void testInputHasLessCharacters() { final FastDateParser parser = new FastDateParser("MM/dd/yyy", TimeZone.getDefault(), Locale.getDefault()); @@ -82,21 +82,21 @@ public class FastDateParser_MoreOrLessTest { Assert.assertNull(parser.parse("03/23", parsePosition)); Assert.assertEquals(5, parsePosition.getErrorIndex()); } - + @Test public void testInputHasWrongTimeZone() { final FastDateParser parser = new FastDateParser("mm:ss z", NEW_YORK, Locale.US); - + final String input = "11:23 Pacific Standard Time"; final ParsePosition parsePosition = new ParsePosition(0); Assert.assertNotNull(parser.parse(input, parsePosition)); Assert.assertEquals(input.length(), parsePosition.getIndex()); - + parsePosition.setIndex(0); Assert.assertNull(parser.parse( "11:23 Pacific Standard ", parsePosition)); Assert.assertEquals(6, parsePosition.getErrorIndex()); } - + @Test public void testInputHasWrongDay() { final FastDateParser parser = new FastDateParser("EEEE, MM/dd/yyy", NEW_YORK, Locale.US); @@ -104,7 +104,7 @@ public class FastDateParser_MoreOrLessTest { final ParsePosition parsePosition = new ParsePosition(0); Assert.assertNotNull(parser.parse(input, parsePosition)); Assert.assertEquals(input.length(), parsePosition.getIndex()); - + parsePosition.setIndex(0); Assert.assertNull(parser.parse( "Thorsday, 03/23/61", parsePosition)); Assert.assertEquals(0, parsePosition.getErrorIndex()); 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 fa8836ef6..8d8372677 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java @@ -42,7 +42,7 @@ import org.junit.Test; * @since 3.0 */ public class FastDatePrinterTest { - + private static final String YYYY_MM_DD = "yyyy/MM/dd"; private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York"); private static final TimeZone GMT = TimeZone.getTimeZone("GMT"); @@ -226,36 +226,36 @@ public class FastDatePrinterTest { assertEquals("fredag, week 53", fdf.format(d)); } - + @Test public void testEquals() { final DatePrinter printer1= getInstance(YYYY_MM_DD); final DatePrinter printer2= getInstance(YYYY_MM_DD); assertEquals(printer1, printer2); - assertEquals(printer1.hashCode(), printer2.hashCode()); + assertEquals(printer1.hashCode(), printer2.hashCode()); assertFalse(printer1.equals(new Object())); } - + @Test public void testToStringContainsName() { final DatePrinter printer= getInstance(YYYY_MM_DD); assertTrue(printer.toString().startsWith("FastDate")); } - + @Test public void testPatternMatches() { final DatePrinter printer= getInstance(YYYY_MM_DD); assertEquals(YYYY_MM_DD, printer.getPattern()); } - + @Test public void testLocaleMatches() { final DatePrinter printer= getInstance(YYYY_MM_DD, SWEDEN); assertEquals(SWEDEN, printer.getLocale()); } - + @Test public void testTimeZoneMatches() { final DatePrinter printer= getInstance(YYYY_MM_DD, NEW_YORK); @@ -268,10 +268,10 @@ public class FastDatePrinterTest { final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC")); final FastDateFormat noColonFormat = FastDateFormat.getInstance("Z"); assertEquals("+0000", noColonFormat.format(c)); - + final FastDateFormat isoFormat = FastDateFormat.getInstance("ZZ"); assertEquals("Z", isoFormat.format(c)); - + final FastDateFormat colonFormat = FastDateFormat.getInstance("ZZZ"); assertEquals("+00:00", colonFormat.format(c)); } @@ -325,7 +325,7 @@ public class FastDatePrinterTest { assertEquals(trial.three, printer.format(cal)); } } - + @Test public void testLang1103() throws ParseException { final Calendar cal = Calendar.getInstance(SWEDEN); 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 eefe2b323..645b680e5 100644 --- a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java +++ b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,10 +41,10 @@ public class StopWatchTest { watch.stop(); final long time = watch.getTime(); assertEquals(time, watch.getTime()); - + assertTrue(time >= 500); assertTrue(time < 700); - + watch.reset(); assertEquals(0, watch.getTime()); } @@ -54,13 +54,13 @@ public class StopWatchTest { final StopWatch watch = StopWatch.createStarted(); assertTrue(watch.isStarted()); } - + @Test public void testStopWatchSimpleGet(){ final StopWatch watch = new StopWatch(); assertEquals(0, watch.getTime()); assertEquals("00:00:00.000", watch.toString()); - + watch.start(); try {Thread.sleep(500);} catch (final InterruptedException ex) {} assertTrue(watch.getTime() < 2000); @@ -95,14 +95,14 @@ public class StopWatchTest { watch.stop(); final long totalTime = watch.getTime(); - assertEquals("Formatted split string not the correct length", + assertEquals("Formatted split string not the correct length", splitStr.length(), 12); assertTrue(splitTime >= 500); assertTrue(splitTime < 700); assertTrue(totalTime >= 1500); assertTrue(totalTime < 1900); } - + @Test public void testStopWatchSuspend(){ final StopWatch watch = new StopWatch(); @@ -115,7 +115,7 @@ public class StopWatchTest { try {Thread.sleep(550);} catch (final InterruptedException ex) {} watch.stop(); final long totalTime = watch.getTime(); - + assertTrue(suspendTime >= 500); assertTrue(suspendTime < 700); assertTrue(totalTime >= 1000); @@ -275,7 +275,7 @@ public class StopWatchTest { * Creates a suspended StopWatch object which appears to have elapsed * for the requested amount of time in nanoseconds. * <p> - * + * * <pre> * // Create a mock StopWatch with a time of 2:59:01.999 * final long nanos = TimeUnit.HOURS.toNanos(2) @@ -284,7 +284,7 @@ public class StopWatchTest { * + TimeUnit.MILLISECONDS.toNanos(999); * final StopWatch watch = createMockStopWatch(nanos); * </pre> - * + * * @param nanos Time in nanoseconds to have elapsed on the stop watch * @return StopWatch in a suspended state with the elapsed time */ 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 eaedef3e1..998ab1c6a 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java @@ -78,37 +78,37 @@ public class ImmutablePairTest { public void testHashCode() throws Exception { assertEquals(ImmutablePair.of(null, "foo").hashCode(), ImmutablePair.of(null, "foo").hashCode()); } - + @Test public void testNullPairEquals() { assertEquals(ImmutablePair.nullPair(), ImmutablePair.nullPair()); } - + @Test public void testNullPairSame() { assertSame(ImmutablePair.nullPair(), ImmutablePair.nullPair()); } - + @Test public void testNullPairLeft() { assertNull(ImmutablePair.nullPair().getLeft()); } - + @Test public void testNullPairKey() { assertNull(ImmutablePair.nullPair().getKey()); } - + @Test public void testNullPairRight() { assertNull(ImmutablePair.nullPair().getRight()); } - + @Test public void testNullPairValue() { assertNull(ImmutablePair.nullPair().getValue()); } - + @Test public void testNullPairTyped() { // No compiler warnings @@ -116,7 +116,7 @@ public class ImmutablePairTest { ImmutablePair<String, String> pair = ImmutablePair.nullPair(); assertNotNull(pair); } - + @Test public void testToString() throws Exception { assertEquals("(null,null)", ImmutablePair.of(null, null).toString()); 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 3be666069..d126d6e7b 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java @@ -91,27 +91,27 @@ public class ImmutableTripleTest { public void testNullTripleEquals() { assertEquals(ImmutableTriple.nullTriple(), ImmutableTriple.nullTriple()); } - + @Test public void testNullTripleSame() { assertSame(ImmutableTriple.nullTriple(), ImmutableTriple.nullTriple()); } - + @Test public void testNullTripleLeft() { assertNull(ImmutableTriple.nullTriple().getLeft()); } - + @Test public void testNullTripleMiddle() { assertNull(ImmutableTriple.nullTriple().getMiddle()); } - + @Test public void testNullTripleRight() { assertNull(ImmutableTriple.nullTriple().getRight()); } - + @Test public void testNullTripleTyped() { // No compiler warnings 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 b8eed248e..edd8fe9cd 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java @@ -49,7 +49,7 @@ public class MutablePairTest { assertNull(pair.getLeft()); assertNull(pair.getRight()); } - + @Test public void testMutate() throws Exception { final MutablePair<Integer, String> pair = new MutablePair<>(0, "foo"); 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 dc18ddb3d..5ca0aaeb3 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java @@ -52,7 +52,7 @@ public class MutableTripleTest { assertNull(triple.getMiddle()); assertNull(triple.getRight()); } - + @Test public void testMutate() throws Exception { final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<>(0, "foo", Boolean.TRUE); |