You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2018/03/01 22:06:17 UTC
logging-log4j2 git commit: Better Javadocs.
Repository: logging-log4j2
Updated Branches:
refs/heads/release-2.x 59a8efed0 -> 146b14b41
Better Javadocs.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/146b14b4
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/146b14b4
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/146b14b4
Branch: refs/heads/release-2.x
Commit: 146b14b41f430f69bac65e66856e43af64fc4034
Parents: 59a8efe
Author: Gary Gregory <ga...@gmail.com>
Authored: Thu Mar 1 15:06:13 2018 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Thu Mar 1 15:06:13 2018 -0700
----------------------------------------------------------------------
.../log4j/junit/SecurityManagerTestRule.java | 88 +++++++++++++-------
1 file changed, 56 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/146b14b4/log4j-api/src/test/java/org/apache/logging/log4j/junit/SecurityManagerTestRule.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/junit/SecurityManagerTestRule.java b/log4j-api/src/test/java/org/apache/logging/log4j/junit/SecurityManagerTestRule.java
index 311b817..57ac55d 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/junit/SecurityManagerTestRule.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/junit/SecurityManagerTestRule.java
@@ -22,49 +22,73 @@ import org.junit.runner.Description;
import org.junit.runners.model.Statement;
/**
- * Sets a security manager for a test run. The current security manager is first
- * saved then restored after the test is run.
+ * Sets a security manager for a test run. The current security manager is first saved then restored after the test is
+ * run.
* <p>
- * Using a security manager can mess up other tests so this is best used from
- * integration tests (classes that end in "IT" instead of "Test" and
- * "TestCase".)
+ * Using a security manager can mess up other tests so this is best used from integration tests (classes that end in
+ * "IT" instead of "Test" and "TestCase".)
* </p>
*
+ * <p>
+ * When this test rule is evaluated, it will:
+ * </p>
+ * <ol>
+ * <li>Save the current SecurityManager.</li>
+ * <li>Set the SecurityManager to the instance supplied to this rule.</li>
+ * <li>Evaluate the test statement.</li>
+ * <li>Reset the current SecurityManager to the one from step (1).</li>
+ * </ol>
+ *
* @since 2.11.0
*/
public class SecurityManagerTestRule implements TestRule {
- public SecurityManagerTestRule(final SecurityManager securityManager) {
- super();
- this.securityManager = securityManager;
- }
+ /**
+ * Constructs a new instance with the given {@link SecurityManager}.
+ * <p>
+ * When this test rule is evaluated, it will:
+ * </p>
+ * <ol>
+ * <li>Save the current SecurityManager.</li>
+ * <li>Set the SecurityManager to the instance supplied to this rule.</li>
+ * <li>Evaluate the test statement.</li>
+ * <li>Reset the current SecurityManager to the one from step (1).</li>
+ * </ol>
+ *
+ * @param securityManager
+ * the {@link SecurityManager} to use while running a test.
+ */
+ public SecurityManagerTestRule(final SecurityManager securityManager) {
+ super();
+ this.securityManager = securityManager;
+ }
- private SecurityManager securityManagerBefore;
- private final SecurityManager securityManager;
+ private SecurityManager securityManagerBefore;
+ private final SecurityManager securityManager;
- @Override
- public Statement apply(final Statement base, final Description description) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- before();
- try {
- base.evaluate();
- } finally {
- after();
- }
- }
+ @Override
+ public Statement apply(final Statement base, final Description description) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ before();
+ try {
+ base.evaluate();
+ } finally {
+ after();
+ }
+ }
- private void after() {
- System.setSecurityManager(securityManagerBefore);
- }
+ private void after() {
+ System.setSecurityManager(securityManagerBefore);
+ }
- private void before() {
- securityManagerBefore = System.getSecurityManager();
- System.setSecurityManager(securityManager);
+ private void before() {
+ securityManagerBefore = System.getSecurityManager();
+ System.setSecurityManager(securityManager);
- }
- };
- }
+ }
+ };
+ }
}