mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-10 03:55:10 +00:00
LANG-1041: Fix MethodUtilsTest so it does not depend on JDK method ordering. This fixes #30 from github. Thanks to Alexandre Bartel.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1628922 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aa3f174986
commit
4477ae6952
6
pom.xml
6
pom.xml
@ -473,6 +473,12 @@
|
|||||||
<version>4.11</version>
|
<version>4.11</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hamcrest</groupId>
|
||||||
|
<artifactId>hamcrest-all</artifactId>
|
||||||
|
<version>1.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<release version="3.4" date="tba" description="tba">
|
<release version="3.4" date="tba" description="tba">
|
||||||
|
<action issue="LANG-1041" type="fix" dev="britter" due-to="Alexandre Bartel">Fix MethodUtilsTest so it does not depend on JDK method ordering</action>
|
||||||
<action issue="LANG-827" type="update" dev="djones">CompareToBuilder's doc doesn't specify precedence of fields it uses in performing comparisons</action>
|
<action issue="LANG-827" type="update" dev="djones">CompareToBuilder's doc doesn't specify precedence of fields it uses in performing comparisons</action>
|
||||||
<action issue="LANG-1000" type="fix" dev="djones">ParseException when trying to parse UTC dates with Z as zone designator using DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT</action>
|
<action issue="LANG-1000" type="fix" dev="djones">ParseException when trying to parse UTC dates with Z as zone designator using DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT</action>
|
||||||
<action issue="LANG-1035" type="fix" dev="djones">Javadoc for EqualsBuilder.reflectionEquals() is unclear</action>
|
<action issue="LANG-1035" type="fix" dev="djones">Javadoc for EqualsBuilder.reflectionEquals() is unclear</action>
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.commons.lang3.reflect;
|
package org.apache.commons.lang3.reflect;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.hasItemInArray;
|
||||||
|
import static org.hamcrest.Matchers.hasItems;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@ -23,6 +25,7 @@
|
|||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.Assert.assertNotSame;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
@ -432,11 +435,11 @@ public void testGetOverrideHierarchyExcludingInterfaces() {
|
|||||||
@Annotated
|
@Annotated
|
||||||
public void testGetMethodsWithAnnotation() throws NoSuchMethodException {
|
public void testGetMethodsWithAnnotation() throws NoSuchMethodException {
|
||||||
assertArrayEquals(new Method[0], MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class));
|
assertArrayEquals(new Method[0], MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class));
|
||||||
final Method[] annotatedMethods = new Method[]{
|
|
||||||
MethodUtilsTest.class.getMethod("testGetMethodsWithAnnotation"),
|
Method[] methodsWithAnnotation = MethodUtils.getMethodsWithAnnotation(MethodUtilsTest.class, Annotated.class);
|
||||||
MethodUtilsTest.class.getMethod("testGetMethodsListWithAnnotation")
|
assertEquals(2, methodsWithAnnotation.length);
|
||||||
};
|
assertThat(methodsWithAnnotation, hasItemInArray(MethodUtilsTest.class.getMethod("testGetMethodsWithAnnotation")));
|
||||||
assertArrayEquals(annotatedMethods, MethodUtils.getMethodsWithAnnotation(MethodUtilsTest.class, Annotated.class));
|
assertThat(methodsWithAnnotation, hasItemInArray(MethodUtilsTest.class.getMethod("testGetMethodsListWithAnnotation")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@ -458,14 +461,13 @@ public void testGetMethodsWithAnnotationIllegalArgumentException3() {
|
|||||||
@Annotated
|
@Annotated
|
||||||
public void testGetMethodsListWithAnnotation() throws NoSuchMethodException {
|
public void testGetMethodsListWithAnnotation() throws NoSuchMethodException {
|
||||||
assertEquals(0, MethodUtils.getMethodsListWithAnnotation(Object.class, Annotated.class).size());
|
assertEquals(0, MethodUtils.getMethodsListWithAnnotation(Object.class, Annotated.class).size());
|
||||||
final List<Method> annotatedMethods = Arrays.asList(
|
|
||||||
|
final List<Method> methodWithAnnotation = MethodUtils.getMethodsListWithAnnotation(MethodUtilsTest.class, Annotated.class);
|
||||||
|
assertEquals(2, methodWithAnnotation.size());
|
||||||
|
assertThat(methodWithAnnotation, hasItems(
|
||||||
MethodUtilsTest.class.getMethod("testGetMethodsWithAnnotation"),
|
MethodUtilsTest.class.getMethod("testGetMethodsWithAnnotation"),
|
||||||
MethodUtilsTest.class.getMethod("testGetMethodsListWithAnnotation")
|
MethodUtilsTest.class.getMethod("testGetMethodsListWithAnnotation")
|
||||||
);
|
));
|
||||||
final List<Method> methodUtilsTestAnnotatedFields = MethodUtils.getMethodsListWithAnnotation(MethodUtilsTest.class, Annotated.class);
|
|
||||||
assertEquals(annotatedMethods.size(), methodUtilsTestAnnotatedFields.size());
|
|
||||||
assertTrue(methodUtilsTestAnnotatedFields.contains(annotatedMethods.get(0)));
|
|
||||||
assertTrue(methodUtilsTestAnnotatedFields.contains(annotatedMethods.get(1)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user