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
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
56 changes: 34 additions & 22 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
name: Build, test and deploy

on: [push, pull_request]
on:
push:
branches: [ '*' ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [8, 11]
java: [17, 21]
name: Java ${{ matrix.java }}
env:
CC_TEST_REPORTER_ID: 47b239597faea3da257baa211d7438ff8ba9047319a2c687110f4f8e41bb07f1
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Build with Maven
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: ./mvnw install --no-transfer-progress -DskipTests=true -Dmaven.javadoc.skip=true -B -V
id: mvnInstall
- name: Run tests
run: mvn test -B
run: ./mvnw test jacoco:report-aggregate -B
id: mvnTest
- name: Record coverage
run: |
mvn clean cobertura:cobertura coveralls:report
# if: startsWith(matrix.java, 8)
# - name: Deploy to Github packages
# env:
# token: ${{ secrets.GITHUB_TOKEN }}
# packagesUrl: https://maven.pkg.github.com/zapodot
# run: |
# mvn deploy -Dregistry=$packagesUrl -Dtoken=$token
# id: deployGithubPackages
# if: startsWith(matrix.java, 11)

- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ join(matrix.*, '-') }}
debug: true
compare-ref: master
parallel: true
finish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: "run-17,run-21"
19 changes: 19 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
15 changes: 8 additions & 7 deletions embedded-jms-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>embedded-jms-parent</artifactId>
<groupId>org.zapodot</groupId>
<version>0.3-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -30,21 +30,22 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>

</dependencies>
<build>
<plugins>
Expand Down
11 changes: 1 addition & 10 deletions embedded-jms-junit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.zapodot</groupId>
<artifactId>embedded-jms-parent</artifactId>
<version>0.3-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -82,15 +82,6 @@
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>

</plugins>
</build>
<profiles>
Expand Down
10 changes: 1 addition & 9 deletions embedded-jms-junit5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.zapodot</groupId>
<artifactId>embedded-jms-parent</artifactId>
<version>0.3-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -84,14 +84,6 @@
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

import com.google.common.base.Strings;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolver;
import org.junit.jupiter.api.extension.TestInstancePostProcessor;
import org.junit.jupiter.api.extension.*;
import org.junit.platform.commons.util.AnnotationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -35,8 +30,6 @@ public class EmbeddedJmsBroker implements BeforeEachCallback, AfterEachCallback,
private static final ExtensionContext.Namespace EMBEDDED_JMS_EXT = ExtensionContext.Namespace
.create("org.zapodot.junit5.jms");

private static final String TEST_INSTANCE = "TestInstance";

private static final String STORE_EMBEDDED_JMS_BROKER = "EmbeddedJmsBroker";

private static final String STORE_BROKER_CONFIGURATION = "BrokerConfiguration";
Expand Down Expand Up @@ -171,18 +164,11 @@ public void beforeEach(final ExtensionContext context) {
final EmbeddedJMSBrokerHolder embeddedJmsBrokerHolder = getOrCreateEmbeddedJMSBrokerHolder(context);
embeddedJmsBrokerHolder.start();

Object testInstance = context.getStore(EMBEDDED_JMS_EXT).get(TEST_INSTANCE);
if (testInstance == null) {
testInstance = context.getTestInstance().orElse(null);
}
Optional.ofNullable(testInstance)
.ifPresent(ti -> FieldInjector.injectToInstance(ti, embeddedJmsBrokerHolder));
context.getTestInstances().ifPresent(instance -> FieldInjector.injectToInstance(instance, embeddedJmsBrokerHolder));
}

@Override
public void postProcessTestInstance(final Object testInstance, final ExtensionContext context) {
LOGGER.debug("postProcessTestInstance instance: \"{}\"", testInstance);
context.getStore(EMBEDDED_JMS_EXT).put(TEST_INSTANCE, testInstance);

createBrokerConfigurationFromContext(context)
.ifPresent(c -> context.getStore(EMBEDDED_JMS_EXT).put(STORE_BROKER_CONFIGURATION, c));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.zapodot.junit5.jms.internal;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.platform.commons.util.ReflectionUtils;
import org.junit.jupiter.api.extension.TestInstances;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zapodot.jms.common.EmbeddedJMSBrokerHolder;

import javax.jms.ConnectionFactory;
import java.lang.reflect.Field;
import java.net.URI;
import java.util.Optional;

/**
* FieldInjector - part of the internal API. May be removed, moved or changed without prior deprecation
Expand All @@ -22,20 +21,11 @@ private FieldInjector() {
// Constructor added to avoid instantiation
}

public static void injectToInstance(final Object instance, final EmbeddedJMSBrokerHolder embeddedJMSBrokerHolder) {
if (instance.getClass().isMemberClass()) {
tryToFindOuterInstance(instance)
.ifPresent(i -> injectToInstance(i, embeddedJMSBrokerHolder));
}
InjectableFieldsAccessor.findInjectableFields(instance.getClass())
.stream()
.forEach(field -> injectConnectionFactoryOrURI(instance,
field,
embeddedJMSBrokerHolder));
}

private static Optional<Object> tryToFindOuterInstance(final Object innerInstance) {
return ReflectionUtils.getOutermostInstance(innerInstance, innerInstance.getClass().getDeclaringClass());
public static void injectToInstance(final TestInstances testInstances, final EmbeddedJMSBrokerHolder embeddedJMSBrokerHolder) {
testInstances.getAllInstances().forEach(testInstance -> {
InjectableFieldsAccessor.findInjectableFields(testInstance.getClass())
.forEach(field -> injectConnectionFactoryOrURI(testInstance, field, embeddedJMSBrokerHolder));
});
}

private static void injectConnectionFactoryOrURI(final Object instance,
Expand Down
Loading
Loading