Skip to content

Commit

Permalink
Add RM annotations for better UX (#19)
Browse files Browse the repository at this point in the history
* Add RM annotations for better UX

Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys authored Feb 29, 2024
1 parent 568a98d commit c259c02
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.skodjob.testframe.annotations;

import io.skodjob.testframe.listeners.ResourceManagerCleanerExtension;
import io.skodjob.testframe.listeners.ResourceManagerExtension;
import org.junit.jupiter.api.extension.ExtendWith;

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

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target(ElementType.TYPE)
@Retention(RUNTIME)
@ExtendWith(ResourceManagerExtension.class)
@ExtendWith(ResourceManagerCleanerExtension.class)
public @interface ResourceManager {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.skodjob.testframe.annotations;

import io.skodjob.testframe.listeners.ResourceManagerExtension;
import org.junit.jupiter.api.extension.ExtendWith;

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

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target(ElementType.TYPE)
@Retention(RUNTIME)
@ExtendWith(ResourceManagerExtension.class)
public @interface ResourceManagerDebug {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.skodjob.testframe.annotations;

import io.skodjob.testframe.listeners.TestVisualSeparatorExtension;
import org.junit.jupiter.api.extension.ExtendWith;

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

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target(ElementType.TYPE)
@Retention(RUNTIME)
@ExtendWith(TestVisualSeparatorExtension.class)
public @interface TestVisualSeparator {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.skodjob.testframe.listeners;

import io.skodjob.testframe.resources.ResourceManager;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

/**
* jUnit5 specific class which listening on test callbacks
*/
public class ResourceManagerCleanerExtension
implements AfterAllCallback, AfterEachCallback {

@Override
public void afterAll(ExtensionContext extensionContext) {
ResourceManager.setTestContext(extensionContext);
ResourceManager.getInstance().deleteResources();
}

@Override
public void afterEach(ExtensionContext extensionContext) {
ResourceManager.setTestContext(extensionContext);
ResourceManager.getInstance().deleteResources();
}
}

0 comments on commit c259c02

Please sign in to comment.