From aaf89e70815565e31f465cf717a848fa1f8d893e Mon Sep 17 00:00:00 2001 From: Stefan Kapferer Date: Wed, 28 Aug 2024 09:41:45 +0200 Subject: [PATCH] Fix build + update dependencies --- build.gradle | 7 +-- gradle.properties | 5 +- gradle/wrapper/gradle-wrapper.properties | 2 +- ...ASBoundedContextDiscoveryStrategyTest.java | 52 +++++++++++-------- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/build.gradle b/build.gradle index 7ee5827..4143304 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'jacoco' id 'maven-publish' id 'signing' - id 'nebula.release' version '13.0.0' + id 'nebula.release' version '19.0.10' } group 'org.contextmapper' @@ -27,6 +27,7 @@ dependencies { implementation "org.yaml:snakeyaml:${snakeYMLVersion}" implementation "org.contextmapper:context-mapper-dsl:${cmlVersion}" implementation "io.swagger.parser.v3:swagger-parser:${swaggerParserVersion}" + implementation "ch.qos.logback:logback-classic:${logbackVersion}" testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: jUnitVersion @@ -152,8 +153,8 @@ test { jacocoTestReport { reports { - xml.enabled true - html.enabled false + xml.required = true + html.required = false } } diff --git a/gradle.properties b/gradle.properties index a7cfc6d..61088e4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,8 @@ ossSnapshotRepository=https://oss.sonatype.org/content/repositories/snapshots/ ossReleaseStagingRepository=https://oss.sonatype.org/service/local/staging/deploy/maven2/ # dependency versions -jUnitVersion=5.5.2 -cmlVersion=6.6.1 +jUnitVersion=5.11.0 +cmlVersion=6.11.0 reflectionsVersion=0.10.2 springBootVersion=2.6.4 springWebVersion=5.3.16 @@ -12,3 +12,4 @@ commonsLangVersion=3.9 commonsIOVersion=2.6 snakeYMLVersion=1.25 swaggerParserVersion=2.0.20 +logbackVersion=1.2.6 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f33907c..78bb237 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Fri Oct 25 16:08:31 CEST 2019 -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/src/test/java/org/contextmapper/discovery/strategies/boundedcontexts/OASBoundedContextDiscoveryStrategyTest.java b/src/test/java/org/contextmapper/discovery/strategies/boundedcontexts/OASBoundedContextDiscoveryStrategyTest.java index 1a668f9..172592b 100644 --- a/src/test/java/org/contextmapper/discovery/strategies/boundedcontexts/OASBoundedContextDiscoveryStrategyTest.java +++ b/src/test/java/org/contextmapper/discovery/strategies/boundedcontexts/OASBoundedContextDiscoveryStrategyTest.java @@ -15,17 +15,19 @@ */ package org.contextmapper.discovery.strategies.boundedcontexts; -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggingEvent; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.read.ListAppender; import org.contextmapper.discovery.ContextMapDiscoverer; import org.contextmapper.discovery.model.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -35,6 +37,23 @@ public class OASBoundedContextDiscoveryStrategyTest { public static final String SAMPLE_CONTRACT_LOCATION = "./src/test/resources/test/oas-tests/sample-contract.yml"; + private TestAppender logAppender; + + @BeforeEach + public void setup() { + Logger logger = (Logger) LoggerFactory.getLogger(OASBoundedContextDiscoveryStrategy.class); + logAppender = new TestAppender(); + logAppender.setContext((LoggerContext) LoggerFactory.getILoggerFactory()); + logger.addAppender(logAppender); + logAppender.start(); + } + + @AfterEach + public void cleanUp() { + logAppender.reset(); + logAppender.stop(); + } + @Test public void canDiscoverContext() { // given @@ -241,32 +260,21 @@ public void canLogOASValidationError() { // given ContextMapDiscoverer discoverer = new ContextMapDiscoverer() .usingBoundedContextDiscoveryStrategies(new OASBoundedContextDiscoveryStrategy("./src/test/resources/test/oas-tests/oas-with-error.yml")); - TestAppender testAppender = new TestAppender(); - final Logger rootLogger = Logger.getRootLogger(); - rootLogger.addAppender(testAppender); // when, then assertThrows(RuntimeException.class, () -> { discoverer.discoverContextMap(); }); - assertFalse(testAppender.events.isEmpty()); + assertFalse(logAppender.logEmpty()); } - private class TestAppender extends AppenderSkeleton { - List events = new ArrayList(); - - @Override - protected void append(LoggingEvent event) { - events.add(event); - } - - @Override - public void close() { + private class TestAppender extends ListAppender { + public void reset() { + this.list.clear(); } - @Override - public boolean requiresLayout() { - return false; + public boolean logEmpty() { + return this.list.isEmpty(); } }