@@ -194,8 +194,6 @@ public String getAsText() {
194
194
transformTag .setParent (this .tag );
195
195
transformTag .setPageContext (getPageContext ());
196
196
transformTag .doStartTag ();
197
- String output = getOutput ();
198
- System .err .println (output );
199
197
assertEquals ("Austria" , getPageContext ().findAttribute ("key" ));
200
198
}
201
199
@@ -255,7 +253,6 @@ public String getAsText() {
255
253
getPageContext ().getRequest ().setAttribute (BindingResult .MODEL_KEY_PREFIX + "testBean" , bindingResult );
256
254
this .tag .doStartTag ();
257
255
String output = getOutput ();
258
- System .err .println (output );
259
256
assertTrue (output .startsWith ("<select " ));
260
257
assertTrue (output .endsWith ("</select>" ));
261
258
assertFalse (output .contains ("selected=\" selected\" " ));
@@ -312,7 +309,6 @@ public String getAsText() {
312
309
getPageContext ().getRequest ().setAttribute (BindingResult .MODEL_KEY_PREFIX + "testBean" , bindingResult );
313
310
this .tag .doStartTag ();
314
311
String output = getOutput ();
315
- System .err .println (output );
316
312
assertTrue (output .startsWith ("<select " ));
317
313
assertTrue (output .endsWith ("</select>" ));
318
314
assertFalse (output .contains ("selected=\" selected\" " ));
@@ -335,8 +331,8 @@ public void testWithInvalidList() throws Exception {
335
331
}
336
332
catch (JspException expected ) {
337
333
String message = expected .getMessage ();
338
- assertTrue (message .indexOf ("items" ) > - 1 );
339
- assertTrue (message .indexOf ("org.springframework.tests.sample.beans.TestBean" ) > - 1 );
334
+ assertTrue (message .contains ("items" ));
335
+ assertTrue (message .contains ("org.springframework.tests.sample.beans.TestBean" ));
340
336
}
341
337
}
342
338
@@ -664,7 +660,6 @@ public void testWithMultiMap() throws Exception {
664
660
* </ul>
665
661
*/
666
662
public void testWithMultiMapWithItemValueAndItemLabel () throws Exception {
667
-
668
663
// Save original default locale.
669
664
final Locale defaultLocale = Locale .getDefault ();
670
665
// Use a locale that doesn't result in the generation of HTML entities
@@ -686,7 +681,6 @@ public void testWithMultiMapWithItemValueAndItemLabel() throws Exception {
686
681
687
682
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult (getTestBean (), COMMAND_NAME );
688
683
bindingResult .getPropertyAccessor ().registerCustomEditor (Country .class , new PropertyEditorSupport () {
689
-
690
684
@ Override
691
685
public void setAsText (final String text ) throws IllegalArgumentException {
692
686
setValue (Country .getCountryWithIsoCode (text ));
@@ -737,7 +731,7 @@ public String getAsText() {
737
731
}
738
732
}
739
733
740
- public void testMultiWithEmptyCollection () throws Exception {
734
+ public void testMultiForCollection () throws Exception {
741
735
this .bean .setSomeList (new ArrayList ());
742
736
743
737
this .tag .setPath ("someList" );
@@ -766,6 +760,34 @@ public void testMultiWithEmptyCollection() throws Exception {
766
760
assertNotNull (inputElement );
767
761
}
768
762
763
+ public void testMultiExplicit () throws Exception {
764
+ this .tag .setPath ("name" );
765
+ this .tag .setItems (Country .getCountries ());
766
+ this .tag .setItemValue ("isoCode" );
767
+ this .tag .setMultiple ("true" );
768
+ int result = this .tag .doStartTag ();
769
+ assertEquals (Tag .SKIP_BODY , result );
770
+
771
+ String output = getOutput ();
772
+ output = "<doc>" + output + "</doc>" ;
773
+
774
+ SAXReader reader = new SAXReader ();
775
+ Document document = reader .read (new StringReader (output ));
776
+ Element rootElement = document .getRootElement ();
777
+ assertEquals (2 , rootElement .elements ().size ());
778
+
779
+ Element selectElement = rootElement .element ("select" );
780
+ assertEquals ("select" , selectElement .getName ());
781
+ assertEquals ("name" , selectElement .attribute ("name" ).getValue ());
782
+ assertEquals ("multiple" , selectElement .attribute ("multiple" ).getValue ());
783
+
784
+ List children = selectElement .elements ();
785
+ assertEquals ("Incorrect number of children" , 4 , children .size ());
786
+
787
+ Element inputElement = rootElement .element ("input" );
788
+ assertNotNull (inputElement );
789
+ }
790
+
769
791
770
792
private void assertStringArray () throws JspException , DocumentException {
771
793
int result = this .tag .doStartTag ();
0 commit comments