commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pascalschumac...@apache.org
Subject [2/3] [lang] SerializationUtilsTest identity assertions
Date Wed, 04 Apr 2018 07:32:52 GMT
SerializationUtilsTest identity assertions

Replaced calls to assertTrue with a != condition with calls to
assertNotSame calls.
This change retains the functionality, but will produce a more
detailed error message in case the assertion fails.
It also (arguably) makes the test code more straight-forward.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/aff0fae2
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/aff0fae2
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/aff0fae2

Branch: refs/heads/master
Commit: aff0fae2ec3a7d74356776c183c6986eb9eed520
Parents: 9901bf9
Author: Allon Mureinik <amureini@redhat.com>
Authored: Wed Apr 4 06:58:09 2018 +0300
Committer: pascalschumacher <pascalschumacher@gmx.net>
Committed: Wed Apr 4 09:32:22 2018 +0200

----------------------------------------------------------------------
 .../commons/lang3/SerializationUtilsTest.java    | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/aff0fae2/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
index cc2614f..cd20602 100644
--- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.lang3;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
@@ -197,12 +198,12 @@ public class SerializationUtilsTest {
         final Object test = SerializationUtils.deserialize(inTest);
         assertNotNull(test);
         assertTrue(test instanceof HashMap<?, ?>);
-        assertTrue(test != iMap);
+        assertNotSame(test, iMap);
         final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
         assertEquals(iString, testMap.get("FOO"));
-        assertTrue(iString != testMap.get("FOO"));
+        assertNotSame(iString, testMap.get("FOO"));
         assertEquals(iInteger, testMap.get("BAR"));
-        assertTrue(iInteger != testMap.get("BAR"));
+        assertNotSame(iInteger, testMap.get("BAR"));
         assertEquals(iMap, testMap);
     }
 
@@ -333,12 +334,12 @@ public class SerializationUtilsTest {
         final Object test = SerializationUtils.deserialize(streamReal.toByteArray());
         assertNotNull(test);
         assertTrue(test instanceof HashMap<?, ?>);
-        assertTrue(test != iMap);
+        assertNotSame(test, iMap);
         final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
         assertEquals(iString, testMap.get("FOO"));
-        assertTrue(iString != testMap.get("FOO"));
+        assertNotSame(iString, testMap.get("FOO"));
         assertEquals(iInteger, testMap.get("BAR"));
-        assertTrue(iInteger != testMap.get("BAR"));
+        assertNotSame(iInteger, testMap.get("BAR"));
         assertEquals(iMap, testMap);
     }
 
@@ -381,12 +382,12 @@ public class SerializationUtilsTest {
         final Object test = SerializationUtils.clone(iMap);
         assertNotNull(test);
         assertTrue(test instanceof HashMap<?,?>);
-        assertTrue(test != iMap);
+        assertNotSame(test, iMap);
         final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
         assertEquals(iString, testMap.get("FOO"));
-        assertTrue(iString != testMap.get("FOO"));
+        assertNotSame(iString, testMap.get("FOO"));
         assertEquals(iInteger, testMap.get("BAR"));
-        assertTrue(iInteger != testMap.get("BAR"));
+        assertNotSame(iInteger, testMap.get("BAR"));
         assertEquals(iMap, testMap);
     }
 


Mime
View raw message