-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- introduce io.quarkus.test.InjectMock - deprecate io.quakus.test.junit.mockito.InjectMock - remove io.quarkus.test.component.ConfigureMock
- Loading branch information
Showing
20 changed files
with
182 additions
and
58 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
27 changes: 27 additions & 0 deletions
27
test-framework/common/src/main/java/io/quarkus/test/InjectMock.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,27 @@ | ||
package io.quarkus.test; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Instructs the test engine to inject a mock instance of a bean in the field of a test class. | ||
* <p> | ||
* This annotation is supported: | ||
* <ul> | ||
* <li>in a {@code io.quarkus.test.component.QuarkusComponentTest},</li> | ||
* <li>in a {@code io.quarkus.test.QuarkusTest} if {@code quarkus-junit5-mockito} is present.</li> | ||
* </ul> | ||
* The lifecycle and configuration API of the injected mock depends on the type of test being used. | ||
* <p> | ||
* Some test types impose additional restrictons and limitations. For example, only beans that have a | ||
* <a href="https://quarkus.io/guides/cdi#client_proxies">client proxy</a> may be mocked in a | ||
* {@code io.quarkus.test.junit.QuarkusTest}. | ||
*/ | ||
@Retention(RUNTIME) | ||
@Target(FIELD) | ||
public @interface InjectMock { | ||
|
||
} |
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
16 changes: 0 additions & 16 deletions
16
test-framework/junit5-component/src/main/java/io/quarkus/test/component/ConfigureMock.java
This file was deleted.
Oops, something went wrong.
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
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
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
34 changes: 34 additions & 0 deletions
34
test-framework/junit5-mockito/src/main/java/io/quarkus/test/junit/mockito/MockitoConfig.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,34 @@ | ||
package io.quarkus.test.junit.mockito; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import io.quarkus.test.InjectMock; | ||
|
||
/** | ||
* This annotation can be used to configure a Mockito mock injected in a field of a test class that is annotated with | ||
* {@link InjectMock}. This annotation is only supported in a {@code io.quarkus.test.QuarkusTest}. | ||
* | ||
* @see InjectMock | ||
*/ | ||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface MockitoConfig { | ||
|
||
/** | ||
* If true, then Quarkus will change the scope of the target {@code Singleton} bean to {@code ApplicationScoped} | ||
* to make it mockable. | ||
* <p> | ||
* This is an advanced setting and should only be used if you don't rely on the differences between {@code Singleton} | ||
* and {@code ApplicationScoped} beans (for example it is invalid to read fields of {@code ApplicationScoped} beans | ||
* as a proxy stands in place of the actual implementation) | ||
*/ | ||
boolean convertScopes() default false; | ||
|
||
/** | ||
* If true, the mock will be created with the {@link org.mockito.Mockito#RETURNS_DEEP_STUBS} | ||
*/ | ||
boolean returnsDeepMocks() default false; | ||
} |
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
Oops, something went wrong.