Skip to content

Commit

Permalink
Adding JavaDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
tginsberg committed Nov 11, 2018
1 parent cec371f commit 1cf78c4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
13 changes: 12 additions & 1 deletion build.gradle
Expand Up @@ -33,7 +33,7 @@ ext {
}

group 'com.ginsberg'
version '1.0.0-SNAPSHOT'
version '1.0.0'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down Expand Up @@ -66,6 +66,10 @@ task sourcesJar(type: Jar) {
classifier = 'sources'
}

task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}

publishing {
publications {
Expand All @@ -75,6 +79,7 @@ publishing {
version = project.version
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'junit5-system-exit'
description = 'A JUnit5 Extension to help write tests that call System.exit()'
Expand Down Expand Up @@ -123,6 +128,12 @@ publishing {
}
}

javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html4', true)
}
}

signing {
sign publishing.publications.mavenJava
}
Expand Up @@ -28,6 +28,11 @@
import java.net.InetAddress;
import java.security.Permission;

/**
* This is a SecurityManager that will prevent the system from exiting. If that happens, it will
* record the status code that was attempted. All other actions are delegated to another SecurityManager,
* optionally provided at construction.
*/
public class DisallowExitSecurityManager extends SecurityManager {
private final SecurityManager delegatedSecurityManager;
private Integer firstExitStatusCode;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/ginsberg/junit/exit/ExpectSystemExit.java
Expand Up @@ -31,6 +31,10 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* This is a marker annotation that indicates the given test method or class is expected
* to call System.exit()
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@ExtendWith(SystemExitExtension.class)
Expand Down
Expand Up @@ -31,6 +31,10 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* This is a marker annotation that indicates the given test method or class is expected
* to call System.exit() with a specific code
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@ExtendWith(SystemExitExtension.class)
Expand Down
Expand Up @@ -35,6 +35,10 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.platform.commons.support.AnnotationSupport.findAnnotation;

/**
* Does the work of installing the DisallowExitSecurityManager, interpreting the test results, and
* returning the original SecurityManager to service.
*/
public class SystemExitExtension implements BeforeEachCallback, AfterEachCallback, TestExecutionExceptionHandler {
private Integer expectedStatusCode;
private final DisallowExitSecurityManager disallowExitSecurityManager = new DisallowExitSecurityManager(System.getSecurityManager());
Expand Down

0 comments on commit 1cf78c4

Please sign in to comment.