LANG-1349: EqualsBuilder#isRegistered: swappedPair construction bug

Add a test and a changes.xml entry.
This commit is contained in:
pascalschumacher 2017-09-08 18:18:45 +02:00
parent 3e08af573f
commit a2dce32cda
2 changed files with 16 additions and 1 deletions

View File

@ -47,7 +47,8 @@ The <action> type attribute can be add,update,fix,remove.
<release version="3.7" date="tba" description="tba"> <release version="3.7" date="tba" description="tba">
<action issue="LANG-1346" type="update" dev="pschumacher">Remove deprecation from RandomStringUtils</action> <action issue="LANG-1346" type="update" dev="pschumacher">Remove deprecation from RandomStringUtils</action>
<action issue="LANG-1350" type="update" dev="ggregory" due-to="Brett Kail">ConstructorUtils.invokeConstructor(Class, Object...) regression</action> <action issue="LANG-1350" type="fix" dev="ggregory" due-to="Brett Kail">ConstructorUtils.invokeConstructor(Class, Object...) regression</action>
<action issue="LANG-1349" type="fix" dev="pschumacher" due-to="Naman Nigam">EqualsBuilder#isRegistered: swappedPair construction bug</action>
</release> </release>
<release version="3.6" date="2017-06-08" description="New features and bug fixes. Requires Java 7."> <release version="3.6" date="2017-06-08" description="New features and bug fixes. Requires Java 7.">

View File

@ -21,8 +21,10 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.lang.reflect.Method;
import java.util.Arrays; import java.util.Arrays;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.junit.Test; import org.junit.Test;
/** /**
@ -1339,5 +1341,17 @@ public class EqualsBuilderTest {
assertFalse(new EqualsBuilder().reflectionAppend(null, o2).build()); assertFalse(new EqualsBuilder().reflectionAppend(null, o2).build());
} }
@Test
public void testIsRegistered() throws Exception {
Object firstObject = new Object();
Object secondObject = new Object();
Method registerMethod = MethodUtils.getMatchingMethod(EqualsBuilder.class, "register", Object.class, Object.class);
registerMethod.setAccessible(true);
registerMethod.invoke(null, firstObject, secondObject);
assertTrue(EqualsBuilder.isRegistered(firstObject, secondObject));
assertTrue(EqualsBuilder.isRegistered(secondObject, firstObject)); // LANG-1349
}
} }