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

4.x: MP testing refactoring #7548

Merged
merged 2 commits into from
Sep 18, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions archetypes/helidon/src/main/archetype/mp/common/common-mp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<value key="scope">test</value>
</map>
<map order="0">
<value key="groupId">io.helidon.microprofile.tests</value>
<value key="artifactId">helidon-microprofile-tests-junit5</value>
<value key="groupId">io.helidon.microprofile.testing</value>
<value key="artifactId">helidon-microprofile-testing-junit5</value>
<value key="scope">test</value>
</map>
<map order="0">
Expand All @@ -69,7 +69,7 @@
<value>jakarta.ws.rs.core.Response</value>
</list>
<list key="MainTest-helidon-imports">
<value>io.helidon.microprofile.tests.junit5.HelidonTest</value>
<value>io.helidon.microprofile.testing.junit5.HelidonTest</value>
</list>
<list key="MainTest-other-imports">
<value>org.junit.jupiter.api.AfterAll</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {{.}};
{{/FileServiceTest-helidon-imports}}
import io.helidon.microprofile.server.JaxRsCdiExtension;
import io.helidon.microprofile.server.ServerCdiExtension;
import io.helidon.microprofile.tests.junit5.AddBean;
import io.helidon.microprofile.tests.junit5.AddExtension;
import io.helidon.microprofile.tests.junit5.DisableDiscovery;
import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.AddBean;
import io.helidon.microprofile.testing.junit5.AddExtension;
import io.helidon.microprofile.testing.junit5.DisableDiscovery;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import jakarta.json.JsonObject;
import jakarta.json.JsonString;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package {{package}};

import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.HelidonTest;
import jakarta.inject.Inject;
import jakarta.ws.rs.client.WebTarget;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package {{package}};
import io.helidon.http.HeaderNames;
import io.helidon.config.Config;
import io.helidon.cors.CrossOriginConfig;
import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.HelidonTest;
import jakarta.inject.Inject;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.Invocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import java.net.URI;
import jakarta.inject.Inject;

import io.helidon.microprofile.server.ServerCdiExtension;
import io.helidon.microprofile.tests.junit5.Configuration;
import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.Configuration;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import {{package}}.client.api.ApiException;
import {{package}}.client.api.GreetApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import java.net.URI;
import jakarta.inject.Inject;

import io.helidon.microprofile.server.ServerCdiExtension;
import io.helidon.microprofile.tests.junit5.Configuration;
import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.Configuration;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import {{package}}.client.api.ApiException;
import {{package}}.client.api.GreetApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import jakarta.enterprise.inject.Alternative;
import jakarta.inject.Inject;

import io.helidon.microprofile.server.ServerCdiExtension;
import io.helidon.microprofile.tests.junit5.AddBean;
import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.AddBean;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import com.oracle.bmc.Region;
import com.oracle.bmc.loggingingestion.Logging;
Expand Down
4 changes: 2 additions & 2 deletions archetypes/helidon/src/main/archetype/mp/oci/oci-mp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ ocimetrics:
<value key="scope">test</value>
</map>
<map order="0">
<value key="groupId">io.helidon.microprofile.tests</value>
<value key="artifactId">helidon-microprofile-tests-junit5</value>
<value key="groupId">io.helidon.microprofile.testing</value>
<value key="artifactId">helidon-microprofile-testing-junit5</value>
<value key="scope">test</value>
</map>
<map order="0">
Expand Down
8 changes: 4 additions & 4 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -964,13 +964,13 @@
</dependency>
<!-- Testing -->
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-testng</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-testng</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
Expand Down
18 changes: 9 additions & 9 deletions docs/mp/guides/testing-junit5.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2021, 2022 Oracle and/or its affiliates.
Copyright (c) 2021, 2023 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,8 +40,8 @@ To start using this feature, add the following dependencies to the testing modul
----
<dependencies>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -64,7 +64,7 @@ First you'll need to create a test class with an empty test method, and annotate
[source,java]
.Test Class
----
import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -217,11 +217,11 @@ If you want just the basic test features enabled, then you only have to add a fe
import jakarta.inject.Inject;

import io.helidon.microprofile.config.ConfigCdiExtension;
import io.helidon.microprofile.tests.junit5.AddBean;
import io.helidon.microprofile.tests.junit5.AddConfig;
import io.helidon.microprofile.tests.junit5.AddExtension;
import io.helidon.microprofile.tests.junit5.DisableDiscovery;
import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.AddBean;
import io.helidon.microprofile.testing.junit5.AddConfig;
import io.helidon.microprofile.testing.junit5.AddExtension;
import io.helidon.microprofile.testing.junit5.DisableDiscovery;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.junit.jupiter.api.Test;
Expand Down
18 changes: 9 additions & 9 deletions docs/mp/testing-ng.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2022 Oracle and/or its affiliates.
Copyright (c) 2022, 2023 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,20 +40,20 @@ include::{rootdir}/includes/dependencies.adoc[]
[source,xml]
----
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-testng</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-testng</artifactId>
<scope>test</scope>
</dependency>
----

== Usage - default
A test can be annotated with `io.helidon.microprofile.tests.testng.HelidonTest` annotation to mark it as a
A test can be annotated with `io.helidon.microprofile.testing.testng.HelidonTest` annotation to mark it as a
CDI test. This annotation will start the CDI container before any test method is invoked, and stop it after
the last method is invoked. This annotation also enables injection into the test class itself.

== Usage

A test can be annotated with `io.helidon.microprofile.tests.testng.HelidonTest` annotation to mark it as a
A test can be annotated with `io.helidon.microprofile.testing.testng.HelidonTest` annotation to mark it as a
CDI test. This annotation will start the CDI container before any test method is invoked, and stop it after
the last method is invoked. This annotation also enables injection into the test class itself.

Expand Down Expand Up @@ -97,16 +97,16 @@ In addition to this simplification, the following annotations are supported:
|===
|Annotation | Usage

|`@io.helidon.microprofile.tests.testng.AddBean`
|`@io.helidon.microprofile.testing.testng.AddBean`
|Used to add one or more beans to the container (if not part of a bean archive, or when discovery is disabled)

|`@io.helidon.microprofile.tests.testng.AddExtension`
|`@io.helidon.microprofile.testing.testng.AddExtension`
|Used to add one or more CDI extensions to the container (if not added through service loader, or when discovery is disabled)

|`@io.helidon.microprofile.tests.testng.AddConfig`
|`@io.helidon.microprofile.testing.testng.AddConfig`
|Used to add one or more configuration properties to MicroProfile config without the need of creating a `microprofile-config.properties` file

|`@io.helidon.microprofile.tests.testng.DisableDiscovery`
|`@io.helidon.microprofile.testing.testng.DisableDiscovery`
|Used to disable automated discovery of beans and extensions
|===

Expand Down
16 changes: 8 additions & 8 deletions docs/mp/testing.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2020, 2022 Oracle and/or its affiliates.
Copyright (c) 2020, 2023 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,14 +41,14 @@ include::{rootdir}/includes/dependencies.adoc[]
[source,xml]
----
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
----

== Usage
A test can be annotated with `io.helidon.microprofile.tests.junit5.HelidonTest` annotation to mark it as a
A test can be annotated with `io.helidon.microprofile.testing.junit5.HelidonTest` annotation to mark it as a
CDI test. This annotation will start the CDI container before any test method is invoked, and stop it after
the last method is invoked. This annotation also enables injection into the test class itself.

Expand Down Expand Up @@ -102,16 +102,16 @@ In addition to this simplification, the following annotations are supported:
|===
|Annotation | Usage

|`@io.helidon.microprofile.tests.junit5.AddBean`
|`@io.helidon.microprofile.testing.junit5.AddBean`
|Used to add one or more beans to the container (if not part of a bean archive, or when discovery is disabled)

|`@io.helidon.microprofile.tests.junit5.AddExtension`
|`@io.helidon.microprofile.testing.junit5.AddExtension`
|Used to add one or more CDI extensions to the container (if not added through service loader, or when discovery is disabled)

|`@io.helidon.microprofile.tests.junit5.AddConfig`
|`@io.helidon.microprofile.testing.junit5.AddConfig`
|Used to add one or more configuration properties to MicroProfile config without the need of creating a `microprofile-config.properties` file

|Used `@io.helidon.microprofile.tests.junit5.DisableDiscovery`
|Used `@io.helidon.microprofile.testing.junit5.DisableDiscovery`
|to disable automated discovery of beans and extensions
|===

Expand Down
4 changes: 2 additions & 2 deletions examples/integrations/micrometer/mp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.helidon.examples.integrations.micrometer.mp;

import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
Expand Down
4 changes: 2 additions & 2 deletions examples/integrations/micronaut/data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.helidon.examples.integrations.micronaut.data;

import io.helidon.examples.integrations.micronaut.data.model.Pet;
import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import jakarta.inject.Inject;
import jakarta.json.JsonArray;
Expand Down
4 changes: 2 additions & 2 deletions examples/integrations/microstream/greetings-mp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.nio.file.Path;

import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import jakarta.inject.Inject;
import jakarta.ws.rs.client.WebTarget;
Expand Down
4 changes: 2 additions & 2 deletions examples/integrations/oci/vault-cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions examples/jbatch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,19 +14,22 @@
* limitations under the License.
*/
package io.helidon.examples.jbatch;
import io.helidon.microprofile.tests.junit5.HelidonTest;
import jakarta.json.Json;
import jakarta.json.JsonBuilderFactory;
import org.junit.jupiter.api.Test;

import java.util.Collections;

import io.helidon.microprofile.testing.junit5.HelidonTest;

import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonBuilderFactory;
import jakarta.json.JsonObject;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.MediaType;
import org.junit.jupiter.api.Test;

import java.util.Collections;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;

@HelidonTest
Expand Down
4 changes: 2 additions & 2 deletions examples/metrics/filtering/mp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import java.time.Duration;

import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import jakarta.inject.Inject;
import org.eclipse.microprofile.metrics.Counter;
Expand Down
Loading