1 package com.opensymphony.webwork.views.jsp.ui; 2 3 import com.opensymphony.webwork.TestAction; 4 import com.opensymphony.webwork.views.jsp.AbstractUITagTest; 5 6 import java.util.ArrayList ; 7 import java.util.Collection ; 8 import java.util.List ; 9 10 14 public class DoubleSelectTest extends AbstractUITagTest { 15 16 public void testDouble() throws Exception { 17 TestAction testAction = (TestAction) action; 18 19 Region antwerp = new Region("Antwerp", "AN"); 20 Region gent = new Region("Gent", "GN"); 21 Region brugge = new Region("Brugge", "BRG"); 22 ArrayList belgiumRegions = new ArrayList (); 23 belgiumRegions.add(antwerp); 24 belgiumRegions.add(gent); 25 belgiumRegions.add(brugge); 26 Country belgium = new Country("Belgium", "BE", belgiumRegions); 27 28 Region paris = new Region("Paris", "PA"); 29 Region bordeaux = new Region("Bordeaux", "BOR"); 30 ArrayList franceRegions = new ArrayList (); 31 franceRegions.add(paris); 32 franceRegions.add(bordeaux); 33 Country france = new Country("France", "FR", franceRegions); 34 35 Collection collection = new ArrayList (2); 36 collection.add("AN"); 37 testAction.setCollection(collection); 38 39 List countries = new ArrayList (); 40 countries.add(belgium); 41 countries.add(france); 42 43 testAction.setList2(countries); 44 45 DoubleSelectTag tag = new DoubleSelectTag(); 46 tag.setPageContext(pageContext); 47 tag.setLabel("mylabel"); 48 tag.setName("foo"); 49 tag.setDoubleName("region"); 50 51 tag.setList("list2"); 52 tag.setDoubleList("regions"); 53 54 tag.setListKey("iso"); 55 tag.setDoubleListKey("key"); 56 tag.setListValue("name"); 57 tag.setDoubleListValue("name"); 58 59 tag.setFormName("inputForm"); 60 61 tag.setOnmousedown("window.status='onmousedown';"); 62 tag.setOnmousemove("window.status='onmousemove';"); 63 tag.setOnmouseout("window.status='onmouseout';"); 64 tag.setOnmouseover("window.status='onmouseover';"); 65 tag.setOnmouseup("window.status='onmouseup';"); 66 67 tag.doStartTag(); 68 tag.doEndTag(); 69 70 verify(SelectTag.class.getResource("DoubleSelect-1.txt")); 71 } 72 73 public class Country { 74 String name; 75 String iso; 76 Collection regions; 77 78 public Country(String name, String iso, Collection regions) { 79 this.name = name; 80 this.iso = iso; 81 this.regions = regions; 82 } 83 84 public String getName() { 85 return name; 86 } 87 88 public String getIso() { 89 return iso; 90 } 91 92 public Collection getRegions() { 93 return regions; 94 } 95 } 96 97 public class Region { 98 String name; 99 String key; 100 101 public Region(String name, String key) { 102 this.name = name; 103 this.key = key; 104 } 105 106 public String getName() { 107 return name; 108 } 109 110 public String getKey() { 111 return key; 112 } 113 } 114 } 115 | Popular Tags |