You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2017/06/08 08:16:09 UTC
[35/48] [lang] Make sure placement of curly braces is consistent
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
index 524140f..ab98319 100644
--- a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
@@ -1076,8 +1076,7 @@ public class ClassUtilsTest {
try {
ClassUtils.getClass( className );
fail( "ClassUtils.getClass() should fail with an exception of type " + exceptionType.getName() + " when given class name \"" + className + "\"." );
- }
- catch( final Exception e ) {
+ } catch( final Exception e ) {
assertTrue( exceptionType.isAssignableFrom( e.getClass() ) );
}
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
index d9a5bde..4912ece 100644
--- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
@@ -179,8 +179,7 @@ public class SerializationUtilsTest {
};
try {
SerializationUtils.serialize(iMap, streamTest);
- }
- catch(final SerializationException e) {
+ } catch(final SerializationException e) {
assertEquals("java.io.IOException: " + SERIALIZE_IO_EXCEPTION_MESSAGE, e.getMessage());
}
}
@@ -422,8 +421,7 @@ public class SerializationUtilsTest {
}
-class ClassNotFoundSerialization implements Serializable
-{
+class ClassNotFoundSerialization implements Serializable {
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/ValidateTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/ValidateTest.java b/src/test/java/org/apache/commons/lang3/ValidateTest.java
index 958c6d3..e5d077a 100644
--- a/src/test/java/org/apache/commons/lang3/ValidateTest.java
+++ b/src/test/java/org/apache/commons/lang3/ValidateTest.java
@@ -40,7 +40,7 @@ import org.junit.Test;
/**
* Unit tests {@link org.apache.commons.lang3.Validate}.
*/
-public class ValidateTest {
+public class ValidateTest {
//-----------------------------------------------------------------------
@Test
@@ -141,7 +141,7 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNotEmptyArray1() {
- Validate.notEmpty(new Object[] {null});
+ Validate.notEmpty(new Object[]{null});
try {
Validate.notEmpty((Object[]) null);
fail("Expecting NullPointerException");
@@ -155,7 +155,7 @@ public class ValidateTest {
assertEquals("The validated array is empty", ex.getMessage());
}
- final String[] array = new String[] {"hi"};
+ final String[] array = new String[]{"hi"};
final String[] test = Validate.notEmpty(array);
assertSame(array, test);
}
@@ -163,7 +163,7 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNotEmptyArray2() {
- Validate.notEmpty(new Object[] {null}, "MSG");
+ Validate.notEmpty(new Object[]{null}, "MSG");
try {
Validate.notEmpty((Object[]) null, "MSG");
fail("Expecting NullPointerException");
@@ -177,7 +177,7 @@ public class ValidateTest {
assertEquals("MSG", ex.getMessage());
}
- final String[] array = new String[] {"hi"};
+ final String[] array = new String[]{"hi"};
final String[] test = Validate.notEmpty(array, "Message");
assertSame(array, test);
}
@@ -541,7 +541,7 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNoNullElementsArray1() {
- String[] array = new String[] {"a", "b"};
+ String[] array = new String[]{"a", "b"};
Validate.noNullElements(array);
try {
Validate.noNullElements((Object[]) null);
@@ -557,7 +557,7 @@ public class ValidateTest {
assertEquals("The validated array contains null element at index: 1", ex.getMessage());
}
- array = new String[] {"a", "b"};
+ array = new String[]{"a", "b"};
final String[] test = Validate.noNullElements(array);
assertSame(array, test);
}
@@ -565,7 +565,7 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
public void testNoNullElementsArray2() {
- String[] array = new String[] {"a", "b"};
+ String[] array = new String[]{"a", "b"};
Validate.noNullElements(array, "MSG");
try {
Validate.noNullElements((Object[]) null, "MSG");
@@ -581,7 +581,7 @@ public class ValidateTest {
assertEquals("MSG", ex.getMessage());
}
- array = new String[] {"a", "b"};
+ array = new String[]{"a", "b"};
final String[] test = Validate.noNullElements(array, "Message");
assertSame(array, test);
}
@@ -671,7 +671,7 @@ public class ValidateTest {
assertEquals("Broken: ", ex.getMessage());
}
- final String[] strArray = new String[] {"Hi"};
+ final String[] strArray = new String[]{"Hi"};
final String[] test = Validate.noNullElements(strArray, "Message");
assertSame(strArray, test);
}
@@ -694,7 +694,7 @@ public class ValidateTest {
assertEquals("The validated array index is invalid: 2", ex.getMessage());
}
- final String[] strArray = new String[] {"Hi"};
+ final String[] strArray = new String[]{"Hi"};
final String[] test = Validate.noNullElements(strArray);
assertSame(strArray, test);
}
@@ -800,33 +800,25 @@ public class ValidateTest {
}
@Test
- public void testMatchesPattern()
- {
+ public void testMatchesPattern() {
final CharSequence str = "hi";
Validate.matchesPattern(str, "[a-z]*");
- try
- {
+ try {
Validate.matchesPattern(str, "[0-9]*");
fail("Expecting IllegalArgumentException");
- }
- catch (final IllegalArgumentException e)
- {
+ } catch (final IllegalArgumentException e) {
assertEquals("The string hi does not match the pattern [0-9]*", e.getMessage());
}
}
@Test
- public void testMatchesPattern_withMessage()
- {
+ public void testMatchesPattern_withMessage() {
final CharSequence str = "hi";
Validate.matchesPattern(str, "[a-z]*", "Does not match");
- try
- {
+ try {
Validate.matchesPattern(str, "[0-9]*", "Does not match");
fail("Expecting IllegalArgumentException");
- }
- catch (final IllegalArgumentException e)
- {
+ } catch (final IllegalArgumentException e) {
assertEquals("Does not match", e.getMessage());
}
}
@@ -913,8 +905,7 @@ public class ValidateTest {
//-----------------------------------------------------------------------
@Test
- public void testInclusiveBetween()
- {
+ public void testInclusiveBetween() {
Validate.inclusiveBetween("a", "c", "b");
try {
Validate.inclusiveBetween("0", "5", "6");
@@ -925,8 +916,7 @@ public class ValidateTest {
}
@Test
- public void testInclusiveBetween_withMessage()
- {
+ public void testInclusiveBetween_withMessage() {
Validate.inclusiveBetween("a", "c", "b", "Error");
try {
Validate.inclusiveBetween("0", "5", "6", "Error");
@@ -937,8 +927,7 @@ public class ValidateTest {
}
@Test
- public void testInclusiveBetweenLong()
- {
+ public void testInclusiveBetweenLong() {
Validate.inclusiveBetween(0, 2, 1);
Validate.inclusiveBetween(0, 2, 2);
try {
@@ -950,8 +939,7 @@ public class ValidateTest {
}
@Test
- public void testInclusiveBetweenLong_withMessage()
- {
+ public void testInclusiveBetweenLong_withMessage() {
Validate.inclusiveBetween(0, 2, 1, "Error");
Validate.inclusiveBetween(0, 2, 2, "Error");
try {
@@ -963,8 +951,7 @@ public class ValidateTest {
}
@Test
- public void testInclusiveBetweenDouble()
- {
+ public void testInclusiveBetweenDouble() {
Validate.inclusiveBetween(0.1, 2.1, 1.1);
Validate.inclusiveBetween(0.1, 2.1, 2.1);
try {
@@ -976,8 +963,7 @@ public class ValidateTest {
}
@Test
- public void testInclusiveBetweenDouble_withMessage()
- {
+ public void testInclusiveBetweenDouble_withMessage() {
Validate.inclusiveBetween(0.1, 2.1, 1.1, "Error");
Validate.inclusiveBetween(0.1, 2.1, 2.1, "Error");
try {
@@ -989,8 +975,7 @@ public class ValidateTest {
}
@Test
- public void testExclusiveBetween()
- {
+ public void testExclusiveBetween() {
Validate.exclusiveBetween("a", "c", "b");
try {
Validate.exclusiveBetween("0", "5", "6");
@@ -1007,8 +992,7 @@ public class ValidateTest {
}
@Test
- public void testExclusiveBetween_withMessage()
- {
+ public void testExclusiveBetween_withMessage() {
Validate.exclusiveBetween("a", "c", "b", "Error");
try {
Validate.exclusiveBetween("0", "5", "6", "Error");
@@ -1025,8 +1009,7 @@ public class ValidateTest {
}
@Test
- public void testExclusiveBetweenLong()
- {
+ public void testExclusiveBetweenLong() {
Validate.exclusiveBetween(0, 2, 1);
try {
Validate.exclusiveBetween(0, 5, 6);
@@ -1043,8 +1026,7 @@ public class ValidateTest {
}
@Test
- public void testExclusiveBetweenLong_withMessage()
- {
+ public void testExclusiveBetweenLong_withMessage() {
Validate.exclusiveBetween(0, 2, 1, "Error");
try {
Validate.exclusiveBetween(0, 5, 6, "Error");
@@ -1061,8 +1043,7 @@ public class ValidateTest {
}
@Test
- public void testExclusiveBetweenDouble()
- {
+ public void testExclusiveBetweenDouble() {
Validate.exclusiveBetween(0.1, 2.1, 1.1);
try {
Validate.exclusiveBetween(0.1, 5.1, 6.1);
@@ -1079,8 +1060,7 @@ public class ValidateTest {
}
@Test
- public void testExclusiveBetweenDouble_withMessage()
- {
+ public void testExclusiveBetweenDouble_withMessage() {
Validate.exclusiveBetween(0.1, 2.1, 1.1, "Error");
try {
Validate.exclusiveBetween(0.1, 5.1, 6.1, "Error");
@@ -1107,7 +1087,7 @@ public class ValidateTest {
try {
Validate.isInstanceOf(List.class, "hi");
fail("Expecting IllegalArgumentException");
- } catch(final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Expected type: java.util.List, actual: java.lang.String", e.getMessage());
}
}
@@ -1119,7 +1099,7 @@ public class ValidateTest {
try {
Validate.isInstanceOf(List.class, "hi", "Error");
fail("Expecting IllegalArgumentException");
- } catch(final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
}
@@ -1131,19 +1111,19 @@ public class ValidateTest {
try {
Validate.isInstanceOf(List.class, "hi", "Error %s=%s", "Name", "Value");
fail("Expecting IllegalArgumentException");
- } catch(final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error Name=Value", e.getMessage());
}
try {
Validate.isInstanceOf(List.class, "hi", "Error %s=%s", List.class, "Value");
fail("Expecting IllegalArgumentException");
- } catch(final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error interface java.util.List=Value", e.getMessage());
}
try {
Validate.isInstanceOf(List.class, "hi", "Error %s=%s", List.class, null);
fail("Expecting IllegalArgumentException");
- } catch(final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error interface java.util.List=null", e.getMessage());
}
}
@@ -1159,7 +1139,7 @@ public class ValidateTest {
try {
Validate.isAssignableFrom(List.class, String.class);
fail("Expecting IllegalArgumentException");
- } catch(final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Cannot assign a java.lang.String to a java.util.List", e.getMessage());
}
}
@@ -1171,7 +1151,7 @@ public class ValidateTest {
try {
Validate.isAssignableFrom(List.class, String.class, "Error");
fail("Expecting IllegalArgumentException");
- } catch(final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals("Error", e.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
----------------------------------------------------------------------
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 8be9b98..3e47b3a 100644
--- a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
@@ -34,15 +34,22 @@ public class EqualsBuilderTest {
static class TestObject {
private int a;
+
TestObject() {
}
+
TestObject(final int a) {
this.a = a;
}
+
@Override
public boolean equals(final Object o) {
- if (o == null) { return false; }
- if (o == this) { return true; }
+ if (o == null) {
+ return false;
+ }
+ if (o == this) {
+ return true;
+ }
if (o.getClass() != getClass()) {
return false;
}
@@ -67,17 +74,24 @@ public class EqualsBuilderTest {
static class TestSubObject extends TestObject {
private int b;
+
TestSubObject() {
super(0);
}
+
TestSubObject(final int a, final int b) {
super(a);
this.b = b;
}
+
@Override
public boolean equals(final Object o) {
- if (o == null) { return false; }
- if (o == this) { return true; }
+ if (o == null) {
+ return false;
+ }
+ if (o == this) {
+ return true;
+ }
if (o.getClass() != getClass()) {
return false;
}
@@ -88,7 +102,7 @@ public class EqualsBuilderTest {
@Override
public int hashCode() {
- return b *17 + super.hashCode();
+ return b * 17 + super.hashCode();
}
public void setB(final int b) {
@@ -109,6 +123,7 @@ public class EqualsBuilderTest {
static class TestTSubObject extends TestObject {
@SuppressWarnings("unused")
private transient int t;
+
TestTSubObject(final int a, final int t) {
super(a);
this.t = t;
@@ -118,6 +133,7 @@ public class EqualsBuilderTest {
static class TestTTSubObject extends TestTSubObject {
@SuppressWarnings("unused")
private transient int tt;
+
TestTTSubObject(final int a, final int t, final int tt) {
super(a, t);
this.tt = tt;
@@ -127,6 +143,7 @@ public class EqualsBuilderTest {
static class TestTTLeafObject extends TestTTSubObject {
@SuppressWarnings("unused")
private final int leafValue;
+
TestTTLeafObject(final int a, final int t, final int tt, final int leafValue) {
super(a, t, tt);
this.leafValue = leafValue;
@@ -135,12 +152,15 @@ public class EqualsBuilderTest {
static class TestTSubObject2 extends TestObject {
private transient int t;
+
TestTSubObject2(final int a, final int t) {
super(a);
}
+
public int getT() {
return t;
}
+
public void setT(final int t) {
this.t = t;
}
@@ -152,7 +172,7 @@ public class EqualsBuilderTest {
private int z;
TestRecursiveObject(final TestRecursiveInnerObject a,
- final TestRecursiveInnerObject b, final int z) {
+ final TestRecursiveInnerObject b, final int z) {
this.a = a;
this.b = b;
}
@@ -173,6 +193,7 @@ public class EqualsBuilderTest {
static class TestRecursiveInnerObject {
private final int n;
+
TestRecursiveInnerObject(final int n) {
this.n = n;
}
@@ -185,6 +206,7 @@ public class EqualsBuilderTest {
static class TestRecursiveCycleObject {
private TestRecursiveCycleObject cycle;
private final int n;
+
TestRecursiveCycleObject(final int n) {
this.n = n;
this.cycle = this;
@@ -301,20 +323,21 @@ public class EqualsBuilderTest {
* <li>consistency</li>
* <li>non-null reference</li>
* </ul>
- * @param to a TestObject
- * @param toBis a TestObject, equal to to and toTer
- * @param toTer Left hand side, equal to to and toBis
- * @param to2 a different TestObject
- * @param oToChange a TestObject that will be changed
+ *
+ * @param to a TestObject
+ * @param toBis a TestObject, equal to to and toTer
+ * @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
*/
private void testReflectionEqualsEquivalenceRelationship(
- final TestObject to,
- final TestObject toBis,
- final TestObject toTer,
- final TestObject to2,
- final TestObject oToChange,
- final boolean testTransients) {
+ final TestObject to,
+ final TestObject toBis,
+ final TestObject toTer,
+ final TestObject to2,
+ final TestObject oToChange,
+ final boolean testTransients) {
// reflection test
assertTrue(EqualsBuilder.reflectionEquals(to, to, testTransients));
@@ -325,9 +348,9 @@ public class EqualsBuilderTest {
// transitive test
assertTrue(
- EqualsBuilder.reflectionEquals(to, toBis, testTransients)
- && EqualsBuilder.reflectionEquals(toBis, toTer, testTransients)
- && EqualsBuilder.reflectionEquals(to, toTer, testTransients));
+ EqualsBuilder.reflectionEquals(to, toBis, testTransients)
+ && EqualsBuilder.reflectionEquals(toBis, toTer, testTransients)
+ && EqualsBuilder.reflectionEquals(to, toTer, testTransients));
// consistency test
oToChange.setA(to.getA());
@@ -1146,8 +1169,8 @@ public class EqualsBuilderTest {
*/
@Test
public void testNpeForNullElement() {
- final Object[] x1 = new Object[] { Integer.valueOf(1), null, Integer.valueOf(3) };
- final Object[] x2 = new Object[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };
+ final Object[] x1 = new Object[]{Integer.valueOf(1), null, Integer.valueOf(3)};
+ final Object[] x2 = new Object[]{Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)};
// causes an NPE in 2.0 according to:
// http://issues.apache.org/bugzilla/show_bug.cgi?id=33067
@@ -1249,17 +1272,17 @@ public class EqualsBuilderTest {
final TestObject one = new TestObject(1);
final TestObject two = new TestObject(2);
- final Object[] o1 = new Object[] { one };
- final Object[] o2 = new Object[] { two };
- final Object[] o3 = new Object[] { one };
+ final Object[] o1 = new Object[]{one};
+ final Object[] o2 = new Object[]{two};
+ final Object[] o3 = new Object[]{one};
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 };
+ 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));
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
----------------------------------------------------------------------
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 a6e2555..9c4265a 100644
--- a/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
@@ -41,8 +41,7 @@ import org.junit.Test;
/**
* @since 3.0
*/
-public class EventUtilsTest
-{
+public class EventUtilsTest {
@Test
public void testConstructor() {
@@ -55,8 +54,7 @@ public class EventUtilsTest
}
@Test
- public void testAddEventListener()
- {
+ public void testAddEventListener() {
final PropertyChangeSource src = new PropertyChangeSource();
final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
final PropertyChangeListener listener = handler.createListener(PropertyChangeListener.class);
@@ -68,64 +66,49 @@ public class EventUtilsTest
}
@Test
- public void testAddEventListenerWithNoAddMethod()
- {
+ public void testAddEventListenerWithNoAddMethod() {
final PropertyChangeSource src = new PropertyChangeSource();
final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
final ObjectChangeListener listener = handler.createListener(ObjectChangeListener.class);
- try
- {
+ try {
EventUtils.addEventListener(src, ObjectChangeListener.class, listener);
fail("Should not be allowed to add a listener to an object that doesn't support it.");
- }
- catch (final IllegalArgumentException e)
- {
+ } catch (final IllegalArgumentException e) {
assertEquals("Class " + src.getClass().getName() + " does not have a public add" + ObjectChangeListener.class.getSimpleName() + " method which takes a parameter of type " + ObjectChangeListener.class.getName() + ".", e.getMessage());
}
}
@Test
- public void testAddEventListenerThrowsException()
- {
+ public void testAddEventListenerThrowsException() {
final ExceptionEventSource src = new ExceptionEventSource();
- try
- {
- EventUtils.addEventListener(src, PropertyChangeListener.class, new PropertyChangeListener()
- {
+ try {
+ EventUtils.addEventListener(src, PropertyChangeListener.class, new PropertyChangeListener() {
@Override
- public void propertyChange(final PropertyChangeEvent e)
- {
+ public void propertyChange(final PropertyChangeEvent e) {
// Do nothing!
}
});
fail("Add method should have thrown an exception, so method should fail.");
- }
- catch (final RuntimeException e)
- {
+ } catch (final RuntimeException e) {
}
}
@Test
- public void testAddEventListenerWithPrivateAddMethod()
- {
+ public void testAddEventListenerWithPrivateAddMethod() {
final PropertyChangeSource src = new PropertyChangeSource();
final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
final VetoableChangeListener listener = handler.createListener(VetoableChangeListener.class);
- try
- {
+ try {
EventUtils.addEventListener(src, VetoableChangeListener.class, listener);
fail("Should not be allowed to add a listener to an object that doesn't support it.");
- }
- catch (final IllegalArgumentException e)
- {
+ } catch (final IllegalArgumentException e) {
assertEquals("Class " + src.getClass().getName() + " does not have a public add" + VetoableChangeListener.class.getSimpleName() + " method which takes a parameter of type " + VetoableChangeListener.class.getName() + ".", e.getMessage());
}
}
@Test
- public void testBindEventsToMethod()
- {
+ public void testBindEventsToMethod() {
final PropertyChangeSource src = new PropertyChangeSource();
final EventCounter counter = new EventCounter();
EventUtils.bindEventsToMethod(counter, "eventOccurred", src, PropertyChangeListener.class);
@@ -136,8 +119,7 @@ public class EventUtilsTest
@Test
- public void testBindEventsToMethodWithEvent()
- {
+ public void testBindEventsToMethodWithEvent() {
final PropertyChangeSource src = new PropertyChangeSource();
final EventCounterWithEvent counter = new EventCounterWithEvent();
EventUtils.bindEventsToMethod(counter, "eventOccurred", src, PropertyChangeListener.class);
@@ -148,8 +130,7 @@ public class EventUtilsTest
@Test
- public void testBindFilteredEventsToMethod()
- {
+ public void testBindFilteredEventsToMethod() {
final MultipleEventSource src = new MultipleEventSource();
final EventCounter counter = new EventCounter();
EventUtils.bindEventsToMethod(counter, "eventOccurred", src, MultipleEventListener.class, "event1");
@@ -160,120 +141,97 @@ public class EventUtilsTest
assertEquals(1, counter.getCount());
}
- public interface MultipleEventListener
- {
+ public interface MultipleEventListener {
void event1(PropertyChangeEvent e);
void event2(PropertyChangeEvent e);
}
- public static class EventCounter
- {
+ public static class EventCounter {
private int count;
- public void eventOccurred()
- {
+ public void eventOccurred() {
count++;
}
- public int getCount()
- {
+ public int getCount() {
return count;
}
}
- public static class EventCounterWithEvent
- {
+ public static class EventCounterWithEvent {
private int count;
- public void eventOccurred(final PropertyChangeEvent e)
- {
+ public void eventOccurred(final PropertyChangeEvent e) {
count++;
}
- public int getCount()
- {
+ public int getCount() {
return count;
}
}
- private static class EventCountingInvociationHandler implements InvocationHandler
- {
+ private static class EventCountingInvociationHandler implements InvocationHandler {
private final Map<String, Integer> eventCounts = new TreeMap<>();
- public <L> L createListener(final Class<L> listenerType)
- {
+ public <L> L createListener(final Class<L> listenerType) {
return listenerType.cast(Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
new Class[]{listenerType},
this));
}
- public int getEventCount(final String eventName)
- {
+ public int getEventCount(final String eventName) {
final Integer count = eventCounts.get(eventName);
return count == null ? 0 : count.intValue();
}
@Override
- public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable
- {
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
final Integer count = eventCounts.get(method.getName());
- if (count == null)
- {
+ if (count == null) {
eventCounts.put(method.getName(), Integer.valueOf(1));
- }
- else
- {
+ } else {
eventCounts.put(method.getName(), Integer.valueOf(count.intValue() + 1));
}
return null;
}
}
- public static class MultipleEventSource
- {
+ public static class MultipleEventSource {
private final EventListenerSupport<MultipleEventListener> listeners = EventListenerSupport.create(MultipleEventListener.class);
- public void addMultipleEventListener(final MultipleEventListener listener)
- {
+ public void addMultipleEventListener(final MultipleEventListener listener) {
listeners.addListener(listener);
}
}
- public static class ExceptionEventSource
- {
- public void addPropertyChangeListener(final PropertyChangeListener listener)
- {
+ public static class ExceptionEventSource {
+ public void addPropertyChangeListener(final PropertyChangeListener listener) {
throw new RuntimeException();
}
}
- public static class PropertyChangeSource
- {
+ public static class PropertyChangeSource {
private final EventListenerSupport<PropertyChangeListener> listeners = EventListenerSupport.create(PropertyChangeListener.class);
private String property;
- public void setProperty(final String property)
- {
+ public void setProperty(final String property) {
final String oldValue = this.property;
this.property = property;
listeners.fire().propertyChange(new PropertyChangeEvent(this, "property", oldValue, property));
}
- protected void addVetoableChangeListener(final VetoableChangeListener listener)
- {
+ protected void addVetoableChangeListener(final VetoableChangeListener listener) {
// Do nothing!
}
- public void addPropertyChangeListener(final PropertyChangeListener listener)
- {
+ public void addPropertyChangeListener(final PropertyChangeListener listener) {
listeners.addListener(listener);
}
- public void removePropertyChangeListener(final PropertyChangeListener listener)
- {
+ public void removePropertyChangeListener(final PropertyChangeListener listener) {
listeners.removeListener(listener);
}
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
----------------------------------------------------------------------
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 d319e2e..aa69ce7 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
@@ -40,6 +40,7 @@ import org.junit.Test;
/**
* Tests {@link org.apache.commons.lang3.exception.ExceptionUtils}.
+ *
* @since 1.0
*/
public class ExceptionUtilsTest {
@@ -133,15 +134,15 @@ public class ExceptionUtilsTest {
// not known type, so match on supplied method names
assertSame(nested, ExceptionUtils.getCause(withCause, null)); // default names
assertSame(null, ExceptionUtils.getCause(withCause, new String[0]));
- assertSame(null, ExceptionUtils.getCause(withCause, new String[] {null}));
- assertSame(nested, ExceptionUtils.getCause(withCause, new String[] {"getCause"}));
+ 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]));
- assertSame(null, ExceptionUtils.getCause(withoutCause, new String[] {null}));
- assertSame(null, ExceptionUtils.getCause(withoutCause, new String[] {"getCause"}));
- assertSame(null, ExceptionUtils.getCause(withoutCause, new String[] {"getTargetException"}));
+ assertSame(null, ExceptionUtils.getCause(withoutCause, new String[]{null}));
+ assertSame(null, ExceptionUtils.getCause(withoutCause, new String[]{"getCause"}));
+ assertSame(null, ExceptionUtils.getCause(withoutCause, new String[]{"getTargetException"}));
}
@Test
@@ -449,7 +450,7 @@ public class ExceptionUtilsTest {
assertFalse(match);
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testRemoveCommonFrames_ListList() throws Exception {
ExceptionUtils.removeCommonFrames(null, null);
}
@@ -479,6 +480,7 @@ public class ExceptionUtilsTest {
}
//-----------------------------------------------------------------------
+
/**
* Provides a method with a well known chained/nested exception
* name which matches the full signature (e.g. has a return value
@@ -517,7 +519,7 @@ public class ExceptionUtilsTest {
private static class ExceptionWithoutCause extends Exception {
private static final long serialVersionUID = 1L;
- @SuppressWarnings("unused")
+ @SuppressWarnings("unused")
public void getTargetException() {
}
}
@@ -528,8 +530,13 @@ public class ExceptionUtilsTest {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unused")
- NestableException() { super(); }
- NestableException(final Throwable t) { super(t); }
+ NestableException() {
+ super();
+ }
+
+ NestableException(final Throwable t) {
+ super(t);
+ }
}
@Test
@@ -538,8 +545,7 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.rethrow(expected);
Assert.fail("Exception not thrown");
- }
- catch(final Exception actual) {
+ } catch (final Exception actual) {
Assert.assertSame(expected, actual);
}
}
@@ -549,8 +555,7 @@ public class ExceptionUtilsTest {
try {
throwsCheckedException();
Assert.fail("Exception not thrown");
- }
- catch(final Exception ioe) {
+ } catch (final Exception ioe) {
assertTrue(ioe instanceof IOException);
assertEquals(1, ExceptionUtils.getThrowableCount(ioe));
}
@@ -558,8 +563,7 @@ public class ExceptionUtilsTest {
try {
redeclareCheckedException();
Assert.fail("Exception not thrown");
- }
- catch(final IOException ioe) {
+ } catch (final IOException ioe) {
assertEquals(1, ExceptionUtils.getThrowableCount(ioe));
}
}
@@ -585,8 +589,7 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.wrapAndThrow(new OutOfMemoryError());
Assert.fail("Error not thrown");
- }
- catch(final Throwable t) {
+ } catch (final Throwable t) {
Assert.assertTrue(ExceptionUtils.hasCause(t, Error.class));
}
}
@@ -596,8 +599,7 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.wrapAndThrow(new IllegalArgumentException());
Assert.fail("RuntimeException not thrown");
- }
- catch(final Throwable t) {
+ } catch (final Throwable t) {
Assert.assertTrue(ExceptionUtils.hasCause(t, RuntimeException.class));
}
}
@@ -607,8 +609,7 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.wrapAndThrow(new IOException());
Assert.fail("Checked Exception not thrown");
- }
- catch(final Throwable t) {
+ } catch (final Throwable t) {
Assert.assertTrue(ExceptionUtils.hasCause(t, IOException.class));
}
}
@@ -618,8 +619,7 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.wrapAndThrow(new TestThrowable());
Assert.fail("Checked Exception not thrown");
- }
- catch(final Throwable t) {
+ } catch (final Throwable t) {
Assert.assertTrue(ExceptionUtils.hasCause(t, TestThrowable.class));
}
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
index 5c1989b..5f29430 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
@@ -59,7 +59,8 @@ import org.junit.Test;
*/
public class MethodUtilsTest {
- private interface PrivateInterface {}
+ private interface PrivateInterface {
+ }
static class TestBeanWithInterfaces implements PrivateInterface {
public String foo() {
@@ -197,54 +198,107 @@ public class MethodUtilsTest {
// This method is overloaded for the wrapper class for every primitive type, plus the common supertypes
// Number and Object. This is an acid test since it easily leads to ambiguous methods.
- public static String varOverload(final Byte... args) { return "Byte..."; }
- public static String varOverload(final Character... args) { return "Character..."; }
- public static String varOverload(final Short... args) { return "Short..."; }
- public static String varOverload(final Boolean... args) { return "Boolean..."; }
- public static String varOverload(final Float... args) { return "Float..."; }
- public static String varOverload(final Double... args) { return "Double..."; }
- public static String varOverload(final Integer... args) { return "Integer..."; }
- public static String varOverload(final Long... args) { return "Long..."; }
- public static String varOverload(final Number... args) { return "Number..."; }
- public static String varOverload(final Object... args) { return "Object..."; }
- public static String varOverload(final String... args) { return "String..."; }
+ public static String varOverload(final Byte... args) {
+ return "Byte...";
+ }
+
+ public static String varOverload(final Character... args) {
+ return "Character...";
+ }
+
+ public static String varOverload(final Short... args) {
+ return "Short...";
+ }
+
+ public static String varOverload(final Boolean... args) {
+ return "Boolean...";
+ }
+
+ public static String varOverload(final Float... args) {
+ return "Float...";
+ }
+
+ public static String varOverload(final Double... args) {
+ return "Double...";
+ }
+
+ public static String varOverload(final Integer... args) {
+ return "Integer...";
+ }
+
+ public static String varOverload(final Long... args) {
+ return "Long...";
+ }
+
+ public static String varOverload(final Number... args) {
+ return "Number...";
+ }
+
+ public static String varOverload(final Object... args) {
+ return "Object...";
+ }
+
+ public static String varOverload(final String... args) {
+ return "String...";
+ }
// This method is overloaded for the wrapper class for every numeric primitive type, plus the common
// supertype Number
- public static String numOverload(final Byte... args) { return "Byte..."; }
- public static String numOverload(final Short... args) { return "Short..."; }
- public static String numOverload(final Float... args) { return "Float..."; }
- public static String numOverload(final Double... args) { return "Double..."; }
- public static String numOverload(final Integer... args) { return "Integer..."; }
- public static String numOverload(final Long... args) { return "Long..."; }
- public static String numOverload(final Number... args) { return "Number..."; }
+ public static String numOverload(final Byte... args) {
+ return "Byte...";
+ }
+
+ public static String numOverload(final Short... args) {
+ return "Short...";
+ }
+
+ public static String numOverload(final Float... args) {
+ return "Float...";
+ }
+
+ public static String numOverload(final Double... args) {
+ return "Double...";
+ }
+
+ public static String numOverload(final Integer... args) {
+ return "Integer...";
+ }
+
+ public static String numOverload(final Long... args) {
+ return "Long...";
+ }
+
+ public static String numOverload(final Number... args) {
+ return "Number...";
+ }
// These varOverloadEcho and varOverloadEchoStatic methods are designed to verify that
// not only is the correct overloaded variant invoked, but that the varags arguments
// are also delivered correctly to the method.
public ImmutablePair<String, Object[]> varOverloadEcho(final String... args) {
- return new ImmutablePair<String, Object[]>("String...", args);
+ return new ImmutablePair<String, Object[]>("String...", args);
}
+
public ImmutablePair<String, Object[]> varOverloadEcho(final Number... args) {
- return new ImmutablePair<String, Object[]>("Number...", args);
+ return new ImmutablePair<String, Object[]>("Number...", args);
}
public static ImmutablePair<String, Object[]> varOverloadEchoStatic(final String... args) {
- return new ImmutablePair<String, Object[]>("String...", args);
+ return new ImmutablePair<String, Object[]>("String...", args);
}
+
public static ImmutablePair<String, Object[]> varOverloadEchoStatic(final Number... args) {
- return new ImmutablePair<String, Object[]>("Number...", args);
+ return new ImmutablePair<String, Object[]>("Number...", args);
}
static void verify(final ImmutablePair<String, Object[]> a, final ImmutablePair<String, Object[]> b) {
- assertEquals(a.getLeft(), b.getLeft());
- assertArrayEquals(a.getRight(), b.getRight());
+ assertEquals(a.getLeft(), b.getLeft());
+ assertArrayEquals(a.getRight(), b.getRight());
}
static void verify(final ImmutablePair<String, Object[]> a, final Object _b) {
- @SuppressWarnings("unchecked")
- final ImmutablePair<String, Object[]> b = (ImmutablePair<String, Object[]>) _b;
- verify(a, b);
+ @SuppressWarnings("unchecked") final ImmutablePair<String, Object[]> b = (ImmutablePair<String, Object[]>) _b;
+ verify(a, b);
}
}
@@ -389,13 +443,13 @@ public class MethodUtilsTest {
}
TestBean.verify(new ImmutablePair<String, Object[]>("String...", new String[]{"x", "y"}),
- MethodUtils.invokeMethod(testBean, "varOverloadEcho", "x", "y"));
+ MethodUtils.invokeMethod(testBean, "varOverloadEcho", "x", "y"));
TestBean.verify(new ImmutablePair<String, Object[]>("Number...", new Number[]{17, 23, 42}),
- MethodUtils.invokeMethod(testBean, "varOverloadEcho", 17, 23, 42));
+ MethodUtils.invokeMethod(testBean, "varOverloadEcho", 17, 23, 42));
TestBean.verify(new ImmutablePair<String, Object[]>("String...", new String[]{"x", "y"}),
- MethodUtils.invokeMethod(testBean, "varOverloadEcho", "x", "y"));
+ MethodUtils.invokeMethod(testBean, "varOverloadEcho", "x", "y"));
TestBean.verify(new ImmutablePair<String, Object[]>("Number...", new Number[]{17, 23, 42}),
- MethodUtils.invokeMethod(testBean, "varOverloadEcho", 17, 23, 42));
+ MethodUtils.invokeMethod(testBean, "varOverloadEcho", 17, 23, 42));
}
@Test
@@ -414,8 +468,8 @@ public class MethodUtilsTest {
assertEquals("foo(Integer)", MethodUtils.invokeExactMethod(testBean,
"foo", NumberUtils.INTEGER_ONE));
assertEquals("foo(double)", MethodUtils.invokeExactMethod(testBean,
- "foo", new Object[] { NumberUtils.DOUBLE_ONE },
- new Class[] { Double.TYPE }));
+ "foo", new Object[]{NumberUtils.DOUBLE_ONE},
+ new Class[]{Double.TYPE}));
try {
MethodUtils
@@ -464,13 +518,13 @@ public class MethodUtilsTest {
TestBean.class, "bar", NumberUtils.INTEGER_ONE, "a", "b"));
TestBean.verify(new ImmutablePair<String, Object[]>("String...", new String[]{"x", "y"}),
- MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", "x", "y"));
+ MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", "x", "y"));
TestBean.verify(new ImmutablePair<String, Object[]>("Number...", new Number[]{17, 23, 42}),
- MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", 17, 23, 42));
+ MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", 17, 23, 42));
TestBean.verify(new ImmutablePair<String, Object[]>("String...", new String[]{"x", "y"}),
- MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", "x", "y"));
+ MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", "x", "y"));
TestBean.verify(new ImmutablePair<String, Object[]>("Number...", new Number[]{17, 23, 42}),
- MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", 17, 23, 42));
+ MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", 17, 23, 42));
try {
MethodUtils.invokeStaticMethod(TestBean.class, "does_not_exist");
@@ -494,8 +548,8 @@ public class MethodUtilsTest {
assertEquals("bar(Integer)", MethodUtils.invokeExactStaticMethod(
TestBean.class, "bar", NumberUtils.INTEGER_ONE));
assertEquals("bar(double)", MethodUtils.invokeExactStaticMethod(
- TestBean.class, "bar", new Object[] { NumberUtils.DOUBLE_ONE },
- new Class[] { Double.TYPE }));
+ TestBean.class, "bar", new Object[]{NumberUtils.DOUBLE_ONE},
+ new Class[]{Double.TYPE}));
try {
MethodUtils.invokeExactStaticMethod(TestBean.class, "bar",
@@ -519,7 +573,7 @@ public class MethodUtilsTest {
@Test
public void testGetAccessibleInterfaceMethod() throws Exception {
- final Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
+ final Class<?>[][] p = {ArrayUtils.EMPTY_CLASS_ARRAY, null};
for (final Class<?>[] element : p) {
final Method method = TestMutable.class.getMethod("getValue", element);
final Method accessibleMethod = MethodUtils.getAccessibleMethod(method);
@@ -539,7 +593,7 @@ public class MethodUtilsTest {
@Test
public void testGetAccessibleInterfaceMethodFromDescription()
throws Exception {
- final Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
+ final Class<?>[][] p = {ArrayUtils.EMPTY_CLASS_ARRAY, null};
for (final Class<?>[] element : p) {
final Method accessibleMethod = MethodUtils.getAccessibleMethod(
TestMutable.class, "getValue", element);
@@ -562,14 +616,14 @@ public class MethodUtilsTest {
}
@Test
- public void testGetAccessibleMethodInaccessible() throws Exception {
+ public void testGetAccessibleMethodInaccessible() throws Exception {
final Method expected = TestBean.class.getDeclaredMethod("privateStuff");
final Method actual = MethodUtils.getAccessibleMethod(expected);
assertNull(actual);
}
@Test
- public void testGetMatchingAccessibleMethod() throws Exception {
+ public void testGetMatchingAccessibleMethod() throws Exception {
expectMatchingAccessibleMethodParameterTypes(TestBean.class, "foo",
ArrayUtils.EMPTY_CLASS_ARRAY, ArrayUtils.EMPTY_CLASS_ARRAY);
expectMatchingAccessibleMethodParameterTypes(TestBean.class, "foo",
@@ -611,9 +665,9 @@ public class MethodUtilsTest {
expectMatchingAccessibleMethodParameterTypes(TestBean.class, "foo",
singletonArray(Double.TYPE), singletonArray(Double.TYPE));
expectMatchingAccessibleMethodParameterTypes(TestBean.class, "foo",
- new Class[] {String.class, String.class}, new Class[] {String[].class});
+ new Class[]{String.class, String.class}, new Class[]{String[].class});
expectMatchingAccessibleMethodParameterTypes(TestBean.class, "foo",
- new Class[] {Integer.TYPE, String.class, String.class}, new Class[] {Integer.class, String[].class});
+ new Class[]{Integer.TYPE, String.class, String.class}, new Class[]{Integer.class, String[].class});
expectMatchingAccessibleMethodParameterTypes(InheritanceBean.class, "testOne",
singletonArray(ParentObject.class), singletonArray(ParentObject.class));
expectMatchingAccessibleMethodParameterTypes(InheritanceBean.class, "testOne",
@@ -634,10 +688,10 @@ public class MethodUtilsTest {
public void testGetOverrideHierarchyIncludingInterfaces() {
final Method method = MethodUtils.getAccessibleMethod(StringParameterizedChild.class, "consume", String.class);
final Iterator<MethodDescriptor> expected =
- Arrays.asList(new MethodDescriptor(StringParameterizedChild.class, "consume", String.class),
- new MethodDescriptor(GenericParent.class, "consume", GenericParent.class.getTypeParameters()[0]),
- new MethodDescriptor(GenericConsumer.class, "consume", GenericConsumer.class.getTypeParameters()[0]))
- .iterator();
+ Arrays.asList(new MethodDescriptor(StringParameterizedChild.class, "consume", String.class),
+ new MethodDescriptor(GenericParent.class, "consume", GenericParent.class.getTypeParameters()[0]),
+ new MethodDescriptor(GenericConsumer.class, "consume", GenericConsumer.class.getTypeParameters()[0]))
+ .iterator();
for (final Method m : MethodUtils.getOverrideHierarchy(method, Interfaces.INCLUDE)) {
assertTrue(expected.hasNext());
final MethodDescriptor md = expected.next();
@@ -655,9 +709,9 @@ public class MethodUtilsTest {
public void testGetOverrideHierarchyExcludingInterfaces() {
final Method method = MethodUtils.getAccessibleMethod(StringParameterizedChild.class, "consume", String.class);
final Iterator<MethodDescriptor> expected =
- Arrays.asList(new MethodDescriptor(StringParameterizedChild.class, "consume", String.class),
- new MethodDescriptor(GenericParent.class, "consume", GenericParent.class.getTypeParameters()[0]))
- .iterator();
+ Arrays.asList(new MethodDescriptor(StringParameterizedChild.class, "consume", String.class),
+ new MethodDescriptor(GenericParent.class, "consume", GenericParent.class.getTypeParameters()[0]))
+ .iterator();
for (final Method m : MethodUtils.getOverrideHierarchy(method, Interfaces.EXCLUDE)) {
assertTrue(expected.hasNext());
final MethodDescriptor md = expected.next();
@@ -861,7 +915,7 @@ public class MethodUtilsTest {
}
private void expectMatchingAccessibleMethodParameterTypes(final Class<?> cls,
- final String methodName, final Class<?>[] requestTypes, final Class<?>[] actualTypes) {
+ final String methodName, final Class<?>[] requestTypes, final Class<?>[] actualTypes) {
final Method m = MethodUtils.getMatchingAccessibleMethod(cls, methodName,
requestTypes);
assertNotNull("could not find any matches for " + methodName
@@ -878,25 +932,43 @@ public class MethodUtilsTest {
private Class<?>[] singletonArray(final Class<?> c) {
Class<?>[] result = classCache.get(c);
if (result == null) {
- result = new Class[] { c };
+ result = new Class[]{c};
classCache.put(c, result);
}
return result;
}
public static class InheritanceBean {
- public void testOne(final Object obj) {}
- public void testOne(final GrandParentObject obj) {}
- public void testOne(final ParentObject obj) {}
- public void testTwo(final Object obj) {}
- public void testTwo(final GrandParentObject obj) {}
- public void testTwo(final ChildInterface obj) {}
+ public void testOne(final Object obj) {
+ }
+
+ public void testOne(final GrandParentObject obj) {
+ }
+
+ public void testOne(final ParentObject obj) {
+ }
+
+ public void testTwo(final Object obj) {
+ }
+
+ public void testTwo(final GrandParentObject obj) {
+ }
+
+ public void testTwo(final ChildInterface obj) {
+ }
}
- interface ChildInterface {}
- public static class GrandParentObject {}
- public static class ParentObject extends GrandParentObject {}
- public static class ChildObject extends ParentObject implements ChildInterface {}
+ interface ChildInterface {
+ }
+
+ public static class GrandParentObject {
+ }
+
+ public static class ParentObject extends GrandParentObject {
+ }
+
+ public static class ChildObject extends ParentObject implements ChildInterface {
+ }
private static class MethodDescriptor {
final Class<?> declaringClass;
@@ -913,7 +985,7 @@ public class MethodUtilsTest {
@Test
public void testVarArgsUnboxing() throws Exception {
final TestBean testBean = new TestBean();
- final int[] actual = (int[])MethodUtils.invokeMethod(testBean, "unboxing", Integer.valueOf(1), Integer.valueOf(2));
+ final int[] actual = (int[]) MethodUtils.invokeMethod(testBean, "unboxing", Integer.valueOf(1), Integer.valueOf(2));
Assert.assertArrayEquals(new int[]{1, 2}, actual);
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
----------------------------------------------------------------------
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 cdc53f7..17ec976 100644
--- a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java
@@ -409,7 +409,9 @@ public class ExtendedMessageFormatTest {
return toAppendTo.append(((String)obj).toLowerCase());
}
@Override
- public Object parseObject(final String source, final ParsePosition pos) {throw new UnsupportedOperationException();}
+ public Object parseObject(final String source, final ParsePosition pos) {
+ throw new UnsupportedOperationException();
+ }
}
/**
@@ -423,7 +425,9 @@ public class ExtendedMessageFormatTest {
return toAppendTo.append(((String)obj).toUpperCase());
}
@Override
- public Object parseObject(final String source, final ParsePosition pos) {throw new UnsupportedOperationException();}
+ public Object parseObject(final String source, final ParsePosition pos) {
+ throw new UnsupportedOperationException();
+ }
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
----------------------------------------------------------------------
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 09486ef..435ae42 100644
--- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java
@@ -565,29 +565,25 @@ public class StrBuilderTest {
try {
sb.getChars(-1,0,a,0);
fail("no exception");
- }
- catch (final IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
}
try {
sb.getChars(0,-1,a,0);
fail("no exception");
- }
- catch (final IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
}
try {
sb.getChars(0,20,a,0);
fail("no exception");
- }
- catch (final IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
}
try {
sb.getChars(4,2,a,0);
fail("no exception");
- }
- catch (final IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
}
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
----------------------------------------------------------------------
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 3289e5b..55bac2d 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
@@ -206,8 +206,7 @@ public class FastDateParserTest {
cal.set(Calendar.ERA, 0);
cal.set(Calendar.YEAR, 1868-year);
}
- }
- else {
+ } else {
if (year < 0) {
cal.set(Calendar.ERA, GregorianCalendar.BC);
year= -year;
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
index ecb876b..33104b5 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
@@ -40,8 +40,7 @@ public class FastDateParser_TimeZoneStrategyTest {
}
try {
parser.parse(tzDisplay);
- }
- catch(final Exception ex) {
+ } catch(final Exception ex) {
Assert.fail("'" + tzDisplay + "'"
+ " Locale: '" + locale.getDisplayName() + "'"
+ " TimeZone: " + zone[0]
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
----------------------------------------------------------------------
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 645b680..3ff1e77 100644
--- a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
@@ -30,14 +30,17 @@ import org.junit.Test;
/**
* TestCase for StopWatch.
*/
-public class StopWatchTest {
+public class StopWatchTest {
//-----------------------------------------------------------------------
@Test
- public void testStopWatchSimple(){
+ public void testStopWatchSimple() {
final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(550);} catch (final InterruptedException ex) {}
+ try {
+ Thread.sleep(550);
+ } catch (final InterruptedException ex) {
+ }
watch.stop();
final long time = watch.getTime();
assertEquals(time, watch.getTime());
@@ -56,13 +59,16 @@ public class StopWatchTest {
}
@Test
- public void testStopWatchSimpleGet(){
+ 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) {}
+ try {
+ Thread.sleep(500);
+ } catch (final InterruptedException ex) {
+ }
assertTrue(watch.getTime() < 2000);
}
@@ -71,9 +77,9 @@ public class StopWatchTest {
// Create a mock StopWatch with a time of 2:59:01.999
final StopWatch watch = createMockStopWatch(
TimeUnit.HOURS.toNanos(2)
- + TimeUnit.MINUTES.toNanos(59)
- + TimeUnit.SECONDS.toNanos(1)
- + TimeUnit.MILLISECONDS.toNanos(999));
+ + TimeUnit.MINUTES.toNanos(59)
+ + TimeUnit.SECONDS.toNanos(1)
+ + TimeUnit.MILLISECONDS.toNanos(999));
assertEquals(2L, watch.getTime(TimeUnit.HOURS));
assertEquals(179L, watch.getTime(TimeUnit.MINUTES));
@@ -82,21 +88,30 @@ public class StopWatchTest {
}
@Test
- public void testStopWatchSplit(){
+ public void testStopWatchSplit() {
final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(550);} catch (final InterruptedException ex) {}
+ try {
+ Thread.sleep(550);
+ } catch (final InterruptedException ex) {
+ }
watch.split();
final long splitTime = watch.getSplitTime();
final String splitStr = watch.toSplitString();
- try {Thread.sleep(550);} catch (final InterruptedException ex) {}
+ try {
+ Thread.sleep(550);
+ } catch (final InterruptedException ex) {
+ }
watch.unsplit();
- try {Thread.sleep(550);} catch (final InterruptedException ex) {}
+ try {
+ Thread.sleep(550);
+ } catch (final InterruptedException ex) {
+ }
watch.stop();
final long totalTime = watch.getTime();
assertEquals("Formatted split string not the correct length",
- splitStr.length(), 12);
+ splitStr.length(), 12);
assertTrue(splitTime >= 500);
assertTrue(splitTime < 700);
assertTrue(totalTime >= 1500);
@@ -104,15 +119,24 @@ public class StopWatchTest {
}
@Test
- public void testStopWatchSuspend(){
+ public void testStopWatchSuspend() {
final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(550);} catch (final InterruptedException ex) {}
+ try {
+ Thread.sleep(550);
+ } catch (final InterruptedException ex) {
+ }
watch.suspend();
final long suspendTime = watch.getTime();
- try {Thread.sleep(550);} catch (final InterruptedException ex) {}
+ try {
+ Thread.sleep(550);
+ } catch (final InterruptedException ex) {
+ }
watch.resume();
- try {Thread.sleep(550);} catch (final InterruptedException ex) {}
+ try {
+ Thread.sleep(550);
+ } catch (final InterruptedException ex) {
+ }
watch.stop();
final long totalTime = watch.getTime();
@@ -126,13 +150,19 @@ public class StopWatchTest {
public void testLang315() {
final StopWatch watch = new StopWatch();
watch.start();
- try {Thread.sleep(200);} catch (final InterruptedException ex) {}
+ try {
+ Thread.sleep(200);
+ } catch (final InterruptedException ex) {
+ }
watch.suspend();
final long suspendTime = watch.getTime();
- try {Thread.sleep(200);} catch (final InterruptedException ex) {}
+ try {
+ Thread.sleep(200);
+ } catch (final InterruptedException ex) {
+ }
watch.stop();
final long totalTime = watch.getTime();
- assertTrue( suspendTime == totalTime );
+ assertTrue(suspendTime == totalTime);
}
// test bad states
@@ -142,42 +172,42 @@ public class StopWatchTest {
try {
watch.stop();
fail("Calling stop on an unstarted StopWatch should throw an exception. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
try {
watch.stop();
fail("Calling stop on an unstarted StopWatch should throw an exception. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
try {
watch.suspend();
fail("Calling suspend on an unstarted StopWatch should throw an exception. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
try {
watch.split();
fail("Calling split on a non-running StopWatch should throw an exception. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
try {
watch.unsplit();
fail("Calling unsplit on an unsplit StopWatch should throw an exception. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
try {
watch.resume();
fail("Calling resume on an unsuspended StopWatch should throw an exception. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
@@ -186,28 +216,28 @@ public class StopWatchTest {
try {
watch.start();
fail("Calling start on a started StopWatch should throw an exception. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
try {
watch.unsplit();
fail("Calling unsplit on an unsplit StopWatch should throw an exception. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
try {
watch.getSplitTime();
fail("Calling getSplitTime on an unsplit StopWatch should throw an exception. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
try {
watch.resume();
fail("Calling resume on an unsuspended StopWatch should throw an exception. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
@@ -216,7 +246,7 @@ public class StopWatchTest {
try {
watch.start();
fail("Calling start on a stopped StopWatch should throw an exception as it needs to be reset. ");
- } catch(final IllegalStateException ise) {
+ } catch (final IllegalStateException ise) {
// expected
}
}
@@ -275,7 +305,7 @@ public class StopWatchTest {
* Creates a suspended StopWatch object which appears to have elapsed
* for the requested amount of time in nanoseconds.
* <p>
- *
+ * <p>
* <pre>
* // Create a mock StopWatch with a time of 2:59:01.999
* final long nanos = TimeUnit.HOURS.toNanos(2)