-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/NoExitSecurityMock.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.aim42.htmlsanitycheck.cli | ||
|
||
import java.security.Permission | ||
|
||
class NoExitSecurityMock extends SecurityManager { | ||
private final SecurityManager originalSecurityManager | ||
|
||
int exitCalled = 0 | ||
|
||
NoExitSecurityMock(SecurityManager originalSecurityManager) { | ||
this.originalSecurityManager = originalSecurityManager | ||
} | ||
|
||
@Override | ||
void checkPermission(Permission perm) { | ||
if (originalSecurityManager != null) { | ||
originalSecurityManager.checkPermission(perm) | ||
} | ||
} | ||
|
||
@Override | ||
void checkPermission(Permission perm, Object context) { | ||
if (originalSecurityManager != null) { | ||
originalSecurityManager.checkPermission(perm, context) | ||
} | ||
} | ||
|
||
@Override | ||
void checkExit(int status) { | ||
exitCalled++ | ||
throw new SecurityException("System.exit(" + status + ") called") | ||
} | ||
} |