View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.renderkit.html.util;
21  
22  import org.junit.Assert;
23  import org.junit.Test;
24  
25  public class HtmlRendererUtilsUnitTest {
26  
27    // the suffix number 1 means true or != null, 0 means false or == null
28  
29    @Test
30    public void testWriteSubmitAction100() {
31      Assert.assertEquals("Tobago.submitAction(this,'id',{});",
32          HtmlRendererUtils.createSubmitAction("id", true, null, null));
33    }
34  
35    @Test
36    public void testWriteSubmitAction000() {
37      Assert.assertEquals("Tobago.submitAction(this,'id',{transition:false});",
38          HtmlRendererUtils.createSubmitAction("id", false, null, null));
39    }
40  
41    @Test
42    public void testWriteSubmitAction110() {
43      Assert.assertEquals("Tobago.submitAction(this,'id',{target:'t'});",
44          HtmlRendererUtils.createSubmitAction("id", true, "t", null));
45    }
46  
47    @Test
48    public void testWriteSubmitAction010() {
49      Assert.assertEquals("Tobago.submitAction(this,'id',{transition:false,target:'t'});",
50          HtmlRendererUtils.createSubmitAction("id", false, "t", null));
51    }
52  
53    @Test
54    public void testWriteSubmitAction101() {
55      Assert.assertEquals("Tobago.submitAction(this,'id',{focus:'f'});",
56          HtmlRendererUtils.createSubmitAction("id", true, null, "f"));
57    }
58  
59    @Test
60    public void testWriteSubmitAction001() {
61      Assert.assertEquals("Tobago.submitAction(this,'id',{transition:false,focus:'f'});",
62          HtmlRendererUtils.createSubmitAction("id", false, null, "f"));
63    }
64  
65    @Test
66    public void testWriteSubmitAction111() {
67      Assert.assertEquals("Tobago.submitAction(this,'id',{target:'t',focus:'f'});",
68          HtmlRendererUtils.createSubmitAction("id", true, "t", "f"));
69    }
70  
71    @Test
72    public void testWriteSubmitAction011() {
73      Assert.assertEquals("Tobago.submitAction(this,'id',{transition:false,target:'t',focus:'f'});",
74          HtmlRendererUtils.createSubmitAction("id", false, "t", "f"));
75    }
76  }