Skip to content
Open
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
17 changes: 15 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@ updates:
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 15
open-pull-requests-limit: 20
target-branch: master
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 20
target-branch: "5.0"
- package-ecosystem: maven
directory: "/"
schedule:
interval: monthly
open-pull-requests-limit: 20
target-branch: master
- package-ecosystem: maven
directory: "/"
schedule:
interval: monthly
open-pull-requests-limit: 10
open-pull-requests-limit: 20
target-branch: "5.0"
13 changes: 4 additions & 9 deletions .github/workflows/ci-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
build-weld-junit:
name: "Weld Testing build, JDK ${{matrix.java.name}}, JUnit ${{matrix.junit.name}}"
name: "Weld Testing build, JDK ${{matrix.java.name}}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -20,14 +20,9 @@ jobs:
name: "21",
java-version: 21,
}
junit:
- {
name: "5.x",
profile: "junit5",
}
- {
name: "6.x",
profile: "junit6",
name: "25",
java-version: 25,
}
steps:
- uses: actions/checkout@v6
Expand All @@ -50,7 +45,7 @@ jobs:
# after the job is done. In this case we refresh the cache monthly (by changing key) to avoid unlimited growth.
key: q2maven-master-${{ steps.get-date.outputs.date }}
- name: Build with Maven
run: WELD_JUNIT_DEBUG=spotbugs mvn clean install -Dno-format -Dspotbugs.failOnError=true -D${{matrix.junit.profile}}
run: WELD_JUNIT_DEBUG=spotbugs mvn clean install -Dno-format -Dspotbugs.failOnError=true
- name: Delete Local Artifacts From Cache
shell: bash
run: rm -r ~/.m2/repository/org/jboss/weld/weld-junit*
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Simulating field injection to start with, then interceptors and/or decorators -
There are frameworks to make this easier such as [Mockito](http://site.mockito.org/); but use too many mocks and things get tangled real quick.
So we came with JUnit/Spock extensions which allow you to use actual CDI container instead of complex simulations.
There is no need to change the way you develop your CDI components if you have a real container to test it with.
Besides, it's easy to combine this approach with mocking frameworks (see for instance [Adding mock beans](junit5/README.md#adding-mock-beans)).
Besides, it's easy to combine this approach with mocking frameworks (see for instance [Adding mock beans](junit-jupiter/README.md#adding-mock-beans)).

## How To Use Each Extension

Expand All @@ -34,7 +34,7 @@ Below is a list with links to detailed README of each extension:
* JUnit 4 extension
* [JUnit 4 extension using `@Rule` and `@ClassRule` mechanism](junit4/README.md)
* JUnit 5
* [JUnit 5 extension using the `@ExtendWith` mechanism](junit5/README.md)
* [JUnit 5 extension using the `@ExtendWith` mechanism](junit-jupiter/README.md)
* JUnit-common
* Houses the parts of code shared by both Junit extensions
* Spock
Expand Down
2 changes: 1 addition & 1 deletion junit-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-junit-parent</artifactId>
<version>5.0.4-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
</parent>

<artifactId>weld-junit-common</artifactId>
Expand Down
File renamed without changes.
26 changes: 13 additions & 13 deletions junit5/README.md → junit-jupiter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Requirements are JUnit 5 and Java 17.
```xml
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-junit5</artifactId>
<artifactId>weld-junit-jupiter</artifactId>
<version>${version.weld-junit}</version>
</dependency>
```
Expand Down Expand Up @@ -94,7 +94,7 @@ This default behaviour includes:
* Shut down the container after test is done

```java
import org.jboss.weld.junit5.WeldJunit5Extension;
import org.jboss.weld.junit.jupiter.WeldJunit5Extension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -113,19 +113,19 @@ class BasicUsageTest {

### WeldInitiator

`org.jboss.weld.junit5.WeldInitiator` is an entry point you will want to define if you wish to customize how we bootstrap Weld.
`org.jboss.weld.junit.jupiter.WeldInitiator` is an entry point you will want to define if you wish to customize how we bootstrap Weld.
The container is configured through a provided `org.jboss.weld.environment.se.Weld` instance.
By default, the container is optimized for testing purposes, i.e. with automatic discovery and concurrent deployment disabled (see also `WeldInitiator.createWeld()`).
However, it is possible to provide a customized `Weld` instance - see also `WeldInitiator.of(Weld)` and `WeldInitiator.from(Weld)` methods.
`WeldInitiator` also implements `jakarta.enterprise.inject.Instance` and therefore might be used to perform programmatic lookup of bean instances.

`WeldInitiator` should be available in a field annotated with `@org.jboss.weld.junit5.WeldSetup`.
`WeldInitiator` should be available in a field annotated with `@org.jboss.weld.junit.jupiter.WeldSetup`.
From there you can use static methods:

```java
import org.jboss.weld.junit5.WeldInitiator;
import org.jboss.weld.junit5.WeldJunit5Extension;
import org.jboss.weld.junit5.WeldSetup;
import org.jboss.weld.junit.jupiter.WeldInitiator;
import org.jboss.weld.junit.jupiter.WeldJunit5Extension;
import org.jboss.weld.junit.jupiter.WeldSetup;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand Down Expand Up @@ -513,8 +513,8 @@ By default, the extension will:
Here is a simple example using the default plus one additional annotation (`@AddPackages`):

```java
import org.jboss.weld.junit5.auto.beans.Engine;
import org.jboss.weld.junit5.auto.beans.V8;
import org.jboss.weld.junit.jupiter.auto.beans.Engine;
import org.jboss.weld.junit.jupiter.auto.beans.V8;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -600,8 +600,8 @@ It will not exclude beans of the implied type that are defined by `@Produces` pr
Also, the current implementation excludes beans based on type, disregarding any qualifiers that are specified.

```java
import org.jboss.weld.junit5.auto.ExcludeBean;
import org.jboss.weld.junit5.auto.WeldJunit5AutoExtension;
import org.jboss.weld.junit.jupiter.auto.ExcludeBean;
import org.jboss.weld.junit.jupiter.auto.WeldJunit5AutoExtension;
import org.junit.jupiter.api.Test;

import jakarta.enterprise.inject.Produces;
Expand Down Expand Up @@ -652,8 +652,8 @@ This is mainly for usability, as it would be annoying to constantly type additio
However, we are aware that this might cause trouble if more extensions are competing for parameter resolution.
In such case, you can turn on explicit parameter resolution and Weld will only resolve parameters which have at least one `jakarta.inject.Qualifier` annotation on them.
There are two ways to enable it:
* First option is enabling this globally through a system property - `org.jboss.weld.junit5.explicitParamInjection=true`
This property is also available as a constant in our extension class; you can therefore refer to it via `org.jboss.weld.junit5.WeldJunit5Extension.GLOBAL_EXPLICIT_PARAM_INJECTION`.
* First option is enabling this globally through a system property - `org.jboss.weld.junit.jupiter.explicitParamInjection=true`
This property is also available as a constant in our extension class; you can therefore refer to it via `org.jboss.weld.junit.jupiter.WeldJunit5Extension.GLOBAL_EXPLICIT_PARAM_INJECTION`.
* The other approach is to use `@ExplicitParamInjection(boolean)` on either test method, or test class.
In case of test class this annotation will enforce the presence on qualifiers on all methods.

Expand Down
6 changes: 3 additions & 3 deletions junit5/pom.xml → junit-jupiter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<name>Weld JUnit 5 Extensions</name>
<name>Weld JUnit Jupiter Extensions</name>

<parent>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-junit-parent</artifactId>
<version>5.0.4-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
</parent>

<artifactId>weld-junit5</artifactId>
<artifactId>weld-junit-jupiter</artifactId>

<dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5;
package org.jboss.weld.junit.jupiter;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5;
package org.jboss.weld.junit.jupiter;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5;
package org.jboss.weld.junit.jupiter;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5;
package org.jboss.weld.junit.jupiter;

import java.lang.annotation.Annotation;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5;

import static org.jboss.weld.junit5.ExtensionContextUtils.getContainerFromStore;
import static org.jboss.weld.junit5.ExtensionContextUtils.getEnrichersFromStore;
import static org.jboss.weld.junit5.ExtensionContextUtils.getExplicitInjectionInfoFromStore;
import static org.jboss.weld.junit5.ExtensionContextUtils.getInitiatorFromStore;
import static org.jboss.weld.junit5.ExtensionContextUtils.removeContainerFromStore;
import static org.jboss.weld.junit5.ExtensionContextUtils.setContainerToStore;
import static org.jboss.weld.junit5.ExtensionContextUtils.setEnrichersToStore;
import static org.jboss.weld.junit5.ExtensionContextUtils.setExplicitInjectionInfoToStore;
import static org.jboss.weld.junit5.ExtensionContextUtils.setInitiatorToStore;
package org.jboss.weld.junit.jupiter;

import static org.jboss.weld.junit.jupiter.ExtensionContextUtils.getContainerFromStore;
import static org.jboss.weld.junit.jupiter.ExtensionContextUtils.getEnrichersFromStore;
import static org.jboss.weld.junit.jupiter.ExtensionContextUtils.getExplicitInjectionInfoFromStore;
import static org.jboss.weld.junit.jupiter.ExtensionContextUtils.getInitiatorFromStore;
import static org.jboss.weld.junit.jupiter.ExtensionContextUtils.removeContainerFromStore;
import static org.jboss.weld.junit.jupiter.ExtensionContextUtils.setContainerToStore;
import static org.jboss.weld.junit.jupiter.ExtensionContextUtils.setEnrichersToStore;
import static org.jboss.weld.junit.jupiter.ExtensionContextUtils.setExplicitInjectionInfoToStore;
import static org.jboss.weld.junit.jupiter.ExtensionContextUtils.setInitiatorToStore;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_METHOD;

Expand Down Expand Up @@ -96,7 +96,7 @@ public class WeldJunit5Extension implements AfterAllCallback, BeforeAllCallback,
BeforeEachCallback, AfterEachCallback, ParameterResolver {

// global system property
public static final String GLOBAL_EXPLICIT_PARAM_INJECTION = "org.jboss.weld.junit5.explicitParamInjection";
public static final String GLOBAL_EXPLICIT_PARAM_INJECTION = "org.jboss.weld.junit.jupiter.explicitParamInjection";

private static void storeExplicitParamResolutionInformation(ExtensionContext ec) {
// check system property which may have set the global explicit param injection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5;
package org.jboss.weld.junit.jupiter;

import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.junit5.WeldInitiator.Builder;
import org.jboss.weld.junit.jupiter.WeldInitiator.Builder;
import org.junit.jupiter.api.extension.ExtensionContext;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5;
package org.jboss.weld.junit.jupiter;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.reflect.Type;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.weld.junit5.auto;
package org.jboss.weld.junit.jupiter.auto;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
Expand Down
Loading
Loading