|
4 | 4 |
|
5 | 5 | import java.io.File; |
6 | 6 | import java.lang.reflect.Method; |
7 | | -import java.security.Permission; |
8 | 7 | import org.testng.IReporter; |
9 | 8 | import org.testng.ITestNGListener; |
10 | 9 | import org.testng.TestNG; |
11 | | -import org.testng.annotations.AfterClass; |
12 | | -import org.testng.annotations.BeforeClass; |
13 | 10 | import org.testng.annotations.DataProvider; |
14 | 11 | import org.testng.annotations.Test; |
15 | 12 | import org.testng.reporters.EmailableReporter; |
16 | 13 | import org.testng.reporters.EmailableReporter2; |
17 | 14 | import test.SimpleBaseTest; |
18 | 15 |
|
19 | 16 | public class EmailableReporterTest extends SimpleBaseTest { |
20 | | - private SecurityManager manager; |
21 | | - |
22 | | - @BeforeClass(alwaysRun = true) |
23 | | - public void setup() { |
24 | | - manager = System.getSecurityManager(); |
25 | | - System.setSecurityManager(new MySecurityManager(manager)); |
26 | | - } |
27 | | - |
28 | | - @AfterClass(alwaysRun = true) |
29 | | - public void cleanup() { |
30 | | - System.setSecurityManager(manager); |
31 | | - } |
32 | | - |
33 | 17 | @Test(dataProvider = "getReporterInstances", priority = 1) |
34 | 18 | public void testReportsNameCustomizationViaRunMethodInvocationAndJVMArguments( |
35 | 19 | IReporter reporter, String jvm) { |
@@ -133,23 +117,4 @@ private void runTestViaRunMethod(IReporter reporter, String jvm) { |
133 | 117 | File actual = new File(output.getAbsolutePath(), filename); |
134 | 118 | assertThat(actual).exists(); |
135 | 119 | } |
136 | | - |
137 | | - public static class MySecurityManager extends SecurityManager { |
138 | | - |
139 | | - private SecurityManager baseSecurityManager; |
140 | | - |
141 | | - MySecurityManager(SecurityManager baseSecurityManager) { |
142 | | - this.baseSecurityManager = baseSecurityManager; |
143 | | - } |
144 | | - |
145 | | - @Override |
146 | | - public void checkPermission(Permission permission) { |
147 | | - if (permission.getName().startsWith("exitVM")) { |
148 | | - throw new SecurityException("System exit not allowed"); |
149 | | - } |
150 | | - if (baseSecurityManager != null) { |
151 | | - baseSecurityManager.checkPermission(permission); |
152 | | - } |
153 | | - } |
154 | | - } |
155 | 120 | } |
0 commit comments