-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
ojcms-cdi-testutils/src/main/java/de/adito/ojcms/cdi/TestMethodContext.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 @@ | ||
package de.adito.ojcms.cdi; | ||
|
||
import de.adito.ojcms.cdi.context.*; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
/** | ||
* Custom CDI context for test method scope. | ||
* | ||
* @author Simon Danner, 29.02.2020 | ||
*/ | ||
@CustomCdiContext | ||
public class TestMethodContext extends AbstractCustomContext | ||
{ | ||
@Override | ||
public Class<? extends Annotation> getScope() | ||
{ | ||
return TestMethodScoped.class; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
ojcms-cdi-testutils/src/main/java/de/adito/ojcms/cdi/TestMethodScoped.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,18 @@ | ||
package de.adito.ojcms.cdi; | ||
|
||
import javax.enterprise.context.NormalScope; | ||
import java.lang.annotation.*; | ||
|
||
/** | ||
* CDI scope for unit test methods. The CDI scope lives as long as the execution of a test method. | ||
* | ||
* @author Simon Danner, 29.02.2020 | ||
*/ | ||
@Documented | ||
@NormalScope | ||
@Inherited | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) | ||
public @interface TestMethodScoped | ||
{ | ||
} |
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,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" | ||
bean-discovery-mode="all"> | ||
</beans> |