You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2013/01/22 08:09:49 UTC
svn commit: r1436770 [11/16] - in /commons/proper/lang/trunk/src:
main/java/org/apache/commons/lang3/
main/java/org/apache/commons/lang3/builder/
main/java/org/apache/commons/lang3/concurrent/
main/java/org/apache/commons/lang3/event/ main/java/org/apa...
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java Tue Jan 22 07:09:45 2013
@@ -51,10 +51,10 @@ public class TimedSemaphoreTest {
*/
@Test
public void testInit() {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
EasyMock.replay(service);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
EasyMock.verify(service);
assertEquals("Wrong service", service, semaphore.getExecutorService());
@@ -83,8 +83,8 @@ public class TimedSemaphoreTest {
*/
@Test
public void testInitDefaultService() {
- TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
- ScheduledThreadPoolExecutor exec = (ScheduledThreadPoolExecutor) semaphore
+ final TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
+ final ScheduledThreadPoolExecutor exec = (ScheduledThreadPoolExecutor) semaphore
.getExecutorService();
assertFalse("Wrong periodic task policy", exec
.getContinueExistingPeriodicTasksAfterShutdownPolicy());
@@ -99,9 +99,9 @@ public class TimedSemaphoreTest {
*/
@Test
public void testStartTimer() throws InterruptedException {
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(PERIOD,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(PERIOD,
UNIT, LIMIT);
- ScheduledFuture<?> future = semaphore.startTimer();
+ final ScheduledFuture<?> future = semaphore.startTimer();
assertNotNull("No future returned", future);
Thread.sleep(PERIOD);
final int trials = 10;
@@ -121,7 +121,7 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownOwnExecutor() {
- TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
+ final TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
semaphore.shutdown();
assertTrue("Not shutdown", semaphore.isShutdown());
assertTrue("Executor not shutdown", semaphore.getExecutorService()
@@ -134,10 +134,10 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownSharedExecutorNoTask() {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
EasyMock.replay(service);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
semaphore.shutdown();
assertTrue("Not shutdown", semaphore.isShutdown());
@@ -163,13 +163,13 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownSharedExecutorTask() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.expect(Boolean.valueOf(future.cancel(false))).andReturn(Boolean.TRUE);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, LIMIT);
semaphore.acquire();
semaphore.shutdown();
@@ -182,13 +182,13 @@ public class TimedSemaphoreTest {
*/
@Test
public void testShutdownMultipleTimes() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.expect(Boolean.valueOf(future.cancel(false))).andReturn(Boolean.TRUE);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, LIMIT);
semaphore.acquire();
for (int i = 0; i < 10; i++) {
@@ -202,15 +202,15 @@ public class TimedSemaphoreTest {
*/
@Test
public void testAcquireLimit() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
final int count = 10;
- CountDownLatch latch = new CountDownLatch(count - 1);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT, 1);
- SemaphoreThread t = new SemaphoreThread(semaphore, latch, count,
+ final CountDownLatch latch = new CountDownLatch(count - 1);
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT, 1);
+ final SemaphoreThread t = new SemaphoreThread(semaphore, latch, count,
count - 1);
semaphore.setLimit(count - 1);
@@ -239,16 +239,16 @@ public class TimedSemaphoreTest {
*/
@Test
public void testAcquireMultipleThreads() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, 1);
semaphore.latch = new CountDownLatch(1);
final int count = 10;
- SemaphoreThread[] threads = new SemaphoreThread[count];
+ final SemaphoreThread[] threads = new SemaphoreThread[count];
for (int i = 0; i < count; i++) {
threads[i] = new SemaphoreThread(semaphore, null, 1, 0);
threads[i].start();
@@ -274,16 +274,16 @@ public class TimedSemaphoreTest {
*/
@Test
public void testAcquireNoLimit() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service,
PERIOD, UNIT, TimedSemaphore.NO_LIMIT);
final int count = 1000;
- CountDownLatch latch = new CountDownLatch(count);
- SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
+ final CountDownLatch latch = new CountDownLatch(count);
+ final SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
t.start();
latch.await();
EasyMock.verify(service, future);
@@ -294,7 +294,7 @@ public class TimedSemaphoreTest {
*/
@Test(expected = IllegalStateException.class)
public void testPassAfterShutdown() throws InterruptedException {
- TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
+ final TimedSemaphore semaphore = new TimedSemaphore(PERIOD, UNIT, LIMIT);
semaphore.shutdown();
semaphore.acquire();
}
@@ -308,11 +308,11 @@ public class TimedSemaphoreTest {
@Test
public void testAcquireMultiplePeriods() throws InterruptedException {
final int count = 1000;
- TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(
+ final TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(
PERIOD / 10, TimeUnit.MILLISECONDS, 1);
semaphore.setLimit(count / 4);
- CountDownLatch latch = new CountDownLatch(count);
- SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
+ final CountDownLatch latch = new CountDownLatch(count);
+ final SemaphoreThread t = new SemaphoreThread(semaphore, latch, count, count);
t.start();
latch.await();
semaphore.shutdown();
@@ -324,12 +324,12 @@ public class TimedSemaphoreTest {
*/
@Test
public void testGetAverageCallsPerPeriod() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
semaphore.acquire();
semaphore.endOfPeriod();
@@ -348,12 +348,12 @@ public class TimedSemaphoreTest {
*/
@Test
public void testGetAvailablePermits() throws InterruptedException {
- ScheduledExecutorService service = EasyMock
+ final ScheduledExecutorService service = EasyMock
.createMock(ScheduledExecutorService.class);
- ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
+ final ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class);
prepareStartTimer(service, future);
EasyMock.replay(service, future);
- TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
+ final TimedSemaphore semaphore = new TimedSemaphore(service, PERIOD, UNIT,
LIMIT);
for (int i = 0; i < LIMIT; i++) {
assertEquals("Wrong available count at " + i, LIMIT - i, semaphore
@@ -470,7 +470,7 @@ public class TimedSemaphoreTest {
latch.countDown();
}
}
- } catch (InterruptedException iex) {
+ } catch (final InterruptedException iex) {
Thread.currentThread().interrupt();
}
}
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java Tue Jan 22 07:09:45 2013
@@ -45,21 +45,21 @@ public class EventListenerSupportTest
@Test(expected=NullPointerException.class)
public void testAddNullListener()
{
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.addListener(null);
}
@Test(expected=NullPointerException.class)
public void testRemoveNullListener()
{
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.removeListener(null);
}
@Test
public void testEventDispatchOrder() throws PropertyVetoException
{
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
final List<VetoableChangeListener> calledListeners = new ArrayList<VetoableChangeListener>();
final VetoableChangeListener listener1 = createListener(calledListeners);
@@ -101,17 +101,17 @@ public class EventListenerSupportTest
public void testGetListeners() {
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
- VetoableChangeListener[] listeners = listenerSupport.getListeners();
+ final VetoableChangeListener[] listeners = listenerSupport.getListeners();
assertEquals(0, listeners.length);
assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType());
- VetoableChangeListener[] empty = listeners;
+ final VetoableChangeListener[] empty = listeners;
//for fun, show that the same empty instance is used
assertSame(empty, listenerSupport.getListeners());
- VetoableChangeListener listener1 = EasyMock.createNiceMock(VetoableChangeListener.class);
+ final VetoableChangeListener listener1 = EasyMock.createNiceMock(VetoableChangeListener.class);
listenerSupport.addListener(listener1);
assertEquals(1, listenerSupport.getListeners().length);
- VetoableChangeListener listener2 = EasyMock.createNiceMock(VetoableChangeListener.class);
+ final VetoableChangeListener listener2 = EasyMock.createNiceMock(VetoableChangeListener.class);
listenerSupport.addListener(listener2);
assertEquals(2, listenerSupport.getListeners().length);
listenerSupport.removeListener(listener1);
@@ -122,7 +122,7 @@ public class EventListenerSupportTest
@Test
public void testSerialization() throws IOException, ClassNotFoundException, PropertyVetoException {
- EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
+ final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.addListener(new VetoableChangeListener() {
@Override
@@ -132,25 +132,26 @@ public class EventListenerSupportTest
listenerSupport.addListener(EasyMock.createNiceMock(VetoableChangeListener.class));
//serialize:
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ final ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
objectOutputStream.writeObject(listenerSupport);
objectOutputStream.close();
//deserialize:
@SuppressWarnings("unchecked")
+ final
EventListenerSupport<VetoableChangeListener> deserializedListenerSupport = (EventListenerSupport<VetoableChangeListener>) new ObjectInputStream(
new ByteArrayInputStream(outputStream.toByteArray())).readObject();
//make sure we get a listener array back, of the correct component type, and that it contains only the serializable mock
- VetoableChangeListener[] listeners = deserializedListenerSupport.getListeners();
+ final VetoableChangeListener[] listeners = deserializedListenerSupport.getListeners();
assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType());
assertEquals(1, listeners.length);
//now verify that the mock still receives events; we can infer that the proxy was correctly reconstituted
- VetoableChangeListener listener = listeners[0];
- PropertyChangeEvent evt = new PropertyChangeEvent(new Date(), "Day", 7, 9);
+ final VetoableChangeListener listener = listeners[0];
+ final PropertyChangeEvent evt = new PropertyChangeEvent(new Date(), "Day", 7, 9);
listener.vetoableChange(evt);
EasyMock.replay(listener);
deserializedListenerSupport.fire().vetoableChange(evt);
@@ -165,6 +166,7 @@ public class EventListenerSupportTest
public void testSubclassInvocationHandling() throws PropertyVetoException {
@SuppressWarnings("serial")
+ final
EventListenerSupport<VetoableChangeListener> eventListenerSupport = new EventListenerSupport<VetoableChangeListener>(
VetoableChangeListener.class) {
@Override
@@ -184,11 +186,11 @@ public class EventListenerSupportTest
}
};
- VetoableChangeListener listener = EasyMock.createNiceMock(VetoableChangeListener.class);
+ final VetoableChangeListener listener = EasyMock.createNiceMock(VetoableChangeListener.class);
eventListenerSupport.addListener(listener);
- Object source = new Date();
- PropertyChangeEvent ignore = new PropertyChangeEvent(source, "Hour", 5, 6);
- PropertyChangeEvent respond = new PropertyChangeEvent(source, "Day", 6, 7);
+ final Object source = new Date();
+ final PropertyChangeEvent ignore = new PropertyChangeEvent(source, "Hour", 5, 6);
+ final PropertyChangeEvent respond = new PropertyChangeEvent(source, "Day", 6, 7);
listener.vetoableChange(respond);
EasyMock.replay(listener);
eventListenerSupport.fire().vetoableChange(ignore);
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java Tue Jan 22 07:09:45 2013
@@ -48,7 +48,7 @@ public class EventUtilsTest
@Test
public void testConstructor() {
assertNotNull(new EventUtils());
- Constructor<?>[] cons = EventUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = EventUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(EventUtils.class.getModifiers()));
@@ -59,8 +59,8 @@ public class EventUtilsTest
public void testAddEventListener()
{
final PropertyChangeSource src = new PropertyChangeSource();
- EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
- PropertyChangeListener listener = handler.createListener(PropertyChangeListener.class);
+ final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
+ final PropertyChangeListener listener = handler.createListener(PropertyChangeListener.class);
assertEquals(0, handler.getEventCount("propertyChange"));
EventUtils.addEventListener(src, PropertyChangeListener.class, listener);
assertEquals(0, handler.getEventCount("propertyChange"));
@@ -72,14 +72,14 @@ public class EventUtilsTest
public void testAddEventListenerWithNoAddMethod()
{
final PropertyChangeSource src = new PropertyChangeSource();
- EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
- ObjectChangeListener listener = handler.createListener(ObjectChangeListener.class);
+ final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
+ final ObjectChangeListener listener = handler.createListener(ObjectChangeListener.class);
try
{
EventUtils.addEventListener(src, ObjectChangeListener.class, listener);
fail("Should not be allowed to add a listener to an object that doesn't support it.");
}
- catch (IllegalArgumentException e)
+ catch (final IllegalArgumentException e)
{
assertEquals("Class " + src.getClass().getName() + " does not have a public add" + ObjectChangeListener.class.getSimpleName() + " method which takes a parameter of type " + ObjectChangeListener.class.getName() + ".", e.getMessage());
}
@@ -101,7 +101,7 @@ public class EventUtilsTest
});
fail("Add method should have thrown an exception, so method should fail.");
}
- catch (RuntimeException e)
+ catch (final RuntimeException e)
{
}
@@ -111,14 +111,14 @@ public class EventUtilsTest
public void testAddEventListenerWithPrivateAddMethod()
{
final PropertyChangeSource src = new PropertyChangeSource();
- EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
- VetoableChangeListener listener = handler.createListener(VetoableChangeListener.class);
+ final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
+ final VetoableChangeListener listener = handler.createListener(VetoableChangeListener.class);
try
{
EventUtils.addEventListener(src, VetoableChangeListener.class, listener);
fail("Should not be allowed to add a listener to an object that doesn't support it.");
}
- catch (IllegalArgumentException e)
+ catch (final IllegalArgumentException e)
{
assertEquals("Class " + src.getClass().getName() + " does not have a public add" + VetoableChangeListener.class.getSimpleName() + " method which takes a parameter of type " + VetoableChangeListener.class.getName() + ".", e.getMessage());
}
@@ -212,14 +212,14 @@ public class EventUtilsTest
public int getEventCount(final String eventName)
{
- Integer count = eventCounts.get(eventName);
+ final Integer count = eventCounts.get(eventName);
return count == null ? 0 : count.intValue();
}
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable
{
- Integer count = eventCounts.get(method.getName());
+ final Integer count = eventCounts.get(method.getName());
if (count == null)
{
eventCounts.put(method.getName(), Integer.valueOf(1));
@@ -258,7 +258,7 @@ public class EventUtilsTest
public void setProperty(final String property)
{
- String oldValue = this.property;
+ final String oldValue = this.property;
this.property = property;
listeners.fire().propertyChange(new PropertyChangeEvent(this, "property", oldValue, property));
}
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java Tue Jan 22 07:09:45 2013
@@ -59,7 +59,7 @@ public abstract class AbstractExceptionC
@Test
public void testAddContextValue() {
- String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
+ final String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
assertTrue(message.indexOf(TEST_MESSAGE) >= 0);
assertTrue(message.indexOf("test1") >= 0);
assertTrue(message.indexOf("test2") >= 0);
@@ -81,7 +81,7 @@ public abstract class AbstractExceptionC
assertEquals(5, exceptionContext.getContextLabels().size());
assertTrue(exceptionContext.getContextLabels().contains("test2"));
- String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
+ final String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
}
@@ -90,7 +90,7 @@ public abstract class AbstractExceptionC
exceptionContext.addContextValue("test2", "different value");
exceptionContext.setContextValue("test3", "3");
- String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
+ final String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
assertTrue(message.indexOf(TEST_MESSAGE) >= 0);
assertTrue(message.indexOf("test Poorly written obj") >= 0);
assertTrue(message.indexOf("Crap") >= 0);
@@ -114,7 +114,7 @@ public abstract class AbstractExceptionC
assertEquals(6, exceptionContext.getContextEntries().size());
assertEquals(6, exceptionContext.getContextLabels().size());
- String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
+ final String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
}
@@ -149,7 +149,7 @@ public abstract class AbstractExceptionC
exceptionContext.addContextValue("test2", "different value");
- Set<String> labels = exceptionContext.getContextLabels();
+ final Set<String> labels = exceptionContext.getContextLabels();
assertEquals(6, exceptionContext.getContextEntries().size());
assertEquals(5, labels.size());
assertTrue(labels.contains("test1"));
@@ -164,7 +164,7 @@ public abstract class AbstractExceptionC
exceptionContext.addContextValue("test2", "different value");
- List<Pair<String, Object>> entries = exceptionContext.getContextEntries();
+ final List<Pair<String, Object>> entries = exceptionContext.getContextEntries();
assertEquals(6, entries.size());
assertEquals("test1", entries.get(0).getKey());
assertEquals("test2", entries.get(1).getKey());
@@ -178,7 +178,7 @@ public abstract class AbstractExceptionC
public void testJavaSerialization() {
exceptionContext.setContextValue("test Poorly written obj", "serializable replacement");
- T clone = SerializationUtils.deserialize(SerializationUtils.serialize(exceptionContext));
+ final T clone = SerializationUtils.deserialize(SerializationUtils.serialize(exceptionContext));
assertEquals(exceptionContext.getFormattedExceptionMessage(null), clone.getFormattedExceptionMessage(null));
}
}
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java Tue Jan 22 07:09:45 2013
@@ -39,8 +39,8 @@ public class ContextedExceptionTest exte
@Test
public void testContextedException() {
exceptionContext = new ContextedException();
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(StringUtils.isEmpty(message));
}
@@ -50,15 +50,15 @@ public class ContextedExceptionTest exte
exceptionContext = new ContextedException(TEST_MESSAGE);
assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
}
@Test
public void testContextedExceptionThrowable() {
exceptionContext = new ContextedException(new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(message.indexOf(TEST_MESSAGE)>=0);
@@ -67,8 +67,8 @@ public class ContextedExceptionTest exte
@Test
public void testContextedExceptionStringThrowable() {
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -78,8 +78,8 @@ public class ContextedExceptionTest exte
@Test
public void testContextedExceptionStringThrowableContext() {
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -95,7 +95,7 @@ public class ContextedExceptionTest exte
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
- String message = exceptionContext.getMessage();
+ final String message = exceptionContext.getMessage();
assertTrue(message != null);
}
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java Tue Jan 22 07:09:45 2013
@@ -41,8 +41,8 @@ public class ContextedRuntimeExceptionTe
@Test
public void testContextedException() {
exceptionContext = new ContextedRuntimeException();
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(StringUtils.isEmpty(message));
}
@@ -52,15 +52,15 @@ public class ContextedRuntimeExceptionTe
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE);
assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
}
@Test
public void testContextedExceptionThrowable() {
exceptionContext = new ContextedRuntimeException(new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(message.indexOf(TEST_MESSAGE)>=0);
@@ -69,8 +69,8 @@ public class ContextedRuntimeExceptionTe
@Test
public void testContextedExceptionStringThrowable() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE));
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -80,8 +80,8 @@ public class ContextedRuntimeExceptionTe
@Test
public void testContextedExceptionStringThrowableContext() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext() {});
- String message = exceptionContext.getMessage();
- String trace = ExceptionUtils.getStackTrace(exceptionContext);
+ final String message = exceptionContext.getMessage();
+ final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
@@ -97,7 +97,7 @@ public class ContextedRuntimeExceptionTe
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
- String message = exceptionContext.getMessage();
+ final String message = exceptionContext.getMessage();
assertTrue(message != null);
}
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java Tue Jan 22 07:09:45 2013
@@ -64,8 +64,8 @@ public class ExceptionUtilsTest {
nested = new NestableException(withoutCause);
withCause = new ExceptionWithCause(nested);
jdkNoCause = new NullPointerException();
- ExceptionWithCause a = new ExceptionWithCause(null);
- ExceptionWithCause b = new ExceptionWithCause(a);
+ final ExceptionWithCause a = new ExceptionWithCause(null);
+ final ExceptionWithCause b = new ExceptionWithCause(a);
a.setCause(b);
cyclicCause = new ExceptionWithCause(a);
}
@@ -84,7 +84,7 @@ public class ExceptionUtilsTest {
private Throwable createExceptionWithoutCause() {
try {
throw new ExceptionWithoutCause();
- } catch (Throwable t) {
+ } catch (final Throwable t) {
return t;
}
}
@@ -93,10 +93,10 @@ public class ExceptionUtilsTest {
try {
try {
throw new ExceptionWithCause(createExceptionWithoutCause());
- } catch (Throwable t) {
+ } catch (final Throwable t) {
throw new ExceptionWithCause(t);
}
- } catch (Throwable t) {
+ } catch (final Throwable t) {
return t;
}
}
@@ -106,7 +106,7 @@ public class ExceptionUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new ExceptionUtils());
- Constructor<?>[] cons = ExceptionUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = ExceptionUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(ExceptionUtils.class.getModifiers()));
@@ -176,14 +176,14 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowables_Throwable_withoutCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(withoutCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(withoutCause);
assertEquals(1, throwables.length);
assertSame(withoutCause, throwables[0]);
}
@Test
public void testGetThrowables_Throwable_nested() {
- Throwable[] throwables = ExceptionUtils.getThrowables(nested);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(nested);
assertEquals(2, throwables.length);
assertSame(nested, throwables[0]);
assertSame(withoutCause, throwables[1]);
@@ -191,7 +191,7 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowables_Throwable_withCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(withCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(withCause);
assertEquals(3, throwables.length);
assertSame(withCause, throwables[0]);
assertSame(nested, throwables[1]);
@@ -200,14 +200,14 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowables_Throwable_jdkNoCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(jdkNoCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(jdkNoCause);
assertEquals(1, throwables.length);
assertSame(jdkNoCause, throwables[0]);
}
@Test
public void testGetThrowables_Throwable_recursiveCause() {
- Throwable[] throwables = ExceptionUtils.getThrowables(cyclicCause);
+ final Throwable[] throwables = ExceptionUtils.getThrowables(cyclicCause);
assertEquals(3, throwables.length);
assertSame(cyclicCause, throwables[0]);
assertSame(cyclicCause.getCause(), throwables[1]);
@@ -217,20 +217,20 @@ public class ExceptionUtilsTest {
//-----------------------------------------------------------------------
@Test
public void testGetThrowableList_Throwable_null() {
- List<?> throwables = ExceptionUtils.getThrowableList(null);
+ final List<?> throwables = ExceptionUtils.getThrowableList(null);
assertEquals(0, throwables.size());
}
@Test
public void testGetThrowableList_Throwable_withoutCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(withoutCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(withoutCause);
assertEquals(1, throwables.size());
assertSame(withoutCause, throwables.get(0));
}
@Test
public void testGetThrowableList_Throwable_nested() {
- List<?> throwables = ExceptionUtils.getThrowableList(nested);
+ final List<?> throwables = ExceptionUtils.getThrowableList(nested);
assertEquals(2, throwables.size());
assertSame(nested, throwables.get(0));
assertSame(withoutCause, throwables.get(1));
@@ -238,7 +238,7 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowableList_Throwable_withCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(withCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(withCause);
assertEquals(3, throwables.size());
assertSame(withCause, throwables.get(0));
assertSame(nested, throwables.get(1));
@@ -247,14 +247,14 @@ public class ExceptionUtilsTest {
@Test
public void testGetThrowableList_Throwable_jdkNoCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(jdkNoCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(jdkNoCause);
assertEquals(1, throwables.size());
assertSame(jdkNoCause, throwables.get(0));
}
@Test
public void testGetThrowableList_Throwable_recursiveCause() {
- List<?> throwables = ExceptionUtils.getThrowableList(cyclicCause);
+ final List<?> throwables = ExceptionUtils.getThrowableList(cyclicCause);
assertEquals(3, throwables.size());
assertSame(cyclicCause, throwables.get(0));
assertSame(cyclicCause.getCause(), throwables.get(1));
@@ -384,11 +384,11 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.printRootCauseStackTrace(withCause, (PrintStream) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
out = new ByteArrayOutputStream(1024);
- Throwable withCause = createExceptionWithCause();
+ final Throwable withCause = createExceptionWithCause();
ExceptionUtils.printRootCauseStackTrace(withCause, new PrintStream(out));
String stackTrace = out.toString();
assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) != -1);
@@ -410,11 +410,11 @@ public class ExceptionUtilsTest {
try {
ExceptionUtils.printRootCauseStackTrace(withCause, (PrintWriter) null);
fail();
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
writer = new StringWriter(1024);
- Throwable withCause = createExceptionWithCause();
+ final Throwable withCause = createExceptionWithCause();
ExceptionUtils.printRootCauseStackTrace(withCause, new PrintWriter(writer));
String stackTrace = writer.toString();
assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) != -1);
@@ -430,10 +430,10 @@ public class ExceptionUtilsTest {
public void testGetRootCauseStackTrace_Throwable() throws Exception {
assertEquals(0, ExceptionUtils.getRootCauseStackTrace(null).length);
- Throwable withCause = createExceptionWithCause();
+ final Throwable withCause = createExceptionWithCause();
String[] stackTrace = ExceptionUtils.getRootCauseStackTrace(withCause);
boolean match = false;
- for (String element : stackTrace) {
+ for (final String element : stackTrace) {
if (element.startsWith(ExceptionUtils.WRAPPED_MARKER)) {
match = true;
break;
@@ -443,7 +443,7 @@ public class ExceptionUtilsTest {
stackTrace = ExceptionUtils.getRootCauseStackTrace(withoutCause);
match = false;
- for (String element : stackTrace) {
+ for (final String element : stackTrace) {
if (element.startsWith(ExceptionUtils.WRAPPED_MARKER)) {
match = true;
break;
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/FractionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/FractionTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/FractionTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/FractionTest.java Tue Jan 22 07:09:45 2013
@@ -123,27 +123,27 @@ public class FractionTest {
try {
f = Fraction.getFraction(1, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(2, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-3, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// very large: can't represent as unsimplified fraction, although
try {
f = Fraction.getFraction(4, Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -172,17 +172,17 @@ public class FractionTest {
try {
f = Fraction.getFraction(1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// negative whole
f = Fraction.getFraction(-1, 6, 10);
@@ -192,43 +192,43 @@ public class FractionTest {
try {
f = Fraction.getFraction(-1, -6, 10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, 6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, -6, -10);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// zero denominator
try {
f = Fraction.getFraction(0, 1, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, 2, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, -3, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(Integer.MAX_VALUE, 1, 2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-Integer.MAX_VALUE, 1, 2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// very large
f = Fraction.getFraction(-1, 0, Integer.MAX_VALUE);
@@ -239,15 +239,15 @@ public class FractionTest {
// negative denominators not allowed in this constructor.
f = Fraction.getFraction(0, 4, Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(1, 1, Integer.MAX_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(-1, 2, Integer.MAX_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
public void testReducedFactory_int_int() {
@@ -289,17 +289,17 @@ public class FractionTest {
try {
f = Fraction.getReducedFraction(1, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getReducedFraction(2, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getReducedFraction(-3, 0);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// reduced
f = Fraction.getReducedFraction(0, 2);
@@ -332,7 +332,7 @@ public class FractionTest {
try {
f = Fraction.getReducedFraction(-7, Integer.MIN_VALUE);
fail("Expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// LANG-662
f = Fraction.getReducedFraction(Integer.MIN_VALUE, 2);
@@ -347,22 +347,22 @@ public class FractionTest {
try {
f = Fraction.getFraction(Double.NaN);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(Double.POSITIVE_INFINITY);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction(Double.NEGATIVE_INFINITY);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = Fraction.getFraction((double) Integer.MAX_VALUE + 1);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// zero
f = Fraction.getFraction(0.0d);
@@ -405,7 +405,7 @@ public class FractionTest {
for (int j = 1; j <= i; j++) { // numerator
try {
f = Fraction.getFraction((double) j / (double) i);
- } catch (ArithmeticException ex) {
+ } catch (final ArithmeticException ex) {
System.err.println(j + " " + i);
throw ex;
}
@@ -419,7 +419,7 @@ public class FractionTest {
for (int j = 1; j <= i; j++) { // numerator
try {
f = Fraction.getFraction((double) j / (double) i);
- } catch (ArithmeticException ex) {
+ } catch (final ArithmeticException ex) {
System.err.println(j + " " + i);
throw ex;
}
@@ -459,17 +459,17 @@ public class FractionTest {
try {
f = Fraction.getFraction("2.3R");
fail("Expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2147483648"); // too big
fail("Expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction(".");
fail("Expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
}
@Test
@@ -503,32 +503,32 @@ public class FractionTest {
try {
f = Fraction.getFraction("2 3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("a 3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2 b/4");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2 ");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction(" 3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction(" ");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
}
@Test
@@ -562,22 +562,22 @@ public class FractionTest {
try {
f = Fraction.getFraction("2/d");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2e/3");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("2/");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
try {
f = Fraction.getFraction("/");
fail("expecting NumberFormatException");
- } catch (NumberFormatException ex) {}
+ } catch (final NumberFormatException ex) {}
}
@Test
@@ -686,14 +686,14 @@ public class FractionTest {
try {
f = f.invert();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// large values
f = Fraction.getFraction(Integer.MIN_VALUE, 1);
try {
f = f.invert();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f = Fraction.getFraction(Integer.MAX_VALUE, 1);
f = f.invert();
@@ -725,7 +725,7 @@ public class FractionTest {
try {
f = f.negate();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -756,7 +756,7 @@ public class FractionTest {
try {
f = f.abs();
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -833,11 +833,11 @@ public class FractionTest {
try {
f = f.pow(-1);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f = f.pow(Integer.MIN_VALUE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// one to any power is still one.
f = Fraction.getFraction(1, 1);
@@ -856,20 +856,20 @@ public class FractionTest {
try {
f = f.pow(2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// Numerator growing too negative during the pow operation.
f = Fraction.getFraction(Integer.MIN_VALUE, 1);
try {
f = f.pow(3);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f = Fraction.getFraction(65536, 1);
try {
f = f.pow(2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -936,7 +936,7 @@ public class FractionTest {
try {
f.add(null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
// if this fraction is added naively, it will overflow.
// check that it doesn't.
@@ -961,7 +961,7 @@ public class FractionTest {
try {
f = f.add(Fraction.ONE); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// denominator should not be a multiple of 2 or 3 to trigger overflow
f1 = Fraction.getFraction(Integer.MIN_VALUE, 5);
@@ -969,26 +969,26 @@ public class FractionTest {
try {
f = f1.add(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(-Integer.MAX_VALUE, 1);
f = f.add(f);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(-Integer.MAX_VALUE, 1);
f = f.add(f);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f1 = Fraction.getFraction(3,327680);
f2 = Fraction.getFraction(2,59049);
try {
f = f1.add(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1047,7 +1047,7 @@ public class FractionTest {
try {
f.subtract(null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
// if this fraction is subtracted naively, it will overflow.
// check that it doesn't.
@@ -1074,7 +1074,7 @@ public class FractionTest {
f2 = Fraction.getFraction(1, Integer.MAX_VALUE - 1);
f = f1.subtract(f2);
fail("expecting ArithmeticException"); //should overflow
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// denominator should not be a multiple of 2 or 3 to trigger overflow
f1 = Fraction.getFraction(Integer.MIN_VALUE, 5);
@@ -1082,26 +1082,26 @@ public class FractionTest {
try {
f = f1.subtract(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(Integer.MIN_VALUE, 1);
f = f.subtract(Fraction.ONE);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f= Fraction.getFraction(Integer.MAX_VALUE, 1);
f = f.subtract(Fraction.ONE.negate());
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f1 = Fraction.getFraction(3,327680);
f2 = Fraction.getFraction(2,59049);
try {
f = f1.subtract(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1158,19 +1158,19 @@ public class FractionTest {
try {
f.multiplyBy(null);
fail("expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
f1 = Fraction.getFraction(1, Integer.MAX_VALUE);
f = f1.multiplyBy(f1); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f1 = Fraction.getFraction(1, -Integer.MAX_VALUE);
f = f1.multiplyBy(f1); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1190,7 +1190,7 @@ public class FractionTest {
try {
f = f1.divideBy(f2);
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
f1 = Fraction.getFraction(0, 5);
f2 = Fraction.getFraction(2, 7);
@@ -1217,18 +1217,18 @@ public class FractionTest {
try {
f.divideBy(null);
fail("IllegalArgumentException");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
f1 = Fraction.getFraction(1, Integer.MAX_VALUE);
f = f1.divideBy(f1.invert()); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
try {
f1 = Fraction.getFraction(1, -Integer.MAX_VALUE);
f = f1.divideBy(f1.invert()); // should overflow
fail("expecting ArithmeticException");
- } catch (ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
}
@Test
@@ -1256,7 +1256,7 @@ public class FractionTest {
@Test
public void testHashCode() {
- Fraction f1 = Fraction.getFraction(3, 5);
+ final Fraction f1 = Fraction.getFraction(3, 5);
Fraction f2 = Fraction.getFraction(3, 5);
assertTrue(f1.hashCode() == f2.hashCode());
@@ -1279,7 +1279,7 @@ public class FractionTest {
try {
f1.compareTo(null);
fail("expecting NullPointerException");
- } catch (NullPointerException ex) {}
+ } catch (final NullPointerException ex) {}
f2 = Fraction.getFraction(2, 5);
assertTrue(f1.compareTo(f2) > 0);
@@ -1308,7 +1308,7 @@ public class FractionTest {
Fraction f = null;
f = Fraction.getFraction(3, 5);
- String str = f.toString();
+ final String str = f.toString();
assertEquals("3/5", str);
assertSame(str, f.toString());
@@ -1336,7 +1336,7 @@ public class FractionTest {
Fraction f = null;
f = Fraction.getFraction(3, 5);
- String str = f.toProperString();
+ final String str = f.toProperString();
assertEquals("3/5", str);
assertSame(str, f.toProperString());
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java Tue Jan 22 07:09:45 2013
@@ -38,19 +38,19 @@ public class IEEE754rUtilsTest {
assertEquals(2.5f, IEEE754rUtils.max(1.2f, 2.5f, Float.NaN), 0.01);
assertTrue(Float.isNaN(IEEE754rUtils.max(Float.NaN, Float.NaN, Float.NaN)));
- double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertEquals(42.0, IEEE754rUtils.max(a), 0.01);
assertEquals(1.2, IEEE754rUtils.min(a), 0.01);
- double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertEquals(42.0, IEEE754rUtils.max(b), 0.01);
assertEquals(1.2, IEEE754rUtils.min(b), 0.01);
- float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertEquals(1.2f, IEEE754rUtils.min(aF), 0.01);
assertEquals(42.0f, IEEE754rUtils.max(aF), 0.01);
- float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertEquals(1.2f, IEEE754rUtils.min(bF), 0.01);
assertEquals(42.0f, IEEE754rUtils.max(bF), 0.01);
}
@@ -60,42 +60,42 @@ public class IEEE754rUtilsTest {
try {
IEEE754rUtils.min( (float[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.min(new float[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max( (float[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max(new float[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.min( (double[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.min(new double[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max( (double[]) null);
fail("IllegalArgumentException expected for null input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
try {
IEEE754rUtils.max(new double[0]);
fail("IllegalArgumentException expected for empty input");
- } catch(IllegalArgumentException iae) { /* expected */ }
+ } catch(final IllegalArgumentException iae) { /* expected */ }
}
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java Tue Jan 22 07:09:45 2013
@@ -42,7 +42,7 @@ public class NumberUtilsTest {
@Test
public void testConstructor() {
assertNotNull(new NumberUtils());
- Constructor<?>[] cons = NumberUtils.class.getDeclaredConstructors();
+ final Constructor<?>[] cons = NumberUtils.class.getDeclaredConstructors();
assertEquals(1, cons.length);
assertTrue(Modifier.isPublic(cons[0].getModifiers()));
assertTrue(Modifier.isPublic(NumberUtils.class.getModifiers()));
@@ -240,7 +240,7 @@ public class NumberUtilsTest {
try {
NumberUtils.createNumber("--1.1E-700F");
fail("Expected NumberFormatException");
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
// expected
}
}
@@ -287,9 +287,9 @@ public class NumberUtilsTest {
protected void testCreateFloatFailure(final String str) {
try {
- Float value = NumberUtils.createFloat(str);
+ final Float value = NumberUtils.createFloat(str);
fail("createFloat(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -307,9 +307,9 @@ public class NumberUtilsTest {
protected void testCreateDoubleFailure(final String str) {
try {
- Double value = NumberUtils.createDouble(str);
+ final Double value = NumberUtils.createDouble(str);
fail("createDouble(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -327,9 +327,9 @@ public class NumberUtilsTest {
protected void testCreateIntegerFailure(final String str) {
try {
- Integer value = NumberUtils.createInteger(str);
+ final Integer value = NumberUtils.createInteger(str);
fail("createInteger(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -347,9 +347,9 @@ public class NumberUtilsTest {
protected void testCreateLongFailure(final String str) {
try {
- Long value = NumberUtils.createLong(str);
+ final Long value = NumberUtils.createLong(str);
fail("createLong(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -379,9 +379,9 @@ public class NumberUtilsTest {
protected void testCreateBigIntegerFailure(final String str) {
try {
- BigInteger value = NumberUtils.createBigInteger(str);
+ final BigInteger value = NumberUtils.createBigInteger(str);
fail("createBigInteger(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -405,9 +405,9 @@ public class NumberUtilsTest {
protected void testCreateBigDecimalFailure(final String str) {
try {
- BigDecimal value = NumberUtils.createBigDecimal(str);
+ final BigDecimal value = NumberUtils.createBigDecimal(str);
fail("createBigDecimal(blank) failed: " + value);
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
// empty
}
}
@@ -720,12 +720,12 @@ public class NumberUtilsTest {
try {
NumberUtils.max(d);
fail("No exception was thrown for null input.");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
try {
NumberUtils.max(new double[0]);
fail("No exception was thrown for empty input.");
- } catch (IllegalArgumentException ex) {}
+ } catch (final IllegalArgumentException ex) {}
assertEquals(
"max(double[]) failed for array length 1",
@@ -801,9 +801,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumShort() {
- short low = 1234;
- short mid = 1234 + 1;
- short high = 1234 + 2;
+ final short low = 1234;
+ final short mid = 1234 + 1;
+ final short high = 1234 + 2;
assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(low, mid, high));
assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(mid, low, high));
assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(mid, high, low));
@@ -812,9 +812,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumByte() {
- byte low = 123;
- byte mid = 123 + 1;
- byte high = 123 + 2;
+ final byte low = 123;
+ final byte mid = 123 + 1;
+ final byte high = 123 + 2;
assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(low, mid, high));
assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(mid, low, high));
assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(mid, high, low));
@@ -823,9 +823,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumDouble() {
- double low = 12.3;
- double mid = 12.3 + 1;
- double high = 12.3 + 2;
+ final double low = 12.3;
+ final double mid = 12.3 + 1;
+ final double high = 12.3 + 2;
assertEquals(low, NumberUtils.min(low, mid, high), 0.0001);
assertEquals(low, NumberUtils.min(mid, low, high), 0.0001);
assertEquals(low, NumberUtils.min(mid, high, low), 0.0001);
@@ -835,9 +835,9 @@ public class NumberUtilsTest {
@Test
public void testMinimumFloat() {
- float low = 12.3f;
- float mid = 12.3f + 1;
- float high = 12.3f + 2;
+ final float low = 12.3f;
+ final float mid = 12.3f + 1;
+ final float high = 12.3f + 2;
assertEquals(low, NumberUtils.min(low, mid, high), 0.0001f);
assertEquals(low, NumberUtils.min(mid, low, high), 0.0001f);
assertEquals(low, NumberUtils.min(mid, high, low), 0.0001f);
@@ -865,9 +865,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumShort() {
- short low = 1234;
- short mid = 1234 + 1;
- short high = 1234 + 2;
+ final short low = 1234;
+ final short mid = 1234 + 1;
+ final short high = 1234 + 2;
assertEquals("maximum(short,short,short) 1 failed", high, NumberUtils.max(low, mid, high));
assertEquals("maximum(short,short,short) 1 failed", high, NumberUtils.max(mid, low, high));
assertEquals("maximum(short,short,short) 1 failed", high, NumberUtils.max(mid, high, low));
@@ -876,9 +876,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumByte() {
- byte low = 123;
- byte mid = 123 + 1;
- byte high = 123 + 2;
+ final byte low = 123;
+ final byte mid = 123 + 1;
+ final byte high = 123 + 2;
assertEquals("maximum(byte,byte,byte) 1 failed", high, NumberUtils.max(low, mid, high));
assertEquals("maximum(byte,byte,byte) 1 failed", high, NumberUtils.max(mid, low, high));
assertEquals("maximum(byte,byte,byte) 1 failed", high, NumberUtils.max(mid, high, low));
@@ -887,9 +887,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumDouble() {
- double low = 12.3;
- double mid = 12.3 + 1;
- double high = 12.3 + 2;
+ final double low = 12.3;
+ final double mid = 12.3 + 1;
+ final double high = 12.3 + 2;
assertEquals(high, NumberUtils.max(low, mid, high), 0.0001);
assertEquals(high, NumberUtils.max(mid, low, high), 0.0001);
assertEquals(high, NumberUtils.max(mid, high, low), 0.0001);
@@ -899,9 +899,9 @@ public class NumberUtilsTest {
@Test
public void testMaximumFloat() {
- float low = 12.3f;
- float mid = 12.3f + 1;
- float high = 12.3f + 2;
+ final float low = 12.3f;
+ final float mid = 12.3f + 1;
+ final float high = 12.3f + 2;
assertEquals(high, NumberUtils.max(low, mid, high), 0.0001f);
assertEquals(high, NumberUtils.max(mid, low, high), 0.0001f);
assertEquals(high, NumberUtils.max(mid, high, low), 0.0001f);
@@ -1256,12 +1256,12 @@ public class NumberUtilsTest {
private boolean checkCreateNumber(final String val) {
try {
- Object obj = NumberUtils.createNumber(val);
+ final Object obj = NumberUtils.createNumber(val);
if (obj == null) {
return false;
}
return true;
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return false;
}
}
@@ -1322,18 +1322,18 @@ public class NumberUtilsTest {
assertTrue(Float.isNaN(NumberUtils.min(1.2f, 2.5f, Float.NaN)));
assertTrue(Float.isNaN(NumberUtils.max(1.2f, 2.5f, Float.NaN)));
- double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] a = new double[] { 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertTrue(Double.isNaN(NumberUtils.max(a)));
assertTrue(Double.isNaN(NumberUtils.min(a)));
- double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
+ final double[] b = new double[] { Double.NaN, 1.2, Double.NaN, 3.7, 27.0, 42.0, Double.NaN };
assertTrue(Double.isNaN(NumberUtils.max(b)));
assertTrue(Double.isNaN(NumberUtils.min(b)));
- float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] aF = new float[] { 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertTrue(Float.isNaN(NumberUtils.max(aF)));
- float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
+ final float[] bF = new float[] { Float.NaN, 1.2f, Float.NaN, 3.7f, 27.0f, 42.0f, Float.NaN };
assertTrue(Float.isNaN(NumberUtils.max(bF)));
}
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java Tue Jan 22 07:09:45 2013
@@ -118,7 +118,7 @@ public class MutableByteTest {
@Test
public void testPrimitiveValues() {
- MutableByte mutNum = new MutableByte( (byte) 1 );
+ final MutableByte mutNum = new MutableByte( (byte) 1 );
assertEquals( 1.0F, mutNum.floatValue(), 0 );
assertEquals( 1.0, mutNum.doubleValue(), 0 );
@@ -136,7 +136,7 @@ public class MutableByteTest {
@Test
public void testIncrement() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -145,7 +145,7 @@ public class MutableByteTest {
@Test
public void testDecrement() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -154,7 +154,7 @@ public class MutableByteTest {
@Test
public void testAddValuePrimitive() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add((byte)1);
assertEquals((byte) 2, mutNum.byteValue());
@@ -162,7 +162,7 @@ public class MutableByteTest {
@Test
public void testAddValueObject() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add(Integer.valueOf(1));
assertEquals((byte) 2, mutNum.byteValue());
@@ -170,7 +170,7 @@ public class MutableByteTest {
@Test
public void testSubtractValuePrimitive() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract((byte) 1);
assertEquals((byte) 0, mutNum.byteValue());
@@ -178,7 +178,7 @@ public class MutableByteTest {
@Test
public void testSubtractValueObject() {
- MutableByte mutNum = new MutableByte((byte) 1);
+ final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract(Integer.valueOf(1));
assertEquals((byte) 0, mutNum.byteValue());
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java Tue Jan 22 07:09:45 2013
@@ -130,7 +130,7 @@ public class MutableDoubleTest {
@Test
public void testPrimitiveValues() {
- MutableDouble mutNum = new MutableDouble(1.7);
+ final MutableDouble mutNum = new MutableDouble(1.7);
assertEquals( 1.7F, mutNum.floatValue(), 0 );
assertEquals( 1.7, mutNum.doubleValue(), 0 );
@@ -148,7 +148,7 @@ public class MutableDoubleTest {
@Test
public void testIncrement() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.increment();
assertEquals(2, mutNum.intValue());
@@ -157,7 +157,7 @@ public class MutableDoubleTest {
@Test
public void testDecrement() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.decrement();
assertEquals(0, mutNum.intValue());
@@ -166,7 +166,7 @@ public class MutableDoubleTest {
@Test
public void testAddValuePrimitive() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.add(1.1d);
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
@@ -174,7 +174,7 @@ public class MutableDoubleTest {
@Test
public void testAddValueObject() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.add(Double.valueOf(1.1d));
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
@@ -182,7 +182,7 @@ public class MutableDoubleTest {
@Test
public void testSubtractValuePrimitive() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(0.9d);
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
@@ -190,7 +190,7 @@ public class MutableDoubleTest {
@Test
public void testSubtractValueObject() {
- MutableDouble mutNum = new MutableDouble(1);
+ final MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(Double.valueOf(0.9d));
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);