Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated @NativeImageTest #31048

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public class JunitTestRunner {
public static final DotName QUARKUS_TEST = DotName.createSimple("io.quarkus.test.junit.QuarkusTest");
public static final DotName QUARKUS_MAIN_TEST = DotName.createSimple("io.quarkus.test.junit.main.QuarkusMainTest");
public static final DotName QUARKUS_INTEGRATION_TEST = DotName.createSimple("io.quarkus.test.junit.QuarkusIntegrationTest");
public static final DotName NATIVE_IMAGE_TEST = DotName.createSimple("io.quarkus.test.junit.NativeImageTest");
public static final DotName TEST_PROFILE = DotName.createSimple("io.quarkus.test.junit.TestProfile");
public static final DotName TEST = DotName.createSimple(Test.class.getName());
public static final DotName REPEATED_TEST = DotName.createSimple(RepeatedTest.class.getName());
Expand Down Expand Up @@ -555,13 +554,11 @@ private DiscoveryResult discoverTestClasses() {
//we now have all the classes by name
//these tests we never run
Set<String> integrationTestClasses = new HashSet<>();
for (DotName intAnno : Arrays.asList(QUARKUS_INTEGRATION_TEST, NATIVE_IMAGE_TEST)) {
for (AnnotationInstance i : index.getAnnotations(intAnno)) {
DotName name = i.target().asClass().name();
integrationTestClasses.add(name.toString());
for (ClassInfo clazz : index.getAllKnownSubclasses(name)) {
integrationTestClasses.add(clazz.name().toString());
}
for (AnnotationInstance i : index.getAnnotations(QUARKUS_INTEGRATION_TEST)) {
DotName name = i.target().asClass().name();
integrationTestClasses.add(name.toString());
for (ClassInfo clazz : index.getAllKnownSubclasses(name)) {
integrationTestClasses.add(clazz.name().toString());
}
}
Set<String> quarkusTestClasses = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public class TestConfig {
Optional<List<String>> argLine;

/**
* Used in {@code @QuarkusIntegrationTest} and {@code NativeImageTest} to determine how long the test will wait for the
* Used in {@code @QuarkusIntegrationTest} to determine how long the test will wait for the
* application to launch
*/
@ConfigItem(defaultValue = "PT1M")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public interface TestScopeSetup {

void setup(boolean isNativeImageTest);
void setup(boolean isIntegrationTest);

void tearDown(boolean isNativeImageTest);
void tearDown(boolean isIntegrationTest);
}
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/amazon-lambda-http.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ If you want to hand code raw events for the AWS REST API, Quarkus has its own im
and `io.quarkus.amazon.lambda.http.model.AwsProxyResponse`. This corresponds
to `quarkus-amazon-lambda-rest` extension and the AWS REST API.

The mock event server is also started for `@NativeImageTest` and `@QuarkusIntegrationTest` tests so will work
The mock event server is also started for `@QuarkusIntegrationTest` tests so will work
with native binaries too. All this provides similar functionality to the SAM CLI local testing, without the overhead of Docker.

Finally, if port 8080 or port 8081 is not available on your computer, you can modify the dev
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/amazon-lambda.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public class LambdaHandlerTest {
}
----

The mock event server is also started for `@NativeImageTest` and `@QuarkusIntegrationTest` tests so will work
The mock event server is also started for `@QuarkusIntegrationTest` tests so will work
with native binaries too. All this provides similar functionality to the SAM CLI local testing, without the overhead of Docker.

Finally, if port 8080 or port 8081 is not available on your computer, you can modify the dev
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/building-native-image.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ to 300 seconds, use: `./mvnw verify -Pnative -Dquarkus.test.wait-time=300`.

[WARNING]
====
This procedure was formerly accomplished using the `@NativeImageTest` annotation. `@NativeImageTest` is considered deprecated in favor of `@QuarkusIntegrationTest` which provides a superset of the testing
This procedure was formerly accomplished using the `@NativeImageTest` annotation. `@NativeImageTest` was replaced by `@QuarkusIntegrationTest` which provides a superset of the testing
capabilities of `@NativeImageTest`. More information about `@QuarkusIntegrationTest` can be found in the xref:getting-started-testing.adoc#quarkus-integration-test[Testing Guide].
====

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/getting-started-testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ If instead a native image was built, then the application is launched as `./appl
Finally, if a container image was created during the build (by including the `quarkus-container-image-jib` or `quarkus-container-image-docker` extensions and having the
`quarkus.container-image.build=true` property configured), then a container is created and run (this requires the `docker` executable being present).

As is the case with `@NativeImageTest`, this is a black box test that supports the same set features and has the same limitations.
This is a black box test that supports the same set features and has the same limitations.

[NOTE]
====
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/maven-tooling.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ As mentioned below, this is overridden in the `native` profile.
`maven.home` is only required if you have custom configuration in `${maven.home}/conf/settings.xml`.
<7> Use a specific `native` profile for native executable building.
<8> Enable the `native` package type. The build will therefore produce a native executable.
<9> Always run integration tests when building a native image (test names `*IT` and annotated with `@QuarkusIntegrationTest` or `@NativeImageTest`). +
<9> Always run integration tests when building a native image (test names `*IT` and annotated with `@QuarkusIntegrationTest`). +
If you do not wish to run integration tests when building a native image, simply remove this property altogether or set its value to `true`.

[[fast-jar]]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/rest-client-reactive.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ You can do it with Mockito's `@InjectMock` or with `QuarkusMock`.

This section shows how to replace your client with a mock. If you would like to get a more in-depth understanding of how mocking works in Quarkus, see the blog post on https://quarkus.io/blog/mocking/[Mocking CDI beans].

NOTE: Mocking does not work when using `@NativeImageTest` or `@QuarkusIntegrationTest`.
NOTE: Mocking does not work when using `@QuarkusIntegrationTest`.

Let's assume you have the following client:
[source,java]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/security-testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ See xref:security-oidc-bearer-authentication-concept.adoc#integration-testing-se

[WARNING]
====
The feature is only available for `@QuarkusTest` and will **not** work on a `@NativeImageTest` or `@QuarkusIntegrationTest`.
The feature is only available for `@QuarkusTest` and will **not** work on a `@QuarkusIntegrationTest`.
====

[TIP]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class ArcTestRequestScopeProvider implements TestScopeSetup {
private static final Logger LOGGER = Logger.getLogger(ArcTestRequestScopeProvider.class);

@Override
public void setup(boolean isNativeImageTest) {
if (isNativeImageTest) {
public void setup(boolean isIntegrationTest) {
if (isIntegrationTest) {
return;
}
ArcContainer container = Arc.container();
Expand All @@ -25,8 +25,8 @@ public void setup(boolean isNativeImageTest) {
}

@Override
public void tearDown(boolean isNativeImageTest) {
if (isNativeImageTest) {
public void tearDown(boolean isIntegrationTest) {
if (isIntegrationTest) {
return;
}
ArcContainer container = Arc.container();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public class TestScopeManager {
}
}

public static void setup(boolean isNativeImageTest) {
public static void setup(boolean isIntegrationTest) {
for (TestScopeSetup i : SCOPE_MANAGERS) {
i.setup(isNativeImageTest);
i.setup(isIntegrationTest);
}
}

public static void tearDown(boolean isNativeImageTest) {
public static void tearDown(boolean isIntegrationTest) {
for (TestScopeSetup i : SCOPE_MANAGERS) {
i.tearDown(isNativeImageTest);
i.tearDown(isIntegrationTest);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* Used to signal that a test class or method should be disabled if the version of GraalVM used to build the native binary
* under test was older than the supplied version.
*
* This annotation should only be used on a test classes annotated with {@link NativeImageTest} or
* {@link QuarkusIntegrationTest}. If it is used on other test classes, it will have no effect.
* This annotation should only be used on a test classes annotated with {@link QuarkusIntegrationTest}.
* If it is used on other test classes, it will have no effect.
*/
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
public class DisableIfBuiltWithGraalVMNewerThanCondition implements ExecutionCondition {

private static final String QUARKUS_INTEGRATION_TEST_NAME = QuarkusIntegrationTest.class.getName();
private static final String NATIVE_IMAGE_TEST_NAME = NativeImageTest.class.getName();
private static final Set<String> SUPPORTED_INTEGRATION_TESTS = Set.of(QUARKUS_INTEGRATION_TEST_NAME,
NATIVE_IMAGE_TEST_NAME);
private static final Set<String> SUPPORTED_INTEGRATION_TESTS = Set.of(QUARKUS_INTEGRATION_TEST_NAME);

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* Used to signal that a test class or method should be disabled if the version of GraalVM used to build the native binary
* under test was older than the supplied version.
*
* This annotation should only be used on a test classes annotated with {@link NativeImageTest} or
* {@link QuarkusIntegrationTest}. If it is used on other test classes, it will have no effect.
* This annotation should only be used on a test classes annotated with {@link QuarkusIntegrationTest}.
* If it is used on other test classes, it will have no effect.
*/
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
public class DisableIfBuiltWithGraalVMOlderThanCondition implements ExecutionCondition {

private static final String QUARKUS_INTEGRATION_TEST_NAME = QuarkusIntegrationTest.class.getName();
private static final String NATIVE_IMAGE_TEST_NAME = NativeImageTest.class.getName();
private static final Set<String> SUPPORTED_INTEGRATION_TESTS = Set.of(QUARKUS_INTEGRATION_TEST_NAME,
NATIVE_IMAGE_TEST_NAME);
private static final Set<String> SUPPORTED_INTEGRATION_TESTS = Set.of(QUARKUS_INTEGRATION_TEST_NAME);

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
Expand Down Expand Up @@ -58,16 +59,7 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
}
return false;
}));
if (disabledOnIntegrationTestReason != null) {
return disabledOnIntegrationTestReason;
}
// support DisabledOnNativeImage for backward compatibility
ConditionEvaluationResult disabledOnNativeImageReason = check(context, element, DisabledOnNativeImage.class,
DisabledOnNativeImage::value, null);
if (disabledOnNativeImageReason != null) {
return disabledOnNativeImageReason;
}
return ENABLED;
return Objects.requireNonNullElse(disabledOnIntegrationTestReason, ENABLED);
}

private <T extends Annotation> ConditionEvaluationResult check(ExtensionContext context, Optional<AnnotatedElement> element,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ static void ensureNoInjectAnnotationIsUsed(Class<?> testClass) {
for (Field field : current.getDeclaredFields()) {
if (field.getAnnotation(Inject.class) != null) {
throw new JUnitException(
"@Inject is not supported in @NativeImageTest and @QuarkusIntegrationTest tests. Offending field is "
"@Inject is not supported in @QuarkusIntegrationTest tests. Offending field is "
+ field.getDeclaringClass().getTypeName() + "."
+ field.getName());
}
if (field.getAnnotation(ConfigProperty.class) != null) {
throw new JUnitException(
"@ConfigProperty is not supported in @NativeImageTest and @QuarkusIntegrationTest tests. Offending field is "
"@ConfigProperty is not supported in @QuarkusIntegrationTest tests. Offending field is "
+ field.getDeclaringClass().getTypeName() + "."
+ field.getName());
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,11 @@ public void afterEach(ExtensionContext context) throws Exception {

private boolean isNativeOrIntegrationTest(Class<?> clazz) {
for (Class<?> i : currentTestClassStack) {
if (i.isAnnotationPresent(NativeImageTest.class) || i.isAnnotationPresent(QuarkusIntegrationTest.class)) {
if (i.isAnnotationPresent(QuarkusIntegrationTest.class)) {
return true;
}
}
if (clazz.isAnnotationPresent(NativeImageTest.class) || clazz.isAnnotationPresent(QuarkusIntegrationTest.class)) {
if (clazz.isAnnotationPresent(QuarkusIntegrationTest.class)) {
return true;
}
return false;
Expand Down