Debian Codegraph @

tests/reproducers/signed/EntryPointSignedSingleBothOk/testcases/EntryPointSignedSingleBothOkTest1.java

raw
1 /*
2 Copyright (C) 2015 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.io.IOException;
39 import java.util.Arrays;
40 import net.sourceforge.jnlp.OptionsDefinitions;
41 import net.sourceforge.jnlp.ProcessResult;
42 import net.sourceforge.jnlp.ServerAccess;
43 import net.sourceforge.jnlp.annotations.TestInBrowsers;
44 import net.sourceforge.jnlp.browsertesting.BrowserTest;
45 import static net.sourceforge.jnlp.browsertesting.BrowserTest.server;
46 import net.sourceforge.jnlp.browsertesting.Browsers;
47 import net.sourceforge.jnlp.closinglisteners.AutoErrorClosingListener;
48 import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener;
49 import net.sourceforge.jnlp.closinglisteners.StringBasedClosingListener;
50 import net.sourceforge.jnlp.config.DeploymentConfiguration;
51 import net.sourceforge.jnlp.runtime.ManifestAttributesChecker;
52 import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier;
53 import org.junit.AfterClass;
54 import org.junit.Assert;
55 import org.junit.BeforeClass;
56 import org.junit.Test;
57
58
59 public class EntryPointSignedSingleBothOkTest1 extends BrowserTest {
60
61
62 public static final String MAGICAL_OK1_CLOSING_STRING = "*** APPLET1 FINISHED ***";
63 public static final String MAGICAL_OK2_CLOSING_STRING = "*** APPLET2 FINISHED ***";
64
65 private static class AutoOk1ClosingListener extends StringBasedClosingListener {
66
67 public AutoOk1ClosingListener() {
68 super(MAGICAL_OK1_CLOSING_STRING);
69 }
70
71 }
72
73 private static class AutoOk2ClosingListener extends StringBasedClosingListener {
74
75 public AutoOk2ClosingListener() {
76 super(MAGICAL_OK2_CLOSING_STRING);
77 }
78
79 }
80
81 private static final DeploymentPropertiesModifier dpm = new DeploymentPropertiesModifier();
82 private static final StringBasedClosingListener aok = new AutoOkClosingListener();
83
84 private static final StringBasedClosingListener aok1 = new AutoOk1ClosingListener();
85 private static final StringBasedClosingListener aok2 = new AutoOk2ClosingListener();
86
87 private static final StringBasedClosingListener aer = new AutoErrorClosingListener();
88 private static final String confirmation1 = "*** applet1 running ***";
89 private static final String confirmation2 = "*** applet2 running ***";
90
91
92 @BeforeClass
93 public static void setDeploymentManifestPermissionReadingOnly() throws IOException {
94 dpm.setProperties(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.ENTRYPOINT.toString());
95 }
96
97 @AfterClass
98 public static void restoreDeploymentProeprtiees() throws IOException {
99 dpm.restoreProperties();
100 }
101
102 @Test
103 public void javawsAllPermNoSecurity1() throws Exception {
104 ProcessResult p = server.executeJavawsHeadless("EntryPointSignedSingleBothOk1.jnlp");
105 Assert.assertTrue(p.stdout.contains(confirmation1));
106 Assert.assertFalse(p.stdout.contains(aok1.getCondition()));
107 Assert.assertTrue(p.stderr.contains(aer.getCondition()));
108 assertNope(p);
109 }
110
111 @Test
112 public void javawsAllPermAllSecurity1() throws Exception {
113 ProcessResult p = server.executeJavawsHeadless("EntryPointSignedSingleBothOk_security1.jnlp");
114 Assert.assertTrue(p.stdout.contains(confirmation1));
115 Assert.assertTrue(p.stdout.contains(aok1.getCondition()));
116 Assert.assertFalse(p.stderr.contains(aer.getCondition()));
117 assertNope(p);
118 }
119
120 @Test
121 public void javawsAppletAllPermNoSecurity1() throws Exception {
122 ProcessResult p = server.executeJavaws(Arrays.asList(new String[]{"-headless", "-verbose"}), "EntryPointSignedSingleBothOk_applet1.jnlp", new AutoOkClosingListener(), new AutoErrorClosingListener());
123 Assert.assertTrue(p.stdout.contains(confirmation1));
124 Assert.assertFalse(p.stdout.contains(aok1.getCondition()));
125 Assert.assertTrue(p.stderr.contains(aer.getCondition()));
126 assertNope(p);
127 }
128
129 @Test
130 public void javawsAppletAllPermAllSecurity1() throws Exception {
131 ProcessResult p = server.executeJavawsHeadless("EntryPointSignedSingleBothOk_applet_security1.jnlp", new AutoOkClosingListener(), new AutoErrorClosingListener());
132 Assert.assertTrue(p.stdout.contains(confirmation1));
133 Assert.assertTrue(p.stdout.contains(aok1.getCondition()));
134 Assert.assertFalse(p.stderr.contains(aer.getCondition()));
135 assertNope(p);
136 }
137
138 @Test
139 @TestInBrowsers(testIn = Browsers.one)
140 public void appletAllPermAllSecurity1() throws Exception {
141 server.getBrowserLocation();
142 ProcessResult p = server.executeBrowser("EntryPointSignedSingleBothOk1.html", ServerAccess.AutoClose.CLOSE_ON_BOTH);
143 Assert.assertTrue(p.stdout.contains(confirmation1));
144 Assert.assertTrue(p.stdout.contains(aok1.getCondition()));
145 Assert.assertFalse(p.stderr.contains(aer.getCondition()));
146 assertNope(p);
147 }
148
149 @Test
150 public void javawsHtml1() throws Exception {
151 ProcessResult p = server.executeJavaws(Arrays.asList(new String[]{OptionsDefinitions.OPTIONS.HTML.option}), "EntryPointSignedSingleBothOk1.html", new AutoOkClosingListener(), new AutoErrorClosingListener());
152 Assert.assertTrue(p.stdout.contains(confirmation1));
153 Assert.assertTrue(p.stdout.contains(aok1.getCondition()));
154 Assert.assertFalse(p.stderr.contains(aer.getCondition()));
155 assertNope(p);
156 }
157
158 public void assertNope(ProcessResult p){
159 Assert.assertFalse(p.stdout.contains(confirmation2));
160 Assert.assertFalse(p.stdout.contains(aok2.getCondition()));
161 }
162
163 }