From 4074ab454ea265d1e60938bcede3c3ce868a1d75 Mon Sep 17 00:00:00 2001 From: Michal Kordas Date: Sun, 16 Aug 2015 22:56:02 +0200 Subject: [PATCH] Use assertSame instead of assertEquals where possible. #1555 Fixes `AssertEqualsMayBeAssertSame` inspection violation in test code. Description: >Reports any calls to org.junit.Assert.assertEquals() or junit.framework.Assert.assertEquals() which can be replaced with an equivalent call to assertSame(). This is possible when the arguments are instances of a final class which does not override the equals() method. --- src/test/java/com/puppycrawl/tools/checkstyle/UtilsTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/UtilsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/UtilsTest.java index 1dd052f7e..c033fc7c0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/UtilsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/UtilsTest.java @@ -22,6 +22,7 @@ package com.puppycrawl.tools.checkstyle; import static com.puppycrawl.tools.checkstyle.TestUtils.assertUtilsClassHasPrivateConstructor; 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; @@ -144,7 +145,7 @@ public class UtilsTest { fail(); } catch (IllegalStateException expected) { - assertEquals(NoSuchMethodException.class, expected.getCause().getClass()); + assertSame(NoSuchMethodException.class, expected.getCause().getClass()); } } @@ -167,7 +168,7 @@ public class UtilsTest { fail(); } catch (IllegalStateException expected) { - assertEquals(InstantiationException.class, expected.getCause().getClass()); + assertSame(InstantiationException.class, expected.getCause().getClass()); } }