View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.juneau.bean.html5;
18  
19  import static org.apache.juneau.bean.html5.HtmlBuilder.*;
20  import static org.apache.juneau.junit.bct.BctAssertions.*;
21  
22  import org.apache.juneau.*;
23  import org.junit.jupiter.api.*;
24  
25  class Form_Test extends TestBase {
26  
27  	@Test void a01_basicSetters() {
28  		Form x = form()
29  			.acceptcharset("a")
30  			.action("b")
31  			.autocomplete("c")
32  			.enctype("d")
33  			.method("e")
34  			.name("f")
35  			.novalidate(true)
36  			.target("h")
37  			._class("i")
38  			.accesskey("j")
39  			.contenteditable("k")
40  			.dir("l")
41  			.hidden("m")
42  			.id("n")
43  			.lang("o")
44  			.onabort("p")
45  			.onblur("q")
46  			.oncancel("r")
47  			.oncanplay("s")
48  			.oncanplaythrough("t")
49  			.onchange("u")
50  			.onclick("v")
51  			.oncuechange("w")
52  			.ondblclick("x")
53  			.ondurationchange("y")
54  			.onemptied("z")
55  			.onended("aa")
56  			.onerror("ab")
57  			.onfocus("ac")
58  			.oninput("ad")
59  			.oninvalid("ae")
60  			.onkeydown("af")
61  			.onkeypress("ag")
62  			.onkeyup("ah")
63  			.onload("ai")
64  			.onloadeddata("aj")
65  			.onloadedmetadata("ak")
66  			.onloadstart("al")
67  			.onmousedown("am")
68  			.onmouseenter("an")
69  			.onmouseleave("ao")
70  			.onmousemove("ap")
71  			.onmouseout("aq")
72  			.onmouseover("ar")
73  			.onmouseup("as")
74  			.onmousewheel("at")
75  			.onpause("au")
76  			.onplay("av")
77  			.onplaying("aw")
78  			.onprogress("ax")
79  			.onratechange("ay")
80  			.onreset("az")
81  			.onresize("ba")
82  			.onscroll("bb")
83  			.onseeked("bc")
84  			.onseeking("bd")
85  			.onselect("be")
86  			.onshow("bf")
87  			.onstalled("bg")
88  			.onsubmit("bh")
89  			.onsuspend("bi")
90  			.ontimeupdate("bj")
91  			.ontoggle("bk")
92  			.onvolumechange("bl")
93  			.onwaiting("bm")
94  			.spellcheck("bn")
95  			.style("bo")
96  			.tabindex("bp")
97  			.title("bq")
98  			.translate("br")
99  			.children("bs", strong("bt"));
100 
101 		assertString(
102 			"<form accept-charset='a' action='b' autocomplete='c' enctype='d' method='e' name='f' novalidate='true' target='h' class='i' accesskey='j' contenteditable='k' dir='l' hidden='m' id='n' lang='o' onabort='p' onblur='q' oncancel='r' oncanplay='s' oncanplaythrough='t' onchange='u' onclick='v' oncuechange='w' ondblclick='x' ondurationchange='y' onemptied='z' onended='aa' onerror='ab' onfocus='ac' oninput='ad' oninvalid='ae' onkeydown='af' onkeypress='ag' onkeyup='ah' onload='ai' onloadeddata='aj' onloadedmetadata='ak' onloadstart='al' onmousedown='am' onmouseenter='an' onmouseleave='ao' onmousemove='ap' onmouseout='aq' onmouseover='ar' onmouseup='as' onmousewheel='at' onpause='au' onplay='av' onplaying='aw' onprogress='ax' onratechange='ay' onreset='az' onresize='ba' onscroll='bb' onseeked='bc' onseeking='bd' onselect='be' onshow='bf' onstalled='bg' onsubmit='bh' onsuspend='bi' ontimeupdate='bj' ontoggle='bk' onvolumechange='bl' onwaiting='bm' spellcheck='bn' style='bo' tabindex='bp' title='bq' translate='br'>bs<strong>bt</strong></form>",
103 			x
104 		);
105 	}
106 
107 	@Test void a02_emptyBean() {
108 		assertString("<form></form>", form());
109 	}
110 
111 	@Test void a03_otherConstructors() {
112 		Form x1 = new Form("a");
113 		assertString("<form action='a'></form>", x1);
114 
115 		Form x2 = new Form("a", "b1", strong("b2"));
116 		assertString("<form action='a'>b1<strong>b2</strong></form>", x2);
117 
118 	}
119 }