forked from debezium/debezium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBZ-8138 Re-add check if assembly profile is active as JUnit annotation
- Loading branch information
Showing
8 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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
29 changes: 29 additions & 0 deletions
29
debezium-core/src/test/java/io/debezium/junit/RequiresAssemblyProfile.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 Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.junit; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Marker annotation used to group tests that require the assembly profile, using the {@code isAssemblyProfileActive} system property. | ||
* | ||
* @author René Kerner | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.METHOD, ElementType.TYPE }) | ||
public @interface RequiresAssemblyProfile { | ||
|
||
String REQUIRES_ASSEMBLY_PROFILE_PROPERTY = "isAssemblyProfileActive"; | ||
|
||
/** | ||
* The optional reason why the test is skipped. | ||
* @return the reason why the test is skipped | ||
*/ | ||
String value() default "Maven 'assembly' profile required (use '-Passembly' to enable assembly profile)"; | ||
} |
32 changes: 32 additions & 0 deletions
32
debezium-core/src/test/java/io/debezium/junit/RequiresAssemblyProfileTestRule.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,32 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.junit; | ||
|
||
import org.junit.runner.Description; | ||
import org.junit.runners.model.Statement; | ||
|
||
/** | ||
* JUnit rule that inspects the presence of the {@link RequiresAssemblyProfile} annotation either on a test method or on a test suite. If | ||
* it finds the annotation, it will only run the test method/suite if the system property {@code isAssemblyProfileActive} has the | ||
* value {@code true} | ||
* | ||
* @author René Kerner | ||
*/ | ||
public class RequiresAssemblyProfileTestRule extends AnnotationBasedTestRule { | ||
|
||
@Override | ||
public Statement apply(Statement base, Description description) { | ||
RequiresAssemblyProfile requiresAssemblyProfileAnnotation = hasAnnotation(description, RequiresAssemblyProfile.class); | ||
if (requiresAssemblyProfileAnnotation != null) { | ||
String requiresAssemblyProfile = System.getProperty(RequiresAssemblyProfile.REQUIRES_ASSEMBLY_PROFILE_PROPERTY, "false"); | ||
if (!Boolean.parseBoolean(requiresAssemblyProfile)) { | ||
return emptyStatement(requiresAssemblyProfileAnnotation.value(), description); | ||
} | ||
} | ||
return base; | ||
} | ||
|
||
} |
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
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