Debian Codegraph @

tests/reproducers/simple/Spaces can be everywhere/testcases/SpacesCanBeEverywhereTests.java

raw
1 /* SpacesCanBeEverywhereTests.java
2 Copyright (C) 2011 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 java.util.ArrayList;
39 import java.util.Arrays;
40 import java.util.List;
41 import net.sourceforge.jnlp.ContentReaderListener;
42 import net.sourceforge.jnlp.ProcessResult;
43 import net.sourceforge.jnlp.ServerAccess;
44 import net.sourceforge.jnlp.annotations.Bug;
45 import net.sourceforge.jnlp.annotations.NeedsDisplay;
46 import net.sourceforge.jnlp.browsertesting.BrowserTest;
47 import net.sourceforge.jnlp.browsertesting.Browsers;
48 import net.sourceforge.jnlp.annotations.TestInBrowsers;
49 import net.sourceforge.jnlp.closinglisteners.StringBasedClosingListener;
50 import org.junit.Assert;
51 import org.junit.Test;
52
53 @Bug(id={"http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2011-October/016127.html","PR804","PR811"})
54 public class SpacesCanBeEverywhereTests extends BrowserTest {
55
56 public static final String s = "Spaces can be everywhere.jsr was launched correctly";
57 @Bug(id="PR811")
58 @Test
59 @NeedsDisplay
60 public void SpacesCanBeEverywhereLocalAppletTestsJnlp2() throws Exception {
61 List<String> commands=new ArrayList<String>(1);
62 commands.add(server.getJavawsLocation());
63 commands.add(server.getDir()+"/NotOnly spaces can kill ěščřž too.jnlp");
64 /* Change of dir is cousing the Exception bellow
65 * ServerAccess.ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());
66 * No X11 DISPLAY variable was set, but this program performed an operation which requires it.
67 * at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:173)
68 * at java.awt.Window.<init>(Window.java:476)
69 * at java.awt.Frame.<init>(Frame.java:419)
70 * at java.awt.Frame.<init>(Frame.java:384)
71 * at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1754)
72 * at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1831)
73 * at javax.swing.JWindow.<init>(JWindow.java:185)
74 * at javax.swing.JWindow.<init>(JWindow.java:137)
75 * at net.sourceforge.jnlp.runtime.JNLPSecurityManager.<init>(JNLPSecurityManager.java:121)
76 * at net.sourceforge.jnlp.runtime.JNLPRuntime.initialize(JNLPRuntime.java:202)
77 * at net.sourceforge.jnlp.runtime.Boot.run(Boot.java:177)
78 * at net.sourceforge.jnlp.runtime.Boot.run(Boot.java:51)
79 * at java.security.AccessController.doPrivileged(Native Method)
80 * at net.sourceforge.jnlp.runtime.Boot.main(Boot.java:168)
81 *
82 * Thats why there is absolute path to the file.
83 *
84 * This is also why SpacesCanBeEverywhereLocalTests1Signed is passing -
85 * it is in headless mode. This can be considered as bug, but because it is
86 * only on ocal files, and probably only from test run - it can be ignored
87 */
88 ProcessResult pr = ServerAccess.executeProcess(commands);
89 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
90 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
91 Assert.assertEquals((Integer) 0, pr.returnValue);
92 }
93
94 @Bug(id="PR811")
95 @Test
96 @NeedsDisplay
97 public void SpacesCanBeEverywhereRemoteAppletTestsJnlp2() throws Exception {
98 ProcessResult pr = server.executeJavaws("/NotOnly%20spaces%20can%20kill%20%C4%9B%C5%A1%C4%8D%C5%99%C5%BE%20too.jnlp");
99 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
100 Assert.assertFalse("should NOT be terminated, but was", pr.wasTerminated);
101 }
102
103 @Bug(id="PR811")
104 @Test
105 @NeedsDisplay
106 @TestInBrowsers(testIn = {Browsers.all})
107 public void SpacesCanBeEverywhereRemoteAppletTestsHtml2() throws Exception {
108 ProcessResult pr = server.executeBrowser("/spaces+applet+Tests.html", Arrays.asList(new ContentReaderListener[] {new StringBasedClosingListener(s)}), null);
109 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
110 Assert.assertTrue("should be terminated, but was not", pr.wasTerminated);
111 }
112
113
114 @Bug(id={"PR811","http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2011-October/016144.html"})
115 @Test
116 public void SpacesCanBeEverywhereRemoteTests1() throws Exception {
117 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere1.jnlp");
118 String s = "Good simple javaws exapmle";
119 Assert.assertTrue("stdout should contains `" + s + "`, but did not", pr.stdout.contains(s));
120 String cc = "ClassNotFoundException";
121 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc));
122 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
123 Assert.assertEquals((Integer) 0, pr.returnValue);
124 }
125
126 @Bug(id="PR811")
127 @Test
128 public void SpacesCanBeEverywhereRemoteTests2() throws Exception {
129 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2.jnlp");
130 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
131 String cc = "ClassNotFoundException";
132 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc));
133 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
134 Assert.assertEquals((Integer) 0, pr.returnValue);
135 }
136
137 @Bug(id="PR811")
138 @Test
139 public void SpacesCanBeEverywhereRemoteTests2_withQuery1() throws Exception {
140 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2.jnlp?test=10");
141 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
142 String cc = "ClassNotFoundException";
143 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc));
144 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
145 Assert.assertEquals((Integer) 0, pr.returnValue);
146 }
147
148
149 @Bug(id="PR811")
150 @Test
151 public void SpacesCanBeEverywhereRemoteTests2_withQuery2() throws Exception {
152 ProcessResult pr = server.executeJavawsHeadless(null, "/Spaces%20can%20be%20everywhere2.jnlp?test%3D10");
153 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
154 String cc = "ClassNotFoundException";
155 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc));
156 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
157 Assert.assertEquals((Integer) 0, pr.returnValue);
158 }
159
160 @Bug(id="PR811")
161 @Test
162 public void SpacesCanBeEverywhereRemoteTests3() throws Exception {
163 ProcessResult pr = server.executeJavawsHeadless(null, "/SpacesCanBeEverywhere1.jnlp");
164 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
165 String cc = "ClassNotFoundException";
166 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc));
167 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
168 Assert.assertEquals((Integer) 0, pr.returnValue);
169 }
170
171
172 @Bug(id="PR804")
173 @Test
174 public void SpacesCanBeEverywhereLocalTests1() throws Exception {
175 List<String> commands=new ArrayList<String>(4);
176 commands.add(server.getJavawsLocation());
177 commands.add(ServerAccess.HEADLES_OPTION);
178 commands.add("Spaces can be everywhere1.jnlp");
179 ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());
180 String s = "Good simple javaws exapmle";
181 Assert.assertTrue("stdout should contains `" + s + "`, but did not", pr.stdout.contains(s));
182 String cc = "ClassNotFoundException";
183 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc));
184 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
185 Assert.assertEquals((Integer) 0, pr.returnValue);
186 }
187
188 @Bug(id="PR804")
189 @Test
190 public void SpacesCanBeEverywhereLocalTests2() throws Exception {
191 List<String> commands=new ArrayList<String>(4);
192 commands.add(server.getJavawsLocation());
193 commands.add(ServerAccess.HEADLES_OPTION);
194 commands.add("Spaces can be everywhere2.jnlp");
195 ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());
196 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
197 String cc = "ClassNotFoundException";
198 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc));
199 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
200 Assert.assertEquals((Integer) 0, pr.returnValue);
201 }
202
203 @Bug(id="PR804")
204 @Test
205 public void SpacesCanBeEverywhereLocalTests4() throws Exception {
206 List<String> commands=new ArrayList<String>(4);
207 commands.add(server.getJavawsLocation());
208 commands.add(ServerAccess.HEADLES_OPTION);
209 commands.add(server.getDir()+"/Spaces can be everywhere2.jnlp");
210 ProcessResult pr = ServerAccess.executeProcess(commands);
211 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
212 String cc = "ClassNotFoundException";
213 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc));
214 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
215 Assert.assertEquals((Integer) 0, pr.returnValue);
216 }
217
218 @Bug(id="PR804")
219 @Test
220 public void SpacesCanBeEverywhereLocalTests3() throws Exception {
221 List<String> commands=new ArrayList<String>(4);
222 commands.add(server.getJavawsLocation());
223 commands.add(ServerAccess.HEADLES_OPTION);
224 commands.add("SpacesCanBeEverywhere1.jnlp");
225 ProcessResult pr = ServerAccess.executeProcess(commands,server.getDir());
226 Assert.assertTrue("stdout should contains `"+s+"`, but did not",pr.stdout.contains(s));
227 String cc = "ClassNotFoundException";
228 Assert.assertFalse("stderr should NOT contains `" + cc + "`, but did", pr.stderr.contains(cc));
229 Assert.assertFalse("should not be terminated, but was", pr.wasTerminated);
230 Assert.assertEquals((Integer) 0, pr.returnValue);
231 }
232 }