001: /*
002: * $Id: OptionTransferSelectTagTest.java 558460 2007-07-22 04:16:29Z jholmes $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.views.jsp.ui;
022:
023: import java.util.ArrayList;
024: import java.util.List;
025:
026: import org.apache.struts2.TestAction;
027: import org.apache.struts2.views.jsp.AbstractUITagTest;
028:
029: /**
030: *
031: */
032: public class OptionTransferSelectTagTest extends AbstractUITagTest {
033:
034: public void testWithAllSelected() throws Exception {
035: List left = new ArrayList();
036: left.add("Left1");
037: left.add("Left2");
038:
039: List right = new ArrayList();
040: right.add("Right1");
041: right.add("Right2");
042:
043: TestAction testaction = (TestAction) action;
044: testaction.setCollection(left);
045: testaction.setList2(right);
046:
047: OptionTransferSelectTag tag = new OptionTransferSelectTag();
048: tag.setPageContext(pageContext);
049:
050: tag.setName("collection");
051: tag.setId("id");
052: tag.setList("collection");
053: tag.setSize("20");
054: tag.setMultiple("true");
055: tag.setEmptyOption("true");
056:
057: tag.setDoubleName("list2");
058: tag.setDoubleList("list2");
059: tag.setDoubleId("doubleId");
060: tag.setDoubleSize("20");
061: tag.setMultiple("true");
062: tag.setDoubleEmptyOption("true");
063: tag.setDoubleCssClass("c2");
064: tag.setDoubleCssStyle("s2");
065:
066: tag.setAllowAddAllToLeft("true");
067: tag.setAllowAddAllToRight("true");
068: tag.setAllowAddToLeft("true");
069: tag.setAllowAddToRight("true");
070: tag.setAllowSelectAll("true");
071:
072: tag.setAddAllToLeftLabel("All Left");
073: tag.setAddAllToRightLabel("All Right");
074: tag.setAddToLeftLabel("Left");
075: tag.setAddToRightLabel("Right");
076: tag.setSelectAllLabel("Select All");
077:
078: tag.setLeftTitle("Title Left");
079: tag.setRightTitle("Title Right");
080:
081: tag.setButtonCssClass("buttonCssClass");
082: tag.setButtonCssStyle("buttonCssStyle");
083:
084: tag.setHeaderKey("Header Key");
085: tag.setHeaderValue("Header Value");
086:
087: tag.setDoubleHeaderKey("Double Header Key");
088: tag.setDoubleHeaderValue("Double Header Value");
089:
090: tag.doStartTag();
091: tag.doEndTag();
092:
093: //System.out.println(writer.toString());
094: verify(OptionTransferSelectTagTest.class
095: .getResource("optiontransferselect-1.txt"));
096: }
097:
098: public void testWithPartialSelectedOnBothSides() throws Exception {
099: List left = new ArrayList();
100: left.add("Left2");
101:
102: List right = new ArrayList();
103: right.add("Right2");
104:
105: List leftVal = new ArrayList();
106: leftVal.add("Left1");
107: leftVal.add("Left2");
108: leftVal.add("Left3");
109:
110: List rightVal = new ArrayList();
111: rightVal.add("Right1");
112: rightVal.add("Right2");
113: rightVal.add("Right3");
114:
115: TestAction testaction = (TestAction) action;
116: testaction.setCollection(left);
117: testaction.setList2(right);
118: testaction.setCollection2(leftVal);
119: testaction.setList3(rightVal);
120:
121: OptionTransferSelectTag tag = new OptionTransferSelectTag();
122: tag.setPageContext(pageContext);
123:
124: tag.setName("collection");
125: tag.setId("id");
126: tag.setList("collection2");
127: tag.setSize("20");
128: tag.setMultiple("true");
129: tag.setEmptyOption("true");
130:
131: tag.setDoubleName("list2");
132: tag.setDoubleList("list3");
133: tag.setDoubleId("doubleId");
134: tag.setDoubleSize("20");
135: tag.setMultiple("true");
136: tag.setDoubleEmptyOption("true");
137:
138: tag.setAllowAddAllToLeft("true");
139: tag.setAllowAddAllToRight("true");
140: tag.setAllowAddToLeft("true");
141: tag.setAllowAddToRight("true");
142: tag.setAllowSelectAll("true");
143:
144: tag.setAddAllToLeftLabel("All Left");
145: tag.setAddAllToRightLabel("All Right");
146: tag.setAddToLeftLabel("Left");
147: tag.setAddToRightLabel("Right");
148: tag.setSelectAllLabel("Select All");
149:
150: tag.setLeftTitle("Title Left");
151: tag.setRightTitle("Title Right");
152:
153: tag.setButtonCssClass("buttonCssClass");
154: tag.setButtonCssStyle("buttonCssStyle");
155:
156: tag.setHeaderKey("Header Key");
157: tag.setHeaderValue("Header Value");
158:
159: tag.setDoubleHeaderKey("Double Header Key");
160: tag.setDoubleHeaderValue("Double Header Value");
161:
162: tag.doStartTag();
163: tag.doEndTag();
164:
165: //System.out.println(writer.toString());
166: verify(OptionTransferSelectTagTest.class
167: .getResource("optiontransferselect-2.txt"));
168: }
169:
170: public void testWithoutHeaderOnBothSides() throws Exception {
171: List left = new ArrayList();
172: left.add("Left2");
173:
174: List right = new ArrayList();
175: right.add("Right2");
176:
177: List leftVal = new ArrayList();
178: leftVal.add("Left1");
179: leftVal.add("Left2");
180: leftVal.add("Left3");
181:
182: List rightVal = new ArrayList();
183: rightVal.add("Right1");
184: rightVal.add("Right2");
185: rightVal.add("Right3");
186:
187: TestAction testaction = (TestAction) action;
188: testaction.setCollection(left);
189: testaction.setList2(right);
190: testaction.setCollection2(leftVal);
191: testaction.setList3(rightVal);
192:
193: OptionTransferSelectTag tag = new OptionTransferSelectTag();
194: tag.setPageContext(pageContext);
195:
196: tag.setName("collection");
197: tag.setId("id");
198: tag.setList("collection2");
199: tag.setSize("20");
200: tag.setMultiple("true");
201: tag.setEmptyOption("true");
202:
203: tag.setDoubleName("list2");
204: tag.setDoubleList("list3");
205: tag.setDoubleId("doubleId");
206: tag.setDoubleSize("20");
207: tag.setMultiple("true");
208: tag.setDoubleEmptyOption("true");
209:
210: tag.setAllowAddAllToLeft("true");
211: tag.setAllowAddAllToRight("true");
212: tag.setAllowAddToLeft("true");
213: tag.setAllowAddToRight("true");
214: tag.setAllowSelectAll("true");
215:
216: tag.setAddAllToLeftLabel("All Left");
217: tag.setAddAllToRightLabel("All Right");
218: tag.setAddToLeftLabel("Left");
219: tag.setAddToRightLabel("Right");
220: tag.setSelectAllLabel("Select All");
221:
222: tag.setLeftTitle("Title Left");
223: tag.setRightTitle("Title Right");
224:
225: tag.setButtonCssClass("buttonCssClass");
226: tag.setButtonCssStyle("buttonCssStyle");
227:
228: tag.doStartTag();
229: tag.doEndTag();
230:
231: //System.out.println(writer.toString());
232: verify(OptionTransferSelectTagTest.class
233: .getResource("optiontransferselect-3.txt"));
234: }
235:
236: public void testWithoutHeaderOnOneSide() throws Exception {
237: List left = new ArrayList();
238: left.add("Left2");
239:
240: List right = new ArrayList();
241: right.add("Right2");
242:
243: List leftVal = new ArrayList();
244: leftVal.add("Left1");
245: leftVal.add("Left2");
246: leftVal.add("Left3");
247:
248: List rightVal = new ArrayList();
249: rightVal.add("Right1");
250: rightVal.add("Right2");
251: rightVal.add("Right3");
252:
253: TestAction testaction = (TestAction) action;
254: testaction.setCollection(left);
255: testaction.setList2(right);
256: testaction.setCollection2(leftVal);
257: testaction.setList3(rightVal);
258:
259: OptionTransferSelectTag tag = new OptionTransferSelectTag();
260: tag.setPageContext(pageContext);
261:
262: tag.setName("collection");
263: tag.setId("id");
264: tag.setList("collection2");
265: tag.setSize("20");
266: tag.setMultiple("true");
267: tag.setEmptyOption("true");
268:
269: tag.setDoubleName("list2");
270: tag.setDoubleList("list3");
271: tag.setDoubleId("doubleId");
272: tag.setDoubleSize("20");
273: tag.setMultiple("true");
274: tag.setDoubleEmptyOption("true");
275:
276: tag.setAllowAddAllToLeft("true");
277: tag.setAllowAddAllToRight("true");
278: tag.setAllowAddToLeft("true");
279: tag.setAllowAddToRight("true");
280: tag.setAllowSelectAll("true");
281:
282: tag.setAddAllToLeftLabel("All Left");
283: tag.setAddAllToRightLabel("All Right");
284: tag.setAddToLeftLabel("Left");
285: tag.setAddToRightLabel("Right");
286: tag.setSelectAllLabel("Select All");
287:
288: tag.setLeftTitle("Title Left");
289: tag.setRightTitle("Title Right");
290:
291: tag.setButtonCssClass("buttonCssClass");
292: tag.setButtonCssStyle("buttonCssStyle");
293:
294: tag.setHeaderKey("Header Key");
295: tag.setHeaderValue("Header Value");
296:
297: tag.doStartTag();
298: tag.doEndTag();
299:
300: //System.out.println(writer.toString());
301: verify(OptionTransferSelectTagTest.class
302: .getResource("optiontransferselect-4.txt"));
303: }
304:
305: public void testWithoutEmptyOptionOnBothSides() throws Exception {
306: List left = new ArrayList();
307: left.add("Left2");
308:
309: List right = new ArrayList();
310: right.add("Right2");
311:
312: List leftVal = new ArrayList();
313: leftVal.add("Left1");
314: leftVal.add("Left2");
315: leftVal.add("Left3");
316:
317: List rightVal = new ArrayList();
318: rightVal.add("Right1");
319: rightVal.add("Right2");
320: rightVal.add("Right3");
321:
322: TestAction testaction = (TestAction) action;
323: testaction.setCollection(left);
324: testaction.setList2(right);
325: testaction.setCollection2(leftVal);
326: testaction.setList3(rightVal);
327:
328: OptionTransferSelectTag tag = new OptionTransferSelectTag();
329: tag.setPageContext(pageContext);
330:
331: tag.setName("collection");
332: tag.setId("id");
333: tag.setList("collection2");
334: tag.setSize("20");
335: tag.setMultiple("true");
336: tag.setEmptyOption("false");
337:
338: tag.setDoubleName("list2");
339: tag.setDoubleList("list3");
340: tag.setDoubleId("doubleId");
341: tag.setDoubleSize("20");
342: tag.setMultiple("true");
343: tag.setDoubleEmptyOption("false");
344:
345: tag.setAllowAddAllToLeft("true");
346: tag.setAllowAddAllToRight("true");
347: tag.setAllowAddToLeft("true");
348: tag.setAllowAddToRight("true");
349: tag.setAllowSelectAll("true");
350:
351: tag.setAddAllToLeftLabel("All Left");
352: tag.setAddAllToRightLabel("All Right");
353: tag.setAddToLeftLabel("Left");
354: tag.setAddToRightLabel("Right");
355: tag.setSelectAllLabel("Select All");
356:
357: tag.setLeftTitle("Title Left");
358: tag.setRightTitle("Title Right");
359:
360: tag.setButtonCssClass("buttonCssClass");
361: tag.setButtonCssStyle("buttonCssStyle");
362:
363: tag.setHeaderKey("Header Key");
364: tag.setHeaderValue("Header Value");
365:
366: tag.setDoubleHeaderKey("Double Header Key");
367: tag.setDoubleHeaderValue("Double Header Value");
368:
369: tag.doStartTag();
370: tag.doEndTag();
371:
372: //System.out.println(writer.toString());
373: verify(OptionTransferSelectTagTest.class
374: .getResource("optiontransferselect-5.txt"));
375: }
376:
377: public void testWithoutEmptyOptionOnOneSide() throws Exception {
378: List left = new ArrayList();
379: left.add("Left2");
380:
381: List right = new ArrayList();
382: right.add("Right2");
383:
384: List leftVal = new ArrayList();
385: leftVal.add("Left1");
386: leftVal.add("Left2");
387: leftVal.add("Left3");
388:
389: List rightVal = new ArrayList();
390: rightVal.add("Right1");
391: rightVal.add("Right2");
392: rightVal.add("Right3");
393:
394: TestAction testaction = (TestAction) action;
395: testaction.setCollection(left);
396: testaction.setList2(right);
397: testaction.setCollection2(leftVal);
398: testaction.setList3(rightVal);
399:
400: OptionTransferSelectTag tag = new OptionTransferSelectTag();
401: tag.setPageContext(pageContext);
402:
403: tag.setName("collection");
404: tag.setId("id");
405: tag.setList("collection2");
406: tag.setSize("20");
407: tag.setMultiple("true");
408: tag.setEmptyOption("true");
409:
410: tag.setDoubleName("list2");
411: tag.setDoubleList("list3");
412: tag.setDoubleId("doubleId");
413: tag.setDoubleSize("20");
414: tag.setMultiple("true");
415: tag.setDoubleEmptyOption("false");
416:
417: tag.setAllowAddAllToLeft("true");
418: tag.setAllowAddAllToRight("true");
419: tag.setAllowAddToLeft("true");
420: tag.setAllowAddToRight("true");
421: tag.setAllowSelectAll("true");
422:
423: tag.setAddAllToLeftLabel("All Left");
424: tag.setAddAllToRightLabel("All Right");
425: tag.setAddToLeftLabel("Left");
426: tag.setAddToRightLabel("Right");
427: tag.setSelectAllLabel("Select All");
428:
429: tag.setLeftTitle("Title Left");
430: tag.setRightTitle("Title Right");
431:
432: tag.setButtonCssClass("buttonCssClass");
433: tag.setButtonCssStyle("buttonCssStyle");
434:
435: tag.setHeaderKey("Header Key");
436: tag.setHeaderValue("Header Value");
437:
438: tag.setDoubleHeaderKey("Double Header Key");
439: tag.setDoubleHeaderValue("Double Header Value");
440:
441: tag.doStartTag();
442: tag.doEndTag();
443:
444: //System.out.println(writer.toString());
445: verify(OptionTransferSelectTagTest.class
446: .getResource("optiontransferselect-6.txt"));
447: }
448:
449: public void testDisableSomeButtons() throws Exception {
450: List left = new ArrayList();
451: left.add("Left2");
452:
453: List right = new ArrayList();
454: right.add("Right2");
455:
456: List leftVal = new ArrayList();
457: leftVal.add("Left1");
458: leftVal.add("Left2");
459: leftVal.add("Left3");
460:
461: List rightVal = new ArrayList();
462: rightVal.add("Right1");
463: rightVal.add("Right2");
464: rightVal.add("Right3");
465:
466: TestAction testaction = (TestAction) action;
467: testaction.setCollection(left);
468: testaction.setList2(right);
469: testaction.setCollection2(leftVal);
470: testaction.setList3(rightVal);
471:
472: OptionTransferSelectTag tag = new OptionTransferSelectTag();
473: tag.setPageContext(pageContext);
474:
475: tag.setName("collection");
476: tag.setId("id");
477: tag.setList("collection2");
478: tag.setSize("20");
479: tag.setMultiple("true");
480: tag.setEmptyOption("true");
481:
482: tag.setDoubleName("list2");
483: tag.setDoubleList("list3");
484: tag.setDoubleId("doubleId");
485: tag.setDoubleSize("20");
486: tag.setMultiple("true");
487: tag.setDoubleEmptyOption("true");
488:
489: tag.setAllowAddAllToLeft("false");
490: tag.setAllowAddAllToRight("false");
491: tag.setAllowAddToLeft("true");
492: tag.setAllowAddToRight("true");
493: tag.setAllowSelectAll("false");
494:
495: tag.setAddAllToLeftLabel("All Left");
496: tag.setAddAllToRightLabel("All Right");
497: tag.setAddToLeftLabel("Left");
498: tag.setAddToRightLabel("Right");
499: tag.setSelectAllLabel("Select All");
500:
501: tag.setLeftTitle("Title Left");
502: tag.setRightTitle("Title Right");
503:
504: tag.setButtonCssClass("buttonCssClass");
505: tag.setButtonCssStyle("buttonCssStyle");
506:
507: tag.setHeaderKey("Header Key");
508: tag.setHeaderValue("Header Value");
509:
510: tag.setDoubleHeaderKey("Double Header Key");
511: tag.setDoubleHeaderValue("Double Header Value");
512:
513: tag.setAddToLeftOnclick("alert('Moving Left')");
514: tag.setAddToRightOnclick("alert('Moving Right')");
515:
516: tag.doStartTag();
517: tag.doEndTag();
518:
519: //System.out.println(writer.toString());
520: verify(OptionTransferSelectTagTest.class
521: .getResource("optiontransferselect-7.txt"));
522: }
523: }
|