Skip to content

Commit

Permalink
Upgrade to Dropwizard 4 (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Chédru committed Jun 19, 2023
1 parent f994f27 commit e21588a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
java-version: '11'
- name: get tag
id: get_tag
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
Expand Down
32 changes: 17 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
</developer>
</developers>
<properties>
<java.source>1.8</java.source>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.source>11</java.source>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dropwizard.version>2.1.6</dropwizard.version>
<sentry.version>6.23.0</sentry.version>
</properties>
<scm>
Expand All @@ -56,17 +55,21 @@
</snapshots>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-bom</artifactId>
<version>4.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>${dropwizard.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
Expand All @@ -79,15 +82,14 @@
<version>${sentry.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-testing</artifactId>
<version>${dropwizard.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package org.dhatim.dropwizard.sentry.logging;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.filter.Filter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.dropwizard.logging.AbstractAppenderFactory;
import io.dropwizard.logging.async.AsyncAppenderFactory;
import io.dropwizard.logging.filter.LevelFilterFactory;
import io.dropwizard.logging.layout.LayoutFactory;
import io.dropwizard.logging.common.AbstractAppenderFactory;
import io.dropwizard.logging.common.async.AsyncAppenderFactory;
import io.dropwizard.logging.common.filter.LevelFilterFactory;
import io.dropwizard.logging.common.layout.LayoutFactory;
import io.sentry.Sentry;
import io.sentry.SentryOptions;
import io.sentry.logback.SentryAppender;
import jakarta.validation.constraints.NotNull;
import org.dhatim.dropwizard.sentry.SentryConfigurator;
import org.dhatim.dropwizard.sentry.filters.DroppingSentryLoggingFilter;

import javax.validation.constraints.NotNull;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.dhatim.dropwizard.sentry.logging;

import ch.qos.logback.classic.Logger;
import io.dropwizard.logging.filter.ThresholdLevelFilterFactory;
import io.dropwizard.logging.layout.DropwizardLayoutFactory;
import io.dropwizard.logging.common.filter.ThresholdLevelFilterFactory;
import io.dropwizard.logging.common.layout.DropwizardLayoutFactory;
import org.slf4j.LoggerFactory;

import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.spi.FilterReply;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class DroppingSentryLoggingFilterTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Appender;
import io.dropwizard.configuration.ConfigurationException;
import io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory;
import io.dropwizard.logging.filter.ThresholdLevelFilterFactory;
import io.dropwizard.logging.layout.DropwizardLayoutFactory;
import io.dropwizard.logging.common.async.AsyncLoggingEventAppenderFactory;
import io.dropwizard.logging.common.filter.ThresholdLevelFilterFactory;
import io.dropwizard.logging.common.layout.DropwizardLayoutFactory;
import io.sentry.logback.SentryAppender;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class SentryAppenderFactoryTest {

Expand All @@ -27,15 +28,16 @@ public class SentryAppenderFactoryTest {
public void hasValidDefaults() throws IOException, ConfigurationException {
final SentryAppenderFactory factory = new SentryAppenderFactory();

assertNull("default dsn is unset", factory.dsn);
assertNull("default environment is unset", factory.environment);
assertNull("default release is unset", factory.release);
assertNull("default serverName is unset", factory.serverName);
assertNull(factory.dsn, "default dsn is unset");
assertNull(factory.environment, "default environment is unset");
assertNull(factory.release, "default release is unset");
assertNull(factory.serverName, "default serverName is unset");
}

@Test(expected = NullPointerException.class)
@Test
public void buildSentryAppenderShouldFailWithNullContext() {
new SentryAppenderFactory().build(null, "", null, levelFilterFactory, asyncAppenderFactory);
assertThrows(NullPointerException.class,
() -> new SentryAppenderFactory().build(null, "", null, levelFilterFactory, asyncAppenderFactory));
}

@Test
Expand Down

0 comments on commit e21588a

Please sign in to comment.