Debian Codegraph @

tests/reproducers/simple/JSToJFuncReturn/testcases/JSToJFuncReturnTest.java

raw
1 /* JSToJFuncReturnTest.java
2 Copyright (C) 2012 Red Hat, Inc.
3
4 This file is part of IcedTea.
5
6 IcedTea is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, version 2.
9
10 IcedTea is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with IcedTea; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301 USA.
19
20 Linking this library statically or dynamically with other modules is
21 making a combined work based on this library. Thus, the terms and
22 conditions of the GNU General Public License cover the whole
23 combination.
24
25 As a special exception, the copyright holders of this library give you
26 permission to link this library with independent modules to produce an
27 executable, regardless of the license terms of these independent
28 modules, and to copy and distribute the resulting executable under
29 terms of your choice, provided that you also meet, for each linked
30 independent module, the terms and conditions of the license of that
31 module. An independent module is a module which is not derived from
32 or based on this library. If you modify this library, you may extend
33 this exception to your version of the library, but you are not
34 obligated to do so. If you do not wish to do so, delete this
35 exception statement from your version.
36 */
37
38 import net.sourceforge.jnlp.ProcessResult;
39 import net.sourceforge.jnlp.ServerAccess;
40 import net.sourceforge.jnlp.browsertesting.BrowserTest;
41 import net.sourceforge.jnlp.browsertesting.Browsers;
42 import net.sourceforge.jnlp.closinglisteners.CountingClosingListener;
43 import net.sourceforge.jnlp.annotations.KnownToFail;
44 import net.sourceforge.jnlp.annotations.NeedsDisplay;
45 import net.sourceforge.jnlp.annotations.TestInBrowsers;
46 import org.junit.Assert;
47
48 import org.junit.Test;
49
50 public class JSToJFuncReturnTest extends BrowserTest {
51
52 private final String initStr = "JSToJFuncReturn applet initialized.";
53 private final String afterStr = "afterTests";
54
55 private class CountingClosingListenerImpl extends CountingClosingListener {
56
57 @Override
58 protected boolean isAlowedToFinish(String s) {
59
60 return (s.contains(initStr) && s.contains(afterStr));
61 }
62 }
63
64 private void evaluateStdoutContents(String expectedStdout, ProcessResult pr) {
65 // Assert that the applet was initialized.
66 Assert.assertTrue("JSToJFuncReturnTest stdout should contain " + initStr + " but it didnt.", pr.stdout.contains(initStr));
67
68 // Assert that the tests have passed.
69 Assert.assertTrue("JSToJFuncReturnTest stdout should contain " + expectedStdout + " but it didnt.", pr.stdout.contains(expectedStdout));
70 }
71
72 private void jsToJavaFuncReturnNormalTest(String methodStr, String expectedStdout) throws Exception {
73 String strURL = "/JSToJFuncReturn.html?" + methodStr;
74 ProcessResult pr = server.executeBrowser(strURL, new CountingClosingListenerImpl(), new CountingClosingListenerImpl());
75 evaluateStdoutContents(expectedStdout, pr);
76 }
77
78 @Test
79 @TestInBrowsers(testIn = { Browsers.all })
80 @NeedsDisplay
81 public void AppletJSToJFuncReturn_int_Test() throws Exception {
82 jsToJavaFuncReturnNormalTest("_int", "number 1");
83 }
84
85 @Test
86 @TestInBrowsers(testIn = { Browsers.all })
87 @NeedsDisplay
88 public void AppletJSToJFuncReturn_double_Test() throws Exception {
89 jsToJavaFuncReturnNormalTest("_double", "number 1.1");
90 }
91
92 @Test
93 @TestInBrowsers(testIn = { Browsers.all })
94 @NeedsDisplay
95 public void AppletJSToJFuncReturn_float_Test() throws Exception {
96 jsToJavaFuncReturnNormalTest("_float", "number 1.1");
97 }
98
99 @Test
100 @TestInBrowsers(testIn = { Browsers.all })
101 @NeedsDisplay
102 public void AppletJSToJFuncReturn_long_Test() throws Exception {
103 jsToJavaFuncReturnNormalTest("_long", "number 10000");
104 }
105
106 @Test
107 @TestInBrowsers(testIn = { Browsers.all })
108 @NeedsDisplay
109 public void AppletJSToJFuncReturn_boolean_Test() throws Exception {
110 jsToJavaFuncReturnNormalTest("_boolean", "boolean true");
111 }
112
113 @Test
114 @TestInBrowsers(testIn = { Browsers.all })
115 @NeedsDisplay
116 public void AppletJSToJFuncReturn_char_Test() throws Exception {
117 jsToJavaFuncReturnNormalTest("_char", "number 97"); // 'a'
118 }
119
120 @Test
121 @TestInBrowsers(testIn = { Browsers.all })
122 @NeedsDisplay
123 public void AppletJSToJFuncReturn_byte_Test() throws Exception {
124 jsToJavaFuncReturnNormalTest("_byte", "number 10");
125 }
126
127 @Test
128 @TestInBrowsers(testIn = { Browsers.all })
129 @NeedsDisplay
130 public void AppletJSToJFuncReturn_charArrayElement_Test() throws Exception {
131 jsToJavaFuncReturnNormalTest("_charArrayElement", "number 97");
132 }
133
134 @Test
135 @TestInBrowsers(testIn = { Browsers.all })
136 @NeedsDisplay
137 public void AppletJSToJFuncReturn_void_Test() throws Exception {
138 jsToJavaFuncReturnNormalTest("_void", "undefined undefined");
139 }
140
141 @Test
142 @TestInBrowsers(testIn = { Browsers.all })
143 @NeedsDisplay
144 public void AppletJSToJFuncReturn_regularString_Test() throws Exception {
145 jsToJavaFuncReturnNormalTest("_regularString", "string test");
146 }
147
148 @Test
149 @TestInBrowsers(testIn = { Browsers.all })
150 @NeedsDisplay
151 public void AppletJSToJFuncReturn_specialCharsString_Test() throws Exception {
152 jsToJavaFuncReturnNormalTest("_specialString", "string 𠁎〒£$ǣ€𝍖");
153 }
154
155 @Test
156 @TestInBrowsers(testIn = { Browsers.all })
157 @NeedsDisplay
158 public void AppletJSToJFuncReturn_null_Test() throws Exception {
159 jsToJavaFuncReturnNormalTest("_null", "object null");
160 }
161
162 @Test
163 @TestInBrowsers(testIn = { Browsers.all })
164 @NeedsDisplay
165 @KnownToFail
166 public void AppletJSToJFuncReturn_Integer_Test() throws Exception {
167 jsToJavaFuncReturnNormalTest("_Integer", "object 1");
168 }
169
170 @Test
171 @TestInBrowsers(testIn = { Browsers.all })
172 @NeedsDisplay
173 @KnownToFail
174 public void AppletJSToJFuncReturn_Double_Test() throws Exception {
175 jsToJavaFuncReturnNormalTest("_Double", "object 1.1");
176 }
177
178 @Test
179 @TestInBrowsers(testIn = { Browsers.all })
180 @NeedsDisplay
181 @KnownToFail
182 public void AppletJSToJFuncReturn_Float_Test() throws Exception {
183 jsToJavaFuncReturnNormalTest("_Float", "object 1.1");
184 }
185
186 @Test
187 @TestInBrowsers(testIn = { Browsers.all })
188 @NeedsDisplay
189 @KnownToFail
190 public void AppletJSToJFuncReturn_Long_Test() throws Exception {
191 jsToJavaFuncReturnNormalTest("_Long", "object 10000");
192 }
193
194 @Test
195 @TestInBrowsers(testIn = { Browsers.all })
196 @NeedsDisplay
197 @KnownToFail
198 public void AppletJSToJFuncReturn_Boolean_Test() throws Exception {
199 jsToJavaFuncReturnNormalTest("_Boolean", "object true");
200 }
201
202 @Test
203 @TestInBrowsers(testIn = { Browsers.all })
204 @NeedsDisplay
205 @KnownToFail
206 public void AppletJSToJFuncReturn_Character_Test() throws Exception {
207 jsToJavaFuncReturnNormalTest("_Character", "object A");
208 }
209
210 @Test
211 @TestInBrowsers(testIn = { Browsers.all })
212 @NeedsDisplay
213 @KnownToFail
214 public void AppletJSToJFuncReturn_Byte_Test() throws Exception {
215 jsToJavaFuncReturnNormalTest("_Byte", "object 10");
216 }
217
218 @Test
219 @TestInBrowsers(testIn = { Browsers.all })
220 @NeedsDisplay
221 @KnownToFail
222 public void AppletJSToJFuncReturn_CharArrayElement_Test() throws Exception {
223 jsToJavaFuncReturnNormalTest("_CharacterArrayElement", "object A");
224 }
225
226 @Test
227 @TestInBrowsers(testIn = { Browsers.all })
228 @NeedsDisplay
229 @KnownToFail
230 public void AppletJSToJFuncReturn_CharFullArray_Test() throws Exception {
231 jsToJavaFuncReturnNormalTest("_CharacterArray", "object [Ljava.lang.Character;@");
232 }
233
234 @Test
235 @TestInBrowsers(testIn = { Browsers.all })
236 @NeedsDisplay
237 public void AppletJSToJFuncReturn_JSObject_Test() throws Exception {
238 jsToJavaFuncReturnNormalTest("_JSObject", "object value1");
239 }
240
241 }