-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RM annotations for better UX (#19)
* Add RM annotations for better UX Signed-off-by: David Kornel <[email protected]>
- Loading branch information
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
test-frame-common/src/main/java/io/skodjob/testframe/annotations/ResourceManager.java
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,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 { | ||
} |
20 changes: 20 additions & 0 deletions
20
test-frame-common/src/main/java/io/skodjob/testframe/annotations/ResourceManagerDebug.java
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,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 { | ||
} |
20 changes: 20 additions & 0 deletions
20
test-frame-common/src/main/java/io/skodjob/testframe/annotations/TestVisualSeparator.java
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,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 { | ||
} |
29 changes: 29 additions & 0 deletions
29
...-common/src/main/java/io/skodjob/testframe/listeners/ResourceManagerCleanerExtension.java
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,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(); | ||
} | ||
} |