Skip to content

Releases: valfirst/slf4j-test

v3.0.1

13 Jul 08:21
341d1b5
Compare
Choose a tag to compare

slf4j-test-3.0.1 (2023-07-13)

Full Changelog

Fixes:

  • #413 via #414 Allow to use TreeMap as input parameter for TestMDCAdapter::setContextMap (by @valfirst)

v3.0.0

11 Jul 13:44
c027968
Compare
Choose a tag to compare

slf4j-test-3.0.0 (2023-07-11)

Full Changelog

Breaking changes

  • #380 via #383 - Switch from Lidalia Level to SLF4J Level (by @karstenspang)

    • uk.org.lidalia.slf4jext.Level is replaced with org.slf4j.event.Level

      The org.slf4j.event.Level class has been present in SLF4J since version 1.7.15 from 2016. There is little reason for a client to use a version older than that.

      Changing the import statement from one package to the other handles most of the changes. But some differences between the two Level classes remain.

      Ordinal Values

      In uk.org.lidalia.slf4jext.Level, ERROR has the lowest ordinal value, and TRACE has the highest. In org.slf4j.event.Level, it is the other way round. When comparing levels using Enum.compareTo, the equality sign will have to be reversed. In SLF4J Test, this is used to decide whether to print the log message.

      OFF Level

      org.slf4j.event.Level has no OFF level. This means that another way must be used to specify that printing is off. null is the only other value you can pass as an enum. The print level logic is changed to use null as "off".

      enableableLevels

      uk.org.lidalia.slf4jext.Level has the static method enableableLevels that returns the set of enum values corresponding to log levels that can be enabled. Since all values represent enableable levels in org.slf4j.event.Level, EnumSet.allOf(Level.class) provides the equivalent funtionality.

    • Dependency uk.org.lidalia:lidalia-slf4j-ext is dropped

  • #380 via #384 - Remove Guava as dependency (by @karstenspang)

    • Guava Collections are replaced with Java Collections

      Parameter and return types are changed to be simply List, Map, or Set, instead of the specific ones from Guava. The client can still pass the Guava ones as parameters if needed. In case the client assign a returned value to a specific type, code changes are needed.

      Returned vales are wrapped using java.util.Collections.unmodifiableList/Map/Set after copying.

      Internal values are implemented using ArrayList, HashMap, or HashSet wrapped to be made unmodifiable. As a special case, enabled log level sets are to be represented as EnumSet<Level>.

    • Dependency com.google.guava:guava is dropped

  • #312, #380 via #326 - Use java.time's Instant rather than joda-time (by @josephw)

    • org.joda.time.Instant is replaced with java.time.Instant
    • Dependency joda-time:joda-time is dropped
  • #390 via #394 - Avoid substitution of null values (by @karstenspang)

    null-s were replaced by other values:

    • When a LoggingEvent was constructed with arguments, null-s were replaced with Option.empty(). If logging events were just compared, such replacement had no impact. So restoration of null-s is considered as an internal change here.
    • If null value was inserted in the MDC, it was replaced with the string "null". If MDC functionality were tested, such replacement could be annoying. In particular, the assertion failure message showed null in both the expected and the actual value. Now such substitution is eliminated, null value is always used.
  • #409 via #411 Drop static binders (by @valfirst)

    slf4j-api 2.0.x relies on the ServiceLoader mechanism to find its logging backend. SLF4J 1.7.x and earlier versions relied on the static binder mechanism which is no loger honored by slf4j-api version 2.0.x. SLF4J Test doesn't support SLF4J 1.7.x and 1.8.x since version 2.4.0 (when breaking changes were introduced in SLf4J API). Thus static binders are removed:

    • org.slf4j.impl.StaticLoggerBinder
    • org.slf4j.impl.StaticMDCBinder
    • org.slf4j.impl.StaticMarkerBinder

Implemented enhancements:

  • #398 via #399 Add utility classes to support java.util.logging testing (by @karstenspang)

    • A helper class to do the java.util.logging setup is added, as well as a JUnit 5 extension that calls it.
    • jul-to-slf4j bridge is added as an optional dependency.
  • #392 via #401 Implement MDC configuration management (by @karstenspang)

    There is now configuration for four aspects:

    • Whether an MDC is supported at all.
    • Whether the MDC is inherited by child threads.
    • Whether getCopyOfContextMap() shall return an empty map or null if the MDC has not been set.
    • Whether null is a legal value in an MDC entry. null keys are never allowed.
  • #407 via #408, #412 Add full support for the SLF4J fluent logging API (by @karstenspang)

    • LoggingEvent class supports multiple markers. This is allowed by the fluent API.
    • LoggingEvent class stores the key/value pair list that can be generated fluent API.
    • The new TestLoggingEventBuilder class can be used for fluently creating LoggingEvent instances for use as expected values.
  • #183 via #410 Add ability to configure cleanup stage (by @valfirst)

    Now it is possible to configure JUnit 5 stage which cleanup should be performed at using @TestLoggerFactorySettings annotation or while programmatic extension registration is performed.

Fixes:

v2.9.0

21 Mar 23:44
0a9aded
Compare
Choose a tag to compare

slf4j-test-2.9.0 (2023-03-22)

Full Changelog

Implemented enhancements:

  • #360 - Add ability to make assertions using the PredicateBuilder more fluent (by @topbadger)

    Static helper method and method overloads are added to make assertions using the PredicateBuilder more fluent.

    This allows assertions to be declared as follows:

    assertThat(logger).hasLogged(aLog().withLevel(Level.WARN).withMessage("Something"));

    as opposed to:

    assertThat(logger).hasLogged(new PredicateBuilder().withLevel(Level.WARN).withMessage("Something").build());

Updates:

  • Bump org.slf4j:slf4j-api from 2.0.6 to 2.0.7
  • Bump org.assertj:assertj-core from 3.23.1 to 3.24.2

v2.8.1

05 Jan 10:29
fbe2c64
Compare
Choose a tag to compare

slf4j-test-2.8.1 (2023-01-05)

Full Changelog

Fixes:

v2.8.0

28 Dec 20:47
6ff0906
Compare
Choose a tag to compare

slf4j-test-2.8.0 (2022-12-28)

Full Changelog

Implemented enhancements:

  • #188 via #328 - Restructure assertions to be based on predicates (by @topbadger)

    By re-structuring the assertion logic to be based upon predicates, the following enhancements have been made:

    Custom Predicates

    Consumers can now provide custom predicates so that they can assert on LoggingEvents in specific ways in addition to the ways previously supported by the library.

    Example:

    assertThat(logger)
        .hasLogged(event -> event.getFormattedMessage().startsWith("First section of long log message"));

    MDC Comparison Strategy

    The MDC comparison strategy can now be set by consumers.

    • The full MDC context isn't always relevant to the test, yet the assertions previously enforced this check. The result was that people were unable to use the fluent assertions we provide in a number of scenarios.
    • The previous behaviour of requiring the MDC contents to match exactly has been retained as the default.

    Example:

    assertThat(logger)
        .usingMdcComparator(MdcComparator.IGNORING)
        .hasLogged(warn("Some log message"));

    Enhanced Assertion Failure Messages

    Assertion failure messages have been enhanced to show the list of LoggingEvents that were actually captured to make debugging the cause of the failure easier.

    Example:

    Failed to find event:
      LoggingEvent{level=ERROR, mdc={}, marker=Optional.empty, throwable=Optional[throwable], message='There was a problem!', arguments=[]}
    
    The logger contained the following events:
      - LoggingEvent{level=WARN, mdc={}, marker=Optional.empty, throwable=Optional.empty, message='Some other problem', arguments=[]}
      - LoggingEvent{level=ERROR, mdc={}, marker=Optional.empty, throwable=Optional.empty, message='Yet another problem', arguments=[]}
    

v.2.7.0

19 Dec 19:59
3a6da95
Compare
Choose a tag to compare

slf4j-test-2.7.0 (2022-12-19)

Full Changelog

Implemented enhancements:

  • #314 via #324 - Introduce a new capture.level property and API to control captured events globally (by @youribonnaffe)

    Introduce a new global setting capture.level to disable storing (and printing) logs at a given level (following the level hierarchy).

    The implementation is very similar to the print.level global setting.

    This is useful when tests are generating a lot of logging events that are not of interest and don't need to be captured. ArchUnit tests are known to be such tests and can be quite slow when slf4j-test is used.

Updates:

  • Bump org.slf4j:slf4j-api from 2.0.0-alpha7 to 2.0.6
  • Bump joda-time:joda-time from 2.10.14 to 2.12.2
  • Bump org.assertj:assertj-core from 3.22.0 to 3.23.1

v2.6.1

01 Apr 14:21
68cbc7f
Compare
Choose a tag to compare

slf4j-test-2.6.1 (2022-04-01)

Full Changelog

Fixes:

  • #255 via #257 Fix memory leak when clearing logs in all threads (by @sofiamorseletto)
    Going back to the custom ThreadLocal implementation (uk.org.lidalia.lang.ThreadLocal) in order to prevent memory leaks.

v2.6.0

22 Mar 11:09
cfce4a6
Compare
Choose a tag to compare

slf4j-test-2.6.0 (2022-03-21)

Full Changelog

Implemented enhancements:

  • #247 Log events found when AssertJ assertion fails (by @jamietanna)
    This helps quite a bit with diagnosing why an assertion fails, as the alternative is to either attach a debugger or System.out.println the logging events found.
  • #250 via #251 Add TCCL attribute to LoggingEvent (by @sofiamorseletto)
    The changes add an attribute on LoggingEvent which contains the Thread Context Classloader used when the logging event was created. This allows the assertion of the TCCL of a certain log to check that the log was handled by the correct classloader.

Updates:

  • Bump org.slf4j:slf4j-api from 2.0.0-alpha6 to 2.0.0-alpha7
  • Bump com.google.guava:guava from 31.0.1-jre to 31.1-jre
  • Bump joda-time:joda-time from 2.10.13 to 2.10.14

v2.5.0

08 Feb 15:51
1c31621
Compare
Choose a tag to compare

slf4j-test-2.5.0 (2022-02-08)

Full Changelog

Updates:

v2.4.1

23 Dec 21:32
3a45af0
Compare
Choose a tag to compare

slf4j-test-2.4.1 (2021-12-23)

Full Changelog

Implemented enhancements:

  • #207 - Enable assertions to be made on LoggingEvents from any thread (by @topbadger)
    The current implementation only verifies against the LoggingEvents captured by the thread that is running the test. TestLogger provides access to all events captured across any thread via TestLogger::getAllLoggingEvents() so a modifying method has been added to the assertion class to allow the assertion mode to be switched.

    Example usage:

    assertThat(logger).anyThread().hasLogged(...);
    
  • #220 via #221 - Format null-s in LoggingEvent#getFormattedMessage() the same way as SLF4J (by @josephw)
    LoggingEvent#getFormattedMessage() is public (#23). However, it hasn't presented null values the same way as SLF4J, due to un-matched wrapping/unwrapping of Optional:

    LoggingEvent e = new LoggingEvent(Level.INFO, "Content: {}, {}", null, "value");
    System.out.println(e.getFormattedMessage());
    

    Produced previously:

    Content: Optional.empty, value
    

    Produces now:

    Content: null, value
    

Updates:

  • Bump org.slf4j:slf4j-api from 2.0.0-alpha4 to 2.0.0-alpha5
  • Bump joda-time:joda-time from 2.10.10 to 2.10.13
  • Bump com.google.guava:guava from 30.1.1-jre to 31.0.1-jre
  • Bump org.assertj:assertj-core from 3.20.2 to 3.21.0