diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf01..41d9927a4 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fcea..ae04661ee 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 83f2acfdc..1b6c78733 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,78 +17,113 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -105,84 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9618d8d96..107acd32c 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/springwolf-add-ons/springwolf-common-model-converters/build.gradle b/springwolf-add-ons/springwolf-common-model-converters/build.gradle index bf55a373e..fd2574842 100644 --- a/springwolf-add-ons/springwolf-common-model-converters/build.gradle +++ b/springwolf-add-ons/springwolf-common-model-converters/build.gradle @@ -3,8 +3,8 @@ plugins { id 'signing' id 'maven-publish' - id 'org.springframework.boot' version '2.1.1.RELEASE' - id 'io.spring.dependency-management' version '1.0.6.RELEASE' + id 'org.springframework.boot' version '2.7.6' + id 'io.spring.dependency-management' version '1.1.0' } def isSnapshot = Boolean.valueOf(project.findProperty('SNAPSHOT')) @@ -19,7 +19,7 @@ repositories { dependencies { implementation 'org.javamoney.moneta:moneta-core:1.4.2' - implementation 'io.swagger.core.v3:swagger-core:2.2.0' + implementation 'io.swagger.core.v3:swagger-core:2.2.7' implementation 'org.springframework:spring-context' @@ -29,10 +29,6 @@ dependencies { testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' } -test { - useJUnitPlatform() -} - jar.enabled = true bootJar.enabled = false @@ -41,6 +37,10 @@ java { withSourcesJar() } +test { + useJUnitPlatform() +} + publishing { publications { mavenJava(MavenPublication) { diff --git a/springwolf-core/build.gradle b/springwolf-core/build.gradle index d423320d5..d96778441 100644 --- a/springwolf-core/build.gradle +++ b/springwolf-core/build.gradle @@ -4,8 +4,8 @@ plugins { id 'signing' id 'maven-publish' - id 'org.springframework.boot' version '2.1.18.RELEASE' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'org.springframework.boot' version '2.7.6' + id 'io.spring.dependency-management' version '1.1.0' } def isSnapshot = Boolean.valueOf(project.findProperty('SNAPSHOT')) @@ -22,6 +22,8 @@ dependencies { api 'com.asyncapi:asyncapi-core:1.0.0-EAP' implementation 'io.swagger:swagger-inflector:2.0.8' + implementation 'io.swagger.core.v3:swagger-core:2.2.7' + implementation 'io.swagger.parser.v3:swagger-parser-core:2.1.9' implementation 'org.springframework:spring-web' implementation 'org.springframework:spring-context' @@ -29,18 +31,16 @@ dependencies { implementation 'org.springframework.boot:spring-boot-autoconfigure' implementation 'com.google.guava:guava:31.1-jre' - implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.10.8' - implementation 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.2' - compileOnly 'org.projectlombok:lombok:1.18.22' - annotationProcessor 'org.projectlombok:lombok:1.18.22' + compileOnly 'org.projectlombok:lombok:1.18.24' + annotationProcessor 'org.projectlombok:lombok:1.18.24' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' - testImplementation 'org.projectlombok:lombok:1.18.22' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' + testImplementation 'org.projectlombok:lombok:1.18.24' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.24' - testImplementation 'org.assertj:assertj-core:3.21.0' + testImplementation 'org.assertj:assertj-core:3.23.1' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.amqp:spring-rabbit' @@ -55,6 +55,10 @@ java { withSourcesJar() } +test { + useJUnitPlatform() +} + publishing { publications { mavenJava(MavenPublication) { @@ -113,6 +117,6 @@ publishing { signing { def signingKey = project.findProperty("SIGNINGKEY") def signingPassword = project.findProperty("SIGNINGPASSWORD") - useInMemoryPgpKeys (signingKey, signingPassword) + useInMemoryPgpKeys(signingKey, signingPassword) sign publishing.publications.mavenJava } diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/SpringPayloadAnnotationTypeExtractor.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/SpringPayloadAnnotationTypeExtractor.java index c53211108..6cbc56b2b 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/SpringPayloadAnnotationTypeExtractor.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/SpringPayloadAnnotationTypeExtractor.java @@ -2,10 +2,10 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.handler.annotation.Payload; -import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl; import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Arrays; import java.util.List; @@ -31,7 +31,7 @@ static Class getPayloadParameterClass(Method method, Class[] parameterType try { // Resolve generic type for batch listeners if (parameterClass == List.class) { - Type type = ((ParameterizedTypeImpl) method.getGenericParameterTypes()[parameterPayloadIndex]).getActualTypeArguments()[0]; + Type type = ((ParameterizedType) method.getGenericParameterTypes()[parameterPayloadIndex]).getActualTypeArguments()[0]; return Class.forName(type.getTypeName()); } } catch (Exception ex) { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/SpringContextTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/SpringContextTest.java index e075c061f..e1de9e1d8 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/SpringContextTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/SpringContextTest.java @@ -6,24 +6,22 @@ import io.github.stavshamir.springwolf.asyncapi.DefaultChannelsService; import io.github.stavshamir.springwolf.configuration.DefaultAsyncApiDocketService; import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@RunWith(Enclosed.class) public class SpringContextTest { - @RunWith(SpringRunner.class) + @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { CustomBeanAsyncApiDocketConfiguration.class, // user has defined an own AsyncApiDocket bean DefaultAsyncApiDocketService.class, @@ -48,7 +46,7 @@ public void testContextWithAsyncApiDocketBean() { } } - @RunWith(SpringRunner.class) + @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { DefaultAsyncApiDocketService.class, DefaultAsyncApiService.class, diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceTest.java index bc08f77cf..eab9f0f18 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceTest.java @@ -18,20 +18,20 @@ import lombok.Data; import org.apache.commons.io.IOUtils; import org.json.JSONException; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Map; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {DefaultAsyncApiSerializerService.class}) public class DefaultAsyncApiSerializerServiceTest { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiServiceTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiServiceTest.java index 195efa699..e7d964b7a 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiServiceTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiServiceTest.java @@ -13,20 +13,20 @@ import io.github.stavshamir.springwolf.configuration.AsyncApiDocket; import io.github.stavshamir.springwolf.configuration.DefaultAsyncApiDocketService; import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { DefaultAsyncApiDocketService.class, DefaultAsyncApiService.class, diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultChannelsServiceTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultChannelsServiceTest.java index 53fcd0e31..304633b1b 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultChannelsServiceTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultChannelsServiceTest.java @@ -4,18 +4,18 @@ import com.asyncapi.v2.model.channel.operation.Operation; import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelsScanner; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { DefaultChannelsService.class, DefaultChannelsServiceTest.FooChannelScanner.class, diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/MessageHelperTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/MessageHelperTest.java index b4ff8575e..79ac061e3 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/MessageHelperTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/MessageHelperTest.java @@ -3,7 +3,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Collections; import java.util.Map; diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/beans/DefaultBeanMethodsScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/beans/DefaultBeanMethodsScannerTest.java index 29d0cf0eb..e9bca9a95 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/beans/DefaultBeanMethodsScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/beans/DefaultBeanMethodsScannerTest.java @@ -2,13 +2,13 @@ import com.google.common.collect.ImmutableSet; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ConfigurationClassScanner; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.lang.reflect.Method; import java.util.Set; @@ -18,7 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {DefaultBeanMethodsScanner.class}) public class DefaultBeanMethodsScannerTest { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/ChannelMergerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/ChannelMergerTest.java index f66a59c47..7c1f869be 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/ChannelMergerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/ChannelMergerTest.java @@ -7,7 +7,7 @@ import com.google.common.collect.Sets; import io.github.stavshamir.springwolf.asyncapi.MessageHelper; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Map; diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScannerTest.java index f6ef54729..d6c041a03 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/TestMethodLevelListenerScannerTest.java @@ -13,12 +13,12 @@ import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; import lombok.Data; import lombok.NoArgsConstructor; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {TestMethodLevelListenerScanner.class, DefaultSchemasService.class}) public class TestMethodLevelListenerScannerTest { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ConsumerOperationDataScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ConsumerOperationDataScannerTest.java index 2e9aaad35..95fe3d926 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ConsumerOperationDataScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ConsumerOperationDataScannerTest.java @@ -16,12 +16,12 @@ import io.github.stavshamir.springwolf.configuration.AsyncApiDocket; import io.github.stavshamir.springwolf.configuration.AsyncApiDocketService; import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Collection; import java.util.Map; @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {ConsumerOperationDataScanner.class, DefaultSchemasService.class}) public class ConsumerOperationDataScannerTest { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProducerOperationDataScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProducerOperationDataScannerTest.java index 7b20a3f6b..00f5a8333 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProducerOperationDataScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProducerOperationDataScannerTest.java @@ -16,12 +16,12 @@ import io.github.stavshamir.springwolf.configuration.AsyncApiDocket; import io.github.stavshamir.springwolf.configuration.AsyncApiDocketService; import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Collection; import java.util.Map; @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {ProducerOperationDataScanner.class, DefaultSchemasService.class}) public class ProducerOperationDataScannerTest { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerTest.java index c8d9ea41c..f123a663c 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerTest.java @@ -12,13 +12,13 @@ import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; import lombok.Data; import lombok.NoArgsConstructor; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Map; import java.util.Set; @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {AsyncListenerAnnotationScanner.class, DefaultSchemasService.class, TestOperationBindingProcessor.class}) @TestPropertySource(properties = {"test.property.test-channel=test-channel", "test.property.description=description"}) public class AsyncListenerAnnotationScannerTest { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerTest.java index 286e1e4b0..2c1b6b23f 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerTest.java @@ -12,13 +12,13 @@ import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; import lombok.Data; import lombok.NoArgsConstructor; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Map; import java.util.Set; @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {AsyncPublisherAnnotationScanner.class, DefaultSchemasService.class, TestOperationBindingProcessor.class}) @TestPropertySource(properties = {"test.property.test-channel=test-channel", "test.property.description=description"}) public class AsyncPublisherAnnotationScannerTest { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/classes/ComponentClassScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/classes/ComponentClassScannerTest.java index 8791b7187..19724080f 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/classes/ComponentClassScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/classes/ComponentClassScannerTest.java @@ -3,19 +3,19 @@ import com.asyncapi.v2.model.info.Info; import io.github.stavshamir.springwolf.configuration.AsyncApiDocket; import io.github.stavshamir.springwolf.configuration.AsyncApiDocketService; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {ComponentClassScanner.class}) public class ComponentClassScannerTest { @MockBean diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/classes/ConfigurationClassScannerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/classes/ConfigurationClassScannerTest.java index eb263e488..3faa49451 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/classes/ConfigurationClassScannerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/classes/ConfigurationClassScannerTest.java @@ -3,19 +3,19 @@ import com.asyncapi.v2.model.info.Info; import io.github.stavshamir.springwolf.configuration.AsyncApiDocket; import io.github.stavshamir.springwolf.configuration.AsyncApiDocketService; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {ConfigurationClassScanner.class}) public class ConfigurationClassScannerTest { diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/serializers/KafkaOperationBindingSerializerTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/serializers/KafkaOperationBindingSerializerTest.java index 669886f38..27dac1653 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/serializers/KafkaOperationBindingSerializerTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/serializers/KafkaOperationBindingSerializerTest.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import org.json.JSONException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/configuration/DefaultAsyncApiDocketServiceIntegrationTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/configuration/DefaultAsyncApiDocketServiceIntegrationTest.java index 0b4c92ed0..d457db1ff 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/configuration/DefaultAsyncApiDocketServiceIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/configuration/DefaultAsyncApiDocketServiceIntegrationTest.java @@ -3,9 +3,8 @@ import com.asyncapi.v2.model.info.Info; import com.asyncapi.v2.model.server.Server; import io.github.stavshamir.springwolf.SpringWolfConfigProperties; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.TestConfiguration; @@ -13,14 +12,13 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Enclosed.class) public class DefaultAsyncApiDocketServiceIntegrationTest { - @RunWith(SpringRunner.class) + @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { DefaultAsyncApiDocketService.class, }) @@ -46,7 +44,7 @@ public void testDocketContentShouldBeLoadedFromProperties() { } } - @RunWith(SpringRunner.class) + @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { DefaultAsyncApiDocketService.class, }) diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/configuration/DefaultAsyncApiDocketServiceTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/configuration/DefaultAsyncApiDocketServiceTest.java index 4033baa9a..ba6df9e88 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/configuration/DefaultAsyncApiDocketServiceTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/configuration/DefaultAsyncApiDocketServiceTest.java @@ -7,7 +7,7 @@ import io.github.stavshamir.springwolf.SpringWolfConfigProperties; import io.github.stavshamir.springwolf.SpringWolfConfigProperties.ConfigDocket; import io.github.stavshamir.springwolf.SpringWolfConfigProperties.ConfigDocket.Info; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Optional; diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultSchemasServiceTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultSchemasServiceTest.java index 702b832c1..7ddc10dd3 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultSchemasServiceTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultSchemasServiceTest.java @@ -7,7 +7,7 @@ import lombok.NoArgsConstructor; import org.apache.commons.io.IOUtils; import org.json.JSONException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; @@ -17,7 +17,7 @@ import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class DefaultSchemasServiceTest { diff --git a/springwolf-examples/springwolf-amqp-example/build.gradle b/springwolf-examples/springwolf-amqp-example/build.gradle index d98037af5..6cc92e61e 100644 --- a/springwolf-examples/springwolf-amqp-example/build.gradle +++ b/springwolf-examples/springwolf-amqp-example/build.gradle @@ -1,9 +1,10 @@ plugins { id 'java' - id 'org.springframework.boot' version '2.1.1.RELEASE' - id 'io.spring.dependency-management' version '1.0.6.RELEASE' - id 'com.bmuschko.docker-spring-boot-application' version '6.1.4' - id 'org.jetbrains.kotlin.jvm' version '1.3.61' + + id 'org.springframework.boot' version '2.7.6' + id 'io.spring.dependency-management' version '1.1.0' + + id 'com.bmuschko.docker-spring-boot-application' version '6.7.0' } sourceCompatibility = '1.8' @@ -22,18 +23,19 @@ repositories { dependencies { implementation project(":springwolf-plugins:springwolf-amqp-plugin") + compileOnly project(":springwolf-plugins:springwolf-amqp-plugin") + annotationProcessor project(":springwolf-plugins:springwolf-amqp-plugin") runtimeOnly 'io.github.springwolf:springwolf-ui:0.6.0' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.amqp:spring-rabbit' implementation 'com.google.guava:guava:31.1-jre' - implementation 'io.swagger.core.v3:swagger-core:2.2.0' + implementation 'org.slf4j:slf4j-api' + implementation 'io.swagger.core.v3:swagger-core:2.2.7' testImplementation 'org.springframework.boot:spring-boot-starter-test' - testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' - testImplementation 'org.jetbrains.kotlin:kotlin-reflect' - testImplementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.10.2' - testImplementation 'org.testcontainers:testcontainers:1.16.0' + testImplementation 'org.testcontainers:testcontainers:1.17.6' + testImplementation 'org.testcontainers:junit-jupiter:1.17.6' testImplementation 'org.skyscreamer:jsonassert:1.5.0' testImplementation 'org.apache.directory.studio:org.apache.commons.io:2.4' } @@ -52,16 +54,11 @@ docker { } } -compileTestKotlin { - kotlinOptions { - jvmTarget = "1.8" - } -} - - test { dependsOn dockerBuildImage + useJUnitPlatform() + testLogging { exceptionFormat = 'full' } diff --git a/springwolf-examples/springwolf-amqp-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleConsumer.java b/springwolf-examples/springwolf-amqp-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleConsumer.java index 914c2b83a..81eebe67a 100644 --- a/springwolf-examples/springwolf-amqp-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleConsumer.java +++ b/springwolf-examples/springwolf-amqp-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleConsumer.java @@ -2,8 +2,7 @@ import io.github.stavshamir.springwolf.example.dtos.AnotherPayloadDto; import io.github.stavshamir.springwolf.example.dtos.ExamplePayloadDto; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.ExchangeTypes; import org.springframework.amqp.rabbit.annotation.Exchange; import org.springframework.amqp.rabbit.annotation.Queue; @@ -12,18 +11,17 @@ import org.springframework.stereotype.Service; @Service +@Slf4j public class ExampleConsumer { - private static final Logger logger = LoggerFactory.getLogger(ExampleConsumer.class); - @RabbitListener(queues = "example-queue") public void receiveExamplePayload(ExamplePayloadDto payload) { - logger.info("Received new message in example-queue: {}", payload.toString()); + log.info("Received new message in example-queue: {}", payload.toString()); } @RabbitListener(queues = "another-queue") public void receiveAnotherPayload(AnotherPayloadDto payload) { - logger.info("Received new message in another-queue: {}", payload.toString()); + log.info("Received new message in another-queue: {}", payload.toString()); } @RabbitListener(bindings = { @@ -32,11 +30,11 @@ public void receiveAnotherPayload(AnotherPayloadDto payload) { value = @Queue(name = "example-bindings-queue")) }) public void bindingsExample(AnotherPayloadDto payload) { - logger.info("Received new message in example-bindings-queue: {}", payload.toString()); + log.info("Received new message in example-bindings-queue: {}", payload.toString()); } @RabbitListener(queues = "example-topic-queue") public void bindingsBeanExample(AnotherPayloadDto payload) { - logger.info("Received new message in example-topic-queue: {}", payload.toString()); + log.info("Received new message in example-topic-queue: {}", payload.toString()); } } diff --git a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTests.java b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTest.java similarity index 87% rename from springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTests.java rename to springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTest.java index a8b0e76c8..0598d531f 100644 --- a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTests.java +++ b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTest.java @@ -1,24 +1,21 @@ package io.github.stavshamir.springwolf.example; import org.json.JSONException; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.test.context.junit4.SpringRunner; import org.testcontainers.shaded.org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -@RunWith(SpringRunner.class) @SpringBootTest(classes = {SpringwolfExampleApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -public class ApiIntegrationTests { +public class ApiIntegrationTest { @Autowired private TestRestTemplate restTemplate; diff --git a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTest.java b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTest.java new file mode 100644 index 000000000..ba21905b8 --- /dev/null +++ b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTest.java @@ -0,0 +1,51 @@ +package io.github.stavshamir.springwolf.example; + +import org.apache.commons.io.IOUtils; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.springframework.web.client.RestTemplate; +import org.testcontainers.containers.DockerComposeContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +/** + * While the assertion of this test is identical to ApiIntegrationTests, + * the setup uses a full docker-compose context with a real kafka instance. + */ +@Testcontainers +// @Ignore("Uncomment this line if you have issues running this test on your local machine.") +public class ApiIntegrationWithDockerTest { + + private final static RestTemplate restTemplate = new RestTemplate(); + private final static String APP_NAME = "app_1"; + private final static int APP_PORT = 8080; + + @Container + public static DockerComposeContainer environment = new DockerComposeContainer<>(new File("docker-compose.yml")) + .withExposedService(APP_NAME, APP_PORT); + + private String baseUrl() { + String host = environment.getServiceHost(APP_NAME, APP_PORT); + int port = environment.getServicePort(APP_NAME, APP_PORT); + return String.format("http://%s:%d", host, port); + } + + @Test + public void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException, JSONException { + String url = baseUrl() + "/springwolf/docs"; + String actual = restTemplate.getForObject(url, String.class); + System.out.println("Got: " + actual); + + InputStream s = this.getClass().getResourceAsStream("/asyncapi.json"); + String expected = IOUtils.toString(s, StandardCharsets.UTF_8); + + JSONAssert.assertEquals(expected, actual, JSONCompareMode.STRICT_ORDER); + } +} diff --git a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java index a3955379d..9dfe99736 100644 --- a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java +++ b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java @@ -1,23 +1,18 @@ package io.github.stavshamir.springwolf.example; import io.github.stavshamir.springwolf.asyncapi.AsyncApiService; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@RunWith(Enclosed.class) public class SpringContextTest { - @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringwolfExampleApplication.class) public static class AsyncApiDocketTest { @@ -34,7 +29,6 @@ public void testContextWithAsyncApiDocketBean() { } } - @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringwolfExampleApplication.class) @TestPropertySource(properties = { "customAsyncApiDocketBean=false", diff --git a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java index 0fb6b7613..5ed809415 100644 --- a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java +++ b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java @@ -1,14 +1,13 @@ package io.github.stavshamir.springwolf.example; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@RunWith(SpringRunner.class) +@SpringBootTest public class SpringwolfExampleApplicationTest { @Autowired diff --git a/springwolf-examples/springwolf-amqp-example/src/test/kotlin/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTests.kt b/springwolf-examples/springwolf-amqp-example/src/test/kotlin/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTests.kt deleted file mode 100644 index 9ec4c78bc..000000000 --- a/springwolf-examples/springwolf-amqp-example/src/test/kotlin/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTests.kt +++ /dev/null @@ -1,53 +0,0 @@ -package io.github.stavshamir.springwolf.example - -import org.apache.commons.io.IOUtils -import org.junit.ClassRule -import org.junit.Test -import org.skyscreamer.jsonassert.JSONAssert -import org.skyscreamer.jsonassert.JSONCompareMode -import org.springframework.web.client.RestTemplate -import org.testcontainers.containers.DockerComposeContainer -import java.io.File -import java.io.InputStream -import java.nio.charset.StandardCharsets - -/** - * While the assertion of this test is identical to ApiIntegrationTests, - * the setup uses a full docker-compose context with a real amqp instance. - */ -// @Ignore("Uncomment this line if you have issues running this test on your local machine.") -class ApiIntegrationWithDockerTests { - - companion object { - private val restTemplate = RestTemplate() - - private const val APP_NAME = "app_1" - private const val APP_PORT = 8080 - - @JvmField - @ClassRule - val environment: DockerComposeContainer = DockerComposeContainer(File("docker-compose.yml")) - .withExposedService(APP_NAME, APP_PORT) - } - - private fun baseUrl(): String { - val host = environment.getServiceHost(APP_NAME, APP_PORT) - val port = environment.getServicePort(APP_NAME, APP_PORT) - return "http://$host:$port" - } - - @Test - fun `asyncapi-docs shold return the correct json response`() { - val url = "${baseUrl()}/springwolf/docs" - val actual = restTemplate.getForObject(url, String::class.java) - println("Got: $actual") - - val s: InputStream = this.javaClass.getResourceAsStream("/asyncapi.json") - val expected: String = IOUtils.toString(s, StandardCharsets.UTF_8) - - print(actual) - - JSONAssert.assertEquals(expected, actual, JSONCompareMode.STRICT_ORDER) - } - -} \ No newline at end of file diff --git a/springwolf-examples/springwolf-cloud-stream-example/build.gradle b/springwolf-examples/springwolf-cloud-stream-example/build.gradle index 68d5b5ef5..98103c68c 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/build.gradle +++ b/springwolf-examples/springwolf-cloud-stream-example/build.gradle @@ -1,8 +1,10 @@ plugins { id 'java' - id 'org.springframework.boot' version '2.7.5' + + id 'org.springframework.boot' version '2.7.6' id 'io.spring.dependency-management' version '1.1.0' - id 'com.bmuschko.docker-spring-boot-application' version '6.1.4' + + id 'com.bmuschko.docker-spring-boot-application' version '6.7.0' } ext { @@ -31,9 +33,9 @@ repositories { } dependencies { - implementation project(":springwolf-plugins:springwolf-kafka-plugin") implementation project(":springwolf-plugins:springwolf-cloud-stream-plugin") - implementation 'io.swagger.core.v3:swagger-core:2.2.0' + compileOnly project(":springwolf-plugins:springwolf-cloud-stream-plugin") + annotationProcessor project(":springwolf-plugins:springwolf-cloud-stream-plugin") runtimeOnly 'io.github.springwolf:springwolf-ui:0.6.0' implementation 'org.springframework.boot:spring-boot-starter-web' @@ -41,11 +43,13 @@ dependencies { implementation 'org.springframework.cloud:spring-cloud-stream-binder-kafka-streams' implementation 'org.apache.kafka:kafka-streams:3.1.2' implementation 'com.google.guava:guava:31.1-jre' - implementation 'io.swagger.core.v3:swagger-core:2.2.0' + implementation 'org.slf4j:slf4j-api' + implementation 'io.swagger.core.v3:swagger-core:2.2.7' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.kafka:spring-kafka-test' - testImplementation 'org.testcontainers:testcontainers:1.16.0' + testImplementation 'org.testcontainers:testcontainers:1.17.6' + testImplementation 'org.testcontainers:junit-jupiter:1.17.6' testImplementation 'org.skyscreamer:jsonassert:1.5.0' testImplementation 'org.apache.directory.studio:org.apache.commons.io:2.4' } @@ -67,6 +71,8 @@ docker { test { dependsOn dockerBuildImage + useJUnitPlatform() + testLogging { exceptionFormat = 'full' } diff --git a/springwolf-examples/springwolf-cloud-stream-example/src/main/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplication.java b/springwolf-examples/springwolf-cloud-stream-example/src/main/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplication.java index faeb98eba..0838be5ee 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/src/main/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplication.java +++ b/springwolf-examples/springwolf-cloud-stream-example/src/main/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplication.java @@ -3,9 +3,8 @@ import io.github.stavshamir.springwolf.example.payload.ConsumerPayload; import io.github.stavshamir.springwolf.example.payload.InputPayload; import io.github.stavshamir.springwolf.example.payload.OutputPayload; +import lombok.extern.slf4j.Slf4j; import org.apache.kafka.streams.kstream.KStream; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -15,10 +14,9 @@ @SpringBootApplication +@Slf4j public class SpringwolfExampleApplication { - private static final Logger logger = LoggerFactory.getLogger(SpringwolfExampleApplication.class); - public static void main(String[] args) { SpringApplication.run(SpringwolfExampleApplication.class, args); } @@ -26,14 +24,14 @@ public static void main(String[] args) { @Bean public Function, KStream> process() { return input -> input - .peek((k, v) -> logger.info("Received payload: {}", v)) + .peek((k, v) -> log.info("Received payload: {}", v)) .mapValues(v -> new OutputPayload(v.getFoo().stream().findFirst().orElse("list was empty"), v.getBar())) - .peek((k, v) -> logger.info("Publishing output: {}", v)); + .peek((k, v) -> log.info("Publishing output: {}", v)); } @Bean public Consumer consumerMethod() { - return input -> logger.info("Consumed: {}", input); + return input -> log.info("Consumed: {}", input); } } diff --git a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTests.java b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTest.java similarity index 90% rename from springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTests.java rename to springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTest.java index bb4dd7eb8..06a97fa09 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTests.java +++ b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTest.java @@ -1,28 +1,25 @@ package io.github.stavshamir.springwolf.example; import org.json.JSONException; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import org.testcontainers.shaded.org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -@RunWith(SpringRunner.class) @SpringBootTest(classes = {SpringwolfExampleApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @EmbeddedKafka(partitions = 1, brokerProperties = {"listeners=PLAINTEXT://localhost:29092", "port=29092"}) @DirtiesContext -public class ApiIntegrationTests { +public class ApiIntegrationTest { @Autowired private TestRestTemplate restTemplate; diff --git a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTest.java b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTest.java index fbb393d42..ba21905b8 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTest.java +++ b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTest.java @@ -2,12 +2,13 @@ import org.apache.commons.io.IOUtils; import org.json.JSONException; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.springframework.web.client.RestTemplate; import org.testcontainers.containers.DockerComposeContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; import java.io.File; import java.io.IOException; @@ -18,13 +19,15 @@ * While the assertion of this test is identical to ApiIntegrationTests, * the setup uses a full docker-compose context with a real kafka instance. */ +@Testcontainers // @Ignore("Uncomment this line if you have issues running this test on your local machine.") public class ApiIntegrationWithDockerTest { private final static RestTemplate restTemplate = new RestTemplate(); private final static String APP_NAME = "app_1"; private final static int APP_PORT = 8080; - @ClassRule + + @Container public static DockerComposeContainer environment = new DockerComposeContainer<>(new File("docker-compose.yml")) .withExposedService(APP_NAME, APP_PORT); diff --git a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java index a859e51b0..39c8ccf05 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java +++ b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java @@ -1,25 +1,20 @@ package io.github.stavshamir.springwolf.example; import io.github.stavshamir.springwolf.asyncapi.AsyncApiService; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@RunWith(Enclosed.class) public class SpringContextTest { - @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringwolfExampleApplication.class) @EmbeddedKafka(partitions = 1, brokerProperties = { "listeners=PLAINTEXT://localhost:29092", "port=29092" }) @DirtiesContext @@ -38,7 +33,6 @@ public void testContextWithAsyncApiDocketBean() { } } - @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringwolfExampleApplication.class) @EmbeddedKafka(partitions = 1, brokerProperties = { "listeners=PLAINTEXT://localhost:29092", "port=29092" }) @DirtiesContext diff --git a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java index c2cdd321d..191a02be6 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java +++ b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java @@ -1,17 +1,13 @@ package io.github.stavshamir.springwolf.example; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; -import static org.junit.Assert.assertNotNull; - -@RunWith(SpringRunner.class) @SpringBootTest(classes = {SpringwolfExampleApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @EmbeddedKafka(partitions = 1, brokerProperties = { "listeners=PLAINTEXT://localhost:29092", "port=29092" }) @DirtiesContext @@ -22,6 +18,6 @@ public class SpringwolfExampleApplicationTest { @Test public void testContext() { - assertNotNull(context); + Assertions.assertNotNull(context); } } \ No newline at end of file diff --git a/springwolf-examples/springwolf-kafka-example/build.gradle b/springwolf-examples/springwolf-kafka-example/build.gradle index 89c1040bc..998433504 100644 --- a/springwolf-examples/springwolf-kafka-example/build.gradle +++ b/springwolf-examples/springwolf-kafka-example/build.gradle @@ -1,9 +1,10 @@ plugins { id 'java' - id 'org.springframework.boot' version '2.1.1.RELEASE' - id 'io.spring.dependency-management' version '1.0.6.RELEASE' - id 'com.bmuschko.docker-spring-boot-application' version '6.1.4' - id 'org.jetbrains.kotlin.jvm' version '1.3.61' + + id 'org.springframework.boot' version '2.7.6' + id 'io.spring.dependency-management' version '1.1.0' + + id 'com.bmuschko.docker-spring-boot-application' version '6.7.0' } sourceCompatibility = '1.8' @@ -23,22 +24,22 @@ repositories { dependencies { implementation project(":springwolf-plugins:springwolf-kafka-plugin") + compileOnly project(":springwolf-plugins:springwolf-kafka-plugin") + annotationProcessor project(":springwolf-plugins:springwolf-kafka-plugin") implementation project(":springwolf-add-ons:springwolf-common-model-converters") - implementation 'io.swagger.core.v3:swagger-core:2.2.0' runtimeOnly 'io.github.springwolf:springwolf-ui:0.6.0' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.kafka:spring-kafka' implementation 'com.google.guava:guava:31.1-jre' + implementation 'org.slf4j:slf4j-api' implementation 'org.javamoney:moneta:1.4.2' - implementation 'io.swagger.core.v3:swagger-core:2.2.0' + implementation 'io.swagger.core.v3:swagger-core:2.2.7' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.kafka:spring-kafka-test' - testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' - testImplementation 'org.jetbrains.kotlin:kotlin-reflect' - testImplementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.10.2' - testImplementation 'org.testcontainers:testcontainers:1.16.0' + testImplementation 'org.testcontainers:testcontainers:1.17.6' + testImplementation 'org.testcontainers:junit-jupiter:1.17.6' testImplementation 'org.skyscreamer:jsonassert:1.5.0' testImplementation 'org.apache.directory.studio:org.apache.commons.io:2.4' } @@ -57,15 +58,11 @@ docker { } } -compileTestKotlin { - kotlinOptions { - jvmTarget = "1.8" - } -} - test { dependsOn dockerBuildImage + useJUnitPlatform() + testLogging { exceptionFormat = 'full' } diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleClassLevelKafkaListener.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleClassLevelKafkaListener.java index dc6a9db9c..1274f9f0a 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleClassLevelKafkaListener.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleClassLevelKafkaListener.java @@ -5,31 +5,29 @@ import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.KafkaAsyncOperationBinding; import io.github.stavshamir.springwolf.example.dtos.AnotherPayloadDto; import io.github.stavshamir.springwolf.example.dtos.ExamplePayloadDto; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.kafka.annotation.KafkaHandler; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.stereotype.Service; import javax.money.MonetaryAmount; -import static org.springframework.kafka.support.converter.AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME; +import static org.springframework.kafka.support.mapping.AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME; @Service +@Slf4j @KafkaListener(topics = "multi-payload-topic", containerFactory = "exampleKafkaListenerContainerFactory") public class ExampleClassLevelKafkaListener { - private static final Logger logger = LoggerFactory.getLogger(ExampleClassLevelKafkaListener.class); - @KafkaHandler public void receiveExamplePayload(ExamplePayloadDto payload) { - logger.info("Received new message in multi-payload-topic: {}", payload.toString()); + log.info("Received new message in multi-payload-topic: {}", payload.toString()); } @KafkaHandler public void receiveAnotherPayload(AnotherPayloadDto payload) { - logger.info("Received new message in multi-payload-topic: {}", payload.toString()); + log.info("Received new message in multi-payload-topic: {}", payload.toString()); } @KafkaHandler @@ -53,7 +51,7 @@ public void receiveAnotherPayload(AnotherPayloadDto payload) { groupId = "#{'foo-groupId'}" ) public void receiveMonetaryAmount(MonetaryAmount payload) { - logger.info("Received new message in multi-payload-topic: {}", payload.toString()); + log.info("Received new message in multi-payload-topic: {}", payload.toString()); } } diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleConsumer.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleConsumer.java index bc2cd55f7..bcb043c8b 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleConsumer.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/consumers/ExampleConsumer.java @@ -2,26 +2,24 @@ import io.github.stavshamir.springwolf.example.dtos.AnotherPayloadDto; import io.github.stavshamir.springwolf.example.dtos.ExamplePayloadDto; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.stereotype.Service; import java.util.List; @Service +@Slf4j public class ExampleConsumer { - private static final Logger logger = LoggerFactory.getLogger(ExampleConsumer.class); - @KafkaListener(topics = "example-topic", containerFactory = "exampleKafkaListenerContainerFactory") public void receiveExamplePayload(ExamplePayloadDto payload) { - logger.info("Received new message in example-topic: {}", payload.toString()); + log.info("Received new message in example-topic: {}", payload.toString()); } @KafkaListener(topics = "another-topic", containerFactory = "anotherKafkaListenerContainerFactory", groupId = "example-group-id") public void receiveAnotherPayloadBatched(List payloads) { - logger.info("Received new messages in another-topic: {}", payloads.toString()); + log.info("Received new messages in another-topic: {}", payloads.toString()); } } diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/producers/ExampleProducer.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/producers/ExampleProducer.java index 339d792a5..b872dacc0 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/producers/ExampleProducer.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/producers/ExampleProducer.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component; import static io.github.stavshamir.springwolf.example.configuration.KafkaConfiguration.PRODUCER_TOPIC; -import static org.springframework.kafka.support.converter.AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME; +import static org.springframework.kafka.support.mapping.AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME; @Component public class ExampleProducer { diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTests.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTest.java similarity index 90% rename from springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTests.java rename to springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTest.java index 4951eed07..3062d4f95 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTests.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationTest.java @@ -1,28 +1,25 @@ package io.github.stavshamir.springwolf.example; import org.json.JSONException; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import org.testcontainers.shaded.org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -@RunWith(SpringRunner.class) @SpringBootTest(classes = {SpringwolfExampleApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @EmbeddedKafka(partitions = 1, brokerProperties = {"listeners=PLAINTEXT://localhost:29092", "port=29092"}) @DirtiesContext -public class ApiIntegrationTests { +public class ApiIntegrationTest { @Autowired private TestRestTemplate restTemplate; diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTest.java new file mode 100644 index 000000000..ba21905b8 --- /dev/null +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTest.java @@ -0,0 +1,51 @@ +package io.github.stavshamir.springwolf.example; + +import org.apache.commons.io.IOUtils; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.springframework.web.client.RestTemplate; +import org.testcontainers.containers.DockerComposeContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +/** + * While the assertion of this test is identical to ApiIntegrationTests, + * the setup uses a full docker-compose context with a real kafka instance. + */ +@Testcontainers +// @Ignore("Uncomment this line if you have issues running this test on your local machine.") +public class ApiIntegrationWithDockerTest { + + private final static RestTemplate restTemplate = new RestTemplate(); + private final static String APP_NAME = "app_1"; + private final static int APP_PORT = 8080; + + @Container + public static DockerComposeContainer environment = new DockerComposeContainer<>(new File("docker-compose.yml")) + .withExposedService(APP_NAME, APP_PORT); + + private String baseUrl() { + String host = environment.getServiceHost(APP_NAME, APP_PORT); + int port = environment.getServicePort(APP_NAME, APP_PORT); + return String.format("http://%s:%d", host, port); + } + + @Test + public void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException, JSONException { + String url = baseUrl() + "/springwolf/docs"; + String actual = restTemplate.getForObject(url, String.class); + System.out.println("Got: " + actual); + + InputStream s = this.getClass().getResourceAsStream("/asyncapi.json"); + String expected = IOUtils.toString(s, StandardCharsets.UTF_8); + + JSONAssert.assertEquals(expected, actual, JSONCompareMode.STRICT_ORDER); + } +} diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java index a859e51b0..2a9bc32a2 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/SpringContextTest.java @@ -1,25 +1,22 @@ package io.github.stavshamir.springwolf.example; import io.github.stavshamir.springwolf.asyncapi.AsyncApiService; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@RunWith(Enclosed.class) +@Nested public class SpringContextTest { - @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringwolfExampleApplication.class) @EmbeddedKafka(partitions = 1, brokerProperties = { "listeners=PLAINTEXT://localhost:29092", "port=29092" }) @DirtiesContext @@ -38,7 +35,6 @@ public void testContextWithAsyncApiDocketBean() { } } - @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringwolfExampleApplication.class) @EmbeddedKafka(partitions = 1, brokerProperties = { "listeners=PLAINTEXT://localhost:29092", "port=29092" }) @DirtiesContext diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java index c2cdd321d..191a02be6 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/SpringwolfExampleApplicationTest.java @@ -1,17 +1,13 @@ package io.github.stavshamir.springwolf.example; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; -import static org.junit.Assert.assertNotNull; - -@RunWith(SpringRunner.class) @SpringBootTest(classes = {SpringwolfExampleApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @EmbeddedKafka(partitions = 1, brokerProperties = { "listeners=PLAINTEXT://localhost:29092", "port=29092" }) @DirtiesContext @@ -22,6 +18,6 @@ public class SpringwolfExampleApplicationTest { @Test public void testContext() { - assertNotNull(context); + Assertions.assertNotNull(context); } } \ No newline at end of file diff --git a/springwolf-examples/springwolf-kafka-example/src/test/kotlin/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTests.kt b/springwolf-examples/springwolf-kafka-example/src/test/kotlin/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTests.kt deleted file mode 100644 index 61f6d2b41..000000000 --- a/springwolf-examples/springwolf-kafka-example/src/test/kotlin/io/github/stavshamir/springwolf/example/ApiIntegrationWithDockerTests.kt +++ /dev/null @@ -1,52 +0,0 @@ -package io.github.stavshamir.springwolf.example; - -import org.apache.commons.io.IOUtils -import org.junit.ClassRule -import org.junit.Test -import org.skyscreamer.jsonassert.JSONAssert -import org.skyscreamer.jsonassert.JSONCompareMode -import org.springframework.web.client.RestTemplate -import org.testcontainers.containers.DockerComposeContainer -import java.io.File -import java.io.InputStream -import java.nio.charset.StandardCharsets - -/** - * While the assertion of this test is identical to ApiIntegrationTests, - * the setup uses a full docker-compose context with a real kafka instance. - */ -// @Ignore("Uncomment this line if you have issues running this test on your local machine.") -class ApiIntegrationWithDockerTests { - - companion object { - private val restTemplate = RestTemplate() - - private const val APP_NAME = "app_1" - private const val APP_PORT = 8080 - - @JvmField - @ClassRule - val environment: DockerComposeContainer = DockerComposeContainer(File("docker-compose.yml")) - .withExposedService(APP_NAME, APP_PORT) - } - - private fun baseUrl(): String { - val host = environment.getServiceHost(APP_NAME, APP_PORT) - val port = environment.getServicePort(APP_NAME, APP_PORT) - return "http://$host:$port" - } - - @Test - fun `asyncapi-docs shold return the correct json response`() { - val url = "${baseUrl()}/springwolf/docs" - val actual = restTemplate.getForObject(url, String::class.java) - println("Got: $actual") - - val s: InputStream = this.javaClass.getResourceAsStream("/asyncapi.json") - val expected: String = IOUtils.toString(s, StandardCharsets.UTF_8) - - JSONAssert.assertEquals(expected, actual, JSONCompareMode.STRICT_ORDER) - - } - -} diff --git a/springwolf-plugins/springwolf-amqp-plugin/build.gradle b/springwolf-plugins/springwolf-amqp-plugin/build.gradle index 3861943e6..609892926 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/build.gradle +++ b/springwolf-plugins/springwolf-amqp-plugin/build.gradle @@ -3,8 +3,8 @@ plugins { id 'signing' id 'maven-publish' - id 'org.springframework.boot' version '2.1.1.RELEASE' - id 'io.spring.dependency-management' version '1.0.6.RELEASE' + id 'org.springframework.boot' version '2.7.6' + id 'io.spring.dependency-management' version '1.1.0' } def isSnapshot = Boolean.valueOf(project.findProperty('SNAPSHOT')) @@ -26,17 +26,18 @@ dependencies { implementation 'org.springframework.amqp:spring-rabbit' implementation 'com.google.guava:guava:31.1-jre' + implementation 'org.slf4j:slf4j-api' - compileOnly 'org.projectlombok:lombok:1.18.4' - annotationProcessor 'org.projectlombok:lombok:1.18.4' + compileOnly 'org.projectlombok:lombok:1.18.24' + annotationProcessor 'org.projectlombok:lombok:1.18.24' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' testImplementation('org.springframework.boot:spring-boot-starter-test') - testImplementation 'org.projectlombok:lombok:1.18.4' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.4' + testImplementation 'org.projectlombok:lombok:1.18.24' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.24' - testImplementation('org.assertj:assertj-core:3.11.1') + testImplementation 'org.assertj:assertj-core:3.23.1' } jar.enabled = true @@ -47,6 +48,10 @@ java { withSourcesJar() } +test { + useJUnitPlatform() +} + publishing { publications { mavenJava(MavenPublication) { @@ -105,6 +110,6 @@ publishing { signing { def signingKey = project.findProperty("SIGNINGKEY") def signingPassword = project.findProperty("SIGNINGPASSWORD") - useInMemoryPgpKeys (signingKey, signingPassword) + useInMemoryPgpKeys(signingKey, signingPassword) sign publishing.publications.mavenJava } diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScannerTest.java b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScannerTest.java index b1f2f2756..9797cc8ab 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScannerTest.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScannerTest.java @@ -16,8 +16,8 @@ import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; import lombok.Data; import lombok.NoArgsConstructor; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.amqp.core.Binding; import org.springframework.amqp.rabbit.annotation.Exchange; import org.springframework.amqp.rabbit.annotation.Queue; @@ -29,7 +29,7 @@ import org.springframework.messaging.handler.annotation.Payload; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Collections; import java.util.HashMap; @@ -42,7 +42,7 @@ import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { MethodLevelRabbitListenerScanner.class, DefaultSchemasService.class, diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfAmqpProducerConfigurationIntegrationTest.java b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfAmqpProducerConfigurationIntegrationTest.java index a74bc8b93..51a8074c1 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfAmqpProducerConfigurationIntegrationTest.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfAmqpProducerConfigurationIntegrationTest.java @@ -5,9 +5,8 @@ import io.github.stavshamir.springwolf.asyncapi.ChannelsService; import io.github.stavshamir.springwolf.asyncapi.SpringwolfAmqpController; import io.github.stavshamir.springwolf.producer.SpringwolfAmqpProducer; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -15,16 +14,15 @@ import org.springframework.boot.test.mock.mockito.MockBeans; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Enclosed.class) public class SpringwolfAmqpProducerConfigurationIntegrationTest { - @RunWith(SpringRunner.class) + @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { DefaultAsyncApiDocketService.class, SpringwolfAmqpProducer.class, @@ -61,7 +59,7 @@ public void springwolfAmqpProducerShouldBePresentInSpringContext() { } } - @RunWith(SpringRunner.class) + @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { DefaultAsyncApiDocketService.class, SpringwolfAmqpProducer.class, diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfAmqpProducerTest.java b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfAmqpProducerTest.java index 7ecfe55b6..6b69b7549 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfAmqpProducerTest.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfAmqpProducerTest.java @@ -6,8 +6,8 @@ import com.asyncapi.v2.model.channel.operation.Operation; import com.google.common.collect.ImmutableMap; import io.github.stavshamir.springwolf.asyncapi.ChannelsService; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.amqp.rabbit.core.RabbitTemplate; import java.util.Collections; @@ -24,7 +24,7 @@ public class SpringwolfAmqpProducerTest { private ChannelsService channelsService; private RabbitTemplate rabbitTemplate; - @Before + @BeforeEach public void setUp() { channelsService = mock(ChannelsService.class); rabbitTemplate = mock(RabbitTemplate.class); diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/build.gradle b/springwolf-plugins/springwolf-cloud-stream-plugin/build.gradle index f70de3b98..696354740 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/build.gradle +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/build.gradle @@ -3,8 +3,8 @@ plugins { id 'signing' id 'maven-publish' - id 'org.springframework.boot' version '2.2.13.RELEASE' - id 'io.spring.dependency-management' version '1.0.10.RELEASE' + id 'org.springframework.boot' version '2.7.6' + id 'io.spring.dependency-management' version '1.1.0' } def isSnapshot = Boolean.valueOf(project.findProperty('SNAPSHOT')) @@ -22,9 +22,9 @@ ext { } dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" - } + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" + } } dependencies { @@ -33,14 +33,15 @@ dependencies { implementation 'org.springframework.cloud:spring-cloud-stream' implementation 'com.google.guava:guava:31.1-jre' + implementation 'org.slf4j:slf4j-api' - compileOnly 'org.projectlombok:lombok:1.18.4' - annotationProcessor 'org.projectlombok:lombok:1.18.4' + compileOnly 'org.projectlombok:lombok:1.18.24' + annotationProcessor 'org.projectlombok:lombok:1.18.24' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.4' - testImplementation 'org.projectlombok:lombok:1.18.4' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.24' + testImplementation 'org.projectlombok:lombok:1.18.24' testImplementation('org.springframework.boot:spring-boot-starter-test') - testImplementation('org.assertj:assertj-core:3.11.1') + testImplementation 'org.assertj:assertj-core:3.23.1' testImplementation('org.apache.kafka:kafka-streams:3.3.1') } @@ -52,6 +53,10 @@ java { withSourcesJar() } +test { + useJUnitPlatform() +} + publishing { publications { mavenJava(MavenPublication) { diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanData.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanData.java index 52367ab7b..186094389 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanData.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanData.java @@ -2,9 +2,9 @@ import com.google.common.collect.ImmutableSet; import lombok.Data; -import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl; import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Arrays; import java.util.Collections; @@ -65,7 +65,7 @@ private static ImmutableSet fromFunctionBean(Method m } private static List> getReturnTypeGenerics(Method methodBean) { - ParameterizedTypeImpl genericReturnType = (ParameterizedTypeImpl) methodBean.getGenericReturnType(); + ParameterizedType genericReturnType = (ParameterizedType) methodBean.getGenericReturnType(); return Arrays.stream(genericReturnType.getActualTypeArguments()) .map(FunctionalChannelBeanData::toClassObject) .collect(toList()); @@ -76,17 +76,17 @@ private static Class toClassObject(Type type) { return (Class) type; } - if (type instanceof ParameterizedTypeImpl) { - Class rawType = ((ParameterizedTypeImpl) type).getRawType(); + if (type instanceof ParameterizedType) { + Type rawType = ((ParameterizedType) type).getRawType(); - if ("org.apache.kafka.streams.kstream.KStream".equals(rawType.getName())) { - return (Class) ((ParameterizedTypeImpl) type).getActualTypeArguments()[1]; + if ("org.apache.kafka.streams.kstream.KStream".equals(rawType.getTypeName())) { + return (Class) ((ParameterizedType) type).getActualTypeArguments()[1]; } - return rawType; + return (Class) rawType; } - throw new IllegalArgumentException("Cannot handle Type which is not Class or ParameterizedTypeImpl, but was given: " + type.getClass()); + throw new IllegalArgumentException("Cannot handle Type which is not Class or ParameterizedType, but was given: " + type.getClass()); } enum BeanType { diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScannerTest.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScannerTest.java index e163cd51b..d437d1edc 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScannerTest.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/CloudStreamFunctionChannelsScannerTest.java @@ -18,8 +18,8 @@ import io.github.stavshamir.springwolf.configuration.DefaultAsyncApiDocketService; import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; import org.apache.kafka.streams.kstream.KStream; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.mock.mockito.MockBean; @@ -28,7 +28,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Collections; import java.util.Map; @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { ConfigurationClassScanner.class, DefaultBeanMethodsScanner.class, diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanDataTest.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanDataTest.java index f9a766fbc..a879075b8 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanDataTest.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/cloudstream/FunctionalChannelBeanDataTest.java @@ -1,7 +1,7 @@ package io.github.stavshamir.springwolf.asyncapi.scanners.channels.cloudstream; import org.apache.kafka.streams.kstream.KStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Bean; import java.lang.reflect.Method; diff --git a/springwolf-plugins/springwolf-kafka-plugin/build.gradle b/springwolf-plugins/springwolf-kafka-plugin/build.gradle index a6a21ec72..46a4bf07b 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/build.gradle +++ b/springwolf-plugins/springwolf-kafka-plugin/build.gradle @@ -3,8 +3,8 @@ plugins { id 'signing' id 'maven-publish' - id 'org.springframework.boot' version '2.1.1.RELEASE' - id 'io.spring.dependency-management' version '1.0.6.RELEASE' + id 'org.springframework.boot' version '2.7.6' + id 'io.spring.dependency-management' version '1.1.0' } def isSnapshot = Boolean.valueOf(project.findProperty('SNAPSHOT')) @@ -27,18 +27,19 @@ dependencies { implementation 'io.swagger.core.v3:swagger-models:2.2.0' implementation 'com.google.guava:guava:31.1-jre' + implementation 'org.slf4j:slf4j-api' - compileOnly 'org.projectlombok:lombok:1.18.4' + compileOnly 'org.projectlombok:lombok:1.18.24' - annotationProcessor 'org.projectlombok:lombok:1.18.4' + annotationProcessor 'org.projectlombok:lombok:1.18.24' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' testImplementation('org.springframework.boot:spring-boot-starter-test') - testImplementation 'org.projectlombok:lombok:1.18.4' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.4' + testImplementation 'org.projectlombok:lombok:1.18.24' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.24' - testImplementation('org.assertj:assertj-core:3.11.1') + testImplementation 'org.assertj:assertj-core:3.23.1' } jar.enabled = true @@ -49,6 +50,10 @@ java { withSourcesJar() } +test { + useJUnitPlatform() +} + publishing { publications { mavenJava(MavenPublication) { @@ -107,6 +112,6 @@ publishing { signing { def signingKey = project.findProperty("SIGNINGKEY") def signingPassword = project.findProperty("SIGNINGPASSWORD") - useInMemoryPgpKeys (signingKey, signingPassword) + useInMemoryPgpKeys(signingKey, signingPassword) sign publishing.publications.mavenJava } diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForSpringKafkaBuilder.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForSpringKafkaBuilder.java index a723dd61d..2b0ffb0cc 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForSpringKafkaBuilder.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/types/channel/operation/message/header/AsyncHeadersForSpringKafkaBuilder.java @@ -1,6 +1,6 @@ package io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.header; -import org.springframework.kafka.support.converter.AbstractJavaTypeMapper; +import org.springframework.kafka.support.mapping.AbstractJavaTypeMapper; import java.util.List; diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/SpringwolfKafkaControllerTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/SpringwolfKafkaControllerTest.java index 7b7e10401..9b2c7cf54 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/SpringwolfKafkaControllerTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/SpringwolfKafkaControllerTest.java @@ -2,13 +2,13 @@ import io.github.stavshamir.springwolf.asyncapi.dtos.KafkaMessageDto; import io.github.stavshamir.springwolf.producer.SpringwolfKafkaProducer; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; import org.springframework.web.server.ResponseStatusException; @@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; import static org.mockito.Mockito.*; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class SpringwolfKafkaControllerTest { @InjectMocks @@ -41,7 +41,7 @@ public void testControllerShouldReturnBadRequestIfPayloadIsEmpty() { failBecauseExceptionWasNotThrown(ResponseStatusException.class); } catch (ResponseStatusException e) { assertThat(e.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST); - verifyZeroInteractions(springwolfKafkaProducer); + verifyNoInteractions(springwolfKafkaProducer); } } diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelKafkaListenerScannerTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelKafkaListenerScannerTest.java index 8c085cef9..badcbc16e 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelKafkaListenerScannerTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelKafkaListenerScannerTest.java @@ -13,18 +13,17 @@ import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.header.HeaderReference; import io.github.stavshamir.springwolf.configuration.AsyncApiDocket; import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; -import junit.framework.TestCase; import lombok.Data; import lombok.NoArgsConstructor; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.kafka.annotation.KafkaHandler; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.List; import java.util.Map; @@ -35,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {ClassLevelKafkaListenerScanner.class, DefaultSchemasService.class}) @TestPropertySource(properties = "kafka.topics.test=test-topic") -public class ClassLevelKafkaListenerScannerTest extends TestCase { +public class ClassLevelKafkaListenerScannerTest { @Autowired private ClassLevelKafkaListenerScanner methodLevelKafkaListenerScanner; diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/KafkaListenerUtilTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/KafkaListenerUtilTest.java index a65ed3609..8ad8cc57e 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/KafkaListenerUtilTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/KafkaListenerUtilTest.java @@ -6,13 +6,13 @@ import com.asyncapi.v2.binding.kafka.KafkaOperationBinding; import org.assertj.core.util.Arrays; import org.assertj.core.util.Sets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.util.StringValueResolver; import java.util.Map; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelKafkaListenerScannerTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelKafkaListenerScannerTest.java index c0f6b7e75..b2cff4b05 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelKafkaListenerScannerTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelKafkaListenerScannerTest.java @@ -16,15 +16,15 @@ import io.github.stavshamir.springwolf.schemas.DefaultSchemasService; import lombok.Data; import lombok.NoArgsConstructor; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.messaging.handler.annotation.Payload; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.List; import java.util.Map; @@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.when; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {MethodLevelKafkaListenerScanner.class, DefaultSchemasService.class}) @TestPropertySource(properties = "kafka.topics.test=test-topic") public class MethodLevelKafkaListenerScannerTest { diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfKafkaProducerConfigurationIntegrationTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfKafkaProducerConfigurationIntegrationTest.java index 0b7bb3c93..306ca768a 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfKafkaProducerConfigurationIntegrationTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfKafkaProducerConfigurationIntegrationTest.java @@ -4,23 +4,21 @@ import io.github.stavshamir.springwolf.SpringWolfKafkaConfigProperties; import io.github.stavshamir.springwolf.asyncapi.SpringwolfKafkaController; import io.github.stavshamir.springwolf.producer.SpringwolfKafkaProducer; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Enclosed.class) public class SpringwolfKafkaProducerConfigurationIntegrationTest { - @RunWith(SpringRunner.class) + @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { DefaultAsyncApiDocketService.class, SpringwolfKafkaProducerConfiguration.class, @@ -58,7 +56,7 @@ public void springwolfKafkaTemplateShouldBePresentInSpringContext() { } } - @RunWith(SpringRunner.class) + @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { DefaultAsyncApiDocketService.class, SpringwolfKafkaProducerConfiguration.class, diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfKafkaTemplateFactoryTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfKafkaTemplateFactoryTest.java index 5c83773fd..84e0d9853 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfKafkaTemplateFactoryTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/configuration/SpringwolfKafkaTemplateFactoryTest.java @@ -2,11 +2,11 @@ import com.asyncapi.v2.model.info.Info; import com.asyncapi.v2.model.server.Server; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.kafka.core.KafkaTemplate; import java.util.Collections; @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class SpringwolfKafkaTemplateFactoryTest { @InjectMocks diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaProducerTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaProducerTest.java index fe5f31880..1f0a2a151 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaProducerTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaProducerTest.java @@ -3,13 +3,13 @@ import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.header.Header; import org.assertj.core.util.Lists; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.kafka.core.KafkaTemplate; import java.util.Collections; @@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verify; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class SpringwolfKafkaProducerTest { private SpringwolfKafkaProducer springwolfKafkaProducer; @@ -31,7 +31,7 @@ public class SpringwolfKafkaProducerTest { @Captor private ArgumentCaptor>> recordArgumentCaptor; - @Before + @BeforeEach public void setUp() { springwolfKafkaProducer = new SpringwolfKafkaProducer(Optional.of(kafkaTemplate)); }