vy commented on issue #3885: URL: https://github.com/apache/logging-log4j2/issues/3885#issuecomment-3199856312
> Should we fix the test class to skip this case if the zone offset contains fractions of an hour? I was reluctant to suggest this, but since you also thought of documenting this in the tests, maybe it is indeed a good idea. @ppkarwasz, shall we also duplicate the test suite such that host tz is configured with some known-to-be-problematic time zones? That is, ```diff import static org.assertj.core.api.Assertions.assertThat; import java.time.Instant; +import java.util.Arrays; +import java.util.TimeZone; +import java.util.stream.Stream; import org.apache.logging.log4j.core.time.MutableInstant; import org.apache.logging.log4j.core.util.internal.instant.InstantPatternFormatter; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; class NamedInstantPatternTest { + private static final TimeZone HOST_TZ = TimeZone.getDefault(); + + @AfterAll + static void restoreHostTz() { + TimeZone.setDefault(HOST_TZ); + } + + static Stream<Arguments> timeZonesAndNamedInstantPatterns() { + return Stream.of(HOST_TZ.getID(), "IST", "America/Jujuy", "America/Santiago") + .distinct() + .flatMap(tz -> Arrays.stream(NamedInstantPattern.values()) + .map(namedInstantPattern -> Arguments.of(tz, namedInstantPattern))); + } + @ParameterizedTest - @EnumSource(NamedInstantPattern.class) - void compatibilityOfLegacyPattern(NamedInstantPattern namedPattern) { + @MethodSource("timeZonesAndNamedInstantPatterns") + void compatibilityOfLegacyPattern(TimeZone timeZone, NamedInstantPattern namedPattern) { + TimeZone.setDefault(timeZone); InstantPatternFormatter legacyFormatter = InstantPatternFormatter.newBuilder() .setPattern(namedPattern.getLegacyPattern()) .setLegacyFormattersEnabled(true) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org