View Javadoc

    1   /*
    2    * $Id: OptionTransferSelectTagTest.java 471756 2006-11-06 15:01:43Z husted $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *  http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing,
    15   * software distributed under the License is distributed on an
    16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    17   * KIND, either express or implied.  See the License for the
    18   * specific language governing permissions and limitations
    19   * under the License.
    20   */
    21  package org.apache.struts2.views.jsp.ui;
    22
    23  import java.util.ArrayList;
    24  import java.util.List;
    25
    26  import org.apache.struts2.TestAction;
    27  import org.apache.struts2.views.jsp.AbstractUITagTest;
    28
    29  /***
    30   *
    31   */
    32  public class OptionTransferSelectTagTest extends AbstractUITagTest {
    33
    34      public void testWithAllSelected() throws Exception {
    35          List left = new ArrayList();
    36          left.add("Left1");
    37          left.add("Left2");
    38
    39          List right = new ArrayList();
    40          right.add("Right1");
    41          right.add("Right2");
    42
    43          TestAction testaction = (TestAction) action;
    44          testaction.setCollection(left);
    45          testaction.setList2(right);
    46
    47          OptionTransferSelectTag tag = new OptionTransferSelectTag();
    48          tag.setPageContext(pageContext);
    49
    50          tag.setName("collection");
    51          tag.setId("id");
    52          tag.setList("collection");
    53          tag.setSize("20");
    54          tag.setMultiple("true");
    55          tag.setEmptyOption("true");
    56
    57          tag.setDoubleName("list2");
    58          tag.setDoubleList("list2");
    59          tag.setDoubleId("doubleId");
    60          tag.setDoubleSize("20");
    61          tag.setMultiple("true");
    62          tag.setDoubleEmptyOption("true");
    63
    64          tag.setAllowAddAllToLeft("true");
    65          tag.setAllowAddAllToRight("true");
    66          tag.setAllowAddToLeft("true");
    67          tag.setAllowAddToRight("true");
    68          tag.setAllowSelectAll("true");
    69
    70          tag.setAddAllToLeftLabel("All Left");
    71          tag.setAddAllToRightLabel("All Right");
    72          tag.setAddToLeftLabel("Left");
    73          tag.setAddToRightLabel("Right");
    74          tag.setSelectAllLabel("Select All");
    75
    76          tag.setLeftTitle("Title Left");
    77          tag.setRightTitle("Title Right");
    78
    79          tag.setButtonCssClass("buttonCssClass");
    80          tag.setButtonCssStyle("buttonCssStyle");
    81
    82          tag.setHeaderKey("Header Key");
    83          tag.setHeaderValue("Header Value");
    84
    85          tag.setDoubleHeaderKey("Double Header Key");
    86          tag.setDoubleHeaderValue("Double Header Value");
    87
    88          tag.doStartTag();
    89          tag.doEndTag();
    90
    91          //System.out.println(writer.toString());
    92          verify(OptionTransferSelectTagTest.class.getResource("optiontransferselect-1.txt"));
    93      }
    94
    95      public void testWithPartialSelectedOnBothSides() throws Exception {
    96          List left = new ArrayList();
    97          left.add("Left2");
    98
    99          List right = new ArrayList();
    100         right.add("Right2");
    101
    102         List leftVal = new ArrayList();
    103         leftVal.add("Left1");
    104         leftVal.add("Left2");
    105         leftVal.add("Left3");
    106
    107         List rightVal = new ArrayList();
    108         rightVal.add("Right1");
    109         rightVal.add("Right2");
    110         rightVal.add("Right3");
    111
    112
    113         TestAction testaction = (TestAction) action;
    114         testaction.setCollection(left);
    115         testaction.setList2(right);
    116         testaction.setCollection2(leftVal);
    117         testaction.setList3(rightVal);
    118
    119
    120         OptionTransferSelectTag tag = new OptionTransferSelectTag();
    121         tag.setPageContext(pageContext);
    122
    123         tag.setName("collection");
    124         tag.setId("id");
    125         tag.setList("collection2");
    126         tag.setSize("20");
    127         tag.setMultiple("true");
    128         tag.setEmptyOption("true");
    129
    130         tag.setDoubleName("list2");
    131         tag.setDoubleList("list3");
    132         tag.setDoubleId("doubleId");
    133         tag.setDoubleSize("20");
    134         tag.setMultiple("true");
    135         tag.setDoubleEmptyOption("true");
    136
    137         tag.setAllowAddAllToLeft("true");
    138         tag.setAllowAddAllToRight("true");
    139         tag.setAllowAddToLeft("true");
    140         tag.setAllowAddToRight("true");
    141         tag.setAllowSelectAll("true");
    142
    143         tag.setAddAllToLeftLabel("All Left");
    144         tag.setAddAllToRightLabel("All Right");
    145         tag.setAddToLeftLabel("Left");
    146         tag.setAddToRightLabel("Right");
    147         tag.setSelectAllLabel("Select All");
    148
    149         tag.setLeftTitle("Title Left");
    150         tag.setRightTitle("Title Right");
    151
    152         tag.setButtonCssClass("buttonCssClass");
    153         tag.setButtonCssStyle("buttonCssStyle");
    154
    155         tag.setHeaderKey("Header Key");
    156         tag.setHeaderValue("Header Value");
    157
    158         tag.setDoubleHeaderKey("Double Header Key");
    159         tag.setDoubleHeaderValue("Double Header Value");
    160
    161         tag.doStartTag();
    162         tag.doEndTag();
    163
    164         //System.out.println(writer.toString());
    165         verify(OptionTransferSelectTagTest.class.getResource("optiontransferselect-2.txt"));
    166     }
    167
    168     public void testWithoutHeaderOnBothSides() throws Exception {
    169         List left = new ArrayList();
    170         left.add("Left2");
    171
    172         List right = new ArrayList();
    173         right.add("Right2");
    174
    175         List leftVal = new ArrayList();
    176         leftVal.add("Left1");
    177         leftVal.add("Left2");
    178         leftVal.add("Left3");
    179
    180         List rightVal = new ArrayList();
    181         rightVal.add("Right1");
    182         rightVal.add("Right2");
    183         rightVal.add("Right3");
    184
    185
    186         TestAction testaction = (TestAction) action;
    187         testaction.setCollection(left);
    188         testaction.setList2(right);
    189         testaction.setCollection2(leftVal);
    190         testaction.setList3(rightVal);
    191
    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.getResource("optiontransferselect-3.txt"));
    233     }
    234
    235     public void testWithoutHeaderOnOneSide() throws Exception {
    236         List left = new ArrayList();
    237         left.add("Left2");
    238
    239         List right = new ArrayList();
    240         right.add("Right2");
    241
    242         List leftVal = new ArrayList();
    243         leftVal.add("Left1");
    244         leftVal.add("Left2");
    245         leftVal.add("Left3");
    246
    247         List rightVal = new ArrayList();
    248         rightVal.add("Right1");
    249         rightVal.add("Right2");
    250         rightVal.add("Right3");
    251
    252
    253         TestAction testaction = (TestAction) action;
    254         testaction.setCollection(left);
    255         testaction.setList2(right);
    256         testaction.setCollection2(leftVal);
    257         testaction.setList3(rightVal);
    258
    259
    260         OptionTransferSelectTag tag = new OptionTransferSelectTag();
    261         tag.setPageContext(pageContext);
    262
    263         tag.setName("collection");
    264         tag.setId("id");
    265         tag.setList("collection2");
    266         tag.setSize("20");
    267         tag.setMultiple("true");
    268         tag.setEmptyOption("true");
    269
    270         tag.setDoubleName("list2");
    271         tag.setDoubleList("list3");
    272         tag.setDoubleId("doubleId");
    273         tag.setDoubleSize("20");
    274         tag.setMultiple("true");
    275         tag.setDoubleEmptyOption("true");
    276
    277         tag.setAllowAddAllToLeft("true");
    278         tag.setAllowAddAllToRight("true");
    279         tag.setAllowAddToLeft("true");
    280         tag.setAllowAddToRight("true");
    281         tag.setAllowSelectAll("true");
    282
    283         tag.setAddAllToLeftLabel("All Left");
    284         tag.setAddAllToRightLabel("All Right");
    285         tag.setAddToLeftLabel("Left");
    286         tag.setAddToRightLabel("Right");
    287         tag.setSelectAllLabel("Select All");
    288
    289         tag.setLeftTitle("Title Left");
    290         tag.setRightTitle("Title Right");
    291
    292         tag.setButtonCssClass("buttonCssClass");
    293         tag.setButtonCssStyle("buttonCssStyle");
    294
    295         tag.setHeaderKey("Header Key");
    296         tag.setHeaderValue("Header Value");
    297
    298         tag.doStartTag();
    299         tag.doEndTag();
    300
    301         //System.out.println(writer.toString());
    302         verify(OptionTransferSelectTagTest.class.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
    323         TestAction testaction = (TestAction) action;
    324         testaction.setCollection(left);
    325         testaction.setList2(right);
    326         testaction.setCollection2(leftVal);
    327         testaction.setList3(rightVal);
    328
    329
    330         OptionTransferSelectTag tag = new OptionTransferSelectTag();
    331         tag.setPageContext(pageContext);
    332
    333         tag.setName("collection");
    334         tag.setId("id");
    335         tag.setList("collection2");
    336         tag.setSize("20");
    337         tag.setMultiple("true");
    338         tag.setEmptyOption("false");
    339
    340         tag.setDoubleName("list2");
    341         tag.setDoubleList("list3");
    342         tag.setDoubleId("doubleId");
    343         tag.setDoubleSize("20");
    344         tag.setMultiple("true");
    345         tag.setDoubleEmptyOption("false");
    346
    347         tag.setAllowAddAllToLeft("true");
    348         tag.setAllowAddAllToRight("true");
    349         tag.setAllowAddToLeft("true");
    350         tag.setAllowAddToRight("true");
    351         tag.setAllowSelectAll("true");
    352
    353         tag.setAddAllToLeftLabel("All Left");
    354         tag.setAddAllToRightLabel("All Right");
    355         tag.setAddToLeftLabel("Left");
    356         tag.setAddToRightLabel("Right");
    357         tag.setSelectAllLabel("Select All");
    358
    359         tag.setLeftTitle("Title Left");
    360         tag.setRightTitle("Title Right");
    361
    362         tag.setButtonCssClass("buttonCssClass");
    363         tag.setButtonCssStyle("buttonCssStyle");
    364
    365         tag.setHeaderKey("Header Key");
    366         tag.setHeaderValue("Header Value");
    367
    368         tag.setDoubleHeaderKey("Double Header Key");
    369         tag.setDoubleHeaderValue("Double Header Value");
    370
    371         tag.doStartTag();
    372         tag.doEndTag();
    373
    374         //System.out.println(writer.toString());
    375         verify(OptionTransferSelectTagTest.class.getResource("optiontransferselect-5.txt"));
    376     }
    377
    378     public void testWithoutEmptyOptionOnOneSide() throws Exception {
    379         List left = new ArrayList();
    380         left.add("Left2");
    381
    382         List right = new ArrayList();
    383         right.add("Right2");
    384
    385         List leftVal = new ArrayList();
    386         leftVal.add("Left1");
    387         leftVal.add("Left2");
    388         leftVal.add("Left3");
    389
    390         List rightVal = new ArrayList();
    391         rightVal.add("Right1");
    392         rightVal.add("Right2");
    393         rightVal.add("Right3");
    394
    395
    396         TestAction testaction = (TestAction) action;
    397         testaction.setCollection(left);
    398         testaction.setList2(right);
    399         testaction.setCollection2(leftVal);
    400         testaction.setList3(rightVal);
    401
    402
    403         OptionTransferSelectTag tag = new OptionTransferSelectTag();
    404         tag.setPageContext(pageContext);
    405
    406         tag.setName("collection");
    407         tag.setId("id");
    408         tag.setList("collection2");
    409         tag.setSize("20");
    410         tag.setMultiple("true");
    411         tag.setEmptyOption("true");
    412
    413         tag.setDoubleName("list2");
    414         tag.setDoubleList("list3");
    415         tag.setDoubleId("doubleId");
    416         tag.setDoubleSize("20");
    417         tag.setMultiple("true");
    418         tag.setDoubleEmptyOption("false");
    419
    420         tag.setAllowAddAllToLeft("true");
    421         tag.setAllowAddAllToRight("true");
    422         tag.setAllowAddToLeft("true");
    423         tag.setAllowAddToRight("true");
    424         tag.setAllowSelectAll("true");
    425
    426         tag.setAddAllToLeftLabel("All Left");
    427         tag.setAddAllToRightLabel("All Right");
    428         tag.setAddToLeftLabel("Left");
    429         tag.setAddToRightLabel("Right");
    430         tag.setSelectAllLabel("Select All");
    431
    432         tag.setLeftTitle("Title Left");
    433         tag.setRightTitle("Title Right");
    434
    435         tag.setButtonCssClass("buttonCssClass");
    436         tag.setButtonCssStyle("buttonCssStyle");
    437
    438         tag.setHeaderKey("Header Key");
    439         tag.setHeaderValue("Header Value");
    440
    441         tag.setDoubleHeaderKey("Double Header Key");
    442         tag.setDoubleHeaderValue("Double Header Value");
    443
    444         tag.doStartTag();
    445         tag.doEndTag();
    446
    447         //System.out.println(writer.toString());
    448         verify(OptionTransferSelectTagTest.class.getResource("optiontransferselect-6.txt"));
    449     }
    450
    451     public void testDisableSomeButtons() throws Exception {
    452         List left = new ArrayList();
    453         left.add("Left2");
    454
    455         List right = new ArrayList();
    456         right.add("Right2");
    457
    458         List leftVal = new ArrayList();
    459         leftVal.add("Left1");
    460         leftVal.add("Left2");
    461         leftVal.add("Left3");
    462
    463         List rightVal = new ArrayList();
    464         rightVal.add("Right1");
    465         rightVal.add("Right2");
    466         rightVal.add("Right3");
    467
    468
    469         TestAction testaction = (TestAction) action;
    470         testaction.setCollection(left);
    471         testaction.setList2(right);
    472         testaction.setCollection2(leftVal);
    473         testaction.setList3(rightVal);
    474
    475
    476         OptionTransferSelectTag tag = new OptionTransferSelectTag();
    477         tag.setPageContext(pageContext);
    478
    479         tag.setName("collection");
    480         tag.setId("id");
    481         tag.setList("collection2");
    482         tag.setSize("20");
    483         tag.setMultiple("true");
    484         tag.setEmptyOption("true");
    485
    486         tag.setDoubleName("list2");
    487         tag.setDoubleList("list3");
    488         tag.setDoubleId("doubleId");
    489         tag.setDoubleSize("20");
    490         tag.setMultiple("true");
    491         tag.setDoubleEmptyOption("true");
    492
    493         tag.setAllowAddAllToLeft("false");
    494         tag.setAllowAddAllToRight("false");
    495         tag.setAllowAddToLeft("true");
    496         tag.setAllowAddToRight("true");
    497         tag.setAllowSelectAll("false");
    498
    499         tag.setAddAllToLeftLabel("All Left");
    500         tag.setAddAllToRightLabel("All Right");
    501         tag.setAddToLeftLabel("Left");
    502         tag.setAddToRightLabel("Right");
    503         tag.setSelectAllLabel("Select All");
    504
    505         tag.setLeftTitle("Title Left");
    506         tag.setRightTitle("Title Right");
    507
    508         tag.setButtonCssClass("buttonCssClass");
    509         tag.setButtonCssStyle("buttonCssStyle");
    510
    511         tag.setHeaderKey("Header Key");
    512         tag.setHeaderValue("Header Value");
    513
    514         tag.setDoubleHeaderKey("Double Header Key");
    515         tag.setDoubleHeaderValue("Double Header Value");
    516
    517         tag.doStartTag();
    518         tag.doEndTag();
    519
    520         //System.out.println(writer.toString());
    521         verify(OptionTransferSelectTagTest.class.getResource("optiontransferselect-7.txt"));
    522     }
    523 }