1
1
/*
2
- * Copyright 2002-2013 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
29
29
import java .util .TreeMap ;
30
30
import java .util .TreeSet ;
31
31
32
+ import org .junit .Before ;
32
33
import org .junit .Test ;
33
34
34
35
import org .springframework .beans .factory .BeanCreationException ;
52
53
*/
53
54
public class XmlBeanCollectionTests {
54
55
55
- private final DefaultListableBeanFactory beanFactory ;
56
+ private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory () ;
56
57
57
- public XmlBeanCollectionTests () {
58
- this .beanFactory = new DefaultListableBeanFactory ();
58
+
59
+ @ Before
60
+ public void loadBeans () {
59
61
new XmlBeanDefinitionReader (this .beanFactory ).loadBeanDefinitions (
60
62
new ClassPathResource ("collections.xml" , getClass ()));
61
63
}
62
64
65
+
63
66
@ Test
64
67
public void testCollectionFactoryDefaults () throws Exception {
65
68
ListFactoryBean listFactory = new ListFactoryBean ();
@@ -327,6 +330,15 @@ public void testObjectArray() throws Exception {
327
330
assertTrue (hasMap .getObjectArray ()[1 ].equals (this .beanFactory .getBean ("jenny" )));
328
331
}
329
332
333
+ @ Test
334
+ public void testIntegerArray () throws Exception {
335
+ HasMap hasMap = (HasMap ) this .beanFactory .getBean ("integerArray" );
336
+ assertTrue (hasMap .getIntegerArray ().length == 3 );
337
+ assertTrue (hasMap .getIntegerArray ()[0 ].intValue () == 0 );
338
+ assertTrue (hasMap .getIntegerArray ()[1 ].intValue () == 1 );
339
+ assertTrue (hasMap .getIntegerArray ()[2 ].intValue () == 2 );
340
+ }
341
+
330
342
@ Test
331
343
public void testClassArray () throws Exception {
332
344
HasMap hasMap = (HasMap ) this .beanFactory .getBean ("classArray" );
@@ -336,12 +348,11 @@ public void testClassArray() throws Exception {
336
348
}
337
349
338
350
@ Test
339
- public void testIntegerArray () throws Exception {
340
- HasMap hasMap = (HasMap ) this .beanFactory .getBean ("integerArray" );
341
- assertTrue (hasMap .getIntegerArray ().length == 3 );
342
- assertTrue (hasMap .getIntegerArray ()[0 ].intValue () == 0 );
343
- assertTrue (hasMap .getIntegerArray ()[1 ].intValue () == 1 );
344
- assertTrue (hasMap .getIntegerArray ()[2 ].intValue () == 2 );
351
+ public void testClassList () throws Exception {
352
+ HasMap hasMap = (HasMap ) this .beanFactory .getBean ("classList" );
353
+ assertTrue (hasMap .getClassList ().size ()== 2 );
354
+ assertTrue (hasMap .getClassList ().get (0 ).equals (String .class ));
355
+ assertTrue (hasMap .getClassList ().get (1 ).equals (Exception .class ));
345
356
}
346
357
347
358
@ Test
@@ -447,4 +458,5 @@ public Object getObject() {
447
458
return obj ;
448
459
}
449
460
}
461
+
450
462
}
0 commit comments