Skip to content

Commit

Permalink
Fix build + update dependencies (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-ka authored Aug 28, 2024
1 parent 71f28f9 commit 8f5329f
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 31 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ jobs:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

4 changes: 3 additions & 1 deletion .github/workflows/build_standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ jobs:
- name: Build with Gradle
run: ./gradlew clean build snapshot
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ jobs:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -152,8 +153,8 @@ test {

jacocoTestReport {
reports {
xml.enabled true
html.enabled false
xml.required = true
html.required = false
}
}

Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ 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
commonsLangVersion=3.9
commonsIOVersion=2.6
snakeYMLVersion=1.25
swaggerParserVersion=2.0.20
logbackVersion=1.2.6
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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<LoggingEvent> events = new ArrayList<LoggingEvent>();

@Override
protected void append(LoggingEvent event) {
events.add(event);
}

@Override
public void close() {
private class TestAppender extends ListAppender<ILoggingEvent> {
public void reset() {
this.list.clear();
}

@Override
public boolean requiresLayout() {
return false;
public boolean logEmpty() {
return this.list.isEmpty();
}
}

Expand Down

0 comments on commit 8f5329f

Please sign in to comment.