Skip to content

Commit

Permalink
SerializationUtilsTest identity assertions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mureinik authored and PascalSchumacher committed Apr 4, 2018
1 parent 9901bf9 commit aff0fae
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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;
Expand Down Expand Up @@ -197,12 +198,12 @@ public void testDeserializeStream() throws Exception {
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);
}

Expand Down Expand Up @@ -333,12 +334,12 @@ public void testDeserializeBytes() throws Exception {
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);
}

Expand Down Expand Up @@ -381,12 +382,12 @@ public void testClone() throws Exception {
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);
}

Expand Down

0 comments on commit aff0fae

Please sign in to comment.