Skip to content

Commit b5a9c92

Browse files
author
Roger Riggs
committed
8256244: java/lang/ProcessHandle/PermissionTest.java fails with TestNG 7.1
Reviewed-by: lancea, iignatyev
1 parent 90f9a70 commit b5a9c92

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

test/jdk/java/lang/ProcessHandle/PermissionTest.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
3535

3636
import org.testng.Assert;
3737
import org.testng.annotations.AfterClass;
38-
import org.testng.annotations.BeforeGroups;
3938
import org.testng.annotations.Test;
4039

4140
/*
@@ -118,45 +117,54 @@ public void processToHandleWithPermission() throws IOException {
118117
}
119118
}
120119

121-
@BeforeGroups (groups = {"NoManageProcessPermission"})
120+
/**
121+
* Setup a policy that would reject ProcessHandle requests without Permissions ManageProcess.
122+
*/
122123
public void noPermissionsSetup(){
123124
Policy.setPolicy(new TestPolicy());
124125
SecurityManager sm = new SecurityManager();
125126
System.setSecurityManager(sm);
126127
}
127128

128-
@Test(groups = { "NoManageProcessPermission" }, expectedExceptions = SecurityException.class)
129+
@Test(expectedExceptions = SecurityException.class)
129130
public void noPermissionAllChildren() {
131+
noPermissionsSetup();
130132
currentHndl.descendants();
131133
}
132134

133-
@Test(groups = { "NoManageProcessPermission" }, expectedExceptions = SecurityException.class)
135+
@Test(expectedExceptions = SecurityException.class)
134136
public void noPermissionAllProcesses() {
137+
noPermissionsSetup();
135138
ProcessHandle.allProcesses();
136139
}
137140

138-
@Test(groups = { "NoManageProcessPermission" }, expectedExceptions = SecurityException.class)
141+
@Test(expectedExceptions = SecurityException.class)
139142
public void noPermissionChildren() {
143+
noPermissionsSetup();
140144
currentHndl.children();
141145
}
142146

143-
@Test(groups = { "NoManageProcessPermission" }, expectedExceptions = SecurityException.class)
147+
@Test(expectedExceptions = SecurityException.class)
144148
public void noPermissionCurrent() {
149+
noPermissionsSetup();
145150
ProcessHandle.current();
146151
}
147152

148-
@Test(groups = { "NoManageProcessPermission" }, expectedExceptions = SecurityException.class)
153+
@Test(expectedExceptions = SecurityException.class)
149154
public void noPermissionOf() {
155+
noPermissionsSetup();
150156
ProcessHandle.of(0);
151157
}
152158

153-
@Test(groups = { "NoManageProcessPermission" }, expectedExceptions = SecurityException.class)
159+
@Test(expectedExceptions = SecurityException.class)
154160
public void noPermissionParent() {
161+
noPermissionsSetup();
155162
currentHndl.parent();
156163
}
157164

158-
@Test(groups = { "NoManageProcessPermission" }, expectedExceptions = SecurityException.class)
165+
@Test(expectedExceptions = SecurityException.class)
159166
public void noPermissionProcessToHandle() throws IOException {
167+
noPermissionsSetup();
160168
Process p = null;
161169
try {
162170
ProcessBuilder pb = new ProcessBuilder("sleep", "30");

0 commit comments

Comments
 (0)