diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java index 09c793c58..c7634d80d 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java @@ -17,11 +17,12 @@ package org.apache.commons.lang3.mutable; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * JUnit tests. @@ -42,10 +43,10 @@ public void testCompareTo() { assertEquals(0, mutBool.compareTo(new MutableBoolean(true))); } - @Test(expected=NullPointerException.class) + @Test public void testCompareToNull() { final MutableBoolean mutBool = new MutableBoolean(false); - mutBool.compareTo(null); + assertThrows(NullPointerException.class, () -> mutBool.compareTo(null)); } // ---------------------------------------------------------------- @@ -61,9 +62,9 @@ public void testConstructors() { } - @Test(expected=NullPointerException.class) + @Test public void testConstructorNull() { - new MutableBoolean(null); + assertThrows(NullPointerException.class, () -> new MutableBoolean(null)); } @Test @@ -115,10 +116,10 @@ public void testGetSet() { } - @Test(expected=NullPointerException.class) + @Test public void testSetNull() { final MutableBoolean mutBool = new MutableBoolean(false); - mutBool.setValue(null); + assertThrows(NullPointerException.class, () -> mutBool.setValue(null)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java index 61dfd0d9c..91ad38cfa 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java @@ -16,11 +16,12 @@ */ package org.apache.commons.lang3.mutable; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * JUnit tests. @@ -43,9 +44,9 @@ public void testConstructors() { } - @Test(expected=NullPointerException.class) + @Test public void testConstructorNull() { - new MutableByte((Number)null); + assertThrows(NullPointerException.class, () -> new MutableByte((Number)null)); } @Test @@ -67,10 +68,10 @@ public void testGetSet() { assertEquals(Byte.valueOf((byte) 3), mutNum.getValue()); } - @Test(expected=NullPointerException.class) + @Test public void testSetNull() { final MutableByte mutNum = new MutableByte((byte) 0); - mutNum.setValue(null); + assertThrows(NullPointerException.class, () -> mutNum.setValue(null)); } @Test @@ -112,18 +113,21 @@ public void testCompareTo() { assertEquals((byte) -1, mutNum.compareTo(new MutableByte((byte) 1))); } - @Test(expected=NullPointerException.class) + @Test public void testCompareToNull() { final MutableByte mutNum = new MutableByte((byte) 0); - mutNum.compareTo(null); + assertThrows(NullPointerException.class, () -> mutNum.compareTo(null)); } @Test public void testPrimitiveValues() { final MutableByte mutNum = new MutableByte( (byte) 1 ); - assertEquals( 1.0F, mutNum.floatValue(), 0 ); - assertEquals( 1.0, mutNum.doubleValue(), 0 ); + // TODO: JUnit Jupiter 5.3.1 doesn't support delta=0. + // This should be replaced when it is supported in JUnit Jupiter 5.4. + // See https://github.com/junit-team/junit5/pull/1613 for details. + assertTrue( 1.0F == mutNum.floatValue() ); + assertTrue( 1.0 == mutNum.doubleValue() ); assertEquals( (byte) 1, mutNum.byteValue() ); assertEquals( (short) 1, mutNum.shortValue() ); assertEquals( 1, mutNum.intValue() ); diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java index df1b6d54c..378379a06 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java @@ -16,11 +16,12 @@ */ package org.apache.commons.lang3.mutable; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * JUnit tests. @@ -43,9 +44,9 @@ public void testConstructors() { } - @Test(expected=NullPointerException.class) + @Test public void testConstructorNull() { - new MutableDouble((Number)null); + assertThrows(NullPointerException.class, () -> new MutableDouble((Number)null)); } @Test @@ -67,10 +68,10 @@ public void testGetSet() { assertEquals(Double.valueOf(3d), mutNum.getValue()); } - @Test(expected=NullPointerException.class) + @Test public void testSetNull() { final MutableDouble mutNum = new MutableDouble(0d); - mutNum.setValue(null); + assertThrows(NullPointerException.class, () -> mutNum.setValue(null)); } @Test @@ -124,18 +125,21 @@ public void testCompareTo() { assertEquals(-1, mutNum.compareTo(new MutableDouble(1d))); } - @Test(expected=NullPointerException.class) + @Test public void testCompareToNull() { final MutableDouble mutNum = new MutableDouble(0d); - mutNum.compareTo(null); + assertThrows(NullPointerException.class, () -> mutNum.compareTo(null)); } @Test public void testPrimitiveValues() { final MutableDouble mutNum = new MutableDouble(1.7); - assertEquals( 1.7F, mutNum.floatValue(), 0 ); - assertEquals( 1.7, mutNum.doubleValue(), 0 ); + // TODO: JUnit Jupiter 5.3.1 doesn't support delta=0. + // This should be replaced when it is supported in JUnit Jupiter 5.4. + // See https://github.com/junit-team/junit5/pull/1613 for details. + assertTrue ( 1.7F == mutNum.floatValue() ); + assertTrue( 1.7 == mutNum.doubleValue() ); assertEquals( (byte) 1, mutNum.byteValue() ); assertEquals( (short) 1, mutNum.shortValue() ); assertEquals( 1, mutNum.intValue() ); diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java index 169763a50..96fbcdd65 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java @@ -16,11 +16,12 @@ */ package org.apache.commons.lang3.mutable; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * JUnit tests. @@ -43,9 +44,9 @@ public void testConstructors() { } - @Test(expected=NullPointerException.class) + @Test public void testConstructorNull() { - new MutableFloat((Number)null); + assertThrows(NullPointerException.class, () -> new MutableFloat((Number)null)); } @Test @@ -67,10 +68,10 @@ public void testGetSet() { assertEquals(Float.valueOf(3f), mutNum.getValue()); } - @Test(expected=NullPointerException.class) + @Test public void testSetNull() { final MutableFloat mutNum = new MutableFloat(0f); - mutNum.setValue(null); + assertThrows(NullPointerException.class, () -> mutNum.setValue(null)); } @Test @@ -124,10 +125,10 @@ public void testCompareTo() { assertEquals(-1, mutNum.compareTo(new MutableFloat(1f))); } - @Test(expected=NullPointerException.class) + @Test public void testCompareToNull() { final MutableFloat mutNum = new MutableFloat(0f); - mutNum.compareTo(null); + assertThrows(NullPointerException.class, () -> mutNum.compareTo(null)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java index 9cf711edf..f3100d3e8 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java @@ -16,11 +16,12 @@ */ package org.apache.commons.lang3.mutable; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * JUnit tests. @@ -43,9 +44,9 @@ public void testConstructors() { } - @Test(expected=NullPointerException.class) + @Test public void testConstructorNull() { - new MutableInt((Number)null); + assertThrows(NullPointerException.class, () -> new MutableInt((Number)null)); } @Test @@ -67,10 +68,10 @@ public void testGetSet() { assertEquals(Integer.valueOf(3), mutNum.getValue()); } - @Test(expected=NullPointerException.class) + @Test public void testSetNull() { final MutableInt mutNum = new MutableInt(0); - mutNum.setValue(null); + assertThrows(NullPointerException.class, () -> mutNum.setValue(null)); } @Test @@ -119,20 +120,23 @@ public void testCompareTo() { assertEquals(-1, mutNum.compareTo(new MutableInt(1))); } - @Test(expected=NullPointerException.class) + @Test public void testCompareToNull() { final MutableInt mutNum = new MutableInt(0); - mutNum.compareTo(null); + assertThrows(NullPointerException.class, () -> mutNum.compareTo(null)); } @Test public void testPrimitiveValues() { final MutableInt mutNum = new MutableInt(1); + // TODO: JUnit Jupiter 5.3.1 doesn't support delta=0. + // This should be replaced when it is supported in JUnit Jupiter 5.4. + // See https://github.com/junit-team/junit5/pull/1613 for details. assertEquals( (byte) 1, mutNum.byteValue() ); assertEquals( (short) 1, mutNum.shortValue() ); - assertEquals( 1.0F, mutNum.floatValue(), 0 ); - assertEquals( 1.0, mutNum.doubleValue(), 0 ); + assertTrue( 1.0F == mutNum.floatValue() ); + assertTrue( 1.0 == mutNum.doubleValue() ); assertEquals( 1L, mutNum.longValue() ); } diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java index 1ec522e5c..2ad7ea9ad 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java @@ -16,11 +16,12 @@ */ package org.apache.commons.lang3.mutable; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * JUnit tests. @@ -43,9 +44,9 @@ public void testConstructors() { } - @Test(expected=NullPointerException.class) + @Test public void testConstructorNull() { - new MutableLong((Number)null); + assertThrows(NullPointerException.class, () -> new MutableLong((Number)null)); } @Test @@ -67,10 +68,10 @@ public void testGetSet() { assertEquals(Long.valueOf(3), mutNum.getValue()); } - @Test(expected=NullPointerException.class) + @Test public void testSetNull() { final MutableLong mutNum = new MutableLong(0); - mutNum.setValue(null); + assertThrows(NullPointerException.class, () -> mutNum.setValue(null)); } @Test @@ -112,18 +113,21 @@ public void testCompareTo() { assertEquals(-1, mutNum.compareTo(new MutableLong(1))); } - @Test(expected=NullPointerException.class) + @Test public void testCompareToNull() { final MutableLong mutNum = new MutableLong(0); - mutNum.compareTo(null); + assertThrows(NullPointerException.class, () -> mutNum.compareTo(null)); } @Test public void testPrimitiveValues() { final MutableLong mutNum = new MutableLong(1L); - assertEquals( 1.0F, mutNum.floatValue(), 0 ); - assertEquals( 1.0, mutNum.doubleValue(), 0 ); + // TODO: JUnit Jupiter 5.3.1 doesn't support delta=0. + // This should be replaced when it is supported in JUnit Jupiter 5.4. + // See https://github.com/junit-team/junit5/pull/1613 for details. + assertTrue( 1.0F == mutNum.floatValue() ); + assertTrue ( 1.0 == mutNum.doubleValue() ); assertEquals( (byte) 1, mutNum.byteValue() ); assertEquals( (short) 1, mutNum.shortValue() ); assertEquals( 1, mutNum.intValue() ); diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java index 09e9b7d8c..cbef25406 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java @@ -16,13 +16,13 @@ */ package org.apache.commons.lang3.mutable; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java index fe926fff6..85373c5a6 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java @@ -16,12 +16,12 @@ */ package org.apache.commons.lang3.mutable; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * JUnit tests. @@ -118,8 +118,11 @@ public void testCompareTo() { public void testPrimitiveValues() { final MutableShort mutNum = new MutableShort( (short) 1 ); - assertEquals( 1.0F, mutNum.floatValue(), 0 ); - assertEquals( 1.0, mutNum.doubleValue(), 0 ); + // TODO: JUnit Jupiter 5.3.1 doesn't support delta=0. + // This should be replaced when it is supported in JUnit Jupiter 5.4. + // See https://github.com/junit-team/junit5/pull/1613 for details. + assertTrue ( 1.0F == mutNum.floatValue() ); + assertTrue ( 1.0 == mutNum.doubleValue() ); assertEquals( (byte) 1, mutNum.byteValue() ); assertEquals( (short) 1, mutNum.shortValue() ); assertEquals( 1, mutNum.intValue() );