Skip to content

Commit c1df51a

Browse files
committed
Polish ExtendedBeanInfoTests
Clean up ignored test, consolidate and document tests cornering covariant return type edge cases. Issue: SPR-8079, SPR-8806
1 parent edc80ff commit c1df51a

File tree

1 file changed

+5
-47
lines changed

1 file changed

+5
-47
lines changed

org.springframework.beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.beans;
1818

19-
import static java.lang.String.format;
2019
import static org.hamcrest.CoreMatchers.equalTo;
2120
import static org.hamcrest.CoreMatchers.instanceOf;
2221
import static org.hamcrest.CoreMatchers.is;
@@ -30,9 +29,7 @@
3029
import java.beans.IntrospectionException;
3130
import java.beans.Introspector;
3231
import java.beans.PropertyDescriptor;
33-
import java.lang.reflect.Method;
3432

35-
import org.junit.Ignore;
3633
import org.junit.Test;
3734
import org.springframework.beans.ExtendedBeanInfo.PropertyDescriptorComparator;
3835

@@ -664,51 +661,12 @@ private boolean hasIndexedReadMethodForProperty(BeanInfo beanInfo, String proper
664661
}
665662

666663
@Test
667-
public void reproSpr8806_y() throws IntrospectionException, SecurityException, NoSuchMethodException {
664+
public void reproSpr8806() throws IntrospectionException {
665+
// does not throw
668666
Introspector.getBeanInfo(LawLibrary.class);
669-
}
670-
671-
@Ignore @Test
672-
public void reproSpr8806_x() throws IntrospectionException, SecurityException, NoSuchMethodException {
673-
BeanInfo info = Introspector.getBeanInfo(LawLibrary.class);
674-
for (PropertyDescriptor d : info.getPropertyDescriptors()) {
675-
if (d.getName().equals("book")) {
676-
Method readMethod = d.getReadMethod();
677-
Method writeMethod = d.getWriteMethod();
678-
System.out.println(format("READ : %s.%s (bridge:%s)",
679-
readMethod.getDeclaringClass().getSimpleName(), readMethod.getName(), readMethod.isBridge()));
680-
System.out.println(format("WRITE: %s.%s (bridge:%s)",
681-
writeMethod.getDeclaringClass().getSimpleName(), writeMethod.getName(), writeMethod.isBridge()));
682-
new PropertyDescriptor("book", readMethod, writeMethod);
683-
}
684-
}
685-
686-
Method readMethod = LawLibrary.class.getMethod("getBook");
687-
Method writeMethod = LawLibrary.class.getMethod("setBook", Book.class);
688-
689-
System.out.println(format("read : %s.%s (bridge:%s)",
690-
readMethod.getDeclaringClass().getSimpleName(), readMethod.getName(), readMethod.isBridge()));
691-
System.out.println(format("write: %s.%s (bridge:%s)",
692-
writeMethod.getDeclaringClass().getSimpleName(), writeMethod.getName(), writeMethod.isBridge()));
693667

694-
695-
System.out.println("--------");
696-
for (Method m : LawLibrary.class.getMethods()) {
697-
if (m.getDeclaringClass() == Object.class) continue;
698-
System.out.println(format("%s %s.%s(%s) [bridge:%s]",
699-
m.getReturnType().getSimpleName(), m.getDeclaringClass().getSimpleName(),
700-
m.getName(),
701-
m.getParameterTypes().length == 1 ? m.getParameterTypes()[0].getSimpleName() : "",
702-
m.isBridge()));
703-
}
704-
705-
//new ExtendedBeanInfo(info);
706-
}
707-
708-
@Test
709-
public void reproSpr8806() throws IntrospectionException {
710-
BeanInfo bi = Introspector.getBeanInfo(LawLibrary.class);
711-
new ExtendedBeanInfo(bi); // throws
668+
// does not throw after the changes introduced in SPR-8806
669+
new ExtendedBeanInfo(Introspector.getBeanInfo(LawLibrary.class));
712670
}
713671

714672
interface Book { }

0 commit comments

Comments
 (0)