You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2012/09/18 23:07:44 UTC
svn commit: r1387361 [3/5] - in /commons/proper/lang/trunk: ./
src/test/java/org/apache/commons/lang3/
src/test/java/org/apache/commons/lang3/concurrent/
src/test/java/org/apache/commons/lang3/event/
src/test/java/org/apache/commons/lang3/exception/ sr...
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ValidateTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ValidateTest.java?rev=1387361&r1=1387360&r2=1387361&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ValidateTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ValidateTest.java Tue Sep 18 21:07:42 2012
@@ -18,6 +18,11 @@
*/
package org.apache.commons.lang3;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.util.AbstractList;
@@ -28,20 +33,17 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Unit tests {@link org.apache.commons.lang3.Validate}.
*
* @version $Id$
*/
-public class ValidateTest extends TestCase {
-
- public ValidateTest(String name) {
- super(name);
- }
-
+public class ValidateTest {
+
//-----------------------------------------------------------------------
+ @Test
public void testIsTrue1() {
Validate.isTrue(true);
try {
@@ -53,6 +55,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testIsTrue2() {
Validate.isTrue(true, "MSG");
try {
@@ -64,6 +67,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testIsTrue3() {
Validate.isTrue(true, "MSG", 6);
try {
@@ -75,6 +79,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testIsTrue4() {
Validate.isTrue(true, "MSG", 7);
try {
@@ -86,6 +91,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testIsTrue5() {
Validate.isTrue(true, "MSG", 7.4d);
try {
@@ -98,6 +104,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testNotNull1() {
Validate.notNull(new Object());
try {
@@ -113,6 +120,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotNull2() {
Validate.notNull(new Object(), "MSG");
try {
@@ -129,6 +137,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testNotEmptyArray1() {
Validate.notEmpty(new Object[] {null});
try {
@@ -150,6 +159,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotEmptyArray2() {
Validate.notEmpty(new Object[] {null}, "MSG");
try {
@@ -172,6 +182,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testNotEmptyCollection1() {
Collection<Integer> coll = new ArrayList<Integer>();
try {
@@ -194,6 +205,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotEmptyCollection2() {
Collection<Integer> coll = new ArrayList<Integer>();
try {
@@ -217,6 +229,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testNotEmptyMap1() {
Map<String, Integer> map = new HashMap<String, Integer>();
try {
@@ -239,6 +252,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotEmptyMap2() {
Map<String, Integer> map = new HashMap<String, Integer>();
try {
@@ -262,6 +276,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testNotEmptyString1() {
Validate.notEmpty("hjl");
try {
@@ -283,6 +298,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotEmptyString2() {
Validate.notEmpty("a", "MSG");
try {
@@ -305,6 +321,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankNullStringShouldThrow() {
//given
String string = null;
@@ -320,6 +337,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankMsgNullStringShouldThrow() {
//given
String string = null;
@@ -335,6 +353,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankEmptyStringShouldThrow() {
//given
String string = "";
@@ -350,6 +369,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankBlankStringWithWhitespacesShouldThrow() {
//given
String string = " ";
@@ -365,6 +385,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankBlankStringWithNewlinesShouldThrow() {
//given
String string = " \n \t \r \n ";
@@ -380,6 +401,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankMsgBlankStringShouldThrow() {
//given
String string = " \n \t \r \n ";
@@ -395,6 +417,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankMsgBlankStringWithWhitespacesShouldThrow() {
//given
String string = " ";
@@ -410,6 +433,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankMsgEmptyStringShouldThrow() {
//given
String string = "";
@@ -425,6 +449,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankNotBlankStringShouldNotThrow() {
//given
String string = "abc";
@@ -436,6 +461,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankNotBlankStringWithWhitespacesShouldNotThrow() {
//given
String string = " abc ";
@@ -447,6 +473,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankNotBlankStringWithNewlinesShouldNotThrow() {
//given
String string = " \n \t abc \r \n ";
@@ -458,6 +485,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankMsgNotBlankStringShouldNotThrow() {
//given
String string = "abc";
@@ -469,6 +497,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankMsgNotBlankStringWithWhitespacesShouldNotThrow() {
//given
String string = " abc ";
@@ -480,6 +509,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankMsgNotBlankStringWithNewlinesShouldNotThrow() {
//given
String string = " \n \t abc \r \n ";
@@ -491,12 +521,14 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNotBlankReturnValues1() {
String str = "Hi";
String test = Validate.notBlank(str);
assertSame(str, test);
}
+ @Test
public void testNotBlankReturnValues2() {
String str = "Hi";
String test = Validate.notBlank(str, "Message");
@@ -505,6 +537,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testNoNullElementsArray1() {
String[] array = new String[] {"a", "b"};
Validate.noNullElements(array);
@@ -528,6 +561,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNoNullElementsArray2() {
String[] array = new String[] {"a", "b"};
Validate.noNullElements(array, "MSG");
@@ -552,6 +586,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testNoNullElementsCollection1() {
List<String> coll = new ArrayList<String>();
coll.add("a");
@@ -577,6 +612,7 @@ public class ValidateTest extends TestCa
}
//-----------------------------------------------------------------------
+ @Test
public void testNoNullElementsCollection2() {
List<String> coll = new ArrayList<String>();
coll.add("a");
@@ -603,6 +639,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testConstructor() {
assertNotNull(new Validate());
Constructor<?>[] cons = Validate.class.getDeclaredConstructors();
@@ -614,6 +651,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testValidIndex_withMessage_array() {
Object[] array = new Object[2];
Validate.validIndex(array, 0, "Broken: ");
@@ -636,6 +674,7 @@ public class ValidateTest extends TestCa
assertSame(strArray, test);
}
+ @Test
public void testValidIndex_array() {
Object[] array = new Object[2];
Validate.validIndex(array, 0);
@@ -660,6 +699,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testValidIndex_withMessage_collection() {
Collection<String> coll = new ArrayList<String>();
coll.add(null);
@@ -684,6 +724,7 @@ public class ValidateTest extends TestCa
assertSame(strColl, test);
}
+ @Test
public void testValidIndex_collection() {
Collection<String> coll = new ArrayList<String>();
coll.add(null);
@@ -710,6 +751,7 @@ public class ValidateTest extends TestCa
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
+ @Test
public void testValidIndex_withMessage_charSequence() {
CharSequence str = "Hi";
Validate.validIndex(str, 0, "Broken: ");
@@ -732,6 +774,7 @@ public class ValidateTest extends TestCa
assertSame(input, test);
}
+ @Test
public void testValidIndex_charSequence() {
CharSequence str = "Hi";
Validate.validIndex(str, 0);
@@ -754,6 +797,7 @@ public class ValidateTest extends TestCa
assertSame(input, test);
}
+ @Test
public void testMatchesPattern()
{
CharSequence str = "hi";
@@ -769,6 +813,7 @@ public class ValidateTest extends TestCa
}
}
+ @Test
public void testMatchesPattern_withMessage()
{
CharSequence str = "hi";
@@ -784,6 +829,7 @@ public class ValidateTest extends TestCa
}
}
+ @Test
public void testInclusiveBetween()
{
Validate.inclusiveBetween("a", "c", "b");
@@ -797,6 +843,7 @@ public class ValidateTest extends TestCa
}
}
+ @Test
public void testInclusiveBetween_withMessage()
{
Validate.inclusiveBetween("a", "c", "b", "Error");
@@ -810,6 +857,7 @@ public class ValidateTest extends TestCa
}
}
+ @Test
public void testExclusiveBetween()
{
Validate.exclusiveBetween("a", "c", "b");
@@ -828,6 +876,7 @@ public class ValidateTest extends TestCa
}
}
+ @Test
public void testExclusiveBetween_withMessage()
{
Validate.exclusiveBetween("a", "c", "b", "Error");
@@ -846,11 +895,13 @@ public class ValidateTest extends TestCa
}
}
+ @Test
public void testIsInstanceOf() {
Validate.isInstanceOf(String.class, "hi");
Validate.isInstanceOf(Integer.class, 1);
}
+ @Test
public void testIsInstanceOfExceptionMessage() {
try {
Validate.isInstanceOf(List.class, "hi");
@@ -860,6 +911,7 @@ public class ValidateTest extends TestCa
}
}
+ @Test
public void testIsInstanceOf_withMessage() {
Validate.isInstanceOf(String.class, "hi", "Error");
Validate.isInstanceOf(Integer.class, 1, "Error");
@@ -871,11 +923,13 @@ public class ValidateTest extends TestCa
}
}
+ @Test
public void testIsAssignable() {
Validate.isAssignableFrom(CharSequence.class, String.class);
Validate.isAssignableFrom(AbstractList.class, ArrayList.class);
}
+ @Test
public void testIsAssignableExceptionMessage() {
try {
Validate.isAssignableFrom(List.class, String.class);
@@ -885,6 +939,7 @@ public class ValidateTest extends TestCa
}
}
+ @Test
public void testIsAssignable_withMessage() {
Validate.isAssignableFrom(CharSequence.class, String.class, "Error");
Validate.isAssignableFrom(AbstractList.class, ArrayList.class, "Error");
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java?rev=1387361&r1=1387360&r2=1387361&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java Tue Sep 18 21:07:42 2012
@@ -16,15 +16,15 @@
*/
package org.apache.commons.lang3.concurrent;
+import org.junit.Test;
+import static org.junit.Assert.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-import junit.framework.TestCase;
-
-public class BackgroundInitializerTest extends TestCase {
+public class BackgroundInitializerTest {
/**
* Helper method for checking whether the initialize() method was correctly
* called. start() must already have been invoked.
@@ -45,6 +45,7 @@ public class BackgroundInitializerTest e
/**
* Tests whether initialize() is invoked.
*/
+ @Test
public void testInitialize() {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
@@ -55,6 +56,7 @@ public class BackgroundInitializerTest e
* Tries to obtain the executor before start(). It should not have been
* initialized yet.
*/
+ @Test
public void testGetActiveExecutorBeforeStart() {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertNull("Got an executor", init.getActiveExecutor());
@@ -63,6 +65,7 @@ public class BackgroundInitializerTest e
/**
* Tests whether an external executor is correctly detected.
*/
+ @Test
public void testGetActiveExecutorExternal() {
ExecutorService exec = Executors.newSingleThreadExecutor();
try {
@@ -79,6 +82,7 @@ public class BackgroundInitializerTest e
/**
* Tests getActiveExecutor() for a temporary executor.
*/
+ @Test
public void testGetActiveExecutorTemp() {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
@@ -90,6 +94,7 @@ public class BackgroundInitializerTest e
* Tests the execution of the background task if a temporary executor has to
* be created.
*/
+ @Test
public void testInitializeTempExecutor() {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertTrue("Wrong result of start()", init.start());
@@ -102,6 +107,7 @@ public class BackgroundInitializerTest e
* Tests whether an external executor can be set using the
* setExternalExecutor() method.
*/
+ @Test
public void testSetExternalExecutor() throws Exception {
ExecutorService exec = Executors.newCachedThreadPool();
try {
@@ -121,6 +127,7 @@ public class BackgroundInitializerTest e
/**
* Tests that setting an executor after start() causes an exception.
*/
+ @Test
public void testSetExternalExecutorAfterStart() throws ConcurrentException {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
@@ -136,6 +143,7 @@ public class BackgroundInitializerTest e
* Tests invoking start() multiple times. Only the first invocation should
* have an effect.
*/
+ @Test
public void testStartMultipleTimes() {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertTrue("Wrong result for start()", init.start());
@@ -148,6 +156,7 @@ public class BackgroundInitializerTest e
/**
* Tests calling get() before start(). This should cause an exception.
*/
+ @Test
public void testGetBeforeStart() throws ConcurrentException {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
try {
@@ -162,6 +171,7 @@ public class BackgroundInitializerTest e
* Tests the get() method if background processing causes a runtime
* exception.
*/
+ @Test
public void testGetRuntimeException() throws Exception {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
RuntimeException rex = new RuntimeException();
@@ -179,6 +189,7 @@ public class BackgroundInitializerTest e
* Tests the get() method if background processing causes a checked
* exception.
*/
+ @Test
public void testGetCheckedException() throws Exception {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
Exception ex = new Exception();
@@ -195,6 +206,7 @@ public class BackgroundInitializerTest e
/**
* Tests the get() method if waiting for the initialization is interrupted.
*/
+ @Test
public void testGetInterruptedException() throws Exception {
ExecutorService exec = Executors.newSingleThreadExecutor();
final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(
@@ -229,6 +241,7 @@ public class BackgroundInitializerTest e
/**
* Tests isStarted() before start() was called.
*/
+ @Test
public void testIsStartedFalse() {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
assertFalse("Already started", init.isStarted());
@@ -237,6 +250,7 @@ public class BackgroundInitializerTest e
/**
* Tests isStarted() after start().
*/
+ @Test
public void testIsStartedTrue() {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
@@ -246,6 +260,7 @@ public class BackgroundInitializerTest e
/**
* Tests isStarted() after the background task has finished.
*/
+ @Test
public void testIsStartedAfterGet() {
BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
init.start();
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java?rev=1387361&r1=1387360&r2=1387361&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java Tue Sep 18 21:07:42 2012
@@ -16,18 +16,21 @@
*/
package org.apache.commons.lang3.concurrent;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Test class for {@code CallableBackgroundInitializer}
*
* @version $Id$
*/
-public class CallableBackgroundInitializerTest extends TestCase {
+public class CallableBackgroundInitializerTest {
/** Constant for the result of the call() invocation. */
private static final Integer RESULT = Integer.valueOf(42);
@@ -35,6 +38,7 @@ public class CallableBackgroundInitializ
* Tries to create an instance without a Callable. This should cause an
* exception.
*/
+ @Test
public void testInitNullCallable() {
try {
new CallableBackgroundInitializer<Object>(null);
@@ -48,6 +52,7 @@ public class CallableBackgroundInitializ
* Tests whether the executor service is correctly passed to the super
* class.
*/
+ @Test
public void testInitExecutor() {
ExecutorService exec = Executors.newSingleThreadExecutor();
CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
@@ -59,6 +64,7 @@ public class CallableBackgroundInitializ
* Tries to pass a null Callable to the constructor that takes an executor.
* This should cause an exception.
*/
+ @Test
public void testInitExecutorNullCallable() {
ExecutorService exec = Executors.newSingleThreadExecutor();
try {
@@ -72,6 +78,7 @@ public class CallableBackgroundInitializ
/**
* Tests the implementation of initialize().
*/
+ @Test
public void testInitialize() throws Exception {
TestCallable call = new TestCallable();
CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
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=1387361&r1=1387360&r2=1387361&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 Sep 18 21:07:42 2012
@@ -17,6 +17,10 @@
package org.apache.commons.lang3.event;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
@@ -30,16 +34,16 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import junit.framework.TestCase;
-
import org.easymock.EasyMock;
+import org.junit.Test;
/**
* @since 3.0
* @version $Id$
*/
-public class EventListenerSupportTest extends TestCase
+public class EventListenerSupportTest
{
+ @Test
public void testAddNullListener()
{
EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
@@ -54,6 +58,7 @@ public class EventListenerSupportTest ex
}
}
+ @Test
public void testRemoveNullListener()
{
EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
@@ -68,6 +73,7 @@ public class EventListenerSupportTest ex
}
}
+ @Test
public void testEventDispatchOrder() throws PropertyVetoException
{
EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
@@ -83,6 +89,7 @@ public class EventListenerSupportTest ex
assertSame(calledListeners.get(1), listener2);
}
+ @Test
public void testCreateWithNonInterfaceParameter()
{
try
@@ -96,6 +103,7 @@ public class EventListenerSupportTest ex
}
}
+ @Test
public void testCreateWithNullParameter()
{
try
@@ -109,6 +117,7 @@ public class EventListenerSupportTest ex
}
}
+ @Test
public void testRemoveListenerDuringEvent() throws PropertyVetoException
{
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
@@ -121,6 +130,7 @@ public class EventListenerSupportTest ex
assertEquals(listenerSupport.getListenerCount(), 0);
}
+ @Test
public void testGetListeners() {
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
@@ -143,6 +153,7 @@ public class EventListenerSupportTest ex
assertSame(empty, listenerSupport.getListeners());
}
+ @Test
public void testSerialization() throws IOException, ClassNotFoundException, PropertyVetoException {
EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.addListener(new VetoableChangeListener() {
@@ -183,6 +194,7 @@ public class EventListenerSupportTest ex
assertEquals(0, deserializedListenerSupport.getListeners().length);
}
+ @Test
public void testSubclassInvocationHandling() throws PropertyVetoException {
@SuppressWarnings("serial")
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=1387361&r1=1387360&r2=1387361&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 Sep 18 21:07:42 2012
@@ -16,6 +16,10 @@
*/
package org.apache.commons.lang3.event;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.VetoableChangeListener;
@@ -30,15 +34,16 @@ import java.util.TreeMap;
import javax.naming.event.ObjectChangeListener;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* @since 3.0
* @version $Id$
*/
-public class EventUtilsTest extends TestCase
+public class EventUtilsTest
{
+ @Test
public void testConstructor() {
assertNotNull(new EventUtils());
Constructor<?>[] cons = EventUtils.class.getDeclaredConstructors();
@@ -48,6 +53,7 @@ public class EventUtilsTest extends Test
assertEquals(false, Modifier.isFinal(EventUtils.class.getModifiers()));
}
+ @Test
public void testAddEventListener()
{
final PropertyChangeSource src = new PropertyChangeSource();
@@ -60,6 +66,7 @@ public class EventUtilsTest extends Test
assertEquals(1, handler.getEventCount("propertyChange"));
}
+ @Test
public void testAddEventListenerWithNoAddMethod()
{
final PropertyChangeSource src = new PropertyChangeSource();
@@ -76,6 +83,7 @@ public class EventUtilsTest extends Test
}
}
+ @Test
public void testAddEventListenerThrowsException()
{
final ExceptionEventSource src = new ExceptionEventSource();
@@ -97,6 +105,7 @@ public class EventUtilsTest extends Test
}
}
+ @Test
public void testAddEventListenerWithPrivateAddMethod()
{
final PropertyChangeSource src = new PropertyChangeSource();
@@ -113,6 +122,7 @@ public class EventUtilsTest extends Test
}
}
+ @Test
public void testBindEventsToMethod()
{
final PropertyChangeSource src = new PropertyChangeSource();
@@ -124,6 +134,7 @@ public class EventUtilsTest extends Test
}
+ @Test
public void testBindEventsToMethodWithEvent()
{
final PropertyChangeSource src = new PropertyChangeSource();
@@ -135,6 +146,7 @@ public class EventUtilsTest extends Test
}
+ @Test
public void testBindFilteredEventsToMethod()
{
final MultipleEventSource src = new MultipleEventSource();
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=1387361&r1=1387360&r2=1387361&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 Sep 18 21:07:42 2012
@@ -16,6 +16,9 @@
*/
package org.apache.commons.lang3.exception;
+import org.junit.Test;
+import org.junit.Before;
+import static org.junit.Assert.*;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
@@ -23,8 +26,6 @@ import java.util.Date;
import java.util.List;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.apache.commons.lang3.SerializationUtils;
import org.apache.commons.lang3.tuple.Pair;
@@ -32,7 +33,7 @@ import org.apache.commons.lang3.tuple.Pa
/**
* Abstract test of an ExceptionContext implementation.
*/
-public abstract class AbstractExceptionContextTest<T extends ExceptionContext & Serializable> extends TestCase {
+public abstract class AbstractExceptionContextTest<T extends ExceptionContext & Serializable> {
protected static final String TEST_MESSAGE_2 = "This is monotonous";
protected static final String TEST_MESSAGE = "Test Message";
@@ -45,8 +46,9 @@ public abstract class AbstractExceptionC
}
}
- @Override
- protected void setUp() throws Exception {
+
+ @Before
+ public void setUp() throws Exception {
exceptionContext
.addContextValue("test1", null)
.addContextValue("test2", "some value")
@@ -55,6 +57,7 @@ public abstract class AbstractExceptionC
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
}
+ @Test
public void testAddContextValue() {
String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
assertTrue(message.indexOf(TEST_MESSAGE) >= 0);
@@ -82,6 +85,7 @@ public abstract class AbstractExceptionC
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
}
+ @Test
public void testSetContextValue() {
exceptionContext.addContextValue("test2", "different value");
exceptionContext.setContextValue("test3", "3");
@@ -114,6 +118,7 @@ public abstract class AbstractExceptionC
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
}
+ @Test
public void testGetFirstContextValue() {
exceptionContext.addContextValue("test2", "different value");
@@ -126,6 +131,7 @@ public abstract class AbstractExceptionC
assertTrue(exceptionContext.getFirstContextValue("test2").equals("another"));
}
+ @Test
public void testGetContextValues() {
exceptionContext.addContextValue("test2", "different value");
@@ -137,6 +143,7 @@ public abstract class AbstractExceptionC
assertTrue(exceptionContext.getFirstContextValue("test2").equals("another"));
}
+ @Test
public void testGetContextLabels() {
assertEquals(5, exceptionContext.getContextEntries().size());
@@ -151,6 +158,7 @@ public abstract class AbstractExceptionC
assertTrue(labels.contains("test Nbr"));
}
+ @Test
public void testGetContextEntries() {
assertEquals(5, exceptionContext.getContextEntries().size());
@@ -166,6 +174,7 @@ public abstract class AbstractExceptionC
assertEquals("test2", entries.get(5).getKey());
}
+ @Test
public void testJavaSerialization() {
exceptionContext.setContextValue("test Poorly written obj", "serializable replacement");
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=1387361&r1=1387360&r2=1387361&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 Sep 18 21:07:42 2012
@@ -16,9 +16,14 @@
*/
package org.apache.commons.lang3.exception;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
/**
* JUnit tests for ContextedException.
@@ -31,6 +36,7 @@ public class ContextedExceptionTest exte
super.setUp();
}
+ @Test
public void testContextedException() {
exceptionContext = new ContextedException();
String message = exceptionContext.getMessage();
@@ -39,6 +45,7 @@ public class ContextedExceptionTest exte
assertTrue(StringUtils.isEmpty(message));
}
+ @Test
public void testContextedExceptionString() {
exceptionContext = new ContextedException(TEST_MESSAGE);
assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
@@ -47,6 +54,7 @@ public class ContextedExceptionTest exte
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
}
+ @Test
public void testContextedExceptionThrowable() {
exceptionContext = new ContextedException(new Exception(TEST_MESSAGE));
String message = exceptionContext.getMessage();
@@ -56,6 +64,7 @@ public class ContextedExceptionTest exte
assertTrue(message.indexOf(TEST_MESSAGE)>=0);
}
+ @Test
public void testContextedExceptionStringThrowable() {
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE));
String message = exceptionContext.getMessage();
@@ -66,6 +75,7 @@ public class ContextedExceptionTest exte
assertTrue(message.indexOf(TEST_MESSAGE_2)>=0);
}
+ @Test
public void testContextedExceptionStringThrowableContext() {
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
String message = exceptionContext.getMessage();
@@ -76,6 +86,7 @@ public class ContextedExceptionTest exte
assertTrue(message.indexOf(TEST_MESSAGE_2)>=0);
}
+ @Test
public void testNullExceptionPassing() {
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), null)
.addContextValue("test1", null)
@@ -88,6 +99,7 @@ public class ContextedExceptionTest exte
assertTrue(message != null);
}
+ @Test
public void testRawMessage() {
assertEquals(Exception.class.getName() + ": " + TEST_MESSAGE, exceptionContext.getRawMessage());
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
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=1387361&r1=1387360&r2=1387361&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 Sep 18 21:07:42 2012
@@ -16,21 +16,28 @@
*/
package org.apache.commons.lang3.exception;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
+import org.junit.Before;
+import org.junit.Test;
/**
* JUnit tests for ContextedRuntimeException.
*/
public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<ContextedRuntimeException> {
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
exceptionContext = new ContextedRuntimeException(new Exception(TEST_MESSAGE));
super.setUp();
}
+ @Test
public void testContextedException() {
exceptionContext = new ContextedRuntimeException();
String message = exceptionContext.getMessage();
@@ -39,6 +46,7 @@ public class ContextedRuntimeExceptionTe
assertTrue(StringUtils.isEmpty(message));
}
+ @Test
public void testContextedExceptionString() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE);
assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
@@ -47,6 +55,7 @@ public class ContextedRuntimeExceptionTe
assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
}
+ @Test
public void testContextedExceptionThrowable() {
exceptionContext = new ContextedRuntimeException(new Exception(TEST_MESSAGE));
String message = exceptionContext.getMessage();
@@ -56,6 +65,7 @@ public class ContextedRuntimeExceptionTe
assertTrue(message.indexOf(TEST_MESSAGE)>=0);
}
+ @Test
public void testContextedExceptionStringThrowable() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE));
String message = exceptionContext.getMessage();
@@ -66,6 +76,7 @@ public class ContextedRuntimeExceptionTe
assertTrue(message.indexOf(TEST_MESSAGE_2)>=0);
}
+ @Test
public void testContextedExceptionStringThrowableContext() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext() {});
String message = exceptionContext.getMessage();
@@ -76,6 +87,7 @@ public class ContextedRuntimeExceptionTe
assertTrue(message.indexOf(TEST_MESSAGE_2)>=0);
}
+ @Test
public void testNullExceptionPassing() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), null)
.addContextValue("test1", null)
@@ -88,6 +100,7 @@ public class ContextedRuntimeExceptionTe
assertTrue(message != null);
}
+ @Test
public void testRawMessage() {
assertEquals(Exception.class.getName() + ": " + TEST_MESSAGE, exceptionContext.getRawMessage());
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java?rev=1387361&r1=1387360&r2=1387361&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java Tue Sep 18 21:07:42 2012
@@ -16,18 +16,22 @@
*/
package org.apache.commons.lang3.exception;
+import org.junit.Before;
+import org.junit.Test;
+
/**
* JUnit tests for DefaultExceptionContext.
*
*/
public class DefaultExceptionContextTest extends AbstractExceptionContextTest<DefaultExceptionContext> {
- @Override
+ @Before
public void setUp() throws Exception {
exceptionContext = new DefaultExceptionContext();
super.setUp();
}
+ @Test
public void testFormattedExceptionMessageNull() {
exceptionContext = new DefaultExceptionContext();
exceptionContext.getFormattedExceptionMessage(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=1387361&r1=1387360&r2=1387361&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 Sep 18 21:07:42 2012
@@ -16,6 +16,10 @@
*/
package org.apache.commons.lang3.exception;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.Before;
+import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -24,8 +28,6 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.util.List;
-import junit.framework.TestCase;
-
/**
* Tests {@link org.apache.commons.lang3.exception.ExceptionUtils}.
*
@@ -47,7 +49,7 @@ import junit.framework.TestCase;
*
* @since 1.0
*/
-public class ExceptionUtilsTest extends TestCase {
+public class ExceptionUtilsTest {
private NestableException nested;
private Throwable withCause;
@@ -55,11 +57,8 @@ public class ExceptionUtilsTest extends
private Throwable jdkNoCause;
private ExceptionWithCause cyclicCause;
- public ExceptionUtilsTest(String name) {
- super(name);
- }
- @Override
+ @Before
public void setUp() {
withoutCause = createExceptionWithoutCause();
nested = new NestableException(withoutCause);
@@ -71,8 +70,9 @@ public class ExceptionUtilsTest extends
cyclicCause = new ExceptionWithCause(a);
}
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
withoutCause = null;
nested = null;
withCause = null;
@@ -103,6 +103,7 @@ public class ExceptionUtilsTest extends
//-----------------------------------------------------------------------
+ @Test
public void testConstructor() {
assertNotNull(new ExceptionUtils());
Constructor<?>[] cons = ExceptionUtils.class.getDeclaredConstructors();
@@ -114,6 +115,7 @@ public class ExceptionUtilsTest extends
//-----------------------------------------------------------------------
@SuppressWarnings("deprecation") // Specifically tests the deprecated methods
+ @Test
public void testGetCause_Throwable() {
assertSame(null, ExceptionUtils.getCause(null));
assertSame(null, ExceptionUtils.getCause(withoutCause));
@@ -126,6 +128,7 @@ public class ExceptionUtilsTest extends
}
@SuppressWarnings("deprecation") // Specifically tests the deprecated methods
+ @Test
public void testGetCause_ThrowableArray() {
assertSame(null, ExceptionUtils.getCause(null, null));
assertSame(null, ExceptionUtils.getCause(null, new String[0]));
@@ -144,6 +147,7 @@ public class ExceptionUtilsTest extends
assertSame(null, ExceptionUtils.getCause(withoutCause, new String[] {"getTargetException"}));
}
+ @Test
public void testGetRootCause_Throwable() {
assertSame(null, ExceptionUtils.getRootCause(null));
assertSame(null, ExceptionUtils.getRootCause(withoutCause));
@@ -154,6 +158,7 @@ public class ExceptionUtilsTest extends
}
//-----------------------------------------------------------------------
+ @Test
public void testGetThrowableCount_Throwable() {
assertEquals(0, ExceptionUtils.getThrowableCount(null));
assertEquals(1, ExceptionUtils.getThrowableCount(withoutCause));
@@ -164,16 +169,19 @@ public class ExceptionUtilsTest extends
}
//-----------------------------------------------------------------------
+ @Test
public void testGetThrowables_Throwable_null() {
assertEquals(0, ExceptionUtils.getThrowables(null).length);
}
+ @Test
public void testGetThrowables_Throwable_withoutCause() {
Throwable[] throwables = ExceptionUtils.getThrowables(withoutCause);
assertEquals(1, throwables.length);
assertSame(withoutCause, throwables[0]);
}
+ @Test
public void testGetThrowables_Throwable_nested() {
Throwable[] throwables = ExceptionUtils.getThrowables(nested);
assertEquals(2, throwables.length);
@@ -181,6 +189,7 @@ public class ExceptionUtilsTest extends
assertSame(withoutCause, throwables[1]);
}
+ @Test
public void testGetThrowables_Throwable_withCause() {
Throwable[] throwables = ExceptionUtils.getThrowables(withCause);
assertEquals(3, throwables.length);
@@ -189,12 +198,14 @@ public class ExceptionUtilsTest extends
assertSame(withoutCause, throwables[2]);
}
+ @Test
public void testGetThrowables_Throwable_jdkNoCause() {
Throwable[] throwables = ExceptionUtils.getThrowables(jdkNoCause);
assertEquals(1, throwables.length);
assertSame(jdkNoCause, throwables[0]);
}
+ @Test
public void testGetThrowables_Throwable_recursiveCause() {
Throwable[] throwables = ExceptionUtils.getThrowables(cyclicCause);
assertEquals(3, throwables.length);
@@ -204,17 +215,20 @@ public class ExceptionUtilsTest extends
}
//-----------------------------------------------------------------------
+ @Test
public void testGetThrowableList_Throwable_null() {
List<?> throwables = ExceptionUtils.getThrowableList(null);
assertEquals(0, throwables.size());
}
+ @Test
public void testGetThrowableList_Throwable_withoutCause() {
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);
assertEquals(2, throwables.size());
@@ -222,6 +236,7 @@ public class ExceptionUtilsTest extends
assertSame(withoutCause, throwables.get(1));
}
+ @Test
public void testGetThrowableList_Throwable_withCause() {
List<?> throwables = ExceptionUtils.getThrowableList(withCause);
assertEquals(3, throwables.size());
@@ -230,12 +245,14 @@ public class ExceptionUtilsTest extends
assertSame(withoutCause, throwables.get(2));
}
+ @Test
public void testGetThrowableList_Throwable_jdkNoCause() {
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);
assertEquals(3, throwables.size());
@@ -245,6 +262,7 @@ public class ExceptionUtilsTest extends
}
//-----------------------------------------------------------------------
+ @Test
public void testIndexOf_ThrowableClass() {
assertEquals(-1, ExceptionUtils.indexOfThrowable(null, null));
assertEquals(-1, ExceptionUtils.indexOfThrowable(null, NestableException.class));
@@ -267,6 +285,7 @@ public class ExceptionUtilsTest extends
assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, Exception.class));
}
+ @Test
public void testIndexOf_ThrowableClassInt() {
assertEquals(-1, ExceptionUtils.indexOfThrowable(null, null, 0));
assertEquals(-1, ExceptionUtils.indexOfThrowable(null, NestableException.class, 0));
@@ -295,6 +314,7 @@ public class ExceptionUtilsTest extends
}
//-----------------------------------------------------------------------
+ @Test
public void testIndexOfType_ThrowableClass() {
assertEquals(-1, ExceptionUtils.indexOfType(null, null));
assertEquals(-1, ExceptionUtils.indexOfType(null, NestableException.class));
@@ -317,6 +337,7 @@ public class ExceptionUtilsTest extends
assertEquals(0, ExceptionUtils.indexOfType(withCause, Exception.class));
}
+ @Test
public void testIndexOfType_ThrowableClassInt() {
assertEquals(-1, ExceptionUtils.indexOfType(null, null, 0));
assertEquals(-1, ExceptionUtils.indexOfType(null, NestableException.class, 0));
@@ -345,12 +366,14 @@ public class ExceptionUtilsTest extends
}
//-----------------------------------------------------------------------
+ @Test
public void testPrintRootCauseStackTrace_Throwable() throws Exception {
ExceptionUtils.printRootCauseStackTrace(null);
// could pipe system.err to a known stream, but not much point as
// internally this method calls stram method anyway
}
+ @Test
public void testPrintRootCauseStackTrace_ThrowableStream() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
ExceptionUtils.printRootCauseStackTrace(null, (PrintStream) null);
@@ -376,6 +399,7 @@ public class ExceptionUtilsTest extends
assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) == -1);
}
+ @Test
public void testPrintRootCauseStackTrace_ThrowableWriter() throws Exception {
StringWriter writer = new StringWriter(1024);
ExceptionUtils.printRootCauseStackTrace(null, (PrintWriter) null);
@@ -402,6 +426,7 @@ public class ExceptionUtilsTest extends
}
//-----------------------------------------------------------------------
+ @Test
public void testGetRootCauseStackTrace_Throwable() throws Exception {
assertEquals(0, ExceptionUtils.getRootCauseStackTrace(null).length);
@@ -427,6 +452,7 @@ public class ExceptionUtilsTest extends
assertEquals(false, match);
}
+ @Test
public void testRemoveCommonFrames_ListList() throws Exception {
try {
ExceptionUtils.removeCommonFrames(null, null);
@@ -435,6 +461,7 @@ public class ExceptionUtilsTest extends
}
}
+ @Test
public void test_getMessage_Throwable() {
Throwable th = null;
assertEquals("", ExceptionUtils.getMessage(th));
@@ -446,6 +473,7 @@ public class ExceptionUtilsTest extends
assertEquals("ExceptionUtilsTest.ExceptionWithCause: Wrapper", ExceptionUtils.getMessage(th));
}
+ @Test
public void test_getRootCauseMessage_Throwable() {
Throwable th = null;
assertEquals("", ExceptionUtils.getRootCauseMessage(th));
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=1387361&r1=1387360&r2=1387361&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 Sep 18 21:07:42 2012
@@ -18,23 +18,25 @@
*/
package org.apache.commons.lang3.math;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
/**
* Test cases for the {@link Fraction} class
*
* @version $Id$
*/
-public class FractionTest extends TestCase {
+public class FractionTest {
private static final int SKIP = 500; //53
- public FractionTest(String name) {
- super(name);
- }
-
//--------------------------------------------------------------------------
-
+ @Test
public void testConstants() {
assertEquals(0, Fraction.ZERO.getNumerator());
assertEquals(1, Fraction.ZERO.getDenominator());
@@ -73,6 +75,7 @@ public class FractionTest extends TestCa
assertEquals(5, Fraction.FOUR_FIFTHS.getDenominator());
}
+ @Test
public void testFactory_int_int() {
Fraction f = null;
@@ -143,6 +146,7 @@ public class FractionTest extends TestCa
} catch (ArithmeticException ex) {}
}
+ @Test
public void testFactory_int_int_int() {
Fraction f = null;
@@ -245,6 +249,7 @@ public class FractionTest extends TestCa
fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}
+ @Test
public void testReducedFactory_int_int() {
Fraction f = null;
@@ -335,6 +340,7 @@ public class FractionTest extends TestCa
assertEquals(1, f.getDenominator());
}
+ @Test
public void testFactory_double() {
Fraction f = null;
@@ -424,6 +430,7 @@ public class FractionTest extends TestCa
}
}
+ @Test
public void testFactory_String() {
try {
Fraction.getFraction(null);
@@ -432,6 +439,7 @@ public class FractionTest extends TestCa
}
+ @Test
public void testFactory_String_double() {
Fraction f = null;
@@ -467,6 +475,7 @@ public class FractionTest extends TestCa
} catch (NumberFormatException ex) {}
}
+ @Test
public void testFactory_String_proper() {
Fraction f = null;
@@ -525,6 +534,7 @@ public class FractionTest extends TestCa
} catch (NumberFormatException ex) {}
}
+ @Test
public void testFactory_String_improper() {
Fraction f = null;
@@ -573,6 +583,7 @@ public class FractionTest extends TestCa
} catch (NumberFormatException ex) {}
}
+ @Test
public void testGets() {
Fraction f = null;
@@ -595,6 +606,7 @@ public class FractionTest extends TestCa
assertEquals(1, f.getDenominator());
}
+ @Test
public void testConversions() {
Fraction f = null;
@@ -605,6 +617,7 @@ public class FractionTest extends TestCa
assertEquals(3.875d, f.doubleValue(), 0.00001d);
}
+ @Test
public void testReduce() {
Fraction f = null;
@@ -653,6 +666,7 @@ public class FractionTest extends TestCa
assertEquals(1, result.getDenominator());
}
+ @Test
public void testInvert() {
Fraction f = null;
@@ -690,6 +704,7 @@ public class FractionTest extends TestCa
assertEquals(Integer.MAX_VALUE, f.getDenominator());
}
+ @Test
public void testNegate() {
Fraction f = null;
@@ -716,6 +731,7 @@ public class FractionTest extends TestCa
} catch (ArithmeticException ex) {}
}
+ @Test
public void testAbs() {
Fraction f = null;
@@ -746,6 +762,7 @@ public class FractionTest extends TestCa
} catch (ArithmeticException ex) {}
}
+ @Test
public void testPow() {
Fraction f = null;
@@ -858,6 +875,7 @@ public class FractionTest extends TestCa
} catch (ArithmeticException ex) {}
}
+ @Test
public void testAdd() {
Fraction f = null;
Fraction f1 = null;
@@ -976,6 +994,7 @@ public class FractionTest extends TestCa
} catch (ArithmeticException ex) {}
}
+ @Test
public void testSubtract() {
Fraction f = null;
Fraction f1 = null;
@@ -1088,6 +1107,7 @@ public class FractionTest extends TestCa
} catch (ArithmeticException ex) {}
}
+ @Test
public void testMultiply() {
Fraction f = null;
Fraction f1 = null;
@@ -1156,6 +1176,7 @@ public class FractionTest extends TestCa
} catch (ArithmeticException ex) {}
}
+ @Test
public void testDivide() {
Fraction f = null;
Fraction f1 = null;
@@ -1213,6 +1234,7 @@ public class FractionTest extends TestCa
} catch (ArithmeticException ex) {}
}
+ @Test
public void testEquals() {
Fraction f1 = null;
Fraction f2 = null;
@@ -1235,6 +1257,7 @@ public class FractionTest extends TestCa
assertEquals(false, f1.equals(f2));
}
+ @Test
public void testHashCode() {
Fraction f1 = Fraction.getFraction(3, 5);
Fraction f2 = Fraction.getFraction(3, 5);
@@ -1248,6 +1271,7 @@ public class FractionTest extends TestCa
assertTrue(f1.hashCode() != f2.hashCode());
}
+ @Test
public void testCompareTo() {
Fraction f1 = null;
Fraction f2 = null;
@@ -1282,6 +1306,7 @@ public class FractionTest extends TestCa
}
+ @Test
public void testToString() {
Fraction f = null;
@@ -1309,6 +1334,7 @@ public class FractionTest extends TestCa
assertEquals("-2147483648/2147483647", f.toString());
}
+ @Test
public void testToProperString() {
Fraction f = null;
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=1387361&r1=1387360&r2=1387361&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 Sep 18 21:07:42 2012
@@ -16,15 +16,20 @@
*/
package org.apache.commons.lang3.math;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
/**
* Unit tests {@link org.apache.commons.lang3.math.IEEE754rUtils}.
*
* @version $Id$
*/
-public class IEEE754rUtilsTest extends TestCase {
+public class IEEE754rUtilsTest {
+ @Test
public void testLang381() {
assertEquals(1.2, IEEE754rUtils.min(1.2, 2.5, Double.NaN), 0.01);
assertEquals(2.5, IEEE754rUtils.max(1.2, 2.5, Double.NaN), 0.01);
@@ -50,6 +55,7 @@ public class IEEE754rUtilsTest extends T
assertEquals(42.0f, IEEE754rUtils.max(bF), 0.01);
}
+ @Test
public void testEnforceExceptions() {
try {
IEEE754rUtils.min( (float[]) null);
@@ -93,6 +99,7 @@ public class IEEE754rUtilsTest extends T
}
+ @Test
public void testConstructorExists() {
new IEEE754rUtils();
}
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java?rev=1387361&r1=1387360&r2=1387361&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java Tue Sep 18 21:07:42 2012
@@ -17,7 +17,8 @@
package org.apache.commons.lang3.mutable;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* JUnit tests.
@@ -26,12 +27,9 @@ import junit.framework.TestCase;
* @see MutableBoolean
* @version $Id$
*/
-public class MutableBooleanTest extends TestCase {
-
- public MutableBooleanTest(String testName) {
- super(testName);
- }
+public class MutableBooleanTest {
+ @Test
public void testCompareTo() {
final MutableBoolean mutBool = new MutableBoolean(false);
@@ -49,6 +47,7 @@ public class MutableBooleanTest extends
}
// ----------------------------------------------------------------
+ @Test
public void testConstructors() {
assertEquals(false, new MutableBoolean().booleanValue());
@@ -65,6 +64,7 @@ public class MutableBooleanTest extends
}
}
+ @Test
public void testEquals() {
final MutableBoolean mutBoolA = new MutableBoolean(false);
final MutableBoolean mutBoolB = new MutableBoolean(false);
@@ -82,6 +82,7 @@ public class MutableBooleanTest extends
assertEquals(false, mutBoolA.equals("false"));
}
+ @Test
public void testGetSet() {
assertEquals(false, new MutableBoolean().booleanValue());
assertEquals(Boolean.FALSE, new MutableBoolean().getValue());
@@ -111,6 +112,7 @@ public class MutableBooleanTest extends
}
}
+ @Test
public void testHashCode() {
final MutableBoolean mutBoolA = new MutableBoolean(false);
final MutableBoolean mutBoolB = new MutableBoolean(false);
@@ -123,6 +125,7 @@ public class MutableBooleanTest extends
assertEquals(true, mutBoolC.hashCode() == Boolean.TRUE.hashCode());
}
+ @Test
public void testToString() {
assertEquals(Boolean.FALSE.toString(), new MutableBoolean(false).toString());
assertEquals(Boolean.TRUE.toString(), new MutableBoolean(true).toString());
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=1387361&r1=1387360&r2=1387361&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 Sep 18 21:07:42 2012
@@ -16,7 +16,8 @@
*/
package org.apache.commons.lang3.mutable;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* JUnit tests.
@@ -24,13 +25,10 @@ import junit.framework.TestCase;
* @version $Id$
* @see MutableByte
*/
-public class MutableByteTest extends TestCase {
-
- public MutableByteTest(String testName) {
- super(testName);
- }
+public class MutableByteTest {
// ----------------------------------------------------------------
+ @Test
public void testConstructors() {
assertEquals((byte) 0, new MutableByte().byteValue());
@@ -47,6 +45,7 @@ public class MutableByteTest extends Tes
} catch (NullPointerException ex) {}
}
+ @Test
public void testGetSet() {
final MutableByte mutNum = new MutableByte((byte) 0);
assertEquals((byte) 0, new MutableByte().byteValue());
@@ -69,6 +68,7 @@ public class MutableByteTest extends Tes
} catch (NullPointerException ex) {}
}
+ @Test
public void testEquals() {
final MutableByte mutNumA = new MutableByte((byte) 0);
final MutableByte mutNumB = new MutableByte((byte) 0);
@@ -86,6 +86,7 @@ public class MutableByteTest extends Tes
assertEquals(false, mutNumA.equals("0"));
}
+ @Test
public void testHashCode() {
final MutableByte mutNumA = new MutableByte((byte) 0);
final MutableByte mutNumB = new MutableByte((byte) 0);
@@ -97,6 +98,7 @@ public class MutableByteTest extends Tes
assertEquals(true, mutNumA.hashCode() == Byte.valueOf((byte) 0).hashCode());
}
+ @Test
public void testCompareTo() {
final MutableByte mutNum = new MutableByte((byte) 0);
@@ -109,6 +111,7 @@ public class MutableByteTest extends Tes
} catch (NullPointerException ex) {}
}
+ @Test
public void testPrimitiveValues() {
MutableByte mutNum = new MutableByte( (byte) 1 );
@@ -120,11 +123,13 @@ public class MutableByteTest extends Tes
assertEquals( 1L, mutNum.longValue() );
}
+ @Test
public void testToByte() {
assertEquals(Byte.valueOf((byte) 0), new MutableByte((byte) 0).toByte());
assertEquals(Byte.valueOf((byte) 123), new MutableByte((byte) 123).toByte());
}
+ @Test
public void testIncrement() {
MutableByte mutNum = new MutableByte((byte) 1);
mutNum.increment();
@@ -133,6 +138,7 @@ public class MutableByteTest extends Tes
assertEquals(2L, mutNum.longValue());
}
+ @Test
public void testDecrement() {
MutableByte mutNum = new MutableByte((byte) 1);
mutNum.decrement();
@@ -141,6 +147,7 @@ public class MutableByteTest extends Tes
assertEquals(0L, mutNum.longValue());
}
+ @Test
public void testAddValuePrimitive() {
MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add((byte)1);
@@ -148,6 +155,7 @@ public class MutableByteTest extends Tes
assertEquals((byte) 2, mutNum.byteValue());
}
+ @Test
public void testAddValueObject() {
MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add(Integer.valueOf(1));
@@ -155,6 +163,7 @@ public class MutableByteTest extends Tes
assertEquals((byte) 2, mutNum.byteValue());
}
+ @Test
public void testSubtractValuePrimitive() {
MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract((byte) 1);
@@ -162,6 +171,7 @@ public class MutableByteTest extends Tes
assertEquals((byte) 0, mutNum.byteValue());
}
+ @Test
public void testSubtractValueObject() {
MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract(Integer.valueOf(1));
@@ -169,6 +179,7 @@ public class MutableByteTest extends Tes
assertEquals((byte) 0, mutNum.byteValue());
}
+ @Test
public void testToString() {
assertEquals("0", new MutableByte((byte) 0).toString());
assertEquals("10", new MutableByte((byte) 10).toString());
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=1387361&r1=1387360&r2=1387361&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 Sep 18 21:07:42 2012
@@ -16,7 +16,8 @@
*/
package org.apache.commons.lang3.mutable;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* JUnit tests.
@@ -24,13 +25,10 @@ import junit.framework.TestCase;
* @version $Id$
* @see MutableDouble
*/
-public class MutableDoubleTest extends TestCase {
-
- public MutableDoubleTest(String testName) {
- super(testName);
- }
+public class MutableDoubleTest {
// ----------------------------------------------------------------
+ @Test
public void testConstructors() {
assertEquals(0d, new MutableDouble().doubleValue(), 0.0001d);
@@ -47,6 +45,7 @@ public class MutableDoubleTest extends T
} catch (NullPointerException ex) {}
}
+ @Test
public void testGetSet() {
final MutableDouble mutNum = new MutableDouble(0d);
assertEquals(0d, new MutableDouble().doubleValue(), 0.0001d);
@@ -69,6 +68,7 @@ public class MutableDoubleTest extends T
} catch (NullPointerException ex) {}
}
+ @Test
public void testNanInfinite() {
MutableDouble mutNum = new MutableDouble(Double.NaN);
assertEquals(true, mutNum.isNaN());
@@ -80,6 +80,7 @@ public class MutableDoubleTest extends T
assertEquals(true, mutNum.isInfinite());
}
+ @Test
public void testEquals() {
final MutableDouble mutNumA = new MutableDouble(0d);
final MutableDouble mutNumB = new MutableDouble(0d);
@@ -97,6 +98,7 @@ public class MutableDoubleTest extends T
assertEquals(false, mutNumA.equals("0"));
}
+ @Test
public void testHashCode() {
final MutableDouble mutNumA = new MutableDouble(0d);
final MutableDouble mutNumB = new MutableDouble(0d);
@@ -108,6 +110,7 @@ public class MutableDoubleTest extends T
assertEquals(true, mutNumA.hashCode() == Double.valueOf(0d).hashCode());
}
+ @Test
public void testCompareTo() {
final MutableDouble mutNum = new MutableDouble(0d);
@@ -120,6 +123,7 @@ public class MutableDoubleTest extends T
} catch (NullPointerException ex) {}
}
+ @Test
public void testPrimitiveValues() {
MutableDouble mutNum = new MutableDouble(1.7);
@@ -131,11 +135,13 @@ public class MutableDoubleTest extends T
assertEquals( 1L, mutNum.longValue() );
}
+ @Test
public void testToDouble() {
assertEquals(Double.valueOf(0d), new MutableDouble(0d).toDouble());
assertEquals(Double.valueOf(12.3d), new MutableDouble(12.3d).toDouble());
}
+ @Test
public void testIncrement() {
MutableDouble mutNum = new MutableDouble(1);
mutNum.increment();
@@ -144,6 +150,7 @@ public class MutableDoubleTest extends T
assertEquals(2L, mutNum.longValue());
}
+ @Test
public void testDecrement() {
MutableDouble mutNum = new MutableDouble(1);
mutNum.decrement();
@@ -152,6 +159,7 @@ public class MutableDoubleTest extends T
assertEquals(0L, mutNum.longValue());
}
+ @Test
public void testAddValuePrimitive() {
MutableDouble mutNum = new MutableDouble(1);
mutNum.add(1.1d);
@@ -159,6 +167,7 @@ public class MutableDoubleTest extends T
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
}
+ @Test
public void testAddValueObject() {
MutableDouble mutNum = new MutableDouble(1);
mutNum.add(Double.valueOf(1.1d));
@@ -166,6 +175,7 @@ public class MutableDoubleTest extends T
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
}
+ @Test
public void testSubtractValuePrimitive() {
MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(0.9d);
@@ -173,6 +183,7 @@ public class MutableDoubleTest extends T
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
}
+ @Test
public void testSubtractValueObject() {
MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(Double.valueOf(0.9d));
@@ -180,6 +191,7 @@ public class MutableDoubleTest extends T
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
}
+ @Test
public void testToString() {
assertEquals("0.0", new MutableDouble(0d).toString());
assertEquals("10.0", new MutableDouble(10d).toString());
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java?rev=1387361&r1=1387360&r2=1387361&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java Tue Sep 18 21:07:42 2012
@@ -16,7 +16,8 @@
*/
package org.apache.commons.lang3.mutable;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* JUnit tests.
@@ -24,13 +25,10 @@ import junit.framework.TestCase;
* @version $Id$
* @see MutableFloat
*/
-public class MutableFloatTest extends TestCase {
-
- public MutableFloatTest(String testName) {
- super(testName);
- }
+public class MutableFloatTest {
// ----------------------------------------------------------------
+ @Test
public void testConstructors() {
assertEquals(0f, new MutableFloat().floatValue(), 0.0001f);
@@ -47,6 +45,7 @@ public class MutableFloatTest extends Te
} catch (NullPointerException ex) {}
}
+ @Test
public void testGetSet() {
final MutableFloat mutNum = new MutableFloat(0f);
assertEquals(0f, new MutableFloat().floatValue(), 0.0001f);
@@ -69,6 +68,7 @@ public class MutableFloatTest extends Te
} catch (NullPointerException ex) {}
}
+ @Test
public void testNanInfinite() {
MutableFloat mutNum = new MutableFloat(Float.NaN);
assertEquals(true, mutNum.isNaN());
@@ -80,6 +80,7 @@ public class MutableFloatTest extends Te
assertEquals(true, mutNum.isInfinite());
}
+ @Test
public void testEquals() {
final MutableFloat mutNumA = new MutableFloat(0f);
final MutableFloat mutNumB = new MutableFloat(0f);
@@ -97,6 +98,7 @@ public class MutableFloatTest extends Te
assertEquals(false, mutNumA.equals("0"));
}
+ @Test
public void testHashCode() {
final MutableFloat mutNumA = new MutableFloat(0f);
final MutableFloat mutNumB = new MutableFloat(0f);
@@ -108,6 +110,7 @@ public class MutableFloatTest extends Te
assertEquals(true, mutNumA.hashCode() == Float.valueOf(0f).hashCode());
}
+ @Test
public void testCompareTo() {
final MutableFloat mutNum = new MutableFloat(0f);
@@ -120,6 +123,7 @@ public class MutableFloatTest extends Te
} catch (NullPointerException ex) {}
}
+ @Test
public void testPrimitiveValues() {
MutableFloat mutNum = new MutableFloat(1.7F);
@@ -131,11 +135,13 @@ public class MutableFloatTest extends Te
assertEquals( 1L, mutNum.longValue() );
}
+ @Test
public void testToFloat() {
assertEquals(Float.valueOf(0f), new MutableFloat(0f).toFloat());
assertEquals(Float.valueOf(12.3f), new MutableFloat(12.3f).toFloat());
}
+ @Test
public void testIncrement() {
MutableFloat mutNum = new MutableFloat(1);
mutNum.increment();
@@ -144,6 +150,7 @@ public class MutableFloatTest extends Te
assertEquals(2L, mutNum.longValue());
}
+ @Test
public void testDecrement() {
MutableFloat mutNum = new MutableFloat(1);
mutNum.decrement();
@@ -152,6 +159,7 @@ public class MutableFloatTest extends Te
assertEquals(0L, mutNum.longValue());
}
+ @Test
public void testAddValuePrimitive() {
MutableFloat mutNum = new MutableFloat(1);
mutNum.add(1.1f);
@@ -159,6 +167,7 @@ public class MutableFloatTest extends Te
assertEquals(2.1f, mutNum.floatValue(), 0.01f);
}
+ @Test
public void testAddValueObject() {
MutableFloat mutNum = new MutableFloat(1);
mutNum.add(Float.valueOf(1.1f));
@@ -166,6 +175,7 @@ public class MutableFloatTest extends Te
assertEquals(2.1f, mutNum.floatValue(), 0.01f);
}
+ @Test
public void testSubtractValuePrimitive() {
MutableFloat mutNum = new MutableFloat(1);
mutNum.subtract(0.9f);
@@ -173,6 +183,7 @@ public class MutableFloatTest extends Te
assertEquals(0.1f, mutNum.floatValue(), 0.01f);
}
+ @Test
public void testSubtractValueObject() {
MutableFloat mutNum = new MutableFloat(1);
mutNum.subtract(Float.valueOf(0.9f));
@@ -180,6 +191,7 @@ public class MutableFloatTest extends Te
assertEquals(0.1f, mutNum.floatValue(), 0.01f);
}
+ @Test
public void testToString() {
assertEquals("0.0", new MutableFloat(0f).toString());
assertEquals("10.0", new MutableFloat(10f).toString());
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java?rev=1387361&r1=1387360&r2=1387361&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java Tue Sep 18 21:07:42 2012
@@ -16,7 +16,8 @@
*/
package org.apache.commons.lang3.mutable;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* JUnit tests.
@@ -24,13 +25,10 @@ import junit.framework.TestCase;
* @version $Id$
* @see MutableInt
*/
-public class MutableIntTest extends TestCase {
-
- public MutableIntTest(String testName) {
- super(testName);
- }
+public class MutableIntTest {
// ----------------------------------------------------------------
+ @Test
public void testConstructors() {
assertEquals(0, new MutableInt().intValue());
@@ -47,6 +45,7 @@ public class MutableIntTest extends Test
} catch (NullPointerException ex) {}
}
+ @Test
public void testGetSet() {
final MutableInt mutNum = new MutableInt(0);
assertEquals(0, new MutableInt().intValue());
@@ -69,6 +68,7 @@ public class MutableIntTest extends Test
} catch (NullPointerException ex) {}
}
+ @Test
public void testEquals() {
this.testEquals(new MutableInt(0), new MutableInt(0), new MutableInt(1));
// Should Numbers be supported? GaryG July-21-2005.
@@ -93,6 +93,7 @@ public class MutableIntTest extends Test
assertEquals(false, numA.equals("0"));
}
+ @Test
public void testHashCode() {
final MutableInt mutNumA = new MutableInt(0);
final MutableInt mutNumB = new MutableInt(0);
@@ -104,6 +105,7 @@ public class MutableIntTest extends Test
assertEquals(true, mutNumA.hashCode() == Integer.valueOf(0).hashCode());
}
+ @Test
public void testCompareTo() {
final MutableInt mutNum = new MutableInt(0);
@@ -116,6 +118,7 @@ public class MutableIntTest extends Test
} catch (NullPointerException ex) {}
}
+ @Test
public void testPrimitiveValues() {
MutableInt mutNum = new MutableInt(1);
@@ -126,11 +129,13 @@ public class MutableIntTest extends Test
assertEquals( 1L, mutNum.longValue() );
}
+ @Test
public void testToInteger() {
assertEquals(Integer.valueOf(0), new MutableInt(0).toInteger());
assertEquals(Integer.valueOf(123), new MutableInt(123).toInteger());
}
+ @Test
public void testIncrement() {
MutableInt mutNum = new MutableInt(1);
mutNum.increment();
@@ -139,6 +144,7 @@ public class MutableIntTest extends Test
assertEquals(2L, mutNum.longValue());
}
+ @Test
public void testDecrement() {
MutableInt mutNum = new MutableInt(1);
mutNum.decrement();
@@ -147,6 +153,7 @@ public class MutableIntTest extends Test
assertEquals(0L, mutNum.longValue());
}
+ @Test
public void testAddValuePrimitive() {
MutableInt mutNum = new MutableInt(1);
mutNum.add(1);
@@ -155,6 +162,7 @@ public class MutableIntTest extends Test
assertEquals(2L, mutNum.longValue());
}
+ @Test
public void testAddValueObject() {
MutableInt mutNum = new MutableInt(1);
mutNum.add(Integer.valueOf(1));
@@ -163,6 +171,7 @@ public class MutableIntTest extends Test
assertEquals(2L, mutNum.longValue());
}
+ @Test
public void testSubtractValuePrimitive() {
MutableInt mutNum = new MutableInt(1);
mutNum.subtract(1);
@@ -171,6 +180,7 @@ public class MutableIntTest extends Test
assertEquals(0L, mutNum.longValue());
}
+ @Test
public void testSubtractValueObject() {
MutableInt mutNum = new MutableInt(1);
mutNum.subtract(Integer.valueOf(1));
@@ -179,6 +189,7 @@ public class MutableIntTest extends Test
assertEquals(0L, mutNum.longValue());
}
+ @Test
public void testToString() {
assertEquals("0", new MutableInt(0).toString());
assertEquals("10", new MutableInt(10).toString());
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java?rev=1387361&r1=1387360&r2=1387361&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java Tue Sep 18 21:07:42 2012
@@ -16,7 +16,8 @@
*/
package org.apache.commons.lang3.mutable;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* JUnit tests.
@@ -24,13 +25,10 @@ import junit.framework.TestCase;
* @version $Id$
* @see MutableLong
*/
-public class MutableLongTest extends TestCase {
-
- public MutableLongTest(String testName) {
- super(testName);
- }
+public class MutableLongTest {
// ----------------------------------------------------------------
+ @Test
public void testConstructors() {
assertEquals(0, new MutableLong().longValue());
@@ -47,6 +45,7 @@ public class MutableLongTest extends Tes
} catch (NullPointerException ex) {}
}
+ @Test
public void testGetSet() {
final MutableLong mutNum = new MutableLong(0);
assertEquals(0, new MutableLong().longValue());
@@ -69,6 +68,7 @@ public class MutableLongTest extends Tes
} catch (NullPointerException ex) {}
}
+ @Test
public void testEquals() {
final MutableLong mutNumA = new MutableLong(0);
final MutableLong mutNumB = new MutableLong(0);
@@ -86,6 +86,7 @@ public class MutableLongTest extends Tes
assertEquals(false, mutNumA.equals("0"));
}
+ @Test
public void testHashCode() {
final MutableLong mutNumA = new MutableLong(0);
final MutableLong mutNumB = new MutableLong(0);
@@ -97,6 +98,7 @@ public class MutableLongTest extends Tes
assertEquals(true, mutNumA.hashCode() == Long.valueOf(0).hashCode());
}
+ @Test
public void testCompareTo() {
final MutableLong mutNum = new MutableLong(0);
@@ -109,6 +111,7 @@ public class MutableLongTest extends Tes
} catch (NullPointerException ex) {}
}
+ @Test
public void testPrimitiveValues() {
MutableLong mutNum = new MutableLong(1L);
@@ -120,11 +123,13 @@ public class MutableLongTest extends Tes
assertEquals( 1L, mutNum.longValue() );
}
+ @Test
public void testToLong() {
assertEquals(Long.valueOf(0L), new MutableLong(0L).toLong());
assertEquals(Long.valueOf(123L), new MutableLong(123L).toLong());
}
+ @Test
public void testIncrement() {
MutableLong mutNum = new MutableLong(1);
mutNum.increment();
@@ -133,6 +138,7 @@ public class MutableLongTest extends Tes
assertEquals(2L, mutNum.longValue());
}
+ @Test
public void testDecrement() {
MutableLong mutNum = new MutableLong(1);
mutNum.decrement();
@@ -141,6 +147,7 @@ public class MutableLongTest extends Tes
assertEquals(0L, mutNum.longValue());
}
+ @Test
public void testAddValuePrimitive() {
MutableLong mutNum = new MutableLong(1);
mutNum.add(1);
@@ -149,6 +156,7 @@ public class MutableLongTest extends Tes
assertEquals(2L, mutNum.longValue());
}
+ @Test
public void testAddValueObject() {
MutableLong mutNum = new MutableLong(1);
mutNum.add(Long.valueOf(1));
@@ -157,6 +165,7 @@ public class MutableLongTest extends Tes
assertEquals(2L, mutNum.longValue());
}
+ @Test
public void testSubtractValuePrimitive() {
MutableLong mutNum = new MutableLong(1);
mutNum.subtract(1);
@@ -165,6 +174,7 @@ public class MutableLongTest extends Tes
assertEquals(0L, mutNum.longValue());
}
+ @Test
public void testSubtractValueObject() {
MutableLong mutNum = new MutableLong(1);
mutNum.subtract(Long.valueOf(1));
@@ -173,6 +183,7 @@ public class MutableLongTest extends Tes
assertEquals(0L, mutNum.longValue());
}
+ @Test
public void testToString() {
assertEquals("0", new MutableLong(0).toString());
assertEquals("10", new MutableLong(10).toString());