Skip to content

Commit 0e59fc4

Browse files
committed
smarter guessing of the element type (SPR-7283)
1 parent 96b1dc9 commit 0e59fc4

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2002-2010 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.context.support;
18+
19+
import java.util.List;
20+
21+
import static org.junit.Assert.*;
22+
import org.junit.Test;
23+
24+
/**
25+
* @author Scott Andrews
26+
* @author Juergen Hoeller
27+
*/
28+
public class Spr7283Tests {
29+
30+
@Test
31+
public void testListWithInconsistentElementType() {
32+
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spr7283.xml", getClass());
33+
List list = ctx.getBean("list", List.class);
34+
assertEquals(2, list.size());
35+
assertTrue(list.get(0) instanceof A);
36+
assertTrue(list.get(1) instanceof B);
37+
}
38+
39+
40+
public static class A {
41+
public A() {}
42+
}
43+
44+
public static class B {
45+
public B() {}
46+
}
47+
48+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:context="http://www.springframework.org/schema/context"
5+
xmlns:util="http://www.springframework.org/schema/util"
6+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7+
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
8+
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
9+
10+
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"/>
11+
12+
<util:list id="list">
13+
<bean class="org.springframework.context.support.Spr7283Tests$A"/>
14+
<bean class="org.springframework.context.support.Spr7283Tests$B"/>
15+
</util:list>
16+
17+
</beans>

0 commit comments

Comments
 (0)