Skip to content

Commit

Permalink
Merge pull request smallrye#4 from cescoffier/handle-inherited-classes
Browse files Browse the repository at this point in the history
handle inherited classes
  • Loading branch information
cescoffier authored Feb 22, 2024
2 parents 1a4c912 + c06429b commit aa6adf6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.escoffier.certs.CertificateRequest;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.platform.commons.util.AnnotationUtils;

import java.io.File;
import java.time.Duration;
Expand All @@ -12,11 +13,11 @@
public class CertificateGenerationExtension implements BeforeAllCallback {
@Override
public void beforeAll(ExtensionContext extensionContext) throws Exception {
Certificates annotation = extensionContext.getRequiredTestClass().getAnnotation(Certificates.class);
if (annotation == null) {
var maybe = AnnotationUtils.findAnnotation(extensionContext.getRequiredTestClass(), Certificates.class);
if (maybe.isEmpty()) {
return;
}

var annotation = maybe.get();
for (Certificate certificate : annotation.certificates()) {
String baseDir = annotation.baseDir();
File file = new File(baseDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

import org.junit.jupiter.api.extension.ExtendWith;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.*;

/**
* Generate certificates before running tests.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(CertificateGenerationExtension.class)
@Inherited
public @interface Certificates {

/**
Expand Down

0 comments on commit aa6adf6

Please sign in to comment.