|
19 | 19 | import static org.hamcrest.CoreMatchers.equalTo;
|
20 | 20 | import static org.hamcrest.CoreMatchers.instanceOf;
|
21 | 21 | import static org.hamcrest.CoreMatchers.is;
|
22 |
| -import static org.hamcrest.CoreMatchers.notNullValue; |
23 |
| -import static org.hamcrest.CoreMatchers.nullValue; |
24 | 22 | import static org.hamcrest.Matchers.greaterThan;
|
25 | 23 | import static org.hamcrest.Matchers.lessThan;
|
26 | 24 | import static org.junit.Assert.assertThat;
|
|
32 | 30 | import java.beans.Introspector;
|
33 | 31 | import java.beans.PropertyDescriptor;
|
34 | 32 |
|
35 |
| -import org.junit.Ignore; |
36 | 33 | import org.junit.Test;
|
37 | 34 | import org.springframework.beans.ExtendedBeanInfo.PropertyDescriptorComparator;
|
38 | 35 |
|
@@ -485,6 +482,23 @@ public void setFoo(String foo) { }
|
485 | 482 | assertThat(hasWriteMethodForProperty(ebi, "foo"), is(true));
|
486 | 483 | }
|
487 | 484 |
|
| 485 | + /** |
| 486 | + * Ensures that an empty string is not passed into a PropertyDescriptor constructor. This |
| 487 | + * could occur when handling ArrayList.set(int,Object) |
| 488 | + */ |
| 489 | + @Test |
| 490 | + public void emptyPropertiesIgnored() throws IntrospectionException { |
| 491 | + @SuppressWarnings("unused") class C { |
| 492 | + public Object set(Object o) { return null; } |
| 493 | + public Object set(int i, Object o) { return null; } |
| 494 | + } |
| 495 | + |
| 496 | + BeanInfo bi = Introspector.getBeanInfo(C.class); |
| 497 | + ExtendedBeanInfo ebi = new ExtendedBeanInfo(bi); |
| 498 | + |
| 499 | + assertThat(ebi.getPropertyDescriptors(), equalTo(bi.getPropertyDescriptors())); |
| 500 | + } |
| 501 | + |
488 | 502 | @Test
|
489 | 503 | public void propertyCountsMatch() throws IntrospectionException {
|
490 | 504 | BeanInfo bi = Introspector.getBeanInfo(TestBean.class);
|
@@ -545,7 +559,6 @@ public void propertyDescriptorComparator() throws IntrospectionException {
|
545 | 559 | assertThat(c.compare(new PropertyDescriptor("a", null, null), new PropertyDescriptor("A", null, null)), greaterThan(0));
|
546 | 560 | }
|
547 | 561 |
|
548 |
| - |
549 | 562 | private boolean hasWriteMethodForProperty(BeanInfo beanInfo, String propertyName) {
|
550 | 563 | for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
|
551 | 564 | if (pd.getName().equals(propertyName)) {
|
|
0 commit comments