From 414419f6e5d21661a18877b433e1935235fa0e79 Mon Sep 17 00:00:00 2001
From: strangelookingnerd
<49242855+strangelookingnerd@users.noreply.github.com>
Date: Tue, 19 Nov 2024 21:23:26 +0100
Subject: [PATCH 1/2] Migrate tests to JUnit5
---
.../apache/log4j/BasicConfiguratorTest.java | 12 +-
.../apache/log4j/CallerInformationTest.java | 6 +-
.../java/org/apache/log4j/CategoryTest.java | 75 ++++----
.../org/apache/log4j/ConsoleAppenderTest.java | 10 +-
.../java/org/apache/log4j/LayoutTest.java | 3 +-
.../test/java/org/apache/log4j/LevelTest.java | 73 ++++----
.../java/org/apache/log4j/ListAppender.java | 3 +-
.../java/org/apache/log4j/LogManagerTest.java | 4 +-
.../java/org/apache/log4j/LogWithMDCTest.java | 6 +-
.../org/apache/log4j/LogWithRouteTest.java | 6 +-
.../org/apache/log4j/LoggerJira3410Test.java | 4 +-
.../java/org/apache/log4j/LoggerTest.java | 77 ++++----
.../java/org/apache/log4j/LoggingTest.java | 4 +-
.../java/org/apache/log4j/MDCTestCase.java | 10 +-
.../test/java/org/apache/log4j/NDCTest.java | 8 +-
.../java/org/apache/log4j/PriorityTest.java | 60 +++----
.../log4j/PropertyConfiguratorTest.java | 7 +-
.../log4j/bridge/LogEventWrapperTest.java | 6 +-
.../log4j/builders/BuilderManagerTest.java | 4 +-
.../filter/LevelRangeFilterBuilderTest.java | 16 +-
.../layout/PatternLayoutBuilderTest.java | 10 +-
...tractLog4j1ConfigurationConverterTest.java | 2 +-
.../AbstractLog4j1ConfigurationTest.java | 106 +++++------
.../log4j/config/AsyncAppenderTest.java | 4 +-
.../apache/log4j/config/AutoConfigTest.java | 10 +-
.../Log4j1ConfigurationFactoryTest.java | 43 ++---
.../log4j/config/MapRewriteAppenderTest.java | 10 +-
.../PropertiesConfigurationFactoryTest.java | 6 +-
.../config/PropertiesConfigurationTest.java | 42 ++---
.../config/PropertiesReconfigurationTest.java | 10 +-
.../PropertiesRollingWithPropertiesTest.java | 6 +-
.../log4j/config/RewriteAppenderTest.java | 10 +-
.../SocketAppenderConfigurationTest.java | 11 +-
.../SyslogAppenderConfigurationTest.java | 14 +-
.../log4j/config/SyslogAppenderTest.java | 10 +-
.../config/XmlConfigurationFactoryTest.java | 6 +-
.../log4j/config/XmlConfigurationTest.java | 24 +--
.../log4j/config/XmlReconfigurationTest.java | 4 +-
.../config/XmlRollingWithPropertiesTest.java | 6 +-
.../log4j/helpers/BoundedFIFOTestCase.java | 20 +--
.../log4j/helpers/CyclicBufferTestCase.java | 20 +--
.../helpers/OptionConverterLevelTest.java | 13 +-
.../log4j/helpers/UtilLoggingLevelTest.java | 4 +-
.../log4j/layout/Log4j1SyslogLayoutTest.java | 4 +-
.../log4j/layout/Log4j1XmlLayoutTest.java | 6 +-
.../log4j/pattern/FormattingInfoTest.java | 4 +-
.../Log4j1LevelPatternConverterTest.java | 4 +-
.../Log4j1MdcPatternConverterTest.java | 10 +-
.../Log4j1NdcPatternConverterTest.java | 10 +-
.../log4j/pattern/NameAbbreviatorTest.java | 2 +-
.../log4j/spi/ThrowableInformationTest.java | 10 +-
.../org/apache/log4j/xml/DOMTestCase.java | 8 +-
.../log4j/util/java9/ProcessIdUtilTest.java | 4 +-
.../log4j/util/java9/StackLocatorTest.java | 20 +--
.../log4j/test/AbstractSerializationTest.java | 2 +-
.../log4j/test/ThreadContextUtilityClass.java | 4 +-
.../logging/log4j/AbstractLoggerTest.java | 42 ++---
.../log4j/CloseableThreadContextTest.java | 30 ++--
.../apache/logging/log4j/EventLoggerTest.java | 6 +-
.../logging/log4j/LambdaLoggerTest.java | 146 +++++++--------
.../org/apache/logging/log4j/LevelTest.java | 22 +--
.../apache/logging/log4j/LogManagerTest.java | 22 +--
.../logging/log4j/LoggerSupplierTest.java | 30 ++--
.../org/apache/logging/log4j/LoggerTest.java | 114 ++++++------
.../org/apache/logging/log4j/MarkerTest.java | 20 +--
.../logging/log4j/NoopThreadContextTest.java | 4 +-
.../log4j/ThreadContextInheritanceTest.java | 32 ++--
.../logging/log4j/ThreadContextTest.java | 36 ++--
.../logging/log4j/TraceLoggingTest.java | 6 +-
.../log4j/internal/DefaultLogBuilderTest.java | 4 +-
.../map/UnmodifiableArrayBackedMapTest.java | 75 ++++----
.../log4j/message/FormattedMessageTest.java | 26 +--
.../message/LocalizedMessageFactoryTest.java | 14 +-
.../log4j/message/LocalizedMessageTest.java | 14 +-
.../logging/log4j/message/MapMessageTest.java | 54 +++---
.../message/MessageFormatMessageTest.java | 16 +-
.../log4j/message/MessageFormatsPerfTest.java | 20 +--
.../log4j/message/ObjectArrayMessageTest.java | 6 +-
.../log4j/message/ObjectMessageTest.java | 12 +-
.../log4j/message/ParameterFormatterTest.java | 6 +-
.../message/ReusableMessageFactoryTest.java | 13 +-
.../message/ReusableObjectMessageTest.java | 24 +--
.../ReusableParameterizedMessageTest.java | 24 +--
.../message/ReusableSimpleMessageTest.java | 24 +--
.../log4j/message/SimpleMessageTest.java | 4 +-
.../message/StringFormattedMessageTest.java | 20 +--
.../message/StructuredDataMessageTest.java | 16 +-
.../log4j/message/ThreadDumpMessageTest.java | 12 +-
.../log4j/simple/SimpleLoggerTest.java | 12 +-
.../spi/DefaultThreadContextStackTest.java | 52 +++---
.../logging/log4j/spi/LoggerAdapterTest.java | 6 +-
.../spi/MutableThreadContextStackTest.java | 66 +++----
.../test/junit/TempLoggingDirectoryTest.java | 2 +-
.../test/junit/TestPropertySourceTest.java | 8 +-
.../apache/logging/log4j/util/CharsTest.java | 6 +-
.../logging/log4j/util/ConstantsTest.java | 4 +-
.../util/EnvironmentPropertySourceTest.java | 4 +-
.../logging/log4j/util/LambdaUtilTest.java | 24 +--
.../LegacyPropertiesCompatibilityTest.java | 4 +-
.../util/Log4jCharsetsPropertiesTest.java | 4 +-
.../logging/log4j/util/ProcessIdUtilTest.java | 6 +-
.../util/PropertiesPropertySourceTest.java | 6 +-
.../log4j/util/PropertiesUtilOrderTest.java | 6 +-
.../util/PropertySourceCamelCaseTest.java | 4 +-
.../util/PropertySourceTokenizerTest.java | 4 +-
.../log4j/util/ServiceLoaderUtilTest.java | 8 +-
.../log4j/util/SortedArrayStringMapTest.java | 118 ++++++------
.../log4j/util/StackLocatorTestIT.java | 5 +-
.../log4j/util/StackLocatorUtilTest.java | 20 +--
.../log4j/util/StringBuildersTest.java | 12 +-
.../logging/log4j/util/StringsTest.java | 18 +-
.../SystemPropertiesPropertySourceTest.java | 4 +-
.../apache/logging/log4j/util/Unbox1Test.java | 26 +--
.../log4j/util/Unbox2ConfigurableTest.java | 10 +-
.../log4j/cassandra/CassandraRule.java | 4 +-
.../log4j/FilterPerformanceComparison.java | 41 +++--
.../logging/log4j/PerformanceComparison.java | 23 ++-
.../apache/logging/log4j/PerformanceRun.java | 2 +-
.../logging/log4j/core/SimplePerfTest.java | 37 ++--
.../logging/log4j/core/ThreadedPerfTest.java | 17 +-
.../logging/log4j/core/ThreadedTest.java | 9 +-
.../core/async/perftest/PerfTestDriver.java | 9 +-
.../log4j/FormatterLoggerManualExample.java | 2 +-
.../logging/log4j/MarkerMixInJsonTest.java | 7 +-
.../apache/logging/log4j/MarkerMixInTest.java | 35 ++--
.../logging/log4j/MarkerMixInXmlTest.java | 7 +-
.../logging/log4j/MarkerMixInYamlTest.java | 7 +-
.../log4j/core/AppenderRefLevelJsonTest.java | 8 +-
.../log4j/core/AppenderRefLevelTest.java | 12 +-
.../logging/log4j/core/BasicLoggingTest.java | 4 +-
.../log4j/core/CollectionLoggingTest.java | 8 +-
.../log4j/core/CustomLevelsOverrideTest.java | 10 +-
.../logging/log4j/core/CustomLevelsTest.java | 8 +-
.../core/CustomLevelsWithFiltersTest.java | 10 +-
.../logging/log4j/core/DeadlockTest.java | 4 +-
.../logging/log4j/core/ExtendedLevelTest.java | 4 +-
.../core/GcFreeAsynchronousLoggingTest.java | 4 +-
.../core/GcFreeMixedSyncAsyncLoggingTest.java | 4 +-
.../core/GcFreeSynchronousLoggingTest.java | 4 +-
.../logging/log4j/core/HostNameTest.java | 4 +-
.../logging/log4j/core/LateConfigTest.java | 14 +-
.../apache/logging/log4j/core/LevelTest.java | 4 +-
.../logging/log4j/core/Log4j1222Test.java | 11 +-
.../logging/log4j/core/LogEventTest.java | 12 +-
.../logging/log4j/core/LoggerDateTest.java | 2 +-
.../apache/logging/log4j/core/LoggerTest.java | 74 ++++----
.../logging/log4j/core/LoggerUpdateTest.java | 6 +-
.../apache/logging/log4j/core/LookupTest.java | 7 +-
...olverDoesNotEvaluateThreadContextTest.java | 10 +-
.../log4j/core/PatternSelectorTest.java | 8 +-
.../core/PatternVariableResolverTest.java | 2 +-
.../log4j/core/PropertiesFileConfigTest.java | 2 +-
...bleParameterizedMessageMemoryLeakTest.java | 4 +-
.../log4j/core/ShutdownDisabledTest.java | 4 +-
.../ShutdownTimeoutConfigurationTest.java | 4 +-
.../log4j/core/StrictXmlConfigTest.java | 22 +--
.../log4j/core/TimestampMessageTest.java | 8 +-
.../apache/logging/log4j/core/XmlEvents.java | 4 +-
.../appender/AbstractAppenderBuilderTest.java | 4 +-
.../AsyncAppenderQueueFullPolicyTest.java | 6 +-
.../core/appender/AsyncAppenderTest.java | 25 +--
.../ConsoleAppenderAnsiStyleLayoutMain.java | 6 +-
.../ConsoleAppenderAnsiXExceptionMain.java | 6 +-
.../appender/ConsoleAppenderBuilderTest.java | 8 +-
.../core/appender/ConsoleAppenderTest.java | 16 +-
.../core/appender/FailoverAppenderTest.java | 16 +-
.../FailoverFailedPrimaryAppenderTest.java | 16 +-
.../appender/FileAppenderBuilderTest.java | 12 +-
.../appender/FileAppenderPermissionsTest.java | 14 +-
.../log4j/core/appender/FileAppenderTest.java | 21 ++-
.../log4j/core/appender/HttpAppenderTest.java | 2 +-
.../core/appender/InMemoryAppenderTest.java | 8 +-
.../JsonCompleteFileAppenderTest.java | 7 +-
.../MemoryMappedFileAppenderTest.java | 6 +-
.../appender/MemoryMappedFileManagerTest.java | 6 +-
.../appender/OutputStreamAppenderTest.java | 42 +++--
.../appender/OutputStreamManagerTest.java | 4 +-
.../RandomAccessFileAppenderTest.java | 2 +-
.../appender/RandomAccessFileManagerTest.java | 12 +-
.../appender/ReconfigureAppenderTest.java | 4 +-
.../appender/ScriptAppenderSelectorTest.java | 2 +-
.../log4j/core/appender/SmtpAppenderTest.java | 36 ++--
.../appender/SocketAppenderBuilderTest.java | 4 +-
.../appender/SocketAppenderReconnectTest.java | 2 +-
.../SocketAppenderSocketOptionsTest.java | 8 +-
.../SocketAppenderSslSocketOptionsTest.java | 2 +-
.../core/appender/SocketAppenderTest.java | 86 ++++-----
.../core/appender/SyslogAppenderTestBase.java | 32 ++--
.../core/appender/TlsSyslogAppenderTest.java | 10 +-
.../core/appender/TlsSyslogFrameTest.java | 8 +-
.../core/appender/WriterAppenderTest.java | 12 +-
.../appender/XmlCompactFileAppenderTest.java | 39 ++--
.../appender/XmlCompleteFileAppenderTest.java | 11 +-
.../core/appender/XmlFileAppenderTest.java | 30 ++--
.../db/AbstractDatabaseAppenderTest.java | 5 +-
.../db/AbstractDatabaseManagerTest.java | 82 ++++-----
.../db/jdbc/AbstractJdbcDataSourceTest.java | 4 +-
.../appender/db/jdbc/ColumnConfigTest.java | 170 +++++++++---------
.../JdbcAppenderStringSubstitutionTest.java | 2 +-
.../core/appender/mom/JmsAppenderTest.java | 4 +-
.../mom/jeromq/JeroMqAppenderTest.java | 10 +-
.../appender/mom/jeromq/JeroMqTestClient.java | 2 +-
.../kafka/KafkaAppenderCloseTimeoutTest.java | 6 +-
.../appender/mom/kafka/KafkaAppenderTest.java | 17 +-
.../KafkaManagerProducerThreadLeakTest.java | 7 +-
.../appender/nosql/NoSqlAppenderTest.java | 36 ++--
.../LoggerNameLevelRewritePolicyTest.java | 4 +-
.../rewrite/MapRewritePolicyTest.java | 10 +-
.../appender/rewrite/RewriteAppenderTest.java | 10 +-
.../rolling/CronTriggeringPolicyTest.java | 16 +-
.../appender/rolling/EligibleFilesTest.java | 12 +-
.../core/appender/rolling/FileSizeTest.java | 2 +-
.../OnStartupTriggeringPolicyTest.java | 8 +-
.../rolling/PatternProcessorTest.java | 52 +++---
.../RandomRollingAppenderOnStartupTest.java | 11 +-
.../rolling/RollingAppenderCountTest.java | 2 +-
.../RollingAppenderCronAndSizeLookupTest.java | 6 +-
.../RollingAppenderCronAndSizeTest.java | 4 +-
.../RollingAppenderCronOnStartupTest.java | 28 +--
.../RollingAppenderCronOnceADayTest.java | 9 +-
.../rolling/RollingAppenderCronTest.java | 5 +-
.../RollingAppenderDeleteScriptTest.java | 3 +-
.../RollingAppenderDirectWrite1906Test.java | 9 +-
...ingAppenderDirectWriteStartupSizeTest.java | 2 +-
...ectWriteTempCompressedFilePatternTest.java | 4 +-
.../RollingAppenderDirectWriteTest.java | 4 +-
...ngAppenderDirectWriteWithFilenameTest.java | 4 +-
...AppenderDirectWriteWithHtmlLayoutTest.java | 2 +-
...ppenderDirectWriteWithReconfigureTest.java | 4 +-
...lingAppenderNoUnconditionalDeleteTest.java | 2 +-
.../RollingAppenderOnStartup2Test.java | 29 +--
.../RollingAppenderOnStartupDirectTest.java | 32 ++--
.../rolling/RollingAppenderOnStartupTest.java | 18 +-
.../RollingAppenderReconfigureTest.java | 4 +-
...ngAppenderSizeCompressPermissionsTest.java | 2 +-
.../RollingAppenderSizeMaxWidthTest.java | 4 +-
.../RollingAppenderSizeNoCompressTest.java | 4 +-
.../rolling/RollingAppenderSizeTest.java | 6 +-
.../RollingAppenderSizeWithTimeTest.java | 2 +-
...AppenderTempCompressedFilePatternTest.java | 4 +-
.../RollingAppenderTimeAndSizeDirectTest.java | 4 +-
.../RollingAppenderTimeAndSizeTest.java | 4 +-
.../RollingAppenderUncompressedTest.java | 2 +-
.../rolling/RollingDirectSize3490Test.java | 6 +-
.../RollingFileAppenderAccessTest.java | 19 +-
.../RollingFileAppenderBuilderTest.java | 11 +-
...lingFileAppenderInterruptedThreadTest.java | 9 +-
.../RollingFileAppenderLayoutTest.java | 11 +-
.../RollingFileAppenderUpdateDataTest.java | 29 +--
.../rolling/RollingFileManagerTest.java | 22 +--
.../rolling/RollingNewDirectoryTest.java | 2 +-
.../RollingRandomAccessFileManagerTest.java | 28 +--
...enderDirectWriteAndSwitchDirectorTest.java | 4 +-
.../RollingRandomAppenderDirectWriteTest.java | 4 +-
...omAppenderDirectWriteWithFilenameTest.java | 4 +-
.../rolling/RolloverFilePatternTest.java | 20 +--
.../rolling/RolloverWithPaddingTest.java | 6 +-
.../action/Bzip2CompressActionTest.java | 10 +-
.../rolling/action/DeleteActionTest.java | 18 +-
.../rolling/action/DeletingVisitorTest.java | 20 +--
.../appender/rolling/action/DurationTest.java | 28 +--
.../rolling/action/FileRenameActionTest.java | 12 +-
.../appender/rolling/action/FileSizeTest.java | 6 +-
.../action/IfAccumulatedFileCountTest.java | 10 +-
.../action/IfAccumulatedFileSizeTest.java | 16 +-
.../appender/rolling/action/IfAnyTest.java | 10 +-
.../rolling/action/IfFileNameTest.java | 20 +--
.../rolling/action/IfLastModifiedTest.java | 14 +-
.../appender/rolling/action/IfNotTest.java | 10 +-
.../rolling/action/PathConditionTest.java | 10 +-
.../PathSortByModificationTimeTest.java | 8 +-
.../rolling/action/ScriptConditionTest.java | 16 +-
.../rolling/action/SortingVisitorTest.java | 12 +-
.../routing/JsonRoutingAppender2Test.java | 3 +-
.../routing/JsonRoutingAppenderTest.java | 3 +-
.../PropertiesRoutingAppenderTest.java | 7 +-
.../routing/RoutingAppender2767Test.java | 4 +-
.../routing/RoutingAppender3350Test.java | 2 +-
...outingAppenderKeyLookupEvaluationTest.java | 4 +-
.../appender/routing/RoutingAppenderTest.java | 7 +-
.../routing/RoutingAppenderWithJndiTest.java | 28 +--
.../RoutingAppenderWithPurgingTest.java | 6 +-
.../routing/RoutingDefaultAppenderTest.java | 3 +-
.../AsyncAppenderExceptionHandlingTest.java | 13 +-
.../AsyncLoggerArgumentFreedOnErrorTest.java | 6 +-
.../AsyncLoggerClassLoadDeadlockTest.java | 25 +--
.../async/AsyncLoggerConfigAutoFlushTest.java | 28 +--
.../async/AsyncLoggerConfigErrorOnFormat.java | 34 ++--
.../core/async/AsyncLoggerConfigTest.java | 8 +-
.../core/async/AsyncLoggerConfigTest2.java | 26 +--
...AsyncLoggerConfigUseAfterShutdownTest.java | 18 +-
...AsyncLoggerConfigWithAsyncEnabledTest.java | 30 ++--
...LoggerContextSelectorInitialStateTest.java | 14 +-
.../async/AsyncLoggerContextSelectorTest.java | 31 ++--
.../core/async/AsyncLoggerContextTest.java | 6 +-
...AsyncLoggerCustomSelectorLocationTest.java | 24 +--
.../async/AsyncLoggerDefaultLocationTest.java | 36 ++--
...ncLoggerEventTranslationExceptionTest.java | 10 +-
.../core/async/AsyncLoggerLocationTest.java | 34 ++--
.../core/async/AsyncLoggerNanoTimeTest.java | 41 ++---
.../log4j/core/async/AsyncLoggerTest.java | 38 ++--
.../AsyncLoggerTestCachedThreadName.java | 36 ++--
.../AsyncLoggerTestUncachedThreadName.java | 36 ++--
.../async/AsyncLoggerThreadContextTest.java | 6 +-
.../AsyncLoggerThreadNameStrategyTest.java | 38 ++--
.../AsyncLoggerTimestampMessageTest.java | 32 ++--
.../AsyncLoggerUseAfterShutdownTest.java | 24 +--
.../AsyncLoggersWithAsyncAppenderTest.java | 4 +-
...AsyncLoggersWithAsyncLoggerConfigTest.java | 8 +-
.../AsyncQueueFullPolicyFactoryTest.java | 36 ++--
.../AsyncRootLoggerDefaultLocationTest.java | 36 ++--
...trategyFactoryConfigGlobalLoggersTest.java | 28 +--
.../AsyncWaitStrategyFactoryConfigTest.java | 20 +--
...ctoryIncorrectConfigGlobalLoggersTest.java | 26 +--
.../BasicAsyncLoggerContextSelectorTest.java | 50 +++---
.../DefaultAsyncQueueFullPolicyTest.java | 16 +-
.../DiscardingAsyncQueueFullPolicyTest.java | 70 ++++----
.../core/async/Log4j2Jira1688AsyncTest.java | 2 +-
.../log4j/core/async/Log4j2Jira1688Test.java | 2 +-
.../core/async/QueueFullAsyncLogger3Test.java | 4 +-
.../core/async/RingBufferLogEventTest.java | 3 +-
.../log4j/core/config/AdvertiserTest.java | 12 +-
.../config/AppenderControlArraySetTest.java | 26 +--
.../CompositeConfigurationMissingTest.java | 6 +-
.../config/CompositeConfigurationTest.java | 16 +-
.../core/config/ConfigurationFactoryTest.java | 5 +-
.../config/ConfigurationPropertyTest.java | 6 +-
.../core/config/ConfigurationSourceTest.java | 2 +-
.../log4j/core/config/Configurator1Test.java | 48 ++---
.../log4j/core/config/Configurator2Test.java | 12 +-
.../core/config/ConfiguratorErrorTest.java | 6 +-
.../core/config/ConfiguratorSetLevelTest.java | 4 +-
.../core/config/CustomConfigurationTest.java | 7 +-
.../log4j/core/config/FileOutputTest.java | 5 +-
.../core/config/JiraLog4j2_2134Test.java | 12 +-
.../log4j/core/config/LoggerConfigTest.java | 16 +-
.../log4j/core/config/LoggersPluginTest.java | 4 +-
.../core/config/MissingLanguageTest.java | 6 +-
.../core/config/MissingRootLoggerTest.java | 4 +-
.../core/config/NestedLoggerConfigTest.java | 29 ++-
.../log4j/core/config/NoLanguagesTest.java | 6 +-
.../core/config/PropertiesPluginTest.java | 6 +-
.../log4j/core/config/PropertyTest.java | 12 +-
.../config/ReconfigurationDeadlockTest.java | 18 +-
.../config/ReconfigurationFailureTest.java | 15 +-
.../config/arbiters/BasicArbiterTest.java | 16 +-
.../arbiters/EnvironmentArbiterTest.java | 12 +-
.../config/arbiters/ScriptArbiterTest.java | 16 +-
.../config/arbiters/SelectArbiterTest.java | 14 +-
.../arbiters/SystemPropertyArbiterTest.java | 16 +-
.../builder/ConfigurationAssemblerTest.java | 12 +-
.../builder/ConfigurationBuilderTest.java | 4 +-
.../convert/DateTypeConverterTest.java | 26 +--
.../convert/TypeConverterRegistryTest.java | 30 ++--
.../plugins/convert/TypeConvertersTest.java | 29 +--
.../plugins/processor/PluginCacheTest.java | 25 ++-
.../processor/PluginProcessorTest.java | 37 ++--
.../util/ResolverUtilCustomProtocolTest.java | 28 ++-
.../config/plugins/util/ResolverUtilTest.java | 18 +-
.../validators/RequiredValidatorTest.java | 8 +-
.../validators/ValidHostValidatorTest.java | 10 +-
.../validators/ValidPortValidatorTest.java | 10 +-
.../ValidatingPluginWithFailoverTest.java | 6 +-
...alidatingPluginWithGenericBuilderTest.java | 8 +-
...ginWithGenericSubclassFoo1BuilderTest.java | 8 +-
.../ValidatingPluginWithTypedBuilderTest.java | 8 +-
.../PropertiesConfigurationTest.java | 24 +--
.../config/xml/XmlConfigurationSecurity.java | 5 +-
.../core/config/xml/XmlLoggerPropsTest.java | 4 +-
...geFreeSortedArrayThreadContextMapTest.java | 2 +-
.../log4j/core/filter/AbstractFilterTest.java | 4 +-
.../core/filter/AbstractFilterableTest.java | 54 +++---
.../core/filter/AbstractScriptFilterTest.java | 9 +-
.../core/filter/BurstFilterLogDelayTest.java | 4 +-
.../log4j/core/filter/BurstFilterTest.java | 4 +-
.../core/filter/CompositeFilterTest.java | 4 +-
.../filter/DynamicThresholdFilterTest.java | 15 +-
.../log4j/core/filter/MapFilterTest.java | 9 +-
.../log4j/core/filter/MarkerFilterTest.java | 10 +-
.../log4j/core/filter/NoMarkerFilterTest.java | 8 +-
.../log4j/core/filter/RegexFilterTest.java | 26 ++-
.../core/filter/StringMatchFilterTest.java | 12 +-
.../core/filter/StructuredDataFilterTest.java | 9 +-
.../filter/ThreadContextMapFilterTest.java | 20 +--
.../core/filter/ThresholdFilterTest.java | 8 +-
.../log4j/core/filter/TimeFilterTest.java | 113 ++++--------
...toryPropertySetMissingConstructorTest.java | 8 +-
.../ContextDataFactoryPropertySetTest.java | 14 +-
.../core/impl/ContextDataFactoryTest.java | 14 +-
.../core/impl/JdkMapAdapterStringMapTest.java | 92 +++++-----
.../core/impl/Log4jLogEventNanoTimeTest.java | 13 +-
.../log4j/core/impl/Log4jLogEventTest.java | 35 ++--
.../log4j/core/impl/MutableLogEventTest.java | 18 +-
.../impl/ReusableLogEventFactoryTest.java | 12 +-
.../impl/ThreadContextDataInjectorTest.java | 2 +-
.../jackson/JacksonIssue429MyNamesTest.java | 28 +--
.../core/jackson/JacksonIssue429Test.java | 28 +--
.../log4j/core/jackson/LevelMixInXmlTest.java | 2 +-
.../jackson/StackTraceElementMixInTest.java | 28 +--
.../logging/log4j/core/jmx/ServerTest.java | 22 +--
.../core/layout/AbstractStringLayoutTest.java | 6 +-
.../ConcurrentLoggingWithGelfLayoutTest.java | 4 +-
.../ConcurrentLoggingWithJsonLayoutTest.java | 2 +-
.../core/layout/CsvLogEventLayoutTest.java | 10 +-
.../CsvParameterLayoutAllAsyncTest.java | 27 ++-
.../core/layout/CsvParameterLayoutTest.java | 4 +-
.../log4j/core/layout/GelfLayout2Test.java | 4 +-
.../log4j/core/layout/GelfLayout3Test.java | 6 +-
.../layout/GelfLayoutPatternSelectorTest.java | 4 +-
.../log4j/core/layout/GelfLayoutTest.java | 30 ++--
.../log4j/core/layout/HtmlLayoutTest.java | 32 ++--
.../core/layout/JsonLayoutMillisTest.java | 2 +-
.../log4j/core/layout/JsonLayoutTest.java | 124 +++++++------
.../log4j/core/layout/Log4j2_2195_Test.java | 4 +-
.../log4j/core/layout/LogEventFixtures.java | 12 +-
.../layout/PatternLayoutLookupDateTest.java | 4 +-
.../PatternLayoutMainMapLookupTest.java | 6 +-
.../layout/PatternLayoutNoLookupDateTest.java | 9 +-
.../log4j/core/layout/PatternLayoutTest.java | 55 +++---
.../core/layout/PatternSelectorTest.java | 6 +-
.../log4j/core/layout/Rfc5424LayoutTest.java | 40 ++---
.../core/layout/SerializedLayoutTest.java | 2 +-
.../core/layout/StringBuilderEncoderTest.java | 37 ++--
.../log4j/core/layout/SyslogLayoutTest.java | 8 +-
.../log4j/core/layout/XmlLayoutTest.java | 16 +-
.../log4j/core/layout/YamlLayoutTest.java | 84 +++++----
.../log4j/core/lookup/CaseLookupTest.java | 4 +-
.../core/lookup/ContextMapLookupTest.java | 2 +-
.../log4j/core/lookup/DateLookupTest.java | 8 +-
.../core/lookup/EnvironmentLookupTest.java | 4 +-
.../log4j/core/lookup/EventLookupTest.java | 14 +-
.../log4j/core/lookup/InterpolatorTest.java | 2 +-
.../core/lookup/JndiDisabledLookupTest.java | 6 +-
.../log4j/core/lookup/JndiExploit.java | 3 +-
.../log4j/core/lookup/JndiLookupTest.java | 2 +-
.../core/lookup/JndiRestrictedLookupTest.java | 5 +-
.../log4j/core/lookup/Log4jLookupTest.java | 10 +-
.../lookup/Log4jLookupWithSpacesTest.java | 10 +-
.../log4j/core/lookup/MainLookupTest.java | 4 +-
.../log4j/core/lookup/MapLookupTest.java | 18 +-
.../core/lookup/MarkerLookupConfigTest.java | 4 +-
.../log4j/core/lookup/MarkerLookupTest.java | 14 +-
.../core/lookup/PropertiesLookupTest.java | 16 +-
.../core/lookup/ResourceBundleLookupTest.java | 11 +-
.../log4j/core/lookup/StrSubstitutorTest.java | 56 +++---
.../core/lookup/StructuredDataLookupTest.java | 8 +-
.../lookup/SystemPropertiesLookupTest.java | 8 +-
.../ExtendedThreadInformationTest.java | 4 +-
.../log4j/core/net/JndiManagerTest.java | 14 +-
.../logging/log4j/core/net/PriorityTest.java | 4 +-
.../log4j/core/net/SmtpManagerTest.java | 10 +-
.../core/net/UrlConnectionFactoryTest.java | 2 +-
.../ssl/EnvironmentPasswordProviderTest.java | 6 +-
.../net/ssl/FilePasswordProviderTest.java | 8 +-
.../net/ssl/KeyStoreConfigurationTest.java | 18 +-
.../net/ssl/MemoryPasswordProviderTest.java | 8 +-
.../net/ssl/SslConfigurationFactoryTest.java | 9 +-
.../core/net/ssl/StoreConfigurationTest.java | 8 +-
.../net/ssl/TrustStoreConfigurationTest.java | 21 +--
.../core/parser/JsonLogEventParserTest.java | 46 ++---
.../log4j/core/parser/LogEventParserTest.java | 6 +-
.../core/parser/XmlLogEventParserTest.java | 44 ++---
.../core/parser/YamlLogEventParserTest.java | 42 ++---
.../core/pattern/CallerInformationTest.java | 6 +-
.../pattern/DatePatternConverterTestBase.java | 56 +++---
.../log4j/core/pattern/DisableAnsiTest.java | 6 +-
.../pattern/DynamicWordAbbreviatorTest.java | 7 +-
.../pattern/EncodingPatternConverterTest.java | 12 +-
.../EndOfBatchPatternConverterTest.java | 6 +-
...alsIgnoreCaseReplacementConverterTest.java | 8 +-
.../EqualsReplacementConverterTest.java | 18 +-
.../core/pattern/FormattingInfoTest.java | 8 +-
.../core/pattern/HighlightConverterTest.java | 22 +--
.../pattern/LevelPatternConverterTest.java | 18 +-
.../pattern/LiteralPatternConverterTest.java | 6 +-
...nPatternConvertersRequireLocationTest.java | 3 +-
.../LoggerFqcnPatternConverterTest.java | 4 +-
.../core/pattern/MapPatternConverterTest.java | 8 +-
.../pattern/MarkerPatternConverterTest.java | 4 +-
.../MarkerSimpleNamePatternConverterTest.java | 4 +-
.../core/pattern/MaxLengthConverterTest.java | 8 +-
.../core/pattern/MdcPatternConverterTest.java | 22 +--
.../pattern/MessageAnsiConverterTest.java | 6 +-
.../pattern/MessagePatternConverterTest.java | 22 +--
.../pattern/MessageStyledConverterTest.java | 6 +-
.../core/pattern/NameAbbreviatorTest.java | 40 ++---
.../pattern/NanoTimePatternConverterTest.java | 4 +-
.../core/pattern/NdcPatternConverterTest.java | 10 +-
.../core/pattern/NoConsoleNoAnsiTest.java | 6 +-
.../log4j/core/pattern/PatternParserTest.java | 81 ++++-----
.../ProcessIdPatternConverterTest.java | 4 +-
.../RegexReplacementConverterTest.java | 4 +-
.../core/pattern/RegexReplacementTest.java | 8 +-
.../pattern/RepeatPatternConverterTest.java | 4 +-
.../SequenceNumberPatternConverterTest.java | 4 +-
...eNumberPatternConverterZeroPaddedTest.java | 4 +-
.../SimpleLiteralPatternConverterTest.java | 6 +-
.../core/pattern/StyleConverterTest.java | 14 +-
.../pattern/ThreadIdPatternConverterTest.java | 4 +-
.../ThreadNamePatternConverterTest.java | 4 +-
.../ThreadPriorityPatternConverterTest.java | 4 +-
...ablesNotEmptyReplacementConverterTest.java | 14 +-
.../selector/BasicContextSelectorTest.java | 24 +--
.../ClassLoaderContextSelectorTest.java | 6 +-
.../log4j/core/test/LogBuilderTest.java | 4 +-
.../core/tools/GenerateCustomLoggerTest.java | 6 +-
.../tools/GenerateExtendedLoggerTest.java | 6 +-
.../log4j/core/util/ClockFactoryTest.java | 18 +-
.../core/util/ContextDataProviderTest.java | 6 +-
.../log4j/core/util/CronExpressionTest.java | 28 +--
.../log4j/core/util/CyclicBufferTest.java | 10 +-
.../log4j/core/util/DummyNanoClockTest.java | 6 +-
.../log4j/core/util/FileUtilsTest.java | 20 +--
.../logging/log4j/core/util/InitTest.java | 6 +-
.../logging/log4j/core/util/IntegersTest.java | 6 +-
.../log4j/core/util/JsonUtilsTest.java | 8 +-
.../logging/log4j/core/util/LoaderTest.java | 6 +-
.../logging/log4j/core/util/NetUtilsTest.java | 12 +-
.../log4j/core/util/OptionConverterTest.java | 10 +-
.../util/ShutdownCallbackRegistryTest.java | 8 +-
.../logging/log4j/core/util/SourceTest.java | 46 +++--
.../log4j/core/util/SystemClockTest.java | 6 +-
.../log4j/core/util/SystemNanoClockTest.java | 4 +-
.../logging/log4j/core/util/UuidTest.java | 8 +-
.../util/datetime/FixedDateFormatTest.java | 54 +++---
.../InstantPatternDynamicFormatterTest.java | 2 +-
...tableLogEventWithReusableParamMsgTest.java | 4 +-
.../logging/log4j/io/AbstractStreamTest.java | 2 +-
.../logging/log4j/io/IoBuilderTest.java | 4 +-
.../io/LoggerPrintStreamCallerInfoTest.java | 28 +--
.../log4j/io/LoggerPrintStreamTest.java | 18 +-
.../io/LoggerPrintWriterCallerInfoTest.java | 30 ++--
.../log4j/io/LoggerPrintWriterJdbcH2Test.java | 6 +-
.../log4j/io/LoggerPrintWriterTest.java | 18 +-
.../log4j/smtp/SmtpAppenderAsyncTest.java | 14 +-
.../logging/log4j/smtp/SmtpAppenderTest.java | 17 +-
.../logging/log4j/smtp/SmtpManagerTest.java | 8 +-
.../Log4jServletContainerInitializerTest.java | 22 +--
.../web/Log4jServletContextListenerTest.java | 12 +-
.../log4j/web/Log4jServletFilterTest.java | 12 +-
...hutdownOnContextDestroyedListenerTest.java | 10 +-
.../web/Log4jWebInitializerImplTest.java | 40 ++---
.../logging/log4j/web/PropertyTest.java | 6 +-
.../logging/log4j/web/TestAsyncServlet.java | 8 +-
.../log4j/jcl/CallerInformationTest.java | 6 +-
.../jdbc/PoolableConnectionFactoryTest.java | 4 +-
.../PoolingDriverConnectionSourceTest.java | 12 +-
.../db/jpa/AbstractJpaAppenderTest.java | 5 +-
.../appender/db/jpa/JpaH2AppenderTest.java | 7 +-
.../db/jpa/JpaHsqldbAppenderTest.java | 14 +-
.../appender/db/jpa/LogEventEntityTest.java | 6 +-
.../ContextDataAttributeConverterTest.java | 12 +-
...ContextDataJsonAttributeConverterTest.java | 12 +-
.../ContextMapAttributeConverterTest.java | 12 +-
.../ContextMapJsonAttributeConverterTest.java | 12 +-
.../ContextStackAttributeConverterTest.java | 12 +-
...ontextStackJsonAttributeConverterTest.java | 12 +-
.../InstantAttributeConverterTest.java | 10 +-
.../MarkerAttributeConverterTest.java | 12 +-
.../MessageAttributeConverterTest.java | 10 +-
...ackTraceElementAttributeConverterTest.java | 20 +--
.../ThrowableAttributeConverterTest.java | 12 +-
.../log4j/jpl/Log4jSystemLoggerTest.java | 24 +--
.../log4j/jul/test/AbstractLoggerTest.java | 50 +++---
.../logging/log4j/jul/test/ApiLoggerTest.java | 50 +++---
.../jul/test/AsyncLoggerThreadsTest.java | 28 +--
.../BracketInNotInterpolatedMessageTest.java | 22 +--
.../log4j/jul/test/CallerInformationTest.java | 4 +-
.../log4j/jul/test/CoreLoggerTest.java | 34 ++--
...aultLevelConverterCustomJulLevelsTest.java | 75 ++++----
.../jul/test/DefaultLevelConverterTest.java | 11 +-
.../jul/test/JavaLevelTranslatorTest.java | 29 ++-
.../jul/test/Log4jBridgeHandlerTest.java | 60 +++----
.../jul/test/Log4jLevelTranslatorTest.java | 24 +--
...nTemplateLayoutNullEventDelimiterTest.java | 4 +-
.../layout/template/json/LogstashIT.java | 6 +-
.../ThreadLocalRecyclerNestedLoggingTest.java | 4 +-
.../ReadOnlyStringMapResolverTest.java | 6 +-
.../template/json/util/JsonReaderTest.java | 2 +-
.../mongodb/AbstractMongoDbCappedIT.java | 12 +-
.../log4j/mongodb/MongoDbAuthFailureIT.java | 1 -
.../log4j/mongodb/MongoDbMapMessageIT.java | 14 +-
.../log4j/mongodb/MongoDbResolver.java | 4 +-
.../mongodb4/AbstractMongoDb4CappedIT.java | 12 +-
.../log4j/mongodb4/MongoDb4AuthFailureIT.java | 1 -
.../log4j/mongodb4/MongoDb4MapMessageIT.java | 14 +-
.../log4j/mongodb4/MongoDb4Resolver.java | 4 +-
.../other/pkg/LoggerContextAnchorTest.java | 8 +-
.../logging/slf4j/CallerInformationTest.java | 6 +-
.../apache/logging/slf4j/Log4j1222Test.java | 4 +-
.../apache/logging/slf4j/Log4jMarkerTest.java | 8 +-
.../logging/slf4j/LoggerContextTest.java | 4 +-
.../org/apache/logging/slf4j/LoggerTest.java | 21 ++-
.../org/apache/logging/slf4j/MarkerTest.java | 20 +--
.../apache/logging/slf4j/OptionalTest.java | 9 +-
.../apache/logging/slf4j/OverflowTest.java | 4 +-
.../apache/logging/slf4j/SerializeTest.java | 4 +-
.../ThrowableConsumingMessageFactoryTest.java | 2 +-
.../other/pkg/LoggerContextAnchorTest.java | 8 +-
.../logging/slf4j/CallerInformationTest.java | 8 +-
.../apache/logging/slf4j/Log4j1222Test.java | 4 +-
.../logging/slf4j/Log4jEventBuilderTest.java | 8 +-
.../logging/slf4j/Log4jMDCAdapterTest.java | 4 +-
.../apache/logging/slf4j/Log4jMarkerTest.java | 8 +-
.../logging/slf4j/LoggerContextTest.java | 4 +-
.../org/apache/logging/slf4j/LoggerTest.java | 25 ++-
.../org/apache/logging/slf4j/MarkerTest.java | 20 +--
.../apache/logging/slf4j/OverflowTest.java | 4 +-
.../apache/logging/slf4j/SerializeTest.java | 4 +-
.../ThrowableConsumingMessageFactoryTest.java | 2 +-
.../spring/boot/Log4j2SpringBootInitTest.java | 6 +-
.../Log4j2SpringBootLoggingSystemTest.java | 13 +-
.../log4j/spring/boot/SpringLookupTest.java | 6 +-
.../log4j/spring/boot/SpringProfileTest.java | 2 +-
.../client/Log4j2EventListenerTest.java | 2 +-
.../logging/log4j/taglib/DumpTagTest.java | 40 ++---
.../taglib/ExceptionAwareTagSupportTest.java | 24 +--
.../logging/log4j/taglib/LogTagTest.java | 24 +--
.../taglib/LoggerAwareTagSupportTest.java | 84 ++++-----
.../log4j/taglib/SetLoggerTagTest.java | 138 +++++++-------
.../logging/log4j/taglib/TagLevelTest.java | 22 +--
.../log4j/taglib/TagUtilsLevelTest.java | 27 +--
.../log4j/taglib/TagUtilsScopeTest.java | 24 +--
.../logging/log4j/tojul/JULLoggerTest.java | 4 +-
.../logging/log4j/tojul/LoggerTest.java | 42 ++---
.../logging/slf4j/CallerInformationTest.java | 6 +-
.../logging/slf4j/Log4j2Jira1688Test.java | 4 +-
.../apache/logging/slf4j/LogBuilderTest.java | 4 +-
.../logging/slf4j/LoggerContextResolver.java | 4 +-
.../apache/logging/slf4j/LoggerResolver.java | 4 +-
.../org/apache/logging/slf4j/LoggerTest.java | 44 ++---
.../Log4jServletContainerInitializerTest.java | 20 +--
.../web/Log4jServletContextListenerTest.java | 12 +-
.../log4j/web/Log4jServletFilterTest.java | 12 +-
...hutdownOnContextDestroyedListenerTest.java | 8 +-
.../web/Log4jWebInitializerImplTest.java | 40 ++---
.../logging/log4j/web/PropertyTest.java | 6 +-
.../log4j/web/ServletAppenderTest.java | 4 +-
.../logging/log4j/web/TestAsyncServlet.java | 8 +-
.../logging/log4j/web/WebLookupTest.java | 6 +-
640 files changed, 4998 insertions(+), 5088 deletions(-)
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfiguratorTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfiguratorTest.java
index 0d2d8f49003..ab632507dc0 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfiguratorTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfiguratorTest.java
@@ -22,34 +22,34 @@
/**
* Test {@link BasicConfigurator}.
*/
-public class BasicConfiguratorTest {
+class BasicConfiguratorTest {
@Test
- public void testConfigure() {
+ void testConfigure() {
// TODO More...
BasicConfigurator.configure();
}
@Test
- public void testResetConfiguration() {
+ void testResetConfiguration() {
// TODO More...
BasicConfigurator.resetConfiguration();
}
@Test
- public void testConfigureAppender() {
+ void testConfigureAppender() {
BasicConfigurator.configure(null);
// TODO More...
}
@Test
- public void testConfigureConsoleAppender() {
+ void testConfigureConsoleAppender() {
// TODO What to do? Map to Log4j 2 Appender deeper in the code?
BasicConfigurator.configure(new ConsoleAppender());
}
@Test
- public void testConfigureNullAppender() {
+ void testConfigureNullAppender() {
// The NullAppender name is null and we do not want an NPE when the name is used as a key in a
// ConcurrentHashMap.
BasicConfigurator.configure(NullAppender.getNullAppender());
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java
index 3c5cb502870..1212fc97c0c 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java
@@ -26,10 +26,10 @@
// config from log4j-core test-jar
@LoggerContextSource(value = "log4j2-calling-class.xml")
-public class CallerInformationTest {
+class CallerInformationTest {
@Test
- public void testClassLogger(@Named("Class") final ListAppender app) {
+ void testClassLogger(@Named("Class") final ListAppender app) {
app.clear();
final Logger logger = Logger.getLogger("ClassLogger");
logger.info("Ignored message contents.");
@@ -44,7 +44,7 @@ public void testClassLogger(@Named("Class") final ListAppender app) {
}
@Test
- public void testMethodLogger(@Named("Method") final ListAppender app) {
+ void testMethodLogger(@Named("Method") final ListAppender app) {
app.clear();
final Logger logger = Logger.getLogger("MethodLogger");
logger.info("More messages.");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java
index 073fc7f45a5..1604f82c2af 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java
@@ -18,6 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -51,7 +52,7 @@
/**
* Tests of Category.
*/
-public class CategoryTest {
+class CategoryTest {
static ConfigurationFactory cf = new BasicConfigurationFactory();
@@ -61,7 +62,7 @@ public class CategoryTest {
private static final org.apache.log4j.ListAppender version1Appender = new org.apache.log4j.ListAppender();
@BeforeAll
- public static void setupAll() {
+ static void setupAll() {
appender.start();
version1Appender.setName(VERSION1_APPENDER_NAME);
ConfigurationFactory.setConfigurationFactory(cf);
@@ -69,18 +70,18 @@ public static void setupAll() {
}
@AfterAll
- public static void cleanupAll() {
+ static void cleanupAll() {
ConfigurationFactory.removeConfigurationFactory(cf);
appender.stop();
}
@BeforeEach
- public void before() {
+ void before() {
appender.clear();
}
@Test
- public void testExist() {
+ void testExist() {
assertNull(Category.exists("Does not exist for sure"));
}
@@ -89,7 +90,7 @@ public void testExist() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testForcedLog() {
+ void testForcedLog() {
final MockCategory category = new MockCategory("org.example.foo");
category.setAdditivity(false);
category.setHierarchy(LogManager.getHierarchy());
@@ -98,23 +99,23 @@ public void testForcedLog() {
category.info("Hello, World");
List list = appender.getEvents();
int events = list.size();
- assertEquals(events, 1, "Number of events");
+ assertEquals(1, events, "Number of events");
LogEvent event = list.get(0);
Message msg = event.getMessage();
assertNotNull(msg, "No message");
// LOG4J2-3080: use message type consistently
- assertTrue(msg instanceof SimpleMessage, "Incorrect Message type");
+ assertInstanceOf(SimpleMessage.class, msg, "Incorrect Message type");
assertEquals("Hello, World", msg.getFormat());
appender.clear();
// Logging a String map
category.info(Collections.singletonMap("hello", "world"));
list = appender.getEvents();
events = list.size();
- assertEquals(events, 1, "Number of events");
+ assertEquals(1, events, "Number of events");
event = list.get(0);
msg = event.getMessage();
assertNotNull(msg, "No message");
- assertTrue(msg instanceof MapMessage, "Incorrect Message type");
+ assertInstanceOf(MapMessage.class, msg, "Incorrect Message type");
Object[] objects = msg.getParameters();
assertEquals("world", objects[0]);
appender.clear();
@@ -122,11 +123,11 @@ public void testForcedLog() {
category.info(Collections.singletonMap(1234L, "world"));
list = appender.getEvents();
events = list.size();
- assertEquals(events, 1, "Number of events");
+ assertEquals(1, events, "Number of events");
event = list.get(0);
msg = event.getMessage();
assertNotNull(msg, "No message");
- assertTrue(msg instanceof MapMessage, "Incorrect Message type");
+ assertInstanceOf(MapMessage.class, msg, "Incorrect Message type");
objects = msg.getParameters();
assertEquals("world", objects[0]);
appender.clear();
@@ -135,11 +136,11 @@ public void testForcedLog() {
category.info(obj);
list = appender.getEvents();
events = list.size();
- assertEquals(events, 1, "Number of events");
+ assertEquals(1, events, "Number of events");
event = list.get(0);
msg = event.getMessage();
assertNotNull(msg, "No message");
- assertTrue(msg instanceof ObjectMessage, "Incorrect Message type");
+ assertInstanceOf(ObjectMessage.class, msg, "Incorrect Message type");
objects = msg.getParameters();
assertEquals(obj, objects[0]);
appender.clear();
@@ -147,11 +148,11 @@ public void testForcedLog() {
category.log(Priority.INFO, "Hello, World");
list = appender.getEvents();
events = list.size();
- assertEquals(events, 1, "Number of events");
+ assertEquals(1, events, "Number of events");
event = list.get(0);
msg = event.getMessage();
assertNotNull(msg, "No message");
- assertTrue(msg instanceof SimpleMessage, "Incorrect Message type");
+ assertInstanceOf(SimpleMessage.class, msg, "Incorrect Message type");
assertEquals("Hello, World", msg.getFormat());
appender.clear();
}
@@ -162,16 +163,16 @@ public void testForcedLog() {
* @throws Exception thrown if Category.getChainedPriority can not be found.
*/
@Test
- public void testGetChainedPriorityReturnType() throws Exception {
+ void testGetChainedPriorityReturnType() throws Exception {
final Method method = Category.class.getMethod("getChainedPriority", (Class[]) null);
- assertEquals(method.getReturnType(), Priority.class);
+ assertEquals(Priority.class, method.getReturnType());
}
/**
* Tests l7dlog(Priority, String, Throwable).
*/
@Test
- public void testL7dlog() {
+ void testL7dlog() {
final Logger logger = Logger.getLogger("org.example.foo");
logger.setLevel(Level.ERROR);
final Priority debug = Level.DEBUG;
@@ -183,7 +184,7 @@ public void testL7dlog() {
* Tests l7dlog(Priority, String, Object[], Throwable).
*/
@Test
- public void testL7dlog4Param() {
+ void testL7dlog4Param() {
final Logger logger = Logger.getLogger("org.example.foo");
logger.setLevel(Level.ERROR);
final Priority debug = Level.DEBUG;
@@ -195,7 +196,7 @@ public void testL7dlog4Param() {
* Test using a pre-existing Log4j 2 logger
*/
@Test
- public void testExistingLog4j2Logger() {
+ void testExistingLog4j2Logger() {
// create the logger using LogManager
org.apache.logging.log4j.LogManager.getLogger("existingLogger");
// Logger will be the one created above
@@ -217,7 +218,7 @@ public void testExistingLog4j2Logger() {
*/
@Deprecated
@Test
- public void testSetPriority() {
+ void testSetPriority() {
final Logger logger = Logger.getLogger("org.example.foo");
final Priority debug = Level.DEBUG;
logger.setPriority(debug);
@@ -230,12 +231,12 @@ public void testSetPriority() {
*/
@Deprecated
@Test
- public void testSetPriorityNull() {
+ void testSetPriorityNull() {
Logger.getLogger("org.example.foo").setPriority(null);
}
@Test
- public void testClassName() {
+ void testClassName() {
final Category category = Category.getInstance("TestCategory");
final Layout layout =
PatternLayout.newBuilder().withPattern("%d %p %C{1.} [%t] %m%n").build();
@@ -245,7 +246,7 @@ public void testClassName() {
((org.apache.logging.log4j.core.Logger) category.getLogger()).addAppender(appender);
category.error("Test Message");
final List msgs = appender.getMessages();
- assertEquals(msgs.size(), 1, "Incorrect number of messages. Expected 1 got " + msgs.size());
+ assertEquals(1, msgs.size(), "Incorrect number of messages. Expected 1 got " + msgs.size());
final String msg = msgs.get(0);
appender.clear();
final String threadName = Thread.currentThread().getName();
@@ -256,14 +257,14 @@ public void testClassName() {
}
@Test
- public void testStringLog() {
+ void testStringLog() {
final String payload = "payload";
testMessageImplementation(
- payload, SimpleMessage.class, message -> assertEquals(message.getFormattedMessage(), payload));
+ payload, SimpleMessage.class, message -> assertEquals(payload, message.getFormattedMessage()));
}
@Test
- public void testCharSequenceLog() {
+ void testCharSequenceLog() {
final CharSequence payload = new CharSequence() {
@Override
@@ -293,7 +294,7 @@ public String toString() {
}
@Test
- public void testMapLog() {
+ void testMapLog() {
final String key = "key";
final Object value = 0xDEADBEEF;
final Map payload = Collections.singletonMap(key, value);
@@ -301,7 +302,7 @@ public void testMapLog() {
}
@Test
- public void testObjectLog() {
+ void testObjectLog() {
final Object payload = new Object();
testMessageImplementation(
payload, ObjectMessage.class, message -> assertEquals(message.getParameter(), payload));
@@ -335,7 +336,7 @@ private void testMessageImplementation(
}
@Test
- public void testAddAppender() {
+ void testAddAppender() {
try {
final Logger rootLogger = LogManager.getRootLogger();
int count = version1Appender.getEvents().size();
@@ -363,7 +364,7 @@ public void testAddAppender() {
}
@Test
- public void testGetAppender() {
+ void testGetAppender() {
try {
final Logger rootLogger = LogManager.getRootLogger();
final org.apache.logging.log4j.core.Logger v2RootLogger =
@@ -372,15 +373,17 @@ public void testGetAppender() {
v2RootLogger.addAppender(appender);
final List rootAppenders = Collections.list(rootLogger.getAllAppenders());
assertEquals(1, rootAppenders.size(), "only v1 appenders");
- assertTrue(rootAppenders.get(0) instanceof org.apache.log4j.ListAppender, "appender is a v1 ListAppender");
+ assertInstanceOf(
+ org.apache.log4j.ListAppender.class, rootAppenders.get(0), "appender is a v1 ListAppender");
assertEquals(
VERSION1_APPENDER_NAME,
rootLogger.getAppender(VERSION1_APPENDER_NAME).getName(),
"explicitly named appender");
final Appender v2ListAppender = rootLogger.getAppender(VERSION2_APPENDER_NAME);
- assertTrue(v2ListAppender instanceof AppenderWrapper, "explicitly named appender");
- assertTrue(
- ((AppenderWrapper) v2ListAppender).getAppender() instanceof ListAppender,
+ assertInstanceOf(AppenderWrapper.class, v2ListAppender, "explicitly named appender");
+ assertInstanceOf(
+ ListAppender.class,
+ ((AppenderWrapper) v2ListAppender).getAppender(),
"appender is a v2 ListAppender");
final Logger logger = LogManager.getLogger(CategoryTest.class);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/ConsoleAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/ConsoleAppenderTest.java
index 9b55dd31f84..7fe9a08e29f 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/ConsoleAppenderTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/ConsoleAppenderTest.java
@@ -16,8 +16,8 @@
*/
package org.apache.log4j;
-import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -25,24 +25,24 @@
/**
* Used to test Log4j 1 support.
*/
-public class ConsoleAppenderTest {
+class ConsoleAppenderTest {
private ConsoleAppender consoleAppender;
@BeforeEach
- public void beforeEach() {
+ void beforeEach() {
consoleAppender = new ConsoleAppender();
}
@Test
- public void testFollow() {
+ void testFollow() {
// Only really care that it compiles, behavior is secondary at this level.
consoleAppender.setFollow(true);
assertTrue(consoleAppender.getFollow());
}
@Test
- public void testTarget() {
+ void testTarget() {
// Only really care that it compiles, behavior is secondary at this level.
consoleAppender.setTarget(ConsoleAppender.SYSTEM_OUT);
assertEquals(ConsoleAppender.SYSTEM_OUT, consoleAppender.getTarget());
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LayoutTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LayoutTest.java
index c85b7fe68a1..35c1b2cf1b3 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LayoutTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LayoutTest.java
@@ -116,9 +116,8 @@ protected Layout createLayout() {
/**
* Tests format.
*
- * @throws Exception derived tests, particular XMLLayoutTest, may throw exceptions.
*/
- public void testFormat() throws Exception {
+ public void testFormat() {
final Logger logger = Logger.getLogger("org.apache.log4j.LayoutTest");
final LoggingEvent event =
new LoggingEvent("org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LevelTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LevelTest.java
index b8d0ed92e66..32b574b8de3 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LevelTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LevelTest.java
@@ -17,6 +17,7 @@
package org.apache.log4j;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Locale;
@@ -31,7 +32,7 @@
*
* @since 1.2.12
*/
-public class LevelTest {
+class LevelTest {
/**
* Serialize Level.INFO and check against witness.
@@ -39,7 +40,7 @@ public class LevelTest {
* @throws Exception if exception during test.
*/
@Test
- public void testSerializeINFO() throws Exception {
+ void testSerializeINFO() throws Exception {
final int[] skip = new int[] {};
SerializationTestHelper.assertSerializationEquals(
"target/test-classes/witness/serialization/info.bin", Level.INFO, skip, Integer.MAX_VALUE);
@@ -51,16 +52,16 @@ public void testSerializeINFO() throws Exception {
* @throws Exception if exception during test.
*/
@Test
- public void testDeserializeINFO() throws Exception {
+ void testDeserializeINFO() throws Exception {
final Object obj =
SerializationTestHelper.deserializeStream("target/test-classes/witness/serialization/info.bin");
- assertTrue(obj instanceof Level);
+ assertInstanceOf(Level.class, obj);
final Level info = (Level) obj;
assertEquals("INFO", info.toString());
//
// JDK 1.1 doesn't support readResolve necessary for the assertion
if (!System.getProperty("java.version").startsWith("1.1.")) {
- assertEquals(obj, Level.INFO);
+ assertEquals(Level.INFO, obj);
}
}
@@ -71,10 +72,10 @@ public void testDeserializeINFO() throws Exception {
* @throws Exception if exception during test.
*/
@Test
- public void testCustomLevelSerialization() throws Exception {
+ void testCustomLevelSerialization() throws Exception {
final CustomLevel custom = new CustomLevel();
final Object obj = SerializationTestHelper.serializeClone(custom);
- assertTrue(obj instanceof CustomLevel);
+ assertInstanceOf(CustomLevel.class, obj);
final CustomLevel clone = (CustomLevel) obj;
assertEquals(Level.INFO.level, clone.level);
@@ -105,7 +106,7 @@ public CustomLevel() {
* Tests Level.TRACE_INT.
*/
@Test
- public void testTraceInt() {
+ void testTraceInt() {
assertEquals(5000, Level.TRACE_INT);
}
@@ -113,7 +114,7 @@ public void testTraceInt() {
* Tests Level.TRACE.
*/
@Test
- public void testTrace() {
+ void testTrace() {
assertEquals("TRACE", Level.TRACE.toString());
assertEquals(5000, Level.TRACE.toInt());
assertEquals(7, Level.TRACE.getSyslogEquivalent());
@@ -123,7 +124,7 @@ public void testTrace() {
* Tests Level.toLevel(Level.TRACE_INT).
*/
@Test
- public void testIntToTrace() {
+ void testIntToTrace() {
final Level trace = Level.toLevel(5000);
assertEquals("TRACE", trace.toString());
}
@@ -132,7 +133,7 @@ public void testIntToTrace() {
* Tests Level.toLevel("TRACE");
*/
@Test
- public void testStringToTrace() {
+ void testStringToTrace() {
final Level trace = Level.toLevel("TRACE");
assertEquals("TRACE", trace.toString());
}
@@ -141,7 +142,7 @@ public void testStringToTrace() {
* Tests that Level extends Priority.
*/
@Test
- public void testLevelExtendsPriority() {
+ void testLevelExtendsPriority() {
assertTrue(Priority.class.isAssignableFrom(Level.class));
}
@@ -149,64 +150,64 @@ public void testLevelExtendsPriority() {
* Tests Level.OFF.
*/
@Test
- public void testOFF() {
- assertTrue(Level.OFF instanceof Level);
+ void testOFF() {
+ assertInstanceOf(Level.class, Level.OFF);
}
/**
* Tests Level.FATAL.
*/
@Test
- public void testFATAL() {
- assertTrue(Level.FATAL instanceof Level);
+ void testFATAL() {
+ assertInstanceOf(Level.class, Level.FATAL);
}
/**
* Tests Level.ERROR.
*/
@Test
- public void testERROR() {
- assertTrue(Level.ERROR instanceof Level);
+ void testERROR() {
+ assertInstanceOf(Level.class, Level.ERROR);
}
/**
* Tests Level.WARN.
*/
@Test
- public void testWARN() {
- assertTrue(Level.WARN instanceof Level);
+ void testWARN() {
+ assertInstanceOf(Level.class, Level.WARN);
}
/**
* Tests Level.INFO.
*/
@Test
- public void testINFO() {
- assertTrue(Level.INFO instanceof Level);
+ void testINFO() {
+ assertInstanceOf(Level.class, Level.INFO);
}
/**
* Tests Level.DEBUG.
*/
@Test
- public void testDEBUG() {
- assertTrue(Level.DEBUG instanceof Level);
+ void testDEBUG() {
+ assertInstanceOf(Level.class, Level.DEBUG);
}
/**
* Tests Level.TRACE.
*/
@Test
- public void testTRACE() {
- assertTrue(Level.TRACE instanceof Level);
+ void testTRACE() {
+ assertInstanceOf(Level.class, Level.TRACE);
}
/**
* Tests Level.ALL.
*/
@Test
- public void testALL() {
- assertTrue(Level.ALL instanceof Level);
+ void testALL() {
+ assertInstanceOf(Level.class, Level.ALL);
}
/**
@@ -214,7 +215,7 @@ public void testALL() {
*/
@ParameterizedTest
@MethodSource("org.apache.log4j.helpers.OptionConverterLevelTest#standardLevels")
- public void testVersion2Level(final Level log4j1Level, final org.apache.logging.log4j.Level log4j2Level) {
+ void testVersion2Level(final Level log4j1Level, final org.apache.logging.log4j.Level log4j2Level) {
assertEquals(log4j2Level, log4j1Level.getVersion2Level());
}
@@ -222,7 +223,7 @@ public void testVersion2Level(final Level log4j1Level, final org.apache.logging.
* Tests Level.toLevel(Level.All_INT).
*/
@Test
- public void testIntToAll() {
+ void testIntToAll() {
final Level level = Level.toLevel(Priority.ALL_INT);
assertEquals("ALL", level.toString());
}
@@ -231,7 +232,7 @@ public void testIntToAll() {
* Tests Level.toLevel(Level.FATAL_INT).
*/
@Test
- public void testIntToFatal() {
+ void testIntToFatal() {
final Level level = Level.toLevel(Priority.FATAL_INT);
assertEquals("FATAL", level.toString());
}
@@ -240,7 +241,7 @@ public void testIntToFatal() {
* Tests Level.toLevel(Level.OFF_INT).
*/
@Test
- public void testIntToOff() {
+ void testIntToOff() {
final Level level = Level.toLevel(Priority.OFF_INT);
assertEquals("OFF", level.toString());
}
@@ -249,7 +250,7 @@ public void testIntToOff() {
* Tests Level.toLevel(17, Level.FATAL).
*/
@Test
- public void testToLevelUnrecognizedInt() {
+ void testToLevelUnrecognizedInt() {
final Level level = Level.toLevel(17, Level.FATAL);
assertEquals("FATAL", level.toString());
}
@@ -258,7 +259,7 @@ public void testToLevelUnrecognizedInt() {
* Tests Level.toLevel(null, Level.FATAL).
*/
@Test
- public void testToLevelNull() {
+ void testToLevelNull() {
final Level level = Level.toLevel(null, Level.FATAL);
assertEquals("FATAL", level.toString());
}
@@ -267,7 +268,7 @@ public void testToLevelNull() {
* Test that dotless lower I + "nfo" is recognized as INFO.
*/
@Test
- public void testDotlessLowerI() {
+ void testDotlessLowerI() {
final Level level = Level.toLevel("\u0131nfo");
assertEquals("INFO", level.toString());
}
@@ -277,7 +278,7 @@ public void testDotlessLowerI() {
* even in Turkish locale.
*/
@Test
- public void testDottedLowerI() {
+ void testDottedLowerI() {
final Locale defaultLocale = Locale.getDefault();
final Locale turkey = new Locale("tr", "TR");
Locale.setDefault(turkey);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/ListAppender.java b/log4j-1.2-api/src/test/java/org/apache/log4j/ListAppender.java
index cfc9fe49bcc..34bce86bd63 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/ListAppender.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/ListAppender.java
@@ -71,8 +71,7 @@ public List getMessages() {
* Polls the messages list for it to grow to a given minimum size at most timeout timeUnits and return a copy of
* what we have so far.
*/
- public List getMessages(final int minSize, final long timeout, final TimeUnit timeUnit)
- throws InterruptedException {
+ public List getMessages(final int minSize, final long timeout, final TimeUnit timeUnit) {
waitAtMost(timeout, timeUnit).until(() -> messages.size() >= minSize);
return getMessages();
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LogManagerTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LogManagerTest.java
index 23f4d0f6f30..501d2c36709 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LogManagerTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LogManagerTest.java
@@ -27,7 +27,7 @@
/**
* Tests {@link LogManager}.
*/
-public class LogManagerTest {
+class LogManagerTest {
private static final String SIMPLE_NAME = LogManagerTest.class.getSimpleName();
@@ -38,7 +38,7 @@ List getCurrentLoggerNames() {
}
@Test
- public void testGetCurrentLoggers() {
+ void testGetCurrentLoggers() {
Logger.getLogger(SIMPLE_NAME);
Logger.getLogger(SIMPLE_NAME + ".foo");
Logger.getLogger(SIMPLE_NAME + ".foo.bar");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java
index c908f56f926..0e5165d4796 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java
@@ -30,10 +30,10 @@
* Test logging with MDC values.
*/
@LoggerContextSource("logWithMDC.xml")
-public class LogWithMDCTest {
+class LogWithMDCTest {
@Test
- public void testMDC(@Named("List") final ListAppender listApp) {
+ void testMDC(@Named("List") final ListAppender listApp) {
MDC.put("Key1", "John");
MDC.put("Key2", "Smith");
try {
@@ -42,7 +42,7 @@ public void testMDC(@Named("List") final ListAppender listApp) {
assertNotNull(listApp);
final List msgs = listApp.getMessages();
assertNotNull(msgs, "No messages received");
- assertEquals(msgs.size(), 1);
+ assertEquals(1, msgs.size());
assertTrue(msgs.get(0).contains("Key1=John"), "Key1 is missing");
assertTrue(msgs.get(0).contains("Key2=Smith"), "Key2 is missing");
} finally {
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java
index ffd09175f58..18ad15293c8 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java
@@ -30,10 +30,10 @@
* Test passing MDC values to the Routing appender.
*/
@LoggerContextSource("log-RouteWithMDC.xml")
-public class LogWithRouteTest {
+class LogWithRouteTest {
@Test
- public void testMDC(@Named("List") final ListAppender listApp) {
+ void testMDC(@Named("List") final ListAppender listApp) {
MDC.put("Type", "Service");
MDC.put("Name", "John Smith");
try {
@@ -42,7 +42,7 @@ public void testMDC(@Named("List") final ListAppender listApp) {
assertNotNull(listApp);
final List msgs = listApp.getMessages();
assertNotNull(msgs, "No messages received");
- assertEquals(msgs.size(), 1);
+ assertEquals(1, msgs.size());
assertTrue(msgs.get(0).contains("Type=Service"), "Type is missing");
assertTrue(msgs.get(0).contains("Name=John Smith"), "Name is missing");
} finally {
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerJira3410Test.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerJira3410Test.java
index e7502f7d40c..be16d3d0953 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerJira3410Test.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerJira3410Test.java
@@ -33,10 +33,10 @@
/**
* Tests Jira3410.
*/
-public class LoggerJira3410Test {
+class LoggerJira3410Test {
@Test
- public void test() throws Exception {
+ void test() throws Exception {
try (final LoggerContext loggerContext =
TestConfigurator.configure("target/test-classes/log4j1-list.properties")) {
final Logger logger = LogManager.getLogger("test");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerTest.java
index a2fef9d77b4..da857121038 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerTest.java
@@ -46,7 +46,7 @@
/**
* Used for internal unit testing the Logger class.
*/
-public class LoggerTest {
+class LoggerTest {
Appender a1;
Appender a2;
@@ -61,7 +61,7 @@ public class LoggerTest {
static ConfigurationFactory configurationFactory = new BasicConfigurationFactory();
@BeforeAll
- public static void setUpAll() {
+ static void setUpAll() {
rbUS = ResourceBundle.getBundle("L7D", new Locale("en", "US"));
assertNotNull(rbUS);
@@ -75,12 +75,12 @@ public static void setUpAll() {
}
@AfterAll
- public static void tearDownAll() {
+ static void tearDownAll() {
ConfigurationFactory.removeConfigurationFactory(configurationFactory);
}
@BeforeEach
- public void resetTest() {
+ void resetTest() {
Objects.requireNonNull(LogManager.getHierarchy()).resetConfiguration();
a1 = null;
a2 = null;
@@ -123,7 +123,7 @@ public void resetTest() {
* Test if logger a.b inherits its appender from a.
*/
@Test
- public void testAdditivity1() {
+ void testAdditivity1() {
final Logger loggerA = Logger.getLogger("a");
final Logger loggerAB = Logger.getLogger("a.b");
final CountingAppender coutingAppender = new CountingAppender();
@@ -150,7 +150,7 @@ public void testAdditivity1() {
* Test multiple additivity.
*/
@Test
- public void testAdditivity2() {
+ void testAdditivity2() {
final Logger a = Logger.getLogger("a");
final Logger ab = Logger.getLogger("a.b");
final Logger abc = Logger.getLogger("a.b.c");
@@ -165,20 +165,20 @@ public void testAdditivity2() {
((org.apache.logging.log4j.core.Logger) a.getLogger()).addAppender(ca1);
((org.apache.logging.log4j.core.Logger) abc.getLogger()).addAppender(ca2);
- assertEquals(ca1.counter, 0);
- assertEquals(ca2.counter, 0);
+ assertEquals(0, ca1.counter);
+ assertEquals(0, ca2.counter);
ab.debug(MSG);
- assertEquals(ca1.counter, 1);
- assertEquals(ca2.counter, 0);
+ assertEquals(1, ca1.counter);
+ assertEquals(0, ca2.counter);
abc.debug(MSG);
- assertEquals(ca1.counter, 2);
- assertEquals(ca2.counter, 1);
+ assertEquals(2, ca1.counter);
+ assertEquals(1, ca2.counter);
x.debug(MSG);
- assertEquals(ca1.counter, 2);
- assertEquals(ca2.counter, 1);
+ assertEquals(2, ca1.counter);
+ assertEquals(1, ca2.counter);
ca1.stop();
ca2.stop();
} finally {
@@ -191,7 +191,7 @@ public void testAdditivity2() {
* Test additivity flag.
*/
@Test
- public void testAdditivity3() {
+ void testAdditivity3() {
final Logger root = Logger.getRootLogger();
final Logger a = Logger.getLogger("a");
final Logger ab = Logger.getLogger("a.b");
@@ -209,26 +209,26 @@ public void testAdditivity3() {
((org.apache.logging.log4j.core.Logger) a.getLogger()).addAppender(caA);
((org.apache.logging.log4j.core.Logger) abc.getLogger()).addAppender(caABC);
- assertEquals(caRoot.counter, 0);
- assertEquals(caA.counter, 0);
- assertEquals(caABC.counter, 0);
+ assertEquals(0, caRoot.counter);
+ assertEquals(0, caA.counter);
+ assertEquals(0, caABC.counter);
ab.setAdditivity(false);
a.debug(MSG);
- assertEquals(caRoot.counter, 1);
- assertEquals(caA.counter, 1);
- assertEquals(caABC.counter, 0);
+ assertEquals(1, caRoot.counter);
+ assertEquals(1, caA.counter);
+ assertEquals(0, caABC.counter);
ab.debug(MSG);
- assertEquals(caRoot.counter, 1);
- assertEquals(caA.counter, 1);
- assertEquals(caABC.counter, 0);
+ assertEquals(1, caRoot.counter);
+ assertEquals(1, caA.counter);
+ assertEquals(0, caABC.counter);
abc.debug(MSG);
- assertEquals(caRoot.counter, 1);
- assertEquals(caA.counter, 1);
- assertEquals(caABC.counter, 1);
+ assertEquals(1, caRoot.counter);
+ assertEquals(1, caA.counter);
+ assertEquals(1, caABC.counter);
caRoot.stop();
caA.stop();
caABC.stop();
@@ -304,7 +304,7 @@ public void testDisable1() {
} */
@Test
- public void testRB1() {
+ void testRB1() {
final Logger root = Logger.getRootLogger();
root.setResourceBundle(rbUS);
ResourceBundle t = root.getResourceBundle();
@@ -323,7 +323,7 @@ public void testRB1() {
}
@Test
- public void testRB2() {
+ void testRB2() {
final Logger root = Logger.getRootLogger();
root.setResourceBundle(rbUS);
ResourceBundle t = root.getResourceBundle();
@@ -343,7 +343,7 @@ public void testRB2() {
}
@Test
- public void testRB3() {
+ void testRB3() {
final Logger root = Logger.getRootLogger();
root.setResourceBundle(rbUS);
ResourceBundle t = root.getResourceBundle();
@@ -364,7 +364,7 @@ public void testRB3() {
}
@Test
- public void testExists() {
+ void testExists() {
final Logger a = Logger.getLogger("a");
final Logger a_b = Logger.getLogger("a.b");
final Logger a_b_c = Logger.getLogger("a.b.c");
@@ -379,6 +379,7 @@ public void testExists() {
t = LogManager.exists("a.b.c");
assertSame(a_b_c, t);
}
+
/* Don't support hierarchy
public void testHierarchy1() {
Hierarchy h = new Hierarchy(new RootLogger((Level) Level.ERROR));
@@ -395,7 +396,7 @@ public void testHierarchy1() {
* Tests logger.trace(Object).
*/
@Test
- public void testTrace() {
+ void testTrace() {
final ListAppender appender = new ListAppender("List");
appender.start();
final Logger root = Logger.getRootLogger();
@@ -422,7 +423,7 @@ public void testTrace() {
* Tests logger.trace(Object, Exception).
*/
@Test
- public void testTraceWithException() {
+ void testTraceWithException() {
final ListAppender appender = new ListAppender("List");
appender.start();
final Logger root = Logger.getRootLogger();
@@ -453,7 +454,7 @@ public void testTraceWithException() {
* Tests isTraceEnabled.
*/
@Test
- public void testIsTraceEnabled() {
+ void testIsTraceEnabled() {
final ListAppender appender = new ListAppender("List");
appender.start();
final Logger root = Logger.getRootLogger();
@@ -474,7 +475,7 @@ public void testIsTraceEnabled() {
@Test
@SuppressWarnings("deprecation")
- public void testLog() {
+ void testLog() {
final PatternLayout layout =
PatternLayout.newBuilder().withPattern("%d %C %L %m").build();
final ListAppender appender = new ListAppender("List", null, layout, false, false);
@@ -488,7 +489,7 @@ public void testLog() {
root.log(Priority.INFO, "Test msg2", null);
root.log(Priority.INFO, "Test msg3");
final List msgs = appender.getMessages();
- assertEquals(msgs.size(), 3, "Incorrect number of messages");
+ assertEquals(3, msgs.size(), "Incorrect number of messages");
final String msg = msgs.get(0);
assertTrue(msg.contains(LoggerTest.class.getName()), "Message contains incorrect class name: " + msg);
appender.stop();
@@ -498,7 +499,7 @@ public void testLog() {
}
@Test
- public void testSetLevel() {
+ void testSetLevel() {
final Logger a = Logger.getLogger("a");
final Logger a_b = Logger.getLogger("a.b");
final Logger a_b_c = Logger.getLogger("a.b.c");
@@ -523,7 +524,7 @@ public void testSetLevel() {
}
@Test
- public void testSetPriority() {
+ void testSetPriority() {
final Logger a = Logger.getLogger("a");
final Logger a_b = Logger.getLogger("a.b");
final Logger a_b_c = Logger.getLogger("a.b.c");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java
index 017dde05fa6..0e77fd8962e 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java
@@ -26,10 +26,10 @@
*
*/
@LoggerContextSource("log4j2-config.xml")
-public class LoggingTest {
+class LoggingTest {
@Test
- public void testParent() {
+ void testParent() {
final Logger logger = Logger.getLogger("org.apache.test.logging.Test");
final Category parent = logger.getParent();
assertNotNull(parent, "No parent Logger");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/MDCTestCase.java b/log4j-1.2-api/src/test/java/org/apache/log4j/MDCTestCase.java
index 75353d7dba3..b90b59ae671 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/MDCTestCase.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/MDCTestCase.java
@@ -22,27 +22,27 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class MDCTestCase {
+class MDCTestCase {
@BeforeEach
- public void setUp() {
+ void setUp() {
MDC.clear();
}
@AfterEach
- public void tearDown() {
+ void tearDown() {
MDC.clear();
}
@Test
- public void testPut() {
+ void testPut() {
MDC.put("key", "some value");
assertEquals("some value", MDC.get("key"));
assertEquals(1, MDC.getContext().size());
}
@Test
- public void testRemoveLastKey() {
+ void testRemoveLastKey() {
MDC.put("key", "some value");
MDC.remove("key");
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java
index a45d0702b5d..30173b5e2ee 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java
@@ -22,23 +22,23 @@
import org.apache.logging.log4j.util.Strings;
import org.junit.jupiter.api.Test;
-public class NDCTest {
+class NDCTest {
@Test
- public void testPopEmpty() {
+ void testPopEmpty() {
NDC.clear();
assertEquals(Strings.EMPTY, NDC.pop());
}
@Test
- public void testPeekEmpty() {
+ void testPeekEmpty() {
NDC.clear();
assertEquals(Strings.EMPTY, NDC.peek());
}
@SuppressWarnings({"rawtypes"})
@Test
- public void testCompileCloneToInherit() {
+ void testCompileCloneToInherit() {
NDC.inherit(NDC.cloneStack());
final Stack stackRaw = NDC.cloneStack();
NDC.inherit(stackRaw);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/PriorityTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/PriorityTest.java
index 5fb356d61b5..7d649fdc9b5 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/PriorityTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/PriorityTest.java
@@ -18,7 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.util.Locale;
import java.util.stream.Stream;
@@ -31,13 +31,13 @@
* Tests of Priority.
*
*/
-public class PriorityTest {
+class PriorityTest {
/**
* Tests Priority.OFF_INT.
*/
@Test
- public void testOffInt() {
+ void testOffInt() {
assertEquals(Integer.MAX_VALUE, Priority.OFF_INT);
}
@@ -45,7 +45,7 @@ public void testOffInt() {
* Tests Priority.FATAL_INT.
*/
@Test
- public void testFatalInt() {
+ void testFatalInt() {
assertEquals(50000, Priority.FATAL_INT);
}
@@ -53,7 +53,7 @@ public void testFatalInt() {
* Tests Priority.ERROR_INT.
*/
@Test
- public void testErrorInt() {
+ void testErrorInt() {
assertEquals(40000, Priority.ERROR_INT);
}
@@ -61,7 +61,7 @@ public void testErrorInt() {
* Tests Priority.WARN_INT.
*/
@Test
- public void testWarnInt() {
+ void testWarnInt() {
assertEquals(30000, Priority.WARN_INT);
}
@@ -69,7 +69,7 @@ public void testWarnInt() {
* Tests Priority.INFO_INT.
*/
@Test
- public void testInfoInt() {
+ void testInfoInt() {
assertEquals(20000, Priority.INFO_INT);
}
@@ -77,7 +77,7 @@ public void testInfoInt() {
* Tests Priority.DEBUG_INT.
*/
@Test
- public void testDebugInt() {
+ void testDebugInt() {
assertEquals(10000, Priority.DEBUG_INT);
}
@@ -85,7 +85,7 @@ public void testDebugInt() {
* Tests Priority.ALL_INT.
*/
@Test
- public void testAllInt() {
+ void testAllInt() {
assertEquals(Integer.MIN_VALUE, Priority.ALL_INT);
}
@@ -104,7 +104,7 @@ static Stream testVersion2Level() {
*/
@ParameterizedTest
@MethodSource()
- public void testVersion2Level(final Priority log4j1Priority, final org.apache.logging.log4j.Level log4j2Level) {
+ void testVersion2Level(final Priority log4j1Priority, final org.apache.logging.log4j.Level log4j2Level) {
assertEquals(log4j2Level, log4j1Priority.getVersion2Level());
}
@@ -113,7 +113,7 @@ public void testVersion2Level(final Priority log4j1Priority, final org.apache.lo
*/
@Test
@SuppressWarnings("deprecation")
- public void testFATAL() {
+ void testFATAL() {
assertFalse(Priority.FATAL instanceof Level);
}
@@ -122,7 +122,7 @@ public void testFATAL() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testERROR() {
+ void testERROR() {
assertFalse(Priority.ERROR instanceof Level);
}
@@ -131,7 +131,7 @@ public void testERROR() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testWARN() {
+ void testWARN() {
assertFalse(Priority.WARN instanceof Level);
}
@@ -140,7 +140,7 @@ public void testWARN() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testINFO() {
+ void testINFO() {
assertFalse(Priority.INFO instanceof Level);
}
@@ -149,7 +149,7 @@ public void testINFO() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testDEBUG() {
+ void testDEBUG() {
assertFalse(Priority.DEBUG instanceof Level);
}
@@ -158,8 +158,8 @@ public void testDEBUG() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testEqualsNull() {
- assertFalse(Priority.DEBUG.equals(null));
+ void testEqualsNull() {
+ assertNotEquals(null, Priority.DEBUG);
}
/**
@@ -167,11 +167,11 @@ public void testEqualsNull() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testEqualsLevel() {
+ void testEqualsLevel() {
//
// this behavior violates the equals contract.
//
- assertTrue(Priority.DEBUG.equals(Level.DEBUG));
+ assertEquals(Priority.DEBUG, Level.DEBUG);
}
/**
@@ -179,7 +179,7 @@ public void testEqualsLevel() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testGetAllPossiblePriorities() {
+ void testGetAllPossiblePriorities() {
final Priority[] priorities = Priority.getAllPossiblePriorities();
assertEquals(5, priorities.length);
}
@@ -189,8 +189,8 @@ public void testGetAllPossiblePriorities() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testToPriorityString() {
- assertEquals(Priority.toPriority("DEBUG"), Level.DEBUG);
+ void testToPriorityString() {
+ assertEquals(Level.DEBUG, Priority.toPriority("DEBUG"));
}
/**
@@ -198,8 +198,8 @@ public void testToPriorityString() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testToPriorityInt() {
- assertEquals(Priority.toPriority(Priority.DEBUG_INT), Level.DEBUG);
+ void testToPriorityInt() {
+ assertEquals(Level.DEBUG, Priority.toPriority(Priority.DEBUG_INT));
}
/**
@@ -207,8 +207,8 @@ public void testToPriorityInt() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testToPriorityStringPriority() {
- assertEquals(Priority.toPriority("foo", Priority.DEBUG), Priority.DEBUG);
+ void testToPriorityStringPriority() {
+ assertEquals(Priority.DEBUG, Priority.toPriority("foo", Priority.DEBUG));
}
/**
@@ -216,8 +216,8 @@ public void testToPriorityStringPriority() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testToPriorityIntPriority() {
- assertEquals(Priority.toPriority(17, Priority.DEBUG), Priority.DEBUG);
+ void testToPriorityIntPriority() {
+ assertEquals(Priority.DEBUG, Priority.toPriority(17, Priority.DEBUG));
}
/**
@@ -225,7 +225,7 @@ public void testToPriorityIntPriority() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testDotlessLowerI() {
+ void testDotlessLowerI() {
final Priority level = Priority.toPriority("\u0131nfo");
assertEquals("INFO", level.toString());
}
@@ -236,7 +236,7 @@ public void testDotlessLowerI() {
*/
@Test
@SuppressWarnings("deprecation")
- public void testDottedLowerI() {
+ void testDottedLowerI() {
final Locale defaultLocale = Locale.getDefault();
final Locale turkey = new Locale("tr", "TR");
Locale.setDefault(turkey);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/PropertyConfiguratorTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/PropertyConfiguratorTest.java
index f5190e83468..b80296f898f 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/PropertyConfiguratorTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/PropertyConfiguratorTest.java
@@ -271,7 +271,7 @@ void testInputStream() throws IOException {
* @throws IOException if IOException creating properties jar.
*/
@Test
- public void testJarURL() throws IOException {
+ void testJarURL() throws IOException {
final File dir = new File("output");
dir.mkdirs();
final File file = new File("output/properties.jar");
@@ -287,7 +287,7 @@ public void testJarURL() throws IOException {
}
@Test
- public void testLocalVsGlobal() {
+ void testLocalVsGlobal() {
LoggerRepository repos1, repos2;
final Logger catA = Logger.getLogger(CAT_A_NAME);
final Logger catB = Logger.getLogger(CAT_B_NAME);
@@ -360,10 +360,9 @@ void testURL() throws IOException {
/**
* Test for bug 40944. configure(URL) did not catch IllegalArgumentException and did not close stream.
*
- * @throws IOException if IOException creating properties file.
*/
@Test
- void testURLBadEscape() throws IOException {
+ void testURLBadEscape() {
final URL configURL = PropertyConfiguratorTest.class.getResource(BAD_ESCAPE_PROPERTIES);
PropertyConfigurator.configure(configURL);
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/bridge/LogEventWrapperTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/bridge/LogEventWrapperTest.java
index 8a3e9dd2cfa..ff5faff5f1d 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/bridge/LogEventWrapperTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/bridge/LogEventWrapperTest.java
@@ -23,10 +23,10 @@
import org.apache.logging.log4j.core.LogEvent;
import org.junit.jupiter.api.Test;
-public class LogEventWrapperTest {
+class LogEventWrapperTest {
@Test
- public void testThread() {
+ void testThread() {
final Thread currentThread = Thread.currentThread();
final String threadName = currentThread.getName();
final LoggingEvent log4j1Event = new LoggingEvent() {
@@ -42,7 +42,7 @@ public String getThreadName() {
}
@Test
- public void testToImmutable() {
+ void testToImmutable() {
final LogEventWrapper wrapper = new LogEventWrapper(new LoggingEvent());
assertSame(wrapper, wrapper.toImmutable());
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/BuilderManagerTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/builders/BuilderManagerTest.java
index 9b29ba0dd61..8d6b5a23f9d 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/BuilderManagerTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/builders/BuilderManagerTest.java
@@ -26,7 +26,7 @@
import org.apache.log4j.varia.StringMatchFilter;
import org.junit.jupiter.api.Test;
-public class BuilderManagerTest {
+class BuilderManagerTest {
/**
* This test ensures that instantiation failures due to missing parameters
@@ -34,7 +34,7 @@ public class BuilderManagerTest {
* "instantiate by classname" fallback mechanism for supported components.
*/
@Test
- public void testReturnInvalidValueOnError() {
+ void testReturnInvalidValueOnError() {
final PropertiesConfiguration config = new PropertiesConfiguration(null, null);
final BuilderManager manager = new BuilderManager();
final Properties props = new Properties();
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/filter/LevelRangeFilterBuilderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/builders/filter/LevelRangeFilterBuilderTest.java
index 854c945f311..4a6290da846 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/filter/LevelRangeFilterBuilderTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/builders/filter/LevelRangeFilterBuilderTest.java
@@ -35,11 +35,11 @@
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
-public class LevelRangeFilterBuilderTest {
+class LevelRangeFilterBuilderTest {
@ParameterizedTest
@ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testAcceptOnMatchTrue(final TestLevelRangeFilterBuilder builder) throws Exception {
+ void testAcceptOnMatchTrue(final TestLevelRangeFilterBuilder builder) throws Exception {
final LevelRangeFilter levelRangeFilter = builder.build(Level.INFO, Level.ERROR, true);
assertResult(Result.DENY, levelRangeFilter, Level.ALL);
@@ -53,7 +53,7 @@ public void testAcceptOnMatchTrue(final TestLevelRangeFilterBuilder builder) thr
@ParameterizedTest
@ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testAcceptOnMatchFalse(final TestLevelRangeFilterBuilder builder) throws Exception {
+ void testAcceptOnMatchFalse(final TestLevelRangeFilterBuilder builder) throws Exception {
final LevelRangeFilter levelRangeFilter = builder.build(Level.INFO, Level.ERROR, false);
assertResult(Result.DENY, levelRangeFilter, Level.ALL);
@@ -67,7 +67,7 @@ public void testAcceptOnMatchFalse(final TestLevelRangeFilterBuilder builder) th
@ParameterizedTest
@ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testAcceptOnMatchNull(final TestLevelRangeFilterBuilder builder) throws Exception {
+ void testAcceptOnMatchNull(final TestLevelRangeFilterBuilder builder) throws Exception {
final LevelRangeFilter levelRangeFilter = builder.build(Level.INFO, Level.ERROR, null);
assertResult(Result.DENY, levelRangeFilter, Level.ALL);
@@ -81,7 +81,7 @@ public void testAcceptOnMatchNull(final TestLevelRangeFilterBuilder builder) thr
@ParameterizedTest
@ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testMinLevelNull(final TestLevelRangeFilterBuilder builder) throws Exception {
+ void testMinLevelNull(final TestLevelRangeFilterBuilder builder) throws Exception {
final LevelRangeFilter levelRangeFilter = builder.build(null, Level.ERROR, true);
assertResult(Result.ACCEPT, levelRangeFilter, Level.ALL);
@@ -95,7 +95,7 @@ public void testMinLevelNull(final TestLevelRangeFilterBuilder builder) throws E
@ParameterizedTest
@ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testMaxLevelNull(final TestLevelRangeFilterBuilder builder) throws Exception {
+ void testMaxLevelNull(final TestLevelRangeFilterBuilder builder) throws Exception {
final LevelRangeFilter levelRangeFilter = builder.build(Level.INFO, null, true);
assertResult(Result.DENY, levelRangeFilter, Level.ALL);
@@ -109,7 +109,7 @@ public void testMaxLevelNull(final TestLevelRangeFilterBuilder builder) throws E
@ParameterizedTest
@ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testMinMaxLevelSame(final TestLevelRangeFilterBuilder builder) throws Exception {
+ void testMinMaxLevelSame(final TestLevelRangeFilterBuilder builder) throws Exception {
final LevelRangeFilter levelRangeFilter = builder.build(Level.INFO, Level.INFO, true);
assertResult(Result.DENY, levelRangeFilter, Level.ALL);
@@ -123,7 +123,7 @@ public void testMinMaxLevelSame(final TestLevelRangeFilterBuilder builder) throw
@ParameterizedTest
@ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testMinMaxLevelNull(final TestLevelRangeFilterBuilder builder) throws Exception {
+ void testMinMaxLevelNull(final TestLevelRangeFilterBuilder builder) throws Exception {
final LevelRangeFilter levelRangeFilter = builder.build(null, null, true);
assertResult(Result.ACCEPT, levelRangeFilter, Level.ALL);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/layout/PatternLayoutBuilderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/builders/layout/PatternLayoutBuilderTest.java
index 430b02a98cc..c64dfc3df37 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/layout/PatternLayoutBuilderTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/builders/layout/PatternLayoutBuilderTest.java
@@ -18,7 +18,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
-import java.util.Arrays;
import java.util.stream.Stream;
import org.apache.log4j.bridge.LayoutAdapter;
import org.apache.logging.log4j.core.layout.PatternLayout;
@@ -26,10 +25,10 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
-public class PatternLayoutBuilderTest {
+class PatternLayoutBuilderTest {
static Stream patterns() {
- return Arrays.asList(
+ return Stream.of(
Arguments.of("%p", "%v1Level"),
Arguments.of("%100p", "%100v1Level"),
Arguments.of("%-100p", "%-100v1Level"),
@@ -41,13 +40,12 @@ static Stream patterns() {
Arguments.of("%XX", "%XX"),
Arguments.of("%p id", "%v1Level id"),
Arguments.of("%x Ex", "%ndc Ex"),
- Arguments.of("%X X", "%properties X"))
- .stream();
+ Arguments.of("%X X", "%properties X"));
}
@ParameterizedTest
@MethodSource("patterns")
- public void testLevelPatternReplacement(final String v1Pattern, final String v2Pattern) {
+ void testLevelPatternReplacement(final String v1Pattern, final String v2Pattern) {
final PatternLayoutBuilder builder = new PatternLayoutBuilder();
final PatternLayout layout = (PatternLayout) LayoutAdapter.adapt(builder.createLayout(v1Pattern, null));
assertEquals(v2Pattern, layout.getConversionPattern());
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationConverterTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationConverterTest.java
index 2d242cb838a..f27722278dc 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationConverterTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationConverterTest.java
@@ -38,7 +38,7 @@ protected static List getPaths(final String root) throws IOException {
final List paths = new ArrayList<>();
Files.walkFileTree(Paths.get(root), new SimpleFileVisitor() {
@Override
- public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+ public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) {
paths.add(file.toAbsolutePath());
return FileVisitResult.CONTINUE;
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationTest.java
index 7874ffe2d85..b9967d0de41 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationTest.java
@@ -18,6 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -67,7 +68,7 @@
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.junit.jupiter.api.io.TempDir;
-public abstract class AbstractLog4j1ConfigurationTest {
+abstract class AbstractLog4j1ConfigurationTest {
@TempDir
File tempDir;
@@ -85,14 +86,14 @@ protected LoggerContext configure(final String configResourcePrefix) throws URIS
return (LoggerContext) org.apache.logging.log4j.LogManager.getContext(false);
}
- public void testConsoleCapitalization() throws Exception {
+ void testConsoleCapitalization() throws Exception {
final Configuration config = getConfiguration("config-1.2/log4j-capitalization");
final Appender capitalized = config.getAppender("ConsoleCapitalized");
assertNotNull(capitalized);
- assertEquals(capitalized.getClass(), ConsoleAppender.class);
+ assertEquals(ConsoleAppender.class, capitalized.getClass());
final Appender javaStyle = config.getAppender("ConsoleJavaStyle");
assertNotNull(javaStyle);
- assertEquals(javaStyle.getClass(), ConsoleAppender.class);
+ assertEquals(ConsoleAppender.class, javaStyle.getClass());
testConsoleAppender((ConsoleAppender) capitalized, (ConsoleAppender) javaStyle);
}
@@ -116,7 +117,7 @@ private Layout> testConsole(final String configResource) throws Exception {
final ConsoleAppender appender = configuration.getAppender(name);
assertNotNull(
appender, "Missing appender '" + name + "' in configuration " + configResource + " → " + configuration);
- assertEquals(true, getFollowProperty(appender), "follow");
+ assertTrue(getFollowProperty(appender), "follow");
assertEquals(Target.SYSTEM_ERR, appender.getTarget());
//
final LoggerConfig loggerConfig = configuration.getLoggerConfig("com.example.foo");
@@ -128,24 +129,24 @@ private Layout> testConsole(final String configResource) throws Exception {
return appender.getLayout();
}
- public void testConsoleTtccLayout() throws Exception {
+ void testConsoleTtccLayout() throws Exception {
final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-TTCCLayout");
assertEquals("%d{ISO8601}{CET} %p - %m%n", layout.getConversionPattern());
}
- public void testRollingFileAppender() throws Exception {
+ void testRollingFileAppender() throws Exception {
testRollingFileAppender("config-1.2/log4j-RollingFileAppender");
}
- public void testDailyRollingFileAppender() throws Exception {
+ void testDailyRollingFileAppender() throws Exception {
testDailyRollingFileAppender("config-1.2/log4j-DailyRollingFileAppender");
}
- public void testRollingFileAppenderWithProperties() throws Exception {
+ void testRollingFileAppenderWithProperties() throws Exception {
testRollingFileAppender("config-1.2/log4j-RollingFileAppender-with-props");
}
- public void testSystemProperties1() throws Exception {
+ void testSystemProperties1() throws Exception {
final String tempFileName = System.getProperty("java.io.tmpdir") + "/hadoop.log";
final Path tempFilePath = new File(tempFileName).toPath();
Files.deleteIfExists(tempFilePath);
@@ -162,7 +163,7 @@ public void testSystemProperties1() throws Exception {
final TriggeringPolicy[] triggeringPolicies = ctp.getTriggeringPolicies();
assertEquals(1, triggeringPolicies.length);
final TriggeringPolicy tp = triggeringPolicies[0];
- assertTrue(tp instanceof SizeBasedTriggeringPolicy, tp.getClass().getName());
+ assertInstanceOf(SizeBasedTriggeringPolicy.class, tp, tp.getClass().getName());
final SizeBasedTriggeringPolicy sbtp = (SizeBasedTriggeringPolicy) tp;
assertEquals(20 * 1024 * 1024, sbtp.getMaxFileSize());
appender.stop(10, TimeUnit.SECONDS);
@@ -174,7 +175,7 @@ public void testSystemProperties1() throws Exception {
}
}
- public void testSystemProperties2() throws Exception {
+ void testSystemProperties2() throws Exception {
final Configuration configuration = getConfiguration("config-1.2/log4j-system-properties-2");
final RollingFileAppender appender = configuration.getAppender("RFA");
final String tmpDir = System.getProperty("java.io.tmpdir");
@@ -192,11 +193,12 @@ private void testRollingFileAppender(final String configResource) throws Excepti
final Appender appender = configuration.getAppender("RFA");
assertNotNull(appender);
assertEquals("RFA", appender.getName());
- assertTrue(appender instanceof RollingFileAppender, appender.getClass().getName());
+ assertInstanceOf(
+ RollingFileAppender.class, appender, appender.getClass().getName());
final RollingFileAppender rfa = (RollingFileAppender) appender;
- assertTrue(
- rfa.getManager().getRolloverStrategy() instanceof DefaultRolloverStrategy, "defaultRolloverStrategy");
+ assertInstanceOf(
+ DefaultRolloverStrategy.class, rfa.getManager().getRolloverStrategy(), "defaultRolloverStrategy");
assertFalse(((DefaultRolloverStrategy) rfa.getManager().getRolloverStrategy()).isUseMax(), "rolloverStrategy");
assertFalse(getAppendProperty(rfa), "append");
assertEquals(1000, rfa.getManager().getBufferSize(), "bufferSize");
@@ -205,19 +207,21 @@ private void testRollingFileAppender(final String configResource) throws Excepti
assertEquals("target/hadoop.log.%i", rfa.getFilePattern());
final TriggeringPolicy triggeringPolicy = rfa.getTriggeringPolicy();
assertNotNull(triggeringPolicy);
- assertTrue(
- triggeringPolicy instanceof CompositeTriggeringPolicy,
+ assertInstanceOf(
+ CompositeTriggeringPolicy.class,
+ triggeringPolicy,
triggeringPolicy.getClass().getName());
final CompositeTriggeringPolicy ctp = (CompositeTriggeringPolicy) triggeringPolicy;
final TriggeringPolicy[] triggeringPolicies = ctp.getTriggeringPolicies();
assertEquals(1, triggeringPolicies.length);
final TriggeringPolicy tp = triggeringPolicies[0];
- assertTrue(tp instanceof SizeBasedTriggeringPolicy, tp.getClass().getName());
+ assertInstanceOf(SizeBasedTriggeringPolicy.class, tp, tp.getClass().getName());
final SizeBasedTriggeringPolicy sbtp = (SizeBasedTriggeringPolicy) tp;
assertEquals(256 * 1024 * 1024, sbtp.getMaxFileSize());
final RolloverStrategy rolloverStrategy = rfa.getManager().getRolloverStrategy();
- assertTrue(
- rolloverStrategy instanceof DefaultRolloverStrategy,
+ assertInstanceOf(
+ DefaultRolloverStrategy.class,
+ rolloverStrategy,
rolloverStrategy.getClass().getName());
final DefaultRolloverStrategy drs = (DefaultRolloverStrategy) rolloverStrategy;
assertEquals(20, drs.getMaxIndex());
@@ -231,8 +235,8 @@ private void testDailyRollingFileAppender(final String configResource) throws Ex
final Appender appender = configuration.getAppender("DRFA");
assertNotNull(appender);
assertEquals("DRFA", appender.getName());
- assertTrue(
- appender instanceof RollingFileAppender, appender.getClass().getName());
+ assertInstanceOf(
+ RollingFileAppender.class, appender, appender.getClass().getName());
final RollingFileAppender rfa = (RollingFileAppender) appender;
assertFalse(getAppendProperty(rfa), "append");
assertEquals(1000, rfa.getManager().getBufferSize(), "bufferSize");
@@ -241,19 +245,21 @@ private void testDailyRollingFileAppender(final String configResource) throws Ex
assertEquals("target/hadoop.log%d{.dd-MM-yyyy}", rfa.getFilePattern());
final TriggeringPolicy triggeringPolicy = rfa.getTriggeringPolicy();
assertNotNull(triggeringPolicy);
- assertTrue(
- triggeringPolicy instanceof CompositeTriggeringPolicy,
+ assertInstanceOf(
+ CompositeTriggeringPolicy.class,
+ triggeringPolicy,
triggeringPolicy.getClass().getName());
final CompositeTriggeringPolicy ctp = (CompositeTriggeringPolicy) triggeringPolicy;
final TriggeringPolicy[] triggeringPolicies = ctp.getTriggeringPolicies();
assertEquals(1, triggeringPolicies.length);
final TriggeringPolicy tp = triggeringPolicies[0];
- assertTrue(tp instanceof TimeBasedTriggeringPolicy, tp.getClass().getName());
+ assertInstanceOf(TimeBasedTriggeringPolicy.class, tp, tp.getClass().getName());
final TimeBasedTriggeringPolicy tbtp = (TimeBasedTriggeringPolicy) tp;
assertEquals(1, tbtp.getInterval());
final RolloverStrategy rolloverStrategy = rfa.getManager().getRolloverStrategy();
- assertTrue(
- rolloverStrategy instanceof DefaultRolloverStrategy,
+ assertInstanceOf(
+ DefaultRolloverStrategy.class,
+ rolloverStrategy,
rolloverStrategy.getClass().getName());
final DefaultRolloverStrategy drs = (DefaultRolloverStrategy) rolloverStrategy;
assertEquals(Integer.MAX_VALUE, drs.getMaxIndex());
@@ -280,40 +286,40 @@ private Layout> testFile() throws Exception {
return appender.getLayout();
}
- public void testConsoleEnhancedPatternLayout() throws Exception {
+ void testConsoleEnhancedPatternLayout() throws Exception {
final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-EnhancedPatternLayout");
// %p, %X and %x converted to their Log4j 1.x bridge equivalent
assertEquals("%d{ISO8601} [%t][%c] %-5v1Level %properties %ndc: %m%n", layout.getConversionPattern());
}
- public void testConsoleHtmlLayout() throws Exception {
+ void testConsoleHtmlLayout() throws Exception {
final HtmlLayout layout = (HtmlLayout) testConsole("config-1.2/log4j-console-HtmlLayout");
assertEquals("Headline", layout.getTitle());
assertTrue(layout.isLocationInfo());
}
- public void testConsolePatternLayout() throws Exception {
+ void testConsolePatternLayout() throws Exception {
final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-PatternLayout");
// %p converted to its Log4j 1.x bridge equivalent
assertEquals("%d{ISO8601} [%t][%c] %-5v1Level: %m%n", layout.getConversionPattern());
}
- public void testConsoleSimpleLayout() throws Exception {
+ void testConsoleSimpleLayout() throws Exception {
final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-SimpleLayout");
assertEquals("%v1Level - %m%n", layout.getConversionPattern());
}
- public void testFileSimpleLayout() throws Exception {
+ void testFileSimpleLayout() throws Exception {
final PatternLayout layout = (PatternLayout) testFile();
assertEquals("%v1Level - %m%n", layout.getConversionPattern());
}
- public void testNullAppender() throws Exception {
+ void testNullAppender() throws Exception {
final Configuration configuration = getConfiguration("config-1.2/log4j-NullAppender");
final Appender appender = configuration.getAppender("NullAppender");
assertNotNull(appender);
assertEquals("NullAppender", appender.getName());
- assertTrue(appender instanceof NullAppender, appender.getClass().getName());
+ assertInstanceOf(NullAppender.class, appender, appender.getClass().getName());
}
private boolean getFollowProperty(final ConsoleAppender consoleAppender) throws Exception {
@@ -362,7 +368,7 @@ private Layout> testLayout(final Configuration config, final String appenderNa
/**
* Test if the default values from Log4j 1.x are respected.
*/
- public void testDefaultValues() throws Exception {
+ void testDefaultValues() throws Exception {
final Configuration config = getConfiguration("config-1.2/log4j-defaultValues");
// HtmlLayout
final HtmlLayout htmlLayout = (HtmlLayout) testLayout(config, "HTMLLayout");
@@ -394,7 +400,7 @@ public void testDefaultValues() throws Exception {
assertEquals(
"target/dailyRollingFileAppender%d{.yyyy-MM-dd}",
dailyRollingFileAppender.getFilePattern(), "equivalent file pattern");
- assertEquals(true, getAppendProperty(dailyRollingFileAppender), "append");
+ assertTrue(getAppendProperty(dailyRollingFileAppender), "append");
assertEquals(8192, dailyRollingFileAppender.getManager().getBufferSize(), "bufferSize");
assertTrue(dailyRollingFileAppender.getImmediateFlush(), "immediateFlush");
// FileAppender
@@ -472,7 +478,7 @@ private int checkFilters(final org.apache.log4j.spi.Filter filter) {
return count;
}
- public void testMultipleFilters() throws Exception {
+ void testMultipleFilters() throws Exception {
System.setProperty("test.tmpDir", tempDir.getCanonicalPath());
try (final LoggerContext loggerContext = configure("log4j-multipleFilters")) {
@@ -500,7 +506,7 @@ public void testMultipleFilters() throws Exception {
final ListAppender legacyAppender = (ListAppender) ((Adapter) appender).getAppender();
final org.apache.logging.log4j.core.test.appender.ListAppender nativeAppender =
configuration.getAppender("LIST2");
- assertEquals(3, checkFilters(((Filterable) nativeAppender).getFilter()));
+ assertEquals(3, checkFilters(nativeAppender.getFilter()));
final Logger logger = LogManager.getLogger(PropertiesConfigurationTest.class);
int expected = 0;
@@ -531,11 +537,11 @@ public void testMultipleFilters() throws Exception {
}
}
- public void testGlobalThreshold() throws Exception {
+ void testGlobalThreshold() throws Exception {
try (final LoggerContext ctx = configure("config-1.2/log4j-global-threshold")) {
final Configuration config = ctx.getConfiguration();
final Filter filter = config.getFilter();
- assertTrue(filter instanceof ThresholdFilter);
+ assertInstanceOf(ThresholdFilter.class, filter);
final ThresholdFilter thresholdFilter = (ThresholdFilter) filter;
assertEquals(Level.INFO, thresholdFilter.getLevel());
assertEquals(Filter.Result.NEUTRAL, thresholdFilter.getOnMatch());
@@ -565,7 +571,7 @@ protected void testEnhancedRollingFileAppender(final Configuration configuration
DefaultRolloverStrategy defaultRolloverStrategy;
// Time policy with default attributes
appender = configuration.getAppender("DEFAULT_TIME");
- assertTrue(appender instanceof RollingFileAppender, "is RollingFileAppender");
+ assertInstanceOf(RollingFileAppender.class, appender, "is RollingFileAppender");
final RollingFileAppender defaultTime = (RollingFileAppender) appender;
assertTrue(defaultTime.getManager().isAppend(), "append");
assertEquals(8192, defaultTime.getManager().getBufferSize(), "bufferSize");
@@ -575,10 +581,10 @@ protected void testEnhancedRollingFileAppender(final Configuration configuration
"target/EnhancedRollingFileAppender/defaultTime.%d{yyyy-MM-dd}.log",
defaultTime.getFilePattern(), "filePattern");
policy = defaultTime.getTriggeringPolicy();
- assertTrue(policy instanceof TimeBasedTriggeringPolicy, "is TimeBasedTriggeringPolicy");
+ assertInstanceOf(TimeBasedTriggeringPolicy.class, policy, "is TimeBasedTriggeringPolicy");
// Size policy with default attributes
appender = configuration.getAppender("DEFAULT_SIZE");
- assertTrue(appender instanceof RollingFileAppender, "is RollingFileAppender");
+ assertInstanceOf(RollingFileAppender.class, appender, "is RollingFileAppender");
final RollingFileAppender defaultSize = (RollingFileAppender) appender;
assertTrue(defaultSize.getManager().isAppend(), "append");
assertEquals(8192, defaultSize.getManager().getBufferSize(), "bufferSize");
@@ -587,16 +593,16 @@ protected void testEnhancedRollingFileAppender(final Configuration configuration
assertEquals(
"target/EnhancedRollingFileAppender/defaultSize.%i.log", defaultSize.getFilePattern(), "filePattern");
policy = defaultSize.getTriggeringPolicy();
- assertTrue(policy instanceof SizeBasedTriggeringPolicy, "is SizeBasedTriggeringPolicy");
+ assertInstanceOf(SizeBasedTriggeringPolicy.class, policy, "is SizeBasedTriggeringPolicy");
assertEquals(10 * 1024 * 1024L, ((SizeBasedTriggeringPolicy) policy).getMaxFileSize());
strategy = defaultSize.getManager().getRolloverStrategy();
- assertTrue(strategy instanceof DefaultRolloverStrategy, "is DefaultRolloverStrategy");
+ assertInstanceOf(DefaultRolloverStrategy.class, strategy, "is DefaultRolloverStrategy");
defaultRolloverStrategy = (DefaultRolloverStrategy) strategy;
assertEquals(1, defaultRolloverStrategy.getMinIndex());
assertEquals(7, defaultRolloverStrategy.getMaxIndex());
// Time policy with custom attributes
appender = configuration.getAppender("TIME");
- assertTrue(appender instanceof RollingFileAppender, "is RollingFileAppender");
+ assertInstanceOf(RollingFileAppender.class, appender, "is RollingFileAppender");
final RollingFileAppender time = (RollingFileAppender) appender;
assertFalse(time.getManager().isAppend(), "append");
assertEquals(1000, time.getManager().getBufferSize(), "bufferSize");
@@ -605,10 +611,10 @@ protected void testEnhancedRollingFileAppender(final Configuration configuration
assertEquals(
"target/EnhancedRollingFileAppender/time.%d{yyyy-MM-dd}.log", time.getFilePattern(), "filePattern");
policy = time.getTriggeringPolicy();
- assertTrue(policy instanceof TimeBasedTriggeringPolicy, "is TimeBasedTriggeringPolicy");
+ assertInstanceOf(TimeBasedTriggeringPolicy.class, policy, "is TimeBasedTriggeringPolicy");
// Size policy with custom attributes
appender = configuration.getAppender("SIZE");
- assertTrue(appender instanceof RollingFileAppender, "is RollingFileAppender");
+ assertInstanceOf(RollingFileAppender.class, appender, "is RollingFileAppender");
final RollingFileAppender size = (RollingFileAppender) appender;
assertFalse(size.getManager().isAppend(), "append");
assertEquals(1000, size.getManager().getBufferSize(), "bufferSize");
@@ -616,10 +622,10 @@ protected void testEnhancedRollingFileAppender(final Configuration configuration
assertEquals("target/EnhancedRollingFileAppender/size.log", size.getFileName(), "fileName");
assertEquals("target/EnhancedRollingFileAppender/size.%i.log", size.getFilePattern(), "filePattern");
policy = size.getTriggeringPolicy();
- assertTrue(policy instanceof SizeBasedTriggeringPolicy, "is SizeBasedTriggeringPolicy");
+ assertInstanceOf(SizeBasedTriggeringPolicy.class, policy, "is SizeBasedTriggeringPolicy");
assertEquals(10_000_000L, ((SizeBasedTriggeringPolicy) policy).getMaxFileSize());
strategy = size.getManager().getRolloverStrategy();
- assertTrue(strategy instanceof DefaultRolloverStrategy, "is DefaultRolloverStrategy");
+ assertInstanceOf(DefaultRolloverStrategy.class, strategy, "is DefaultRolloverStrategy");
defaultRolloverStrategy = (DefaultRolloverStrategy) strategy;
assertEquals(11, defaultRolloverStrategy.getMinIndex());
assertEquals(20, defaultRolloverStrategy.getMaxIndex());
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AsyncAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AsyncAppenderTest.java
index 93b9a5d4d4d..b74c3365ae7 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AsyncAppenderTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AsyncAppenderTest.java
@@ -37,7 +37,7 @@
* Test configuration from XML.
*/
@UsingStatusListener
-public class AsyncAppenderTest {
+class AsyncAppenderTest {
private static long DEFAULT_TIMEOUT_MS = 500;
@@ -51,7 +51,7 @@ static Stream testAsyncAppender() {
@ParameterizedTest
@MethodSource
- public void testAsyncAppender(final String configLocation) throws Exception {
+ void testAsyncAppender(final String configLocation) throws Exception {
try (final LoggerContext loggerContext = TestConfigurator.configure(configLocation)) {
final Logger logger = LogManager.getLogger("test");
logger.debug("This is a test of the root logger");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java
index 12419de4796..be551f3d8cd 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java
@@ -36,15 +36,15 @@
/**
* Test configuration from XML.
*/
-public class AutoConfigTest {
+class AutoConfigTest {
@BeforeAll
- public static void beforeAll() {
+ static void beforeAll() {
System.setProperty(ConfigurationFactory.LOG4J1_EXPERIMENTAL, "true");
}
@Test
- public void testListAppender() {
+ void testListAppender() {
final Logger logger = LogManager.getLogger("test");
logger.debug("This is a test of the root logger");
final LoggerContext loggerContext = org.apache.logging.log4j.LogManager.getContext(false);
@@ -63,8 +63,8 @@ public void testListAppender() {
assertNotNull(eventAppender, "No Event Appender");
assertNotNull(messageAppender, "No Message Appender");
final List events = eventAppender.getEvents();
- assertTrue(events != null && events.size() > 0, "No events");
+ assertTrue(events != null && !events.isEmpty(), "No events");
final List messages = messageAppender.getMessages();
- assertTrue(messages != null && messages.size() > 0, "No messages");
+ assertTrue(messages != null && !messages.isEmpty(), "No messages");
}
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
index 12b9e907209..6636544668f 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
@@ -18,6 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -39,7 +40,7 @@
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.junit.jupiter.api.Test;
-public class Log4j1ConfigurationFactoryTest extends AbstractLog4j1ConfigurationTest {
+class Log4j1ConfigurationFactoryTest extends AbstractLog4j1ConfigurationTest {
private static final String SUFFIX = ".properties";
@@ -71,35 +72,35 @@ private Layout> testConsole(final String configResource) throws Exception {
@Override
@Test
- public void testConsoleEnhancedPatternLayout() throws Exception {
+ void testConsoleEnhancedPatternLayout() throws Exception {
super.testConsoleEnhancedPatternLayout();
}
@Override
@Test
- public void testConsoleHtmlLayout() throws Exception {
+ void testConsoleHtmlLayout() throws Exception {
super.testConsoleHtmlLayout();
}
@Test
- public void testConsolePatternLayout() throws Exception {
+ void testConsolePatternLayout() throws Exception {
super.testConsolePatternLayout();
}
@Override
@Test
- public void testConsoleSimpleLayout() throws Exception {
+ void testConsoleSimpleLayout() throws Exception {
super.testConsoleSimpleLayout();
}
@Override
@Test
- public void testConsoleTtccLayout() throws Exception {
+ void testConsoleTtccLayout() throws Exception {
super.testConsoleTtccLayout();
}
@Test
- public void testConsoleXmlLayout() throws Exception {
+ void testConsoleXmlLayout() throws Exception {
final Log4j1XmlLayout layout = (Log4j1XmlLayout) testConsole("config-1.2/log4j-console-XmlLayout");
assertTrue(layout.isLocationInfo());
assertFalse(layout.isProperties());
@@ -107,67 +108,67 @@ public void testConsoleXmlLayout() throws Exception {
@Override
@Test
- public void testFileSimpleLayout() throws Exception {
+ void testFileSimpleLayout() throws Exception {
super.testFileSimpleLayout();
}
@Override
@Test
- public void testNullAppender() throws Exception {
+ void testNullAppender() throws Exception {
super.testNullAppender();
}
@Override
@Test
- public void testRollingFileAppender() throws Exception {
+ void testRollingFileAppender() throws Exception {
super.testRollingFileAppender();
}
@Override
@Test
- public void testDailyRollingFileAppender() throws Exception {
+ void testDailyRollingFileAppender() throws Exception {
super.testDailyRollingFileAppender();
}
@Test
- public void testRollingFileAppenderWithProperties() throws Exception {
+ void testRollingFileAppenderWithProperties() throws Exception {
super.testRollingFileAppenderWithProperties();
}
@Override
@Test
- public void testSystemProperties1() throws Exception {
+ void testSystemProperties1() throws Exception {
super.testSystemProperties1();
}
@Override
@Test
- public void testSystemProperties2() throws Exception {
+ void testSystemProperties2() throws Exception {
super.testSystemProperties2();
}
@Override
@Test
- public void testConsoleCapitalization() throws Exception {
+ void testConsoleCapitalization() throws Exception {
super.testConsoleCapitalization();
}
@Override
@Test
- public void testDefaultValues() throws Exception {
+ void testDefaultValues() throws Exception {
super.testDefaultValues();
}
@Test
- public void testUntrimmedValues() throws Exception {
+ void testUntrimmedValues() throws Exception {
try {
final Configuration config = getConfiguration("config-1.2/log4j-untrimmed");
final LoggerConfig rootLogger = config.getRootLogger();
assertEquals(Level.DEBUG, rootLogger.getLevel());
final Appender appender = config.getAppender("Console");
- assertTrue(appender instanceof ConsoleAppender);
+ assertInstanceOf(ConsoleAppender.class, appender);
final Layout extends Serializable> layout = appender.getLayout();
- assertTrue(layout instanceof PatternLayout);
+ assertInstanceOf(PatternLayout.class, layout);
assertEquals("%v1Level - %m%n", ((PatternLayout) layout).getConversionPattern());
// No filter support
config.start();
@@ -178,11 +179,11 @@ public void testUntrimmedValues() throws Exception {
}
@Test
- public void testGlobalThreshold() throws Exception {
+ void testGlobalThreshold() throws Exception {
try (final LoggerContext ctx = configure("config-1.2/log4j-global-threshold")) {
final Configuration config = ctx.getConfiguration();
final Filter filter = config.getFilter();
- assertTrue(filter instanceof ThresholdFilter);
+ assertInstanceOf(ThresholdFilter.class, filter);
final ThresholdFilter thresholdFilter = (ThresholdFilter) filter;
assertEquals(Level.INFO, thresholdFilter.getLevel());
assertEquals(Filter.Result.NEUTRAL, thresholdFilter.getOnMatch());
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java
index ef95d1633cf..bcae05d6bee 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java
@@ -40,21 +40,21 @@
/**
* Test RewriteAppender
*/
-public class MapRewriteAppenderTest {
+class MapRewriteAppenderTest {
@BeforeAll
- public static void beforeAll() {
+ static void beforeAll() {
System.setProperty(
ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY, "target/test-classes/log4j1-mapRewrite.xml");
}
@AfterEach
- public void after() {
+ void after() {
ThreadContext.clearMap();
}
@Test
- public void testRewrite() {
+ void testRewrite() {
final Logger logger = LogManager.getLogger("test");
final Map map = new HashMap<>();
map.put("message", "This is a test");
@@ -71,7 +71,7 @@ public void testRewrite() {
}
assertNotNull(eventAppender, "No Event Appender");
final List events = eventAppender.getEvents();
- assertTrue(events != null && events.size() > 0, "No events");
+ assertTrue(events != null && !events.isEmpty(), "No events");
assertNotNull(events.get(0).getProperties(), "No properties in the event");
assertTrue(events.get(0).getProperties().containsKey("hello"), "Key was not inserted");
assertEquals("world", events.get(0).getProperties().get("hello"), "Key value is incorrect");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java
index 0cc7f5ae7e6..7b14885786d 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java
@@ -28,17 +28,17 @@
/**
* Test configuration from Properties.
*/
-public class PropertiesConfigurationFactoryTest {
+class PropertiesConfigurationFactoryTest {
@BeforeAll
- public static void beforeAll() {
+ static void beforeAll() {
System.setProperty(
ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY,
"target/test-classes/log4j1-file-1.properties");
}
@Test
- public void testProperties() {
+ void testProperties() {
final Logger logger = LogManager.getLogger("test");
logger.debug("This is a test of the root logger");
File file = new File("target/temp.A1");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java
index 93ff778154a..fb8ed815671 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java
@@ -17,6 +17,7 @@
package org.apache.log4j.config;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -25,7 +26,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
-import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import org.apache.log4j.ListAppender;
@@ -55,13 +55,13 @@
/**
* Test configuration from Properties.
*/
-public class PropertiesConfigurationTest extends AbstractLog4j1ConfigurationTest {
+class PropertiesConfigurationTest extends AbstractLog4j1ConfigurationTest {
private static final String TEST_KEY = "log4j.test.tmpdir";
private static final String SUFFIX = ".properties";
@Override
- Configuration getConfiguration(final String configResourcePrefix) throws URISyntaxException, IOException {
+ Configuration getConfiguration(final String configResourcePrefix) throws IOException {
final String configResource = configResourcePrefix + SUFFIX;
final InputStream inputStream = getResourceAsStream(configResource);
final ConfigurationSource source = new ConfigurationSource(inputStream);
@@ -73,7 +73,7 @@ Configuration getConfiguration(final String configResourcePrefix) throws URISynt
}
@Test
- public void testConfigureNullPointerException() throws Exception {
+ void testConfigureNullPointerException() throws Exception {
try (final LoggerContext loggerContext =
TestConfigurator.configure("target/test-classes/LOG4J2-3247.properties")) {
// [LOG4J2-3247] configure() should not throw an NPE.
@@ -85,7 +85,7 @@ public void testConfigureNullPointerException() throws Exception {
}
@Test
- public void testConsoleAppenderFilter() throws Exception {
+ void testConsoleAppenderFilter() throws Exception {
try (final LoggerContext loggerContext =
TestConfigurator.configure("target/test-classes/LOG4J2-3247.properties")) {
// LOG4J2-3281 PropertiesConfiguration.buildAppender not adding filters to appender
@@ -96,12 +96,12 @@ public void testConsoleAppenderFilter() throws Exception {
final Filterable filterable = (Filterable) appender;
final FilterAdapter filter = (FilterAdapter) filterable.getFilter();
assertNotNull(filter);
- assertTrue(filter.getFilter() instanceof NeutralFilterFixture);
+ assertInstanceOf(NeutralFilterFixture.class, filter.getFilter());
}
}
@Test
- public void testCustomAppenderFilter() throws Exception {
+ void testCustomAppenderFilter() throws Exception {
try (final LoggerContext loggerContext =
TestConfigurator.configure("target/test-classes/LOG4J2-3281.properties")) {
// LOG4J2-3281 PropertiesConfiguration.buildAppender not adding filters to appender
@@ -112,12 +112,12 @@ public void testCustomAppenderFilter() throws Exception {
final Filterable filterable = (Filterable) appender;
final FilterAdapter filter = (FilterAdapter) filterable.getFilter();
assertNotNull(filter);
- assertTrue(filter.getFilter() instanceof NeutralFilterFixture);
+ assertInstanceOf(NeutralFilterFixture.class, filter.getFilter());
}
}
@Test
- public void testConsoleAppenderLevelRangeFilter() throws Exception {
+ void testConsoleAppenderLevelRangeFilter() throws Exception {
PluginManager.addPackage("org.apache.log4j.builders.filter");
try (final LoggerContext loggerContext =
TestConfigurator.configure("target/test-classes/LOG4J2-3326.properties")) {
@@ -164,7 +164,7 @@ public void testConsoleAppenderLevelRangeFilter() throws Exception {
}
@Test
- public void testConfigureAppenderDoesNotExist() throws Exception {
+ void testConfigureAppenderDoesNotExist() throws Exception {
// Verify that we tolerate a logger which specifies an appender that does not exist.
try (final LoggerContext loggerContext =
TestConfigurator.configure("target/test-classes/LOG4J2-3407.properties")) {
@@ -174,7 +174,7 @@ public void testConfigureAppenderDoesNotExist() throws Exception {
}
@Test
- public void testListAppender() throws Exception {
+ void testListAppender() throws Exception {
try (final LoggerContext loggerContext =
TestConfigurator.configure("target/test-classes/log4j1-list.properties")) {
final Logger logger = LogManager.getLogger("test");
@@ -193,14 +193,14 @@ public void testListAppender() throws Exception {
assertNotNull(eventAppender, "No Event Appender");
assertNotNull(messageAppender, "No Message Appender");
final List events = eventAppender.getEvents();
- assertTrue(events != null && events.size() > 0, "No events");
+ assertTrue(events != null && !events.isEmpty(), "No events");
final List messages = messageAppender.getMessages();
- assertTrue(messages != null && messages.size() > 0, "No messages");
+ assertTrue(messages != null && !messages.isEmpty(), "No messages");
}
}
@Test
- public void testProperties() throws Exception {
+ void testProperties() throws Exception {
try (final LoggerContext loggerContext =
TestConfigurator.configure("target/test-classes/log4j1-file-1.properties")) {
final Logger logger = LogManager.getLogger("test");
@@ -215,7 +215,7 @@ public void testProperties() throws Exception {
}
@Test
- public void testSystemProperties() throws Exception {
+ void testSystemProperties() throws Exception {
final String testPathLocation = "target";
System.setProperty(TEST_KEY, testPathLocation);
try (final LoggerContext loggerContext =
@@ -226,7 +226,7 @@ public void testSystemProperties() throws Exception {
final String name = "FILE_APPENDER";
final Appender appender = configuration.getAppender(name);
assertNotNull(appender, name);
- assertTrue(appender instanceof FileAppender, appender.getClass().getName());
+ assertInstanceOf(FileAppender.class, appender, appender.getClass().getName());
final FileAppender fileAppender = (FileAppender) appender;
// Two slashes because that's how the config file is setup.
assertEquals(testPathLocation + "/hadoop.log", fileAppender.getFileName());
@@ -326,18 +326,18 @@ public void testMultipleFilters() throws Exception {
}
@Test
- public void testUntrimmedValues() throws Exception {
+ void testUntrimmedValues() throws Exception {
try {
final Configuration config = getConfiguration("config-1.2/log4j-untrimmed");
final LoggerConfig rootLogger = config.getRootLogger();
assertEquals(Level.DEBUG, rootLogger.getLevel());
final Appender appender = config.getAppender("Console");
- assertTrue(appender instanceof ConsoleAppender);
+ assertInstanceOf(ConsoleAppender.class, appender);
final Layout extends Serializable> layout = appender.getLayout();
- assertTrue(layout instanceof PatternLayout);
+ assertInstanceOf(PatternLayout.class, layout);
assertEquals("%v1Level - %m%n", ((PatternLayout) layout).getConversionPattern());
final Filter filter = ((Filterable) appender).getFilter();
- assertTrue(filter instanceof DenyAllFilter);
+ assertInstanceOf(DenyAllFilter.class, filter);
config.start();
config.stop();
} catch (NoClassDefFoundError e) {
@@ -352,7 +352,7 @@ public void testGlobalThreshold() throws Exception {
}
@Test
- public void testEnhancedRollingFileAppender() throws Exception {
+ void testEnhancedRollingFileAppender() throws Exception {
try (final LoggerContext ctx = configure("config-1.2/log4j-EnhancedRollingFileAppender")) {
final Configuration configuration = ctx.getConfiguration();
assertNotNull(configuration);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java
index 9c5f852be79..dbdca87084c 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java
@@ -48,7 +48,7 @@
/**
* Test reconfiguring with an XML configuration.
*/
-public class PropertiesReconfigurationTest {
+class PropertiesReconfigurationTest {
private class TestListener implements ConfigurationListener {
@@ -177,7 +177,7 @@ private T getAppenderFromContext(final Str
* Tests that configuring and reconfiguring CUSTOM appenders properly pick up different settings.
*/
@Test
- public void testCustomAppenders_TestConfigurator() throws IOException {
+ void testCustomAppenders_TestConfigurator() throws IOException {
checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_1, true, 1, "A", TestConfigurator::configure);
checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_2, false, 2, "B", TestConfigurator::configure);
checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_1, true, 1, "A", TestConfigurator::configure);
@@ -188,7 +188,7 @@ public void testCustomAppenders_TestConfigurator() throws IOException {
* Tests that configuring and reconfiguring CUSTOM appenders properly pick up different settings.
*/
@Test
- public void testCustomAppenders_PropertyConfigurator() throws IOException {
+ void testCustomAppenders_PropertyConfigurator() throws IOException {
checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_1, true, 1, "A", PropertyConfigurator::configure);
checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_2, false, 2, "B", PropertyConfigurator::configure);
checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_1, true, 1, "A", PropertyConfigurator::configure);
@@ -199,7 +199,7 @@ public void testCustomAppenders_PropertyConfigurator() throws IOException {
* Tests that configuring and reconfiguring STOCK file appenders properly pick up different settings.
*/
@Test
- public void testFileAppenders() throws Exception {
+ void testFileAppenders() throws Exception {
checkConfigureFileAppender(CONFIG_FILE_APPENDER_1, false);
checkConfigureFileAppender(CONFIG_FILE_APPENDER_2, true);
checkConfigureFileAppender(CONFIG_FILE_APPENDER_1, false);
@@ -207,7 +207,7 @@ public void testFileAppenders() throws Exception {
}
@Test
- public void testTestListener() throws Exception {
+ void testTestListener() throws Exception {
System.setProperty(Log4j1Configuration.MONITOR_INTERVAL, "1");
final File file = new File(CONFIG_FILE_APPENDER_1);
assertTrue(file.exists(), "No Config file");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java
index c136a6dcc0f..ea740d93d4f 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java
@@ -29,19 +29,19 @@
/**
* Test configuration from Properties.
*/
-public class PropertiesRollingWithPropertiesTest {
+class PropertiesRollingWithPropertiesTest {
private static final String TEST_DIR = "target/" + PropertiesRollingWithPropertiesTest.class.getSimpleName();
@BeforeAll
- public static void setupSystemProperties() {
+ static void setupSystemProperties() {
// Set system properties as a replacement for SystemPropertyTestRule
System.setProperty("test.directory", TEST_DIR);
System.setProperty("log4j.configuration", "target/test-classes/log4j1-rolling-properties.properties");
}
@Test
- public void testProperties() throws Exception {
+ void testProperties() throws Exception {
final Path path = Paths.get(TEST_DIR, "somefile.log");
Files.deleteIfExists(path);
final Logger logger = LogManager.getLogger("test");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java
index ac68e6ce9fc..86af9aea741 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java
@@ -39,21 +39,21 @@
/**
* Test RewriteAppender
*/
-public class RewriteAppenderTest {
+class RewriteAppenderTest {
@BeforeAll
- public static void beforeAll() {
+ static void beforeAll() {
System.setProperty(
ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY, "target/test-classes/log4j1-rewrite.xml");
}
@AfterEach
- public void after() {
+ void after() {
ThreadContext.clearMap();
}
@Test
- public void testRewrite() {
+ void testRewrite() {
final Logger logger = LogManager.getLogger("test");
ThreadContext.put("key1", "This is a test");
ThreadContext.put("hello", "world");
@@ -70,7 +70,7 @@ public void testRewrite() {
}
assertNotNull(eventAppender, "No Event Appender");
final List events = eventAppender.getEvents();
- assertTrue(events != null && events.size() > 0, "No events");
+ assertTrue(events != null && !events.isEmpty(), "No events");
assertNotNull(events.get(0).getProperties(), "No properties in the event");
assertTrue(events.get(0).getProperties().containsKey("key2"), "Key was not inserted");
assertEquals("Log4j", events.get(0).getProperties().get("key2"), "Key value is incorrect");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SocketAppenderConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/SocketAppenderConfigurationTest.java
index d58479cd82f..2294c556d18 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SocketAppenderConfigurationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/SocketAppenderConfigurationTest.java
@@ -17,6 +17,7 @@
package org.apache.log4j.config;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -35,7 +36,7 @@
/**
* Tests configuring a Syslog appender.
*/
-public class SocketAppenderConfigurationTest {
+class SocketAppenderConfigurationTest {
private SocketAppender check(final Protocol expected, final Configuration configuration) {
final Map appenders = configuration.getAppenders();
@@ -71,19 +72,19 @@ private SocketAppender checkProtocolXmlConfig(final Protocol expected, final Str
}
@Test
- public void testProperties() throws Exception {
+ void testProperties() throws Exception {
checkProtocolXmlConfig(Protocol.TCP, "target/test-classes/log4j1-socket.properties");
}
@Test
- public void testPropertiesXmlLayout() throws Exception {
+ void testPropertiesXmlLayout() throws Exception {
final SocketAppender socketAppender =
checkProtocolXmlConfig(Protocol.TCP, "target/test-classes/log4j1-socket-xml-layout.properties");
- assertTrue(socketAppender.getLayout() instanceof Log4j1XmlLayout);
+ assertInstanceOf(Log4j1XmlLayout.class, socketAppender.getLayout());
}
@Test
- public void testXml() throws Exception {
+ void testXml() throws Exception {
checkProtocolXmlConfig(Protocol.TCP, "target/test-classes/log4j1-socket.xml");
}
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderConfigurationTest.java
index 8d077ae6883..1313cee2c44 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderConfigurationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderConfigurationTest.java
@@ -41,7 +41,7 @@
*/
@UsingStatusListener
@WritesSystemProperty
-public class SyslogAppenderConfigurationTest {
+class SyslogAppenderConfigurationTest {
private static ServerSocket tcpSocket;
@@ -89,32 +89,32 @@ private void checkProtocolXmlConfig(final Protocol expected, final String xmlPat
}
@Test
- public void testPropertiesProtocolDefault() throws Exception {
+ void testPropertiesProtocolDefault() throws Exception {
checkProtocolPropertiesConfig(Protocol.TCP, "target/test-classes/log4j1-syslog-protocol-default.properties");
}
@Test
- public void testPropertiesProtocolTcp() throws Exception {
+ void testPropertiesProtocolTcp() throws Exception {
checkProtocolPropertiesConfig(Protocol.TCP, "target/test-classes/log4j1-syslog-protocol-tcp.properties");
}
@Test
- public void testPropertiesProtocolUdp() throws Exception {
+ void testPropertiesProtocolUdp() throws Exception {
checkProtocolPropertiesConfig(Protocol.UDP, "target/test-classes/log4j1-syslog-protocol-udp.properties");
}
@Test
- public void testXmlProtocolDefault() throws Exception {
+ void testXmlProtocolDefault() throws Exception {
checkProtocolXmlConfig(Protocol.TCP, "target/test-classes/log4j1-syslog.xml");
}
@Test
- public void testXmlProtocolTcp() throws Exception {
+ void testXmlProtocolTcp() throws Exception {
checkProtocolXmlConfig(Protocol.TCP, "target/test-classes/log4j1-syslog-protocol-tcp.xml");
}
@Test
- public void testXmlProtocolUdp() throws Exception {
+ void testXmlProtocolUdp() throws Exception {
checkProtocolXmlConfig(Protocol.UDP, "target/test-classes/log4j1-syslog-protocol-udp.xml");
}
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderTest.java
index 66be7c89ab7..720577bc86e 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderTest.java
@@ -30,12 +30,12 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-public class SyslogAppenderTest {
+class SyslogAppenderTest {
private static MockSyslogServer syslogServer;
@BeforeAll
- public static void beforeAll() throws IOException {
+ static void beforeAll() throws IOException {
initTCPTestEnvironment(null);
System.setProperty("syslog.port", Integer.toString(syslogServer.getLocalPort()));
System.setProperty(
@@ -43,20 +43,20 @@ public static void beforeAll() throws IOException {
}
@AfterAll
- public static void afterAll() {
+ static void afterAll() {
System.clearProperty(ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY);
syslogServer.shutdown();
}
@Test
- public void sendMessage() throws Exception {
+ void sendMessage() throws Exception {
final Logger logger = LogManager.getLogger(SyslogAppenderTest.class);
logger.info("This is a test");
List messages = null;
for (int i = 0; i < 5; ++i) {
Thread.sleep(250);
messages = syslogServer.getMessageList();
- if (messages != null && messages.size() > 0) {
+ if (messages != null && !messages.isEmpty()) {
break;
}
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java
index 408d3bb4b32..e28121da899 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java
@@ -28,16 +28,16 @@
/**
* Test configuration from XML.
*/
-public class XmlConfigurationFactoryTest {
+class XmlConfigurationFactoryTest {
@BeforeAll
- public static void beforeAll() {
+ static void beforeAll() {
System.setProperty(
ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY, "target/test-classes/log4j1-file.xml");
}
@Test
- public void testXML() {
+ void testXML() {
final Logger logger = LogManager.getLogger("test");
logger.debug("This is a test of the root logger");
File file = new File("target/temp.A1");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationTest.java
index 5990021923a..95a260ed862 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationTest.java
@@ -17,13 +17,13 @@
package org.apache.log4j.config;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import org.apache.log4j.ListAppender;
@@ -46,12 +46,12 @@
/**
* Test configuration from XML.
*/
-public class XmlConfigurationTest extends AbstractLog4j1ConfigurationTest {
+class XmlConfigurationTest extends AbstractLog4j1ConfigurationTest {
private static final String SUFFIX = ".xml";
@Override
- Configuration getConfiguration(final String configResourcePrefix) throws URISyntaxException, IOException {
+ Configuration getConfiguration(final String configResourcePrefix) throws IOException {
final String configResource = configResourcePrefix + SUFFIX;
final InputStream inputStream = getResourceAsStream(configResource);
final ConfigurationSource source = new ConfigurationSource(inputStream);
@@ -63,7 +63,7 @@ Configuration getConfiguration(final String configResourcePrefix) throws URISynt
}
@Test
- public void testListAppender() throws Exception {
+ void testListAppender() throws Exception {
final LoggerContext loggerContext = TestConfigurator.configure("target/test-classes/log4j1-list.xml");
final Logger logger = LogManager.getLogger("test");
logger.debug("This is a test of the root logger");
@@ -81,13 +81,13 @@ public void testListAppender() throws Exception {
assertNotNull(eventAppender, "No Event Appender");
assertNotNull(messageAppender, "No Message Appender");
final List events = eventAppender.getEvents();
- assertTrue(events != null && events.size() > 0, "No events");
+ assertTrue(events != null && !events.isEmpty(), "No events");
final List messages = messageAppender.getMessages();
- assertTrue(messages != null && messages.size() > 0, "No messages");
+ assertTrue(messages != null && !messages.isEmpty(), "No messages");
}
@Test
- public void testXML() throws Exception {
+ void testXML() throws Exception {
TestConfigurator.configure("target/test-classes/log4j1-file.xml");
final Logger logger = LogManager.getLogger("test");
logger.debug("This is a test of the root logger");
@@ -184,20 +184,20 @@ public void testGlobalThreshold() throws Exception {
}
@Test
- public void testEnhancedRollingFileAppender() throws Exception {
+ void testEnhancedRollingFileAppender() throws Exception {
try (final LoggerContext ctx = configure("config-1.2/log4j-EnhancedRollingFileAppender")) {
final Configuration configuration = ctx.getConfiguration();
assertNotNull(configuration);
testEnhancedRollingFileAppender(configuration);
// Only supported through XML configuration
final Appender appender = configuration.getAppender("MIXED");
- assertTrue(appender instanceof RollingFileAppender, "is RollingFileAppender");
+ assertInstanceOf(RollingFileAppender.class, appender, "is RollingFileAppender");
final TriggeringPolicy policy = ((RollingFileAppender) appender).getTriggeringPolicy();
- assertTrue(policy instanceof CompositeTriggeringPolicy, "is CompositeTriggeringPolicy");
+ assertInstanceOf(CompositeTriggeringPolicy.class, policy, "is CompositeTriggeringPolicy");
final TriggeringPolicy[] policies = ((CompositeTriggeringPolicy) policy).getTriggeringPolicies();
assertEquals(2, policies.length);
- assertTrue(policies[0] instanceof TimeBasedTriggeringPolicy, "is TimeBasedTriggeringPolicy");
- assertTrue(policies[1] instanceof SizeBasedTriggeringPolicy, "is SizeBasedTriggeringPolicy");
+ assertInstanceOf(TimeBasedTriggeringPolicy.class, policies[0], "is TimeBasedTriggeringPolicy");
+ assertInstanceOf(SizeBasedTriggeringPolicy.class, policies[1], "is SizeBasedTriggeringPolicy");
}
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java
index af91d40ae59..ee9dbfcdb9a 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java
@@ -35,7 +35,7 @@
/**
* Test reconfiguring with an XML configuration.
*/
-public class XmlReconfigurationTest {
+class XmlReconfigurationTest {
private static final String CONFIG = "target/test-classes/log4j1-file.xml";
private static final long FIVE_MINUTES = 5 * 60 * 1000;
@@ -43,7 +43,7 @@ public class XmlReconfigurationTest {
private final CountDownLatch toggle = new CountDownLatch(1);
@Test
- public void testReconfiguration() throws Exception {
+ void testReconfiguration() throws Exception {
System.setProperty(Log4j1Configuration.MONITOR_INTERVAL, "1");
final File file = new File(CONFIG);
assertNotNull(file, "No Config file");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java
index bd2e9a2b2ba..0847a3cc93e 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java
@@ -29,18 +29,18 @@
/**
* Test configuration from Properties.
*/
-public class XmlRollingWithPropertiesTest {
+class XmlRollingWithPropertiesTest {
private static final String TEST_DIR = "target/" + XmlRollingWithPropertiesTest.class.getSimpleName();
@BeforeAll
- public static void setupSystemProperties() {
+ static void setupSystemProperties() {
System.setProperty("test.directory", TEST_DIR);
System.setProperty("log4j.configuration", "target/test-classes/log4j1-rolling-properties.xml");
}
@Test
- public void testProperties() throws Exception {
+ void testProperties() throws Exception {
// ${test.directory}/logs/etl.log
final Path path = Paths.get(TEST_DIR, "logs/etl.log");
Files.deleteIfExists(path);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java
index 38dc4573afc..d45b21448e0 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java
@@ -56,7 +56,7 @@ public BoundedFIFOTestCase(final String name) {
}
int min(final int a, final int b) {
- return a < b ? a : b;
+ return Math.min(a, b);
}
@Override
@@ -82,11 +82,11 @@ public void test1() {
bf.put(e[j]);
assertEquals(bf.length(), j < size ? j + 1 : size);
}
- final int max = size < j ? size : j;
+ final int max = Math.min(size, j);
j--;
for (k = 0; k <= j; k++) {
// System.out.println("max="+max+", j="+j+", k="+k);
- assertEquals(bf.length(), max - k > 0 ? max - k : 0);
+ assertEquals(bf.length(), Math.max(max - k, 0));
final Object r = bf.get();
// System.out.println("Got "+r);
if (k >= size) {
@@ -112,19 +112,19 @@ public void test2() {
assertNull(bf.get());
bf.put(e[1]);
- assertEquals(bf.length(), 1);
+ assertEquals(1, bf.length());
bf.put(e[2]);
- assertEquals(bf.length(), 2);
+ assertEquals(2, bf.length());
bf.put(e[3]);
- assertEquals(bf.length(), 3);
+ assertEquals(3, bf.length());
assertEquals(bf.get(), e[1]);
- assertEquals(bf.length(), 2);
+ assertEquals(2, bf.length());
assertEquals(bf.get(), e[2]);
- assertEquals(bf.length(), 1);
+ assertEquals(1, bf.length());
assertEquals(bf.get(), e[3]);
- assertEquals(bf.length(), 0);
+ assertEquals(0, bf.length());
assertNull(bf.get());
- assertEquals(bf.length(), 0);
+ assertEquals(0, bf.length());
}
/**
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java
index a2f19761b57..864e400e30a 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java
@@ -64,7 +64,7 @@ void doTest1(final int size) {
for (int i = 0; i < MAX; i++) {
cb.add(e[i]);
- final int limit = i < size - 1 ? i : size - 1;
+ final int limit = Math.min(i, size - 1);
// System.out.println("\nLimit is " + limit + ", i="+i);
@@ -91,8 +91,8 @@ void doTestResize(final int initialSize, final int numberOfAdds, final int newSi
offset = 0;
}
- int len = newSize < numberOfAdds ? newSize : numberOfAdds;
- len = len < initialSize ? len : initialSize;
+ int len = Math.min(newSize, numberOfAdds);
+ len = Math.min(len, initialSize);
// System.out.println("Len = "+len+", offset="+offset);
for (int j = 0; j < len; j++) {
assertEquals(cb.get(j), e[offset + j]);
@@ -109,22 +109,22 @@ public void test0() {
assertEquals(size, cb.getMaxSize());
cb.add(e[0]);
- assertEquals(cb.length(), 1);
+ assertEquals(1, cb.length());
assertEquals(cb.get(), e[0]);
- assertEquals(cb.length(), 0);
+ assertEquals(0, cb.length());
assertNull(cb.get());
- assertEquals(cb.length(), 0);
+ assertEquals(0, cb.length());
cb = new CyclicBuffer(size);
cb.add(e[0]);
cb.add(e[1]);
- assertEquals(cb.length(), 2);
+ assertEquals(2, cb.length());
assertEquals(cb.get(), e[0]);
- assertEquals(cb.length(), 1);
+ assertEquals(1, cb.length());
assertEquals(cb.get(), e[1]);
- assertEquals(cb.length(), 0);
+ assertEquals(0, cb.length());
assertNull(cb.get());
- assertEquals(cb.length(), 0);
+ assertEquals(0, cb.length());
}
/**
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/OptionConverterLevelTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/OptionConverterLevelTest.java
index 65a1cb69c5d..2156540c111 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/OptionConverterLevelTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/OptionConverterLevelTest.java
@@ -34,7 +34,7 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
-public class OptionConverterLevelTest {
+class OptionConverterLevelTest {
static Stream standardLevels() {
return Arrays.stream(StandardLevel.values())
@@ -47,7 +47,7 @@ static Stream standardLevels() {
*/
@ParameterizedTest
@MethodSource("standardLevels")
- public void testStandardLevelConversion(final Level log4j1Level, final org.apache.logging.log4j.Level log4j2Level) {
+ void testStandardLevelConversion(final Level log4j1Level, final org.apache.logging.log4j.Level log4j2Level) {
assertThat(log4j2Level).isSameAs(OptionConverter.convertLevel(log4j1Level));
assertThat(log4j1Level).isSameAs(OptionConverter.convertLevel(log4j2Level));
assertThat(OptionConverter.toLevel(org.apache.logging.log4j.Level.class.getName(), log4j2Level.name(), null))
@@ -59,14 +59,13 @@ public void testStandardLevelConversion(final Level log4j1Level, final org.apach
*/
@ParameterizedTest
@MethodSource("standardLevels")
- public void testStandardIntLevelConversion(
- final Level log4j1Level, final org.apache.logging.log4j.Level log4j2Level) {
+ void testStandardIntLevelConversion(final Level log4j1Level, final org.apache.logging.log4j.Level log4j2Level) {
assertEquals(log4j2Level.intLevel(), toLog4j2Level(log4j1Level.toInt()));
assertEquals(log4j1Level.toInt(), toLog4j1Level(log4j2Level.intLevel()));
}
@Test
- public void testMaxMinCutoff() {
+ void testMaxMinCutoff() {
// The cutoff values are transformed into ALL and OFF
assertEquals(StandardLevel.ALL.intLevel(), toLog4j2Level(OptionConverter.MIN_CUTOFF_LEVEL));
assertEquals(StandardLevel.OFF.intLevel(), toLog4j2Level(OptionConverter.MAX_CUTOFF_LEVEL));
@@ -87,7 +86,7 @@ public void testMaxMinCutoff() {
* correctly.
*/
@Test
- public void testUsefulRange() {
+ void testUsefulRange() {
for (int intLevel = StandardLevel.OFF.intLevel(); intLevel <= StandardLevel.TRACE.intLevel(); intLevel++) {
assertEquals(intLevel, toLog4j2Level(toLog4j1Level(intLevel)));
}
@@ -101,7 +100,7 @@ public void testUsefulRange() {
* used in {@link LogEventAdapter}.
*/
@Test
- public void testCustomLog4j2Levels() {
+ void testCustomLog4j2Levels() {
final int infoDebug = (StandardLevel.INFO.intLevel() + StandardLevel.DEBUG.intLevel()) / 2;
final org.apache.logging.log4j.Level v2Level = org.apache.logging.log4j.Level.forName("INFO_DEBUG", infoDebug);
final Level v1Level =
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/UtilLoggingLevelTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/UtilLoggingLevelTest.java
index f9ee8c548c3..2e41de6b142 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/UtilLoggingLevelTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/UtilLoggingLevelTest.java
@@ -20,6 +20,7 @@
import java.util.stream.Stream;
import org.apache.log4j.Level;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@@ -32,6 +33,7 @@ public class UtilLoggingLevelTest {
/**
* Test toLevel("fiNeSt").
*/
+ @Test
public void testToLevelFINEST() {
assertEquals(UtilLoggingLevel.FINEST, UtilLoggingLevel.toLevel("fiNeSt"));
}
@@ -43,7 +45,7 @@ static Stream namesAndLevels() {
@ParameterizedTest
@MethodSource("namesAndLevels")
- public void testOptionConverterToLevel(final String name, final UtilLoggingLevel level) {
+ void testOptionConverterToLevel(final String name, final UtilLoggingLevel level) {
assertEquals(level, OptionConverter.toLevel(name, Level.ALL), "get v1 level by name");
// Comparison of Log4j 2.x levels
assertEquals(level.getVersion2Level(), org.apache.logging.log4j.Level.getLevel(name), "get v2 level by name");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1SyslogLayoutTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1SyslogLayoutTest.java
index bb4f4428df2..b19382edd3a 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1SyslogLayoutTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1SyslogLayoutTest.java
@@ -35,7 +35,7 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
-public class Log4j1SyslogLayoutTest {
+class Log4j1SyslogLayoutTest {
private static final SimpleMessage MESSAGE = new SimpleMessage("Hello world!");
private static final long TIMESTAMP = LocalDateTime.of(2022, 4, 5, 12, 34, 56)
@@ -68,7 +68,7 @@ static Stream configurations() {
@ParameterizedTest
@MethodSource("configurations")
- public void testSimpleLayout(
+ void testSimpleLayout(
final String expected, final Facility facility, final boolean header, final boolean facilityPrinting) {
final LogEvent logEvent = createLogEvent();
StringLayout appenderLayout = Log4j1SyslogLayout.newBuilder()
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java
index 46d6bf4cbc7..1af12167a60 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java
@@ -27,10 +27,10 @@
import org.junit.jupiter.api.Test;
@UsingThreadContextStack
-public class Log4j1XmlLayoutTest {
+class Log4j1XmlLayoutTest {
@Test
- public void testWithoutThrown() {
+ void testWithoutThrown() {
final Log4j1XmlLayout layout = Log4j1XmlLayout.createLayout(false, true);
final Log4jLogEvent event = Log4jLogEvent.newBuilder()
@@ -51,7 +51,7 @@ public void testWithoutThrown() {
}
@Test
- public void testWithPropertiesAndLocationInfo() {
+ void testWithPropertiesAndLocationInfo() {
final Log4j1XmlLayout layout = Log4j1XmlLayout.createLayout(true, true);
final StringMap contextMap = ContextDataFactory.createContextData(2);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
index 529220966e3..291224674ea 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
@@ -43,7 +43,7 @@ public void testConstructor() {
assertNotNull(field);
assertEquals(3, field.getMinLength());
assertEquals(6, field.getMaxLength());
- assertEquals(true, field.isLeftAligned());
+ assertTrue(field.isLeftAligned());
}
/**
@@ -55,7 +55,7 @@ public void testGetDefault() {
assertNotNull(field);
assertEquals(0, field.getMinLength());
assertEquals(Integer.MAX_VALUE, field.getMaxLength());
- assertEquals(false, field.isLeftAligned());
+ assertFalse(field.isLeftAligned());
}
/**
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1LevelPatternConverterTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1LevelPatternConverterTest.java
index 4170859d7fb..d6bcbb50fe2 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1LevelPatternConverterTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1LevelPatternConverterTest.java
@@ -25,7 +25,7 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
-public class Log4j1LevelPatternConverterTest {
+class Log4j1LevelPatternConverterTest {
/**
* Tests if the converter returns the Log4j 1.x {@code toString()} value of
@@ -35,7 +35,7 @@ public class Log4j1LevelPatternConverterTest {
*/
@ParameterizedTest
@MethodSource("org.apache.log4j.helpers.UtilLoggingLevel#getAllPossibleLevels")
- public void testUtilLoggingLevels(final Level level) {
+ void testUtilLoggingLevels(final Level level) {
final Log4j1LevelPatternConverter converter = Log4j1LevelPatternConverter.newInstance(null);
final LogEvent logEvent = mock(LogEvent.class);
when(logEvent.getLevel()).thenReturn(level.getVersion2Level());
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1MdcPatternConverterTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1MdcPatternConverterTest.java
index aa9359a3b75..7b791c1442d 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1MdcPatternConverterTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1MdcPatternConverterTest.java
@@ -26,17 +26,17 @@
import org.apache.logging.log4j.util.StringMap;
import org.junit.jupiter.api.Test;
-public class Log4j1MdcPatternConverterTest {
+class Log4j1MdcPatternConverterTest {
@Test
- public void testConverter0() {
+ void testConverter0() {
final StringMap contextMap = ContextDataFactory.createContextData(0);
final String expected = "{}";
test(contextMap, expected, null);
}
@Test
- public void testConverter1() {
+ void testConverter1() {
final StringMap contextMap = ContextDataFactory.createContextData(1);
contextMap.putValue("key1", "value1");
final String expected = "{{key1,value1}}";
@@ -44,7 +44,7 @@ public void testConverter1() {
}
@Test
- public void testConverter2() {
+ void testConverter2() {
final StringMap contextMap = ContextDataFactory.createContextData(2);
contextMap.putValue("key1", "value1");
contextMap.putValue("key2", "value2");
@@ -53,7 +53,7 @@ public void testConverter2() {
}
@Test
- public void testConverterWithKey() {
+ void testConverterWithKey() {
final StringMap contextMap = ContextDataFactory.createContextData(2);
contextMap.putValue("key1", "value1");
contextMap.putValue("key2", "value2");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1NdcPatternConverterTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1NdcPatternConverterTest.java
index 146ac902ed2..a0b3da20d40 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1NdcPatternConverterTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1NdcPatternConverterTest.java
@@ -27,28 +27,28 @@
import org.junit.jupiter.api.Test;
@UsingThreadContextStack
-public class Log4j1NdcPatternConverterTest {
+class Log4j1NdcPatternConverterTest {
@Test
- public void testEmpty() {
+ void testEmpty() {
testConverter("");
}
@Test
- public void test1() {
+ void test1() {
ThreadContext.push("foo");
testConverter("foo");
}
@Test
- public void test2() {
+ void test2() {
ThreadContext.push("foo");
ThreadContext.push("bar");
testConverter("foo bar");
}
@Test
- public void test3() {
+ void test3() {
ThreadContext.push("foo");
ThreadContext.push("bar");
ThreadContext.push("baz");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/NameAbbreviatorTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/NameAbbreviatorTest.java
index d051581f38c..06f2e9698c2 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/NameAbbreviatorTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/NameAbbreviatorTest.java
@@ -39,7 +39,7 @@ public NameAbbreviatorTest(final String name) {
public void testBlank() {
final NameAbbreviator abbrev = NameAbbreviator.getAbbreviator(" ");
final NameAbbreviator defaultAbbrev = NameAbbreviator.getDefaultAbbreviator();
- assertTrue(abbrev == defaultAbbrev);
+ assertSame(abbrev, defaultAbbrev);
}
/**
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/spi/ThrowableInformationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/spi/ThrowableInformationTest.java
index 36e25538418..bd8549c0a2d 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/spi/ThrowableInformationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/spi/ThrowableInformationTest.java
@@ -119,11 +119,11 @@ public void testNotOverriddenBehavior() {
assertEquals(7, rep.length);
final StringBuffer buf = new StringBuffer(String.valueOf(true));
buf.append('a');
- buf.append(String.valueOf(1));
- buf.append(String.valueOf(2L));
- buf.append(String.valueOf(Float.MAX_VALUE));
- buf.append(String.valueOf(Double.MIN_VALUE));
- buf.append(String.valueOf(true));
+ buf.append(1);
+ buf.append(2L);
+ buf.append(Float.MAX_VALUE);
+ buf.append(Double.MIN_VALUE);
+ buf.append(true);
assertEquals(buf.toString(), rep[0]);
assertEquals("a", rep[1]);
assertEquals(String.valueOf(1), rep[2]);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/xml/DOMTestCase.java b/log4j-1.2-api/src/test/java/org/apache/log4j/xml/DOMTestCase.java
index fb63057df19..695d32179ff 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/xml/DOMTestCase.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/xml/DOMTestCase.java
@@ -53,13 +53,13 @@ class DOMTestCase {
Logger logger;
@BeforeEach
- public void setUp() {
+ void setUp() {
root = Logger.getRootLogger();
logger = Logger.getLogger(DOMTestCase.class);
}
@AfterEach
- public void tearDown() {
+ void tearDown() {
root.getLoggerRepository().resetConfiguration();
}
@@ -110,7 +110,7 @@ void testJarURL() throws Exception {
*
*/
@Test
- public void testOverrideSubst() {
+ void testOverrideSubst() {
final DOMConfigurator configurator = new DOMConfigurator();
configurator.doConfigure(
DOMTestCase.class.getResource("/DOMTestCase/DOMTestCase1.xml"), LogManager.getLoggerRepository());
@@ -131,7 +131,7 @@ public void testOverrideSubst() {
*
*/
@Test
- public void testReset() {
+ void testReset() {
final VectorAppender appender = new VectorAppender();
appender.setName("V1");
Logger.getRootLogger().addAppender(appender);
diff --git a/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/ProcessIdUtilTest.java b/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/ProcessIdUtilTest.java
index 7b7e86bc3df..1a24860f57d 100644
--- a/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/ProcessIdUtilTest.java
+++ b/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/ProcessIdUtilTest.java
@@ -21,10 +21,10 @@
import org.apache.logging.log4j.util.ProcessIdUtil;
import org.junit.jupiter.api.Test;
-public class ProcessIdUtilTest {
+class ProcessIdUtilTest {
@Test
- public void processIdTest() {
+ void processIdTest() {
final String processId = ProcessIdUtil.getProcessId();
assertNotEquals(processId, ProcessIdUtil.DEFAULT_PROCESSID, "ProcessId is default");
}
diff --git a/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorTest.java b/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorTest.java
index 1e8591c2074..2ccebbde0f3 100644
--- a/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorTest.java
+++ b/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorTest.java
@@ -26,10 +26,10 @@
import org.apache.logging.log4j.util.StackLocator;
import org.junit.jupiter.api.Test;
-public class StackLocatorTest {
+class StackLocatorTest {
@Test
- public void testGetCallerClass() {
+ void testGetCallerClass() {
final Class> expected = StackLocatorTest.class;
final StackLocator stackLocator = StackLocator.getInstance();
final Class> actual = stackLocator.getCallerClass(1);
@@ -37,14 +37,14 @@ public void testGetCallerClass() {
}
@Test
- public void testGetCallerClassNameViaStackTrace() throws Exception {
+ void testGetCallerClassNameViaStackTrace() throws Exception {
final Class> expected = StackLocatorTest.class;
final Class> actual = Class.forName(new Throwable().getStackTrace()[0].getClassName());
assertSame(expected, actual);
}
@Test
- public void testGetCurrentStackTrace() {
+ void testGetCurrentStackTrace() {
final StackLocator stackLocator = StackLocator.getInstance();
final Deque> classes = stackLocator.getCurrentStackTrace();
final Stack> reversed = new Stack<>();
@@ -60,12 +60,12 @@ public void testGetCurrentStackTrace() {
}
@Test
- public void testGetCallerClassViaName() {
+ void testGetCallerClassViaName() {
Inner.assertCallerClassViaName();
}
@Test
- public void testGetCallerClassViaAnchorClass() {
+ void testGetCallerClassViaAnchorClass() {
Inner.assertCallerClassViaAnchorClass();
}
@@ -86,7 +86,7 @@ private static void assertCallerClassViaAnchorClass() {
}
@Test
- public void testLocateClass() {
+ void testLocateClass() {
final ClassLocator locator = new ClassLocator();
final Class> clazz = locator.locateClass();
assertNotNull(clazz, "Could not locate class");
@@ -117,7 +117,7 @@ private StackTraceElement quux() {
}
@Test
- public void testCalcLocation() {
+ void testCalcLocation() {
/*
* We are setting up a stack trace that looks like:
* - org.apache.logging.log4j.util.test.StackLocatorTest#quux(line:118)
@@ -135,14 +135,14 @@ public void testCalcLocation() {
}
@Test
- public void testTopElementInStackTrace() {
+ void testTopElementInStackTrace() {
final StackLocator stackLocator = StackLocator.getInstance();
final Deque> classes = stackLocator.getCurrentStackTrace();
assertSame(StackLocator.class, classes.getFirst());
}
@Test
- public void testCalcLocationWhenNotInTheStack() {
+ void testCalcLocationWhenNotInTheStack() {
final StackLocator stackLocator = StackLocator.getInstance();
final StackTraceElement stackTraceElement = stackLocator.calcLocation("java.util.Logger");
assertNull(stackTraceElement);
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/AbstractSerializationTest.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/AbstractSerializationTest.java
index 900fea6ab54..a2b67b64889 100644
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/AbstractSerializationTest.java
+++ b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/AbstractSerializationTest.java
@@ -17,7 +17,7 @@
package org.apache.logging.log4j.test;
import static org.apache.logging.log4j.test.SerializableMatchers.serializesRoundTrip;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import java.io.Serializable;
import org.junit.Test;
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ThreadContextUtilityClass.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ThreadContextUtilityClass.java
index 396039a50b1..eed1952c324 100644
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ThreadContextUtilityClass.java
+++ b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ThreadContextUtilityClass.java
@@ -16,10 +16,10 @@
*/
package org.apache.logging.log4j.test;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
index f83afb25a9c..79a8fd75dd8 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
@@ -48,7 +48,7 @@
@ResourceLock(value = Log4jStaticResources.MARKER_MANAGER, mode = ResourceAccessMode.READ)
@SetSystemProperty(key = "log4j2.status.entries", value = "200")
@SetSystemProperty(key = "log4j2.StatusLogger.level", value = "WARN")
-public class AbstractLoggerTest {
+class AbstractLoggerTest {
private static final StringBuilder CHAR_SEQ = new StringBuilder("CharSeq");
@@ -94,7 +94,7 @@ public class AbstractLoggerTest {
};
@Test
- public void testDebug() {
+ void testDebug() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.DEBUG);
@@ -149,7 +149,7 @@ public void testDebug() {
}
@Test
- public void testError() {
+ void testError() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.ERROR);
@@ -204,7 +204,7 @@ public void testError() {
}
@Test
- public void testFatal() {
+ void testFatal() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.FATAL);
@@ -259,7 +259,7 @@ public void testFatal() {
}
@Test
- public void testInfo() {
+ void testInfo() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.INFO);
@@ -314,7 +314,7 @@ public void testInfo() {
}
@Test
- public void testLogDebug() {
+ void testLogDebug() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.DEBUG);
@@ -369,7 +369,7 @@ public void testLogDebug() {
}
@Test
- public void testLogError() {
+ void testLogError() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.ERROR);
@@ -424,7 +424,7 @@ public void testLogError() {
}
@Test
- public void testLogFatal() {
+ void testLogFatal() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.FATAL);
@@ -479,7 +479,7 @@ public void testLogFatal() {
}
@Test
- public void testLogInfo() {
+ void testLogInfo() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.INFO);
@@ -534,7 +534,7 @@ public void testLogInfo() {
}
@Test
- public void testLogTrace() {
+ void testLogTrace() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.TRACE);
@@ -589,7 +589,7 @@ public void testLogTrace() {
}
@Test
- public void testLogWarn() {
+ void testLogWarn() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.WARN);
@@ -644,7 +644,7 @@ public void testLogWarn() {
}
@Test
- public void testTrace() {
+ void testTrace() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.TRACE);
@@ -699,7 +699,7 @@ public void testTrace() {
}
@Test
- public void testWarn() {
+ void testWarn() {
final CountingLogger logger = new CountingLogger();
logger.setCurrentLevel(Level.WARN);
@@ -754,7 +754,7 @@ public void testWarn() {
}
@Test
- public void testMessageWithThrowable() {
+ void testMessageWithThrowable() {
final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(true);
final ThrowableMessage message = new ThrowableMessage(t);
@@ -776,7 +776,7 @@ public void testMessageWithThrowable() {
}
@Test
- public void testMessageWithoutThrowable() {
+ void testMessageWithoutThrowable() {
final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
final ThrowableMessage message = new ThrowableMessage(null);
@@ -798,7 +798,7 @@ public void testMessageWithoutThrowable() {
}
@Test
- public void testMessageSupplierWithThrowable() {
+ void testMessageSupplierWithThrowable() {
final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(true);
final ThrowableMessage message = new ThrowableMessage(t);
final MessageSupplier supplier = () -> message;
@@ -821,7 +821,7 @@ public void testMessageSupplierWithThrowable() {
}
@Test
- public void testMessageSupplierWithoutThrowable() {
+ void testMessageSupplierWithoutThrowable() {
final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
final ThrowableMessage message = new ThrowableMessage(null);
final MessageSupplier supplier = () -> message;
@@ -844,7 +844,7 @@ public void testMessageSupplierWithoutThrowable() {
}
@Test
- public void testSupplierWithThrowable() {
+ void testSupplierWithThrowable() {
final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(true);
final ThrowableMessage message = new ThrowableMessage(t);
final Supplier supplier = () -> message;
@@ -867,7 +867,7 @@ public void testSupplierWithThrowable() {
}
@Test
- public void testSupplierWithoutThrowable() {
+ void testSupplierWithoutThrowable() {
final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
final ThrowableMessage message = new ThrowableMessage(null);
final Supplier supplier = () -> message;
@@ -891,7 +891,7 @@ public void testSupplierWithoutThrowable() {
@Test
@ResourceLock("log4j2.StatusLogger")
- public void testMessageThrows() {
+ void testMessageThrows() {
final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
logger.error(new TestMessage(
() -> {
@@ -909,7 +909,7 @@ public void testMessageThrows() {
@Test
@ResourceLock("log4j2.StatusLogger")
- public void testMessageThrowsAndNullFormat() {
+ void testMessageThrowsAndNullFormat() {
final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
logger.error(new TestMessage(
() -> {
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/CloseableThreadContextTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/CloseableThreadContextTest.java
index bc053b080c3..c6bab5da531 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/CloseableThreadContextTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/CloseableThreadContextTest.java
@@ -38,7 +38,7 @@
* @since 2.6
*/
@ResourceLock(value = Resources.SYSTEM_PROPERTIES, mode = ResourceAccessMode.READ)
-public class CloseableThreadContextTest {
+class CloseableThreadContextTest {
private final String key = "key";
private final String value = "value";
@@ -50,7 +50,7 @@ void clearThreadContext() {
}
@Test
- public void shouldAddAnEntryToTheMap() {
+ void shouldAddAnEntryToTheMap() {
try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.put(key, value)) {
assertNotNull(ignored);
assertEquals(value, ThreadContext.get(key));
@@ -58,7 +58,7 @@ public void shouldAddAnEntryToTheMap() {
}
@Test
- public void shouldAddTwoEntriesToTheMap() {
+ void shouldAddTwoEntriesToTheMap() {
final String key2 = "key2";
final String value2 = "value2";
try (final CloseableThreadContext.Instance ignored =
@@ -70,7 +70,7 @@ public void shouldAddTwoEntriesToTheMap() {
}
@Test
- public void shouldNestEntries() {
+ void shouldNestEntries() {
final String oldValue = "oldValue";
final String innerValue = "innerValue";
ThreadContext.put(key, oldValue);
@@ -87,7 +87,7 @@ public void shouldNestEntries() {
}
@Test
- public void shouldPreserveOldEntriesFromTheMapWhenAutoClosed() {
+ void shouldPreserveOldEntriesFromTheMapWhenAutoClosed() {
final String oldValue = "oldValue";
ThreadContext.put(key, oldValue);
try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.put(key, value)) {
@@ -98,7 +98,7 @@ public void shouldPreserveOldEntriesFromTheMapWhenAutoClosed() {
}
@Test
- public void ifTheSameKeyIsAddedTwiceTheOriginalShouldBeUsed() {
+ void ifTheSameKeyIsAddedTwiceTheOriginalShouldBeUsed() {
final String oldValue = "oldValue";
final String secondValue = "innerValue";
ThreadContext.put(key, oldValue);
@@ -111,7 +111,7 @@ public void ifTheSameKeyIsAddedTwiceTheOriginalShouldBeUsed() {
}
@Test
- public void shouldPushAndPopAnEntryToTheStack() {
+ void shouldPushAndPopAnEntryToTheStack() {
final String message = "message";
try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.push(message)) {
assertNotNull(ignored);
@@ -121,7 +121,7 @@ public void shouldPushAndPopAnEntryToTheStack() {
}
@Test
- public void shouldPushAndPopTwoEntriesToTheStack() {
+ void shouldPushAndPopTwoEntriesToTheStack() {
final String message1 = "message1";
final String message2 = "message2";
try (final CloseableThreadContext.Instance ignored =
@@ -133,7 +133,7 @@ public void shouldPushAndPopTwoEntriesToTheStack() {
}
@Test
- public void shouldPushAndPopAParameterizedEntryToTheStack() {
+ void shouldPushAndPopAParameterizedEntryToTheStack() {
final String parameterizedMessage = "message {}";
final String parameterizedMessageParameter = "param";
final String formattedMessage = parameterizedMessage.replace("{}", parameterizedMessageParameter);
@@ -146,7 +146,7 @@ public void shouldPushAndPopAParameterizedEntryToTheStack() {
}
@Test
- public void shouldRemoveAnEntryFromTheMapWhenAutoClosed() {
+ void shouldRemoveAnEntryFromTheMapWhenAutoClosed() {
try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.put(key, value)) {
assertNotNull(ignored);
assertEquals(value, ThreadContext.get(key));
@@ -155,7 +155,7 @@ public void shouldRemoveAnEntryFromTheMapWhenAutoClosed() {
}
@Test
- public void shouldAddEntriesToBothStackAndMap() {
+ void shouldAddEntriesToBothStackAndMap() {
final String stackValue = "something";
try (final CloseableThreadContext.Instance ignored =
CloseableThreadContext.put(key, value).push(stackValue)) {
@@ -168,7 +168,7 @@ public void shouldAddEntriesToBothStackAndMap() {
}
@Test
- public void canReuseCloseableThreadContext() {
+ void canReuseCloseableThreadContext() {
final String stackValue = "something";
// Create a ctc and close it
final CloseableThreadContext.Instance ctc =
@@ -195,7 +195,7 @@ public void canReuseCloseableThreadContext() {
}
@Test
- public void closeIsIdempotent() {
+ void closeIsIdempotent() {
final String originalMapValue = "map to keep";
final String originalStackValue = "stack to keep";
@@ -218,7 +218,7 @@ public void closeIsIdempotent() {
}
@Test
- public void putAllWillPutAllValues() {
+ void putAllWillPutAllValues() {
final String oldValue = "oldValue";
ThreadContext.put(key, oldValue);
@@ -234,7 +234,7 @@ public void putAllWillPutAllValues() {
}
@Test
- public void pushAllWillPushAllValues() {
+ void pushAllWillPushAllValues() {
ThreadContext.push(key);
final List messages = ThreadContext.getImmutableStack().asList();
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/EventLoggerTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/EventLoggerTest.java
index c13829e27bb..a6611bbf27f 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/EventLoggerTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/EventLoggerTest.java
@@ -27,18 +27,18 @@
import org.junit.jupiter.api.parallel.ResourceLock;
@ResourceLock("log4j2.TestLogger")
-public class EventLoggerTest {
+class EventLoggerTest {
TestLogger logger = (TestLogger) LogManager.getLogger("EventLogger");
List results = logger.getEntries();
@BeforeEach
- public void setup() {
+ void setup() {
results.clear();
}
@Test
- public void structuredData() {
+ void structuredData() {
ThreadContext.put("loginId", "JohnDoe");
ThreadContext.put("ipAddress", "192.168.0.120");
ThreadContext.put("locale", Locale.US.getDisplayName(Locale.US));
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/LambdaLoggerTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/LambdaLoggerTest.java
index b5ce701d154..c84ba45e91b 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/LambdaLoggerTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/LambdaLoggerTest.java
@@ -34,7 +34,7 @@
/**
* Tests the AbstractLogger implementation of the Logger2 interface.
*/
-public class LambdaLoggerTest {
+class LambdaLoggerTest {
private static class LogEvent {
@SuppressWarnings("unused")
@@ -275,14 +275,14 @@ public String get() {
final Supplier[] supplierArray2 = new Supplier[] {supplier, supplier2};
@BeforeEach
- public void beforeEachTest() {
+ void beforeEachTest() {
logger2.list.clear();
supplier.invoked = false;
messageSupplier.invoked = false;
}
@Test
- public void testDebugMarkerMessageSupplier() {
+ void testDebugMarkerMessageSupplier() {
logger2.disable().debug(marker, messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -298,7 +298,7 @@ public void testDebugMarkerMessageSupplier() {
}
@Test
- public void testDebugMessageSupplier() {
+ void testDebugMessageSupplier() {
logger2.disable().debug(messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -313,7 +313,7 @@ public void testDebugMessageSupplier() {
}
@Test
- public void testDebugMarkerMessageSupplierThrowable() {
+ void testDebugMarkerMessageSupplierThrowable() {
logger2.disable().debug(marker, messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -330,7 +330,7 @@ public void testDebugMarkerMessageSupplierThrowable() {
}
@Test
- public void testDebugMessageSupplierThrowable() {
+ void testDebugMessageSupplierThrowable() {
logger2.disable().debug(messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -346,7 +346,7 @@ public void testDebugMessageSupplierThrowable() {
}
@Test
- public void testDebugMarkerSupplier() {
+ void testDebugMarkerSupplier() {
logger2.disable().debug(marker, supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -362,7 +362,7 @@ public void testDebugMarkerSupplier() {
}
@Test
- public void testDebugSupplier() {
+ void testDebugSupplier() {
logger2.disable().debug(supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -377,7 +377,7 @@ public void testDebugSupplier() {
}
@Test
- public void testDebugMarkerSupplierThrowable() {
+ void testDebugMarkerSupplierThrowable() {
logger2.disable().debug(marker, supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -394,7 +394,7 @@ public void testDebugMarkerSupplierThrowable() {
}
@Test
- public void testDebugSupplierThrowable() {
+ void testDebugSupplierThrowable() {
logger2.disable().debug(supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -410,7 +410,7 @@ public void testDebugSupplierThrowable() {
}
@Test
- public void testDebugStringParamSupplier() {
+ void testDebugStringParamSupplier() {
logger2.disable().debug("abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -425,7 +425,7 @@ public void testDebugStringParamSupplier() {
}
@Test
- public void testDebugMarkerStringParamSupplier() {
+ void testDebugMarkerStringParamSupplier() {
logger2.disable().debug(marker, "abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -441,7 +441,7 @@ public void testDebugMarkerStringParamSupplier() {
}
@Test
- public void testErrorMarkerMessageSupplier() {
+ void testErrorMarkerMessageSupplier() {
logger2.disable().error(marker, messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -457,7 +457,7 @@ public void testErrorMarkerMessageSupplier() {
}
@Test
- public void testErrorMessageSupplier() {
+ void testErrorMessageSupplier() {
logger2.disable().error(messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -472,7 +472,7 @@ public void testErrorMessageSupplier() {
}
@Test
- public void testErrorMarkerMessageSupplierThrowable() {
+ void testErrorMarkerMessageSupplierThrowable() {
logger2.disable().error(marker, messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -489,7 +489,7 @@ public void testErrorMarkerMessageSupplierThrowable() {
}
@Test
- public void testErrorMessageSupplierThrowable() {
+ void testErrorMessageSupplierThrowable() {
logger2.disable().error(messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -505,7 +505,7 @@ public void testErrorMessageSupplierThrowable() {
}
@Test
- public void testErrorMarkerSupplier() {
+ void testErrorMarkerSupplier() {
logger2.disable().error(marker, supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -521,7 +521,7 @@ public void testErrorMarkerSupplier() {
}
@Test
- public void testErrorSupplier() {
+ void testErrorSupplier() {
logger2.disable().error(supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -536,7 +536,7 @@ public void testErrorSupplier() {
}
@Test
- public void testErrorMarkerSupplierThrowable() {
+ void testErrorMarkerSupplierThrowable() {
logger2.disable().error(marker, supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -553,7 +553,7 @@ public void testErrorMarkerSupplierThrowable() {
}
@Test
- public void testErrorSupplierThrowable() {
+ void testErrorSupplierThrowable() {
logger2.disable().error(supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -569,7 +569,7 @@ public void testErrorSupplierThrowable() {
}
@Test
- public void testErrorStringParamSupplier() {
+ void testErrorStringParamSupplier() {
logger2.disable().error("abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -584,7 +584,7 @@ public void testErrorStringParamSupplier() {
}
@Test
- public void testErrorMarkerStringParamSupplier() {
+ void testErrorMarkerStringParamSupplier() {
logger2.disable().error(marker, "abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -600,7 +600,7 @@ public void testErrorMarkerStringParamSupplier() {
}
@Test
- public void testFatalMarkerMessageSupplier() {
+ void testFatalMarkerMessageSupplier() {
logger2.disable().fatal(marker, messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -616,7 +616,7 @@ public void testFatalMarkerMessageSupplier() {
}
@Test
- public void testFatalMessageSupplier() {
+ void testFatalMessageSupplier() {
logger2.disable().fatal(messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -631,7 +631,7 @@ public void testFatalMessageSupplier() {
}
@Test
- public void testFatalMarkerMessageSupplierThrowable() {
+ void testFatalMarkerMessageSupplierThrowable() {
logger2.disable().fatal(marker, messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -648,7 +648,7 @@ public void testFatalMarkerMessageSupplierThrowable() {
}
@Test
- public void testFatalMessageSupplierThrowable() {
+ void testFatalMessageSupplierThrowable() {
logger2.disable().fatal(messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -664,7 +664,7 @@ public void testFatalMessageSupplierThrowable() {
}
@Test
- public void testFatalMarkerSupplier() {
+ void testFatalMarkerSupplier() {
logger2.disable().fatal(marker, supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -680,7 +680,7 @@ public void testFatalMarkerSupplier() {
}
@Test
- public void testFatalSupplier() {
+ void testFatalSupplier() {
logger2.disable().fatal(supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -695,7 +695,7 @@ public void testFatalSupplier() {
}
@Test
- public void testFatalMarkerSupplierThrowable() {
+ void testFatalMarkerSupplierThrowable() {
logger2.disable().fatal(marker, supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -712,7 +712,7 @@ public void testFatalMarkerSupplierThrowable() {
}
@Test
- public void testFatalSupplierThrowable() {
+ void testFatalSupplierThrowable() {
logger2.disable().fatal(supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -728,7 +728,7 @@ public void testFatalSupplierThrowable() {
}
@Test
- public void testFatalStringParamSupplier() {
+ void testFatalStringParamSupplier() {
logger2.disable().fatal("abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -743,7 +743,7 @@ public void testFatalStringParamSupplier() {
}
@Test
- public void testFatalStringParam2Suppliers() {
+ void testFatalStringParam2Suppliers() {
logger2.disable().fatal("abc {}{}", supplierArray2);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -760,7 +760,7 @@ public void testFatalStringParam2Suppliers() {
}
@Test
- public void testFatalMarkerStringParamSupplier() {
+ void testFatalMarkerStringParamSupplier() {
logger2.disable().fatal(marker, "abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -776,7 +776,7 @@ public void testFatalMarkerStringParamSupplier() {
}
@Test
- public void testInfoMarkerMessageSupplier() {
+ void testInfoMarkerMessageSupplier() {
logger2.disable().info(marker, messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -792,7 +792,7 @@ public void testInfoMarkerMessageSupplier() {
}
@Test
- public void testInfoMessageSupplier() {
+ void testInfoMessageSupplier() {
logger2.disable().info(messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -807,7 +807,7 @@ public void testInfoMessageSupplier() {
}
@Test
- public void testInfoMarkerMessageSupplierThrowable() {
+ void testInfoMarkerMessageSupplierThrowable() {
logger2.disable().info(marker, messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -824,7 +824,7 @@ public void testInfoMarkerMessageSupplierThrowable() {
}
@Test
- public void testInfoMessageSupplierThrowable() {
+ void testInfoMessageSupplierThrowable() {
logger2.disable().info(messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -840,7 +840,7 @@ public void testInfoMessageSupplierThrowable() {
}
@Test
- public void testInfoMarkerSupplier() {
+ void testInfoMarkerSupplier() {
logger2.disable().info(marker, supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -856,7 +856,7 @@ public void testInfoMarkerSupplier() {
}
@Test
- public void testInfoSupplier() {
+ void testInfoSupplier() {
logger2.disable().info(supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -871,7 +871,7 @@ public void testInfoSupplier() {
}
@Test
- public void testInfoMarkerSupplierThrowable() {
+ void testInfoMarkerSupplierThrowable() {
logger2.disable().info(marker, supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -888,7 +888,7 @@ public void testInfoMarkerSupplierThrowable() {
}
@Test
- public void testInfoSupplierThrowable() {
+ void testInfoSupplierThrowable() {
logger2.disable().info(supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -904,7 +904,7 @@ public void testInfoSupplierThrowable() {
}
@Test
- public void testInfoStringParamSupplier() {
+ void testInfoStringParamSupplier() {
logger2.disable().info("abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -919,7 +919,7 @@ public void testInfoStringParamSupplier() {
}
@Test
- public void testInfoMarkerStringParamSupplier() {
+ void testInfoMarkerStringParamSupplier() {
logger2.disable().info(marker, "abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -935,7 +935,7 @@ public void testInfoMarkerStringParamSupplier() {
}
@Test
- public void testTraceMarkerMessageSupplier() {
+ void testTraceMarkerMessageSupplier() {
logger2.disable().trace(marker, messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -951,7 +951,7 @@ public void testTraceMarkerMessageSupplier() {
}
@Test
- public void testTraceMessageSupplier() {
+ void testTraceMessageSupplier() {
logger2.disable().trace(messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -966,7 +966,7 @@ public void testTraceMessageSupplier() {
}
@Test
- public void testTraceMarkerMessageSupplierThrowable() {
+ void testTraceMarkerMessageSupplierThrowable() {
logger2.disable().trace(marker, messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -983,7 +983,7 @@ public void testTraceMarkerMessageSupplierThrowable() {
}
@Test
- public void testTraceMessageSupplierThrowable() {
+ void testTraceMessageSupplierThrowable() {
logger2.disable().trace(messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -999,7 +999,7 @@ public void testTraceMessageSupplierThrowable() {
}
@Test
- public void testTraceMarkerSupplier() {
+ void testTraceMarkerSupplier() {
logger2.disable().trace(marker, supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1015,7 +1015,7 @@ public void testTraceMarkerSupplier() {
}
@Test
- public void testTraceSupplier() {
+ void testTraceSupplier() {
logger2.disable().trace(supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1030,7 +1030,7 @@ public void testTraceSupplier() {
}
@Test
- public void testTraceMarkerSupplierThrowable() {
+ void testTraceMarkerSupplierThrowable() {
logger2.disable().trace(marker, supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1047,7 +1047,7 @@ public void testTraceMarkerSupplierThrowable() {
}
@Test
- public void testTraceSupplierThrowable() {
+ void testTraceSupplierThrowable() {
logger2.disable().trace(supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1063,7 +1063,7 @@ public void testTraceSupplierThrowable() {
}
@Test
- public void testTraceStringParamSupplier() {
+ void testTraceStringParamSupplier() {
logger2.disable().trace("abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1078,7 +1078,7 @@ public void testTraceStringParamSupplier() {
}
@Test
- public void testTraceMarkerStringParamSupplier() {
+ void testTraceMarkerStringParamSupplier() {
logger2.disable().trace(marker, "abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1094,7 +1094,7 @@ public void testTraceMarkerStringParamSupplier() {
}
@Test
- public void testWarnMarkerMessageSupplier() {
+ void testWarnMarkerMessageSupplier() {
logger2.disable().warn(marker, messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -1110,7 +1110,7 @@ public void testWarnMarkerMessageSupplier() {
}
@Test
- public void testWarnMessageSupplier() {
+ void testWarnMessageSupplier() {
logger2.disable().warn(messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -1125,7 +1125,7 @@ public void testWarnMessageSupplier() {
}
@Test
- public void testWarnMarkerMessageSupplierThrowable() {
+ void testWarnMarkerMessageSupplierThrowable() {
logger2.disable().warn(marker, messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -1142,7 +1142,7 @@ public void testWarnMarkerMessageSupplierThrowable() {
}
@Test
- public void testWarnMessageSupplierThrowable() {
+ void testWarnMessageSupplierThrowable() {
logger2.disable().warn(messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -1158,7 +1158,7 @@ public void testWarnMessageSupplierThrowable() {
}
@Test
- public void testWarnMarkerSupplier() {
+ void testWarnMarkerSupplier() {
logger2.disable().warn(marker, supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1174,7 +1174,7 @@ public void testWarnMarkerSupplier() {
}
@Test
- public void testWarnSupplier() {
+ void testWarnSupplier() {
logger2.disable().warn(supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1189,7 +1189,7 @@ public void testWarnSupplier() {
}
@Test
- public void testWarnMarkerSupplierThrowable() {
+ void testWarnMarkerSupplierThrowable() {
logger2.disable().warn(marker, supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1206,7 +1206,7 @@ public void testWarnMarkerSupplierThrowable() {
}
@Test
- public void testWarnSupplierThrowable() {
+ void testWarnSupplierThrowable() {
logger2.disable().warn(supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1222,7 +1222,7 @@ public void testWarnSupplierThrowable() {
}
@Test
- public void testWarnStringParamSupplier() {
+ void testWarnStringParamSupplier() {
logger2.disable().warn("abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1237,7 +1237,7 @@ public void testWarnStringParamSupplier() {
}
@Test
- public void testWarnMarkerStringParamSupplier() {
+ void testWarnMarkerStringParamSupplier() {
logger2.disable().warn(marker, "abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1253,7 +1253,7 @@ public void testWarnMarkerStringParamSupplier() {
}
@Test
- public void testLogMarkerMessageSupplier() {
+ void testLogMarkerMessageSupplier() {
logger2.disable().log(Level.WARN, marker, messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -1269,7 +1269,7 @@ public void testLogMarkerMessageSupplier() {
}
@Test
- public void testLogMessageSupplier() {
+ void testLogMessageSupplier() {
logger2.disable().log(Level.WARN, messageSupplier);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -1284,7 +1284,7 @@ public void testLogMessageSupplier() {
}
@Test
- public void testLogMarkerMessageSupplierThrowable() {
+ void testLogMarkerMessageSupplierThrowable() {
logger2.disable().log(Level.WARN, marker, messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -1301,7 +1301,7 @@ public void testLogMarkerMessageSupplierThrowable() {
}
@Test
- public void testLogMessageSupplierThrowable() {
+ void testLogMessageSupplierThrowable() {
logger2.disable().log(Level.WARN, messageSupplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(messageSupplier.invoked);
@@ -1317,7 +1317,7 @@ public void testLogMessageSupplierThrowable() {
}
@Test
- public void testLogMarkerSupplier() {
+ void testLogMarkerSupplier() {
logger2.disable().log(Level.WARN, marker, supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1333,7 +1333,7 @@ public void testLogMarkerSupplier() {
}
@Test
- public void testLogSupplier() {
+ void testLogSupplier() {
logger2.disable().log(Level.WARN, supplier);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1348,7 +1348,7 @@ public void testLogSupplier() {
}
@Test
- public void testLogMarkerSupplierThrowable() {
+ void testLogMarkerSupplierThrowable() {
logger2.disable().log(Level.WARN, marker, supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1365,7 +1365,7 @@ public void testLogMarkerSupplierThrowable() {
}
@Test
- public void testLogSupplierThrowable() {
+ void testLogSupplierThrowable() {
logger2.disable().log(Level.WARN, supplier, throwable);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1381,7 +1381,7 @@ public void testLogSupplierThrowable() {
}
@Test
- public void testLogStringParamSupplier() {
+ void testLogStringParamSupplier() {
logger2.disable().log(Level.WARN, "abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
@@ -1396,7 +1396,7 @@ public void testLogStringParamSupplier() {
}
@Test
- public void testLogMarkerStringParamSupplier() {
+ void testLogMarkerStringParamSupplier() {
logger2.disable().log(Level.WARN, marker, "abc {}", supplierArray1);
assertTrue(logger2.list.isEmpty());
assertFalse(supplier.invoked);
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/LevelTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/LevelTest.java
index 690d7c74371..30f9e4073d5 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/LevelTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/LevelTest.java
@@ -25,17 +25,17 @@
import org.junit.jupiter.api.Test;
-public class LevelTest {
+class LevelTest {
@Test
- public void testDefault() {
+ void testDefault() {
final Level level = Level.toLevel("Information", Level.ERROR);
assertNotNull(level);
assertEquals(Level.ERROR, level);
}
@Test
- public void testForNameEquals() {
+ void testForNameEquals() {
final String name = "Foo";
final int intValue = 1;
final Level level = Level.forName(name, intValue);
@@ -47,7 +47,7 @@ public void testForNameEquals() {
}
@Test
- public void testThrowsOnNull() {
+ void testThrowsOnNull() {
assertThrowsExactly(IllegalArgumentException.class, () -> Level.forName(null, 100));
assertThrowsExactly(IllegalArgumentException.class, () -> Level.getLevel(null));
// the intLevel should be checked only if we create a new level
@@ -56,14 +56,14 @@ public void testThrowsOnNull() {
}
@Test
- public void testGoodLevels() {
+ void testGoodLevels() {
final Level level = Level.toLevel("INFO");
assertNotNull(level);
assertEquals(Level.INFO, level);
}
@Test
- public void testIsInRangeErrorToDebug() {
+ void testIsInRangeErrorToDebug() {
assertFalse(Level.OFF.isInRange(Level.ERROR, Level.DEBUG));
assertFalse(Level.FATAL.isInRange(Level.ERROR, Level.DEBUG));
assertTrue(Level.ERROR.isInRange(Level.ERROR, Level.DEBUG));
@@ -75,7 +75,7 @@ public void testIsInRangeErrorToDebug() {
}
@Test
- public void testIsInRangeFatalToTrace() {
+ void testIsInRangeFatalToTrace() {
assertFalse(Level.OFF.isInRange(Level.FATAL, Level.TRACE));
assertTrue(Level.FATAL.isInRange(Level.FATAL, Level.TRACE));
assertTrue(Level.ERROR.isInRange(Level.FATAL, Level.TRACE));
@@ -87,7 +87,7 @@ public void testIsInRangeFatalToTrace() {
}
@Test
- public void testIsInRangeOffToAll() {
+ void testIsInRangeOffToAll() {
assertTrue(Level.OFF.isInRange(Level.OFF, Level.ALL));
assertTrue(Level.FATAL.isInRange(Level.OFF, Level.ALL));
assertTrue(Level.ERROR.isInRange(Level.OFF, Level.ALL));
@@ -99,7 +99,7 @@ public void testIsInRangeOffToAll() {
}
@Test
- public void testIsInRangeSameLevels() {
+ void testIsInRangeSameLevels() {
// Level.OFF
assertTrue(Level.OFF.isInRange(Level.OFF, Level.OFF));
assertFalse(Level.OFF.isInRange(Level.FATAL, Level.FATAL));
@@ -175,7 +175,7 @@ public void testIsInRangeSameLevels() {
}
@Test
- public void testIsInRangeWarnToInfo() {
+ void testIsInRangeWarnToInfo() {
assertFalse(Level.OFF.isInRange(Level.WARN, Level.INFO));
assertFalse(Level.FATAL.isInRange(Level.WARN, Level.INFO));
assertFalse(Level.ERROR.isInRange(Level.WARN, Level.INFO));
@@ -187,7 +187,7 @@ public void testIsInRangeWarnToInfo() {
}
@Test
- public void testIsLessSpecificThan() {
+ void testIsLessSpecificThan() {
// Level.OFF
assertTrue(Level.OFF.isLessSpecificThan(Level.OFF));
assertFalse(Level.OFF.isLessSpecificThan(Level.FATAL));
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/LogManagerTest.java
index 5b3bd70d8b8..6d54a96c52a 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/LogManagerTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/LogManagerTest.java
@@ -28,7 +28,7 @@
import org.junit.jupiter.api.parallel.ResourceLock;
@ResourceLock(value = "log4j2.LoggerContextFactory", mode = ResourceAccessMode.READ)
-public class LogManagerTest {
+class LogManagerTest {
@SuppressWarnings("InnerClassMayBeStatic")
class Inner {
@@ -49,7 +49,7 @@ static class StaticInnerByClass {
}
@Test
- public void testGetLogger() {
+ void testGetLogger() {
Logger logger = LogManager.getLogger();
assertNotNull(logger, "No Logger returned");
assertEquals(LogManagerTest.class.getName(), logger.getName(), "Incorrect Logger name: " + logger.getName());
@@ -77,13 +77,13 @@ public void testGetLogger() {
}
@Test
- public void testGetLoggerForAnonymousInnerClass1() throws IOException {
+ void testGetLoggerForAnonymousInnerClass1() throws IOException {
final Closeable closeable = new Closeable() {
final Logger LOGGER = LogManager.getLogger();
@Override
- public void close() throws IOException {
+ public void close() {
assertEquals("org.apache.logging.log4j.LogManagerTest$1", LOGGER.getName());
}
};
@@ -91,13 +91,13 @@ public void close() throws IOException {
}
@Test
- public void testGetLoggerForAnonymousInnerClass2() throws IOException {
+ void testGetLoggerForAnonymousInnerClass2() throws IOException {
final Closeable closeable = new Closeable() {
final Logger LOGGER = LogManager.getLogger(getClass());
@Override
- public void close() throws IOException {
+ public void close() {
assertEquals("org.apache.logging.log4j.LogManagerTest$2", LOGGER.getName());
}
};
@@ -105,27 +105,27 @@ public void close() throws IOException {
}
@Test
- public void testGetLoggerForInner() {
+ void testGetLoggerForInner() {
assertEquals("org.apache.logging.log4j.LogManagerTest.Inner", new Inner().LOGGER.getName());
}
@Test
- public void testGetLoggerForInnerByClass() {
+ void testGetLoggerForInnerByClass() {
assertEquals("org.apache.logging.log4j.LogManagerTest.InnerByClass", new InnerByClass().LOGGER.getName());
}
@Test
- public void testGetLoggerForStaticInner() {
+ void testGetLoggerForStaticInner() {
assertEquals("org.apache.logging.log4j.LogManagerTest.StaticInner", StaticInner.LOGGER.getName());
}
@Test
- public void testGetLoggerForStaticInnerByClass() {
+ void testGetLoggerForStaticInnerByClass() {
assertEquals("org.apache.logging.log4j.LogManagerTest.StaticInnerByClass", StaticInnerByClass.LOGGER.getName());
}
@Test
- public void testShutdown() {
+ void testShutdown() {
final LoggerContext loggerContext = LogManager.getContext(false);
}
}
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerSupplierTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerSupplierTest.java
index d458c27cbee..761425eabb2 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerSupplierTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerSupplierTest.java
@@ -44,7 +44,7 @@
*/
@ResourceLock(Resources.LOCALE)
@ResourceLock("log4j2.TestLogger")
-public class LoggerSupplierTest {
+class LoggerSupplierTest {
private final TestLogger logger = (TestLogger) LogManager.getLogger("LoggerTest");
@@ -53,7 +53,7 @@ public class LoggerSupplierTest {
Locale defaultLocale;
@Test
- public void flowTracing_SupplierOfFormattedMessage() {
+ void flowTracing_SupplierOfFormattedMessage() {
logger.traceEntry(() -> new FormattedMessage("int foo={}", 1234567890));
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -64,7 +64,7 @@ public void flowTracing_SupplierOfFormattedMessage() {
}
@Test
- public void flowTracing_SupplierOfJsonMessage() {
+ void flowTracing_SupplierOfJsonMessage() {
final Properties props = new Properties();
props.setProperty("foo", "bar");
logger.traceEntry(() -> new JsonMessage(props));
@@ -77,7 +77,7 @@ public void flowTracing_SupplierOfJsonMessage() {
}
@Test
- public void flowTracing_SupplierOfLocalizedMessage() {
+ void flowTracing_SupplierOfLocalizedMessage() {
logger.traceEntry(() -> new LocalizedMessage("int foo={}", 1234567890));
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -88,7 +88,7 @@ public void flowTracing_SupplierOfLocalizedMessage() {
}
@Test
- public void flowTracing_SupplierOfLong() {
+ void flowTracing_SupplierOfLong() {
logger.traceEntry(() -> 1234567890L);
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -99,7 +99,7 @@ public void flowTracing_SupplierOfLong() {
}
@Test
- public void flowTracing_SupplierOfMessageFormatMessage() {
+ void flowTracing_SupplierOfMessageFormatMessage() {
logger.traceEntry(() -> new MessageFormatMessage("int foo={0}", 1234567890));
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -110,7 +110,7 @@ public void flowTracing_SupplierOfMessageFormatMessage() {
}
@Test
- public void flowTracing_SupplierOfObjectArrayMessage() {
+ void flowTracing_SupplierOfObjectArrayMessage() {
logger.traceEntry(() -> new ObjectArrayMessage(1234567890));
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -121,7 +121,7 @@ public void flowTracing_SupplierOfObjectArrayMessage() {
}
@Test
- public void flowTracing_SupplierOfObjectMessage() {
+ void flowTracing_SupplierOfObjectMessage() {
logger.traceEntry(() -> new ObjectMessage(1234567890));
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -132,7 +132,7 @@ public void flowTracing_SupplierOfObjectMessage() {
}
@Test
- public void flowTracing_SupplierOfParameterizedMessage() {
+ void flowTracing_SupplierOfParameterizedMessage() {
logger.traceEntry(() -> new ParameterizedMessage("int foo={}", 1234567890));
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -143,7 +143,7 @@ public void flowTracing_SupplierOfParameterizedMessage() {
}
@Test
- public void flowTracing_SupplierOfSimpleMessage() {
+ void flowTracing_SupplierOfSimpleMessage() {
logger.traceEntry(() -> new SimpleMessage("1234567890"));
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -154,7 +154,7 @@ public void flowTracing_SupplierOfSimpleMessage() {
}
@Test
- public void flowTracing_SupplierOfString() {
+ void flowTracing_SupplierOfString() {
logger.traceEntry(() -> "1234567890");
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -165,7 +165,7 @@ public void flowTracing_SupplierOfString() {
}
@Test
- public void flowTracing_SupplierOfStringFormattedMessage() {
+ void flowTracing_SupplierOfStringFormattedMessage() {
logger.traceEntry(() -> new StringFormattedMessage("int foo=%,d", 1234567890));
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -176,7 +176,7 @@ public void flowTracing_SupplierOfStringFormattedMessage() {
}
@Test
- public void flowTracing_SupplierOfThreadDumpMessage() {
+ void flowTracing_SupplierOfThreadDumpMessage() {
logger.traceEntry(() -> new ThreadDumpMessage("Title of ..."));
assertThat(results).hasSize(1);
final String entry = results.get(0);
@@ -186,14 +186,14 @@ public void flowTracing_SupplierOfThreadDumpMessage() {
}
@BeforeEach
- public void setup() {
+ void setup() {
results.clear();
defaultLocale = Locale.getDefault(Locale.Category.FORMAT);
Locale.setDefault(Locale.Category.FORMAT, java.util.Locale.US);
}
@AfterEach
- public void tearDown() {
+ void tearDown() {
Locale.setDefault(Locale.Category.FORMAT, defaultLocale);
}
}
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerTest.java
index 9c276044684..ac00b97be9a 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerTest.java
@@ -53,7 +53,7 @@
@ResourceLock(value = Log4jStaticResources.MARKER_MANAGER, mode = ResourceAccessMode.READ)
@ReadsSystemProperty
-public class LoggerTest {
+class LoggerTest {
private static class TestParameterizedMessageFactory {
// empty
@@ -68,7 +68,7 @@ private static class TestStringFormatterMessageFactory {
private final List results = logger.getEntries();
@Test
- public void builder() {
+ void builder() {
logger.atDebug().withLocation().log("Hello");
logger.atError().withMarker(marker).log("Hello {}", "John");
logger.atWarn().withThrowable(new Throwable("This is a test")).log((Message) new SimpleMessage("Log4j rocks!"));
@@ -89,7 +89,7 @@ public void builder() {
}
@Test
- public void basicFlow() {
+ void basicFlow() {
logger.entry();
logger.exit();
assertEquals(2, results.size());
@@ -98,7 +98,7 @@ public void basicFlow() {
}
@Test
- public void flowTracingMessage() {
+ void flowTracingMessage() {
final Properties props = new Properties();
props.setProperty("foo", "bar");
logger.traceEntry(new JsonMessage(props));
@@ -110,7 +110,7 @@ public void flowTracingMessage() {
}
@Test
- public void flowTracingString_ObjectArray1() {
+ void flowTracingString_ObjectArray1() {
logger.traceEntry("doFoo(a={}, b={})", 1, 2);
logger.traceExit("doFoo(a=1, b=2): {}", 3);
assertThat(results).hasSize(2);
@@ -119,7 +119,7 @@ public void flowTracingString_ObjectArray1() {
}
@Test
- public void flowTracingExitValueOnly() {
+ void flowTracingExitValueOnly() {
logger.traceEntry("doFoo(a={}, b={})", 1, 2);
logger.traceExit(3);
assertThat(results).hasSize(2);
@@ -128,7 +128,7 @@ public void flowTracingExitValueOnly() {
}
@Test
- public void flowTracingString_ObjectArray2() {
+ void flowTracingString_ObjectArray2() {
final EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", 1, 2);
logger.traceExit(msg, 3);
assertThat(results).hasSize(2);
@@ -137,7 +137,7 @@ public void flowTracingString_ObjectArray2() {
}
@Test
- public void flowTracingVoidReturn() {
+ void flowTracingVoidReturn() {
final EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", 1, 2);
logger.traceExit(msg);
assertThat(results).hasSize(2);
@@ -146,7 +146,7 @@ public void flowTracingVoidReturn() {
}
@Test
- public void flowTracingNoExitArgs() {
+ void flowTracingNoExitArgs() {
logger.traceEntry();
logger.traceExit();
assertThat(results).hasSize(2);
@@ -155,7 +155,7 @@ public void flowTracingNoExitArgs() {
}
@Test
- public void flowTracingNoArgs() {
+ void flowTracingNoArgs() {
final EntryMessage message = logger.traceEntry();
logger.traceExit(message);
assertThat(results).hasSize(2);
@@ -164,7 +164,7 @@ public void flowTracingNoArgs() {
}
@Test
- public void flowTracingString_SupplierOfObjectMessages() {
+ void flowTracingString_SupplierOfObjectMessages() {
final EntryMessage msg = logger.traceEntry(
"doFoo(a={}, b={})", (Supplier) () -> new ObjectMessage(1), (Supplier)
() -> new ObjectMessage(2));
@@ -175,7 +175,7 @@ public void flowTracingString_SupplierOfObjectMessages() {
}
@Test
- public void flowTracingString_SupplierOfStrings() {
+ void flowTracingString_SupplierOfStrings() {
final EntryMessage msg =
logger.traceEntry("doFoo(a={}, b={})", (Supplier) () -> "1", (Supplier) () -> "2");
logger.traceExit(msg, 3);
@@ -185,7 +185,7 @@ public void flowTracingString_SupplierOfStrings() {
}
@Test
- public void flowTracingNoFormat() {
+ void flowTracingNoFormat() {
logger.traceEntry(null, 1, "2", new ObjectMessage(3));
logger.traceExit((String) null, 4);
assertThat(results).hasSize(2);
@@ -194,7 +194,7 @@ public void flowTracingNoFormat() {
}
@Test
- public void catching() {
+ void catching() {
try {
throw new NullPointerException();
} catch (final Exception e) {
@@ -208,28 +208,28 @@ public void catching() {
}
@Test
- public void debug() {
+ void debug() {
logger.debug("Debug message");
assertEquals(1, results.size());
assertTrue(results.get(0).startsWith(" DEBUG Debug message"), "Incorrect message");
}
@Test
- public void debugObject() {
+ void debugObject() {
logger.debug(new Date());
assertEquals(1, results.size());
assertTrue(results.get(0).length() > 7, "Invalid length");
}
@Test
- public void debugWithParms() {
+ void debugWithParms() {
logger.debug("Hello, {}", "World");
assertEquals(1, results.size());
assertTrue(results.get(0).startsWith(" DEBUG Hello, World"), "Incorrect substitution");
}
@Test
- public void debugWithParmsAndThrowable() {
+ void debugWithParmsAndThrowable() {
logger.debug("Hello, {}", "World", new RuntimeException("Test Exception"));
assertEquals(1, results.size());
assertTrue(
@@ -239,7 +239,7 @@ public void debugWithParmsAndThrowable() {
@Test
@ResourceLock(value = org.junit.jupiter.api.parallel.Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void getFormatterLogger() {
+ void getFormatterLogger() {
// The TestLogger logger was already created in an instance variable for this class.
// The message factory is only used when the logger is created.
final TestLogger testLogger = (TestLogger) LogManager.getFormatterLogger();
@@ -257,7 +257,7 @@ public void getFormatterLogger() {
@Test
@ResourceLock(value = org.junit.jupiter.api.parallel.Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void getFormatterLogger_Class() {
+ void getFormatterLogger_Class() {
// The TestLogger logger was already created in an instance variable for this class.
// The message factory is only used when the logger is created.
final TestLogger testLogger =
@@ -281,7 +281,7 @@ private static void assertMessageFactoryInstanceOf(MessageFactory factory, final
@Test
@ResourceLock(value = org.junit.jupiter.api.parallel.Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void getFormatterLogger_Object() {
+ void getFormatterLogger_Object() {
// The TestLogger logger was already created in an instance variable for this class.
// The message factory is only used when the logger is created.
final TestLogger testLogger =
@@ -298,7 +298,7 @@ public void getFormatterLogger_Object() {
@Test
@ResourceLock(value = org.junit.jupiter.api.parallel.Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void getFormatterLogger_String() {
+ void getFormatterLogger_String() {
final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
final TestLogger testLogger =
(TestLogger) LogManager.getFormatterLogger("getLogger_String_StringFormatterMessageFactory");
@@ -313,7 +313,7 @@ public void getFormatterLogger_String() {
}
@Test
- public void getLogger_Class_ParameterizedMessageFactory() {
+ void getLogger_Class_ParameterizedMessageFactory() {
// The TestLogger logger was already created in an instance variable for this class.
// The message factory is only used when the logger is created.
final ParameterizedMessageFactory messageFactory = ParameterizedMessageFactory.INSTANCE;
@@ -327,7 +327,7 @@ public void getLogger_Class_ParameterizedMessageFactory() {
}
@Test
- public void getLogger_Class_StringFormatterMessageFactory() {
+ void getLogger_Class_StringFormatterMessageFactory() {
// The TestLogger logger was already created in an instance variable for this class.
// The message factory is only used when the logger is created.
final TestLogger testLogger = (TestLogger)
@@ -342,7 +342,7 @@ public void getLogger_Class_StringFormatterMessageFactory() {
}
@Test
- public void getLogger_Object_ParameterizedMessageFactory() {
+ void getLogger_Object_ParameterizedMessageFactory() {
// The TestLogger logger was already created in an instance variable for this class.
// The message factory is only used when the logger is created.
final ParameterizedMessageFactory messageFactory = ParameterizedMessageFactory.INSTANCE;
@@ -364,7 +364,7 @@ private void assertEqualMessageFactory(final MessageFactory messageFactory, fina
}
@Test
- public void getLogger_Object_StringFormatterMessageFactory() {
+ void getLogger_Object_StringFormatterMessageFactory() {
// The TestLogger logger was already created in an instance variable for this class.
// The message factory is only used when the logger is created.
final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
@@ -380,7 +380,7 @@ public void getLogger_Object_StringFormatterMessageFactory() {
}
@Test
- public void getLogger_String_MessageFactoryMismatch() {
+ void getLogger_String_MessageFactoryMismatch() {
final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
final TestLogger testLogger =
(TestLogger) LogManager.getLogger("getLogger_String_MessageFactoryMismatch", messageFactory);
@@ -400,7 +400,7 @@ public void getLogger_String_MessageFactoryMismatch() {
}
@Test
- public void getLogger_String_ParameterizedMessageFactory() {
+ void getLogger_String_ParameterizedMessageFactory() {
final ParameterizedMessageFactory messageFactory = ParameterizedMessageFactory.INSTANCE;
final TestLogger testLogger =
(TestLogger) LogManager.getLogger("getLogger_String_ParameterizedMessageFactory", messageFactory);
@@ -412,7 +412,7 @@ public void getLogger_String_ParameterizedMessageFactory() {
}
@Test
- public void getLogger_String_SimpleMessageFactory() {
+ void getLogger_String_SimpleMessageFactory() {
final SimpleMessageFactory messageFactory = SimpleMessageFactory.INSTANCE;
final TestLogger testLogger =
(TestLogger) LogManager.getLogger("getLogger_String_StringFormatterMessageFactory", messageFactory);
@@ -424,7 +424,7 @@ public void getLogger_String_SimpleMessageFactory() {
}
@Test
- public void getLogger_String_StringFormatterMessageFactory() {
+ void getLogger_String_StringFormatterMessageFactory() {
final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
final TestLogger testLogger =
(TestLogger) LogManager.getLogger("getLogger_String_StringFormatterMessageFactory", messageFactory);
@@ -438,38 +438,38 @@ public void getLogger_String_StringFormatterMessageFactory() {
}
@Test
- public void getLoggerByClass() {
+ void getLoggerByClass() {
final Logger classLogger = LogManager.getLogger(LoggerTest.class);
assertNotNull(classLogger);
}
@Test
- public void getLoggerByNullClass() {
+ void getLoggerByNullClass() {
// Returns a SimpleLogger
assertNotNull(LogManager.getLogger((Class>) null));
}
@Test
- public void getLoggerByNullObject() {
+ void getLoggerByNullObject() {
// Returns a SimpleLogger
assertNotNull(LogManager.getLogger((Object) null));
}
@Test
- public void getLoggerByNullString() {
+ void getLoggerByNullString() {
// Returns a SimpleLogger
assertNotNull(LogManager.getLogger((String) null));
}
@Test
- public void getLoggerByObject() {
+ void getLoggerByObject() {
final Logger classLogger = LogManager.getLogger(this);
assertNotNull(classLogger);
assertEquals(classLogger, LogManager.getLogger(LoggerTest.class));
}
@Test
- public void getRootLogger() {
+ void getRootLogger() {
assertNotNull(LogManager.getRootLogger());
assertNotNull(LogManager.getLogger(Strings.EMPTY));
assertNotNull(LogManager.getLogger(LogManager.ROOT_LOGGER_NAME));
@@ -478,100 +478,100 @@ public void getRootLogger() {
}
@Test
- public void isAllEnabled() {
+ void isAllEnabled() {
assertTrue(logger.isEnabled(Level.ALL), "Incorrect level");
}
@Test
- public void isDebugEnabled() {
+ void isDebugEnabled() {
assertTrue(logger.isDebugEnabled(), "Incorrect level");
assertTrue(logger.isEnabled(Level.DEBUG), "Incorrect level");
}
@Test
- public void isErrorEnabled() {
+ void isErrorEnabled() {
assertTrue(logger.isErrorEnabled(), "Incorrect level");
assertTrue(logger.isEnabled(Level.ERROR), "Incorrect level");
}
@Test
- public void isFatalEnabled() {
+ void isFatalEnabled() {
assertTrue(logger.isFatalEnabled(), "Incorrect level");
assertTrue(logger.isEnabled(Level.FATAL), "Incorrect level");
}
@Test
- public void isInfoEnabled() {
+ void isInfoEnabled() {
assertTrue(logger.isInfoEnabled(), "Incorrect level");
assertTrue(logger.isEnabled(Level.INFO), "Incorrect level");
}
@Test
- public void isOffEnabled() {
+ void isOffEnabled() {
assertTrue(logger.isEnabled(Level.OFF), "Incorrect level");
}
@Test
- public void isTraceEnabled() {
+ void isTraceEnabled() {
assertTrue(logger.isTraceEnabled(), "Incorrect level");
assertTrue(logger.isEnabled(Level.TRACE), "Incorrect level");
}
@Test
- public void isWarnEnabled() {
+ void isWarnEnabled() {
assertTrue(logger.isWarnEnabled(), "Incorrect level");
assertTrue(logger.isEnabled(Level.WARN), "Incorrect level");
}
@Test
- public void isAllEnabledWithMarker() {
+ void isAllEnabledWithMarker() {
assertTrue(logger.isEnabled(Level.ALL, marker), "Incorrect level");
}
@Test
- public void isDebugEnabledWithMarker() {
+ void isDebugEnabledWithMarker() {
assertTrue(logger.isDebugEnabled(marker), "Incorrect level");
assertTrue(logger.isEnabled(Level.DEBUG, marker), "Incorrect level");
}
@Test
- public void isErrorEnabledWithMarker() {
+ void isErrorEnabledWithMarker() {
assertTrue(logger.isErrorEnabled(marker), "Incorrect level");
assertTrue(logger.isEnabled(Level.ERROR, marker), "Incorrect level");
}
@Test
- public void isFatalEnabledWithMarker() {
+ void isFatalEnabledWithMarker() {
assertTrue(logger.isFatalEnabled(marker), "Incorrect level");
assertTrue(logger.isEnabled(Level.FATAL, marker), "Incorrect level");
}
@Test
- public void isInfoEnabledWithMarker() {
+ void isInfoEnabledWithMarker() {
assertTrue(logger.isInfoEnabled(marker), "Incorrect level");
assertTrue(logger.isEnabled(Level.INFO, marker), "Incorrect level");
}
@Test
- public void isOffEnabledWithMarker() {
+ void isOffEnabledWithMarker() {
assertTrue(logger.isEnabled(Level.OFF, marker), "Incorrect level");
}
@Test
- public void isTraceEnabledWithMarker() {
+ void isTraceEnabledWithMarker() {
assertTrue(logger.isTraceEnabled(marker), "Incorrect level");
assertTrue(logger.isEnabled(Level.TRACE, marker), "Incorrect level");
}
@Test
- public void isWarnEnabledWithMarker() {
+ void isWarnEnabledWithMarker() {
assertTrue(logger.isWarnEnabled(marker), "Incorrect level");
assertTrue(logger.isEnabled(Level.WARN, marker), "Incorrect level");
}
@Test
@UsingThreadContextMap
- public void mdc() {
+ void mdc() {
ThreadContext.put("TestYear", Integer.toString(2010));
logger.debug("Debug message");
final String testYear = ThreadContext.get("TestYear");
@@ -588,7 +588,7 @@ public void mdc() {
}
@Test
- public void printf() {
+ void printf() {
logger.printf(Level.DEBUG, "Debug message %d", 1);
logger.printf(Level.DEBUG, MarkerManager.getMarker("Test"), "Debug message %d", 2);
assertEquals(2, results.size());
@@ -597,12 +597,12 @@ public void printf() {
}
@BeforeEach
- public void setup() {
+ void setup() {
results.clear();
}
@Test
- public void structuredData() {
+ void structuredData() {
ThreadContext.put("loginId", "JohnDoe");
ThreadContext.put("ipAddress", "192.168.0.120");
ThreadContext.put("locale", Locale.US.getDisplayName());
@@ -621,7 +621,7 @@ public void structuredData() {
}
@Test
- public void throwing() {
+ void throwing() {
logger.throwing(new IllegalArgumentException("Test Exception"));
assertEquals(1, results.size());
assertThat(
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/MarkerTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/MarkerTest.java
index 901f55a0136..411dd5766cd 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/MarkerTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/MarkerTest.java
@@ -28,21 +28,21 @@
import org.junit.jupiter.api.parallel.ResourceLock;
@ResourceLock(value = Log4jStaticResources.MARKER_MANAGER, mode = ResourceAccessMode.READ_WRITE)
-public class MarkerTest {
+class MarkerTest {
@BeforeEach
- public void setUp() {
+ void setUp() {
MarkerManager.clear();
}
@Test
- public void testGetMarker() {
+ void testGetMarker() {
final Marker expected = MarkerManager.getMarker("A");
assertNull(expected.getParents());
}
@Test
- public void testGetMarkerWithParents() {
+ void testGetMarkerWithParents() {
final Marker expected = MarkerManager.getMarker("A");
final Marker p1 = MarkerManager.getMarker("P1");
p1.addParents(MarkerManager.getMarker("PP1"));
@@ -53,7 +53,7 @@ public void testGetMarkerWithParents() {
}
@Test
- public void testHasParents() {
+ void testHasParents() {
final Marker parent = MarkerManager.getMarker("PARENT");
final Marker existing = MarkerManager.getMarker("EXISTING");
assertFalse(existing.hasParents());
@@ -62,7 +62,7 @@ public void testHasParents() {
}
@Test
- public void testMarker() {
+ void testMarker() {
// root (level 1)
final Marker parent = MarkerManager.getMarker("PARENT");
// level 2
@@ -83,7 +83,7 @@ public void testMarker() {
}
@Test
- public void testMarkerSharedIntermediaryMarker() {
+ void testMarkerSharedIntermediaryMarker() {
final Marker parent1 = MarkerManager.getMarker("PARENT1");
final Marker parent2 = MarkerManager.getMarker("PARENT2");
final Marker test1 = MarkerManager.getMarker("TEST1").setParents(parent1, parent2);
@@ -96,7 +96,7 @@ public void testMarkerSharedIntermediaryMarker() {
}
@Test
- public void testMultipleParents() {
+ void testMultipleParents() {
final Marker parent1 = MarkerManager.getMarker("PARENT1");
final Marker parent2 = MarkerManager.getMarker("PARENT2");
final Marker test1 = MarkerManager.getMarker("TEST1").setParents(parent1, parent2);
@@ -112,7 +112,7 @@ public void testMultipleParents() {
}
@Test
- public void testAddToExistingParents() {
+ void testAddToExistingParents() {
final Marker parent = MarkerManager.getMarker("PARENT");
final Marker existing = MarkerManager.getMarker("EXISTING");
final Marker test1 = MarkerManager.getMarker("TEST1").setParents(existing);
@@ -124,7 +124,7 @@ public void testAddToExistingParents() {
}
@Test
- public void testDuplicateParents() {
+ void testDuplicateParents() {
final Marker parent = MarkerManager.getMarker("PARENT");
final Marker existing = MarkerManager.getMarker("EXISTING");
final Marker test1 = MarkerManager.getMarker("TEST1").setParents(existing);
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/NoopThreadContextTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/NoopThreadContextTest.java
index d4ce703b56d..c4d9bebd81c 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/NoopThreadContextTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/NoopThreadContextTest.java
@@ -28,10 +28,10 @@
@SetTestProperty(key = "log4j2.disableThreadContext", value = "true")
@SetTestProperty(key = "log4j2.disableThreadContextMap", value = "true")
@UsingThreadContextMap
-public class NoopThreadContextTest {
+class NoopThreadContextTest {
@Test
- public void testNoop() {
+ void testNoop() {
ThreadContext.put("Test", "Test");
final String value = ThreadContext.get("Test");
assertNull(value, "value was saved");
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/ThreadContextInheritanceTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/ThreadContextInheritanceTest.java
index c800b396a61..8e398910d14 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/ThreadContextInheritanceTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/ThreadContextInheritanceTest.java
@@ -37,72 +37,72 @@
@SetTestProperty(key = DefaultThreadContextMap.INHERITABLE_MAP, value = "true")
@UsingThreadContextMap
@UsingThreadContextStack
-public class ThreadContextInheritanceTest {
+class ThreadContextInheritanceTest {
@BeforeAll
- public static void setupClass() {
+ static void setupClass() {
System.setProperty(DefaultThreadContextMap.INHERITABLE_MAP, "true");
ThreadContext.init();
}
@AfterAll
- public static void tearDownClass() {
+ static void tearDownClass() {
System.clearProperty(DefaultThreadContextMap.INHERITABLE_MAP);
ThreadContext.init();
}
@Test
- public void testPush() {
+ void testPush() {
ThreadContext.push("Hello");
ThreadContext.push("{} is {}", ThreadContextInheritanceTest.class.getSimpleName(), "running");
assertEquals(
- ThreadContext.pop(), "ThreadContextInheritanceTest is running", "Incorrect parameterized stack value");
- assertEquals(ThreadContext.pop(), "Hello", "Incorrect simple stack value");
+ "ThreadContextInheritanceTest is running", ThreadContext.pop(), "Incorrect parameterized stack value");
+ assertEquals("Hello", ThreadContext.pop(), "Incorrect simple stack value");
}
@Test
@Tag("performance")
- public void perfTest() {
+ void perfTest() {
ThreadContextUtilityClass.perfTest();
}
@Test
- public void testGetContextReturnsEmptyMapIfEmpty() {
+ void testGetContextReturnsEmptyMapIfEmpty() {
ThreadContextUtilityClass.testGetContextReturnsEmptyMapIfEmpty();
}
@Test
- public void testGetContextReturnsMutableCopy() {
+ void testGetContextReturnsMutableCopy() {
ThreadContextUtilityClass.testGetContextReturnsMutableCopy();
}
@Test
- public void testGetImmutableContextReturnsEmptyMapIfEmpty() {
+ void testGetImmutableContextReturnsEmptyMapIfEmpty() {
ThreadContextUtilityClass.testGetImmutableContextReturnsEmptyMapIfEmpty();
}
@Test
- public void testGetImmutableContextReturnsImmutableMapIfNonEmpty() {
+ void testGetImmutableContextReturnsImmutableMapIfNonEmpty() {
ThreadContextUtilityClass.testGetImmutableContextReturnsImmutableMapIfNonEmpty();
}
@Test
- public void testGetImmutableContextReturnsImmutableMapIfEmpty() {
+ void testGetImmutableContextReturnsImmutableMapIfEmpty() {
ThreadContextUtilityClass.testGetImmutableContextReturnsImmutableMapIfEmpty();
}
@Test
- public void testGetImmutableStackReturnsEmptyStackIfEmpty() {
+ void testGetImmutableStackReturnsEmptyStackIfEmpty() {
ThreadContextUtilityClass.testGetImmutableStackReturnsEmptyStackIfEmpty();
}
@Test
- public void testPut() {
+ void testPut() {
ThreadContextUtilityClass.testPut();
}
@Test
- public void testRemove() {
+ void testRemove() {
ThreadContext.clearMap();
assertNull(ThreadContext.get("testKey"));
ThreadContext.put("testKey", "testValue");
@@ -114,7 +114,7 @@ public void testRemove() {
}
@Test
- public void testContainsKey() {
+ void testContainsKey() {
ThreadContext.clearMap();
assertFalse(ThreadContext.containsKey("testKey"));
ThreadContext.put("testKey", "testValue");
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/ThreadContextTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/ThreadContextTest.java
index e84958bcf05..a06fd7c2611 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/ThreadContextTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/ThreadContextTest.java
@@ -30,18 +30,18 @@
import org.junit.jupiter.api.Test;
@UsingAnyThreadContext
-public class ThreadContextTest {
+class ThreadContextTest {
@Test
- public void testPush() {
+ void testPush() {
ThreadContext.push("Hello");
ThreadContext.push("{} is {}", ThreadContextTest.class.getSimpleName(), "running");
- assertEquals(ThreadContext.pop(), "ThreadContextTest is running", "Incorrect parameterized stack value");
- assertEquals(ThreadContext.pop(), "Hello", "Incorrect simple stack value");
+ assertEquals("ThreadContextTest is running", ThreadContext.pop(), "Incorrect parameterized stack value");
+ assertEquals("Hello", ThreadContext.pop(), "Incorrect simple stack value");
}
@Test
- public void testInheritanceSwitchedOffByDefault() throws Exception {
+ void testInheritanceSwitchedOffByDefault() throws Exception {
ThreadContext.put("Greeting", "Hello");
StringBuilder sb = new StringBuilder();
TestThread thread = new TestThread(sb);
@@ -59,47 +59,47 @@ public void testInheritanceSwitchedOffByDefault() throws Exception {
@Test
@Tag("performance")
- public void perfTest() {
+ void perfTest() {
ThreadContextUtilityClass.perfTest();
}
@Test
- public void testGetContextReturnsEmptyMapIfEmpty() {
+ void testGetContextReturnsEmptyMapIfEmpty() {
ThreadContextUtilityClass.testGetContextReturnsEmptyMapIfEmpty();
}
@Test
- public void testGetContextReturnsMutableCopy() {
+ void testGetContextReturnsMutableCopy() {
ThreadContextUtilityClass.testGetContextReturnsMutableCopy();
}
@Test
- public void testGetImmutableContextReturnsEmptyMapIfEmpty() {
+ void testGetImmutableContextReturnsEmptyMapIfEmpty() {
ThreadContextUtilityClass.testGetImmutableContextReturnsEmptyMapIfEmpty();
}
@Test
- public void testGetImmutableContextReturnsImmutableMapIfNonEmpty() {
+ void testGetImmutableContextReturnsImmutableMapIfNonEmpty() {
ThreadContextUtilityClass.testGetImmutableContextReturnsImmutableMapIfNonEmpty();
}
@Test
- public void testGetImmutableContextReturnsImmutableMapIfEmpty() {
+ void testGetImmutableContextReturnsImmutableMapIfEmpty() {
ThreadContextUtilityClass.testGetImmutableContextReturnsImmutableMapIfEmpty();
}
@Test
- public void testGetImmutableStackReturnsEmptyStackIfEmpty() {
+ void testGetImmutableStackReturnsEmptyStackIfEmpty() {
ThreadContextUtilityClass.testGetImmutableStackReturnsEmptyStackIfEmpty();
}
@Test
- public void testPut() {
+ void testPut() {
ThreadContextUtilityClass.testPut();
}
@Test
- public void testPutIfNotNull() {
+ void testPutIfNotNull() {
ThreadContext.clearMap();
assertNull(ThreadContext.get("testKey"));
ThreadContext.put("testKey", "testValue");
@@ -111,7 +111,7 @@ public void testPutIfNotNull() {
}
@Test
- public void testPutAll() {
+ void testPutAll() {
assertTrue(ThreadContext.isEmpty());
assertFalse(ThreadContext.containsKey("key"));
final int mapSize = 10;
@@ -128,7 +128,7 @@ public void testPutAll() {
}
@Test
- public void testRemove() {
+ void testRemove() {
assertNull(ThreadContext.get("testKey"));
ThreadContext.put("testKey", "testValue");
assertEquals("testValue", ThreadContext.get("testKey"));
@@ -139,7 +139,7 @@ public void testRemove() {
}
@Test
- public void testRemoveAll() {
+ void testRemoveAll() {
ThreadContext.put("testKey1", "testValue1");
ThreadContext.put("testKey2", "testValue2");
assertEquals("testValue1", ThreadContext.get("testKey1"));
@@ -153,7 +153,7 @@ public void testRemoveAll() {
}
@Test
- public void testContainsKey() {
+ void testContainsKey() {
assertFalse(ThreadContext.containsKey("testKey"));
ThreadContext.put("testKey", "testValue");
assertTrue(ThreadContext.containsKey("testKey"));
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/TraceLoggingTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/TraceLoggingTest.java
index c8227698f33..dcc16803baa 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/TraceLoggingTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/TraceLoggingTest.java
@@ -32,7 +32,7 @@
import org.apache.logging.log4j.spi.AbstractLogger;
import org.junit.jupiter.api.Test;
-public class TraceLoggingTest extends AbstractLogger {
+class TraceLoggingTest extends AbstractLogger {
static final StringBuilder CHAR_SEQ = new StringBuilder("CharSeq");
private int charSeqCount;
private int objectCount;
@@ -323,7 +323,7 @@ public void logMessage(
}
@Test
- public void testTraceEntryExit() {
+ void testTraceEntryExit() {
currentLevel = Level.TRACE;
final FlowMessageFactory fact = new DefaultFlowMessageFactory();
@@ -348,7 +348,7 @@ public void testTraceEntryExit() {
}
@Test
- public void testTraceEntryMessage() {
+ void testTraceEntryMessage() {
currentLevel = Level.TRACE;
final FlowMessageFactory fact = new DefaultFlowMessageFactory();
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/DefaultLogBuilderTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/DefaultLogBuilderTest.java
index 3ed88257cb2..4bff93565cd 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/DefaultLogBuilderTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/DefaultLogBuilderTest.java
@@ -25,13 +25,13 @@
import org.apache.logging.log4j.test.TestLogger;
import org.junit.jupiter.api.Test;
-public class DefaultLogBuilderTest {
+class DefaultLogBuilderTest {
private final TestLogger logger1 = (TestLogger) LogManager.getLogger(DefaultLogBuilderTest.class);
private final TestLogger logger2 = (TestLogger) LogManager.getLogger("second.logger");
@Test
- public void testConcurrentUsage() {
+ void testConcurrentUsage() {
logger1.getEntries().clear();
logger2.getEntries().clear();
final List logBuilders =
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/map/UnmodifiableArrayBackedMapTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/map/UnmodifiableArrayBackedMapTest.java
index 092c082ed4e..612840bbf5e 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/map/UnmodifiableArrayBackedMapTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/map/UnmodifiableArrayBackedMapTest.java
@@ -20,6 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -37,7 +38,7 @@
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
-public class UnmodifiableArrayBackedMapTest {
+class UnmodifiableArrayBackedMapTest {
private static final int TEST_DATA_SIZE = 5;
private HashMap getTestParameters() {
@@ -54,25 +55,25 @@ private HashMap getTestParameters(int numParams) {
}
@Test
- public void testCopyAndPut() {
+ void testCopyAndPut() {
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP;
testMap = testMap.copyAndPut("6", "value6");
assertTrue(testMap.containsKey("6"));
- assertEquals(testMap.get("6"), "value6");
+ assertEquals("value6", testMap.get("6"));
testMap = testMap.copyAndPut("6", "another value");
assertTrue(testMap.containsKey("6"));
- assertEquals(testMap.get("6"), "another value");
+ assertEquals("another value", testMap.get("6"));
HashMap newValues = getTestParameters();
testMap = testMap.copyAndPutAll(newValues);
- assertEquals(testMap.get("1"), "value1");
- assertEquals(testMap.get("4"), "value4");
- assertEquals(testMap.get("6"), "another value");
+ assertEquals("value1", testMap.get("1"));
+ assertEquals("value4", testMap.get("4"));
+ assertEquals("another value", testMap.get("6"));
}
@Test
- public void testCopyAndRemove() {
+ void testCopyAndRemove() {
// general removing from well-populated set
HashMap params = getTestParameters();
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(params);
@@ -104,7 +105,7 @@ public void testCopyAndRemove() {
}
@Test
- public void testCopyAndRemoveAll() {
+ void testCopyAndRemoveAll() {
HashMap initialMapContents = getTestParameters(15);
initialMapContents.put("extra_key", "extra_value");
@@ -138,23 +139,23 @@ public void testCopyAndRemoveAll() {
assertEquals(testMapWithSetRemoval, testMapWithArrayListRemoval);
testMap = UnmodifiableArrayBackedMap.EMPTY_MAP;
- assertEquals(testMap.copyAndRemoveAll(initialMapContents.keySet()).size(), 0);
+ assertEquals(0, testMap.copyAndRemoveAll(initialMapContents.keySet()).size());
testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPut("test", "test");
- assertEquals(testMap.copyAndRemoveAll(initialMapContents.keySet()).size(), 1);
+ assertEquals(1, testMap.copyAndRemoveAll(initialMapContents.keySet()).size());
testMap = testMap.copyAndRemoveAll(Collections.singleton("not found"));
- assertEquals(testMap.copyAndRemoveAll(testMap.keySet()).size(), 0);
+ assertEquals(0, testMap.copyAndRemoveAll(testMap.keySet()).size());
testMap = testMap.copyAndRemoveAll(Collections.singleton("test"));
- assertEquals(testMap.copyAndRemoveAll(testMap.keySet()).size(), 0);
+ assertEquals(0, testMap.copyAndRemoveAll(testMap.keySet()).size());
}
@Test
- public void testEmptyMap() {
+ void testEmptyMap() {
assertNull(UnmodifiableArrayBackedMap.EMPTY_MAP.get("test"));
}
@Test
- public void testEntrySetIteratorAndSize() {
+ void testEntrySetIteratorAndSize() {
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters());
Set> entrySet = testMap.entrySet();
int numEntriesFound = 0;
@@ -167,7 +168,7 @@ public void testEntrySetIteratorAndSize() {
}
@Test
- public void testEntrySetMutatorsBlocked() {
+ void testEntrySetMutatorsBlocked() {
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters());
Set> entrySet = testMap.entrySet();
for (Map.Entry entry : entrySet) {
@@ -199,7 +200,7 @@ public void testEntrySetMutatorsBlocked() {
* as well as UnmodifiableArrayBackedMap.equals(HashMap).
*/
@Test
- public void testEqualsHashCodeWithIdenticalContent() {
+ void testEqualsHashCodeWithIdenticalContent() {
HashMap params = getTestParameters();
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(params);
assertEquals(params, testMap);
@@ -208,18 +209,18 @@ public void testEqualsHashCodeWithIdenticalContent() {
}
@Test
- public void testEqualsHashCodeWithOneEmptyMap() {
+ void testEqualsHashCodeWithOneEmptyMap() {
HashMap params = getTestParameters();
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(params);
// verify empty maps are not equal to non-empty maps
- assertNotEquals(params, UnmodifiableArrayBackedMap.EMPTY_MAP);
+ assertNotEquals(UnmodifiableArrayBackedMap.EMPTY_MAP, params);
assertNotEquals(new HashMap<>(), testMap);
assertNotEquals(UnmodifiableArrayBackedMap.EMPTY_MAP, params);
- assertNotEquals(testMap, new HashMap<>());
+ assertNotEquals(new HashMap<>(), testMap);
}
@Test
- public void testEqualsHashCodeWithOneKeyRemoved() {
+ void testEqualsHashCodeWithOneKeyRemoved() {
HashMap params = getTestParameters();
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(params);
@@ -233,7 +234,7 @@ public void testEqualsHashCodeWithOneKeyRemoved() {
}
@Test
- public void testEqualsWhenOneValueDiffers() {
+ void testEqualsWhenOneValueDiffers() {
HashMap params = getTestParameters();
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(params);
assertNotEquals(params, testMap.copyAndPut("1", "different value"));
@@ -241,7 +242,7 @@ public void testEqualsWhenOneValueDiffers() {
}
@Test
- public void testForEachBiConsumer_JavaUtil() {
+ void testForEachBiConsumer_JavaUtil() {
final Map map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters());
final Collection keys = new HashSet<>();
map.forEach((key, value) -> keys.add(key));
@@ -249,7 +250,7 @@ public void testForEachBiConsumer_JavaUtil() {
}
@Test
- public void testForEachBiConsumer_Log4jUtil() {
+ void testForEachBiConsumer_Log4jUtil() {
final ReadOnlyStringMap map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters());
final Collection keys = new HashSet<>();
map.forEach((key, value) -> keys.add(key));
@@ -257,7 +258,7 @@ public void testForEachBiConsumer_Log4jUtil() {
}
@Test
- public void testForEachTriConsumer() {
+ void testForEachTriConsumer() {
UnmodifiableArrayBackedMap map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters());
HashMap iterationResultMap = new HashMap<>();
TriConsumer> triConsumer =
@@ -272,7 +273,7 @@ public void accept(String k, String v, Map s) {
}
@Test
- public void testImmutability() {
+ void testImmutability() {
HashMap params = getTestParameters();
UnmodifiableArrayBackedMap originalMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(params);
UnmodifiableArrayBackedMap modifiedMap = originalMap.copyAndPutAll(getTestParameters());
@@ -285,7 +286,7 @@ public void testImmutability() {
}
@Test
- public void testInstanceCopy() {
+ void testInstanceCopy() {
HashMap params = getTestParameters();
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(params);
@@ -294,7 +295,7 @@ public void testInstanceCopy() {
}
@Test
- public void testMutatorsBlocked() {
+ void testMutatorsBlocked() {
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters());
try {
testMap.put("a", "a");
@@ -322,18 +323,18 @@ public void testMutatorsBlocked() {
}
@Test
- public void testNullValue() {
+ void testNullValue() {
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP;
testMap = testMap.copyAndPut("key", null);
assertTrue(testMap.containsKey("key"));
assertTrue(testMap.containsValue(null));
- assertTrue(testMap.size() == 1);
- assertEquals(testMap.get("key"), null);
+ assertEquals(1, testMap.size());
+ assertNull(testMap.get("key"));
}
@Test
- public void testReads() {
- assertEquals(UnmodifiableArrayBackedMap.EMPTY_MAP.get("test"), null);
+ void testReads() {
+ assertNull(UnmodifiableArrayBackedMap.EMPTY_MAP.get("test"));
HashMap params = getTestParameters();
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(params);
for (Map.Entry entry : params.entrySet()) {
@@ -345,11 +346,11 @@ public void testReads() {
}
assertFalse(testMap.containsKey("not_present"));
assertFalse(testMap.containsValue("not_present"));
- assertEquals(null, testMap.get("not_present"));
+ assertNull(testMap.get("not_present"));
}
@Test
- public void testState() {
+ void testState() {
UnmodifiableArrayBackedMap originalMap;
UnmodifiableArrayBackedMap newMap;
@@ -369,10 +370,10 @@ public void testState() {
}
@Test
- public void testToMap() {
+ void testToMap() {
UnmodifiableArrayBackedMap map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPut("test", "test");
// verify same instance, not just equals()
- assertTrue(map == map.toMap());
+ assertSame(map, map.toMap());
}
@Test
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/FormattedMessageTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/message/FormattedMessageTest.java
index 72518c97241..f2a35b2474a 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/FormattedMessageTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/message/FormattedMessageTest.java
@@ -33,7 +33,7 @@
import org.junit.jupiter.api.parallel.Resources;
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
-public class FormattedMessageTest {
+class FormattedMessageTest {
private static final String SPACE = Constants.JAVA_MAJOR_VERSION < 9 ? " " : "\u00a0";
@@ -41,7 +41,7 @@ public class FormattedMessageTest {
String[] array = new String[LOOP_CNT];
@Test
- public void testStringNoArgs() {
+ void testStringNoArgs() {
final String testMsg = "Test message %1s";
FormattedMessage msg = new FormattedMessage(testMsg, (Object[]) null);
String result = msg.getFormattedMessage();
@@ -54,7 +54,7 @@ public void testStringNoArgs() {
}
@Test
- public void tesStringOneStringArg() {
+ void tesStringOneStringArg() {
final String testMsg = "Test message %1s";
final FormattedMessage msg = new FormattedMessage(testMsg, "Apache");
final String result = msg.getFormattedMessage();
@@ -63,7 +63,7 @@ public void tesStringOneStringArg() {
}
@Test
- public void tesStringOneArgLocaleFrance_StringFormattedMessage() {
+ void tesStringOneArgLocaleFrance_StringFormattedMessage() {
final String testMsg = "Test message e = %+10.4f";
final FormattedMessage msg = new FormattedMessage(Locale.FRANCE, testMsg, Math.E);
final String result = msg.getFormattedMessage();
@@ -72,7 +72,7 @@ public void tesStringOneArgLocaleFrance_StringFormattedMessage() {
}
@Test
- public void tesStringOneArgLocaleFrance_MessageFormatMessage() {
+ void tesStringOneArgLocaleFrance_MessageFormatMessage() {
final String testMsg = "Test message {0,number,currency}";
final FormattedMessage msg = new FormattedMessage(Locale.FRANCE, testMsg, 12);
final String result = msg.getFormattedMessage();
@@ -81,7 +81,7 @@ public void tesStringOneArgLocaleFrance_MessageFormatMessage() {
}
@Test
- public void tesStringOneArgLocaleUs_MessageFormatMessage() {
+ void tesStringOneArgLocaleUs_MessageFormatMessage() {
final String testMsg = "Test message {0,number,currency}";
final FormattedMessage msg = new FormattedMessage(Locale.US, testMsg, 12);
final String result = msg.getFormattedMessage();
@@ -90,7 +90,7 @@ public void tesStringOneArgLocaleUs_MessageFormatMessage() {
}
@Test
- public void tesStringOneArgLocaleUs() {
+ void tesStringOneArgLocaleUs() {
final String testMsg = "Test message e = %+10.4f";
final FormattedMessage msg = new FormattedMessage(Locale.US, testMsg, Math.E);
final String result = msg.getFormattedMessage();
@@ -99,7 +99,7 @@ public void tesStringOneArgLocaleUs() {
}
@Test
- public void testNoArgs() {
+ void testNoArgs() {
final String testMsg = "Test message {0}";
FormattedMessage msg = new FormattedMessage(testMsg, (Object[]) null);
String result = msg.getFormattedMessage();
@@ -112,7 +112,7 @@ public void testNoArgs() {
}
@Test
- public void testOneArg() {
+ void testOneArg() {
final String testMsg = "Test message {0}";
final FormattedMessage msg = new FormattedMessage(testMsg, "Apache");
final String result = msg.getFormattedMessage();
@@ -121,7 +121,7 @@ public void testOneArg() {
}
@Test
- public void testParamNoArgs() {
+ void testParamNoArgs() {
final String testMsg = "Test message {}";
FormattedMessage msg = new FormattedMessage(testMsg, (Object[]) null);
String result = msg.getFormattedMessage();
@@ -133,7 +133,7 @@ public void testParamNoArgs() {
}
@Test
- public void testUnsafeWithMutableParams() { // LOG4J2-763
+ void testUnsafeWithMutableParams() { // LOG4J2-763
final String testMsg = "Test message %s";
final Mutable param = new Mutable().set("abc");
final FormattedMessage msg = new FormattedMessage(testMsg, param);
@@ -145,7 +145,7 @@ public void testUnsafeWithMutableParams() { // LOG4J2-763
}
@Test
- public void testSafeAfterGetFormattedMessageIsCalled() { // LOG4J2-763
+ void testSafeAfterGetFormattedMessageIsCalled() { // LOG4J2-763
final String testMsg = "Test message %s";
final Mutable param = new Mutable().set("abc");
final FormattedMessage msg = new FormattedMessage(testMsg, param);
@@ -158,7 +158,7 @@ public void testSafeAfterGetFormattedMessageIsCalled() { // LOG4J2-763
}
@Test
- public void testSerialization() throws IOException, ClassNotFoundException {
+ void testSerialization() throws IOException, ClassNotFoundException {
final FormattedMessage expected = new FormattedMessage("Msg", "a", "b", "c");
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (final ObjectOutputStream out = new ObjectOutputStream(baos)) {
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageFactoryTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageFactoryTest.java
index 7375e71797e..06d3fb8088e 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageFactoryTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageFactoryTest.java
@@ -25,10 +25,10 @@
/**
* Tests {@link LocalizedMessageFactory}.
*/
-public class LocalizedMessageFactoryTest {
+class LocalizedMessageFactoryTest {
@Test
- public void testMessageMarkersDataNo() {
+ void testMessageMarkersDataNo() {
final LocalizedMessageFactory localizedMessageFactory =
new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
final Message message = localizedMessageFactory.newMessage("msg1");
@@ -36,7 +36,7 @@ public void testMessageMarkersDataNo() {
}
@Test
- public void testMessageMarkersNoDataYes() {
+ void testMessageMarkersNoDataYes() {
final LocalizedMessageFactory localizedMessageFactory =
new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
final Message message = localizedMessageFactory.newMessage("msg1", 1, "two");
@@ -44,7 +44,7 @@ public void testMessageMarkersNoDataYes() {
}
@Test
- public void testNewMessage() {
+ void testNewMessage() {
final LocalizedMessageFactory localizedMessageFactory =
new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
final Message message = localizedMessageFactory.newMessage("hello_world");
@@ -52,7 +52,7 @@ public void testNewMessage() {
}
@Test
- public void testNoMatch() {
+ void testNoMatch() {
final LocalizedMessageFactory localizedMessageFactory =
new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
final Message message = localizedMessageFactory.newMessage("no match");
@@ -60,7 +60,7 @@ public void testNoMatch() {
}
@Test
- public void testNoMatchPercentInMessageNoArgsNo() {
+ void testNoMatchPercentInMessageNoArgsNo() {
// LOG4J2-3458 LocalizedMessage causes a lot of noise on the console
//
// ERROR StatusLogger Unable to format msg: C:/Program%20Files/Some%20Company/Some%20Product%20Name/
@@ -87,7 +87,7 @@ public void testNoMatchPercentInMessageNoArgsNo() {
}
@Test
- public void testNoMatchPercentInMessageArgsYes() {
+ void testNoMatchPercentInMessageArgsYes() {
final LocalizedMessageFactory localizedMessageFactory =
new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
final Message message = localizedMessageFactory.newMessage(
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageTest.java
index e2af8b65fbe..832230d53c8 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageTest.java
@@ -31,21 +31,21 @@
* Tests LocalizedMessage.
*/
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
-public class LocalizedMessageTest {
+class LocalizedMessageTest {
private T roundtrip(final T msg) {
return SerializationUtils.roundtrip(msg);
}
@Test
- public void testMessageFormat() {
+ void testMessageFormat() {
final LocalizedMessage msg =
new LocalizedMessage("MF", new Locale("en", "US"), "msg1", new Object[] {"1", "Test"});
assertEquals("This is test number 1 with string argument Test.", msg.getFormattedMessage());
}
@Test
- public void testSerializationMessageFormat() {
+ void testSerializationMessageFormat() {
final LocalizedMessage msg =
new LocalizedMessage("MF", new Locale("en", "US"), "msg1", new Object[] {"1", "Test"});
assertEquals("This is test number 1 with string argument Test.", msg.getFormattedMessage());
@@ -54,7 +54,7 @@ public void testSerializationMessageFormat() {
}
@Test
- public void testSerializationStringFormat() {
+ void testSerializationStringFormat() {
final LocalizedMessage msg =
new LocalizedMessage("SF", new Locale("en", "US"), "msg1", new Object[] {"1", "Test"});
assertEquals("This is test number 1 with string argument Test.", msg.getFormattedMessage());
@@ -63,14 +63,14 @@ public void testSerializationStringFormat() {
}
@Test
- public void testStringFormat() {
+ void testStringFormat() {
final LocalizedMessage msg =
new LocalizedMessage("SF", new Locale("en", "US"), "msg1", new Object[] {"1", "Test"});
assertEquals("This is test number 1 with string argument Test.", msg.getFormattedMessage());
}
@Test
- public void testUnsafeWithMutableParams() { // LOG4J2-763
+ void testUnsafeWithMutableParams() { // LOG4J2-763
final String testMsg = "Test message %s";
final Mutable param = new Mutable().set("abc");
final LocalizedMessage msg = new LocalizedMessage(testMsg, param);
@@ -82,7 +82,7 @@ public void testUnsafeWithMutableParams() { // LOG4J2-763
}
@Test
- public void testSafeAfterGetFormattedMessageIsCalled() { // LOG4J2-763
+ void testSafeAfterGetFormattedMessageIsCalled() { // LOG4J2-763
final String testMsg = "Test message %s";
final Mutable param = new Mutable().set("abc");
final LocalizedMessage msg = new LocalizedMessage(testMsg, param);
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
index 048801128d8..a36bb6b4ae9 100644
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
+++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
@@ -35,10 +35,10 @@
/**
*
*/
-public class MapMessageTest {
+class MapMessageTest {
@Test
- public void testMap() {
+ void testMap() {
final String testMsg = "Test message {}";
final StringMapMessage msg = new StringMapMessage();
msg.put("message", testMsg);
@@ -49,7 +49,7 @@ public void testMap() {
}
@Test
- public void testBuilder() {
+ void testBuilder() {
final String testMsg = "Test message {}";
final StringMapMessage msg =
new StringMapMessage().with("message", testMsg).with("project", "Log4j");
@@ -59,7 +59,7 @@ public void testBuilder() {
}
@Test
- public void testXML() {
+ void testXML() {
final String testMsg = "Test message {}";
final StringMapMessage msg = new StringMapMessage();
msg.put("message", testMsg);
@@ -71,7 +71,7 @@ public void testXML() {
}
@Test
- public void testXMLEscape() {
+ void testXMLEscape() {
final String testMsg = "Test message ";
final StringMapMessage msg = new StringMapMessage();
msg.put("message", testMsg);
@@ -81,7 +81,7 @@ public void testXMLEscape() {
}
@Test
- public void testJSON() {
+ void testJSON() {
final String testMsg = "Test message {}";
final StringMapMessage msg = new StringMapMessage();
msg.put("message", testMsg);
@@ -92,7 +92,7 @@ public void testJSON() {
}
@Test
- public void testJSONEscape() {
+ void testJSONEscape() {
final String testMsg = "Test message \"Hello, World!\"";
final StringMapMessage msg = new StringMapMessage();
msg.put("message", testMsg);
@@ -102,7 +102,7 @@ public void testJSONEscape() {
}
@Test
- public void testJSONEscapeNewlineAndOtherControlCharacters() {
+ void testJSONEscapeNewlineAndOtherControlCharacters() {
final String testMsg = "hello\tworld\r\nhh\bere is it\f";
final StringMapMessage msg = new StringMapMessage();
msg.put("one\ntwo", testMsg);
@@ -112,7 +112,7 @@ public void testJSONEscapeNewlineAndOtherControlCharacters() {
}
@Test
- public void testJsonFormatterNestedObjectSupport() {
+ void testJsonFormatterNestedObjectSupport() {
final Map map = new LinkedHashMap<>();
map.put("chars", new char[] {'a', 'b', 'c'});
map.put("booleans", new boolean[] {true, false});
@@ -157,7 +157,7 @@ public void testJsonFormatterNestedObjectSupport() {
}
@Test
- public void testJsonFormatterInfiniteRecursionPrevention() {
+ void testJsonFormatterInfiniteRecursionPrevention() {
final List
*/
@LoggerContextSource("log4j2-744.xml")
-public class TimestampMessageTest {
+class TimestampMessageTest {
private ListAppender app;
public TimestampMessageTest(@Named("List") final ListAppender app) {
@@ -51,18 +51,18 @@ public TimestampMessageTest(@Named("List") final ListAppender app) {
}
@BeforeAll
- public static void beforeClass() {
+ static void beforeClass() {
System.setProperty(ClockFactory.PROPERTY_NAME, PoisonClock.class.getName());
}
@AfterAll
- public static void afterClass() throws IllegalAccessException {
+ static void afterClass() throws IllegalAccessException {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
ClockFactoryTest.resetClocks();
}
@Test
- public void testTimestampMessage(final LoggerContext context) {
+ void testTimestampMessage(final LoggerContext context) {
final Logger log = context.getLogger("TimestampMessageTest");
log.info((Message) new TimeMsg("Message with embedded timestamp", 123456789000L));
final List msgs = app.getMessages();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/XmlEvents.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/XmlEvents.java
index c91ffb220fb..15e8856c473 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/XmlEvents.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/XmlEvents.java
@@ -27,10 +27,10 @@
@LoggerContextSource("xml-events.xml")
@Disabled("TODO")
-public class XmlEvents {
+class XmlEvents {
@Test
- public void testEvents() {
+ void testEvents() {
ThreadContext.put("loginId", "JohnDoe");
ThreadContext.put("ipAddress", "192.168.0.120");
ThreadContext.put("locale", Locale.US.getDisplayName());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AbstractAppenderBuilderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AbstractAppenderBuilderTest.java
index bec17bef216..6035ea1425d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AbstractAppenderBuilderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AbstractAppenderBuilderTest.java
@@ -22,10 +22,10 @@
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.junit.jupiter.api.Test;
-public class AbstractAppenderBuilderTest {
+class AbstractAppenderBuilderTest {
@Test
- public void testDefaultLayoutLeak() {
+ void testDefaultLayoutLeak() {
final int expected = AbstractManager.getManagerCount();
final Configuration configuration = new DefaultConfiguration();
final ConsoleAppender appender = ConsoleAppender.newBuilder()
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
index 4c9021df83d..f0a84f1f4dc 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
@@ -42,7 +42,7 @@
*
*/
@LoggerContextSource("log4j-asynch-queue-full.xml")
-public class AsyncAppenderQueueFullPolicyTest {
+class AsyncAppenderQueueFullPolicyTest {
private final BlockingAppender blockingAppender;
private final AsyncAppender asyncAppender;
@@ -61,13 +61,13 @@ public AsyncAppenderQueueFullPolicyTest(
}
@AfterEach
- public void after() {
+ void after() {
blockingAppender.running = false;
policy.queueFull.set(0L);
}
@Test
- public void testRouter() throws Exception {
+ void testRouter() {
final Logger logger = LogManager.getLogger(AsyncAppenderQueueFullPolicyTest.class);
assertEquals(4, asyncAppender.getQueueCapacity());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
index e693d2ca15f..ed0c6bc24a3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
@@ -19,6 +19,7 @@
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -37,7 +38,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
-public class AsyncAppenderTest {
+class AsyncAppenderTest {
static void exceptionTest(final LoggerContext context) throws InterruptedException {
assertNotNull(context);
@@ -78,14 +79,14 @@ static void rewriteTest(final LoggerContext context) throws InterruptedException
@Test
@LoggerContextSource("BlockingQueueFactory-ArrayBlockingQueue.xml")
- public void testArrayBlockingQueue(final LoggerContext context) throws InterruptedException {
+ void testArrayBlockingQueue(final LoggerContext context) throws InterruptedException {
rewriteTest(context);
exceptionTest(context);
}
@Test
@LoggerContextSource("log4j-asynch.xml")
- public void testDefaultAsyncAppenderConfig(final LoggerContext context) throws InterruptedException {
+ void testDefaultAsyncAppenderConfig(final LoggerContext context) throws InterruptedException {
rewriteTest(context);
exceptionTest(context);
@@ -101,14 +102,14 @@ public void testDefaultAsyncAppenderConfig(final LoggerContext context) throws I
@Test
@Tag("disruptor")
@LoggerContextSource("BlockingQueueFactory-DisruptorBlockingQueue.xml")
- public void testDisruptorBlockingQueue(final LoggerContext context) throws InterruptedException {
+ void testDisruptorBlockingQueue(final LoggerContext context) throws InterruptedException {
rewriteTest(context);
exceptionTest(context);
}
@Test
@LoggerContextSource("log4j-asynch.xml")
- public void testGetAppenderRefStrings(final LoggerContext context) throws InterruptedException {
+ void testGetAppenderRefStrings(final LoggerContext context) {
final AsyncAppender appender = context.getConfiguration().getAppender("Async");
assertArrayEquals(new String[] {"List"}, appender.getAppenderRefStrings());
assertNotSame(appender.getAppenderRefStrings(), appender.getAppenderRefStrings());
@@ -116,18 +117,18 @@ public void testGetAppenderRefStrings(final LoggerContext context) throws Interr
@Test
@LoggerContextSource("log4j-asynch.xml")
- public void testGetAppenders(final LoggerContext context) throws InterruptedException {
+ void testGetAppenders(final LoggerContext context) {
final AsyncAppender appender = context.getConfiguration().getAppender("Async");
final List appenders = appender.getAppenders();
assertEquals(1, appenders.size());
final Appender listAppender = appenders.get(0);
assertEquals("List", listAppender.getName());
- assertTrue(listAppender instanceof ListAppender);
+ assertInstanceOf(ListAppender.class, listAppender);
}
@Test
@LoggerContextSource("log4j-asynch.xml")
- public void testGetErrorRef(final LoggerContext context) throws InterruptedException {
+ void testGetErrorRef(final LoggerContext context) {
final AsyncAppender appender = context.getConfiguration().getAppender("Async");
assertEquals("STDOUT", appender.getErrorRef());
}
@@ -135,21 +136,21 @@ public void testGetErrorRef(final LoggerContext context) throws InterruptedExcep
@Test
@Tag("jctools")
@LoggerContextSource("BlockingQueueFactory-JCToolsBlockingQueue.xml")
- public void testJcToolsBlockingQueue(final LoggerContext context) throws InterruptedException {
+ void testJcToolsBlockingQueue(final LoggerContext context) throws InterruptedException {
rewriteTest(context);
exceptionTest(context);
}
@Test
@LoggerContextSource("BlockingQueueFactory-LinkedTransferQueue.xml")
- public void testLinkedTransferQueue(final LoggerContext context) throws InterruptedException {
+ void testLinkedTransferQueue(final LoggerContext context) throws InterruptedException {
rewriteTest(context);
exceptionTest(context);
}
@Test
@LoggerContextSource("log4j-asynch-no-location.xml")
- public void testNoLocationInformation(final LoggerContext context, @Named("List") final ListAppender appender)
+ void testNoLocationInformation(final LoggerContext context, @Named("List") final ListAppender appender)
throws InterruptedException {
final ExtendedLogger logger = context.getLogger(getClass());
logger.error("This is a test");
@@ -169,7 +170,7 @@ public void testNoLocationInformation(final LoggerContext context, @Named("List"
@Test
@Timeout(5)
@LoggerContextSource("log4j-asynch-shutdownTimeout.xml")
- public void testShutdownTimeout(final LoggerContext context) {
+ void testShutdownTimeout(final LoggerContext context) {
context.getLogger("Logger").info("This is a test");
context.stop();
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java
index 2ef1c52c9fa..83a6e8632cc 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java
@@ -21,7 +21,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Shows how to use ANSI escape codes to color messages. Each message is printed to the console in color, but the rest
@@ -39,7 +39,7 @@
*
*
*/
-public class ConsoleAppenderAnsiStyleLayoutMain {
+class ConsoleAppenderAnsiStyleLayoutMain {
public static void main(final String[] args) {
new ConsoleAppenderAnsiStyleLayoutMain().test(args);
@@ -49,7 +49,7 @@ public static void main(final String[] args) {
* This is a @Test method to make it easy to run from a command line with {@code mvn -Dtest=FQCN test}
*/
@Test
- public void test() {
+ void test() {
test(null);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiXExceptionMain.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiXExceptionMain.java
index ee062add98e..88abec63f87 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiXExceptionMain.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiXExceptionMain.java
@@ -22,7 +22,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Shows how to use ANSI escape codes to color messages. Each message is printed to the console in color, but the rest
@@ -42,7 +42,7 @@
*
*
*/
-public class ConsoleAppenderAnsiXExceptionMain {
+class ConsoleAppenderAnsiXExceptionMain {
public static void main(final String[] args) {
new ConsoleAppenderAnsiXExceptionMain().test(args);
@@ -52,7 +52,7 @@ public static void main(final String[] args) {
* This is a @Test method to make it easy to run from a command line with {@code mvn -Dtest=FQCN test}
*/
@Test
- public void test() {
+ void test() {
test(null);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderBuilderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderBuilderTest.java
index dae67a50fdf..10ab22436f3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderBuilderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderBuilderTest.java
@@ -26,13 +26,13 @@
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.junit.jupiter.api.Test;
-public class ConsoleAppenderBuilderTest {
+class ConsoleAppenderBuilderTest {
/**
* Tests https://issues.apache.org/jira/browse/LOG4J2-1620
*/
@Test
- public void testDefaultImmediateFlush() {
+ void testDefaultImmediateFlush() {
assertTrue(ConsoleAppender.newBuilder().isImmediateFlush());
}
@@ -42,7 +42,7 @@ public void testDefaultImmediateFlush() {
* Tested with Oracle 7 and 8 and IBM Java 8.
*/
@Test
- public void testDefaultLayoutDefaultCharset() {
+ void testDefaultLayoutDefaultCharset() {
final ConsoleAppender appender =
ConsoleAppender.newBuilder().setName("test").build();
final PatternLayout layout = (PatternLayout) appender.getLayout();
@@ -56,7 +56,7 @@ public void testDefaultLayoutDefaultCharset() {
* Tests https://issues.apache.org/jira/browse/LOG4J2-2441
*/
@Test
- public void testSetNullErrorHandlerIsNotAllowed() {
+ void testSetNullErrorHandlerIsNotAllowed() {
final ConsoleAppender appender =
ConsoleAppender.newBuilder().setName("test").build();
final ErrorHandler handler = appender.getHandler();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderTest.java
index 1d8171233b2..87b4a5077a9 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderTest.java
@@ -44,17 +44,17 @@
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
-public class ConsoleAppenderTest {
+class ConsoleAppenderTest {
private static final String LOG4J_SKIP_JANSI = "log4j.skipJansi";
@AfterAll
- public static void afterClass() {
+ static void afterClass() {
System.clearProperty(LOG4J_SKIP_JANSI);
}
@BeforeAll
- public static void beforeClass() {
+ static void beforeClass() {
System.setProperty(LOG4J_SKIP_JANSI, "true");
}
@@ -64,7 +64,7 @@ public static void beforeClass() {
PrintStream psMock;
@BeforeEach
- public void before() {
+ void before() {
System.setProperty(LOG4J_SKIP_JANSI, "true");
baos = new ByteArrayOutputStream();
}
@@ -120,12 +120,12 @@ private void testConsoleStreamManagerDoesNotClose(
}
@Test
- public void testFollowSystemErr() {
+ void testFollowSystemErr() {
testFollowSystemPrintStream(System.err, Target.SYSTEM_ERR, SystemSetter.SYSTEM_ERR);
}
@Test
- public void testFollowSystemOut() {
+ void testFollowSystemOut() {
testFollowSystemPrintStream(System.out, Target.SYSTEM_OUT, SystemSetter.SYSTEM_OUT);
}
@@ -164,12 +164,12 @@ private void testFollowSystemPrintStream(
}
@Test
- public void testSystemErrStreamManagerDoesNotClose() {
+ void testSystemErrStreamManagerDoesNotClose() {
testConsoleStreamManagerDoesNotClose(System.err, Target.SYSTEM_ERR, SystemSetter.SYSTEM_ERR);
}
@Test
- public void testSystemOutStreamManagerDoesNotClose() {
+ void testSystemOutStreamManagerDoesNotClose() {
testConsoleStreamManagerDoesNotClose(System.out, Target.SYSTEM_OUT, SystemSetter.SYSTEM_OUT);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
index 9770771b8c7..efba39b0b97 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
@@ -48,37 +48,37 @@ public FailoverAppenderTest(
}
@AfterEach
- public void tearDown() throws Exception {
+ void tearDown() {
app.clear();
}
@Test
- public void testFailover() {
+ void testFailover() {
logger.error("This is a test");
List events = app.getEvents();
assertNotNull(events);
- assertEquals(events.size(), 1, "Incorrect number of events. Should be 1 is " + events.size());
+ assertEquals(1, events.size(), "Incorrect number of events. Should be 1 is " + events.size());
app.clear();
logger.error("This is a test");
events = app.getEvents();
assertNotNull(events);
- assertEquals(events.size(), 1, "Incorrect number of events. Should be 1 is " + events.size());
+ assertEquals(1, events.size(), "Incorrect number of events. Should be 1 is " + events.size());
}
@Test
- public void testRecovery() throws Exception {
+ void testRecovery() throws Exception {
onceLogger.error("Fail once");
onceLogger.error("Fail again");
List events = app.getEvents();
assertNotNull(events);
- assertEquals(events.size(), 2, "Incorrect number of events. Should be 2 is " + events.size());
+ assertEquals(2, events.size(), "Incorrect number of events. Should be 2 is " + events.size());
app.clear();
Thread.sleep(1100);
onceLogger.error("Fail after recovery interval");
onceLogger.error("Second log message");
events = app.getEvents();
- assertEquals(events.size(), 0, "Did not recover");
+ assertEquals(0, events.size(), "Did not recover");
events = foApp.drainEvents();
- assertEquals(events.size(), 2, "Incorrect number of events in primary appender");
+ assertEquals(2, events.size(), "Incorrect number of events in primary appender");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FailoverFailedPrimaryAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FailoverFailedPrimaryAppenderTest.java
index 6ef641c8b90..9c39204b166 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FailoverFailedPrimaryAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FailoverFailedPrimaryAppenderTest.java
@@ -43,15 +43,15 @@ public class FailoverFailedPrimaryAppenderTest {
public static LoggerContextRule init = new LoggerContextRule("log4j-failover.xml");
@Before
- public void setUp() throws Exception {
+ public void setUp() {
app = init.getListAppender("List");
- foApp = (FailOnceAppender) init.getAppender("Once");
+ foApp = init.getAppender("Once");
logger = init.getLogger("LoggerTest");
onceLogger = init.getLogger("Once");
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
if (app != null) {
app.clear();
}
@@ -62,12 +62,12 @@ public void testFailover() {
logger.error("This is a test");
List events = app.getEvents();
assertNotNull(events);
- assertEquals("Incorrect number of events. Should be 1 is " + events.size(), events.size(), 1);
+ assertEquals("Incorrect number of events. Should be 1 is " + events.size(), 1, events.size());
app.clear();
logger.error("This is a test");
events = app.getEvents();
assertNotNull(events);
- assertEquals("Incorrect number of events. Should be 1 is " + events.size(), events.size(), 1);
+ assertEquals("Incorrect number of events. Should be 1 is " + events.size(), 1, events.size());
}
@Test
@@ -76,14 +76,14 @@ public void testRecovery() throws Exception {
onceLogger.error("Fail again");
List events = app.getEvents();
assertNotNull(events);
- assertEquals("Incorrect number of events. Should be 2 is " + events.size(), events.size(), 2);
+ assertEquals("Incorrect number of events. Should be 2 is " + events.size(), 2, events.size());
app.clear();
Thread.sleep(1100);
onceLogger.error("Fail after recovery interval");
onceLogger.error("Second log message");
events = app.getEvents();
- assertEquals("Did not recover", events.size(), 0);
+ assertEquals("Did not recover", 0, events.size());
events = foApp.drainEvents();
- assertEquals("Incorrect number of events in primary appender", events.size(), 2);
+ assertEquals("Incorrect number of events in primary appender", 2, events.size());
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderBuilderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderBuilderTest.java
index 904ef088cc1..718349e1f3c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderBuilderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderBuilderTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.logging.log4j.core.appender;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
-import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.status.StatusData;
@@ -29,13 +29,13 @@
import org.apache.logging.log4j.status.StatusLogger;
import org.junit.jupiter.api.Test;
-public class FileAppenderBuilderTest {
+class FileAppenderBuilderTest {
/**
* Tests https://issues.apache.org/jira/browse/LOG4J2-1620
*/
@Test
- public void testDefaultImmediateFlush() {
+ void testDefaultImmediateFlush() {
assertTrue(FileAppender.newBuilder().isImmediateFlush());
}
@@ -44,12 +44,12 @@ public void testDefaultImmediateFlush() {
* {@code null}.
*/
@Test
- public void testConstraints() {
+ void testConstraints() {
final AtomicInteger counter = new AtomicInteger();
final StatusListener listener = new StatusListener() {
@Override
- public void close() throws IOException {}
+ public void close() {}
@Override
public void log(final StatusData data) {
@@ -79,7 +79,7 @@ public Level getStatusLevel() {
.withFileName("target/FileAppenderBuilderTest.log")
.build();
assertNotNull(appender);
- assertTrue(counter.get() == 0);
+ assertEquals(0, counter.get());
} catch (NullPointerException e) {
// thrown if no filename is provided
fail(e);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsTest.java
index 1db2eee7eb3..1ebf7cbacf3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsTest.java
@@ -53,19 +53,19 @@
* Tests {@link FileAppender}.
*/
@CleanUpDirectories(FileAppenderPermissionsTest.DIR)
-public class FileAppenderPermissionsTest {
+class FileAppenderPermissionsTest {
static final String DIR = "target/permissions1";
@BeforeAll
- public static void beforeClass() {
+ static void beforeClass() {
System.setProperty("log4j2.debug", "true");
assumeTrue(FileUtils.isFilePosixAttributeViewSupported());
}
@ParameterizedTest
@CsvSource({"rwxrwxrwx,true,2", "rw-r--r--,false,3", "rw-------,true,4", "rw-rw----,false,5"})
- public void testFilePermissionsAPI(final String filePermissions, final boolean createOnDemand, final int fileIndex)
+ void testFilePermissionsAPI(final String filePermissions, final boolean createOnDemand, final int fileIndex)
throws Exception {
final File file = new File(DIR, "AppenderTest-" + fileIndex + ".log");
final Path path = file.toPath();
@@ -91,7 +91,7 @@ public void testFilePermissionsAPI(final String filePermissions, final boolean c
assertNotEquals(createOnDemand, Files.exists(path));
long curLen = file.length();
long prevLen = curLen;
- assertEquals(curLen, 0, "File length: " + curLen);
+ assertEquals(0, curLen, "File length: " + curLen);
for (int i = 0; i < 100; ++i) {
final LogEvent event = Log4jLogEvent.newBuilder()
.setLoggerName("TestLogger") //
@@ -121,7 +121,7 @@ public void testFilePermissionsAPI(final String filePermissions, final boolean c
@ParameterizedTest
@CsvSource({"rwxrwxrwx,2", "rw-r--r--,3", "rw-------,4", "rw-rw----,5"})
- public void testFileUserGroupAPI(final String filePermissions, final int fileIndex) throws Exception {
+ void testFileUserGroupAPI(final String filePermissions, final int fileIndex) throws Exception {
final File file = new File(DIR, "AppenderTest-" + (1000 + fileIndex) + ".log");
final Path path = file.toPath();
final String user = findAUser();
@@ -151,7 +151,7 @@ public void testFileUserGroupAPI(final String filePermissions, final int fileInd
assertTrue(appender.isStarted(), "Appender did not start");
long curLen = file.length();
long prevLen = curLen;
- assertEquals(curLen, 0, file + " File length: " + curLen);
+ assertEquals(0, curLen, file + " File length: " + curLen);
for (int i = 0; i < 100; ++i) {
final LogEvent event = Log4jLogEvent.newBuilder()
.setLoggerName("TestLogger") //
@@ -209,7 +209,7 @@ public static String findAGroup(final String user) throws IOException {
}
}
- private static String findAUser() throws IOException {
+ private static String findAUser() {
// On jenkins build within ubuntu, it is not possible to chmod to another user
return System.getProperty("user.name");
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
index c645c3516e3..07221c2c811 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
@@ -52,20 +52,20 @@
* Tests {@link FileAppender}.
*/
@CleanUpFiles(FileAppenderTest.FILE_NAME)
-public class FileAppenderTest {
+class FileAppenderTest {
static final String FILE_NAME = "target/fileAppenderTest.log";
private static final Path PATH = Paths.get(FILE_NAME);
private static final int THREADS = 2;
@AfterAll
- public static void cleanupClass() {
+ static void cleanupClass() {
assertFalse(AbstractManager.hasManager(FILE_NAME), "Manager for " + FILE_NAME + " not removed");
}
@ParameterizedTest
@ValueSource(booleans = {false, true})
- public void testAppender(final boolean createOnDemand) throws Exception {
+ void testAppender(final boolean createOnDemand) throws Exception {
final int logEventCount = 1;
writer(false, logEventCount, "test", createOnDemand, false);
verifyFile(logEventCount);
@@ -73,7 +73,7 @@ public void testAppender(final boolean createOnDemand) throws Exception {
@ParameterizedTest
@ValueSource(booleans = {false, true})
- public void testLazyCreate(final boolean createOnDemand) throws Exception {
+ void testLazyCreate(final boolean createOnDemand) {
final Layout layout = createPatternLayout();
// @formatter:off
final FileAppender appender = FileAppender.newBuilder()
@@ -106,7 +106,7 @@ private static PatternLayout createPatternLayout() {
@ParameterizedTest
@ValueSource(booleans = {false, true})
- public void testSmallestBufferSize(final boolean createOnDemand) throws Exception {
+ void testSmallestBufferSize(final boolean createOnDemand) throws Exception {
final Layout layout = createPatternLayout();
// @formatter:off
final FileAppender appender = FileAppender.newBuilder()
@@ -154,7 +154,7 @@ public void testSmallestBufferSize(final boolean createOnDemand) throws Exceptio
@ParameterizedTest
@ValueSource(booleans = {false, true})
- public void testLockingAppender(final boolean createOnDemand) throws Exception {
+ void testLockingAppender(final boolean createOnDemand) throws Exception {
final int logEventCount = 1;
writer(true, logEventCount, "test", createOnDemand, false);
verifyFile(logEventCount);
@@ -162,13 +162,12 @@ public void testLockingAppender(final boolean createOnDemand) throws Exception {
@ParameterizedTest
@ValueSource(booleans = {false, true})
- public void testMultipleAppenderThreads(final boolean createOnDemand) throws Exception {
+ void testMultipleAppenderThreads(final boolean createOnDemand) throws Exception {
testMultipleLockingAppenderThreads(false, THREADS, createOnDemand);
}
private void testMultipleLockingAppenderThreads(
- final boolean lock, final int threadCount, final boolean createOnDemand)
- throws InterruptedException, Exception {
+ final boolean lock, final int threadCount, final boolean createOnDemand) throws Exception {
final ExecutorService threadPool = Executors.newFixedThreadPool(threadCount);
final AtomicReference throwableRef = new AtomicReference<>();
final int logEventCount = 100;
@@ -193,14 +192,14 @@ private void testMultipleLockingAppenderThreads(
@ParameterizedTest
@ValueSource(booleans = {false, true})
- public void testMultipleLockingAppenders(final boolean createOnDemand) throws Exception {
+ void testMultipleLockingAppenders(final boolean createOnDemand) throws Exception {
testMultipleLockingAppenderThreads(true, THREADS, createOnDemand);
}
@ParameterizedTest
@ValueSource(booleans = {false, true})
@Disabled
- public void testMultipleVMs(final boolean createOnDemand) throws Exception {
+ void testMultipleVMs(final boolean createOnDemand) throws Exception {
final String classPath = System.getProperty("java.class.path");
final int logEventCount = 10;
final int processCount = 3;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java
index 1719f15cba9..a4df56e5074 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java
@@ -26,7 +26,7 @@
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/InMemoryAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/InMemoryAppenderTest.java
index bdc95ceef32..4bc0c53b765 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/InMemoryAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/InMemoryAppenderTest.java
@@ -31,10 +31,10 @@
import org.apache.logging.log4j.util.Strings;
import org.junit.jupiter.api.Test;
-public class InMemoryAppenderTest {
+class InMemoryAppenderTest {
@Test
- public void testAppender() {
+ void testAppender() {
final Layout layout = PatternLayout.createDefaultLayout();
final boolean writeHeader = true;
final InMemoryAppender app = new InMemoryAppender("test", layout, null, false, writeHeader);
@@ -43,7 +43,7 @@ public void testAppender() {
}
@Test
- public void testHeaderRequested() {
+ void testHeaderRequested() {
final PatternLayout layout =
PatternLayout.newBuilder().withHeader("HEADERHEADER").build();
final boolean writeHeader = true;
@@ -53,7 +53,7 @@ public void testHeaderRequested() {
}
@Test
- public void testHeaderSuppressed() {
+ void testHeaderSuppressed() {
final PatternLayout layout =
PatternLayout.newBuilder().withHeader("HEADERHEADER").build();
final boolean writeHeader = false;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
index fa8666af1c3..4d1befb11d4 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
@@ -16,10 +16,11 @@
*/
package org.apache.logging.log4j.core.appender;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import org.apache.logging.log4j.Logger;
@@ -83,7 +84,7 @@ public void testFlushAtEndOfBatch() throws Exception {
logger.error(logMsg, new IllegalArgumentException("badarg"));
this.loggerContextRule.getLoggerContext().stop(); // stops async thread
- final List lines = Files.readAllLines(logFile.toPath(), Charset.forName("UTF8"));
+ final List lines = Files.readAllLines(logFile.toPath(), StandardCharsets.UTF_8);
final String[] expected = {
"[", // equals
@@ -106,6 +107,6 @@ public void testFlushAtEndOfBatch() throws Exception {
line.contains(expected[i]));
}
final String location = "testFlushAtEndOfBatch";
- assertTrue("no location", !lines.get(0).contains(location));
+ assertFalse("no location", lines.get(0).contains(location));
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/MemoryMappedFileAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/MemoryMappedFileAppenderTest.java
index 8937864d0c7..f4ca62e9ab2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/MemoryMappedFileAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/MemoryMappedFileAppenderTest.java
@@ -46,11 +46,11 @@
"target/MemoryMappedFileAppenderRemapTest.log",
"target/MemoryMappedFileAppenderLocationTest.log"
})
-public class MemoryMappedFileAppenderTest {
+class MemoryMappedFileAppenderTest {
@Test
@LoggerContextSource("MemoryMappedFileAppenderTest.xml")
- public void testMemMapBasics(final LoggerContext context) throws Exception {
+ void testMemMapBasics(final LoggerContext context) throws Exception {
final Logger log = context.getLogger(getClass());
final Path logFile = Paths.get("target", "MemoryMappedFileAppenderTest.log");
try {
@@ -71,7 +71,7 @@ public void testMemMapBasics(final LoggerContext context) throws Exception {
@Test
@LoggerContextSource("MemoryMappedFileAppenderRemapTest.xml")
- public void testMemMapExtendsIfNeeded(final LoggerContext context) throws Exception {
+ void testMemMapExtendsIfNeeded(final LoggerContext context) throws Exception {
final Logger log = context.getLogger(getClass());
final Path logFile = Paths.get("target", "MemoryMappedFileAppenderRemapTest.log");
final char[] text = new char[256];
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManagerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManagerTest.java
index f0d21994439..2a442f6ea70 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManagerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManagerTest.java
@@ -33,13 +33,13 @@
*
* @since 2.1
*/
-public class MemoryMappedFileManagerTest {
+class MemoryMappedFileManagerTest {
@TempDir
File tempDir;
@Test
- public void testRemapAfterInitialMapSizeExceeded() throws IOException {
+ void testRemapAfterInitialMapSizeExceeded() throws IOException {
final int mapSize = 64; // very small, on purpose
final File file = new File(tempDir, "memory-mapped-file.bin");
@@ -65,7 +65,7 @@ public void testRemapAfterInitialMapSizeExceeded() throws IOException {
}
@Test
- public void testAppendDoesNotOverwriteExistingFile() throws IOException {
+ void testAppendDoesNotOverwriteExistingFile() throws IOException {
final File file = new File(tempDir, "memory-mapped-file.bin");
final int initialLength = 4 * 1024;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamAppenderTest.java
index 3082425be09..ed09bc11d86 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamAppenderTest.java
@@ -16,10 +16,14 @@
*/
package org.apache.logging.log4j.core.appender;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
-import java.sql.SQLException;
+import java.lang.reflect.Method;
+import java.util.Optional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.Appender;
@@ -27,23 +31,21 @@
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.filter.NoMarkerFilter;
import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
* Tests {@link OutputStreamAppender}.
*/
-public class OutputStreamAppenderTest {
+class OutputStreamAppenderTest {
private static final String TEST_MSG = "FOO ERROR";
- @Rule
- public TestName testName = new TestName();
+ public String testName;
private String getName(final OutputStream out) {
- return out.getClass().getSimpleName() + "." + testName.getMethodName();
+ return out.getClass().getSimpleName() + "." + testName;
}
/**
@@ -61,19 +63,19 @@ private void addAppender(final OutputStream outputStream, final String outputStr
}
@Test
- public void testBuildFilter() {
+ void testBuildFilter() {
final NoMarkerFilter filter = NoMarkerFilter.newBuilder().build();
// @formatter:off
final OutputStreamAppender.Builder builder =
OutputStreamAppender.newBuilder().setName("test").setFilter(filter);
// @formatter:on
- Assert.assertEquals(filter, builder.getFilter());
+ assertEquals(filter, builder.getFilter());
final OutputStreamAppender appender = builder.build();
- Assert.assertEquals(filter, appender.getFilter());
+ assertEquals(filter, appender.getFilter());
}
@Test
- public void testOutputStreamAppenderToBufferedOutputStream() throws SQLException {
+ void testOutputStreamAppenderToBufferedOutputStream() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final OutputStream os = new BufferedOutputStream(out);
final String name = getName(out);
@@ -81,18 +83,18 @@ public void testOutputStreamAppenderToBufferedOutputStream() throws SQLException
addAppender(os, name);
logger.error(TEST_MSG);
final String actual = out.toString();
- Assert.assertTrue(actual, actual.contains(TEST_MSG));
+ assertTrue(actual.contains(TEST_MSG), actual);
}
@Test
- public void testOutputStreamAppenderToByteArrayOutputStream() throws SQLException {
+ void testOutputStreamAppenderToByteArrayOutputStream() {
final OutputStream out = new ByteArrayOutputStream();
final String name = getName(out);
final Logger logger = LogManager.getLogger(name);
addAppender(out, name);
logger.error(TEST_MSG);
final String actual = out.toString();
- Assert.assertTrue(actual, actual.contains(TEST_MSG));
+ assertTrue(actual.contains(TEST_MSG), actual);
}
/**
@@ -101,7 +103,7 @@ public void testOutputStreamAppenderToByteArrayOutputStream() throws SQLExceptio
* new Writer appender.
*/
@Test
- public void testUpdatePatternWithFileAppender() {
+ void testUpdatePatternWithFileAppender() {
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
// @formatter:off
@@ -120,4 +122,10 @@ public void testUpdatePatternWithFileAppender() {
ConfigurationTestUtils.updateLoggers(appender, config);
LogManager.getLogger().error("FOO MSG");
}
+
+ @BeforeEach
+ public void setup(TestInfo testInfo) {
+ Optional testMethod = testInfo.getTestMethod();
+ testMethod.ifPresent(method -> this.testName = method.getName());
+ }
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamManagerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamManagerTest.java
index c5e25a15c66..64c0a08dbe1 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamManagerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamManagerTest.java
@@ -62,7 +62,7 @@ void narrow(final LoggerContext context) {
}
@Test
- public void testOutputStreamAppenderFlushClearsBufferOnException() {
+ void testOutputStreamAppenderFlushClearsBufferOnException() {
final IOException exception = new IOException();
final OutputStream throwingOutputStream = new OutputStream() {
@Override
@@ -79,7 +79,7 @@ public void write(final int b) throws IOException {
outputStreamManager.getByteBuffer().put((byte) 0);
}
- assertEquals(outputStreamManager.getByteBuffer().remaining(), 1);
+ assertEquals(1, outputStreamManager.getByteBuffer().remaining());
final AppenderLoggingException appenderLoggingException = assertThrows(
AppenderLoggingException.class,
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppenderTest.java
index b240958379a..0371bbdb2ae 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileAppenderTest.java
@@ -18,8 +18,8 @@
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import java.io.BufferedReader;
import java.io.File;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
index 4c8b0af078a..fa8ccae5d50 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
@@ -31,7 +31,7 @@
/**
* Tests the RandomAccessFileManager class.
*/
-public class RandomAccessFileManagerTest {
+class RandomAccessFileManagerTest {
@TempDir
File tempDir;
@@ -41,7 +41,7 @@ public class RandomAccessFileManagerTest {
* {@link org.apache.logging.log4j.core.appender.RandomAccessFileManager#writeBytes(byte[], int, int)}.
*/
@Test
- public void testWrite_multiplesOfBufferSize() throws IOException {
+ void testWrite_multiplesOfBufferSize() throws IOException {
final File file = new File(tempDir, "testWrite_multiplesOfBufferSize.bin");
try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
final OutputStream os = NullOutputStream.getInstance();
@@ -63,7 +63,7 @@ public void testWrite_multiplesOfBufferSize() throws IOException {
* .
*/
@Test
- public void testWrite_dataExceedingBufferSize() throws IOException {
+ void testWrite_dataExceedingBufferSize() throws IOException {
final File file = new File(tempDir, "testWrite_dataExceedingBufferSize.bin");
try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
final OutputStream os = NullOutputStream.getInstance();
@@ -82,7 +82,7 @@ public void testWrite_dataExceedingBufferSize() throws IOException {
}
@Test
- public void testConfigurableBufferSize() throws IOException {
+ void testConfigurableBufferSize() throws IOException {
final File file = new File(tempDir, "testConfigurableBufferSize.bin");
try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
final OutputStream os = NullOutputStream.getInstance();
@@ -98,7 +98,7 @@ public void testConfigurableBufferSize() throws IOException {
}
@Test
- public void testWrite_dataExceedingMinBufferSize() throws IOException {
+ void testWrite_dataExceedingMinBufferSize() throws IOException {
final File file = new File(tempDir, "testWrite_dataExceedingMinBufferSize.bin");
try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
final OutputStream os = NullOutputStream.getInstance();
@@ -118,7 +118,7 @@ public void testWrite_dataExceedingMinBufferSize() throws IOException {
}
@Test
- public void testAppendDoesNotOverwriteExistingFile() throws IOException {
+ void testAppendDoesNotOverwriteExistingFile() throws IOException {
final boolean isAppend = true;
final File file = new File(tempDir, "testAppendDoesNotOverwriteExistingFile.bin");
assertEquals(0, file.length());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ReconfigureAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ReconfigureAppenderTest.java
index bd649ff5bb5..688ac302044 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ReconfigureAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ReconfigureAppenderTest.java
@@ -32,11 +32,11 @@
import org.apache.logging.log4j.core.util.Builder;
import org.junit.jupiter.api.Test;
-public class ReconfigureAppenderTest {
+class ReconfigureAppenderTest {
private RollingFileAppender appender;
@Test
- public void addAndRemoveAppenderTest() {
+ void addAndRemoveAppenderTest() {
// this will create a rolling file appender and add it to the logger
// of this class. The file manager is created for the first time.
// see AbstractManager.getManager(...).
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelectorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelectorTest.java
index 0b8c8c6cb56..99545656641 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelectorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelectorTest.java
@@ -31,7 +31,7 @@
import org.junitpioneer.jupiter.SetSystemProperty;
@SetSystemProperty(key = Constants.SCRIPT_LANGUAGES, value = "Groovy, Javascript")
-public class ScriptAppenderSelectorTest {
+class ScriptAppenderSelectorTest {
@Test
@LoggerContextSource("log4j-appender-selector-javascript.xml")
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SmtpAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SmtpAppenderTest.java
index f1ac50d8f2f..1ad3d8f8d2d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SmtpAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SmtpAppenderTest.java
@@ -16,12 +16,13 @@
*/
package org.apache.logging.log4j.core.appender;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Iterator;
import javax.mail.Address;
@@ -35,19 +36,18 @@
import org.apache.logging.log4j.core.net.MimeMessageBuilder;
import org.apache.logging.log4j.core.net.SmtpManager;
import org.apache.logging.log4j.core.test.AvailablePortFinder;
-import org.apache.logging.log4j.core.test.categories.Appenders;
import org.apache.logging.log4j.core.test.smtp.SimpleSmtpServer;
import org.apache.logging.log4j.core.test.smtp.SmtpMessage;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(Appenders.Smtp.class)
-public class SmtpAppenderTest {
+@Tag("Smtp")
+class SmtpAppenderTest {
private static final String HOST = "localhost";
@Test
- public void testMessageFactorySetFrom() throws MessagingException {
+ void testMessageFactorySetFrom() throws MessagingException {
final MimeMessageBuilder builder = new MimeMessageBuilder(null);
final String address = "testing@example.com";
@@ -67,7 +67,7 @@ public void testMessageFactorySetFrom() throws MessagingException {
}
@Test
- public void testMessageFactorySetReplyTo() throws MessagingException {
+ void testMessageFactorySetReplyTo() throws MessagingException {
final MimeMessageBuilder builder = new MimeMessageBuilder(null);
final String addresses = "testing1@example.com,testing2@example.com";
@@ -81,7 +81,7 @@ public void testMessageFactorySetReplyTo() throws MessagingException {
}
@Test
- public void testMessageFactorySetRecipients() throws MessagingException {
+ void testMessageFactorySetRecipients() throws MessagingException {
final MimeMessageBuilder builder = new MimeMessageBuilder(null);
final String addresses = "testing1@example.com,testing2@example.com";
@@ -95,7 +95,7 @@ public void testMessageFactorySetRecipients() throws MessagingException {
}
@Test
- public void testMessageFactorySetSubject() throws MessagingException {
+ void testMessageFactorySetSubject() throws MessagingException {
final MimeMessageBuilder builder = new MimeMessageBuilder(null);
final String subject = "Test Subject";
@@ -109,7 +109,7 @@ public void testMessageFactorySetSubject() throws MessagingException {
}
@Test
- public void testDelivery() {
+ void testDelivery() {
final String subjectKey = getClass().getName();
final String subjectValue = "SubjectValue1";
ThreadContext.put(subjectKey, subjectValue);
@@ -127,7 +127,7 @@ public void testDelivery() {
.setBufferSize(3)
.build();
assertNotNull(appender);
- assertTrue(appender.getManager() instanceof SmtpManager);
+ assertInstanceOf(SmtpManager.class, appender.getManager());
appender.start();
final LoggerContext context = LoggerContext.getContext();
@@ -146,7 +146,7 @@ public void testDelivery() {
root.error("Error message #2");
server.stop();
- assertTrue(server.getReceivedEmailSize() == 2);
+ assertEquals(2, server.getReceivedEmailSize());
final Iterator messages = server.getReceivedEmail();
final SmtpMessage email = messages.next();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderBuilderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderBuilderTest.java
index e79579444e3..e67b2f2d65e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderBuilderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderBuilderTest.java
@@ -20,13 +20,13 @@
import org.junit.jupiter.api.Test;
-public class SocketAppenderBuilderTest {
+class SocketAppenderBuilderTest {
/**
* Tests https://issues.apache.org/jira/browse/LOG4J2-1620
*/
@Test
- public void testDefaultImmediateFlush() {
+ void testDefaultImmediateFlush() {
assertTrue(
SocketAppender.newBuilder().isImmediateFlush(),
"Regression of LOG4J2-1620: default value for immediateFlush should be true");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
index 503b2b1e1ad..619749eacf2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
@@ -55,7 +55,7 @@
/**
* Tests reconnection support of {@link org.apache.logging.log4j.core.appender.SocketAppender}.
*/
-public class SocketAppenderReconnectTest {
+class SocketAppenderReconnectTest {
private static final String CLASS_NAME = SocketAppenderReconnectTest.class.getSimpleName();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderSocketOptionsTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderSocketOptionsTest.java
index 76453658539..7988c3fbd8c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderSocketOptionsTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderSocketOptionsTest.java
@@ -86,10 +86,10 @@ public void testSocketOptions() throws IOException {
Assert.assertEquals(12345, socketOptions.getSoLinger().intValue());
Assert.assertEquals(54321, socketOptions.getSoTimeout().intValue());
// Test live socket
- Assert.assertEquals(false, socket.getKeepAlive());
- Assert.assertEquals(false, socket.getOOBInline());
- Assert.assertEquals(false, socket.getReuseAddress());
- Assert.assertEquals(false, socket.getTcpNoDelay());
+ Assert.assertFalse(socket.getKeepAlive());
+ Assert.assertFalse(socket.getOOBInline());
+ Assert.assertFalse(socket.getReuseAddress());
+ Assert.assertFalse(socket.getTcpNoDelay());
// Assert.assertEquals(10000, socket.getReceiveBufferSize());
// This settings changes while we are running, so we cannot assert it.
// Assert.assertEquals(8000, socket.getSendBufferSize());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderSslSocketOptionsTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderSslSocketOptionsTest.java
index 5e68fd776ce..0167194c7b1 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderSslSocketOptionsTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderSslSocketOptionsTest.java
@@ -40,7 +40,7 @@
import org.junit.jupiter.api.io.CleanupMode;
import org.junit.jupiter.api.io.TempDir;
-public class SocketAppenderSslSocketOptionsTest {
+class SocketAppenderSslSocketOptionsTest {
private static final String APPENDER_NAME = "TestSocket";
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java
index b330f7d4d43..3eaad6533f1 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java
@@ -16,17 +16,16 @@
*/
package org.apache.logging.log4j.core.appender;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
-import java.io.Serializable;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.ServerSocket;
@@ -41,7 +40,6 @@
import org.apache.logging.log4j.LoggingException;
import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.LoggerContext;
@@ -52,17 +50,16 @@
import org.apache.logging.log4j.core.test.AvailablePortFinder;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.util.Throwables;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
/**
*
*/
-public class SocketAppenderTest {
+class SocketAppenderTest {
private static final int PORT = AvailablePortFinder.getNextAvailable();
private static final int DYN_PORT = AvailablePortFinder.getNextAvailable();
@@ -74,8 +71,8 @@ public class SocketAppenderTest {
private final LoggerContext context = LoggerContext.getContext();
private final Logger logger = context.getLogger(SocketAppenderTest.class.getName());
- @BeforeClass
- public static void setupClass() throws Exception {
+ @BeforeAll
+ static void setupClass() throws Exception {
tcpServer = new TcpSocketTestServer(PORT);
tcpServer.start();
udpServer = new UdpSocketTestServer();
@@ -84,15 +81,15 @@ public static void setupClass() throws Exception {
ThreadContext.clearAll();
}
- @AfterClass
- public static void cleanupClass() {
+ @AfterAll
+ static void cleanupClass() {
tcpServer.shutdown();
udpServer.shutdown();
ThreadContext.clearAll();
}
- @After
- public void teardown() {
+ @AfterEach
+ void teardown() {
ThreadContext.clearAll();
removeAndStopAppenders();
reset();
@@ -113,13 +110,13 @@ static void reset() {
}
@Test
- public void testTcpAppender1() throws Exception {
+ void testTcpAppender1() throws Exception {
testTcpAppender(tcpServer, logger, Constants.ENCODER_BYTE_BUFFER_SIZE);
}
@Test
- @Ignore("WIP Bug when this method runs after testTcpAppender1()")
- public void testTcpAppender2() throws Exception {
+ @Disabled("WIP Bug when this method runs after testTcpAppender1()")
+ void testTcpAppender2() throws Exception {
testTcpAppender(tcpServer, logger, Constants.ENCODER_BYTE_BUFFER_SIZE);
}
@@ -133,12 +130,11 @@ static void testTcpAppender(final TcpSocketTestServer tcpTestServer, final Logge
.setName("test")
.setImmediateFail(false)
.setBufferSize(bufferSize)
- .setLayout((Layout extends Serializable>)
- JsonLayout.newBuilder().setProperties(true).build())
+ .setLayout(JsonLayout.newBuilder().setProperties(true).build())
.build();
// @formatter:on
appender.start();
- Assert.assertEquals(bufferSize, appender.getManager().getByteBuffer().capacity());
+ assertEquals(bufferSize, appender.getManager().getByteBuffer().capacity());
// set appender on root and set level to debug
logger.addAppender(appender);
@@ -160,29 +156,28 @@ static void testTcpAppender(final TcpSocketTestServer tcpTestServer, final Logge
}
Thread.sleep(250);
LogEvent event = tcpTestServer.getQueue().poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", event);
- assertTrue("Incorrect event", event.getMessage().getFormattedMessage().equals("This is a test message"));
- assertTrue("Message not delivered via TCP", tcpTestServer.getCount() > 0);
+ assertNotNull(event, "No event retrieved");
+ assertEquals("This is a test message", event.getMessage().getFormattedMessage(), "Incorrect event");
+ assertTrue(tcpTestServer.getCount() > 0, "Message not delivered via TCP");
assertEquals(expectedUuidStr, event.getContextData().getValue(tcKey));
event = tcpTestServer.getQueue().poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", event);
- assertTrue("Incorrect event", event.getMessage().getFormattedMessage().equals("Throwing an exception"));
- assertTrue("Message not delivered via TCP", tcpTestServer.getCount() > 1);
+ assertNotNull(event, "No event retrieved");
+ assertEquals("Throwing an exception", event.getMessage().getFormattedMessage(), "Incorrect event");
+ assertTrue(tcpTestServer.getCount() > 1, "Message not delivered via TCP");
assertEquals(expectedUuidStr, event.getContextStack().pop());
assertNotNull(event.getThrownProxy());
assertEquals(expectedExMsg, event.getThrownProxy().getMessage());
}
@Test
- public void testDefaultProtocol() throws Exception {
+ void testDefaultProtocol() {
// @formatter:off
final SocketAppender appender = SocketAppender.newBuilder()
.setPort(tcpServer.getLocalPort())
.setReconnectDelayMillis(-1)
.setName("test")
.setImmediateFail(false)
- .setLayout((Layout extends Serializable>)
- JsonLayout.newBuilder().setProperties(true).build())
+ .setLayout(JsonLayout.newBuilder().setProperties(true).build())
.build();
// @formatter:on
assertNotNull(appender);
@@ -190,7 +185,7 @@ public void testDefaultProtocol() throws Exception {
}
@Test
- public void testUdpAppender() throws Exception {
+ void testUdpAppender() throws Exception {
try {
udpServer.latch.await();
} catch (final InterruptedException ex) {
@@ -204,8 +199,7 @@ public void testUdpAppender() throws Exception {
.setReconnectDelayMillis(-1)
.setName("test")
.setImmediateFail(false)
- .setLayout((Layout extends Serializable>)
- JsonLayout.newBuilder().setProperties(true).build())
+ .setLayout(JsonLayout.newBuilder().setProperties(true).build())
.build();
// @formatter:on
appender.start();
@@ -216,13 +210,13 @@ public void testUdpAppender() throws Exception {
logger.setLevel(Level.DEBUG);
logger.debug("This is a udp message");
final LogEvent event = udpServer.getQueue().poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", event);
- assertTrue("Incorrect event", event.getMessage().getFormattedMessage().equals("This is a udp message"));
- assertTrue("Message not delivered via UDP", udpServer.getCount() > 0);
+ assertNotNull(event, "No event retrieved");
+ assertEquals("This is a udp message", event.getMessage().getFormattedMessage(), "Incorrect event");
+ assertTrue(udpServer.getCount() > 0, "Message not delivered via UDP");
}
@Test
- public void testTcpAppenderDeadlock() throws Exception {
+ void testTcpAppenderDeadlock() throws Exception {
// @formatter:off
final SocketAppender appender = SocketAppender.newBuilder()
@@ -231,8 +225,7 @@ public void testTcpAppenderDeadlock() throws Exception {
.setReconnectDelayMillis(100)
.setName("test")
.setImmediateFail(false)
- .setLayout((Layout extends Serializable>)
- JsonLayout.newBuilder().setProperties(true).build())
+ .setLayout(JsonLayout.newBuilder().setProperties(true).build())
.build();
// @formatter:on
appender.start();
@@ -248,14 +241,14 @@ public void testTcpAppenderDeadlock() throws Exception {
logger.debug("This message is written because a deadlock never.");
final LogEvent event = tcpSocketServer.getQueue().poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", event);
+ assertNotNull(event, "No event retrieved");
} finally {
tcpSocketServer.shutdown();
}
}
@Test
- public void testTcpAppenderNoWait() throws Exception {
+ void testTcpAppenderNoWait() {
// @formatter:off
final SocketAppender appender = SocketAppender.newBuilder()
.setHost("localhost")
@@ -264,8 +257,7 @@ public void testTcpAppenderNoWait() throws Exception {
.setName("test")
.setImmediateFail(false)
.setIgnoreExceptions(false)
- .setLayout((Layout extends Serializable>)
- JsonLayout.newBuilder().setProperties(true).build())
+ .setLayout(JsonLayout.newBuilder().setProperties(true).build())
.build();
// @formatter:on
appender.start();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SyslogAppenderTestBase.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SyslogAppenderTestBase.java
index 4de3e69d298..5af62582bf2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SyslogAppenderTestBase.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SyslogAppenderTestBase.java
@@ -16,9 +16,10 @@
*/
package org.apache.logging.log4j.core.appender;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.Serializable;
import java.util.ArrayList;
@@ -40,11 +41,10 @@
import org.apache.logging.log4j.message.StructuredDataMessage;
import org.apache.logging.log4j.test.junit.UsingStatusListener;
import org.apache.logging.log4j.util.Strings;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeAll;
@UsingStatusListener
-public abstract class SyslogAppenderTestBase {
+abstract class SyslogAppenderTestBase {
protected static final String line1 =
"TestApp - Audit [Transfer@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"]"
+ "[RequestContext@18060 ipAddress=\"192.168.0.120\" loginId=\"JohnDoe\"] Transfer Complete";
@@ -57,7 +57,7 @@ public abstract class SyslogAppenderTestBase {
protected boolean includeNewLine = true;
@BeforeAll
- public static void setupClass() throws Exception {
+ public static void setupClass() {
LoggerContext.getContext().reconfigure();
}
@@ -110,26 +110,26 @@ protected void sendInfoStructuredMessage() {
protected void checkTheNumberOfSentAndReceivedMessages() throws InterruptedException {
assertEquals(
- "The number of received messages should be equal with the number of sent messages",
sentMessages.size(),
- getReceivedMessages(DEFAULT_TIMEOUT_IN_MS).size());
+ getReceivedMessages(DEFAULT_TIMEOUT_IN_MS).size(),
+ "The number of received messages should be equal with the number of sent messages");
}
protected void checkTheEqualityOfSentAndReceivedMessages(final Level expectedLevel) throws InterruptedException {
final List receivedMessages = getReceivedMessages(DEFAULT_TIMEOUT_IN_MS);
- assertNotNull("No messages received", receivedMessages);
+ assertNotNull(receivedMessages, "No messages received");
for (int i = 0; i < receivedMessages.size(); i++) {
final String receivedMessage = receivedMessages.get(i);
final String sentMessage = sentMessages.get(i);
final String suffix = includeNewLine ? "\n" : Strings.EMPTY;
assertTrue(
- "Incorrect message received: " + receivedMessage,
- receivedMessage.endsWith(sentMessage + suffix) || receivedMessage.contains(sentMessage));
+ receivedMessage.endsWith(sentMessage + suffix) || receivedMessage.contains(sentMessage),
+ "Incorrect message received: " + receivedMessage);
final int expectedPriority = Priority.getPriority(getExpectedFacility(), expectedLevel);
assertTrue(
- "Expected facility " + expectedPriority + " in message " + receivedMessage,
- receivedMessage.startsWith("<" + expectedPriority + ">"));
+ receivedMessage.startsWith("<" + expectedPriority + ">"),
+ "Expected facility " + expectedPriority + " in message " + receivedMessage);
}
}
@@ -166,15 +166,15 @@ protected void validate(final SyslogAppender syslogAppender) {
} else if (layout instanceof Rfc5424Layout) {
validate((Rfc5424Layout) layout);
} else {
- Assert.fail("Unexpected layout: " + layout);
+ fail("Unexpected layout: " + layout);
}
}
protected void validate(final Rfc5424Layout layout) {
- Assert.assertEquals(getExpectedFacility(), layout.getFacility());
+ assertEquals(getExpectedFacility(), layout.getFacility());
}
protected void validate(final SyslogLayout layout) {
- Assert.assertEquals(getExpectedFacility(), layout.getFacility());
+ assertEquals(getExpectedFacility(), layout.getFacility());
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/TlsSyslogAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/TlsSyslogAppenderTest.java
index 7294e038ba3..b18673e4be2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/TlsSyslogAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/TlsSyslogAppenderTest.java
@@ -33,7 +33,7 @@
import org.apache.logging.log4j.core.test.net.ssl.TlsSyslogTestUtil;
import org.junit.jupiter.api.Test;
-public class TlsSyslogAppenderTest extends SyslogAppenderTest {
+class TlsSyslogAppenderTest extends SyslogAppenderTest {
private SSLServerSocketFactory serverSocketFactory;
private SslConfiguration sslConfiguration;
@@ -44,7 +44,7 @@ public TlsSyslogAppenderTest() throws StoreConfigurationException {
}
@Test
- public void sendLargeLegacyBsdMessageOverTls() throws IOException, InterruptedException {
+ void sendLargeLegacyBsdMessageOverTls() throws IOException, InterruptedException {
final String prefix = "BEGIN";
initTlsTestEnvironment(1, TlsSyslogMessageFormat.LEGACY_BSD);
@@ -55,7 +55,7 @@ public void sendLargeLegacyBsdMessageOverTls() throws IOException, InterruptedEx
}
@Test
- public void sendLegacyBsdMessagesOverTls() throws IOException, InterruptedException {
+ void sendLegacyBsdMessagesOverTls() throws IOException, InterruptedException {
final int numberOfMessages = 100;
initTlsTestEnvironment(numberOfMessages, TlsSyslogMessageFormat.LEGACY_BSD);
final List generatedMessages =
@@ -64,14 +64,14 @@ public void sendLegacyBsdMessagesOverTls() throws IOException, InterruptedExcept
}
@Test
- public void sendStructuredMessageOverTls() throws InterruptedException, IOException {
+ void sendStructuredMessageOverTls() throws InterruptedException, IOException {
initTlsTestEnvironment(1, TlsSyslogMessageFormat.SYSLOG);
sendAndCheckStructuredMessage();
}
@Test
- public void sendStructuredMessagesOverTls() throws IOException, InterruptedException {
+ void sendStructuredMessagesOverTls() throws IOException, InterruptedException {
final int numberOfMessages = 100;
initTlsTestEnvironment(numberOfMessages, TlsSyslogMessageFormat.SYSLOG);
sendAndCheckStructuredMessages(numberOfMessages);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/TlsSyslogFrameTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/TlsSyslogFrameTest.java
index 670431d5c79..653718d0bf0 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/TlsSyslogFrameTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/TlsSyslogFrameTest.java
@@ -23,11 +23,11 @@
import org.apache.logging.log4j.util.Chars;
import org.junit.jupiter.api.Test;
-public class TlsSyslogFrameTest {
+class TlsSyslogFrameTest {
private static final String TEST_MESSAGE = "The quick brown fox jumps over the lazy dog";
@Test
- public void equals() {
+ void equals() {
final TlsSyslogFrame first = new TlsSyslogFrame(TEST_MESSAGE);
final TlsSyslogFrame second = new TlsSyslogFrame(TEST_MESSAGE);
assertEquals(first, second);
@@ -35,7 +35,7 @@ public void equals() {
}
@Test
- public void notEquals() {
+ void notEquals() {
final TlsSyslogFrame first = new TlsSyslogFrame("A message");
final TlsSyslogFrame second = new TlsSyslogFrame("B message");
assertNotEquals(first, second);
@@ -43,7 +43,7 @@ public void notEquals() {
}
@Test
- public void testToString() {
+ void testToString() {
final TlsSyslogFrame frame = new TlsSyslogFrame(TEST_MESSAGE);
final int length = TEST_MESSAGE.getBytes(StandardCharsets.UTF_8).length;
final String expected = Integer.toString(length) + Chars.SPACE + TEST_MESSAGE;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/WriterAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/WriterAppenderTest.java
index e813ee456eb..37e715216a1 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/WriterAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/WriterAppenderTest.java
@@ -39,7 +39,7 @@
/**
* Tests {@link WriterAppender}.
*/
-public class WriterAppenderTest {
+class WriterAppenderTest {
private static final String TEST_MSG = "FOO ERROR";
@@ -83,31 +83,31 @@ private void addAppender(final Writer writer, final String writerName) {
}
@Test
- public void testWriterAppenderToCharArrayWriter() {
+ void testWriterAppenderToCharArrayWriter() {
test(new CharArrayWriter());
}
@Test
- public void testWriterAppenderToOutputStreamWriter() {
+ void testWriterAppenderToOutputStreamWriter() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final Writer writer = new OutputStreamWriter(out);
test(out, writer);
}
@Test
- public void testWriterAppenderToPrintWriter() {
+ void testWriterAppenderToPrintWriter() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final Writer writer = new PrintWriter(out);
test(out, writer);
}
@Test
- public void testWriterAppenderToStringWriter() {
+ void testWriterAppenderToStringWriter() {
test(new StringWriter());
}
@Test
- public void testBuilder() {
+ void testBuilder() {
// This should compile
WriterAppender.newBuilder()
.setTarget(new StringWriter())
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderTest.java
index f39e40ace3d..731ee7ffa8d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderTest.java
@@ -16,8 +16,10 @@
*/
package org.apache.logging.log4j.core.appender;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
@@ -26,24 +28,23 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.Layouts;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests a "compact" XML file, no extra spaces or end of lines.
*/
-@Category(Layouts.Xml.class)
-public class XmlCompactFileAppenderTest {
+@Tag("Layouts.Xml")
+class XmlCompactFileAppenderTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "XmlCompactFileAppenderTest.xml");
}
@Test
- public void testFlushAtEndOfBatch() throws Exception {
+ void testFlushAtEndOfBatch() throws Exception {
final File file = new File("target", "XmlCompactFileAppenderTest.log");
file.delete();
final Logger log = LogManager.getLogger("com.foo.Bar");
@@ -57,23 +58,23 @@ public void testFlushAtEndOfBatch() throws Exception {
} finally {
file.delete();
}
- assertNotNull("line1", line1);
+ assertNotNull(line1, "line1");
final String msg1 = "";
- assertTrue("line1 incorrect: [" + line1 + "], does not contain: [" + msg1 + ']', line1.contains(msg1));
+ assertTrue(line1.contains(msg1), "line1 incorrect: [" + line1 + "], does not contain: [" + msg1 + ']');
final String msg2 = "";
- assertTrue("line1 incorrect: [" + line1 + "], does not contain: [" + msg2 + ']', line1.contains(msg2));
+ assertTrue(line1.contains(msg2), "line1 incorrect: [" + line1 + "], does not contain: [" + msg2 + ']');
final String msg3 = "";
- assertTrue("line1 incorrect: [" + line1 + "], does not contain: [" + msg1 + ']', line1.equals(msg1));
+ assertEquals("line1 incorrect: [" + line1 + "], does not contain: [" + msg1 + ']', msg1, line1);
assertNotNull("line2", line2);
final String msg2 = "";
- assertTrue("line2 incorrect: [" + line2 + "], does not contain: [" + msg2 + ']', line2.equals(msg2));
+ assertEquals("line2 incorrect: [" + line2 + "], does not contain: [" + msg2 + ']', msg2, line2);
assertNotNull("line3", line3);
final String msg3 = "\n" +
0, // "\n";
};
- final List lines1 = Files.readAllLines(logFile.toPath(), Charset.forName("UTF-8"));
+ final List lines1 = Files.readAllLines(logFile.toPath(), StandardCharsets.UTF_8);
assertEquals("number of lines", indentations.length, lines1.size());
for (int i = 0; i < indentations.length; i++) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlFileAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlFileAppenderTest.java
index ab2a44380d6..ad186d21129 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlFileAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlFileAppenderTest.java
@@ -16,34 +16,34 @@
*/
package org.apache.logging.log4j.core.appender;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.Layouts;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests a "complete" XML file a.k.a. a well-formed XML file.
*/
-@Category(Layouts.Xml.class)
-public class XmlFileAppenderTest {
+@Tag("Layouts.Xml")
+class XmlFileAppenderTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "XmlFileAppenderTest.xml");
}
@Test
- public void testFlushAtEndOfBatch() throws Exception {
+ void testFlushAtEndOfBatch() throws Exception {
final File file = new File("target", "XmlFileAppenderTest.log");
// System.out.println(f.getAbsolutePath());
file.delete();
@@ -52,7 +52,7 @@ public void testFlushAtEndOfBatch() throws Exception {
log.info(logMsg);
CoreLoggerContexts.stopLoggerContext(false, file); // stop async thread
- final List lines = Files.readAllLines(file.toPath(), Charset.forName("UTF8"));
+ final List lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
file.delete();
final String[] expect = {
@@ -65,11 +65,11 @@ public void testFlushAtEndOfBatch() throws Exception {
for (int i = 0; i < expect.length; i++) {
assertTrue(
- "Expected line " + i + " to contain " + expect[i] + " but got: " + lines.get(i),
- lines.get(i).contains(expect[i]));
+ lines.get(i).contains(expect[i]),
+ "Expected line " + i + " to contain " + expect[i] + " but got: " + lines.get(i));
}
final String location = "testFlushAtEndOfBatch";
- assertTrue("no location", !lines.get(0).contains(location));
+ assertFalse(lines.get(0).contains(location), "no location");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java
index 8ede2cdc3e4..fdf2df70843 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java
@@ -26,7 +26,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
-import java.io.Serializable;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LogEvent;
@@ -74,12 +73,12 @@ public void testAppend() {
appender.append(event1);
then(manager).should().isBuffered();
- then(manager).should().writeThrough(same(event1), (Serializable) isNull());
+ then(manager).should().writeThrough(same(event1), isNull());
reset(manager);
appender.append(event2);
then(manager).should().isBuffered();
- then(manager).should().writeThrough(same(event2), (Serializable) isNull());
+ then(manager).should().writeThrough(same(event2), isNull());
reset(manager);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java
index 2af9990f65e..38fad66231c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.logging.log4j.core.appender.db;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.BDDMockito.then;
@@ -31,9 +31,9 @@
import java.io.Serializable;
import org.apache.logging.log4j.core.LogEvent;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class AbstractDatabaseManagerTest {
+class AbstractDatabaseManagerTest {
// this stub is provided because mocking constructors is hard
private static class StubDatabaseManager extends AbstractDatabaseManager {
@@ -52,12 +52,12 @@ protected void connectAndStart() {
}
@Override
- protected boolean shutdownInternal() throws Exception {
+ protected boolean shutdownInternal() {
return true;
}
@Override
- protected void startupInternal() throws Exception {
+ protected void startupInternal() {
// noop
}
@@ -74,7 +74,7 @@ public void setUp(final String name, final int buffer) {
}
@Test
- public void testBuffering01() throws Exception {
+ void testBuffering01() throws Exception {
setUp("name", 0);
final LogEvent event1 = mock(LogEvent.class);
@@ -86,35 +86,35 @@ public void testBuffering01() throws Exception {
reset(manager);
manager.write(event1, null);
- then(manager).should().writeThrough(same(event1), (Serializable) isNull());
+ then(manager).should().writeThrough(same(event1), isNull());
then(manager).should().connectAndStart();
then(manager).should().isBuffered();
- then(manager).should().writeInternal(same(event1), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event1), isNull());
then(manager).should().commitAndClose();
then(manager).shouldHaveNoMoreInteractions();
reset(manager);
manager.write(event2, null);
- then(manager).should().writeThrough(same(event2), (Serializable) isNull());
+ then(manager).should().writeThrough(same(event2), isNull());
then(manager).should().connectAndStart();
then(manager).should().isBuffered();
- then(manager).should().writeInternal(same(event2), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event2), isNull());
then(manager).should().commitAndClose();
then(manager).shouldHaveNoMoreInteractions();
reset(manager);
manager.write(event3, null);
- then(manager).should().writeThrough(same(event3), (Serializable) isNull());
+ then(manager).should().writeThrough(same(event3), isNull());
then(manager).should().connectAndStart();
then(manager).should().isBuffered();
- then(manager).should().writeInternal(same(event3), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event3), isNull());
then(manager).should().commitAndClose();
then(manager).shouldHaveNoMoreInteractions();
reset(manager);
}
@Test
- public void testBuffering02() throws Exception {
+ void testBuffering02() throws Exception {
setUp("name", 4);
final LogEvent event1 = mock(LogEvent.class);
@@ -142,20 +142,20 @@ public void testBuffering02() throws Exception {
then(manager).should().connectAndStart();
verify(manager, times(5)).isBuffered(); // 4 + 1 in flush()
- then(manager).should().writeInternal(same(event1copy), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event1copy), isNull());
then(manager).should().buffer(event1);
- then(manager).should().writeInternal(same(event2copy), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event2copy), isNull());
then(manager).should().buffer(event2);
- then(manager).should().writeInternal(same(event3copy), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event3copy), isNull());
then(manager).should().buffer(event3);
- then(manager).should().writeInternal(same(event4copy), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event4copy), isNull());
then(manager).should().buffer(event4);
then(manager).should().commitAndClose();
then(manager).shouldHaveNoMoreInteractions();
}
@Test
- public void testBuffering03() throws Exception {
+ void testBuffering03() throws Exception {
setUp("name", 10);
final LogEvent event1 = mock(LogEvent.class);
@@ -180,18 +180,18 @@ public void testBuffering03() throws Exception {
then(manager).should().connectAndStart();
verify(manager, times(4)).isBuffered();
- then(manager).should().writeInternal(same(event1copy), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event1copy), isNull());
then(manager).should().buffer(event1);
- then(manager).should().writeInternal(same(event2copy), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event2copy), isNull());
then(manager).should().buffer(event2);
- then(manager).should().writeInternal(same(event3copy), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event3copy), isNull());
then(manager).should().buffer(event3);
then(manager).should().commitAndClose();
then(manager).shouldHaveNoMoreInteractions();
}
@Test
- public void testBuffering04() throws Exception {
+ void testBuffering04() throws Exception {
setUp("name", 10);
final LogEvent event1 = mock(LogEvent.class);
@@ -216,11 +216,11 @@ public void testBuffering04() throws Exception {
then(manager).should().connectAndStart();
verify(manager, times(4)).isBuffered();
- then(manager).should().writeInternal(same(event1copy), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event1copy), isNull());
then(manager).should().buffer(event1);
- then(manager).should().writeInternal(same(event2copy), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event2copy), isNull());
then(manager).should().buffer(event2);
- then(manager).should().writeInternal(same(event3copy), (Serializable) isNull());
+ then(manager).should().writeInternal(same(event3copy), isNull());
then(manager).should().buffer(event3);
then(manager).should().commitAndClose();
then(manager).should().shutdownInternal();
@@ -228,48 +228,48 @@ public void testBuffering04() throws Exception {
}
@Test
- public void testStartupShutdown01() throws Exception {
+ void testStartupShutdown01() throws Exception {
setUp("testName01", 0);
- assertEquals("The name is not correct.", "testName01", manager.getName());
- assertFalse("The manager should not have started.", manager.isRunning());
+ assertEquals("testName01", manager.getName(), "The name is not correct.");
+ assertFalse(manager.isRunning(), "The manager should not have started.");
manager.startup();
then(manager).should().startupInternal();
- assertTrue("The manager should be running now.", manager.isRunning());
+ assertTrue(manager.isRunning(), "The manager should be running now.");
manager.shutdown();
then(manager).should().shutdownInternal();
- assertFalse("The manager should not be running anymore.", manager.isRunning());
+ assertFalse(manager.isRunning(), "The manager should not be running anymore.");
}
@Test
- public void testStartupShutdown02() throws Exception {
+ void testStartupShutdown02() throws Exception {
setUp("anotherName02", 0);
- assertEquals("The name is not correct.", "anotherName02", manager.getName());
- assertFalse("The manager should not have started.", manager.isRunning());
+ assertEquals("anotherName02", manager.getName(), "The name is not correct.");
+ assertFalse(manager.isRunning(), "The manager should not have started.");
manager.startup();
then(manager).should().startupInternal();
- assertTrue("The manager should be running now.", manager.isRunning());
+ assertTrue(manager.isRunning(), "The manager should be running now.");
manager.releaseSub(-1, null);
then(manager).should().shutdownInternal();
- assertFalse("The manager should not be running anymore.", manager.isRunning());
+ assertFalse(manager.isRunning(), "The manager should not be running anymore.");
}
@Test
- public void testToString01() {
+ void testToString01() {
setUp("someName01", 0);
- assertEquals("The string is not correct.", "someName01", manager.toString());
+ assertEquals("someName01", manager.toString(), "The string is not correct.");
}
@Test
- public void testToString02() {
+ void testToString02() {
setUp("bufferSize=12, anotherKey02=coolValue02", 12);
- assertEquals("The string is not correct.", "bufferSize=12, anotherKey02=coolValue02", manager.toString());
+ assertEquals("bufferSize=12, anotherKey02=coolValue02", manager.toString(), "The string is not correct.");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcDataSourceTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcDataSourceTest.java
index fad3411bbba..4167bdc678c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcDataSourceTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcDataSourceTest.java
@@ -26,12 +26,12 @@
public abstract class AbstractJdbcDataSourceTest {
@AfterClass
- public static void afterClass() throws Exception {
+ public static void afterClass() {
System.clearProperty("log4j2.enableJndiJdbc");
}
@BeforeClass
- public static void beforeClass() throws Exception {
+ public static void beforeClass() {
System.setProperty("log4j2.enableJndiJdbc", "true");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfigTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfigTest.java
index af816eb47b4..a27e5ce9adb 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfigTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfigTest.java
@@ -16,76 +16,76 @@
*/
package org.apache.logging.log4j.core.appender.db.jdbc;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.logging.log4j.util.Strings;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ColumnConfigTest {
+class ColumnConfigTest {
@Test
- public void testNullNameNoConfig() {
+ void testNullNameNoConfig() {
final ColumnConfig config = ColumnConfig.newBuilder().setPattern("%l").build();
- assertNull("The result should be null.", config);
+ assertNull(config, "The result should be null.");
}
@Test
- public void testPatternAndLiteralNoConfig() {
+ void testPatternAndLiteralNoConfig() {
final ColumnConfig config = ColumnConfig.newBuilder()
.setName("col")
.setPattern("%l")
.setLiteral("literal")
.build();
- assertNull("The result should be null.", config);
+ assertNull(config, "The result should be null.");
}
@Test
- public void testPatternAndDateNoConfig() {
+ void testPatternAndDateNoConfig() {
final ColumnConfig config = ColumnConfig.newBuilder()
.setName("col")
.setPattern("%l")
.setEventTimestamp(true)
.build();
- assertNull("The result should be null.", config);
+ assertNull(config, "The result should be null.");
}
@Test
- public void testLiteralAndDateNoConfig() {
+ void testLiteralAndDateNoConfig() {
final ColumnConfig config = ColumnConfig.newBuilder()
.setName("col")
.setLiteral("literal")
.setEventTimestamp(true)
.build();
- assertNull("The result should be null.", config);
+ assertNull(config, "The result should be null.");
}
@Test
- public void testNoSettingNoConfig01() {
+ void testNoSettingNoConfig01() {
final ColumnConfig config = ColumnConfig.newBuilder().setName("col").build();
- assertNull("The result should be null.", config);
+ assertNull(config, "The result should be null.");
}
@Test
- public void testNoSettingNoConfig02() {
+ void testNoSettingNoConfig02() {
final ColumnConfig config = ColumnConfig.newBuilder()
.setName("col")
.setEventTimestamp(false)
.build();
- assertNull("The result should be null.", config);
+ assertNull(config, "The result should be null.");
}
@Test
- public void testNoSettingNoConfig03() {
+ void testNoSettingNoConfig03() {
final ColumnConfig config = ColumnConfig.newBuilder()
.setName("col")
.setPattern(Strings.EMPTY)
@@ -93,25 +93,25 @@ public void testNoSettingNoConfig03() {
.setEventTimestamp(false)
.build();
- assertNull("The result should be null.", config);
+ assertNull(config, "The result should be null.");
}
@Test
- public void testDateColumn01() {
+ void testDateColumn01() {
final ColumnConfig config =
ColumnConfig.newBuilder().setName("col").setEventTimestamp(true).build();
- assertNotNull("The result should not be null.", config);
- assertEquals("The column name is not correct.", "col", config.getColumnName());
- assertNull("The pattern should be null.", config.getLayout());
- assertNull("The literal value should be null.", config.getLiteralValue());
- assertTrue("The timestamp flag should be true.", config.isEventTimestamp());
- assertFalse("The unicode flag should be false.", config.isUnicode());
- assertFalse("The clob flag should be false.", config.isClob());
+ assertNotNull(config, "The result should not be null.");
+ assertEquals("col", config.getColumnName(), "The column name is not correct.");
+ assertNull(config.getLayout(), "The pattern should be null.");
+ assertNull(config.getLiteralValue(), "The literal value should be null.");
+ assertTrue(config.isEventTimestamp(), "The timestamp flag should be true.");
+ assertFalse(config.isUnicode(), "The unicode flag should be false.");
+ assertFalse(config.isClob(), "The clob flag should be false.");
}
@Test
- public void testDateColumn02() {
+ void testDateColumn02() {
final ColumnConfig config = ColumnConfig.newBuilder()
.setName("col2")
.setEventTimestamp(true)
@@ -119,32 +119,32 @@ public void testDateColumn02() {
.setClob(true)
.build();
- assertNotNull("The result should not be null.", config);
- assertEquals("The column name is not correct.", "col2", config.getColumnName());
- assertNull("The pattern should be null.", config.getLayout());
- assertNull("The literal value should be null.", config.getLiteralValue());
- assertTrue("The timestamp flag should be true.", config.isEventTimestamp());
- assertFalse("The unicode flag should be false.", config.isUnicode());
- assertFalse("The clob flag should be false.", config.isClob());
+ assertNotNull(config, "The result should not be null.");
+ assertEquals("col2", config.getColumnName(), "The column name is not correct.");
+ assertNull(config.getLayout(), "The pattern should be null.");
+ assertNull(config.getLiteralValue(), "The literal value should be null.");
+ assertTrue(config.isEventTimestamp(), "The timestamp flag should be true.");
+ assertFalse(config.isUnicode(), "The unicode flag should be false.");
+ assertFalse(config.isClob(), "The clob flag should be false.");
}
@Test
- public void testPatternColumn01() {
+ void testPatternColumn01() {
final ColumnConfig config =
ColumnConfig.newBuilder().setName("col").setPattern("%l").build();
- assertNotNull("The result should not be null.", config);
- assertEquals("The column name is not correct.", "col", config.getColumnName());
- assertNotNull("The pattern should not be null.", config.getLayout());
- assertEquals("The pattern is not correct.", "%l", config.getLayout().toString());
- assertNull("The literal value should be null.", config.getLiteralValue());
- assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
- assertTrue("The unicode flag should be true.", config.isUnicode());
- assertFalse("The clob flag should be false.", config.isClob());
+ assertNotNull(config, "The result should not be null.");
+ assertEquals("col", config.getColumnName(), "The column name is not correct.");
+ assertNotNull(config.getLayout(), "The pattern should not be null.");
+ assertEquals("%l", config.getLayout().toString(), "The pattern is not correct.");
+ assertNull(config.getLiteralValue(), "The literal value should be null.");
+ assertFalse(config.isEventTimestamp(), "The timestamp flag should be false.");
+ assertTrue(config.isUnicode(), "The unicode flag should be true.");
+ assertFalse(config.isClob(), "The clob flag should be false.");
}
@Test
- public void testPatternColumn02() {
+ void testPatternColumn02() {
final ColumnConfig config = ColumnConfig.newBuilder()
.setName("col2")
.setPattern("%X{id} %level")
@@ -154,21 +154,18 @@ public void testPatternColumn02() {
.setClob(true)
.build();
- assertNotNull("The result should not be null.", config);
- assertEquals("The column name is not correct.", "col2", config.getColumnName());
- assertNotNull("The pattern should not be null.", config.getLayout());
- assertEquals(
- "The pattern is not correct.",
- "%X{id} %level",
- config.getLayout().toString());
- assertNull("The literal value should be null.", config.getLiteralValue());
- assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
- assertFalse("The unicode flag should be false.", config.isUnicode());
- assertTrue("The clob flag should be true.", config.isClob());
+ assertNotNull(config, "The result should not be null.");
+ assertEquals("col2", config.getColumnName(), "The column name is not correct.");
+ assertNotNull(config.getLayout(), "The pattern should not be null.");
+ assertEquals("%X{id} %level", config.getLayout().toString(), "The pattern is not correct.");
+ assertNull(config.getLiteralValue(), "The literal value should be null.");
+ assertFalse(config.isEventTimestamp(), "The timestamp flag should be false.");
+ assertFalse(config.isUnicode(), "The unicode flag should be false.");
+ assertTrue(config.isClob(), "The clob flag should be true.");
}
@Test
- public void testPatternColumn03() {
+ void testPatternColumn03() {
final ColumnConfig config = ColumnConfig.newBuilder()
.setName("col3")
.setPattern("%X{id} %level")
@@ -178,38 +175,35 @@ public void testPatternColumn03() {
.setClob(false)
.build();
- assertNotNull("The result should not be null.", config);
- assertEquals("The column name is not correct.", "col3", config.getColumnName());
- assertNotNull("The pattern should not be null.", config.getLayout());
- assertEquals(
- "The pattern is not correct.",
- "%X{id} %level",
- config.getLayout().toString());
- assertNull("The literal value should be null.", config.getLiteralValue());
- assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
- assertTrue("The unicode flag should be true.", config.isUnicode());
- assertFalse("The clob flag should be false.", config.isClob());
+ assertNotNull(config, "The result should not be null.");
+ assertEquals("col3", config.getColumnName(), "The column name is not correct.");
+ assertNotNull(config.getLayout(), "The pattern should not be null.");
+ assertEquals("%X{id} %level", config.getLayout().toString(), "The pattern is not correct.");
+ assertNull(config.getLiteralValue(), "The literal value should be null.");
+ assertFalse(config.isEventTimestamp(), "The timestamp flag should be false.");
+ assertTrue(config.isUnicode(), "The unicode flag should be true.");
+ assertFalse(config.isClob(), "The clob flag should be false.");
}
@Test
- public void testLiteralColumn01() {
+ void testLiteralColumn01() {
final ColumnConfig config = ColumnConfig.newBuilder()
.setName("col")
.setLiteral("literalValue01")
.build();
- assertNotNull("The result should not be null.", config);
- assertEquals("The column name is not correct.", "col", config.getColumnName());
- assertNull("The pattern should be null.", config.getLayout());
- assertNotNull("The literal value should be null.", config.getLiteralValue());
- assertEquals("The literal value is not correct.", "literalValue01", config.getLiteralValue());
- assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
- assertFalse("The unicode flag should be false.", config.isUnicode());
- assertFalse("The clob flag should be false.", config.isClob());
+ assertNotNull(config, "The result should not be null.");
+ assertEquals("col", config.getColumnName(), "The column name is not correct.");
+ assertNull(config.getLayout(), "The pattern should be null.");
+ assertNotNull(config.getLiteralValue(), "The literal value should be null.");
+ assertEquals("literalValue01", config.getLiteralValue(), "The literal value is not correct.");
+ assertFalse(config.isEventTimestamp(), "The timestamp flag should be false.");
+ assertFalse(config.isUnicode(), "The unicode flag should be false.");
+ assertFalse(config.isClob(), "The clob flag should be false.");
}
@Test
- public void testLiteralColumn02() {
+ void testLiteralColumn02() {
final ColumnConfig config = ColumnConfig.newBuilder()
.setName("col2")
.setLiteral("USER1.MY_SEQUENCE.NEXT")
@@ -217,13 +211,13 @@ public void testLiteralColumn02() {
.setClob(true)
.build();
- assertNotNull("The result should not be null.", config);
- assertEquals("The column name is not correct.", "col2", config.getColumnName());
- assertNull("The pattern should be null.", config.getLayout());
- assertNotNull("The literal value should be null.", config.getLiteralValue());
- assertEquals("The literal value is not correct.", "USER1.MY_SEQUENCE.NEXT", config.getLiteralValue());
- assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
- assertFalse("The unicode flag should be false.", config.isUnicode());
- assertFalse("The clob flag should be false.", config.isClob());
+ assertNotNull(config, "The result should not be null.");
+ assertEquals("col2", config.getColumnName(), "The column name is not correct.");
+ assertNull(config.getLayout(), "The pattern should be null.");
+ assertNotNull(config.getLiteralValue(), "The literal value should be null.");
+ assertEquals("USER1.MY_SEQUENCE.NEXT", config.getLiteralValue(), "The literal value is not correct.");
+ assertFalse(config.isEventTimestamp(), "The timestamp flag should be false.");
+ assertFalse(config.isUnicode(), "The unicode flag should be false.");
+ assertFalse(config.isClob(), "The clob flag should be false.");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderStringSubstitutionTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderStringSubstitutionTest.java
index 3578e1a9788..693aa835797 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderStringSubstitutionTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderStringSubstitutionTest.java
@@ -41,7 +41,7 @@ public static void afterClass() {
new LoggerContextRule("org/apache/logging/log4j/core/appender/db/jdbc/log4j2-jdbc-string-substitution.xml");
@Test
- public void test() throws Exception {
+ public void test() {
final JdbcAppender appender = rule.getAppender("databaseAppender", JdbcAppender.class);
Assert.assertNotNull(appender);
final JdbcDatabaseManager manager = appender.getManager();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/JmsAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/JmsAppenderTest.java
index ce16f06df14..5507c33075b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/JmsAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/JmsAppenderTest.java
@@ -83,12 +83,12 @@ public class JmsAppenderTest {
public RuleChain rules = RuleChain.outerRule(jndiRule).around(ctx);
@AfterClass
- public static void afterClass() throws Exception {
+ public static void afterClass() {
System.clearProperty("log4j2.enableJndiJms");
}
@BeforeClass
- public static void beforeClass() throws Exception {
+ public static void beforeClass() {
System.setProperty("log4j2.enableJndiJms", "true");
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqAppenderTest.java
index 57ac558b189..9bd516daa48 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqAppenderTest.java
@@ -51,7 +51,7 @@
@Timeout(value = 20, unit = TimeUnit.SECONDS)
@UsingStatusListener
@LoggerContextSource(value = "JeroMqAppenderTest.xml", timeout = 60)
-public class JeroMqAppenderTest {
+class JeroMqAppenderTest {
private static final Logger LOGGER = StatusLogger.getLogger();
@@ -60,14 +60,14 @@ public class JeroMqAppenderTest {
private static final int DEFAULT_TIMEOUT_MS = 5000;
@Test
- public void testAppenderLifeCycle() throws Exception {
+ void testAppenderLifeCycle() {
// do nothing to make sure the appender starts and stops without
// locking up resources.
assertNotNull(JeroMqManager.getContext());
}
@Test
- public void testClientServer(@Named(APPENDER_NAME) final JeroMqAppender appender, final LoggerContext ctx)
+ void testClientServer(@Named(APPENDER_NAME) final JeroMqAppender appender, final LoggerContext ctx)
throws Exception {
addLoggingFilter(appender);
final Logger logger = ctx.getLogger(getClass());
@@ -106,7 +106,7 @@ public void testClientServer(@Named(APPENDER_NAME) final JeroMqAppender appender
}
@Test
- public void testMultiThreadedServer(@Named(APPENDER_NAME) final JeroMqAppender appender, final LoggerContext ctx)
+ void testMultiThreadedServer(@Named(APPENDER_NAME) final JeroMqAppender appender, final LoggerContext ctx)
throws Exception {
addLoggingFilter(appender);
final Logger logger = ctx.getLogger(getClass());
@@ -159,7 +159,7 @@ public void testMultiThreadedServer(@Named(APPENDER_NAME) final JeroMqAppender a
}
@Test
- public void testServerOnly(@Named(APPENDER_NAME) final JeroMqAppender appender, final LoggerContext ctx) {
+ void testServerOnly(@Named(APPENDER_NAME) final JeroMqAppender appender, final LoggerContext ctx) {
addLoggingFilter(appender);
final Logger logger = ctx.getLogger(getClass());
appender.resetSendRcs();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqTestClient.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqTestClient.java
index 5ae48f6c186..c40514e93b9 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqTestClient.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqTestClient.java
@@ -42,7 +42,7 @@ class JeroMqTestClient implements Callable> {
}
@Override
- public List call() throws Exception {
+ public List call() {
try (final ZMQ.Socket subscriber = context.socket(SocketType.SUB)) {
LOGGER.info("Starting JeroMqTestClient.");
subscriber.connect(endpoint);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderCloseTimeoutTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderCloseTimeoutTest.java
index b150e9f5ec7..3a54a91d0ab 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderCloseTimeoutTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderCloseTimeoutTest.java
@@ -66,7 +66,7 @@ public void close(final long timeout, final TimeUnit timeUnit) {
};
@BeforeClass
- public static void setUpClass() throws Exception {
+ public static void setUpClass() {
KafkaManager.producerFactory = config -> kafka;
}
@@ -74,12 +74,12 @@ public static void setUpClass() throws Exception {
public LoggerContextRule ctx = new LoggerContextRule("KafkaAppenderCloseTimeoutTest.xml");
@Before
- public void setUp() throws Exception {
+ public void setUp() {
kafka.clear();
}
@Test(timeout = 2000)
- public void testClose() throws Exception {
+ public void testClose() {
final Appender appender = ctx.getRequiredAppender("KafkaAppender");
appender.stop();
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderTest.java
index ac69d2e9445..ef8c24edf00 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderTest.java
@@ -75,7 +75,6 @@ public synchronized Future send(final ProducerRecord kafka;
}
@@ -110,12 +109,12 @@ public static void setUpClass() throws Exception {
public LoggerContextRule ctx = new LoggerContextRule("KafkaAppenderTest.xml");
@Before
- public void setUp() throws Exception {
+ public void setUp() {
kafka.clear();
}
@Test
- public void testAppendWithLayout() throws Exception {
+ public void testAppendWithLayout() {
final Appender appender = ctx.getRequiredAppender("KafkaAppenderWithLayout");
appender.append(createLogEvent());
final List> history = kafka.history();
@@ -128,7 +127,7 @@ public void testAppendWithLayout() throws Exception {
}
@Test
- public void testAppendWithSerializedLayout() throws Exception {
+ public void testAppendWithSerializedLayout() {
final Appender appender = ctx.getRequiredAppender("KafkaAppenderWithSerializedLayout");
final LogEvent logEvent = createLogEvent();
appender.append(logEvent);
@@ -144,7 +143,7 @@ public void testAppendWithSerializedLayout() throws Exception {
}
@Test
- public void testAsyncAppend() throws Exception {
+ public void testAsyncAppend() {
final Appender appender = ctx.getRequiredAppender("AsyncKafkaAppender");
appender.append(createLogEvent());
final List> history = kafka.history();
@@ -157,7 +156,7 @@ public void testAsyncAppend() throws Exception {
}
@Test
- public void testAppendWithKey() throws Exception {
+ public void testAppendWithKey() {
final Appender appender = ctx.getRequiredAppender("KafkaAppenderWithKey");
final LogEvent logEvent = createLogEvent();
appender.append(logEvent);
@@ -173,7 +172,7 @@ public void testAppendWithKey() throws Exception {
}
@Test
- public void testAppendWithKeyLookup() throws Exception {
+ public void testAppendWithKeyLookup() {
final Appender appender = ctx.getRequiredAppender("KafkaAppenderWithKeyLookup");
final LogEvent logEvent = createLogEvent();
final Date date = new Date();
@@ -208,7 +207,7 @@ public void testAppendWithRetryCount() {
}
@Test
- public void testAppenderNoEventTimestamp() throws Exception {
+ public void testAppenderNoEventTimestamp() {
final Appender appender = ctx.getRequiredAppender("KafkaAppenderNoEventTimestamp");
final LogEvent logEvent = createLogEvent();
appender.append(logEvent);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManagerProducerThreadLeakTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManagerProducerThreadLeakTest.java
index 3982a6e0653..9e4b6b14a79 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManagerProducerThreadLeakTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManagerProducerThreadLeakTest.java
@@ -16,12 +16,11 @@
*/
package org.apache.logging.log4j.core.appender.mom.kafka;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.test.categories.Appenders;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
/**
@@ -30,7 +29,7 @@
*
* @see LOG4J2-2916
*/
-@Category(Appenders.Kafka.class)
+@Tag("Appenders.Kafka")
@LoggerContextSource("KafkaManagerProducerThreadLeakTest.xml")
class KafkaManagerProducerThreadLeakTest {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlAppenderTest.java
index 496415f9ca8..c3e33ffaf64 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlAppenderTest.java
@@ -16,51 +16,51 @@
*/
package org.apache.logging.log4j.core.appender.nosql;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
-public class NoSqlAppenderTest {
+@ExtendWith(MockitoExtension.class)
+class NoSqlAppenderTest {
@Mock
private NoSqlProvider> provider;
@Test
- public void testNoProvider() {
+ void testNoProvider() {
final NoSqlAppender appender = NoSqlAppender.createAppender("myName01", null, null, null, null);
- assertNull("The appender should be null.", appender);
+ assertNull(appender, "The appender should be null.");
}
@Test
- public void testProvider() {
+ void testProvider() {
final NoSqlAppender appender = NoSqlAppender.createAppender("myName01", null, null, null, provider);
- assertNotNull("The appender should not be null.", appender);
+ assertNotNull(appender, "The appender should not be null.");
assertEquals(
- "The toString value is not correct.",
"myName01{ manager=noSqlManager{ description=myName01, bufferSize=0, provider=" + provider + " } }",
- appender.toString());
+ appender.toString(),
+ "The toString value is not correct.");
appender.stop();
}
@Test
- public void testProviderBuffer() {
+ void testProviderBuffer() {
final NoSqlAppender appender = NoSqlAppender.createAppender("anotherName02", null, null, "25", provider);
- assertNotNull("The appender should not be null.", appender);
+ assertNotNull(appender, "The appender should not be null.");
assertEquals(
- "The toString value is not correct.",
"anotherName02{ manager=noSqlManager{ description=anotherName02, bufferSize=25, provider=" + provider
+ " } }",
- appender.toString());
+ appender.toString(),
+ "The toString value is not correct.");
appender.stop();
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/LoggerNameLevelRewritePolicyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/LoggerNameLevelRewritePolicyTest.java
index 89c4e2eb448..69f67c82d91 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/LoggerNameLevelRewritePolicyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/LoggerNameLevelRewritePolicyTest.java
@@ -30,10 +30,10 @@
*
* @since 2.4
*/
-public class LoggerNameLevelRewritePolicyTest {
+class LoggerNameLevelRewritePolicyTest {
@Test
- public void testUpdate() {
+ void testUpdate() {
final KeyValuePair[] rewrite =
new KeyValuePair[] {new KeyValuePair("INFO", "DEBUG"), new KeyValuePair("WARN", "INFO")};
final String loggerNameRewrite = "com.foo.bar";
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
index cf59e7ad3d4..5401b8317e0 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
@@ -40,14 +40,14 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-public class MapRewritePolicyTest {
+class MapRewritePolicyTest {
private static final StringMap stringMap = ContextDataFactory.createContextData();
private static Map map = new HashMap<>();
private static KeyValuePair[] rewrite;
private static LogEvent logEvent0, logEvent1, logEvent2, logEvent3;
@BeforeAll
- public static void setupClass() {
+ static void setupClass() {
stringMap.putValue("test1", "one");
stringMap.putValue("test2", "two");
map = stringMap.toMap();
@@ -91,7 +91,7 @@ public static void setupClass() {
}
@Test
- public void addTest() {
+ void addTest() {
final MapRewritePolicy addPolicy = MapRewritePolicy.createPolicy("Add", rewrite);
LogEvent rewritten = addPolicy.rewrite(logEvent0);
compareLogEvents(logEvent0, rewritten);
@@ -111,7 +111,7 @@ public void addTest() {
}
@Test
- public void updateTest() {
+ void updateTest() {
final MapRewritePolicy updatePolicy = MapRewritePolicy.createPolicy("Update", rewrite);
LogEvent rewritten = updatePolicy.rewrite(logEvent0);
compareLogEvents(logEvent0, rewritten);
@@ -131,7 +131,7 @@ public void updateTest() {
}
@Test
- public void defaultIsAdd() {
+ void defaultIsAdd() {
final MapRewritePolicy addPolicy = MapRewritePolicy.createPolicy(null, rewrite);
LogEvent rewritten = addPolicy.rewrite(logEvent0);
compareLogEvents(logEvent0, rewritten);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
index 16ce2793a9f..226b1952c3b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
@@ -41,7 +41,7 @@
import org.junit.jupiter.api.Test;
@LoggerContextSource("log4j-rewrite.xml")
-public class RewriteAppenderTest {
+class RewriteAppenderTest {
private final ListAppender app;
private final ListAppender app2;
@@ -51,7 +51,7 @@ public RewriteAppenderTest(@Named("List") final ListAppender app, @Named("List2"
}
@Test
- public void rewriteTest() {
+ void rewriteTest() {
final StructuredDataMessage msg = new StructuredDataMessage("Test", "This is a test", "Service");
msg.put("Key1", "Value1");
msg.put("Key2", "Value2");
@@ -70,19 +70,19 @@ public void rewriteTest() {
}
@Test
- public void testProperties(final LoggerContext context) {
+ void testProperties(final LoggerContext context) {
final Logger logger = context.getLogger(RewriteAppenderTest.class);
logger.debug("Test properties rewrite");
final List list = app2.getMessages();
assertThat(list, hasSize(1));
assertThat(list.get(0), not(containsString("{user.dir}")));
assertNotNull(list, "No events generated");
- assertEquals(list.size(), 1, "Incorrect number of events. Expected 1, got " + list.size());
+ assertEquals(1, list.size(), "Incorrect number of events. Expected 1, got " + list.size());
assertFalse(list.get(0).contains("{user."), "Did not resolve user name");
}
@Test
- public void testFilter(final LoggerContext context) {
+ void testFilter(final LoggerContext context) {
StructuredDataMessage msg = new StructuredDataMessage("Test", "This is a test", "Service");
msg.put("Key1", "Value2");
msg.put("Key2", "Value1");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/CronTriggeringPolicyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/CronTriggeringPolicyTest.java
index d967c4cdeaa..1b6fc7edd80 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/CronTriggeringPolicyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/CronTriggeringPolicyTest.java
@@ -26,7 +26,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class CronTriggeringPolicyTest {
+class CronTriggeringPolicyTest {
private static final String CRON_EXPRESSION = "0 0 0 * * ?";
@@ -37,7 +37,7 @@ public class CronTriggeringPolicyTest {
// public CleanFiles cleanFiles = new CleanFiles("testcmd1.log", "testcmd2.log", "testcmd3.log");
@BeforeEach
- public void before() {
+ void before() {
configuration = new NullConfiguration();
}
@@ -68,7 +68,7 @@ private void testBuilder() {
* true.
*/
@Test
- public void testBuilderOnce() {
+ void testBuilderOnce() {
testBuilder();
}
@@ -76,7 +76,7 @@ public void testBuilderOnce() {
* Tests LOG4J2-1740 Add CronTriggeringPolicy programmatically leads to NPE
*/
@Test
- public void testLoggerContextAndBuilder() {
+ void testLoggerContextAndBuilder() {
Configurator.initialize(configuration);
testBuilder();
}
@@ -85,7 +85,7 @@ public void testLoggerContextAndBuilder() {
* Tests LOG4J2-1740 Add CronTriggeringPolicy programmatically leads to NPE
*/
@Test
- public void testRollingRandomAccessFileAppender() {
+ void testRollingRandomAccessFileAppender() {
// @formatter:off
RollingRandomAccessFileAppender.newBuilder()
.setName("test2")
@@ -103,7 +103,7 @@ public void testRollingRandomAccessFileAppender() {
* true.
*/
@Test
- public void testBuilderSequence() {
+ void testBuilderSequence() {
testBuilder();
testBuilder();
}
@@ -139,12 +139,12 @@ private void testFactoryMethod() {
* true.
*/
@Test
- public void testFactoryMethodOnce() {
+ void testFactoryMethodOnce() {
testFactoryMethod();
}
@Test
- public void testFactoryMethodSequence() {
+ void testFactoryMethodSequence() {
testFactoryMethod();
testFactoryMethod();
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/EligibleFilesTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/EligibleFilesTest.java
index ec3600d9e6a..e0b7c487f2e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/EligibleFilesTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/EligibleFilesTest.java
@@ -17,7 +17,7 @@
package org.apache.logging.log4j.core.appender.rolling;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import java.nio.file.Path;
import java.util.Map;
@@ -27,24 +27,24 @@
/**
* Test getEligibleFiles method.
*/
-public class EligibleFilesTest {
+class EligibleFilesTest {
@Test
- public void runTest() throws Exception {
+ void runTest() {
final String path = "target/test-classes/rolloverPath/log4j.txt.20170112_09-" + NotANumber.VALUE + ".gz";
final TestRolloverStrategy strategy = new TestRolloverStrategy();
final Map files = strategy.findFilesInPath(path);
- assertTrue(files.size() > 0, "No files found");
+ assertFalse(files.isEmpty(), "No files found");
assertEquals(30, files.size(), "Incorrect number of files found. Should be 30, was " + files.size());
}
@Test
- public void runTestWithPlusCharacter() throws Exception {
+ void runTestWithPlusCharacter() {
final String path =
"target/test-classes/rolloverPath/log4j.20211028T194500+0200." + NotANumber.VALUE + ".log.gz";
final TestRolloverStrategy strategy = new TestRolloverStrategy();
final Map files = strategy.findFilesWithPlusInPath(path);
- assertTrue(files.size() > 0, "No files found");
+ assertFalse(files.isEmpty(), "No files found");
assertEquals(30, files.size(), "Incorrect number of files found. Should be 30, was " + files.size());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/FileSizeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/FileSizeTest.java
index beca4274495..9d48e6492cb 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/FileSizeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/FileSizeTest.java
@@ -24,7 +24,7 @@
/**
* Tests {@link FileSize}.
*/
-public class FileSizeTest {
+class FileSizeTest {
@ParameterizedTest(name = "[{index}] \"{0}\" -> {1}")
@CsvSource(
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
index ef769ff5841..74820472375 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
@@ -42,7 +42,7 @@
/**
* Tests {@link OnStartupTriggeringPolicy}.
*/
-public class OnStartupTriggeringPolicyTest {
+class OnStartupTriggeringPolicyTest {
private static final String TARGET_PATTERN = "/test1-%d{MM-dd-yyyy}-%i.log";
private static final String TEST_DATA = "Hello world!";
@@ -52,7 +52,7 @@ public class OnStartupTriggeringPolicyTest {
Path tempDir;
@Test
- public void testPolicy() throws Exception {
+ void testPolicy() throws Exception {
final Configuration configuration = new DefaultConfiguration();
final Path target = tempDir.resolve("testfile");
final long timeStamp = Instant.now().minus(Duration.ofDays(1)).toEpochMilli();
@@ -114,9 +114,9 @@ public void testPolicy() throws Exception {
try (final Stream contents = Files.list(tempDir)) {
files = contents.map(Path::toString).collect(Collectors.joining(", ", "[", "]"));
}
- assertTrue(Files.exists(target), target.toString() + ", files = " + files);
+ assertTrue(Files.exists(target), target + ", files = " + files);
assertEquals(0, Files.size(target), target.toString());
- assertTrue(Files.exists(rolled), "Missing: " + rolled.toString() + ", files on disk = " + files);
+ assertTrue(Files.exists(rolled), "Missing: " + rolled + ", files on disk = " + files);
assertEquals(size, Files.size(rolled), rolled.toString());
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java
index ee333d6fe42..36341b77474 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java
@@ -36,7 +36,7 @@
/**
* Tests the PatternProcessor class.
*/
-public class PatternProcessorTest {
+class PatternProcessorTest {
private static Instant parseLocalDateTime(final String text) {
return LocalDateTime.parse(text).atZone(ZoneId.systemDefault()).toInstant();
@@ -44,7 +44,7 @@ private static Instant parseLocalDateTime(final String text) {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testDontInterpretBackslashAsEscape() {
+ void testDontInterpretBackslashAsEscape() {
final PatternProcessor pp = new PatternProcessor("c:\\test\\new/app-%d{HH-mm-ss}.log");
final Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 16);
@@ -58,7 +58,7 @@ public void testDontInterpretBackslashAsEscape() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeHourlyReturnsFirstMinuteOfNextHour() {
+ void testGetNextTimeHourlyReturnsFirstMinuteOfNextHour() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH}.log.gz");
final Instant initial = parseLocalDateTime("2014-03-04T10:31:59");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -69,7 +69,7 @@ public void testGetNextTimeHourlyReturnsFirstMinuteOfNextHour() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeHourlyReturnsFirstMinuteOfNextHour2() {
+ void testGetNextTimeHourlyReturnsFirstMinuteOfNextHour2() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH}.log.gz");
final Instant initial = parseLocalDateTime("2014-03-04T23:31:59");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -80,7 +80,7 @@ public void testGetNextTimeHourlyReturnsFirstMinuteOfNextHour2() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeHourlyReturnsFirstMinuteOfNextHourDstStart() {
+ void testGetNextTimeHourlyReturnsFirstMinuteOfNextHourDstStart() {
// America/Chicago 2014 - DST start - Mar 9 02:00
// during winter GMT-6
// during summer GMT-5
@@ -96,7 +96,7 @@ public void testGetNextTimeHourlyReturnsFirstMinuteOfNextHourDstStart() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeHourlyReturnsFirstMinuteOfHourAfterNextHourDstEnd() {
+ void testGetNextTimeHourlyReturnsFirstMinuteOfHourAfterNextHourDstEnd() {
// America/Chicago 2014 - DST end - Nov 2 02:00
// during summer GMT-5
// during winter GMT-6
@@ -113,7 +113,7 @@ public void testGetNextTimeHourlyReturnsFirstMinuteOfHourAfterNextHourDstEnd() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeHourlyReturnsFirstMinuteOfNextYear() {
+ void testGetNextTimeHourlyReturnsFirstMinuteOfNextYear() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH}.log.gz");
final Instant initial = parseLocalDateTime("2015-12-31T23:31:59");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -124,7 +124,7 @@ public void testGetNextTimeHourlyReturnsFirstMinuteOfNextYear() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeMillisecondlyReturnsNextMillisec() {
+ void testGetNextTimeMillisecondlyReturnsNextMillisec() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH-mm-ss.SSS}.log.gz");
final Instant initial = parseLocalDateTime("2014-03-04T10:31:53.123");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -135,7 +135,7 @@ public void testGetNextTimeMillisecondlyReturnsNextMillisec() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeMinutelyReturnsFirstSecondOfNextMinute() {
+ void testGetNextTimeMinutelyReturnsFirstSecondOfNextMinute() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH-mm}.log.gz");
final Instant initial = parseLocalDateTime("2014-03-04T10:31:59");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -146,7 +146,7 @@ public void testGetNextTimeMinutelyReturnsFirstSecondOfNextMinute() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth() {
+ void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM}.log.gz");
final Instant initial = parseLocalDateTime("2014-10-15T10:31:59");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -157,7 +157,7 @@ public void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth2() {
+ void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth2() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM}.log.gz");
final Instant initial = parseLocalDateTime("2014-01-31T10:31:59");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -169,7 +169,7 @@ public void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth2() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth3() {
+ void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth3() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM}.log.gz");
final Instant initial = parseLocalDateTime("2014-12-31T10:31:59");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -181,7 +181,7 @@ public void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth3() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeMonthlyReturnsFirstDayOfNextYear() {
+ void testGetNextTimeMonthlyReturnsFirstDayOfNextYear() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM}.log.gz");
final Instant initial = parseLocalDateTime("2015-12-28T00:00:00");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -193,7 +193,7 @@ public void testGetNextTimeMonthlyReturnsFirstDayOfNextYear() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeSecondlyReturnsFirstMillisecOfNextSecond() {
+ void testGetNextTimeSecondlyReturnsFirstMillisecOfNextSecond() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH-mm-ss}.log.gz");
final Instant initial = parseLocalDateTime("2014-03-04T10:31:53.123");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -204,7 +204,7 @@ public void testGetNextTimeSecondlyReturnsFirstMillisecOfNextSecond() {
@Test
@ResourceLock(Resources.LOCALE)
- public void testGetNextTimeWeeklyReturnsFirstDayOfNextWeek_FRANCE() {
+ void testGetNextTimeWeeklyReturnsFirstDayOfNextWeek_FRANCE() {
final Locale old = Locale.getDefault();
Locale.setDefault(Locale.FRANCE); // force 1st day of the week to be Monday
@@ -222,7 +222,7 @@ public void testGetNextTimeWeeklyReturnsFirstDayOfNextWeek_FRANCE() {
@Test
@ResourceLock(Resources.LOCALE)
- public void testGetNextTimeWeeklyReturnsFirstDayOfNextWeek_US() {
+ void testGetNextTimeWeeklyReturnsFirstDayOfNextWeek_US() {
final Locale old = Locale.getDefault();
Locale.setDefault(Locale.US); // force 1st day of the week to be Sunday
@@ -243,7 +243,7 @@ public void testGetNextTimeWeeklyReturnsFirstDayOfNextWeek_US() {
*/
@Test
@ResourceLock(Resources.LOCALE)
- public void testGetNextTimeWeeklyReturnsFirstWeekInYear_US() {
+ void testGetNextTimeWeeklyReturnsFirstWeekInYear_US() {
final Locale old = Locale.getDefault();
Locale.setDefault(Locale.US); // force 1st day of the week to be Sunday
try {
@@ -260,7 +260,7 @@ public void testGetNextTimeWeeklyReturnsFirstWeekInYear_US() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeDailyReturnsFirstHourOfNextDay() {
+ void testGetNextTimeDailyReturnsFirstHourOfNextDay() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd}.log.gz");
final Instant initial = parseLocalDateTime("2014-03-04T02:31:59");
final long actual = pp.getNextTime(initial.toEpochMilli(), 1, false);
@@ -271,7 +271,7 @@ public void testGetNextTimeDailyReturnsFirstHourOfNextDay() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeDailyReturnsFirstHourOfNextDayHonoringTimeZoneOption1() {
+ void testGetNextTimeDailyReturnsFirstHourOfNextDayHonoringTimeZoneOption1() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd}{GMT-6}.log.gz");
final Instant initial =
OffsetDateTime.parse("2014-03-04T02:31:59-06:00").toInstant();
@@ -285,7 +285,7 @@ public void testGetNextTimeDailyReturnsFirstHourOfNextDayHonoringTimeZoneOption1
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
@ResourceLock(value = Resources.TIME_ZONE)
- public void testGetNextTimeDailyReturnsFirstHourOfNextDayHonoringTimeZoneOption2() {
+ void testGetNextTimeDailyReturnsFirstHourOfNextDayHonoringTimeZoneOption2() {
final TimeZone old = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("GMT+10")); // default is ignored if pattern contains timezone
try {
@@ -305,7 +305,7 @@ public void testGetNextTimeDailyReturnsFirstHourOfNextDayHonoringTimeZoneOption2
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
@ResourceLock(value = Resources.TIME_ZONE)
- public void testGetNextTimeDailyReturnsFirstHourOfNextDayHonoringTimeZoneOption3() {
+ void testGetNextTimeDailyReturnsFirstHourOfNextDayHonoringTimeZoneOption3() {
final TimeZone old = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("GMT-10")); // default is ignored if pattern contains timezone
try {
@@ -324,7 +324,7 @@ public void testGetNextTimeDailyReturnsFirstHourOfNextDayHonoringTimeZoneOption3
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeDailyReturnsFirstHourOfNextDayDstJan() {
+ void testGetNextTimeDailyReturnsFirstHourOfNextDayDstJan() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd}{America/Chicago}.log.gz");
final Instant initial =
OffsetDateTime.parse("2014-01-04T00:31:59-06:00").toInstant();
@@ -337,7 +337,7 @@ public void testGetNextTimeDailyReturnsFirstHourOfNextDayDstJan() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeDailyReturnsFirstHourOfNextDayDstJun() {
+ void testGetNextTimeDailyReturnsFirstHourOfNextDayDstJun() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd}{America/Chicago}.log.gz");
final Instant initial =
OffsetDateTime.parse("2014-06-04T00:31:59-05:00").toInstant();
@@ -350,7 +350,7 @@ public void testGetNextTimeDailyReturnsFirstHourOfNextDayDstJun() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeDailyReturnsFirstHourOfNextDayDstStart() {
+ void testGetNextTimeDailyReturnsFirstHourOfNextDayDstStart() {
// America/Chicago 2014 - DST start - Mar 9 02:00
// during winter GMT-6
// during summer GMT-5
@@ -366,7 +366,7 @@ public void testGetNextTimeDailyReturnsFirstHourOfNextDayDstStart() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void testGetNextTimeDailyReturnsFirstHourOfNextDayDstEnd() {
+ void testGetNextTimeDailyReturnsFirstHourOfNextDayDstEnd() {
// America/Chicago 2014 - DST end - Nov 2 02:00
// during summer GMT-5
// during winter GMT-6
@@ -383,7 +383,7 @@ public void testGetNextTimeDailyReturnsFirstHourOfNextDayDstEnd() {
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
@ResourceLock(value = Resources.TIME_ZONE)
- public void testGetNextTimeDailyReturnsFirstHourOfNextDayInGmtIfZoneIsInvalid() {
+ void testGetNextTimeDailyReturnsFirstHourOfNextDayInGmtIfZoneIsInvalid() {
final TimeZone old = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("GMT-10")); // default is ignored even if timezone option invalid
try {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java
index 324a9af1258..6ed7c13e945 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
@@ -61,7 +61,7 @@ public RandomRollingAppenderOnStartupTest(final String configFile) {
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = this.loggerContextRule.getLogger(RandomRollingAppenderOnStartupTest.class.getName());
}
@@ -86,9 +86,10 @@ public static void afterClass() throws Exception {
size = Files.size(path);
} else {
final long fileSize = Files.size(path);
- assertTrue(
+ assertEquals(
"Expected size: " + size + " Size of " + path.getFileName() + ": " + fileSize,
- size == fileSize);
+ size,
+ fileSize);
}
Files.delete(path);
}
@@ -97,7 +98,7 @@ public static void afterClass() throws Exception {
}
@Test
- public void testAppender() throws Exception {
+ public void testAppender() {
for (int i = 0; i < 100; ++i) {
logger.debug("This is test message number " + i);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCountTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCountTest.java
index 5294953a18a..e8bd5a9e8aa 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCountTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCountTest.java
@@ -57,7 +57,7 @@ public RollingAppenderCountTest() {
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = this.loggerContextRule.getLogger("LogTest");
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronAndSizeLookupTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronAndSizeLookupTest.java
index c878ec3520c..509cf831227 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronAndSizeLookupTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronAndSizeLookupTest.java
@@ -18,11 +18,11 @@
import static org.apache.logging.log4j.core.test.hamcrest.Descriptors.that;
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.hasName;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -53,7 +53,7 @@ public class RollingAppenderCronAndSizeLookupTest {
private Logger logger;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingAppenderCronAndSizeLookupTest.class.getName());
}
@@ -79,7 +79,7 @@ public void testAppender() throws Exception {
String previous = "";
for (final File file : files) {
final String actual = file.getName();
- if (previous.length() == 0) {
+ if (previous.isEmpty()) {
previous = actual;
} else {
assertNotSame("File names snould not be equal", previous, actual);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronAndSizeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronAndSizeTest.java
index f40daa0b8aa..973ae70a85f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronAndSizeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronAndSizeTest.java
@@ -18,11 +18,11 @@
import static org.apache.logging.log4j.core.test.hamcrest.Descriptors.that;
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.hasName;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -53,7 +53,7 @@ public class RollingAppenderCronAndSizeTest {
private Logger logger;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingAppenderCronAndSizeTest.class.getName());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnStartupTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnStartupTest.java
index 3f3cd56eb9c..822d756034e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnStartupTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnStartupTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.FileOutputStream;
@@ -31,14 +31,14 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
-import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
/**
*
*/
-public class RollingAppenderCronOnStartupTest {
+class RollingAppenderCronOnStartupTest {
private static final String CONFIG = "log4j-rolling-cron-onStartup.xml";
private static final String DIR = "target/rolling-cron-onStartup";
@@ -48,7 +48,7 @@ public class RollingAppenderCronOnStartupTest {
private LoggerContext context;
@AfterAll
- public static void after() {
+ static void after() {
final File dir = new File(DIR);
if (dir.exists()) {
cleanDir(dir);
@@ -57,14 +57,14 @@ public static void after() {
}
@AfterEach
- public void afterEach() {
+ void afterEach() {
if (context != null) {
context.stop();
}
}
@Test
- public void testAppender() throws Exception {
+ void testAppender() throws Exception {
final File dir = new File(DIR);
if (dir.exists()) {
cleanDir(dir);
@@ -80,18 +80,18 @@ public void testAppender() throws Exception {
ps = new PrintStream(new FileOutputStream(rolled));
ps.println("This is a line 1");
ps.close();
- assertTrue("Log file does not exist", file.exists());
- assertTrue("Log file does not exist", rolled.exists());
+ assertTrue(file.exists(), "Log file does not exist");
+ assertTrue(rolled.exists(), "Log file does not exist");
final LoggerContext lc = Configurator.initialize("Test", CONFIG);
final Logger logger = lc.getLogger(RollingAppenderCronOnStartupTest.class);
logger.info("This is line 3");
final File[] files = dir.listFiles();
- assertNotNull("No files", files);
- assertEquals("Unexpected number of files. Expected 2 but found " + files.length, 2, files.length);
+ assertNotNull(files, "No files");
+ assertEquals(2, files.length, "Unexpected number of files. Expected 2 but found " + files.length);
List lines = Files.readAllLines(file.toPath());
- assertEquals("Unexpected number of lines. Expected 2: Actual: " + lines.size(), 2, lines.size());
+ assertEquals(2, lines.size(), "Unexpected number of lines. Expected 2: Actual: " + lines.size());
lines = Files.readAllLines(rolled.toPath());
- assertEquals("Unexpected number of lines. Expected 1: Actual: " + lines.size(), 1, lines.size());
+ assertEquals(1, lines.size(), "Unexpected number of lines. Expected 1: Actual: " + lines.size());
}
private static void cleanDir(final File dir) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
index 68d3a5987bb..bab06818acc 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
@@ -25,6 +25,7 @@
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -60,14 +61,16 @@ public class RollingAppenderCronOnceADayTest {
@BeforeClass
public static void beforeClass() throws Exception {
final Path src = FileSystems.getDefault().getPath(TARGET_TEST_CLASSES, CONFIG);
- String content = new String(Files.readAllBytes(src), UTF_8);
+ String content = new String(Files.readAllBytes(src), StandardCharsets.UTF_8);
final Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, CRON_DELAY);
remainingTime = cal.getTimeInMillis() - System.currentTimeMillis();
cronExpression = String.format(
"%d %d %d * * ?", cal.get(Calendar.SECOND), cal.get(Calendar.MINUTE), cal.get(Calendar.HOUR_OF_DAY));
content = content.replace("@CRON_EXPR@", cronExpression);
- Files.write(FileSystems.getDefault().getPath(TARGET_TEST_CLASSES, CONFIG_TARGET), content.getBytes(UTF_8));
+ Files.write(
+ FileSystems.getDefault().getPath(TARGET_TEST_CLASSES, CONFIG_TARGET),
+ content.getBytes(StandardCharsets.UTF_8));
StatusLogger.getLogger().debug("Cron expression will be " + cronExpression + " in " + remainingTime + "ms");
}
@@ -84,7 +87,7 @@ public void testAppender() throws Exception {
assertTrue("Log file does not exist", file.exists());
logger.debug("This is test message number 1, waiting for rolling");
- final RollingFileAppender app = (RollingFileAppender)
+ final RollingFileAppender app =
loggerContextRule.getLoggerContext().getConfiguration().getAppender("RollingFile");
final TriggeringPolicy policy = app.getManager().getTriggeringPolicy();
assertNotNull("No triggering policy", policy);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
index 8f3d4c95364..0130de1e481 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
@@ -20,6 +20,7 @@
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.hasName;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.hasItemInArray;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -94,12 +95,12 @@ public void testAppender() throws Exception {
logger.debug("Adding new event {}", i);
}
Thread.sleep(1000);
- final RollingFileAppender app = (RollingFileAppender)
+ final RollingFileAppender app =
loggerContextRule.getLoggerContext().getConfiguration().getAppender("RollingFile");
final TriggeringPolicy policy = app.getManager().getTriggeringPolicy();
assertNotNull("No triggering policy", policy);
assertTrue("Incorrect policy type", policy instanceof CronTriggeringPolicy);
final CronExpression expression = ((CronTriggeringPolicy) policy).getCronExpression();
- assertTrue("Incorrect triggering policy", expression.getCronExpression().equals("* * * ? * *"));
+ assertEquals("Incorrect triggering policy", "* * * ? * *", expression.getCronExpression());
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
index 82cd6152a65..c65c2114b30 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -70,7 +71,7 @@ public void testAppender() throws Exception {
assertTrue(file.getName() + " ends with '.log'", file.getName().endsWith(".log"));
final String strIndex = file.getName().substring(5, file.getName().indexOf('.'));
final int index = Integers.parseInt(strIndex);
- assertTrue(file + " should have odd index", index % 2 == 1);
+ assertEquals(file + " should have odd index", 1, index % 2);
}
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWrite1906Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWrite1906Test.java
index 22e76e9615f..dab76cab14a 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWrite1906Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWrite1906Test.java
@@ -18,17 +18,16 @@
import static org.apache.logging.log4j.core.test.hamcrest.Descriptors.that;
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.hasName;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
-import java.io.IOException;
import java.util.List;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
@@ -60,12 +59,12 @@ public class RollingAppenderDirectWrite1906Test {
private Logger logger;
@BeforeClass
- public static void setupClass() throws Exception {
+ public static void setupClass() {
StatusLogger.getLogger().registerListener(new NoopStatusListener());
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingAppenderDirectWrite1906Test.class.getName());
}
@@ -124,6 +123,6 @@ public Level getStatusLevel() {
}
@Override
- public void close() throws IOException {}
+ public void close() {}
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteStartupSizeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteStartupSizeTest.java
index 92562cf4182..47ab9404efd 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteStartupSizeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteStartupSizeTest.java
@@ -59,7 +59,7 @@ public static void beforeClass() throws Exception {
}
@Test
- public void testRollingFileAppenderWithReconfigure() throws Exception {
+ public void testRollingFileAppenderWithReconfigure() {
final RollingFileAppender rfAppender =
loggerContextRule.getRequiredAppender("RollingFile", RollingFileAppender.class);
final RollingFileManager manager = rfAppender.getManager();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteTempCompressedFilePatternTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteTempCompressedFilePatternTest.java
index c092b2834fe..087fb7aefa4 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteTempCompressedFilePatternTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteTempCompressedFilePatternTest.java
@@ -40,7 +40,7 @@
*/
@UsingStatusListener
@DisabledOnOs(value = OS.MAC, disabledReason = "FileWatcher is not fast enough on macOS for this test")
-public class RollingAppenderDirectWriteTempCompressedFilePatternTest {
+class RollingAppenderDirectWriteTempCompressedFilePatternTest {
private final String PATTERN = "test-\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d+\\.log\\.gz";
private final Pattern FILE_PATTERN = Pattern.compile(PATTERN);
@@ -51,7 +51,7 @@ public class RollingAppenderDirectWriteTempCompressedFilePatternTest {
@Test
@LoggerContextSource
- public void testAppender(final LoggerContext ctx) throws Exception {
+ void testAppender(final LoggerContext ctx) throws Exception {
final Logger logger = ctx.getLogger(getClass());
try (final WatchService watcher = FileSystems.getDefault().newWatchService()) {
WatchKey key = loggingPath.register(watcher, StandardWatchEventKinds.ENTRY_CREATE);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteTest.java
index 4a34ca917c6..f28b6268cb8 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteTest.java
@@ -36,7 +36,7 @@
import org.junit.jupiter.api.Test;
@UsingStatusListener
-public class RollingAppenderDirectWriteTest {
+class RollingAppenderDirectWriteTest {
private final Pattern FILE_PATTERN = Pattern.compile("test-\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d+\\.log(\\.gz)?");
private final Pattern LINE_PATTERN = Pattern.compile("This is test message number \\d+\\.");
@@ -46,7 +46,7 @@ public class RollingAppenderDirectWriteTest {
@Test
@LoggerContextSource
- public void testAppender(final LoggerContext ctx) throws Exception {
+ void testAppender(final LoggerContext ctx) throws Exception {
final Logger logger = ctx.getLogger(getClass());
final int count = 100;
for (int i = 0; i < count; ++i) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithFilenameTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithFilenameTest.java
index c445e747f48..530c65c1fbd 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithFilenameTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithFilenameTest.java
@@ -44,12 +44,12 @@ public class RollingAppenderDirectWriteWithFilenameTest {
private Logger logger;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingAppenderDirectWriteWithFilenameTest.class.getName());
}
@Test
- public void testAppender() throws Exception {
+ public void testAppender() {
final File dir = new File(DIR);
assertFalse("Directory created", dir.exists());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithHtmlLayoutTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithHtmlLayoutTest.java
index 598aa9dbd0f..887bee97e59 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithHtmlLayoutTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithHtmlLayoutTest.java
@@ -18,11 +18,11 @@
import static org.apache.logging.log4j.core.test.hamcrest.Descriptors.that;
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.hasName;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithReconfigureTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithReconfigureTest.java
index 61af172b7ab..f27ca883d3c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithReconfigureTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithReconfigureTest.java
@@ -16,10 +16,10 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -53,7 +53,7 @@ public class RollingAppenderDirectWriteWithReconfigureTest {
private Logger logger;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingAppenderDirectWriteWithReconfigureTest.class.getName());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
index 8070312323b..803a898c20e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
@@ -64,7 +64,7 @@ public RollingAppenderNoUnconditionalDeleteTest(final String configFile, final S
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = this.loggerContextRule.getLogger();
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartup2Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartup2Test.java
index 5158cb912f6..7dba6fcfddf 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartup2Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartup2Test.java
@@ -16,11 +16,13 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -33,15 +35,14 @@
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.apache.logging.log4j.core.util.datetime.FastDateFormat;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
/**
*
*/
-public class RollingAppenderOnStartup2Test {
+class RollingAppenderOnStartup2Test {
private static final String DIR = "target/rollOnStartup";
private static final String TARGET_FILE = DIR + "/orchestrator.log";
@@ -50,8 +51,8 @@ public class RollingAppenderOnStartup2Test {
private static final String ROLLED_FILE_SUFFIX = "-1.log.gz";
private static final String TEST_DATA = "Hello world!";
- @BeforeClass
- public static void beforeClass() throws Exception {
+ @BeforeAll
+ static void beforeClass() throws Exception {
if (Files.exists(Paths.get("target/rollOnStartup"))) {
try (final DirectoryStream directoryStream = Files.newDirectoryStream(Paths.get(DIR))) {
for (final Path path : directoryStream) {
@@ -64,14 +65,14 @@ public static void beforeClass() throws Exception {
// System.setProperty("log4j2.StatusLogger.level", "trace");
final Configuration configuration = new DefaultConfiguration();
final Path target = Paths.get(TARGET_FILE);
- Assert.assertFalse(Files.exists(target));
+ assertFalse(Files.exists(target));
target.toFile().getParentFile().mkdirs();
final long timeStamp = System.currentTimeMillis() - (1000 * 60 * 60 * 24);
final String expectedDate = formatter.format(timeStamp);
final String rolledFileName = ROLLED_FILE_PREFIX + expectedDate + ROLLED_FILE_SUFFIX;
final Path rolled = Paths.get(rolledFileName);
final long copied;
- try (final InputStream is = new ByteArrayInputStream(TEST_DATA.getBytes("UTF-8"))) {
+ try (final InputStream is = new ByteArrayInputStream(TEST_DATA.getBytes(StandardCharsets.UTF_8))) {
copied = Files.copy(is, target, StandardCopyOption.REPLACE_EXISTING);
}
final long size = Files.size(target);
@@ -83,8 +84,8 @@ public static void beforeClass() throws Exception {
System.setProperty("log4j.configurationFile", "log4j-rollOnStartup.json");
}
- @AfterClass
- public static void afterClass() throws Exception {
+ @AfterAll
+ static void afterClass() {
final long size = 0;
/* try (DirectoryStream directoryStream = Files.newDirectoryStream(Paths.get(DIR))) {
for (final Path path : directoryStream) {
@@ -102,7 +103,7 @@ public static void afterClass() throws Exception {
}
@Test
- public void testAppender() throws Exception {
+ void testAppender() {
final Logger logger = LogManager.getLogger(RollingAppenderOnStartup2Test.class);
for (int i = 0; i < 10; ++i) {
logger.debug("This is test message number " + i);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupDirectTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupDirectTest.java
index ea5d42dde8e..aa7e4a51063 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupDirectTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupDirectTest.java
@@ -16,8 +16,9 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.nio.file.DirectoryStream;
@@ -35,14 +36,14 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
/**
*
*/
-public class RollingAppenderOnStartupDirectTest {
+class RollingAppenderOnStartupDirectTest {
private static final String SOURCE = "src/test/resources/__files";
private static final String DIR = "target/onStartup";
@@ -54,8 +55,8 @@ public class RollingAppenderOnStartupDirectTest {
private static LoggerContext loggerContext;
- @BeforeClass
- public static void beforeClass() throws Exception {
+ @BeforeAll
+ static void beforeClass() throws Exception {
if (Files.exists(Paths.get("target/onStartup"))) {
try (final DirectoryStream directoryStream = Files.newDirectoryStream(Paths.get(DIR))) {
for (final Path path : directoryStream) {
@@ -73,7 +74,7 @@ public static void beforeClass() throws Exception {
}
@Test
- public void performTest() throws Exception {
+ void performTest() throws Exception {
loggerContext = Configurator.initialize("Test", CONFIG);
final Logger logger = loggerContext.getLogger(RollingAppenderOnStartupDirectTest.class);
for (int i = 3; i < 10; ++i) {
@@ -85,18 +86,19 @@ public void performTest() throws Exception {
++fileCount;
if (path.toFile().getName().startsWith(ROLLED)) {
final List lines = Files.readAllLines(path);
- assertTrue("No messages in " + path.toFile().getName(), lines.size() > 0);
+ assertFalse(
+ lines.isEmpty(), "No messages in " + path.toFile().getName());
assertTrue(
- "Missing message for " + path.toFile().getName(),
- lines.get(0).startsWith(PREFIX));
+ lines.get(0).startsWith(PREFIX),
+ "Missing message for " + path.toFile().getName());
}
}
}
- assertEquals("File did not roll", 2, fileCount);
+ assertEquals(2, fileCount, "File did not roll");
}
- @AfterClass
- public static void afterClass() throws Exception {
+ @AfterAll
+ static void afterClass() throws Exception {
Configurator.shutdown(loggerContext);
try (final DirectoryStream directoryStream = Files.newDirectoryStream(Paths.get(DIR))) {
for (final Path path : directoryStream) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupTest.java
index 3e419755c8c..a65513050f0 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderOnStartupTest.java
@@ -16,7 +16,8 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.nio.file.DirectoryStream;
@@ -38,7 +39,7 @@
import org.junit.jupiter.api.Test;
@UsingStatusListener
-public class RollingAppenderOnStartupTest {
+class RollingAppenderOnStartupTest {
private static final String SOURCE = "src/test/resources/__files";
private static final String FILENAME = "onStartup.log";
@@ -49,7 +50,7 @@ public class RollingAppenderOnStartupTest {
private static Path loggingPath;
@BeforeAll
- public static void setup() throws Exception {
+ static void setup() throws Exception {
final Path target = loggingPath.resolve(FILENAME);
Files.copy(Paths.get(SOURCE, FILENAME), target, StandardCopyOption.REPLACE_EXISTING);
final FileTime newTime = FileTime.from(Instant.now().minus(1, ChronoUnit.DAYS));
@@ -70,7 +71,7 @@ public static void setup() throws Exception {
@Test
@LoggerContextSource
- public void performTest(final LoggerContext loggerContext) throws Exception {
+ void performTest(final LoggerContext loggerContext) throws Exception {
boolean rolled = false;
final Logger logger = loggerContext.getLogger(RollingAppenderOnStartupTest.class);
for (int i = 3; i < 10; ++i) {
@@ -81,13 +82,14 @@ public void performTest(final LoggerContext loggerContext) throws Exception {
if (path.toFile().getName().startsWith(ROLLED)) {
rolled = true;
final List lines = Files.readAllLines(path);
- assertTrue("No messages in " + path.toFile().getName(), lines.size() > 0);
+ assertFalse(
+ lines.isEmpty(), "No messages in " + path.toFile().getName());
assertTrue(
- "Missing message for " + path.toFile().getName(),
- lines.get(0).startsWith(PREFIX + "1"));
+ lines.get(0).startsWith(PREFIX + "1"),
+ "Missing message for " + path.toFile().getName());
}
}
}
- assertTrue("File did not roll", rolled);
+ assertTrue(rolled, "File did not roll");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderReconfigureTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderReconfigureTest.java
index ae25790e1c8..8e6a300a28d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderReconfigureTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderReconfigureTest.java
@@ -34,7 +34,7 @@
* LOG4J2-1725.
*/
@UsingStatusListener
-public class RollingAppenderReconfigureTest {
+class RollingAppenderReconfigureTest {
private static final URL CONFIG =
RollingAppenderReconfigureTest.class.getResource("RollingAppenderReconfigureTest.xml");
@@ -45,7 +45,7 @@ public class RollingAppenderReconfigureTest {
@Test
@LoggerContextSource
- public void testReconfigure(final LoggerContext context) throws Exception {
+ void testReconfigure(final LoggerContext context) throws Exception {
final Logger logger = context.getLogger(getClass());
for (int i = 0; i < 500; ++i) {
logger.debug("This is test message number {}", i);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeCompressPermissionsTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeCompressPermissionsTest.java
index e8ebb09cf6a..98bc0989b7a 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeCompressPermissionsTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeCompressPermissionsTest.java
@@ -57,7 +57,7 @@ public static void beforeClass() {
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingAppenderSizeCompressPermissionsTest.class.getName());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeMaxWidthTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeMaxWidthTest.java
index 449d60d1251..4b49a59f120 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeMaxWidthTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeMaxWidthTest.java
@@ -96,7 +96,7 @@ public RollingAppenderSizeMaxWidthTest(final LoggerContextRule loggerContextRule
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingAppenderSizeMaxWidthTest.class.getName());
final RollingFileAppender app = (RollingFileAppender) loggerContextRule.getRequiredAppender("RollingFile");
app.getManager().addRolloverListener(this);
@@ -133,7 +133,7 @@ public void setUp() throws Exception {
}
@Test
- public void testAppender() throws Exception {
+ public void testAppender() {
if (minWidth > 0) {
assertTrue("min must be greater than or equal to the minimum width", min > -powerOfTen(minWidth));
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeNoCompressTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeNoCompressTest.java
index b60ca743612..3906a4c79f6 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeNoCompressTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeNoCompressTest.java
@@ -39,7 +39,7 @@
* LOG4J2-1804.
*/
@UsingStatusListener
-public class RollingAppenderSizeNoCompressTest {
+class RollingAppenderSizeNoCompressTest {
private static final Logger LOGGER = StatusLogger.getLogger();
@@ -48,7 +48,7 @@ public class RollingAppenderSizeNoCompressTest {
@Test
@LoggerContextSource
- public void testAppender(final LoggerContext context) throws Exception {
+ void testAppender(final LoggerContext context) throws Exception {
final Logger logger = context.getLogger(getClass());
final List messages = new ArrayList<>();
for (int i = 0; i < 1000; ++i) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
index b5559f16dbb..dc245af3058 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
@@ -46,7 +46,7 @@
import org.junit.jupiter.params.provider.MethodSource;
@UsingStatusListener
-public class RollingAppenderSizeTest {
+class RollingAppenderSizeTest {
private static long DEFAULT_SHUTDOWN_MS = 500;
@@ -90,7 +90,7 @@ private static LogEvent createEvent(final String pattern, final Object p0) {
@ParameterizedTest
@MethodSource("parameters")
- public void testIsCreateOnDemand(final String fileExtension, final boolean createOnDemand) throws IOException {
+ void testIsCreateOnDemand(final String fileExtension, final boolean createOnDemand) throws IOException {
final Path extensionFolder = loggingPath.resolve(fileExtension);
RollingFileAppender appender = null;
try {
@@ -106,7 +106,7 @@ public void testIsCreateOnDemand(final String fileExtension, final boolean creat
@ParameterizedTest
@MethodSource("parameters")
- public void testAppender(final String fileExtension, final boolean createOnDemand) throws Exception {
+ void testAppender(final String fileExtension, final boolean createOnDemand) throws Exception {
final Path extensionFolder = loggingPath.resolve(fileExtension);
RollingFileAppender appender = null;
try {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeWithTimeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeWithTimeTest.java
index 66fed65dc90..abe97560e82 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeWithTimeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeWithTimeTest.java
@@ -53,7 +53,7 @@ public class RollingAppenderSizeWithTimeTest {
private Logger logger;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingAppenderSizeWithTimeTest.class.getName());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTempCompressedFilePatternTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTempCompressedFilePatternTest.java
index 929a073ad85..579768097f2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTempCompressedFilePatternTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTempCompressedFilePatternTest.java
@@ -51,7 +51,7 @@
* LOG4J2-1766.
*/
@UsingStatusListener
-public class RollingAppenderTempCompressedFilePatternTest {
+class RollingAppenderTempCompressedFilePatternTest {
private static Logger LOGGER = StatusLogger.getLogger();
@@ -61,7 +61,7 @@ public class RollingAppenderTempCompressedFilePatternTest {
@Test
@DisabledOnOs(value = OS.MAC, disabledReason = "FileWatcher isn't fast enough to work properly.")
@LoggerContextSource
- public void testAppender(final LoggerContext context) throws Exception {
+ void testAppender(final LoggerContext context) throws Exception {
final Logger logger = context.getLogger(getClass());
final Path logsDir = loggingPath.resolve("logs");
final Path tmpDir = loggingPath.resolve("tmp");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeDirectTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeDirectTest.java
index 15b45603f91..31c04d39091 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeDirectTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeDirectTest.java
@@ -18,10 +18,10 @@
import static org.apache.logging.log4j.core.test.hamcrest.Descriptors.that;
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.hasName;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -50,7 +50,7 @@ public class RollingAppenderTimeAndSizeDirectTest {
private Logger logger;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingAppenderTimeAndSizeDirectTest.class.getName());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
index 2ec3084657b..a04471dcac1 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
@@ -18,12 +18,12 @@
import static org.apache.logging.log4j.core.test.hamcrest.Descriptors.that;
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.hasName;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -56,7 +56,7 @@ public class RollingAppenderTimeAndSizeTest {
private Logger logger;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingAppenderTimeAndSizeTest.class.getName());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
index 6fc45949b86..66568da524f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
@@ -58,7 +58,7 @@ public static void cleanupClass() {
}
@Test
- public void testAppender() throws Exception {
+ public void testAppender() {
for (int i = 0; i < 100; ++i) {
logger.debug("This is test message number " + i);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectSize3490Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectSize3490Test.java
index bf5be0d9180..d4b6bb5d6f7 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectSize3490Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectSize3490Test.java
@@ -36,7 +36,7 @@
* This test attempts to validate that logging rolls after the max files are already written
* will succeed on a restart.
*/
-public class RollingDirectSize3490Test implements RolloverListener {
+class RollingDirectSize3490Test implements RolloverListener {
private static final String CONFIG = "log4j-rolling-3490.xml";
private static final String[] set1 = {"This is file 1"};
@@ -48,7 +48,7 @@ public class RollingDirectSize3490Test implements RolloverListener {
private boolean rolloverTriggered = false;
@BeforeAll
- public static void clean() throws Exception {
+ static void clean() {
final File dir = new File(DIR);
if (dir.exists()) {
final File[] files = dir.listFiles();
@@ -62,7 +62,7 @@ public static void clean() throws Exception {
}
@Test
- public void rolloverTest() throws Exception {
+ void rolloverTest() throws Exception {
final File parent = new File(DIR);
parent.mkdirs();
final Path app1 = new File(parent, "app-21.log").toPath();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderAccessTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderAccessTest.java
index 4d963f6e211..44a88a7c45f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderAccessTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderAccessTest.java
@@ -16,15 +16,16 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import java.io.File;
import java.io.IOException;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.appender.RollingFileAppender;
import org.apache.logging.log4j.core.config.Configuration;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class RollingFileAppenderAccessTest {
+class RollingFileAppenderAccessTest {
/**
* Not a real test, just make sure we can compile access to the typed manager.
@@ -32,7 +33,7 @@ public class RollingFileAppenderAccessTest {
* @throws IOException
*/
@Test
- public void testAccessManagerWithBuilder() throws IOException {
+ void testAccessManagerWithBuilder() throws IOException {
try (final LoggerContext ctx = LoggerContext.getContext(false)) {
final Configuration config = ctx.getConfiguration();
final File file = File.createTempFile("RollingFileAppenderAccessTest", ".tmp");
@@ -49,8 +50,8 @@ public void testAccessManagerWithBuilder() throws IOException {
final RollingFileManager manager = appender.getManager();
// Since the RolloverStrategy and TriggeringPolicy are immutable, we could also use generics to type their
// access.
- Assert.assertNotNull(manager.getRolloverStrategy());
- Assert.assertNotNull(manager.getTriggeringPolicy());
+ assertNotNull(manager.getRolloverStrategy());
+ assertNotNull(manager.getTriggeringPolicy());
}
}
@@ -60,7 +61,7 @@ public void testAccessManagerWithBuilder() throws IOException {
* @throws IOException
*/
@Test
- public void testAccessManagerWithStrings() throws IOException {
+ void testAccessManagerWithStrings() throws IOException {
try (final LoggerContext ctx = LoggerContext.getContext(false)) {
final Configuration config = ctx.getConfiguration();
final File file = File.createTempFile("RollingFileAppenderAccessTest", ".tmp");
@@ -84,8 +85,8 @@ public void testAccessManagerWithStrings() throws IOException {
final RollingFileManager manager = appender.getManager();
// Since the RolloverStrategy and TriggeringPolicy are immutable, we could also use generics to type their
// access.
- Assert.assertNotNull(manager.getRolloverStrategy());
- Assert.assertNotNull(manager.getTriggeringPolicy());
+ assertNotNull(manager.getRolloverStrategy());
+ assertNotNull(manager.getTriggeringPolicy());
}
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderBuilderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderBuilderTest.java
index ec2bf42cca7..d739c978d07 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderBuilderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderBuilderTest.java
@@ -16,17 +16,18 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.logging.log4j.core.appender.RollingFileAppender;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class RollingFileAppenderBuilderTest {
+class RollingFileAppenderBuilderTest {
/**
* Tests https://issues.apache.org/jira/browse/LOG4J2-1620
*/
@Test
- public void testDefaultImmediateFlush() {
- Assert.assertTrue(RollingFileAppender.newBuilder().isImmediateFlush());
+ void testDefaultImmediateFlush() {
+ assertTrue(RollingFileAppender.newBuilder().isImmediateFlush());
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderInterruptedThreadTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderInterruptedThreadTest.java
index 156c85e8f0c..6a568a66fe2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderInterruptedThreadTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderInterruptedThreadTest.java
@@ -16,8 +16,10 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.instanceOf;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import org.apache.logging.log4j.Level;
@@ -31,7 +33,6 @@
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import org.apache.logging.log4j.core.test.junit.CleanFolders;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -80,14 +81,14 @@ public void tearDown() {
public void testRolloverInInterruptedThread() {
final Logger logger = loggerContext.getLogger(getClass().getName());
- Assert.assertThat(logger.getAppenders().values(), hasItem(instanceOf(RollingFileAppender.class)));
+ assertThat(logger.getAppenders().values(), hasItem(instanceOf(RollingFileAppender.class)));
logger.info("Sending logging event 1"); // send first event to initialize rollover system
Thread.currentThread().interrupt(); // mark thread as interrupted
logger.info("Sending logging event 2"); // send second event to trigger rotation, expecting 2 files in result
- Assert.assertTrue(new File(ROLLING_APPENDER_FILES_DIR, "file-1.log").exists());
- Assert.assertTrue(new File(ROLLING_APPENDER_FILES_DIR, "file-2.log").exists());
+ assertTrue(new File(ROLLING_APPENDER_FILES_DIR, "file-1.log").exists());
+ assertTrue(new File(ROLLING_APPENDER_FILES_DIR, "file-2.log").exists());
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderLayoutTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderLayoutTest.java
index 48c0942a1f2..7ac285ee90d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderLayoutTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderLayoutTest.java
@@ -16,17 +16,18 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import org.apache.logging.log4j.core.appender.RollingFileAppender;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class RollingFileAppenderLayoutTest {
+class RollingFileAppenderLayoutTest {
@Test
- public void testDefaultLayout() throws Exception {
+ void testDefaultLayout() {
// @formatter:off
- Assert.assertNotNull(RollingFileAppender.newBuilder()
+ assertNotNull(RollingFileAppender.newBuilder()
.setName(RollingFileAppenderLayoutTest.class.getName())
.setConfiguration(new DefaultConfiguration())
.withFileName("log.txt")
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderUpdateDataTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderUpdateDataTest.java
index b50d83efa3e..2f63c19e34e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderUpdateDataTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileAppenderUpdateDataTest.java
@@ -16,6 +16,10 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
@@ -25,14 +29,13 @@
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
/**
* Tests LOG4J2-2009 Rolling appender managers broken on pattern/policy reconfiguration
*/
-public class RollingFileAppenderUpdateDataTest {
+class RollingFileAppenderUpdateDataTest {
private ConfigurationBuilder buildConfigA() {
return buildConfigurationBuilder("target/rolling-update-date/foo.log.%i");
@@ -64,8 +67,8 @@ private ConfigurationBuilder buildConfigurationBuilder(final
private LoggerContext loggerContext1 = null;
private LoggerContext loggerContext2 = null;
- @After
- public void after() {
+ @AfterEach
+ void after() {
if (loggerContext1 != null) {
loggerContext1.close();
loggerContext1 = null;
@@ -77,7 +80,7 @@ public void after() {
}
@Test
- public void testClosingLoggerContext() {
+ void testClosingLoggerContext() {
// initial config with indexed rollover
try (final LoggerContext loggerContext1 =
Configurator.initialize(buildConfigA().build())) {
@@ -92,20 +95,20 @@ public void testClosingLoggerContext() {
}
@Test
- public void testNotClosingLoggerContext() {
+ void testNotClosingLoggerContext() {
// initial config with indexed rollover
loggerContext1 = Configurator.initialize(buildConfigA().build());
validateAppender(loggerContext1, "target/rolling-update-date/foo.log.%i");
// rebuild config with date based rollover
loggerContext2 = Configurator.initialize(buildConfigB().build());
- Assert.assertNotNull("No LoggerContext", loggerContext2);
- Assert.assertTrue("Expected same logger context to be returned", loggerContext1 == loggerContext2);
+ assertNotNull(loggerContext2, "No LoggerContext");
+ assertSame(loggerContext1, loggerContext2, "Expected same logger context to be returned");
validateAppender(loggerContext1, "target/rolling-update-date/foo.log.%i");
}
@Test
- public void testReconfigure() {
+ void testReconfigure() {
// initial config with indexed rollover
loggerContext1 = Configurator.initialize(buildConfigA().build());
validateAppender(loggerContext1, "target/rolling-update-date/foo.log.%i");
@@ -117,8 +120,8 @@ public void testReconfigure() {
private void validateAppender(final LoggerContext loggerContext, final String expectedFilePattern) {
final RollingFileAppender appender = loggerContext.getConfiguration().getAppender("fooAppender");
- Assert.assertNotNull(appender);
- Assert.assertEquals(expectedFilePattern, appender.getFilePattern());
+ assertNotNull(appender);
+ assertEquals(expectedFilePattern, appender.getFilePattern());
LogManager.getLogger("root").info("just to show it works.");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManagerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManagerTest.java
index 325b859f6f1..dfa94c3ffe7 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManagerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManagerTest.java
@@ -16,11 +16,11 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -40,10 +40,10 @@
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.apache.logging.log4j.core.lookup.StrSubstitutor;
import org.apache.logging.log4j.core.util.IOUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.Issue;
-public class RollingFileManagerTest {
+class RollingFileManagerTest {
/**
* Test the RollingFileManager with a custom DirectFileRolloverStrategy
@@ -51,7 +51,7 @@ public class RollingFileManagerTest {
* @throws IOException
*/
@Test
- public void testCustomDirectFileRolloverStrategy() throws IOException {
+ void testCustomDirectFileRolloverStrategy() throws IOException {
class CustomDirectFileRolloverStrategy extends AbstractRolloverStrategy implements DirectFileRolloverStrategy {
final File file;
@@ -105,7 +105,7 @@ public RolloverDescription rollover(final RollingFileManager manager) throws Sec
* Test that a synchronous action failure does not cause a rollover. Addresses Issue #1445.
*/
@Test
- public void testSynchronousActionFailure() throws IOException {
+ void testSynchronousActionFailure() throws IOException {
class FailingSynchronousAction extends AbstractAction {
@Override
public boolean execute() {
@@ -158,7 +158,7 @@ public RolloverDescription rollover(final RollingFileManager manager) throws Sec
@Test
@Issue("https://github.com/apache/logging-log4j2/issues/1645")
- public void testCreateParentDir() {
+ void testCreateParentDir() {
final Configuration configuration = new NullConfiguration();
final RollingFileManager manager = RollingFileManager.getFileManager(
null,
@@ -192,7 +192,7 @@ public void testCreateParentDir() {
@Test
@Issue("https://github.com/apache/logging-log4j2/issues/2592")
- public void testRolloverOfDeletedFile() throws IOException {
+ void testRolloverOfDeletedFile() throws IOException {
final File file = File.createTempFile("testRolloverOfDeletedFile", "log");
file.deleteOnExit();
final String testContent = "Test";
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingNewDirectoryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingNewDirectoryTest.java
index 157be9b57f0..e720a33ea0f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingNewDirectoryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingNewDirectoryTest.java
@@ -44,7 +44,7 @@ public class RollingNewDirectoryTest {
private Logger logger;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingNewDirectoryTest.class.getName());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
index 55e0c20961a..e3aba8f2583 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
@@ -20,13 +20,13 @@
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.hasLength;
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.isEmpty;
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.lastModified;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.FileOutputStream;
@@ -45,19 +45,19 @@
import org.apache.logging.log4j.core.util.FileUtils;
import org.apache.logging.log4j.core.util.NullOutputStream;
import org.apache.logging.log4j.util.Strings;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests the RollingRandomAccessFileManager class.
*/
-public class RollingRandomAccessFileManagerTest {
+class RollingRandomAccessFileManagerTest {
/**
* Test method for
* {@link org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager#writeBytes(byte[], int, int)}
*/
@Test
- public void testWrite_multiplesOfBufferSize() throws IOException {
+ void testWrite_multiplesOfBufferSize() throws IOException {
final File file = File.createTempFile("log4j2", "test");
file.deleteOnExit();
try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
@@ -102,7 +102,7 @@ public void testWrite_multiplesOfBufferSize() throws IOException {
* {@link org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager#writeBytes(byte[], int, int)} .
*/
@Test
- public void testWrite_dataExceedingBufferSize() throws IOException {
+ void testWrite_dataExceedingBufferSize() throws IOException {
final File file = File.createTempFile("log4j2", "test");
file.deleteOnExit();
try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
@@ -144,7 +144,7 @@ public void testWrite_dataExceedingBufferSize() throws IOException {
}
@Test
- public void testConfigurableBufferSize() throws IOException {
+ void testConfigurableBufferSize() throws IOException {
final File file = File.createTempFile("log4j2", "test");
file.deleteOnExit();
try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
@@ -183,7 +183,7 @@ public void testConfigurableBufferSize() throws IOException {
}
@Test
- public void testAppendDoesNotOverwriteExistingFile() throws IOException {
+ void testAppendDoesNotOverwriteExistingFile() throws IOException {
final boolean isAppend = true;
final File file = File.createTempFile("log4j2", "test");
file.deleteOnExit();
@@ -224,7 +224,7 @@ public void testAppendDoesNotOverwriteExistingFile() throws IOException {
}
@Test
- public void testFileTimeBasedOnSystemClockWhenAppendIsFalse() throws IOException {
+ void testFileTimeBasedOnSystemClockWhenAppendIsFalse() throws IOException {
final File file = File.createTempFile("log4j2", "test");
file.deleteOnExit();
LockSupport.parkNanos(1000000); // 1 millisec
@@ -255,7 +255,7 @@ public void testFileTimeBasedOnSystemClockWhenAppendIsFalse() throws IOException
}
@Test
- public void testFileTimeBasedOnFileModifiedTimeWhenAppendIsTrue() throws IOException {
+ void testFileTimeBasedOnFileModifiedTimeWhenAppendIsTrue() throws IOException {
final File file = File.createTempFile("log4j2", "test");
file.deleteOnExit();
LockSupport.parkNanos(1000000); // 1 millisec
@@ -282,7 +282,7 @@ public void testFileTimeBasedOnFileModifiedTimeWhenAppendIsTrue() throws IOExcep
}
@Test
- public void testRolloverRetainsFileAttributes() throws Exception {
+ void testRolloverRetainsFileAttributes() throws Exception {
// Short-circuit if host doesn't support file attributes.
if (!FileUtils.isFilePosixAttributeViewSupported()) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteAndSwitchDirectorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteAndSwitchDirectorTest.java
index 5099aa5d04b..ceb6faacfed 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteAndSwitchDirectorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteAndSwitchDirectorTest.java
@@ -27,12 +27,12 @@
import org.junit.jupiter.api.Test;
@CleanUpDirectories(RollingRandomAppenderDirectWriteAndSwitchDirectorTest.DIR)
-public class RollingRandomAppenderDirectWriteAndSwitchDirectorTest {
+class RollingRandomAppenderDirectWriteAndSwitchDirectorTest {
public static final String DIR = "target/rolling-random-direct-switch-director";
@Test
@LoggerContextSource(value = "log4j-rolling-random-direct-switch-director.xml", timeout = 10)
- public void testAppender(final LoggerContext context) throws Exception {
+ void testAppender(final LoggerContext context) throws Exception {
final Logger logger = context.getLogger(RollingRandomAppenderDirectWriteAndSwitchDirectorTest.class.getName());
final LocalTime start = LocalTime.now();
LocalTime end;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteTest.java
index 6489bec0fbb..d74a0637bd2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteTest.java
@@ -18,10 +18,10 @@
import static org.apache.logging.log4j.core.test.hamcrest.Descriptors.that;
import static org.apache.logging.log4j.core.test.hamcrest.FileMatchers.hasName;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -50,7 +50,7 @@ public class RollingRandomAppenderDirectWriteTest {
private Logger logger;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingRandomAppenderDirectWriteTest.class.getName());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteWithFilenameTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteWithFilenameTest.java
index cea54269cb8..8ae8e94eb34 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteWithFilenameTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAppenderDirectWriteWithFilenameTest.java
@@ -44,12 +44,12 @@ public class RollingRandomAppenderDirectWriteWithFilenameTest {
private Logger logger;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.logger = loggerContextRule.getLogger(RollingRandomAppenderDirectWriteWithFilenameTest.class.getName());
}
@Test
- public void testAppender() throws Exception {
+ public void testAppender() {
final File dir = new File(DIR);
assertFalse("Directory created", dir.exists());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RolloverFilePatternTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RolloverFilePatternTest.java
index ed23f414d83..15b6a18ff71 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RolloverFilePatternTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RolloverFilePatternTest.java
@@ -16,21 +16,21 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.regex.Matcher;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test getEligibleFiles method.
*/
-public class RolloverFilePatternTest {
+class RolloverFilePatternTest {
@Test
- public void testFilePatternWithoutPadding() throws Exception {
+ void testFilePatternWithoutPadding() {
final Matcher matcher = AbstractRolloverStrategy.PATTERN_COUNTER.matcher("target/logs/test-%i.log.gz");
assertTrue(matcher.find());
assertNull(matcher.group("ZEROPAD"));
@@ -38,7 +38,7 @@ public void testFilePatternWithoutPadding() throws Exception {
}
@Test
- public void testFilePatternWithSpacePadding() throws Exception {
+ void testFilePatternWithSpacePadding() {
final Matcher matcher = AbstractRolloverStrategy.PATTERN_COUNTER.matcher("target/logs/test-%3i.log.gz");
assertTrue(matcher.find());
assertNull(matcher.group("ZEROPAD"));
@@ -46,7 +46,7 @@ public void testFilePatternWithSpacePadding() throws Exception {
}
@Test
- public void testFilePatternWithZeroPadding() throws Exception {
+ void testFilePatternWithZeroPadding() {
final Matcher matcher = AbstractRolloverStrategy.PATTERN_COUNTER.matcher("target/logs/test-%03i.log.gz");
assertTrue(matcher.find());
assertEquals("0", matcher.group("ZEROPAD"));
@@ -54,7 +54,7 @@ public void testFilePatternWithZeroPadding() throws Exception {
}
@Test
- public void testFilePatternUnmatched() throws Exception {
+ void testFilePatternUnmatched() {
final Matcher matcher = AbstractRolloverStrategy.PATTERN_COUNTER.matcher("target/logs/test-%n.log.gz");
assertFalse(matcher.find());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RolloverWithPaddingTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RolloverWithPaddingTest.java
index 72905b33a81..d31ecf5ec00 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RolloverWithPaddingTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RolloverWithPaddingTest.java
@@ -38,7 +38,7 @@
* Tests that zero-padding in rolled files works correctly.
*/
@UsingStatusListener
-public class RolloverWithPaddingTest {
+class RolloverWithPaddingTest {
private static final String[] EXPECTED_FILES = {
"rollingtest.log", "test-001.log", "test-002.log", "test-003.log", "test-004.log", "test-005.log"
@@ -50,7 +50,7 @@ public class RolloverWithPaddingTest {
@Test
@LoggerContextSource
- public void testPadding(final LoggerContext context) throws Exception {
+ void testPadding(final LoggerContext context) throws Exception {
final Logger logger = context.getLogger(getClass());
for (int i = 0; i < 10; ++i) {
// 30 chars per message: each message triggers a rollover
@@ -64,7 +64,7 @@ public void testPadding(final LoggerContext context) throws Exception {
@Test
@LoggerContextSource
- public void testOldFileDeleted(final LoggerContext context) throws Exception {
+ void testOldFileDeleted(final LoggerContext context) throws Exception {
final Logger logger = context.getLogger(getClass());
// Prepare directory
for (int i = 1; i <= 5; i++) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressActionTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressActionTest.java
index a3119c8bd80..0907ef1e8d5 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressActionTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressActionTest.java
@@ -34,20 +34,20 @@
/**
* Tests Bzip2CompressAction.
*/
-public class Bzip2CompressActionTest {
+class Bzip2CompressActionTest {
@Test
- public void testConstructorDisallowsNullSource() {
+ void testConstructorDisallowsNullSource() {
assertThrows(NullPointerException.class, () -> new CommonsCompressAction("bzip2", null, new File("any"), true));
}
@Test
- public void testConstructorDisallowsNullDestination() {
+ void testConstructorDisallowsNullDestination() {
assertThrows(NullPointerException.class, () -> new CommonsCompressAction("bzip2", new File("any"), null, true));
}
@Test
- public void testExecuteReturnsFalseIfSourceDoesNotExist() throws IOException {
+ void testExecuteReturnsFalseIfSourceDoesNotExist() throws IOException {
File source = new File("any");
while (source.exists()) {
source = new File(source.getName() + Math.random());
@@ -57,7 +57,7 @@ public void testExecuteReturnsFalseIfSourceDoesNotExist() throws IOException {
}
@Test
- public void testExecuteCompressesSourceFileToDestinationFile(@TempDir final File tempDir) throws IOException {
+ void testExecuteCompressesSourceFileToDestinationFile(@TempDir final File tempDir) throws IOException {
final String LINE1 = "Here is line 1. Random text: ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";
final String LINE2 = "Here is line 2. Random text: ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";
final String LINE3 = "Here is line 3. Random text: ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteActionTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteActionTest.java
index d57f4513f17..06548d5b2c1 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteActionTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteActionTest.java
@@ -36,7 +36,7 @@
/**
* Tests the {@code DeleteAction} class.
*/
-public class DeleteActionTest {
+class DeleteActionTest {
private static DeleteAction createAnyFilter(
final String path, final boolean followLinks, final int maxDepth, final boolean testMode) {
@@ -57,7 +57,7 @@ private static DeleteAction create(
}
@Test
- public void testGetBasePathResolvesLookups() {
+ void testGetBasePathResolvesLookups() {
final DeleteAction delete = createAnyFilter("${sys:user.home}/a/b/c", false, 1, false);
final Path actual = delete.getBasePath();
@@ -67,31 +67,31 @@ public void testGetBasePathResolvesLookups() {
}
@Test
- public void testGetBasePathStringReturnsOriginalParam() {
+ void testGetBasePathStringReturnsOriginalParam() {
final DeleteAction delete = createAnyFilter("${sys:user.home}/a/b/c", false, 1, false);
assertEquals("${sys:user.home}/a/b/c", delete.getBasePathString());
}
@Test
- public void testGetMaxDepthReturnsConstructorValue() {
+ void testGetMaxDepthReturnsConstructorValue() {
final DeleteAction delete = createAnyFilter("any", false, 23, false);
assertEquals(23, delete.getMaxDepth());
}
@Test
- public void testGetOptionsReturnsEmptySetIfNotFollowingLinks() {
+ void testGetOptionsReturnsEmptySetIfNotFollowingLinks() {
final DeleteAction delete = createAnyFilter("any", false, 0, false);
assertEquals(Collections.emptySet(), delete.getOptions());
}
@Test
- public void testGetOptionsReturnsSetWithFollowLinksIfFollowingLinks() {
+ void testGetOptionsReturnsSetWithFollowLinksIfFollowingLinks() {
final DeleteAction delete = createAnyFilter("any", true, 0, false);
assertEquals(EnumSet.of(FileVisitOption.FOLLOW_LINKS), delete.getOptions());
}
@Test
- public void testGetFiltersReturnsConstructorValue() {
+ void testGetFiltersReturnsConstructorValue() {
final PathCondition[] filters = {new FixedCondition(true), new FixedCondition(false)};
final DeleteAction delete = create("any", true, 0, false, filters);
@@ -99,14 +99,14 @@ public void testGetFiltersReturnsConstructorValue() {
}
@Test
- public void testCreateFileVisitorReturnsDeletingVisitor() {
+ void testCreateFileVisitorReturnsDeletingVisitor() {
final DeleteAction delete = createAnyFilter("any", true, 0, false);
final FileVisitor visitor = delete.createFileVisitor(delete.getBasePath(), delete.getPathConditions());
assertThat(visitor, instanceOf(DeletingVisitor.class));
}
@Test
- public void testCreateFileVisitorTestModeIsActionTestMode() {
+ void testCreateFileVisitorTestModeIsActionTestMode() {
final DeleteAction delete = createAnyFilter("any", true, 0, false);
assertFalse(delete.isTestMode());
final FileVisitor visitor = delete.createFileVisitor(delete.getBasePath(), delete.getPathConditions());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitorTest.java
index 5e0d2a84786..871f92789ae 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitorTest.java
@@ -37,7 +37,7 @@
/**
* Tests the {@code DeletingVisitor} class.
*/
-public class DeletingVisitorTest {
+class DeletingVisitorTest {
/**
* Modifies {@code DeletingVisitor} for testing: instead of actually deleting a file, it adds the path to a list for
* later verification.
@@ -51,13 +51,13 @@ public DeletingVisitorHelper(
}
@Override
- protected void delete(final Path file) throws IOException {
+ protected void delete(final Path file) {
deleted.add(file); // overrides and stores path instead of deleting
}
}
@Test
- public void testAcceptedFilesAreDeleted() throws IOException {
+ void testAcceptedFilesAreDeleted() throws IOException {
final Path base = Paths.get("/a/b/c");
final FixedCondition ACCEPT_ALL = new FixedCondition(true);
final DeletingVisitorHelper visitor =
@@ -69,7 +69,7 @@ public void testAcceptedFilesAreDeleted() throws IOException {
}
@Test
- public void testRejectedFilesAreNotDeleted() throws IOException {
+ void testRejectedFilesAreNotDeleted() throws IOException {
final Path base = Paths.get("/a/b/c");
final FixedCondition REJECT_ALL = new FixedCondition(false);
final DeletingVisitorHelper visitor =
@@ -81,7 +81,7 @@ public void testRejectedFilesAreNotDeleted() throws IOException {
}
@Test
- public void testAllFiltersMustAcceptOrFileIsNotDeleted() throws IOException {
+ void testAllFiltersMustAcceptOrFileIsNotDeleted() throws IOException {
final Path base = Paths.get("/a/b/c");
final FixedCondition ACCEPT_ALL = new FixedCondition(true);
final FixedCondition REJECT_ALL = new FixedCondition(false);
@@ -94,7 +94,7 @@ public void testAllFiltersMustAcceptOrFileIsNotDeleted() throws IOException {
}
@Test
- public void testIfAllFiltersAcceptFileIsDeleted() throws IOException {
+ void testIfAllFiltersAcceptFileIsDeleted() throws IOException {
final Path base = Paths.get("/a/b/c");
final FixedCondition ACCEPT_ALL = new FixedCondition(true);
final List extends PathCondition> filters = Arrays.asList(ACCEPT_ALL, ACCEPT_ALL, ACCEPT_ALL);
@@ -106,7 +106,7 @@ public void testIfAllFiltersAcceptFileIsDeleted() throws IOException {
}
@Test
- public void testInTestModeFileIsNotDeletedEvenIfAllFiltersAccept() throws IOException {
+ void testInTestModeFileIsNotDeletedEvenIfAllFiltersAccept() throws IOException {
final Path base = Paths.get("/a/b/c");
final FixedCondition ACCEPT_ALL = new FixedCondition(true);
final List extends PathCondition> filters = Arrays.asList(ACCEPT_ALL, ACCEPT_ALL, ACCEPT_ALL);
@@ -118,7 +118,7 @@ public void testInTestModeFileIsNotDeletedEvenIfAllFiltersAccept() throws IOExce
}
@Test
- public void testVisitFileRelativizesAgainstBase() throws IOException {
+ void testVisitFileRelativizesAgainstBase() throws IOException {
final PathCondition filter = new PathCondition() {
@@ -140,7 +140,7 @@ public void beforeFileTreeWalk() {}
}
@Test
- public void testNoSuchFileFailure() throws IOException {
+ void testNoSuchFileFailure() throws IOException {
final DeletingVisitorHelper visitor =
new DeletingVisitorHelper(Paths.get("/a/b/c"), Collections.emptyList(), true);
assertEquals(
@@ -149,7 +149,7 @@ public void testNoSuchFileFailure() throws IOException {
}
@Test
- public void testIOException() {
+ void testIOException() {
final DeletingVisitorHelper visitor =
new DeletingVisitorHelper(Paths.get("/a/b/c"), Collections.emptyList(), true);
final IOException exception = new IOException();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DurationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DurationTest.java
index 75d05c1be87..c66b937d322 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DurationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DurationTest.java
@@ -25,42 +25,42 @@
/**
* Tests the Duration class.
*/
-public class DurationTest {
+class DurationTest {
@Test
- public void testParseFailsIfNullText() {
+ void testParseFailsIfNullText() {
assertThrows(NullPointerException.class, () -> Duration.parse(null));
}
@Test
- public void testParseFailsIfInvalidPattern() {
+ void testParseFailsIfInvalidPattern() {
assertThrows(IllegalArgumentException.class, () -> Duration.parse("abc"));
}
@Test
- public void testParseFailsIfSectionsOutOfOrder() {
+ void testParseFailsIfSectionsOutOfOrder() {
assertThrows(IllegalArgumentException.class, () -> Duration.parse("P4DT2M1S3H"));
}
@Test
- public void testParseFailsIfTButMissingTime() {
+ void testParseFailsIfTButMissingTime() {
assertThrows(IllegalArgumentException.class, () -> Duration.parse("P1dT"));
}
@Test
- public void testParseIsCaseInsensitive() {
+ void testParseIsCaseInsensitive() {
assertEquals("P4DT3H2M1S", Duration.parse("p4dt3h2m1s").toString());
}
@Test
- public void testParseAllowsOverflows() {
+ void testParseAllowsOverflows() {
assertEquals(1000 * 70, Duration.parse("PT70S").toMillis());
assertEquals(1000 * 70 * 60, Duration.parse("PT70M").toMillis());
assertEquals(1000 * 25 * 60 * 60, Duration.parse("PT25H").toMillis());
}
@Test
- public void testToMillis() {
+ void testToMillis() {
assertEquals(0, Duration.ZERO.toMillis());
assertEquals(1000, Duration.parse("PT1S").toMillis());
assertEquals(1000 * 2 * 60, Duration.parse("PT2M").toMillis());
@@ -71,7 +71,7 @@ public void testToMillis() {
}
@Test
- public void testToString() {
+ void testToString() {
assertEquals("PT0S", Duration.ZERO.toString());
assertEquals("PT1S", Duration.parse("PT1S").toString());
assertEquals("PT2M1S", Duration.parse("PT2M1S").toString());
@@ -80,7 +80,7 @@ public void testToString() {
}
@Test
- public void testPrefixPNotRequired() {
+ void testPrefixPNotRequired() {
assertEquals("PT1S", Duration.parse("T1S").toString());
assertEquals("PT2M1S", Duration.parse("T2M1S").toString());
assertEquals("PT3H2M1S", Duration.parse("T3H2M1S").toString());
@@ -88,7 +88,7 @@ public void testPrefixPNotRequired() {
}
@Test
- public void testInfixTNotRequired() {
+ void testInfixTNotRequired() {
assertEquals("PT1S", Duration.parse("P1S").toString());
assertEquals("PT2M1S", Duration.parse("P2M1S").toString());
assertEquals("PT3H2M1S", Duration.parse("P3H2M1S").toString());
@@ -96,7 +96,7 @@ public void testInfixTNotRequired() {
}
@Test
- public void testPrefixPAndInfixTNotRequired() {
+ void testPrefixPAndInfixTNotRequired() {
assertEquals("PT1S", Duration.parse("1S").toString());
assertEquals("PT2M1S", Duration.parse("2M1S").toString());
assertEquals("PT3H2M1S", Duration.parse("3H2M1S").toString());
@@ -104,7 +104,7 @@ public void testPrefixPAndInfixTNotRequired() {
}
@Test
- public void testCompareTo() {
+ void testCompareTo() {
assertEquals(-1, Duration.parse("PT1S").compareTo(Duration.parse("PT2S")));
assertEquals(-1, Duration.parse("PT1M").compareTo(Duration.parse("PT2M")));
assertEquals(-1, Duration.parse("PT1H").compareTo(Duration.parse("PT2H")));
@@ -128,7 +128,7 @@ public void testCompareTo() {
}
@Test
- public void testEquals() {
+ void testEquals() {
assertNotEquals(Duration.parse("PT1S"), (Duration.parse("PT2S")));
assertNotEquals(Duration.parse("PT1M"), (Duration.parse("PT2M")));
assertNotEquals(Duration.parse("PT1H"), (Duration.parse("PT2H")));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameActionTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameActionTest.java
index 7309e6e7ccf..9b179441db5 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameActionTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameActionTest.java
@@ -24,18 +24,18 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
-public class FileRenameActionTest {
+class FileRenameActionTest {
static File tempDir = new File("./target");
@AfterEach
- public void cleanup() {
+ void cleanup() {
final File file = new File(tempDir, "newFile.log");
file.delete();
}
@Test
- public void testRename1() throws Exception {
+ void testRename1() throws Exception {
final File file = new File(tempDir, "fileRename.log");
try (final PrintStream pos = new PrintStream(file)) {
for (int i = 0; i < 100; ++i) {
@@ -52,7 +52,7 @@ public void testRename1() throws Exception {
}
@Test
- public void testEmpty() throws Exception {
+ void testEmpty() throws Exception {
final File file = new File(tempDir, "fileRename.log");
try (final PrintStream pos = new PrintStream(file)) {
// do nothing
@@ -67,7 +67,7 @@ public void testEmpty() throws Exception {
}
@Test
- public void testRenameEmpty() throws Exception {
+ void testRenameEmpty() throws Exception {
final File file = new File(tempDir, "fileRename.log");
try (final PrintStream pos = new PrintStream(file)) {
// do nothing
@@ -82,7 +82,7 @@ public void testRenameEmpty() throws Exception {
}
@Test
- public void testNoParent() throws Exception {
+ void testNoParent() throws Exception {
final File file = new File("fileRename.log");
try (final PrintStream pos = new PrintStream(file)) {
for (int i = 0; i < 100; ++i) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FileSizeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FileSizeTest.java
index b0da9d6d00b..729a5d2e858 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FileSizeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FileSizeTest.java
@@ -24,16 +24,16 @@
import org.junit.jupiter.api.parallel.ResourceLock;
import org.junit.jupiter.api.parallel.Resources;
-public class FileSizeTest {
+class FileSizeTest {
@Test
- public void testParse() {
+ void testParse() {
assertEquals(5 * 1024, FileSize.parse("5k", 0));
}
@Test
@ResourceLock(Resources.LOCALE)
- public void testParseInEurope() {
+ void testParseInEurope() {
// Caveat: Breaks the ability for this test to run in parallel with other tests :(
final Locale previousDefault = Locale.getDefault();
try {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCountTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCountTest.java
index e94f2b5edd1..84120c63d53 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCountTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCountTest.java
@@ -25,16 +25,16 @@
/**
* Tests the IfAccumulatedFileCount class.
*/
-public class IfAccumulatedFileCountTest {
+class IfAccumulatedFileCountTest {
@Test
- public void testGetThresholdCount() {
+ void testGetThresholdCount() {
assertEquals(123, IfAccumulatedFileCount.createFileCountCondition(123).getThresholdCount());
assertEquals(456, IfAccumulatedFileCount.createFileCountCondition(456).getThresholdCount());
}
@Test
- public void testAccept() {
+ void testAccept() {
final int[] counts = {3, 5, 9};
for (final int count : counts) {
final IfAccumulatedFileCount condition = IfAccumulatedFileCount.createFileCountCondition(count);
@@ -49,7 +49,7 @@ public void testAccept() {
}
@Test
- public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
+ void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
final CountingCondition counter = new CountingCondition(true);
final IfAccumulatedFileCount condition = IfAccumulatedFileCount.createFileCountCondition(3, counter);
@@ -65,7 +65,7 @@ public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
}
@Test
- public void testBeforeTreeWalk() {
+ void testBeforeTreeWalk() {
final CountingCondition counter = new CountingCondition(true);
final IfAccumulatedFileCount filter =
IfAccumulatedFileCount.createFileCountCondition(30, counter, counter, counter);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSizeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSizeTest.java
index 0605842a7e1..08fa6aa98d8 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSizeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSizeTest.java
@@ -26,10 +26,10 @@
/**
* Tests the IfAccumulatedFileSize class.
*/
-public class IfAccumulatedFileSizeTest {
+class IfAccumulatedFileSizeTest {
@Test
- public void testGetThresholdBytes() {
+ void testGetThresholdBytes() {
assertEquals(2, create("2B").getThresholdBytes());
assertEquals(3, create("3 B").getThresholdBytes());
assertEquals(2 * 1024, create("2KB").getThresholdBytes());
@@ -47,7 +47,7 @@ private static IfAccumulatedFileSize create(final String size) {
}
@Test
- public void testNotAcceptOnExactMatch() {
+ void testNotAcceptOnExactMatch() {
final String[] sizes = {"2KB", "3MB", "4GB", "5TB"};
for (final String size : sizes) {
final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
@@ -58,7 +58,7 @@ public void testNotAcceptOnExactMatch() {
}
@Test
- public void testAcceptIfExceedThreshold() {
+ void testAcceptIfExceedThreshold() {
final String[] sizes = {"2KB", "3MB", "4GB", "5TB"};
for (final String size : sizes) {
final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
@@ -69,7 +69,7 @@ public void testAcceptIfExceedThreshold() {
}
@Test
- public void testNotAcceptIfBelowThreshold() {
+ void testNotAcceptIfBelowThreshold() {
final String[] sizes = {"2KB", "3MB", "4GB", "5TB"};
for (final String size : sizes) {
final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
@@ -80,7 +80,7 @@ public void testNotAcceptIfBelowThreshold() {
}
@Test
- public void testAcceptOnceThresholdExceeded() {
+ void testAcceptOnceThresholdExceeded() {
final DummyFileAttributes attribs = new DummyFileAttributes();
final String[] sizes = {"2KB", "3MB", "4GB", "5TB"};
for (final String size : sizes) {
@@ -96,7 +96,7 @@ public void testAcceptOnceThresholdExceeded() {
}
@Test
- public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
+ void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
final CountingCondition counter = new CountingCondition(true);
final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition("2KB", counter);
final DummyFileAttributes attribs = new DummyFileAttributes();
@@ -123,7 +123,7 @@ public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
}
@Test
- public void testBeforeTreeWalk() {
+ void testBeforeTreeWalk() {
final CountingCondition counter = new CountingCondition(true);
final IfAccumulatedFileSize filter =
IfAccumulatedFileSize.createFileSizeCondition("2GB", counter, counter, counter);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAnyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAnyTest.java
index 7ed92516851..9fea2f12986 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAnyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAnyTest.java
@@ -42,7 +42,7 @@
class IfAnyTest {
@Test
- public void test() {
+ void test() {
final PathCondition TRUE = new FixedCondition(true);
final PathCondition FALSE = new FixedCondition(false);
assertTrue(IfAny.createOrCondition(TRUE, TRUE).accept(null, null, null));
@@ -52,12 +52,12 @@ public void test() {
}
@Test
- public void testEmptyIsFalse() {
+ void testEmptyIsFalse() {
assertFalse(IfAny.createOrCondition().accept(null, null, null));
}
@Test
- public void testBeforeTreeWalk() {
+ void testBeforeTreeWalk() {
final CountingCondition counter = new CountingCondition(true);
final IfAny or = IfAny.createOrCondition(counter, counter, counter);
or.beforeFileTreeWalk();
@@ -65,14 +65,14 @@ public void testBeforeTreeWalk() {
}
@Test
- public void testCreateOrConditionCalledProgrammaticallyThrowsNPEWhenComponentsNotSpecified() {
+ void testCreateOrConditionCalledProgrammaticallyThrowsNPEWhenComponentsNotSpecified() {
PathCondition[] components = null;
assertThrows(NullPointerException.class, () -> IfAny.createOrCondition(components));
}
@ParameterizedTest
@ValueSource(strings = "No components provided for IfAny")
- public void testCreateOrConditionCalledByPluginBuilderReturnsNullAndLogsMessageWhenComponentsNotSpecified(
+ void testCreateOrConditionCalledByPluginBuilderReturnsNullAndLogsMessageWhenComponentsNotSpecified(
final String expectedMessage) {
final PluginEntry nullEntry = null;
final PluginType type = new PluginType<>(nullEntry, IfAny.class, "Dummy");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileNameTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileNameTest.java
index d307a37cde7..8fe68f5c334 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileNameTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileNameTest.java
@@ -25,22 +25,22 @@
import java.nio.file.Paths;
import org.junit.jupiter.api.Test;
-public class IfFileNameTest {
+class IfFileNameTest {
@Test
- public void testCreateNameConditionFailsIfBothRegexAndPathAreNull() {
+ void testCreateNameConditionFailsIfBothRegexAndPathAreNull() {
assertThrows(IllegalArgumentException.class, () -> IfFileName.createNameCondition(null, null));
}
@Test
- public void testCreateNameConditionAcceptsIfEitherRegexOrPathOrBothAreNonNull() {
+ void testCreateNameConditionAcceptsIfEitherRegexOrPathOrBothAreNonNull() {
IfFileName.createNameCondition("bar", null);
IfFileName.createNameCondition(null, "foo");
IfFileName.createNameCondition("bar", "foo");
}
@Test
- public void testGetSyntaxAndPattern() {
+ void testGetSyntaxAndPattern() {
assertEquals("glob:path", IfFileName.createNameCondition("path", null).getSyntaxAndPattern());
assertEquals(
"glob:path", IfFileName.createNameCondition("glob:path", null).getSyntaxAndPattern());
@@ -50,7 +50,7 @@ public void testGetSyntaxAndPattern() {
}
@Test
- public void testAcceptUsesPathPatternIfExists() {
+ void testAcceptUsesPathPatternIfExists() {
final IfFileName filter = IfFileName.createNameCondition("path", "regex");
final Path relativePath = Paths.get("path");
assertTrue(filter.accept(null, relativePath, null));
@@ -60,7 +60,7 @@ public void testAcceptUsesPathPatternIfExists() {
}
@Test
- public void testAcceptUsesRegexIfNoPathPatternExists() {
+ void testAcceptUsesRegexIfNoPathPatternExists() {
final IfFileName regexFilter = IfFileName.createNameCondition(null, "regex");
final Path pathMatchingRegex = Paths.get("regex");
assertTrue(regexFilter.accept(null, pathMatchingRegex, null));
@@ -70,7 +70,7 @@ public void testAcceptUsesRegexIfNoPathPatternExists() {
}
@Test
- public void testAcceptIgnoresBasePathAndAttributes() {
+ void testAcceptIgnoresBasePathAndAttributes() {
final IfFileName pathFilter = IfFileName.createNameCondition("path", null);
final Path relativePath = Paths.get("path");
assertTrue(pathFilter.accept(null, relativePath, null));
@@ -81,7 +81,7 @@ public void testAcceptIgnoresBasePathAndAttributes() {
}
@Test
- public void testAcceptCallsNestedConditionsOnlyIfPathAccepted1() {
+ void testAcceptCallsNestedConditionsOnlyIfPathAccepted1() {
final CountingCondition counter = new CountingCondition(true);
final IfFileName regexFilter = IfFileName.createNameCondition(null, "regex", counter);
final Path pathMatchingRegex = Paths.get("regex");
@@ -103,7 +103,7 @@ public void testAcceptCallsNestedConditionsOnlyIfPathAccepted1() {
}
@Test
- public void testAcceptCallsNestedConditionsOnlyIfPathAccepted2() {
+ void testAcceptCallsNestedConditionsOnlyIfPathAccepted2() {
final CountingCondition counter = new CountingCondition(true);
final IfFileName globFilter = IfFileName.createNameCondition("glob", null, counter);
final Path pathMatchingGlob = Paths.get("glob");
@@ -125,7 +125,7 @@ public void testAcceptCallsNestedConditionsOnlyIfPathAccepted2() {
}
@Test
- public void testBeforeTreeWalk() {
+ void testBeforeTreeWalk() {
final CountingCondition counter = new CountingCondition(true);
final IfFileName pathFilter = IfFileName.createNameCondition("path", null, counter, counter, counter);
pathFilter.beforeFileTreeWalk();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
index 22bf04e43f1..41a758fe5c5 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
@@ -45,7 +45,7 @@
class IfLastModifiedTest {
@Test
- public void testAcceptsIfFileAgeEqualToDuration() {
+ void testAcceptsIfFileAgeEqualToDuration() {
final IfLastModified filter =
IfLastModified.newBuilder().setAge(Duration.parse("PT33S")).build();
final DummyFileAttributes attrs = new DummyFileAttributes();
@@ -55,7 +55,7 @@ public void testAcceptsIfFileAgeEqualToDuration() {
}
@Test
- public void testAcceptsIfFileAgeExceedsDuration() {
+ void testAcceptsIfFileAgeExceedsDuration() {
final IfLastModified filter =
IfLastModified.newBuilder().setAge(Duration.parse("PT33S")).build();
final DummyFileAttributes attrs = new DummyFileAttributes();
@@ -65,7 +65,7 @@ public void testAcceptsIfFileAgeExceedsDuration() {
}
@Test
- public void testDoesNotAcceptIfFileAgeLessThanDuration() {
+ void testDoesNotAcceptIfFileAgeLessThanDuration() {
final IfLastModified filter =
IfLastModified.newBuilder().setAge(Duration.parse("PT33S")).build();
final DummyFileAttributes attrs = new DummyFileAttributes();
@@ -75,7 +75,7 @@ public void testDoesNotAcceptIfFileAgeLessThanDuration() {
}
@Test
- public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
+ void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
final CountingCondition counter = new CountingCondition(true);
final IfLastModified filter = IfLastModified.newBuilder()
.setAge(Duration.parse("PT33S"))
@@ -103,7 +103,7 @@ public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
}
@Test
- public void testBeforeTreeWalk() {
+ void testBeforeTreeWalk() {
final CountingCondition counter = new CountingCondition(true);
final IfLastModified filter = IfLastModified.newBuilder()
.setAge(Duration.parse("PT33S"))
@@ -114,7 +114,7 @@ public void testBeforeTreeWalk() {
}
@Test
- public void testCreateAgeConditionCalledProgrammaticallyThrowsNPEWhenAgeIsNotSpecified() {
+ void testCreateAgeConditionCalledProgrammaticallyThrowsNPEWhenAgeIsNotSpecified() {
Duration age = null;
assertThrows(
NullPointerException.class, () -> IfLastModified.newBuilder().setAge(age));
@@ -122,7 +122,7 @@ public void testCreateAgeConditionCalledProgrammaticallyThrowsNPEWhenAgeIsNotSpe
@ParameterizedTest
@ValueSource(strings = "No age provided for IfLastModified")
- public void testCreateAgeConditionCalledByPluginBuilderReturnsNullAndLogsMessageWhenAgeIsNotSpecified(
+ void testCreateAgeConditionCalledByPluginBuilderReturnsNullAndLogsMessageWhenAgeIsNotSpecified(
final String expectedMessage) {
final PluginEntry nullEntry = null;
final PluginType type = new PluginType<>(nullEntry, IfLastModified.class, "Dummy");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfNotTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfNotTest.java
index 2398fb2a501..43637e4d4e2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfNotTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfNotTest.java
@@ -42,7 +42,7 @@
class IfNotTest {
@Test
- public void test() {
+ void test() {
assertTrue(new FixedCondition(true).accept(null, null, null));
assertFalse(IfNot.createNotCondition(new FixedCondition(true)).accept(null, null, null));
@@ -51,13 +51,13 @@ public void test() {
}
@Test
- public void testEmptyIsFalse() {
+ void testEmptyIsFalse() {
assertThrows(
NullPointerException.class, () -> IfNot.createNotCondition(null).accept(null, null, null));
}
@Test
- public void testBeforeTreeWalk() {
+ void testBeforeTreeWalk() {
final CountingCondition counter = new CountingCondition(true);
final IfNot not = IfNot.createNotCondition(counter);
not.beforeFileTreeWalk();
@@ -65,14 +65,14 @@ public void testBeforeTreeWalk() {
}
@Test
- public void testCreateNotConditionCalledProgrammaticallyThrowsNPEWhenToNegateIsNotSpecified() {
+ void testCreateNotConditionCalledProgrammaticallyThrowsNPEWhenToNegateIsNotSpecified() {
PathCondition toNegate = null;
assertThrows(NullPointerException.class, () -> IfNot.createNotCondition(toNegate));
}
@ParameterizedTest
@ValueSource(strings = "No condition provided for IfNot")
- public void testCreateNotConditionCalledByPluginBuilderReturnsNullAndLogsMessageWhenToNegateIsNotSpecified(
+ void testCreateNotConditionCalledByPluginBuilderReturnsNullAndLogsMessageWhenToNegateIsNotSpecified(
final String expectedMessage) {
final PluginEntry nullEntry = null;
final PluginType type = new PluginType<>(nullEntry, IfNot.class, "Dummy");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathConditionTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathConditionTest.java
index 823258c2080..5b735c2bd2b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathConditionTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathConditionTest.java
@@ -16,19 +16,19 @@
*/
package org.apache.logging.log4j.core.appender.rolling.action;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
import org.junit.jupiter.api.Test;
-public class PathConditionTest {
+class PathConditionTest {
private static final PathCondition[] EMPTY_FIXTURE = {};
private static final PathCondition[] NULL_FIXTURE = null;
@Test
- public void testCopy() {
+ void testCopy() {
assertArrayEquals(EMPTY_FIXTURE, PathCondition.copy(NULL_FIXTURE));
assertArrayEquals(EMPTY_FIXTURE, PathCondition.copy(EMPTY_FIXTURE));
assertArrayEquals(EMPTY_FIXTURE, PathCondition.copy(PathCondition.EMPTY_ARRAY));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTimeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTimeTest.java
index 8c023998550..5e3abad830f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTimeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTimeTest.java
@@ -29,20 +29,20 @@
/**
* Tests the {@code PathSortByModificationTime} class.
*/
-public class PathSortByModificationTimeTest {
+class PathSortByModificationTimeTest {
/**
* Test method for
* {@link org.apache.logging.log4j.core.appender.rolling.action.PathSortByModificationTime#isRecentFirst()}.
*/
@Test
- public void testIsRecentFirstReturnsConstructorValue() {
+ void testIsRecentFirstReturnsConstructorValue() {
assertTrue(((PathSortByModificationTime) PathSortByModificationTime.createSorter(true)).isRecentFirst());
assertFalse(((PathSortByModificationTime) PathSortByModificationTime.createSorter(false)).isRecentFirst());
}
@Test
- public void testCompareRecentFirst() {
+ void testCompareRecentFirst() {
final PathSorter sorter = PathSortByModificationTime.createSorter(true);
final Path p1 = Paths.get("aaa");
final Path p2 = Paths.get("bbb");
@@ -65,7 +65,7 @@ public void testCompareRecentFirst() {
}
@Test
- public void testCompareRecentLast() {
+ void testCompareRecentLast() {
final PathSorter sorter = PathSortByModificationTime.createSorter(false);
final Path p1 = Paths.get("aaa");
final Path p2 = Paths.get("bbb");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptConditionTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptConditionTest.java
index fcbc287a960..2361202f7ff 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptConditionTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptConditionTest.java
@@ -38,34 +38,34 @@
* Tests the ScriptCondition class.
*/
@SetSystemProperty(key = Constants.SCRIPT_LANGUAGES, value = "js, javascript, groovy")
-public class ScriptConditionTest {
+class ScriptConditionTest {
@Test
- public void testConstructorDisallowsNullScript() {
+ void testConstructorDisallowsNullScript() {
assertNull(ScriptCondition.createCondition(null, new DefaultConfiguration()));
}
@Test
- public void testConstructorDisallowsNullConfig() {
+ void testConstructorDisallowsNullConfig() {
assertThrows(
NullPointerException.class,
() -> ScriptCondition.createCondition(new Script("test", "js", "print('hi')"), null));
}
@Test
- public void testCreateConditionReturnsNullForNullScript() {
+ void testCreateConditionReturnsNullForNullScript() {
assertNull(ScriptCondition.createCondition(null, new DefaultConfiguration()));
}
@Test
- public void testCreateConditionDisallowsNullConfig() {
+ void testCreateConditionDisallowsNullConfig() {
assertThrows(
NullPointerException.class,
() -> ScriptCondition.createCondition(new Script("test", "js", "print('hi')"), null));
}
@Test
- public void testSelectFilesToDelete() {
+ void testSelectFilesToDelete() {
final Configuration config = new DefaultConfiguration();
config.initialize(); // creates the ScriptManager
@@ -78,7 +78,7 @@ public void testSelectFilesToDelete() {
}
@Test
- public void testSelectFilesToDelete2() {
+ void testSelectFilesToDelete2() {
final Configuration config = new DefaultConfiguration();
config.initialize(); // creates the ScriptManager
@@ -101,7 +101,7 @@ public void testSelectFilesToDelete2() {
@Test
@Tag("groovy")
- public void testSelectFilesToDelete3() {
+ void testSelectFilesToDelete3() {
final Configuration config = new DefaultConfiguration();
config.initialize(); // creates the ScriptManager
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitorTest.java
index 29ab4089b36..a6e854525ae 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitorTest.java
@@ -39,7 +39,7 @@
/**
* Tests the SortingVisitor class.
*/
-public class SortingVisitorTest {
+class SortingVisitorTest {
@TempDir
Path base;
@@ -49,7 +49,7 @@ public class SortingVisitorTest {
private Path ccc;
@BeforeEach
- public void setUp() throws Exception {
+ void setUp() throws Exception {
aaa = Files.createFile(base.resolve("aaa"));
bbb = Files.createFile(base.resolve("bbb"));
ccc = Files.createFile(base.resolve("ccc"));
@@ -62,7 +62,7 @@ public void setUp() throws Exception {
}
@Test
- public void testRecentFirst() throws Exception {
+ void testRecentFirst() throws Exception {
final SortingVisitor visitor = new SortingVisitor(new PathSortByModificationTime(true));
final Set options = Collections.emptySet();
Files.walkFileTree(base, options, 1, visitor);
@@ -76,7 +76,7 @@ public void testRecentFirst() throws Exception {
}
@Test
- public void testRecentLast() throws Exception {
+ void testRecentLast() throws Exception {
final SortingVisitor visitor = new SortingVisitor(new PathSortByModificationTime(false));
final Set options = Collections.emptySet();
Files.walkFileTree(base, options, 1, visitor);
@@ -90,7 +90,7 @@ public void testRecentLast() throws Exception {
}
@Test
- public void testNoSuchFileFailure() throws IOException {
+ void testNoSuchFileFailure() throws IOException {
final SortingVisitor visitor = new SortingVisitor(new PathSortByModificationTime(false));
assertSame(
FileVisitResult.CONTINUE,
@@ -98,7 +98,7 @@ public void testNoSuchFileFailure() throws IOException {
}
@Test
- public void testIOException() {
+ void testIOException() {
final SortingVisitor visitor = new SortingVisitor(new PathSortByModificationTime(false));
final IOException exception = new IOException();
assertSame(
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppender2Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppender2Test.java
index 2b53e9e6ce7..f57db401175 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppender2Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppender2Test.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.appender.routing;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -47,7 +48,7 @@ public void routingTest() {
EventLogger.logEvent(msg);
final List list = loggerContextRule.getListAppender("List").getEvents();
assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
+ assertEquals("Incorrect number of events. Expected 1, got " + list.size(), 1, list.size());
msg = new StructuredDataMessage("Test", "This is a test", "Unknown");
EventLogger.logEvent(msg);
final File file = new File(LOG_FILENAME);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppenderTest.java
index b4dcf13494f..886848078c5 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppenderTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.appender.routing;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -47,7 +48,7 @@ public void routingTest() {
EventLogger.logEvent(msg);
final List list = loggerContextRule.getListAppender("List").getEvents();
assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
+ assertEquals("Incorrect number of events. Expected 1, got " + list.size(), 1, list.size());
msg = new StructuredDataMessage("Test", "This is a test", "Unknown");
EventLogger.logEvent(msg);
final File file = new File(LOG_FILENAME);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/PropertiesRoutingAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/PropertiesRoutingAppenderTest.java
index 8c39e5ce852..76c68ed7849 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/PropertiesRoutingAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/PropertiesRoutingAppenderTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.appender.routing;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -49,12 +50,12 @@ public class PropertiesRoutingAppenderTest {
public RuleChain rules = loggerContextRule.withCleanFilesRule(UNKNOWN_LOG_FILE, ALERT_LOG_FILE, ACTIVITY_LOG_FILE);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.app = this.loggerContextRule.getListAppender("List");
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
this.app.clear();
this.loggerContextRule.getLoggerContext().stop();
}
@@ -65,7 +66,7 @@ public void routingTest() {
EventLogger.logEvent(msg);
final List list = app.getEvents();
assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
+ assertEquals("Incorrect number of events. Expected 1, got " + list.size(), 1, list.size());
msg = new StructuredDataMessage("Test", "This is a test", "Alert");
EventLogger.logEvent(msg);
File file = new File(ALERT_LOG_FILE);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender2767Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender2767Test.java
index f1f1a588b15..63666788982 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender2767Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender2767Test.java
@@ -45,10 +45,10 @@ public class RoutingAppender2767Test {
public RuleChain rules = loggerContextRule.withCleanFilesRule(ACTIVITY_LOG_FILE);
@Before
- public void setUp() throws Exception {}
+ public void setUp() {}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
this.loggerContextRule.getLoggerContext().stop();
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender3350Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender3350Test.java
index e2ad0871bdc..cbacf056b84 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender3350Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender3350Test.java
@@ -43,7 +43,7 @@ public class RoutingAppender3350Test {
public RuleChain rules = loggerContextRule.withCleanFilesRule(LOG_FILE);
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
this.loggerContextRule.getLoggerContext().stop();
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderKeyLookupEvaluationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderKeyLookupEvaluationTest.java
index f38013658b7..e44ffc0eaed 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderKeyLookupEvaluationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderKeyLookupEvaluationTest.java
@@ -38,13 +38,13 @@ public class RoutingAppenderKeyLookupEvaluationTest {
public final LoggerContextRule loggerContextRule = new LoggerContextRule(CONFIG);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
ThreadContext.remove(KEY);
this.app = this.loggerContextRule.getListAppender("List");
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
this.app.clear();
this.loggerContextRule.getLoggerContext().stop();
ThreadContext.remove(KEY);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
index d69912f9215..eaaa3255e39 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.appender.routing;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -49,12 +50,12 @@ public class RoutingAppenderTest {
public RuleChain rules = loggerContextRule.withCleanFilesRule(UNKNOWN_LOG_FILE, ALERT_LOG_FILE, ACTIVITY_LOG_FILE);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.app = this.loggerContextRule.getListAppender("List");
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
this.app.clear();
this.loggerContextRule.getLoggerContext().stop();
}
@@ -65,7 +66,7 @@ public void routingTest() {
EventLogger.logEvent(msg);
final List list = app.getEvents();
assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
+ assertEquals("Incorrect number of events. Expected 1, got " + list.size(), 1, list.size());
msg = new StructuredDataMessage("Test", "This is a test", "Alert");
EventLogger.logEvent(msg);
File file = new File(ALERT_LOG_FILE);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
index aa951efbb8e..0d7f8d83009 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.appender.routing;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -59,7 +60,7 @@ private static Map initBindings() {
}
@Before
- public void before() throws NamingException {
+ public void before() {
listAppender1 = RoutingAppenderWithJndiTest.loggerContextRule.getListAppender("List1");
listAppender2 = RoutingAppenderWithJndiTest.loggerContextRule.getListAppender("List2");
}
@@ -91,10 +92,11 @@ public void routingTest() throws NamingException {
msg = new StructuredDataMessage("Test", "This is a message from Application1", "Context");
EventLogger.logEvent(msg);
assertNotNull("No events generated", listAppender1.getEvents());
- assertTrue(
+ assertEquals(
"Incorrect number of events. Expected 1, got "
+ listAppender1.getEvents().size(),
- listAppender1.getEvents().size() == 1);
+ 1,
+ listAppender1.getEvents().size());
// now set jndi resource to Application2
context.rebind(JNDI_CONTEXT_NAME, "Application2");
@@ -102,26 +104,30 @@ public void routingTest() throws NamingException {
msg = new StructuredDataMessage("Test", "This is a message from Application2", "Context");
EventLogger.logEvent(msg);
assertNotNull("No events generated", listAppender2.getEvents());
- assertTrue(
+ assertEquals(
"Incorrect number of events. Expected 1, got "
+ listAppender2.getEvents().size(),
- listAppender2.getEvents().size() == 1);
- assertTrue(
+ 1,
+ listAppender2.getEvents().size());
+ assertEquals(
"Incorrect number of events. Expected 1, got "
+ listAppender1.getEvents().size(),
- listAppender1.getEvents().size() == 1);
+ 1,
+ listAppender1.getEvents().size());
msg = new StructuredDataMessage("Test", "This is another message from Application2", "Context");
EventLogger.logEvent(msg);
assertNotNull("No events generated", listAppender2.getEvents());
- assertTrue(
+ assertEquals(
"Incorrect number of events. Expected 2, got "
+ listAppender2.getEvents().size(),
- listAppender2.getEvents().size() == 2);
- assertTrue(
+ 2,
+ listAppender2.getEvents().size());
+ assertEquals(
"Incorrect number of events. Expected 1, got "
+ listAppender1.getEvents().size(),
- listAppender1.getEvents().size() == 1);
+ 1,
+ listAppender1.getEvents().size());
// now set jndi resource to Application3.
// The context name, 'Application3', will be used as log file name by the default route.
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithPurgingTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithPurgingTest.java
index f0b760dab5b..9d40d070e2b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithPurgingTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithPurgingTest.java
@@ -60,7 +60,7 @@ public class RoutingAppenderWithPurgingTest {
IDLE_LOG_FILE1, IDLE_LOG_FILE2, IDLE_LOG_FILE3, MANUAL_LOG_FILE1, MANUAL_LOG_FILE2, MANUAL_LOG_FILE3);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
this.app = this.loggerContextRule.getListAppender("List");
this.routingAppenderIdle =
this.loggerContextRule.getRequiredAppender("RoutingPurgeIdle", RoutingAppender.class);
@@ -71,7 +71,7 @@ public void setUp() throws Exception {
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
this.app.clear();
this.loggerContextRule.getLoggerContext().stop();
}
@@ -82,7 +82,7 @@ public void routingTest() throws InterruptedException {
EventLogger.logEvent(msg);
final List list = app.getEvents();
assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
+ assertEquals("Incorrect number of events. Expected 1, got " + list.size(), 1, list.size());
msg = new StructuredDataMessage("2", "This is a test 2", "Service");
EventLogger.logEvent(msg);
msg = new StructuredDataMessage("3", "This is a test 3", "Service");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java
index 4d0c7ce3a8a..91eca1321f0 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.appender.routing;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -46,7 +47,7 @@ public void routingTest() {
EventLogger.logEvent(msg);
final List list = loggerContextRule.getListAppender("List").getEvents();
assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
+ assertEquals("Incorrect number of events. Expected 1, got " + list.size(), 1, list.size());
msg = new StructuredDataMessage("Test", "This is a test", "Alert");
EventLogger.logEvent(msg);
final File file = new File(LOG_FILE);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderExceptionHandlingTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderExceptionHandlingTest.java
index db9fad8e88b..430739b225f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderExceptionHandlingTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderExceptionHandlingTest.java
@@ -16,6 +16,10 @@
*/
package org.apache.logging.log4j.core.async;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -30,7 +34,6 @@
import org.apache.logging.log4j.core.test.appender.FailOnceAppender;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.util.Strings;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@@ -74,18 +77,18 @@ void AsyncAppender_should_not_stop_on_appender_failures(final String throwableCl
// Stop the AsyncAppender to drain the queued events.
final Configuration configuration = loggerContext.getConfiguration();
final AsyncAppender asyncAppender = configuration.getAppender("Async");
- Assertions.assertNotNull(asyncAppender, "couldn't obtain the FailOnceAppender");
+ assertNotNull(asyncAppender, "couldn't obtain the FailOnceAppender");
asyncAppender.stop();
// Verify the logged message.
final FailOnceAppender failOnceAppender = configuration.getAppender("FailOnce");
- Assertions.assertNotNull(failOnceAppender, "couldn't obtain the FailOnceAppender");
- Assertions.assertTrue(failOnceAppender.isFailed(), "FailOnceAppender hasn't failed yet");
+ assertNotNull(failOnceAppender, "couldn't obtain the FailOnceAppender");
+ assertTrue(failOnceAppender.isFailed(), "FailOnceAppender hasn't failed yet");
final List accumulatedMessages = failOnceAppender.drainEvents().stream()
.map(LogEvent::getMessage)
.map(Message::getFormattedMessage)
.collect(Collectors.toList());
- Assertions.assertEquals(Collections.singletonList(lastLogMessage), accumulatedMessages);
+ assertEquals(Collections.singletonList(lastLogMessage), accumulatedMessages);
} finally {
System.setProperty(throwableClassNamePropertyName, Strings.EMPTY);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerArgumentFreedOnErrorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerArgumentFreedOnErrorTest.java
index 7dd54b7f761..9a4c9c7c8f6 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerArgumentFreedOnErrorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerArgumentFreedOnErrorTest.java
@@ -20,16 +20,16 @@
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.test.junit.UsingStatusListener;
import org.apache.logging.log4j.util.StringBuilderFormattable;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junitpioneer.jupiter.SetSystemProperty;
-@Category(AsyncLoggers.class)
+@Tag(Tags.ASYNC_LOGGERS)
class AsyncLoggerArgumentFreedOnErrorTest {
/**
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerClassLoadDeadlockTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerClassLoadDeadlockTest.java
index 2cec75e28ba..7a5301e757e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerClassLoadDeadlockTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerClassLoadDeadlockTest.java
@@ -16,31 +16,34 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
/**
* Test class loading deadlock condition from the LOG4J2-1457
*/
-@Category(AsyncLoggers.class)
-public class AsyncLoggerClassLoadDeadlockTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerClassLoadDeadlockTest {
static final int RING_BUFFER_SIZE = 128;
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
System.setProperty("AsyncLogger.RingBufferSize", String.valueOf(RING_BUFFER_SIZE));
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerConsoleTest.xml");
}
- @Test(timeout = 30000)
- public void testClassLoaderDeadlock() throws Exception {
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
+ void testClassLoaderDeadlock() {
// touch the class so static init will be called
final AsyncLoggerClassLoadDeadlock temp = new AsyncLoggerClassLoadDeadlock();
assertNotNull(temp);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigAutoFlushTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigAutoFlushTest.java
index a2e909ac93a..d79ec54848e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigAutoFlushTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigAutoFlushTest.java
@@ -16,8 +16,8 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
@@ -26,23 +26,23 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerConfigAutoFlushTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerConfigAutoFlushTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerConfigAutoFlushTest.xml");
}
@Test
- public void testFlushAtEndOfBatch() throws Exception {
+ void testFlushAtEndOfBatch() throws Exception {
final File file = new File("target", "AsyncLoggerConfigAutoFlushTest.log");
- assertTrue("Deleted old file before test", !file.exists() || file.delete());
+ assertTrue(!file.exists() || file.delete(), "Deleted old file before test");
final Logger log = LogManager.getLogger("com.foo.Bar");
final String msg = "Message flushed with immediate flush=false";
@@ -52,7 +52,7 @@ public void testFlushAtEndOfBatch() throws Exception {
final String line1 = reader.readLine();
reader.close();
file.delete();
- assertNotNull("line1", line1);
- assertTrue("line1 correct", line1.contains(msg));
+ assertNotNull(line1, "line1");
+ assertTrue(line1.contains(msg), "line1 correct");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigErrorOnFormat.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigErrorOnFormat.java
index 58020a8115d..b137fdba80a 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigErrorOnFormat.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigErrorOnFormat.java
@@ -16,10 +16,10 @@
*/
package org.apache.logging.log4j.core.async;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
@@ -29,35 +29,35 @@
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.impl.DefaultLogEventFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.message.AsynchronouslyFormattable;
import org.apache.logging.log4j.message.Message;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerConfigErrorOnFormat {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerConfigErrorOnFormat {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty("log4j2.enableThreadlocals", "true");
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerConfigErrorOnFormat.xml");
// Log4jLogEvent.toString invokes message.toString
System.setProperty("log4j2.logEventFactory", DefaultLogEventFactory.class.getName());
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.clearProperty("log4j2.enableThreadlocals");
System.clearProperty("log4j2.logEventFactory");
}
@Test
- public void testError() throws Exception {
+ void testError() throws Exception {
final File file = new File("target", "AsyncLoggerConfigErrorOnFormat.log");
- assertTrue("Deleted old file before test", !file.exists() || file.delete());
+ assertTrue(!file.exists() || file.delete(), "Deleted old file before test");
final Logger log = LogManager.getLogger("com.foo.Bar");
log.info(new ThrowsErrorOnFormatMessage());
@@ -71,7 +71,7 @@ public void testError() throws Exception {
file.delete();
assertThat(line1, containsString("Second message"));
- assertNull("Expected only one line", line2);
+ assertNull(line2, "Expected only one line");
}
@AsynchronouslyFormattable // Shouldn't call getFormattedMessage early
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
index ef15d5fe45a..77643204302 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
@@ -48,7 +48,7 @@
@Tag(Tags.ASYNC_LOGGERS)
@UsingStatusListener
-public class AsyncLoggerConfigTest {
+class AsyncLoggerConfigTest {
private static final String FQCN = AsyncLoggerConfigTest.class.getName();
@@ -57,7 +57,7 @@ public class AsyncLoggerConfigTest {
@Test
@LoggerContextSource
- public void testAdditivity(final LoggerContext context) throws Exception {
+ void testAdditivity(final LoggerContext context) throws Exception {
final Path file = loggingPath.resolve("AsyncLoggerConfigTest.log");
assertThat(file).isEmptyFile();
@@ -79,7 +79,7 @@ public void testAdditivity(final LoggerContext context) throws Exception {
}
@Test
- public void testIncludeLocationDefaultsToFalse() {
+ void testIncludeLocationDefaultsToFalse() {
final Configuration configuration = new NullConfiguration();
final LoggerConfig rootLoggerConfig =
RootLogger.newAsyncRootBuilder().withConfig(configuration).build();
@@ -93,7 +93,7 @@ public void testIncludeLocationDefaultsToFalse() {
}
@Test
- public void testSingleFilterInvocation() {
+ void testSingleFilterInvocation() {
final Configuration configuration = new NullConfiguration();
final Filter filter = mock(Filter.class);
final LoggerConfig config = AsyncLoggerConfig.newAsyncBuilder()
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest2.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest2.java
index 4b5fdcf8531..1de174cfd29 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest2.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest2.java
@@ -16,8 +16,8 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
@@ -27,18 +27,18 @@
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerConfigTest2 {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerConfigTest2 {
@Test
- public void testConsecutiveReconfigure() throws Exception {
+ void testConsecutiveReconfigure() throws Exception {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerConfigTest2.xml");
final File file = new File("target", "AsyncLoggerConfigTest2.log");
- assertTrue("Deleted old file before test", !file.exists() || file.delete());
+ assertTrue(!file.exists() || file.delete(), "Deleted old file before test");
final Logger log = LogManager.getLogger("com.foo.Bar");
final String msg = "Message before reconfig";
@@ -57,9 +57,9 @@ public void testConsecutiveReconfigure() throws Exception {
final String line2 = reader.readLine();
reader.close();
file.delete();
- assertNotNull("line1", line1);
- assertNotNull("line2", line2);
- assertTrue("line1 " + line1, line1.contains(msg));
- assertTrue("line2 " + line2, line2.contains(msg2));
+ assertNotNull(line1, "line1");
+ assertNotNull(line2, "line2");
+ assertTrue(line1.contains(msg), "line1 " + line1);
+ assertTrue(line2.contains(msg2), "line2 " + line2);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigUseAfterShutdownTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigUseAfterShutdownTest.java
index 04f653ceeff..6fe6cc2c5ec 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigUseAfterShutdownTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigUseAfterShutdownTest.java
@@ -21,23 +21,23 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.spi.AbstractLogger;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerConfigUseAfterShutdownTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerConfigUseAfterShutdownTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerConfigTest.xml");
}
@Test
- public void testNoErrorIfLogAfterShutdown() throws Exception {
+ void testNoErrorIfLogAfterShutdown() {
final Logger log = LogManager.getLogger("com.foo.Bar");
log.info("some message");
CoreLoggerContexts.stopLoggerContext(); // stop async thread
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigWithAsyncEnabledTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigWithAsyncEnabledTest.java
index aca4f73456a..0c060d3cb5e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigWithAsyncEnabledTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigWithAsyncEnabledTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.logging.log4j.core.async;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
@@ -27,33 +27,33 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerConfigWithAsyncEnabledTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerConfigWithAsyncEnabledTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty("log4j2.enableThreadlocals", "true");
System.setProperty("log4j2.contextSelector", AsyncLoggerContextSelector.class.getCanonicalName());
// Reuse the configuration from AsyncLoggerConfigTest4
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerConfigTest4.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.clearProperty("log4j2.enableThreadlocals");
System.clearProperty("log4j2.contextSelector");
}
@Test
- public void testParametersAreAvailableToLayout() throws Exception {
+ void testParametersAreAvailableToLayout() throws Exception {
final File file = new File("target", "AsyncLoggerConfigTest4.log");
- assertTrue("Deleted old file before test", !file.exists() || file.delete());
+ assertTrue(!file.exists() || file.delete(), "Deleted old file before test");
final Logger log = LogManager.getLogger("com.foo.Bar");
final String format = "Additive logging: {} for the price of {}!";
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelectorInitialStateTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelectorInitialStateTest.java
index bff6099b43c..c82c054ddc6 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelectorInitialStateTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelectorInitialStateTest.java
@@ -16,17 +16,17 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerContextSelectorInitialStateTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerContextSelectorInitialStateTest {
@Test
- public void testLoggerContextsListInitiallyEmpty() {
+ void testLoggerContextsListInitiallyEmpty() {
final AsyncLoggerContextSelector selector = new AsyncLoggerContextSelector();
assertTrue(selector.getLoggerContexts().isEmpty());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelectorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelectorTest.java
index c7fbc9c90fa..9079a1a6736 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelectorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelectorTest.java
@@ -16,48 +16,49 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerContextSelectorTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerContextSelectorTest {
private static final String FQCN = AsyncLoggerContextSelectorTest.class.getName();
@Test
- public void testContextReturnsAsyncLoggerContext() {
+ void testContextReturnsAsyncLoggerContext() {
final AsyncLoggerContextSelector selector = new AsyncLoggerContextSelector();
final LoggerContext context = selector.getContext(FQCN, null, false);
- assertTrue(context instanceof AsyncLoggerContext);
+ assertInstanceOf(AsyncLoggerContext.class, context);
}
@Test
- public void testContext2ReturnsAsyncLoggerContext() {
+ void testContext2ReturnsAsyncLoggerContext() {
final AsyncLoggerContextSelector selector = new AsyncLoggerContextSelector();
final LoggerContext context = selector.getContext(FQCN, null, false, null);
- assertTrue(context instanceof AsyncLoggerContext);
+ assertInstanceOf(AsyncLoggerContext.class, context);
}
@Test
- public void testLoggerContextsReturnsAsyncLoggerContext() {
+ void testLoggerContextsReturnsAsyncLoggerContext() {
final AsyncLoggerContextSelector selector = new AsyncLoggerContextSelector();
selector.getContext(FQCN, null, false);
final List list = selector.getLoggerContexts();
assertEquals(1, list.size());
- assertTrue(list.get(0) instanceof AsyncLoggerContext);
+ assertInstanceOf(AsyncLoggerContext.class, list.get(0));
}
@Test
- public void testContextNameIsAsyncLoggerContextWithClassHashCode() {
+ void testContextNameIsAsyncLoggerContextWithClassHashCode() {
final AsyncLoggerContextSelector selector = new AsyncLoggerContextSelector();
final LoggerContext context = selector.getContext(FQCN, null, false);
final int hash = getClass().getClassLoader().hashCode();
@@ -66,7 +67,7 @@ public void testContextNameIsAsyncLoggerContextWithClassHashCode() {
}
@Test
- public void testDependentOnClassLoader() {
+ void testDependentOnClassLoader() {
final AsyncLoggerContextSelector selector = new AsyncLoggerContextSelector();
assertTrue(selector.isClassLoaderDependent());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextTest.java
index 82ee87d0123..00bb100d797 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerContextTest.java
@@ -20,14 +20,14 @@
import static org.mockito.Mockito.mock;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.message.MessageFactory;
import org.apache.logging.log4j.message.MessageFactory2;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
-@Category(AsyncLoggers.class)
+@Tag(Tags.ASYNC_LOGGERS)
class AsyncLoggerContextTest {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerCustomSelectorLocationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerCustomSelectorLocationTest.java
index 504b382b11f..a9226ed2c2f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerCustomSelectorLocationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerCustomSelectorLocationTest.java
@@ -33,19 +33,19 @@
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.selector.ContextSelector;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerCustomSelectorLocationTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerCustomSelectorLocationTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
final File file = new File("target", "AsyncLoggerCustomSelectorLocationTest.log");
file.delete();
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, CustomAsyncContextSelector.class.getName());
@@ -53,13 +53,13 @@ public static void beforeClass() {
ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerCustomSelectorLocationTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testCustomAsyncSelectorLocation() throws Exception {
+ void testCustomAsyncSelectorLocation() throws Exception {
final File file = new File("target", "AsyncLoggerCustomSelectorLocationTest.log");
final Logger log = LogManager.getLogger("com.foo.Bar");
final Logger logIncludingLocation = LogManager.getLogger("com.include.location.Bar");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultLocationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultLocationTest.java
index 32acaab3f07..2a2ec4592f5 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultLocationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultLocationTest.java
@@ -16,10 +16,10 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -27,29 +27,29 @@
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerDefaultLocationTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerDefaultLocationTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerDefaultLocationTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testAsyncLogWritesToLog() throws Exception {
+ void testAsyncLogWritesToLog() {
final LoggerContext context = (LoggerContext) LogManager.getContext(false);
final ListAppender app = context.getConfiguration().getAppender("List");
assertNotNull(app);
@@ -59,7 +59,7 @@ public void testAsyncLogWritesToLog() throws Exception {
context.stop();
assertEquals(1, app.getEvents().size());
final LogEvent event = app.getEvents().get(0);
- assertFalse("includeLocation should be false", event.isIncludeLocation());
- assertNull("Location data should not be present", event.getSource());
+ assertFalse(event.isIncludeLocation(), "includeLocation should be false");
+ assertNull(event.getSource(), "Location data should not be present");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerEventTranslationExceptionTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerEventTranslationExceptionTest.java
index 1c3fdf90714..438d0ef7288 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerEventTranslationExceptionTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerEventTranslationExceptionTest.java
@@ -26,14 +26,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.ReusableSimpleMessage;
import org.apache.logging.log4j.spi.AbstractLogger;
-import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
/**
@@ -43,17 +43,17 @@
*
* @see LOG4J2-2816
*/
-@Category(AsyncLoggers.class)
+@Tag(Tags.ASYNC_LOGGERS)
class AsyncLoggerEventTranslationExceptionTest {
@BeforeAll
- public static void beforeAll() {
+ static void beforeAll() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
System.setProperty("AsyncLogger.ExceptionHandler", TestExceptionHandler.class.getName());
}
@AfterAll
- public static void afterAll() {
+ static void afterAll() {
System.clearProperty(Constants.LOG4J_CONTEXT_SELECTOR);
System.clearProperty("AsyncLogger.ExceptionHandler");
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerLocationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerLocationTest.java
index 562a4a7d37c..c173a9ac2bc 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerLocationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerLocationTest.java
@@ -16,8 +16,8 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
@@ -26,19 +26,19 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerLocationTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerLocationTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
final File file = new File("target", "AsyncLoggerLocationTest.log");
file.delete();
@@ -46,13 +46,13 @@ public static void beforeClass() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerLocationTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testAsyncLogWritesToLog() throws Exception {
+ void testAsyncLogWritesToLog() throws Exception {
final File file = new File("target", "AsyncLoggerLocationTest.log");
// System.out.println(f.getAbsolutePath());
final Logger log = LogManager.getLogger("com.foo.Bar");
@@ -64,10 +64,10 @@ public void testAsyncLogWritesToLog() throws Exception {
final String line1 = reader.readLine();
reader.close();
file.delete();
- assertNotNull("line1", line1);
- assertTrue("line1 correct", line1.contains(msg));
+ assertNotNull(line1, "line1");
+ assertTrue(line1.contains(msg), "line1 correct");
final String location = "testAsyncLogWritesToLog";
- assertTrue("has location", line1.contains(location));
+ assertTrue(line1.contains(location), "has location");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerNanoTimeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerNanoTimeTest.java
index 617090804e9..ce579bef7aa 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerNanoTimeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerNanoTimeTest.java
@@ -16,9 +16,10 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
@@ -27,39 +28,39 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.util.DummyNanoClock;
import org.apache.logging.log4j.core.util.SystemNanoClock;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerNanoTimeTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerNanoTimeTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "NanoTimeToFileTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testAsyncLogUsesNanoTimeClock() throws Exception {
+ void testAsyncLogUsesNanoTimeClock() throws Exception {
final File file = new File("target", "NanoTimeToFileTest.log");
// System.out.println(f.getAbsolutePath());
file.delete();
final AsyncLogger log = (AsyncLogger) LogManager.getLogger("com.foo.Bar");
final long before = System.nanoTime();
log.info("Use actual System.nanoTime()");
- assertTrue("using SystemNanoClock", log.getNanoClock() instanceof SystemNanoClock);
+ assertInstanceOf(SystemNanoClock.class, log.getNanoClock(), "using SystemNanoClock");
final long DUMMYNANOTIME = -53;
log.getContext().getConfiguration().setNanoClock(new DummyNanoClock(DUMMYNANOTIME));
@@ -69,7 +70,7 @@ public void testAsyncLogUsesNanoTimeClock() throws Exception {
log.updateConfiguration(log.getContext().getConfiguration());
log.info("Use dummy nano clock");
- assertTrue("using SystemNanoClock", log.getNanoClock() instanceof DummyNanoClock);
+ assertInstanceOf(DummyNanoClock.class, log.getNanoClock(), "using SystemNanoClock");
CoreLoggerContexts.stopLoggerContext(file); // stop async thread
@@ -81,13 +82,13 @@ public void testAsyncLogUsesNanoTimeClock() throws Exception {
reader.close();
file.delete();
- assertNotNull("line1", line1);
- assertNotNull("line2", line2);
+ assertNotNull(line1, "line1");
+ assertNotNull(line2, "line2");
final String[] line1Parts = line1.split(" AND ");
assertEquals("Use actual System.nanoTime()", line1Parts[2]);
assertEquals(line1Parts[0], line1Parts[1]);
final long loggedNanoTime = Long.parseLong(line1Parts[0]);
- assertTrue("used system nano time", loggedNanoTime - before < TimeUnit.SECONDS.toNanos(1));
+ assertTrue(loggedNanoTime - before < TimeUnit.SECONDS.toNanos(1), "used system nano time");
final String[] line2Parts = line2.split(" AND ");
assertEquals("Use dummy nano clock", line2Parts[2]);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java
index af4eaf0dd89..ee5db78fadb 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java
@@ -16,8 +16,10 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
@@ -25,37 +27,37 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.util.DummyNanoClock;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testAsyncLogWritesToLog() throws Exception {
+ void testAsyncLogWritesToLog() throws Exception {
final File file = new File("target", "AsyncLoggerTest.log");
// System.out.println(f.getAbsolutePath());
file.delete();
final AsyncLogger log = (AsyncLogger) LogManager.getLogger("com.foo.Bar");
- assertTrue(log.getNanoClock() instanceof DummyNanoClock);
+ assertInstanceOf(DummyNanoClock.class, log.getNanoClock());
final String msg = "Async logger msg";
log.info(msg, new InternalError("this is not a real error"));
@@ -65,11 +67,11 @@ public void testAsyncLogWritesToLog() throws Exception {
final String line1 = reader.readLine();
reader.close();
file.delete();
- assertNotNull("line1", line1);
- assertTrue("line1 correct", line1.contains(msg));
+ assertNotNull(line1, "line1");
+ assertTrue(line1.contains(msg), "line1 correct");
final String location = "testAsyncLogWritesToLog";
- assertTrue("no location", !line1.contains(location));
+ assertFalse(line1.contains(location), "no location");
assertTrue(LogManager.getFactory().isClassLoaderDependent());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestCachedThreadName.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestCachedThreadName.java
index 2e365fb46fb..aaa6089dd84 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestCachedThreadName.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestCachedThreadName.java
@@ -16,8 +16,8 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
@@ -26,30 +26,30 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerTestCachedThreadName {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerTestCachedThreadName {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testAsyncLogUsesCachedThreadName() throws Exception {
+ void testAsyncLogUsesCachedThreadName() throws Exception {
final File file = new File("target", "AsyncLoggerTest.log");
// System.out.println(f.getAbsolutePath());
file.delete();
@@ -67,9 +67,9 @@ public void testAsyncLogUsesCachedThreadName() throws Exception {
// System.out.println(line2);
reader.close();
file.delete();
- assertNotNull("line1", line1);
- assertNotNull("line2", line2);
- assertTrue("line1", line1.endsWith(" INFO c.f.Bar [main] Async logger msg "));
- assertTrue("line2", line2.endsWith(" INFO c.f.Bar [main] Async logger msg "));
+ assertNotNull(line1, "line1");
+ assertNotNull(line2, "line2");
+ assertTrue(line1.endsWith(" INFO c.f.Bar [main] Async logger msg "), "line1");
+ assertTrue(line2.endsWith(" INFO c.f.Bar [main] Async logger msg "), "line2");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestUncachedThreadName.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestUncachedThreadName.java
index 10eb49e6d6e..12fa5b07e37 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestUncachedThreadName.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestUncachedThreadName.java
@@ -16,8 +16,8 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
@@ -26,31 +26,31 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerTestUncachedThreadName {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerTestUncachedThreadName {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty("AsyncLogger.ThreadNameStrategy", "UNCACHED");
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testAsyncLogUsesCurrentThreadName() throws Exception {
+ void testAsyncLogUsesCurrentThreadName() throws Exception {
final File file = new File("target", "AsyncLoggerTest.log");
// System.out.println(f.getAbsolutePath());
file.delete();
@@ -68,9 +68,9 @@ public void testAsyncLogUsesCurrentThreadName() throws Exception {
// System.out.println(line2);
reader.close();
file.delete();
- assertNotNull("line1", line1);
- assertNotNull("line2", line2);
- assertTrue("line1", line1.endsWith(" INFO c.f.Bar [main] Async logger msg "));
- assertTrue("line2", line2.endsWith(" INFO c.f.Bar [MODIFIED-THREADNAME] Async logger msg "));
+ assertNotNull(line1, "line1");
+ assertNotNull(line2, "line2");
+ assertTrue(line1.endsWith(" INFO c.f.Bar [main] Async logger msg "), "line1");
+ assertTrue(line2.endsWith(" INFO c.f.Bar [MODIFIED-THREADNAME] Async logger msg "), "line2");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java
index 93eb835c1c2..d7fc698a957 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java
@@ -39,7 +39,7 @@
@Tag(Tags.ASYNC_LOGGERS)
@UsingTestProperties
@UsingStatusListener
-public class AsyncLoggerThreadContextTest {
+class AsyncLoggerThreadContextTest {
private static TestProperties props;
@@ -47,13 +47,13 @@ public class AsyncLoggerThreadContextTest {
private static Path loggingPath;
@BeforeAll
- public static void beforeClass() {
+ static void beforeClass() {
props.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
}
@Test
@LoggerContextSource("AsyncLoggerThreadContextTest.xml")
- public void testAsyncLogWritesToLog() throws Exception {
+ void testAsyncLogWritesToLog() throws Exception {
final Path file = loggingPath.resolve("AsyncLoggerTest.log");
ThreadContext.push("stackvalue");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadNameStrategyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadNameStrategyTest.java
index 6e1dc7e72a0..c784ac2822a 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadNameStrategyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadNameStrategyTest.java
@@ -16,56 +16,56 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncLoggerThreadNameStrategyTest {
- @After
- public void after() {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerThreadNameStrategyTest {
+ @AfterEach
+ void after() {
System.clearProperty("AsyncLogger.ThreadNameStrategy");
}
- @Before
- public void before() {
+ @BeforeEach
+ void before() {
System.clearProperty("AsyncLogger.ThreadNameStrategy");
}
@Test
- public void testDefaultIfNotConfigured() throws Exception {
+ void testDefaultIfNotConfigured() {
final ThreadNameCachingStrategy tns = ThreadNameCachingStrategy.create();
assertSame(ThreadNameCachingStrategy.DEFAULT_STRATEGY, tns);
}
@Test
- public void testDefaultIfInvalidConfig() throws Exception {
+ void testDefaultIfInvalidConfig() {
System.setProperty("AsyncLogger.ThreadNameStrategy", "\\%%InValid ");
final ThreadNameCachingStrategy tns = ThreadNameCachingStrategy.create();
assertSame(ThreadNameCachingStrategy.DEFAULT_STRATEGY, tns);
}
@Test
- public void testUseCachedThreadNameIfConfigured() throws Exception {
+ void testUseCachedThreadNameIfConfigured() {
System.setProperty("AsyncLogger.ThreadNameStrategy", "CACHED");
final ThreadNameCachingStrategy tns = ThreadNameCachingStrategy.create();
assertSame(ThreadNameCachingStrategy.CACHED, tns);
}
@Test
- public void testUseUncachedThreadNameIfConfigured() throws Exception {
+ void testUseUncachedThreadNameIfConfigured() {
System.setProperty("AsyncLogger.ThreadNameStrategy", "UNCACHED");
final ThreadNameCachingStrategy tns = ThreadNameCachingStrategy.create();
assertSame(ThreadNameCachingStrategy.UNCACHED, tns);
}
@Test
- public void testUncachedThreadNameStrategyReturnsCurrentThreadName() throws Exception {
+ void testUncachedThreadNameStrategyReturnsCurrentThreadName() {
final String name1 = "MODIFIED-THREADNAME1";
Thread.currentThread().setName(name1);
assertEquals(name1, ThreadNameCachingStrategy.UNCACHED.getThreadName());
@@ -76,7 +76,7 @@ public void testUncachedThreadNameStrategyReturnsCurrentThreadName() throws Exce
}
@Test
- public void testCachedThreadNameStrategyReturnsCachedThreadName() throws Exception {
+ void testCachedThreadNameStrategyReturnsCachedThreadName() {
final String original = "Original-ThreadName";
Thread.currentThread().setName(original);
assertEquals(original, ThreadNameCachingStrategy.CACHED.getThreadName());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTimestampMessageTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTimestampMessageTest.java
index 10fe2320660..3a50eb2ada2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTimestampMessageTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTimestampMessageTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.BufferedReader;
import java.io.File;
@@ -27,7 +27,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Clock;
import org.apache.logging.log4j.core.util.ClockFactory;
import org.apache.logging.log4j.core.util.ClockFactoryTest;
@@ -36,10 +36,10 @@
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.message.TimestampMessage;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Confirms that if you log a {@link TimestampMessage} then there are no unnecessary calls to {@link Clock}.
@@ -47,24 +47,24 @@
* See LOG4J2-744.
*
*/
-@Category(AsyncLoggers.class)
-public class AsyncLoggerTimestampMessageTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerTimestampMessageTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerTimestampMessageTest.xml");
System.setProperty(ClockFactory.PROPERTY_NAME, PoisonClock.class.getName());
}
- @AfterClass
- public static void afterClass() throws IllegalAccessException {
+ @AfterAll
+ static void afterClass() throws IllegalAccessException {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
ClockFactoryTest.resetClocks();
}
@Test
- public void testAsyncLogWritesToLog() throws Exception {
+ void testAsyncLogWritesToLog() throws Exception {
final File file = new File("target", "AsyncLoggerTimestampMessageTest.log");
// System.out.println(f.getAbsolutePath());
@@ -80,7 +80,7 @@ public void testAsyncLogWritesToLog() throws Exception {
reader.close();
file.delete();
assertNotNull(line1);
- assertTrue("line1 correct", line1.equals("123456789000 Async logger msg with embedded timestamp"));
+ assertEquals("123456789000 Async logger msg with embedded timestamp", line1, "line1 correct");
}
public static class PoisonClock implements Clock {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java
index a7c448bac4b..3c56ad55290 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java
@@ -21,35 +21,35 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.spi.AbstractLogger;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Test for https://issues.apache.org/jira/browse/LOG4J2-639
*/
-@Category(AsyncLoggers.class)
-public class AsyncLoggerUseAfterShutdownTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncLoggerUseAfterShutdownTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testNoErrorIfLogAfterShutdown() throws Exception {
+ void testNoErrorIfLogAfterShutdown() {
final Logger log = LogManager.getLogger("com.foo.Bar");
final String msg = "Async logger msg";
log.info(msg, new InternalError("this is not a real error"));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggersWithAsyncAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggersWithAsyncAppenderTest.java
index 9a0ed348177..1040b044242 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggersWithAsyncAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggersWithAsyncAppenderTest.java
@@ -37,11 +37,11 @@
key = Constants.LOG4J_CONTEXT_SELECTOR,
value = "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
@UsingStatusListener
-public class AsyncLoggersWithAsyncAppenderTest {
+class AsyncLoggersWithAsyncAppenderTest {
@Test
@LoggerContextSource
- public void testLoggingWorks(final LoggerContext ctx) throws Exception {
+ void testLoggingWorks(final LoggerContext ctx) throws Exception {
final Logger logger = ctx.getLogger(AsyncLoggersWithAsyncAppenderTest.class);
logger.error("This {} a test", "is");
logger.warn("Hello {}!", "world");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggersWithAsyncLoggerConfigTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggersWithAsyncLoggerConfigTest.java
index a4de62f77f0..420406d965c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggersWithAsyncLoggerConfigTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggersWithAsyncLoggerConfigTest.java
@@ -16,8 +16,8 @@
*/
package org.apache.logging.log4j.core.async;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.util.List;
import org.apache.logging.log4j.LogManager;
@@ -43,12 +43,12 @@ public void testLoggingWorks() throws Exception {
Thread.sleep(100);
final List list = context.getListAppender("List").getMessages();
assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 2, got " + list.size(), list.size() == 2);
+ assertEquals("Incorrect number of events. Expected 2, got " + list.size(), 2, list.size());
String msg = list.get(0);
String expected = getClass().getName() + " This is a test";
- assertTrue("Expected " + expected + ", Actual " + msg, expected.equals(msg));
+ assertEquals("Expected " + expected + ", Actual " + msg, expected, msg);
msg = list.get(1);
expected = getClass().getName() + " Hello world!";
- assertTrue("Expected " + expected + ", Actual " + msg, expected.equals(msg));
+ assertEquals("Expected " + expected + ", Actual " + msg, expected, msg);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
index 37f4a77c813..8a21114e6fc 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
@@ -17,36 +17,36 @@
package org.apache.logging.log4j.core.async;
import static org.apache.logging.log4j.util.Strings.toRootLowerCase;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests the AsyncQueueFullPolicyFactory class.
*/
-@Category(AsyncLoggers.class)
-public class AsyncQueueFullPolicyFactoryTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncQueueFullPolicyFactoryTest {
- @Before
- @After
- public void resetProperties() throws Exception {
+ @BeforeEach
+ @AfterEach
+ void resetProperties() {
System.clearProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER);
System.clearProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL);
}
@Test
- public void testCreateReturnsDefaultRouterByDefault() throws Exception {
+ void testCreateReturnsDefaultRouterByDefault() {
final AsyncQueueFullPolicy router = AsyncQueueFullPolicyFactory.create();
assertEquals(DefaultAsyncQueueFullPolicy.class, router.getClass());
}
@Test
- public void testCreateReturnsDiscardingRouterIfSpecified() throws Exception {
+ void testCreateReturnsDiscardingRouterIfSpecified() {
System.setProperty(
AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER);
@@ -70,7 +70,7 @@ public void testCreateReturnsDiscardingRouterIfSpecified() throws Exception {
}
@Test
- public void testCreateDiscardingRouterDefaultThresholdLevelInfo() throws Exception {
+ void testCreateDiscardingRouterDefaultThresholdLevelInfo() {
System.setProperty(
AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER);
@@ -80,7 +80,7 @@ public void testCreateDiscardingRouterDefaultThresholdLevelInfo() throws Excepti
}
@Test
- public void testCreateDiscardingRouterCaseInsensitive() {
+ void testCreateDiscardingRouterCaseInsensitive() {
System.setProperty(
AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
toRootLowerCase(AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER));
@@ -90,7 +90,7 @@ public void testCreateDiscardingRouterCaseInsensitive() {
}
@Test
- public void testCreateDiscardingRouterThresholdLevelCustomizable() throws Exception {
+ void testCreateDiscardingRouterThresholdLevelCustomizable() {
System.setProperty(
AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER);
@@ -114,7 +114,7 @@ public EventRoute getRoute(final long backgroundThreadId, final Level level) {
public static class DoesNotImplementInterface {}
@Test
- public void testCreateReturnsCustomRouterIfSpecified() throws Exception {
+ void testCreateReturnsCustomRouterIfSpecified() {
System.setProperty(
AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
CustomRouterDefaultConstructor.class.getName());
@@ -124,7 +124,7 @@ public void testCreateReturnsCustomRouterIfSpecified() throws Exception {
}
@Test
- public void testCreateReturnsDefaultRouterIfSpecifiedCustomRouterFails() throws Exception {
+ void testCreateReturnsDefaultRouterIfSpecifiedCustomRouterFails() {
System.setProperty(
AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
DoesNotImplementInterface.class.getName());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncRootLoggerDefaultLocationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncRootLoggerDefaultLocationTest.java
index 8c7ca12e99c..e10c5e36bf5 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncRootLoggerDefaultLocationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncRootLoggerDefaultLocationTest.java
@@ -16,10 +16,10 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -27,29 +27,29 @@
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncRootLoggerDefaultLocationTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncRootLoggerDefaultLocationTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncRootLoggerDefaultLocationTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testAsyncLogWritesToLog() throws Exception {
+ void testAsyncLogWritesToLog() {
final LoggerContext context = (LoggerContext) LogManager.getContext(false);
final ListAppender app = context.getConfiguration().getAppender("List");
assertNotNull(app);
@@ -59,7 +59,7 @@ public void testAsyncLogWritesToLog() throws Exception {
context.stop();
assertEquals(1, app.getEvents().size());
final LogEvent event = app.getEvents().get(0);
- assertFalse("includeLocation should be false", event.isIncludeLocation());
- assertNull("Location data should not be present", event.getSource());
+ assertFalse(event.isIncludeLocation(), "includeLocation should be false");
+ assertNull(event.getSource(), "Location data should not be present");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigGlobalLoggersTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigGlobalLoggersTest.java
index eb7b2e18aeb..ed12038e3d5 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigGlobalLoggersTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigGlobalLoggersTest.java
@@ -23,33 +23,33 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncWaitStrategyFactoryConfigGlobalLoggersTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncWaitStrategyFactoryConfigGlobalLoggersTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
System.setProperty(
ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncWaitStrategyFactoryConfigGlobalLoggerTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.clearProperty(Constants.LOG4J_CONTEXT_SELECTOR);
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
}
- @Ignore("This test succeeds when run individually but fails when run by Surefire with all other tests")
+ @Disabled("This test succeeds when run individually but fails when run by Surefire with all other tests")
@Test
- public void testConfigWaitStrategyAndFactory() throws Exception {
+ void testConfigWaitStrategyAndFactory() {
final AsyncLogger logger = (AsyncLogger) LogManager.getLogger("com.foo.Bar");
final LoggerContext context = (LoggerContext) LogManager.getContext(false);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigTest.java
index bdc2bad1b14..11072a2e8ba 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigTest.java
@@ -17,25 +17,25 @@
package org.apache.logging.log4j.core.async;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.lmax.disruptor.WaitStrategy;
import com.lmax.disruptor.YieldingWaitStrategy;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
import org.apache.logging.log4j.core.test.junit.Named;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncWaitStrategyFactoryConfigTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncWaitStrategyFactoryConfigTest {
@Test
@LoggerContextSource("AsyncWaitStrategyFactoryConfigTest.xml")
- public void testConfigWaitStrategyFactory(final LoggerContext context) throws Exception {
+ void testConfigWaitStrategyFactory(final LoggerContext context) {
final AsyncWaitStrategyFactory asyncWaitStrategyFactory =
context.getConfiguration().getAsyncWaitStrategyFactory();
assertEquals(YieldingWaitStrategyFactory.class, asyncWaitStrategyFactory.getClass());
@@ -46,7 +46,7 @@ public void testConfigWaitStrategyFactory(final LoggerContext context) throws Ex
@Test
@LoggerContextSource("AsyncWaitStrategyFactoryConfigTest.xml")
- public void testWaitStrategy(final LoggerContext context) throws Exception {
+ void testWaitStrategy(final LoggerContext context) {
final org.apache.logging.log4j.Logger logger = context.getRootLogger();
@@ -62,7 +62,7 @@ public void testWaitStrategy(final LoggerContext context) throws Exception {
@Test
@LoggerContextSource("AsyncWaitStrategyIncorrectFactoryConfigTest.xml")
- public void testIncorrectConfigWaitStrategyFactory(final LoggerContext context) throws Exception {
+ void testIncorrectConfigWaitStrategyFactory(final LoggerContext context) {
final AsyncWaitStrategyFactory asyncWaitStrategyFactory =
context.getConfiguration().getAsyncWaitStrategyFactory();
assertNull(asyncWaitStrategyFactory);
@@ -70,8 +70,8 @@ public void testIncorrectConfigWaitStrategyFactory(final LoggerContext context)
@Test
@LoggerContextSource("AsyncWaitStrategyIncorrectFactoryConfigTest.xml")
- public void testIncorrectWaitStrategyFallsBackToDefault(
- @Named("WaitStrategyAppenderList") final ListAppender list1, final LoggerContext context) throws Exception {
+ void testIncorrectWaitStrategyFallsBackToDefault(
+ @Named("WaitStrategyAppenderList") final ListAppender list1, final LoggerContext context) {
final org.apache.logging.log4j.Logger logger = context.getRootLogger();
final AsyncLoggerConfig loggerConfig =
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest.java
index 9f282de5a95..1d1abdcd4b3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest.java
@@ -17,38 +17,38 @@
package org.apache.logging.log4j.core.async;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
System.setProperty(
ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
"AsyncWaitStrategyIncorrectFactoryConfigGlobalLoggerTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.clearProperty(Constants.LOG4J_CONTEXT_SELECTOR);
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
}
@Test
- public void testIncorrectConfigWaitStrategyFactory() throws Exception {
+ void testIncorrectConfigWaitStrategyFactory() throws Exception {
final LoggerContext context = (LoggerContext) LogManager.getContext(false);
assertThat("context is AsyncLoggerContext", context instanceof AsyncLoggerContext);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/BasicAsyncLoggerContextSelectorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/BasicAsyncLoggerContextSelectorTest.java
index 101af9e6493..e645e4637f3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/BasicAsyncLoggerContextSelectorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/BasicAsyncLoggerContextSelectorTest.java
@@ -16,87 +16,87 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LifeCycle;
import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.test.junit.Tags;
import org.apache.logging.log4j.core.util.Constants;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(AsyncLoggers.class)
-public class BasicAsyncLoggerContextSelectorTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class BasicAsyncLoggerContextSelectorTest {
private static final String FQCN = BasicAsyncLoggerContextSelectorTest.class.getName();
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, BasicAsyncLoggerContextSelector.class.getName());
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.clearProperty(Constants.LOG4J_CONTEXT_SELECTOR);
}
@Test
- public void testContextReturnsAsyncLoggerContext() {
+ void testContextReturnsAsyncLoggerContext() {
final BasicAsyncLoggerContextSelector selector = new BasicAsyncLoggerContextSelector();
final LoggerContext context = selector.getContext(FQCN, null, false);
- assertTrue(context instanceof AsyncLoggerContext);
+ assertInstanceOf(AsyncLoggerContext.class, context);
}
@Test
- public void testContext2ReturnsAsyncLoggerContext() {
+ void testContext2ReturnsAsyncLoggerContext() {
final BasicAsyncLoggerContextSelector selector = new BasicAsyncLoggerContextSelector();
final LoggerContext context = selector.getContext(FQCN, null, false, null);
- assertTrue(context instanceof AsyncLoggerContext);
+ assertInstanceOf(AsyncLoggerContext.class, context);
}
@Test
- public void testLoggerContextsReturnsAsyncLoggerContext() {
+ void testLoggerContextsReturnsAsyncLoggerContext() {
final BasicAsyncLoggerContextSelector selector = new BasicAsyncLoggerContextSelector();
List list = selector.getLoggerContexts();
assertEquals(1, list.size());
- assertTrue(list.get(0) instanceof AsyncLoggerContext);
+ assertInstanceOf(AsyncLoggerContext.class, list.get(0));
selector.getContext(FQCN, null, false);
list = selector.getLoggerContexts();
assertEquals(1, list.size());
- assertTrue(list.get(0) instanceof AsyncLoggerContext);
+ assertInstanceOf(AsyncLoggerContext.class, list.get(0));
}
@Test
- public void testContextNameIsAsyncDefault() {
+ void testContextNameIsAsyncDefault() {
final BasicAsyncLoggerContextSelector selector = new BasicAsyncLoggerContextSelector();
final LoggerContext context = selector.getContext(FQCN, null, false);
assertEquals("AsyncDefault", context.getName());
}
@Test
- public void testDependentOnClassLoader() {
+ void testDependentOnClassLoader() {
final BasicAsyncLoggerContextSelector selector = new BasicAsyncLoggerContextSelector();
assertFalse(selector.isClassLoaderDependent());
}
@Test
- public void testFactoryIsNotDependentOnClassLoader() {
+ void testFactoryIsNotDependentOnClassLoader() {
assertFalse(LogManager.getFactory().isClassLoaderDependent());
}
@Test
- public void testLogManagerShutdown() {
+ void testLogManagerShutdown() {
final LoggerContext context = (LoggerContext) LogManager.getContext();
assertEquals(LifeCycle.State.STARTED, context.getState());
LogManager.shutdown();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java
index 929267c3182..27548391ab6 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java
@@ -16,18 +16,18 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests the DefaultAsyncQueueFullPolicy class.
*/
-@Category(AsyncLoggers.class)
-public class DefaultAsyncQueueFullPolicyTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class DefaultAsyncQueueFullPolicyTest {
private static long currentThreadId() {
return Thread.currentThread().getId();
@@ -38,14 +38,14 @@ private static long otherThreadId() {
}
@Test
- public void testGetRouteEnqueuesIfQueueFullAndCalledFromDifferentThread() throws Exception {
+ void testGetRouteEnqueuesIfQueueFullAndCalledFromDifferentThread() {
final DefaultAsyncQueueFullPolicy router = new DefaultAsyncQueueFullPolicy();
assertEquals(EventRoute.ENQUEUE, router.getRoute(otherThreadId(), Level.ALL));
assertEquals(EventRoute.ENQUEUE, router.getRoute(otherThreadId(), Level.OFF));
}
@Test
- public void testGetRouteSynchronousIfQueueFullAndCalledFromSameThread() throws Exception {
+ void testGetRouteSynchronousIfQueueFullAndCalledFromSameThread() {
final DefaultAsyncQueueFullPolicy router = new DefaultAsyncQueueFullPolicy();
assertEquals(EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), Level.ALL));
assertEquals(EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), Level.OFF));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DiscardingAsyncQueueFullPolicyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DiscardingAsyncQueueFullPolicyTest.java
index 6002e409958..c816cbef4a4 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DiscardingAsyncQueueFullPolicyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DiscardingAsyncQueueFullPolicyTest.java
@@ -16,19 +16,20 @@
*/
package org.apache.logging.log4j.core.async;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.Tags;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests the DiscardingAsyncQueueFullPolicy class..
*/
-@Category(AsyncLoggers.class)
-public class DiscardingAsyncQueueFullPolicyTest {
+@Tag(Tags.ASYNC_LOGGERS)
+class DiscardingAsyncQueueFullPolicyTest {
private static long currentThreadId() {
return Thread.currentThread().getId();
@@ -38,83 +39,84 @@ private static long otherThreadId() {
return -1;
}
- @Test(expected = NullPointerException.class)
- public void testConstructorDisallowsNullThresholdLevel() {
- new DiscardingAsyncQueueFullPolicy(null);
+ @Test
+ void testConstructorDisallowsNullThresholdLevel() {
+ assertThrows(NullPointerException.class, () -> {
+ new DiscardingAsyncQueueFullPolicy(null);
+ });
}
@Test
- public void testThresholdLevelIsConstructorValue() {
+ void testThresholdLevelIsConstructorValue() {
assertSame(Level.ALL, new DiscardingAsyncQueueFullPolicy(Level.ALL).getThresholdLevel());
assertSame(Level.OFF, new DiscardingAsyncQueueFullPolicy(Level.OFF).getThresholdLevel());
assertSame(Level.INFO, new DiscardingAsyncQueueFullPolicy(Level.INFO).getThresholdLevel());
}
@Test
- public void testGetRouteDiscardsIfThresholdCapacityReachedAndLevelEqualOrLessSpecificThanThreshold()
- throws Exception {
+ void testGetRouteDiscardsIfThresholdCapacityReachedAndLevelEqualOrLessSpecificThanThreshold() {
final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
for (final Level level : new Level[] {Level.WARN, Level.INFO, Level.DEBUG, Level.TRACE, Level.ALL}) {
- assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(currentThreadId(), level));
- assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(otherThreadId(), level));
- assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(currentThreadId(), level));
- assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(otherThreadId(), level));
+ assertEquals(EventRoute.DISCARD, router.getRoute(currentThreadId(), level), level.name());
+ assertEquals(EventRoute.DISCARD, router.getRoute(otherThreadId(), level), level.name());
+ assertEquals(EventRoute.DISCARD, router.getRoute(currentThreadId(), level), level.name());
+ assertEquals(EventRoute.DISCARD, router.getRoute(otherThreadId(), level), level.name());
}
}
@Test
- public void testGetRouteDiscardsIfQueueFullAndLevelEqualOrLessSpecificThanThreshold() throws Exception {
+ void testGetRouteDiscardsIfQueueFullAndLevelEqualOrLessSpecificThanThreshold() {
final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
for (final Level level : new Level[] {Level.WARN, Level.INFO, Level.DEBUG, Level.TRACE, Level.ALL}) {
- assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(currentThreadId(), level));
- assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(otherThreadId(), level));
+ assertEquals(EventRoute.DISCARD, router.getRoute(currentThreadId(), level), level.name());
+ assertEquals(EventRoute.DISCARD, router.getRoute(otherThreadId(), level), level.name());
}
}
@Test
- public void testGetRouteEnqueuesIfThresholdCapacityReachedButLevelMoreSpecificThanThreshold() throws Exception {
+ void testGetRouteEnqueuesIfThresholdCapacityReachedButLevelMoreSpecificThanThreshold() {
final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
for (final Level level : new Level[] {Level.ERROR, Level.FATAL, Level.OFF}) {
- assertEquals(level.name(), EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), level));
- assertEquals(level.name(), EventRoute.ENQUEUE, router.getRoute(otherThreadId(), level));
- assertEquals(level.name(), EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), level));
- assertEquals(level.name(), EventRoute.ENQUEUE, router.getRoute(otherThreadId(), level));
+ assertEquals(EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), level), level.name());
+ assertEquals(EventRoute.ENQUEUE, router.getRoute(otherThreadId(), level), level.name());
+ assertEquals(EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), level), level.name());
+ assertEquals(EventRoute.ENQUEUE, router.getRoute(otherThreadId(), level), level.name());
}
}
@Test
- public void testGetRouteEnqueueIfOtherThreadQueueFullAndLevelMoreSpecificThanThreshold() throws Exception {
+ void testGetRouteEnqueueIfOtherThreadQueueFullAndLevelMoreSpecificThanThreshold() {
final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
for (final Level level : new Level[] {Level.ERROR, Level.FATAL, Level.OFF}) {
- assertEquals(level.name(), EventRoute.ENQUEUE, router.getRoute(otherThreadId(), level));
+ assertEquals(EventRoute.ENQUEUE, router.getRoute(otherThreadId(), level), level.name());
}
}
@Test
- public void testGetRouteSynchronousIfCurrentThreadQueueFullAndLevelMoreSpecificThanThreshold() throws Exception {
+ void testGetRouteSynchronousIfCurrentThreadQueueFullAndLevelMoreSpecificThanThreshold() {
final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
for (final Level level : new Level[] {Level.ERROR, Level.FATAL, Level.OFF}) {
- assertEquals(level.name(), EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), level));
+ assertEquals(EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), level), level.name());
}
}
@Test
- public void testGetDiscardCount() throws Exception {
+ void testGetDiscardCount() {
final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.INFO);
- assertEquals("initially", 0, DiscardingAsyncQueueFullPolicy.getDiscardCount(router));
+ assertEquals(0, DiscardingAsyncQueueFullPolicy.getDiscardCount(router), "initially");
assertEquals(EventRoute.DISCARD, router.getRoute(-1L, Level.INFO));
- assertEquals("increase", 1, DiscardingAsyncQueueFullPolicy.getDiscardCount(router));
+ assertEquals(1, DiscardingAsyncQueueFullPolicy.getDiscardCount(router), "increase");
assertEquals(EventRoute.DISCARD, router.getRoute(-1L, Level.INFO));
- assertEquals("increase", 2, DiscardingAsyncQueueFullPolicy.getDiscardCount(router));
+ assertEquals(2, DiscardingAsyncQueueFullPolicy.getDiscardCount(router), "increase");
assertEquals(EventRoute.DISCARD, router.getRoute(-1L, Level.INFO));
- assertEquals("increase", 3, DiscardingAsyncQueueFullPolicy.getDiscardCount(router));
+ assertEquals(3, DiscardingAsyncQueueFullPolicy.getDiscardCount(router), "increase");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java
index e25184c2672..1d72e8fc8f3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java
@@ -62,7 +62,7 @@ public static void afterClass() {
private ListAppender listAppender;
@Before
- public void before() throws Exception {
+ public void before() {
listAppender = context.getListAppender("List");
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java
index 7834bbe121b..4e69ab7085a 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java
@@ -61,7 +61,7 @@ public static void afterClass() {
private ListAppender listAppender;
@Before
- public void before() throws Exception {
+ public void before() {
listAppender = context.getListAppender("List");
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLogger3Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLogger3Test.java
index de5d68a5869..10d45ac8a70 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLogger3Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLogger3Test.java
@@ -45,7 +45,7 @@
@SetTestProperty(key = "log4j2.formatMsgAsync", value = "true")
@SetTestProperty(key = "log4j2.asyncQueueFullPolicy", value = "Discard")
@Tag(Tags.ASYNC_LOGGERS)
-public class QueueFullAsyncLogger3Test extends QueueFullAbstractTest {
+class QueueFullAsyncLogger3Test extends QueueFullAbstractTest {
@Override
protected void checkConfig(final LoggerContext ctx) {
@@ -56,7 +56,7 @@ protected void checkConfig(final LoggerContext ctx) {
@Test
@LoggerContextSource
- public void discarded_messages_should_be_garbage_collected(
+ void discarded_messages_should_be_garbage_collected(
final LoggerContext ctx, final @Named(APPENDER_NAME) BlockingAppender blockingAppender)
throws InterruptedException {
awaitGarbageCollection(() -> {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
index ffd26bed644..75559f87147 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
@@ -24,7 +24,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
-import java.io.IOException;
import java.util.Arrays;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
@@ -194,7 +193,7 @@ void testGetMillisReturnsConstructorMillisForNormalMessage() {
}
@Test
- void testSerializationDeserialization() throws IOException, ClassNotFoundException {
+ void testSerializationDeserialization() {
final RingBufferLogEvent evt = new RingBufferLogEvent();
final String loggerName = "logger.name";
final Marker marker = null;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/AdvertiserTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/AdvertiserTest.java
index 92cfda340f3..e99cf2fbc25 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/AdvertiserTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/AdvertiserTest.java
@@ -30,13 +30,13 @@
import org.junit.jupiter.api.Test;
@Tag("functional")
-public class AdvertiserTest {
+class AdvertiserTest {
private static final String CONFIG = "log4j-advertiser.xml";
private static final String STATUS_LOG = "target/status.log";
@BeforeAll
- public static void setupClass() {
+ static void setupClass() {
final File file = new File(STATUS_LOG);
file.delete();
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
@@ -53,7 +53,7 @@ public static void setupClass() {
}
@AfterAll
- public static void cleanupClass() {
+ static void cleanupClass() {
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
final LoggerContext ctx = LoggerContext.getContext();
ctx.reconfigure();
@@ -91,12 +91,12 @@ private void verifyExpectedEntriesAdvertised(final Map appendersMap = config.getLogger("cat1").getAppenders();
assertEquals(
@@ -102,7 +102,7 @@ public void evaluate() throws Throwable {
final Filter loggerFilter = config.getLogger("cat1").getFilter();
assertTrue(loggerFilter instanceof RegexFilter);
- assertEquals(loggerFilter.getOnMatch(), Filter.Result.DENY);
+ assertEquals(Filter.Result.DENY, loggerFilter.getOnMatch());
appendersMap = config.getLogger("cat2").getAppenders();
assertEquals(
@@ -129,8 +129,8 @@ public void evaluate() throws Throwable {
assertEquals(
"Expected COMPOSITE_SOURCE for composite configuration but got "
+ config.getConfigurationSource(),
- config.getConfigurationSource(),
- ConfigurationSource.COMPOSITE_SOURCE);
+ ConfigurationSource.COMPOSITE_SOURCE,
+ config.getConfigurationSource());
}
};
runTest(lcr, test);
@@ -142,7 +142,7 @@ public void testAttributeCheckWhenMergingConfigurations() {
new LoggerContextRule("classpath:log4j-comp-root-loggers.xml,log4j-comp-logger.json");
final Statement test = new Statement() {
@Override
- public void evaluate() throws Throwable {
+ public void evaluate() {
try {
final CompositeConfiguration config = (CompositeConfiguration) lcr.getConfiguration();
Assert.assertNotNull(config);
@@ -160,7 +160,7 @@ public void testAttributeMergeForLoggers() {
new LoggerContextRule("classpath:log4j-comp-logger-root.xml,log4j-comp-logger-attr-override.json");
final Statement test = new Statement() {
@Override
- public void evaluate() throws Throwable {
+ public void evaluate() {
final CompositeConfiguration config = (CompositeConfiguration) lcr.getConfiguration();
// Test for Root log level override
assertEquals(
@@ -197,7 +197,7 @@ public void testMissingConfig() {
new LoggerContextRule("classpath:log4j-comp-logger-root.xml,log4j-does-not-exist.json");
final Statement test = new Statement() {
@Override
- public void evaluate() throws Throwable {
+ public void evaluate() {
final AbstractConfiguration config = (AbstractConfiguration) lcr.getConfiguration();
assertNotNull("No configuration returned", config);
// Test for Root log level override
@@ -220,7 +220,7 @@ public void testAppenderRefFilterMerge() {
new LoggerContextRule("classpath:log4j-comp-logger-ref.xml,log4j-comp-logger-ref.json");
final Statement test = new Statement() {
@Override
- public void evaluate() throws Throwable {
+ public void evaluate() {
final CompositeConfiguration config = (CompositeConfiguration) lcr.getConfiguration();
final List appenderRefList =
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationFactoryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationFactoryTest.java
index 5db114e7398..f2d81f13472 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationFactoryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationFactoryTest.java
@@ -19,6 +19,7 @@
import static org.apache.logging.log4j.util.Unbox.box;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -72,10 +73,10 @@ static void checkConfiguration(final LoggerContext context) {
assertEquals(1, logger.filterCount());
final Iterator filterIterator = logger.getFilters();
assertTrue(filterIterator.hasNext());
- assertTrue(filterIterator.next() instanceof ThreadContextMapFilter);
+ assertInstanceOf(ThreadContextMapFilter.class, filterIterator.next());
final Appender appender = appenders.get(APPENDER_NAME);
- assertTrue(appender instanceof ConsoleAppender);
+ assertInstanceOf(ConsoleAppender.class, appender);
assertEquals(APPENDER_NAME, appender.getName());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationPropertyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationPropertyTest.java
index 718f6fbb8e2..18813ce1d9f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationPropertyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationPropertyTest.java
@@ -26,12 +26,12 @@
import org.junit.jupiter.api.Test;
@Tag("functional")
-public class ConfigurationPropertyTest {
+class ConfigurationPropertyTest {
private LoggerContext loggerContext;
@AfterEach
- public void afterEach() {
+ void afterEach() {
if (loggerContext != null) {
LogManager.shutdown(loggerContext);
}
@@ -40,7 +40,7 @@ public void afterEach() {
}
@Test
- public void testInitializeFromSystemProperty() {
+ void testInitializeFromSystemProperty() {
System.setProperty("log4j2.configurationFile", "src/test/resources/log4j-list.xml");
loggerContext = (LoggerContext) LogManager.getContext(false);
final Configuration configuration = loggerContext.getConfiguration();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationSourceTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationSourceTest.java
index 5001ad2d449..3015f4f6271 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationSourceTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfigurationSourceTest.java
@@ -81,7 +81,7 @@ void testNoJarFileLeak() throws Exception {
}
@Test
- public void testLoadConfigurationSourceFromJarFile() throws Exception {
+ void testLoadConfigurationSourceFromJarFile() throws Exception {
final Path jarFile = prepareJarConfigURL(tempDir);
final URL jarConfigURL = new URL("jar:" + jarFile.toUri().toURL() + "!" + PATH_IN_JAR);
final long expectedFdCount = getOpenFileDescriptorCount();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator1Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator1Test.java
index be2c6fd1993..e46d4cb3ae7 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator1Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator1Test.java
@@ -66,7 +66,7 @@
@SetSystemProperty(key = Constants.SCRIPT_LANGUAGES, value = "beanshell, Groovy, Javascript")
@Tag("functional")
-public class Configurator1Test {
+class Configurator1Test {
private static final String CONFIG_NAME = "TestConfigurator";
@@ -91,7 +91,7 @@ public class Configurator1Test {
};
@AfterEach
- public void cleanup() {
+ void cleanup() {
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
if (ctx != null) {
Configurator.shutdown(ctx);
@@ -100,7 +100,7 @@ public void cleanup() {
}
@Test
- public void testInitialize_Name_PathName() throws Exception {
+ void testInitialize_Name_PathName() {
ctx = Configurator.initialize("Test1", "target/test-classes/log4j2-TestConfigurator.xml");
LogManager.getLogger("org.apache.test.TestConfigurator");
Configuration config = ctx.getConfiguration();
@@ -116,7 +116,7 @@ public void testInitialize_Name_PathName() throws Exception {
}
@Test
- public void testInitialize_Name_ClassLoader_URI() throws Exception {
+ void testInitialize_Name_ClassLoader_URI() {
ctx = Configurator.initialize(
"Test1", null, new File("target/test-classes/log4j2-TestConfigurator.xml").toURI());
LogManager.getLogger("org.apache.test.TestConfigurator");
@@ -133,7 +133,7 @@ public void testInitialize_Name_ClassLoader_URI() throws Exception {
}
@Test
- public void testInitialize_InputStream_File() throws Exception {
+ void testInitialize_InputStream_File() throws Exception {
final File file = new File("target/test-classes/log4j2-TestConfigurator.xml");
final InputStream is = new FileInputStream(file);
final ConfigurationSource source = new ConfigurationSource(is, file);
@@ -152,7 +152,7 @@ public void testInitialize_InputStream_File() throws Exception {
}
@Test
- public void testInitialize_InputStream_Path() throws Exception {
+ void testInitialize_InputStream_Path() throws Exception {
final Path path = Paths.get("target/test-classes/log4j2-TestConfigurator.xml");
final InputStream is = Files.newInputStream(path);
final ConfigurationSource source = new ConfigurationSource(is, path);
@@ -171,7 +171,7 @@ public void testInitialize_InputStream_Path() throws Exception {
}
@Test
- public void testInitialize_NullClassLoader_ConfigurationSourceWithInputStream_NoId() throws Exception {
+ void testInitialize_NullClassLoader_ConfigurationSourceWithInputStream_NoId() throws Exception {
final InputStream is = new FileInputStream("target/test-classes/log4j2-TestConfigurator.xml");
final ConfigurationSource source = new ConfigurationSource(is);
ctx = Configurator.initialize(null, source);
@@ -189,7 +189,7 @@ public void testInitialize_NullClassLoader_ConfigurationSourceWithInputStream_No
}
@Test
- public void testInitialize_Name_LocationName() throws Exception {
+ void testInitialize_Name_LocationName() {
ctx = Configurator.initialize("Test1", "log4j2-TestConfigurator.xml");
LogManager.getLogger("org.apache.test.TestConfigurator");
Configuration config = ctx.getConfiguration();
@@ -205,7 +205,7 @@ public void testInitialize_Name_LocationName() throws Exception {
}
@Test
- public void testFromClassPathProperty() throws Exception {
+ void testFromClassPathProperty() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "classpath:log4j2-TestConfigurator.xml");
ctx = Configurator.initialize("Test1", null);
LogManager.getLogger("org.apache.test.TestConfigurator");
@@ -222,7 +222,7 @@ public void testFromClassPathProperty() throws Exception {
}
@Test
- public void testFromClassPathWithClassPathPrefix() throws Exception {
+ void testFromClassPathWithClassPathPrefix() {
ctx = Configurator.initialize("Test1", "classpath:log4j2-TestConfigurator.xml");
LogManager.getLogger("org.apache.test.TestConfigurator");
Configuration config = ctx.getConfiguration();
@@ -238,7 +238,7 @@ public void testFromClassPathWithClassPathPrefix() throws Exception {
}
@Test
- public void testFromClassPathWithClassLoaderPrefix() throws Exception {
+ void testFromClassPathWithClassLoaderPrefix() {
ctx = Configurator.initialize("Test1", "classloader:log4j2-TestConfigurator.xml");
LogManager.getLogger("org.apache.test.TestConfigurator");
Configuration config = ctx.getConfiguration();
@@ -254,7 +254,7 @@ public void testFromClassPathWithClassLoaderPrefix() throws Exception {
}
@Test
- public void testByName() throws Exception {
+ void testByName() {
ctx = Configurator.initialize("-TestConfigurator", null);
LogManager.getLogger("org.apache.test.TestConfigurator");
Configuration config = ctx.getConfiguration();
@@ -270,7 +270,7 @@ public void testByName() throws Exception {
}
@Test
- public void testReconfiguration() throws Exception {
+ void testReconfiguration() throws Exception {
final File file = new File("target/test-classes/log4j2-TestConfigurator.xml");
assertTrue(file.setLastModified(System.currentTimeMillis() - 120000), "setLastModified should have succeeded.");
ctx = Configurator.initialize("Test1", "target/test-classes/log4j2-TestConfigurator.xml");
@@ -307,7 +307,7 @@ public void testReconfiguration() throws Exception {
}
@Test
- public void testEnvironment() throws Exception {
+ void testEnvironment() {
ctx = Configurator.initialize("-TestConfigurator", null);
LogManager.getLogger("org.apache.test.TestConfigurator");
final Configuration config = ctx.getConfiguration();
@@ -327,7 +327,7 @@ public void testEnvironment() throws Exception {
}
@Test
- public void testNoLoggers() throws Exception {
+ void testNoLoggers() {
ctx = Configurator.initialize("Test1", "bad/log4j-loggers.xml");
LogManager.getLogger("org.apache.test.TestConfigurator");
final Configuration config = ctx.getConfiguration();
@@ -337,7 +337,7 @@ public void testNoLoggers() throws Exception {
}
@Test
- public void testBadStatus() throws Exception {
+ void testBadStatus() {
ctx = Configurator.initialize("Test1", "bad/log4j-status.xml");
LogManager.getLogger("org.apache.test.TestConfigurator");
final Configuration config = ctx.getConfiguration();
@@ -349,7 +349,7 @@ public void testBadStatus() throws Exception {
}
@Test
- public void testBadFilterParam() throws Exception {
+ void testBadFilterParam() {
ctx = Configurator.initialize("Test1", "bad/log4j-badfilterparam.xml");
LogManager.getLogger("org.apache.test.TestConfigurator");
final Configuration config = ctx.getConfiguration();
@@ -362,7 +362,7 @@ public void testBadFilterParam() throws Exception {
}
@Test
- public void testNoFilters() throws Exception {
+ void testNoFilters() {
ctx = Configurator.initialize("Test1", "bad/log4j-nofilter.xml");
LogManager.getLogger("org.apache.test.TestConfigurator");
final Configuration config = ctx.getConfiguration();
@@ -377,7 +377,7 @@ public void testNoFilters() throws Exception {
}
@Test
- public void testBadLayout() throws Exception {
+ void testBadLayout() {
ctx = Configurator.initialize("Test1", "bad/log4j-badlayout.xml");
LogManager.getLogger("org.apache.test.TestConfigurator");
final Configuration config = ctx.getConfiguration();
@@ -386,14 +386,14 @@ public void testBadLayout() throws Exception {
}
@Test
- public void testBadFileName() throws Exception {
+ void testBadFileName() {
final StringBuilder dir = new StringBuilder("/VeryLongDirectoryName");
for (final String element : CHARS) {
dir.append(element);
dir.append(toRootUpperCase(element));
}
- final String value = FILESEP.equals("/") ? dir.toString() + "/test.log" : "1:/target/bad:file.log";
+ final String value = FILESEP.equals("/") ? dir + "/test.log" : "1:/target/bad:file.log";
System.setProperty("testfile", value);
ctx = Configurator.initialize("Test1", "bad/log4j-badfilename.xml");
LogManager.getLogger("org.apache.test.TestConfigurator");
@@ -404,7 +404,7 @@ public void testBadFileName() throws Exception {
}
@Test
- public void testBuilder() throws Exception {
+ void testBuilder() {
final ConfigurationBuilder builder = ConfigurationBuilderFactory.newConfigurationBuilder();
builder.setStatusLevel(Level.ERROR);
builder.setConfigurationName("BuilderTest");
@@ -429,7 +429,7 @@ public void testBuilder() throws Exception {
}
@Test
- public void testRolling() throws Exception {
+ void testRolling() {
final ConfigurationBuilder builder = ConfigurationBuilderFactory.newConfigurationBuilder();
builder.setStatusLevel(Level.ERROR);
@@ -469,7 +469,7 @@ public void testRolling() throws Exception {
}
@Test
- public void testBuilderWithScripts() throws Exception {
+ void testBuilderWithScripts() {
final String script =
"if (logEvent.getLoggerName().equals(\"NoLocation\")) {\n" + " return \"NoLocation\";\n"
+ " } else if (logEvent.getMarker() != null && logEvent.getMarker().isInstanceOf(\"FLOW\")) {\n"
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator2Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator2Test.java
index d1459aea782..55421ce8dfe 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator2Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator2Test.java
@@ -28,22 +28,22 @@
import org.junit.jupiter.api.Test;
@Tag("functional")
-public class Configurator2Test {
+class Configurator2Test {
@Test
- public void testInitializeFromAbsoluteFilePath() {
+ void testInitializeFromAbsoluteFilePath() {
final String path = new File("src/test/resources/log4j-list.xml").getAbsolutePath();
testInitializeFromFilePath(path);
}
@Test
- public void testInitializeFromRelativeFilePath() {
+ void testInitializeFromRelativeFilePath() {
final String path = new File("src/test/resources/log4j-list.xml").toString();
testInitializeFromFilePath(path);
}
@Test
- public void testReconfigure() {
+ void testReconfigure() {
final String path = new File("src/test/resources/log4j-list.xml").getAbsolutePath();
try (final LoggerContext loggerContext =
Configurator.initialize(getClass().getName(), null, path)) {
@@ -56,7 +56,7 @@ public void testReconfigure() {
}
@Test
- public void testReconfigureFromPath() {
+ void testReconfigureFromPath() {
final String path = new File("src/test/resources/log4j-list.xml").getAbsolutePath();
try (final LoggerContext loggerContext =
Configurator.initialize(getClass().getName(), null, path)) {
@@ -80,7 +80,7 @@ private void testInitializeFromFilePath(final String path) {
* LOG4J2-3631: Configurator uses getName() instead of getCanonicalName().
*/
@Test
- public void testSetLevelUsesCanonicalName() {
+ void testSetLevelUsesCanonicalName() {
final String path = new File("src/test/resources/log4j-list.xml").getAbsolutePath();
try (final LoggerContext loggerContext =
Configurator.initialize(getClass().getName(), null, path)) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorErrorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorErrorTest.java
index a558e4992dc..f00d31b4741 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorErrorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorErrorTest.java
@@ -26,21 +26,21 @@
import org.junit.jupiter.api.parallel.ResourceLock;
@ResourceLock("log4j2.LoggerContextFactory")
-public class ConfiguratorErrorTest {
+class ConfiguratorErrorTest {
@RegisterExtension
static final LoggerContextFactoryExtension EXTENSION =
new LoggerContextFactoryExtension(SimpleLoggerContextFactory.INSTANCE);
@Test
- public void testErrorNoClassLoader() {
+ void testErrorNoClassLoader() {
try (final LoggerContext ctx = Configurator.initialize("Test1", "target/test-classes/log4j2-config.xml")) {
assertNull(ctx, "No LoggerContext should have been returned");
}
}
@Test
- public void testErrorNullClassLoader() {
+ void testErrorNullClassLoader() {
try (final LoggerContext ctx =
Configurator.initialize("Test1", null, "target/test-classes/log4j2-config.xml")) {
assertNull(ctx, "No LoggerContext should have been returned");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorSetLevelTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorSetLevelTest.java
index 3954dda93f9..d5739c021d2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorSetLevelTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorSetLevelTest.java
@@ -30,7 +30,7 @@
@Tag("functional")
@LoggerContextSource("log4j-set-level.xml")
-public class ConfiguratorSetLevelTest {
+class ConfiguratorSetLevelTest {
private final ListAppender app1;
private final LoggerContext loggerContext;
@@ -43,7 +43,7 @@ public ConfiguratorSetLevelTest(final LoggerContext context, @Named("LIST1") fin
}
@Test
- public void testSetLevel() {
+ void testSetLevel() {
final Logger logger = loggerContext.getLogger(ConfiguratorSetLevelTest.class);
Configurator.setLevel(logger, Level.DEBUG);
final LoggerConfig loggerConfig = ((AbstractConfiguration) loggerContext.getConfiguration())
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
index 927f8257465..d9893b7bc53 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
@@ -19,7 +19,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertSame;
-import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Path;
import org.apache.logging.log4j.Level;
@@ -39,7 +38,7 @@
import org.junit.jupiter.api.Test;
@UsingStatusListener
-public class CustomConfigurationTest {
+class CustomConfigurationTest {
@TempLoggingDir
private static Path loggingPath;
@@ -48,14 +47,14 @@ public class CustomConfigurationTest {
@SetTestProperty(key = "log4j.level", value = "INFO")
@SetTestProperty(key = "log.level", value = "INFO")
@LoggerContextSource
- public void testConfig(final LoggerContext ctx) throws IOException {
+ void testConfig(final LoggerContext ctx) {
final Path logFile = loggingPath.resolve("test.log");
// don't bother using "error" since that's the default; try another level
final Configuration config = ctx.getConfiguration();
assertThat(config).isInstanceOf(XmlConfiguration.class);
for (final StatusListener listener : StatusLogger.getLogger().getListeners()) {
if (listener instanceof StatusConsoleListener) {
- assertSame(listener.getStatusLevel(), Level.INFO);
+ assertSame(Level.INFO, listener.getStatusLevel());
break;
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
index 69dc34b67b9..3e7a7e137f4 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
@@ -18,7 +18,6 @@
import static org.assertj.core.api.Assertions.assertThat;
-import java.io.IOException;
import java.nio.file.Path;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
import org.apache.logging.log4j.status.StatusLogger;
@@ -28,14 +27,14 @@
/**
* Tests the possibility to redirect status logger output to a file.
*/
-public class FileOutputTest {
+class FileOutputTest {
@TempLoggingDir
private static Path loggingPath;
@Test
@LoggerContextSource
- public void testConfig() throws IOException {
+ void testConfig() {
final Path logFile = loggingPath.resolve("status.log");
assertThat(logFile).exists().isNotEmptyFile();
// Closes the current listeners
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java
index 0d1b26b2bc4..7f7948c44e8 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java
@@ -33,10 +33,10 @@
@Tag("yaml")
@LoggerContextSource("log4j2-2134.yaml")
-public class JiraLog4j2_2134Test {
+class JiraLog4j2_2134Test {
@Test
- public void testRefresh() {
+ void testRefresh() {
final Logger log = LogManager.getLogger(this.getClass());
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
@@ -69,7 +69,7 @@ public void testRefresh() {
}
@Test
- public void testRefreshMinimalCodeStart() {
+ void testRefreshMinimalCodeStart() {
final Logger log = LogManager.getLogger(this.getClass());
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
@@ -79,7 +79,7 @@ public void testRefreshMinimalCodeStart() {
}
@Test
- public void testRefreshMinimalCodeStopStart() {
+ void testRefreshMinimalCodeStopStart() {
final Logger log = LogManager.getLogger(this.getClass());
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
ctx.stop();
@@ -89,7 +89,7 @@ public void testRefreshMinimalCodeStopStart() {
}
@Test
- public void testRefreshMinimalCodeStopStartConfig() {
+ void testRefreshMinimalCodeStopStartConfig() {
final Logger log = LogManager.getLogger(this.getClass());
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
@@ -101,7 +101,7 @@ public void testRefreshMinimalCodeStopStartConfig() {
@SuppressWarnings("deprecation")
@Test
- public void testRefreshDeprecatedApis() {
+ void testRefreshDeprecatedApis() {
final Logger log = LogManager.getLogger(this.getClass());
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java
index 23ca8ea3779..5098c34ccb3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java
@@ -39,7 +39,7 @@
/**
* Tests for LoggerConfig.
*/
-public class LoggerConfigTest {
+class LoggerConfigTest {
private static final String FQCN = LoggerConfigTest.class.getName();
@@ -50,7 +50,7 @@ private static LoggerConfig createForProperties(final Property[] properties) {
@SuppressWarnings({"deprecation"})
@Test
- public void testPropertiesWithoutSubstitution() {
+ void testPropertiesWithoutSubstitution() {
assertNull(createForProperties(null).getPropertyList(), "null propertiesList");
final Property[] all = new Property[] {
@@ -70,7 +70,7 @@ public void testPropertiesWithoutSubstitution() {
}
@Test
- public void testPropertiesWithSubstitution() {
+ void testPropertiesWithSubstitution() {
final Property[] all = new Property[] {
Property.createProperty("key1", "value1-${sys:user.name}"),
Property.createProperty("key2", "value2-${sys:user.name}"),
@@ -98,7 +98,7 @@ public void testPropertiesWithSubstitution() {
}
@Test
- public void testLevel() {
+ void testLevel() {
final Configuration configuration = new DefaultConfiguration();
final LoggerConfig config1 = LoggerConfig.newBuilder()
.withLoggerName("org.apache.logging.log4j.test")
@@ -112,14 +112,14 @@ public void testLevel() {
.withConfig(configuration)
.build();
config1.setParent(config2);
- assertEquals(config1.getLevel(), Level.ERROR, "Unexpected Level");
- assertEquals(config1.getExplicitLevel(), Level.ERROR, "Unexpected explicit level");
- assertEquals(config2.getLevel(), Level.ERROR, "Unexpected Level");
+ assertEquals(Level.ERROR, config1.getLevel(), "Unexpected Level");
+ assertEquals(Level.ERROR, config1.getExplicitLevel(), "Unexpected explicit level");
+ assertEquals(Level.ERROR, config2.getLevel(), "Unexpected Level");
assertNull(config2.getExplicitLevel(), "Unexpected explicit level");
}
@Test
- public void testSingleFilterInvocation() {
+ void testSingleFilterInvocation() {
final Configuration configuration = new NullConfiguration();
final Filter filter = mock(Filter.class);
final LoggerConfig config = LoggerConfig.newBuilder()
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggersPluginTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggersPluginTest.java
index 70e824937e5..382587b4a8b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggersPluginTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/LoggersPluginTest.java
@@ -31,11 +31,11 @@
* Tests LoggersPlugin.
*/
@SetSystemProperty(key = "log4j2.status.entries", value = "10")
-public class LoggersPluginTest {
+class LoggersPluginTest {
@Test
@LoggerContextSource("multipleRootLoggersTest.xml")
- public void testEmptyAttribute() {
+ void testEmptyAttribute() {
final Logger logger = LogManager.getLogger();
logger.info("Test");
final StatusData data = StatusLogger.getLogger().getStatusData().get(0);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingLanguageTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingLanguageTest.java
index 9018c42acb0..721c0e3090d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingLanguageTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingLanguageTest.java
@@ -34,12 +34,12 @@
@SetSystemProperty(key = Constants.SCRIPT_LANGUAGES, value = "beanshell, Javascript")
@Tag("functional")
-public class MissingLanguageTest {
+class MissingLanguageTest {
private LoggerContext ctx = null;
@AfterEach
- public void cleanup() {
+ void cleanup() {
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
if (ctx != null) {
Configurator.shutdown(ctx);
@@ -48,7 +48,7 @@ public void cleanup() {
}
@org.junit.jupiter.api.Test
- public void testBuilderWithScripts() {
+ void testBuilderWithScripts() {
final String script =
"if (logEvent.getLoggerName().equals(\"NoLocation\")) {\n" + " return \"NoLocation\";\n"
+ " } else if (logEvent.getMarker() != null && logEvent.getMarker().isInstanceOf(\"FLOW\")) {\n"
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
index 1fba7c859fa..13bd9706aa8 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
@@ -35,10 +35,10 @@
import org.junit.jupiter.api.Test;
@LoggerContextSource("missingRootLogger.xml")
-public class MissingRootLoggerTest {
+class MissingRootLoggerTest {
@Test
- public void testMissingRootLogger(final LoggerContext ctx) throws Exception {
+ void testMissingRootLogger(final LoggerContext ctx) {
final Logger logger = ctx.getLogger("sample.Logger1");
assertTrue(logger.isInfoEnabled(), "Logger should have the INFO level enabled");
assertFalse(logger.isDebugEnabled(), "Logger should have the DEBUG level disabled");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NestedLoggerConfigTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NestedLoggerConfigTest.java
index abdcd11303f..46211e4b072 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NestedLoggerConfigTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NestedLoggerConfigTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.logging.log4j.core.config;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
@@ -25,29 +25,21 @@
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
/**
* Tests for LoggerConfig hierarchies.
*/
-@RunWith(Parameterized.class)
-public class NestedLoggerConfigTest {
+class NestedLoggerConfigTest {
- @Parameterized.Parameters(name = "{0}")
- public static List data() throws IOException {
+ public static List data() {
return ImmutableList.of("logger-config/LoggerConfig/", "logger-config/AsyncLoggerConfig/");
}
- private final String prefix;
-
- public NestedLoggerConfigTest(final String prefix) {
- this.prefix = prefix;
- }
-
- @Test
- public void testInheritParentDefaultLevel() throws IOException {
+ @MethodSource("data")
+ @ParameterizedTest(name = "{0}")
+ void testInheritParentDefaultLevel(final String prefix) throws IOException {
final Configuration configuration = loadConfiguration(prefix + "default-level.xml");
try {
assertEquals(Level.ERROR, configuration.getLoggerConfig("com.foo").getLevel());
@@ -56,8 +48,9 @@ public void testInheritParentDefaultLevel() throws IOException {
}
}
- @Test
- public void testInheritParentLevel() throws IOException {
+ @MethodSource("data")
+ @ParameterizedTest(name = "{0}")
+ void testInheritParentLevel(final String prefix) throws IOException {
final Configuration configuration = loadConfiguration(prefix + "inherit-level.xml");
try {
assertEquals(Level.TRACE, configuration.getLoggerConfig("com.foo").getLevel());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NoLanguagesTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NoLanguagesTest.java
index b7bf58961e1..26b69be6d56 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NoLanguagesTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NoLanguagesTest.java
@@ -31,12 +31,12 @@
import org.junit.jupiter.api.Test;
@Tag("functional")
-public class NoLanguagesTest {
+class NoLanguagesTest {
private LoggerContext ctx = null;
@AfterEach
- public void cleanup() {
+ void cleanup() {
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
if (ctx != null) {
Configurator.shutdown(ctx);
@@ -45,7 +45,7 @@ public void cleanup() {
}
@Test
- public void testBuilderWithScripts() {
+ void testBuilderWithScripts() {
final String script =
"if (logEvent.getLoggerName().equals(\"NoLocation\")) {\n" + " return \"NoLocation\";\n"
+ " } else if (logEvent.getMarker() != null && logEvent.getMarker().isInstanceOf(\"FLOW\")) {\n"
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/PropertiesPluginTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/PropertiesPluginTest.java
index 4ef1c500a39..bbaa4894abe 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/PropertiesPluginTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/PropertiesPluginTest.java
@@ -20,15 +20,15 @@
import org.junit.jupiter.api.Test;
-public class PropertiesPluginTest {
+class PropertiesPluginTest {
@Test
- public void testUnescape() {
+ void testUnescape() {
assertEquals("${foo}", PropertiesPlugin.unescape("$${foo}"));
}
@Test
- public void testUnescapeNotEscapedWithDefault() {
+ void testUnescapeNotEscapedWithDefault() {
final String value = "${foo:-bar}";
assertEquals(value, PropertiesPlugin.unescape(value));
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/PropertyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/PropertyTest.java
index 3b13470d160..46539b41cd1 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/PropertyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/PropertyTest.java
@@ -35,10 +35,10 @@
* not working
*/
@LoggerContextSource("configPropertyTest.xml")
-public class PropertyTest {
+class PropertyTest {
@Test
- public void testEmptyAttribute(@Named("List") final ListAppender app) throws Exception {
+ void testEmptyAttribute(@Named("List") final ListAppender app) {
final org.apache.logging.log4j.Logger logger = LogManager.getLogger();
logger.info("msg");
@@ -70,7 +70,7 @@ public void testEmptyAttribute(@Named("List") final ListAppender app) throws Exc
}
@Test
- public void testPropertyValues() {
+ void testPropertyValues() {
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final StrSubstitutor sub = ctx.getConfiguration().getStrSubstitutor();
//
@@ -90,7 +90,7 @@ public void testPropertyValues() {
}
@Test
- public void testLoggerPropertyValues() throws Exception {
+ void testLoggerPropertyValues() {
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final List rootLoggerProperties =
ctx.getConfiguration().getLoggerConfig(LoggerConfig.ROOT).getPropertyList();
@@ -125,12 +125,12 @@ private static void verifyProperty(
}
@Test
- public void testNullValueIsConvertedToEmptyString() { // LOG4J2-1313 support
+ void testNullValueIsConvertedToEmptyString() { // LOG4J2-1313 support
assertEquals("", Property.createProperty("name", null).getValue());
}
@Test
- public void testIsValueNeedsLookup() {
+ void testIsValueNeedsLookup() {
assertTrue(Property.createProperty("", "${").isValueNeedsLookup(), "with ${ as value");
assertTrue(Property.createProperty("", "blah${blah").isValueNeedsLookup(), "with ${ in value");
assertFalse(Property.createProperty("", "").isValueNeedsLookup(), "empty value");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationDeadlockTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationDeadlockTest.java
index 48cfe679c18..2a595b533fe 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationDeadlockTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationDeadlockTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.logging.log4j.core.config;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.File;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -40,7 +43,6 @@
import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.RepeatedTest;
@@ -51,26 +53,26 @@
* @see TestAppender
*/
@LoggerContextSource("reconfiguration-deadlock.xml")
-public class ReconfigurationDeadlockTest {
+class ReconfigurationDeadlockTest {
private static final int WORKER_COUNT = 100;
private ExecutorService executor;
@BeforeEach
- public void startExecutor() {
+ void startExecutor() {
executor = Executors.newFixedThreadPool(WORKER_COUNT);
}
@AfterEach
- public void stopExecutor() throws InterruptedException {
+ void stopExecutor() throws InterruptedException {
executor.shutdownNow();
final boolean terminated = executor.awaitTermination(30, TimeUnit.SECONDS);
- Assertions.assertTrue(terminated, "couldn't terminate the executor");
+ assertTrue(terminated, "couldn't terminate the executor");
}
@RepeatedTest(100)
- public void reconfiguration_should_not_cause_deadlock_for_ongoing_logging() throws Exception {
+ void reconfiguration_should_not_cause_deadlock_for_ongoing_logging() throws Exception {
// Try to update the config file to ensure that we can indeed update it.
updateConfigFileModTime();
@@ -88,7 +90,7 @@ public void reconfiguration_should_not_cause_deadlock_for_ongoing_logging() thro
final Future> workerFuture = workerFutures.get(workerIndex);
try {
final Object workerResult = workerFuture.get(30, TimeUnit.SECONDS);
- Assertions.assertNull(workerResult);
+ assertNull(workerResult);
} catch (final Throwable failure) {
final String message =
String.format("check for worker %02d/%02d has failed", (workerIndex + 1), WORKER_COUNT);
@@ -100,7 +102,7 @@ public void reconfiguration_should_not_cause_deadlock_for_ongoing_logging() thro
private static void updateConfigFileModTime() {
final File file = new File("target/test-classes/reconfiguration-deadlock.xml");
final boolean fileModified = file.setLastModified(System.currentTimeMillis());
- Assertions.assertTrue(fileModified, "couldn't update file modification time");
+ assertTrue(fileModified, "couldn't update file modification time");
}
@SuppressWarnings("SameParameterValue")
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationFailureTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationFailureTest.java
index fcf4f5c60fa..14df356b901 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationFailureTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReconfigurationFailureTest.java
@@ -31,23 +31,24 @@
* Performs reconfiguration against bad configurations.
*
*/
-@Disabled // Remove this when LOG4J2-2240 is addressed.
-public class ReconfigurationFailureTest {
+// Remove this when LOG4J2-2240 is addressed.
+@Disabled
+class ReconfigurationFailureTest {
LoggerContext loggerContext;
@BeforeEach
- public void setup() {
+ void setup() {
loggerContext = (LoggerContext) LogManager.getContext();
}
@AfterEach
- public void stopExecutor() throws InterruptedException {
+ void stopExecutor() {
loggerContext.stop();
}
@Test
- public void setNonExistant() throws Exception {
+ void setNonExistant() {
final URI original = loggerContext.getConfigLocation();
final URI nonExistant = new File("target/file.does.not.exist.xml").toURI();
@@ -56,7 +57,7 @@ public void setNonExistant() throws Exception {
}
@Test
- public void setInvalidXML() throws Exception {
+ void setInvalidXML() {
final URI original = loggerContext.getConfigLocation();
final URI nonExistant = new File("target/InvalidXML.xml").toURI();
@@ -65,7 +66,7 @@ public void setInvalidXML() throws Exception {
}
@Test
- public void setInvalidConfig() throws Exception {
+ void setInvalidConfig() {
final URI original = loggerContext.getConfigLocation();
final URI nonExistant = new File("target/InvalidConfig.xml").toURI();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/BasicArbiterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/BasicArbiterTest.java
index 323bf8b64a8..ad898fb95a4 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/BasicArbiterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/BasicArbiterTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.logging.log4j.core.config.arbiters;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
@@ -31,36 +31,36 @@
/**
* Tests basic condition processing.
*/
-public class BasicArbiterTest {
+class BasicArbiterTest {
static final String CONFIG = "log4j2-arbiters.xml";
static LoggerContext loggerContext = null;
@AfterEach
- public void after() {
+ void after() {
loggerContext.stop();
loggerContext = null;
System.clearProperty("env");
}
@Test
- public void prodTest() {
+ void prodTest() {
System.setProperty("env", "prod");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
final Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
- assertTrue(app instanceof ListAppender);
+ assertInstanceOf(ListAppender.class, app);
}
@Test
- public void devTest() {
+ void devTest() {
System.setProperty("env", "dev");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
final Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
- assertTrue(app instanceof ConsoleAppender);
+ assertInstanceOf(ConsoleAppender.class, app);
}
@Test
@@ -69,7 +69,7 @@ void classArbiterTest() {
assertNotNull(loggerContext);
Appender app = loggerContext.getConfiguration().getAppender("ShouldExist");
assertNotNull(app);
- assertTrue(app instanceof ListAppender);
+ assertInstanceOf(ListAppender.class, app);
app = loggerContext.getConfiguration().getAppender("ShouldNotExist");
assertNull(app);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/EnvironmentArbiterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/EnvironmentArbiterTest.java
index 7c13c7a5cd2..ecb5c24d06b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/EnvironmentArbiterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/EnvironmentArbiterTest.java
@@ -16,8 +16,8 @@
*/
package org.apache.logging.log4j.core.config.arbiters;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
@@ -30,25 +30,25 @@
/**
* Tests system property condition processing.
*/
-public class EnvironmentArbiterTest {
+class EnvironmentArbiterTest {
private static final String CONFIG = "log4j2-environmentArbiters.xml";
@Test
@SetEnvironmentVariable(key = "ENV", value = "prod")
@LoggerContextSource(CONFIG)
- public void prodTest(final LoggerContext loggerContext) throws Exception {
+ void prodTest(final LoggerContext loggerContext) {
final Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
- assertTrue(app instanceof ListAppender);
+ assertInstanceOf(ListAppender.class, app);
}
@Test
@SetEnvironmentVariable(key = "ENV", value = "dev")
@LoggerContextSource(CONFIG)
- public void devTest(final LoggerContext loggerContext) throws Exception {
+ void devTest(final LoggerContext loggerContext) {
final Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
- assertTrue(app instanceof ConsoleAppender);
+ assertInstanceOf(ConsoleAppender.class, app);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/ScriptArbiterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/ScriptArbiterTest.java
index a15d97d0fe5..50899118c90 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/ScriptArbiterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/ScriptArbiterTest.java
@@ -16,8 +16,8 @@
*/
package org.apache.logging.log4j.core.config.arbiters;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
@@ -32,39 +32,39 @@
/**
* Tests basic condition processing.
*/
-public class ScriptArbiterTest {
+class ScriptArbiterTest {
static final String CONFIG = "log4j2-scriptArbiters.xml";
static LoggerContext loggerContext = null;
@BeforeAll
- public static void beforeClass() {
+ static void beforeClass() {
System.setProperty(Constants.SCRIPT_LANGUAGES, "Groovy, Javascript");
}
@AfterEach
- public void after() {
+ void after() {
loggerContext.stop();
loggerContext = null;
}
@Test
- public void prodTest() {
+ void prodTest() {
System.setProperty("env", "prod");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
final Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
- assertTrue(app instanceof ListAppender);
+ assertInstanceOf(ListAppender.class, app);
}
@Test
- public void devTest() {
+ void devTest() {
System.setProperty("env", "dev");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
final Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
- assertTrue(app instanceof ConsoleAppender);
+ assertInstanceOf(ConsoleAppender.class, app);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/SelectArbiterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/SelectArbiterTest.java
index beff044dc6a..07f1520afd7 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/SelectArbiterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/SelectArbiterTest.java
@@ -16,8 +16,8 @@
*/
package org.apache.logging.log4j.core.config.arbiters;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
@@ -30,34 +30,34 @@
/**
* Tests basic condition processing.
*/
-public class SelectArbiterTest {
+class SelectArbiterTest {
static final String CONFIG = "log4j2-selectArbiters.xml";
static LoggerContext loggerContext = null;
@AfterEach
- public void after() {
+ void after() {
loggerContext.stop();
loggerContext = null;
}
@Test
- public void prodTest() {
+ void prodTest() {
System.setProperty("env", "prod");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
final Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
- assertTrue(app instanceof ListAppender);
+ assertInstanceOf(ListAppender.class, app);
}
@Test
- public void devTest() {
+ void devTest() {
System.setProperty("env", "dev");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
final Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
- assertTrue(app instanceof ConsoleAppender);
+ assertInstanceOf(ConsoleAppender.class, app);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/SystemPropertyArbiterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/SystemPropertyArbiterTest.java
index fb3fedb9632..692d9997442 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/SystemPropertyArbiterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/arbiters/SystemPropertyArbiterTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.logging.log4j.core.config.arbiters;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
@@ -31,36 +31,36 @@
/**
* Tests system property condition processing.
*/
-public class SystemPropertyArbiterTest {
+class SystemPropertyArbiterTest {
static final String CONFIG = "log4j2-systemPropertyArbiters.xml";
static LoggerContext loggerContext = null;
@AfterEach
- public void after() {
+ void after() {
loggerContext.stop();
loggerContext = null;
System.clearProperty("env");
}
@Test
- public void prodTest() {
+ void prodTest() {
System.setProperty("env", "prod");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
final Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
- assertTrue(app instanceof ListAppender);
+ assertInstanceOf(ListAppender.class, app);
}
@Test
- public void devTest() {
+ void devTest() {
System.setProperty("env", "dev");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
final Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
- assertTrue(app instanceof ConsoleAppender);
+ assertInstanceOf(ConsoleAppender.class, app);
}
@Test
@@ -69,7 +69,7 @@ void classArbiterTest() {
assertNotNull(loggerContext);
Appender app = loggerContext.getConfiguration().getAppender("ShouldExist");
assertNotNull(app);
- assertTrue(app instanceof ListAppender);
+ assertInstanceOf(ListAppender.class, app);
app = loggerContext.getConfiguration().getAppender("ShouldNotExist");
assertNull(app);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
index 7bcb5437b28..0d6b74f33e6 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
@@ -48,10 +48,10 @@
import org.apache.logging.log4j.core.util.Constants;
import org.junit.jupiter.api.Test;
-public class ConfigurationAssemblerTest {
+class ConfigurationAssemblerTest {
@Test
- public void testBuildConfiguration() throws Exception {
+ void testBuildConfiguration() {
try {
System.setProperty(
Constants.LOG4J_CONTEXT_SELECTOR, "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
@@ -68,7 +68,7 @@ public void testBuildConfiguration() throws Exception {
}
@Test
- public void testCustomConfigurationFactory() throws Exception {
+ void testCustomConfigurationFactory() {
try {
System.setProperty(
ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY,
@@ -88,17 +88,17 @@ private void validate(final Configuration config) {
assertNotNull(config.getName());
assertFalse(config.getName().isEmpty());
assertNotNull(config, "No configuration created");
- assertEquals(config.getState(), LifeCycle.State.STARTED, "Incorrect State: " + config.getState());
+ assertEquals(LifeCycle.State.STARTED, config.getState(), "Incorrect State: " + config.getState());
final Map appenders = config.getAppenders();
assertNotNull(appenders);
- assertEquals(appenders.size(), 2, "Incorrect number of Appenders: " + appenders.size());
+ assertEquals(2, appenders.size(), "Incorrect number of Appenders: " + appenders.size());
final KafkaAppender kafkaAppender = (KafkaAppender) appenders.get("Kafka");
final GelfLayout gelfLayout = (GelfLayout) kafkaAppender.getLayout();
final ConsoleAppender consoleAppender = (ConsoleAppender) appenders.get("Stdout");
final PatternLayout patternLayout = (PatternLayout) consoleAppender.getLayout();
final Map loggers = config.getLoggers();
assertNotNull(loggers);
- assertEquals(loggers.size(), 2, "Incorrect number of LoggerConfigs: " + loggers.size());
+ assertEquals(2, loggers.size(), "Incorrect number of LoggerConfigs: " + loggers.size());
final LoggerConfig rootLoggerConfig = loggers.get("");
assertEquals(Level.ERROR, rootLoggerConfig.getLevel());
assertFalse(rootLoggerConfig.isIncludeLocation());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationBuilderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationBuilderTest.java
index 7232d272526..f2dbdf0bc4f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationBuilderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationBuilderTest.java
@@ -28,7 +28,7 @@
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import org.junit.jupiter.api.Test;
-public class ConfigurationBuilderTest {
+class ConfigurationBuilderTest {
private static final String INDENT = " ";
private static final String EOL = System.lineSeparator();
@@ -112,7 +112,7 @@ private void addTestFixtures(final String name, final ConfigurationBuilder builder = ConfigurationBuilderFactory.newConfigurationBuilder();
addTestFixtures("config name", builder);
final String xmlConfiguration = builder.toXmlConfiguration();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/DateTypeConverterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/DateTypeConverterTest.java
index dad6b53ffd8..1ccd7d032d9 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/DateTypeConverterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/DateTypeConverterTest.java
@@ -16,26 +16,19 @@
*/
package org.apache.logging.log4j.core.config.plugins.convert;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Date;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
/**
*
*/
-@RunWith(Parameterized.class)
-public class DateTypeConverterTest {
+class DateTypeConverterTest {
- private final Class extends Date> dateClass;
- private final long timestamp;
- private final Object expected;
-
- @Parameterized.Parameters
public static Object[][] data() {
final long millis = System.currentTimeMillis();
return new Object[][] {
@@ -46,14 +39,9 @@ public static Object[][] data() {
};
}
- public DateTypeConverterTest(final Class extends Date> dateClass, final long timestamp, final Object expected) {
- this.dateClass = dateClass;
- this.timestamp = timestamp;
- this.expected = expected;
- }
-
- @Test
- public void testFromMillis() throws Exception {
+ @MethodSource("data")
+ @ParameterizedTest
+ void testFromMillis(final Class extends Date> dateClass, final long timestamp, final Object expected) {
assertEquals(expected, DateTypeConverter.fromMillis(timestamp, dateClass));
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/TypeConverterRegistryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/TypeConverterRegistryTest.java
index b0de4ea7d61..5af8220e11e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/TypeConverterRegistryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/TypeConverterRegistryTest.java
@@ -16,30 +16,32 @@
*/
package org.apache.logging.log4j.core.config.plugins.convert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class TypeConverterRegistryTest {
+class TypeConverterRegistryTest {
- @Test(expected = NullPointerException.class)
- public void testFindNullConverter() {
- TypeConverterRegistry.getInstance().findCompatibleConverter(null);
+ @Test
+ void testFindNullConverter() {
+ assertThrows(NullPointerException.class, () -> TypeConverterRegistry.getInstance()
+ .findCompatibleConverter(null));
}
@Test
- public void testFindBooleanConverter() throws Exception {
+ void testFindBooleanConverter() throws Exception {
final TypeConverter> converter = TypeConverterRegistry.getInstance().findCompatibleConverter(Boolean.class);
assertNotNull(converter);
assertTrue((Boolean) converter.convert("TRUE"));
}
@Test
- public void testFindPrimitiveBooleanConverter() throws Exception {
+ void testFindPrimitiveBooleanConverter() throws Exception {
final TypeConverter> converter = TypeConverterRegistry.getInstance().findCompatibleConverter(Boolean.TYPE);
assertNotNull(converter);
assertTrue((Boolean) converter.convert("tRUe"));
@@ -47,7 +49,7 @@ public void testFindPrimitiveBooleanConverter() throws Exception {
@SuppressWarnings("unchecked")
@Test
- public void testFindCharSequenceConverterUsingStringConverter() throws Exception {
+ void testFindCharSequenceConverterUsingStringConverter() throws Exception {
final TypeConverter converter = (TypeConverter)
TypeConverterRegistry.getInstance().findCompatibleConverter(CharSequence.class);
assertNotNull(converter);
@@ -59,7 +61,7 @@ public void testFindCharSequenceConverterUsingStringConverter() throws Exception
@SuppressWarnings("unchecked")
@Test
- public void testFindNumberConverter() throws Exception {
+ void testFindNumberConverter() {
final TypeConverter numberTypeConverter =
(TypeConverter) TypeConverterRegistry.getInstance().findCompatibleConverter(Number.class);
assertNotNull(numberTypeConverter);
@@ -74,7 +76,7 @@ public enum Foo {
@SuppressWarnings("unchecked")
@Test
- public void testFindEnumConverter() throws Exception {
+ void testFindEnumConverter() throws Exception {
final TypeConverter fooTypeConverter =
(TypeConverter) TypeConverterRegistry.getInstance().findCompatibleConverter(Foo.class);
assertNotNull(fooTypeConverter);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/TypeConvertersTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/TypeConvertersTest.java
index de7741bfb10..1fc961db42d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/TypeConvertersTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/convert/TypeConvertersTest.java
@@ -38,18 +38,15 @@
import org.apache.logging.log4j.core.appender.rolling.action.Duration;
import org.apache.logging.log4j.core.layout.GelfLayout;
import org.apache.logging.log4j.core.net.Facility;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
/**
* Tests {@link TypeConverters}.
*/
-@RunWith(Parameterized.class)
public class TypeConvertersTest {
@SuppressWarnings("boxing")
- @Parameterized.Parameters
public static Collection data() throws Exception {
final byte[] byteArray = {
(byte) 0xc7, (byte) 0x73, (byte) 0x21, (byte) 0x8c, (byte) 0x7e, (byte) 0xc8, (byte) 0xee, (byte) 0x99
@@ -144,11 +141,11 @@ public static Collection data() throws Exception {
{"123", "123".getBytes(Charset.defaultCharset()), null, byte[].class},
{"0xC773218C7EC8EE99", byteArray, null, byte[].class},
{"0xc773218c7ec8ee99", byteArray, null, byte[].class},
- {"Base64:cGxlYXN1cmUu", "pleasure.".getBytes("US-ASCII"), null, byte[].class},
+ {"Base64:cGxlYXN1cmUu", "pleasure.".getBytes(StandardCharsets.US_ASCII), null, byte[].class},
// JRE
// JRE Charset
{"UTF-8", StandardCharsets.UTF_8, null, Charset.class},
- {"ASCII", Charset.forName("ASCII"), "UTF-8", Charset.class},
+ {"ASCII", StandardCharsets.US_ASCII, "UTF-8", Charset.class},
{"Not a real charset", StandardCharsets.UTF_8, "UTF-8", Charset.class},
{null, StandardCharsets.UTF_8, "UTF-8", Charset.class},
{null, null, null, Charset.class},
@@ -203,21 +200,9 @@ public static Collection data() throws Exception {
});
}
- private final String value;
- private final Object expected;
- private final String defaultValue;
- private final Class> clazz;
-
- public TypeConvertersTest(
- final String value, final Object expected, final String defaultValue, final Class> clazz) {
- this.value = value;
- this.expected = expected;
- this.defaultValue = defaultValue;
- this.clazz = clazz;
- }
-
- @Test
- public void testConvert() throws Exception {
+ @MethodSource("data")
+ @ParameterizedTest
+ void testConvert(final String value, final Object expected, final String defaultValue, final Class> clazz) {
final Object actual = TypeConverters.convert(value, clazz, defaultValue);
final String assertionMessage = "\nGiven: " + value + "\nDefault: " + defaultValue;
assertThat(actual).as(assertionMessage).isEqualTo(expected);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginCacheTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginCacheTest.java
index ffd89430c87..c94fd5cb1fc 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginCacheTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginCacheTest.java
@@ -16,35 +16,32 @@
*/
package org.apache.logging.log4j.core.config.plugins.processor;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
+import org.junit.jupiter.api.Test;
-@RunWith(JUnit4.class)
-public class PluginCacheTest {
+class PluginCacheTest {
@Test
- public void testOutputIsReproducibleWhenInputOrderingChanges() throws IOException {
+ void testOutputIsReproducibleWhenInputOrderingChanges() throws IOException {
final PluginCache cacheA = new PluginCache();
createCategory(cacheA, "one", Arrays.asList("bravo", "alpha", "charlie"));
createCategory(cacheA, "two", Arrays.asList("alpha", "charlie", "bravo"));
- assertEquals(cacheA.getAllCategories().size(), 2);
- assertEquals(cacheA.getAllCategories().get("one").size(), 3);
- assertEquals(cacheA.getAllCategories().get("two").size(), 3);
+ assertEquals(2, cacheA.getAllCategories().size());
+ assertEquals(3, cacheA.getAllCategories().get("one").size());
+ assertEquals(3, cacheA.getAllCategories().get("two").size());
final PluginCache cacheB = new PluginCache();
createCategory(cacheB, "two", Arrays.asList("bravo", "alpha", "charlie"));
createCategory(cacheB, "one", Arrays.asList("alpha", "charlie", "bravo"));
- assertEquals(cacheB.getAllCategories().size(), 2);
- assertEquals(cacheB.getAllCategories().get("one").size(), 3);
- assertEquals(cacheB.getAllCategories().get("two").size(), 3);
+ assertEquals(2, cacheB.getAllCategories().size());
+ assertEquals(3, cacheB.getAllCategories().get("one").size());
+ assertEquals(3, cacheB.getAllCategories().get("two").size());
assertArrayEquals(cacheData(cacheA), cacheData(cacheB));
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorTest.java
index 99798a38c1f..7dfad92ae8b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorTest.java
@@ -17,52 +17,49 @@
package org.apache.logging.log4j.core.config.plugins.processor;
import static org.apache.logging.log4j.util.Strings.toRootLowerCase;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAliases;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
-@RunWith(JUnit4.class)
-public class PluginProcessorTest {
+class PluginProcessorTest {
private static final PluginCache pluginCache = new PluginCache();
private final Plugin p = FakePlugin.class.getAnnotation(Plugin.class);
- @BeforeClass
- public static void setUpClass() throws Exception {
+ @BeforeAll
+ static void setUpClass() throws Exception {
final Enumeration resources =
PluginProcessor.class.getClassLoader().getResources(PluginProcessor.PLUGIN_CACHE_FILE);
pluginCache.loadCacheFiles(resources);
}
@Test
- public void testTestCategoryFound() throws Exception {
- assertNotNull("No plugin annotation on FakePlugin.", p);
+ void testTestCategoryFound() {
+ assertNotNull(p, "No plugin annotation on FakePlugin.");
final Map testCategory = pluginCache.getCategory(p.category());
- assertNotEquals("No plugins were found.", 0, pluginCache.size());
- assertNotNull("The category '" + p.category() + "' was not found.", testCategory);
+ assertNotEquals(0, pluginCache.size(), "No plugins were found.");
+ assertNotNull(testCategory, "The category '" + p.category() + "' was not found.");
assertFalse(testCategory.isEmpty());
}
@Test
- public void testFakePluginFoundWithCorrectInformation() throws Exception {
+ void testFakePluginFoundWithCorrectInformation() {
final PluginEntry fake = pluginCache.getCategory(p.category()).get(toRootLowerCase(p.name()));
verifyFakePluginEntry(p.name(), fake);
}
@Test
- public void testFakePluginAliasesContainSameInformation() throws Exception {
+ void testFakePluginAliasesContainSameInformation() {
final PluginAliases aliases = FakePlugin.class.getAnnotation(PluginAliases.class);
for (final String alias : aliases.value()) {
final PluginEntry fake = pluginCache.getCategory(p.category()).get(toRootLowerCase(alias));
@@ -71,7 +68,7 @@ public void testFakePluginAliasesContainSameInformation() throws Exception {
}
private void verifyFakePluginEntry(final String name, final PluginEntry fake) {
- assertNotNull("The plugin '" + toRootLowerCase(name) + "' was not found.", fake);
+ assertNotNull(fake, "The plugin '" + toRootLowerCase(name) + "' was not found.");
assertEquals(FakePlugin.class.getName(), fake.getClassName());
assertEquals(toRootLowerCase(name), fake.getKey());
assertEquals(Plugin.EMPTY, p.elementType());
@@ -81,7 +78,7 @@ private void verifyFakePluginEntry(final String name, final PluginEntry fake) {
}
@Test
- public void testNestedPlugin() throws Exception {
+ void testNestedPlugin() {
final Plugin p = FakePlugin.Nested.class.getAnnotation(Plugin.class);
final PluginEntry nested = pluginCache.getCategory(p.category()).get(toRootLowerCase(p.name()));
assertNotNull(nested);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
index 815b35894fc..262af0b0350 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
@@ -17,7 +17,7 @@
package org.apache.logging.log4j.core.config.plugins.util;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
@@ -44,7 +44,7 @@
/**
* Tests the ResolverUtil class for custom protocol like bundleresource, vfs, vfszip.
*/
-public class ResolverUtilCustomProtocolTest {
+class ResolverUtilCustomProtocolTest {
static class NoopURLStreamHandlerFactory implements URLStreamHandlerFactory {
@@ -59,7 +59,7 @@ protected URLConnection openConnection(final URL url) {
private URLConnection open(final URL url, final Proxy proxy) {
return new URLConnection(url) {
@Override
- public void connect() throws IOException {
+ public void connect() {
// do nothing
}
};
@@ -141,7 +141,7 @@ public Enumeration getResources(final String name) throws IOException {
}
@Override
- protected Enumeration findResources(final String name) throws IOException {
+ protected Enumeration findResources(final String name) {
return Collections.enumeration(Arrays.asList(findResource(name)));
}
}
@@ -172,41 +172,39 @@ static Stream testExtractedPath() {
@ParameterizedTest
@MethodSource
- public void testExtractedPath(final String urlAsString, final String expected) throws Exception {
+ void testExtractedPath(final String urlAsString, final String expected) throws Exception {
final URL url = new URL(urlAsString);
assertThat(new ResolverUtil().extractPath(url)).isEqualTo(expected);
}
@Test
- public void testFindInPackageFromVfsDirectoryURL() throws Exception {
+ void testFindInPackageFromVfsDirectoryURL() throws Exception {
final File tmpDir = new File(DIR, "resolverutil3");
try (final URLClassLoader cl = ResolverUtilTest.compileAndCreateClassLoader(tmpDir, "3")) {
final ResolverUtil resolverUtil = new ResolverUtil();
resolverUtil.setClassLoader(new SingleURLClassLoader(new URL("vfs:/" + tmpDir + "/customplugin3/"), cl));
resolverUtil.findInPackage(new PluginTest(), "customplugin3");
+ assertEquals(1, resolverUtil.getClasses().size(), "Class not found in packages");
assertEquals(
- "Class not found in packages", 1, resolverUtil.getClasses().size());
- assertEquals(
- "Unexpected class resolved",
cl.loadClass("customplugin3.FixedString3Layout"),
- resolverUtil.getClasses().iterator().next());
+ resolverUtil.getClasses().iterator().next(),
+ "Unexpected class resolved");
}
}
@Test
- public void testFindInPackageFromVfsJarURL() throws Exception {
+ void testFindInPackageFromVfsJarURL() throws Exception {
final File tmpDir = new File(DIR, "resolverutil4");
try (final URLClassLoader cl = ResolverUtilTest.compileJarAndCreateClassLoader(tmpDir, "4")) {
final ResolverUtil resolverUtil = new ResolverUtil();
resolverUtil.setClassLoader(
new SingleURLClassLoader(new URL("vfs:/" + tmpDir + "/customplugin4.jar/customplugin4/"), cl));
resolverUtil.findInPackage(new PluginTest(), "customplugin4");
+ assertEquals(1, resolverUtil.getClasses().size(), "Class not found in packages");
assertEquals(
- "Class not found in packages", 1, resolverUtil.getClasses().size());
- assertEquals(
- "Unexpected class resolved",
cl.loadClass("customplugin4.FixedString4Layout"),
- resolverUtil.getClasses().iterator().next());
+ resolverUtil.getClasses().iterator().next(),
+ "Unexpected class resolved");
}
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
index 5d20a79a7cf..0ff21e20567 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
@@ -20,7 +20,6 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
-import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
@@ -46,7 +45,7 @@
/**
* Tests the ResolverUtil class.
*/
-public class ResolverUtilTest {
+class ResolverUtilTest {
static Stream testExtractedPath() {
return Stream.of(
@@ -78,13 +77,13 @@ static Stream testExtractedPath() {
@ParameterizedTest
@MethodSource
- public void testExtractedPath(final String urlAsString, final String expected) throws Exception {
+ void testExtractedPath(final String urlAsString, final String expected) throws Exception {
final URL url = new URL(urlAsString);
assertThat(new ResolverUtil().extractPath(url)).isEqualTo(expected);
}
@Test
- public void testExtractPathFromJarUrlNotDecodedIfFileExists() throws Exception {
+ void testExtractPathFromJarUrlNotDecodedIfFileExists() throws Exception {
testExtractPathFromJarUrlNotDecodedIfFileExists("/log4j+config+with+plus+characters.xml");
}
@@ -100,13 +99,13 @@ private void testExtractPathFromJarUrlNotDecodedIfFileExists(final String existi
}
@Test
- public void testFileFromUriWithSpacesAndPlusCharactersInName() throws Exception {
+ void testFileFromUriWithSpacesAndPlusCharactersInName() throws Exception {
final String existingFile = "/s p a c e s/log4j+config+with+plus+characters.xml";
testExtractPathFromJarUrlNotDecodedIfFileExists(existingFile);
}
@Test
- public void testExtractPathFromFileUrlNotDecodedIfFileExists() throws Exception {
+ void testExtractPathFromFileUrlNotDecodedIfFileExists() throws Exception {
final String existingFile = "/log4j+config+with+plus+characters.xml";
final URL url = ResolverUtilTest.class.getResource(existingFile);
assertThat(url).hasProtocol("file");
@@ -115,7 +114,7 @@ public void testExtractPathFromFileUrlNotDecodedIfFileExists() throws Exception
}
@Test
- public void testFindInPackageFromDirectoryPath(final @TempDir File tmpDir) throws Exception {
+ void testFindInPackageFromDirectoryPath(final @TempDir File tmpDir) throws Exception {
try (final URLClassLoader cl = compileAndCreateClassLoader(tmpDir, "1")) {
final ResolverUtil resolverUtil = new ResolverUtil();
resolverUtil.setClassLoader(cl);
@@ -129,7 +128,7 @@ public void testFindInPackageFromDirectoryPath(final @TempDir File tmpDir) throw
}
@Test
- public void testFindInPackageFromJarPath(final @TempDir File tmpDir) throws Exception {
+ void testFindInPackageFromJarPath(final @TempDir File tmpDir) throws Exception {
try (final URLClassLoader cl = compileJarAndCreateClassLoader(tmpDir, "2")) {
final ResolverUtil resolverUtil = new ResolverUtil();
resolverUtil.setClassLoader(cl);
@@ -142,8 +141,7 @@ public void testFindInPackageFromJarPath(final @TempDir File tmpDir) throws Exce
}
}
- static URLClassLoader compileJarAndCreateClassLoader(final File tmpDir, final String suffix)
- throws IOException, Exception {
+ static URLClassLoader compileJarAndCreateClassLoader(final File tmpDir, final String suffix) throws Exception {
compile(tmpDir, suffix);
final File jarFile = new File(tmpDir, "customplugin" + suffix + ".jar");
final URI jarURI = jarFile.toURI();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidatorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidatorTest.java
index 33a5ca37d70..9a53b6fced7 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidatorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidatorTest.java
@@ -29,14 +29,14 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class RequiredValidatorTest {
+class RequiredValidatorTest {
private PluginType plugin;
private Node node;
@SuppressWarnings("unchecked")
@BeforeEach
- public void setUp() throws Exception {
+ void setUp() {
final PluginManager manager = new PluginManager("Test");
manager.collectPlugins();
plugin = (PluginType) manager.getPluginType("Validator");
@@ -45,7 +45,7 @@ public void setUp() throws Exception {
}
@Test
- public void testNullDefaultValue() throws Exception {
+ void testNullDefaultValue() {
final ValidatingPlugin validatingPlugin = (ValidatingPlugin) new PluginBuilder(plugin)
.withConfiguration(new NullConfiguration())
.withConfigurationNode(node)
@@ -54,7 +54,7 @@ public void testNullDefaultValue() throws Exception {
}
@Test
- public void testNonNullValue() throws Exception {
+ void testNonNullValue() {
node.getAttributes().put("name", "foo");
final ValidatingPlugin validatingPlugin = (ValidatingPlugin) new PluginBuilder(plugin)
.withConfiguration(new NullConfiguration())
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidHostValidatorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidHostValidatorTest.java
index af757064c6e..772c6a62d5f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidHostValidatorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidHostValidatorTest.java
@@ -31,14 +31,14 @@
import org.junit.jupiter.api.Test;
@StatusLoggerLevel("FATAL")
-public class ValidHostValidatorTest {
+class ValidHostValidatorTest {
private PluginType plugin;
private Node node;
@SuppressWarnings("unchecked")
@BeforeEach
- public void setUp() throws Exception {
+ void setUp() {
final PluginManager manager = new PluginManager("Test");
manager.collectPlugins();
plugin = (PluginType) manager.getPluginType("HostAndPort");
@@ -47,12 +47,12 @@ public void setUp() throws Exception {
}
@Test
- public void testNullHost() throws Exception {
+ void testNullHost() {
assertNull(buildPlugin());
}
@Test
- public void testInvalidIpAddress() throws Exception {
+ void testInvalidIpAddress() {
node.getAttributes().put("host", "256.256.256.256");
node.getAttributes().put("port", "1");
final HostAndPort plugin = buildPlugin();
@@ -60,7 +60,7 @@ public void testInvalidIpAddress() throws Exception {
}
@Test
- public void testLocalhost() throws Exception {
+ void testLocalhost() {
node.getAttributes().put("host", "localhost");
node.getAttributes().put("port", "1");
final HostAndPort hostAndPort = buildPlugin();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidPortValidatorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidPortValidatorTest.java
index a4b927b562f..99d4853233c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidPortValidatorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidPortValidatorTest.java
@@ -28,13 +28,13 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class ValidPortValidatorTest {
+class ValidPortValidatorTest {
private PluginType plugin;
private Node node;
@SuppressWarnings("unchecked")
@BeforeEach
- public void setUp() throws Exception {
+ void setUp() {
final PluginManager manager = new PluginManager("Test");
manager.collectPlugins();
plugin = (PluginType) manager.getPluginType("HostAndPort");
@@ -44,19 +44,19 @@ public void setUp() throws Exception {
}
@Test
- public void testNegativePort() throws Exception {
+ void testNegativePort() {
node.getAttributes().put("port", "-1");
assertNull(buildPlugin());
}
@Test
- public void testValidPort() throws Exception {
+ void testValidPort() {
node.getAttributes().put("port", "10");
assertNotNull(buildPlugin());
}
@Test
- public void testInvalidPort() throws Exception {
+ void testInvalidPort() {
node.getAttributes().put("port", "1234567890");
assertNull(buildPlugin());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithFailoverTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithFailoverTest.java
index 7a217392315..d47ba5457c1 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithFailoverTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithFailoverTest.java
@@ -39,14 +39,14 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class ValidatingPluginWithFailoverTest {
+class ValidatingPluginWithFailoverTest {
private PluginType plugin;
private Node node;
@SuppressWarnings("unchecked")
@BeforeEach
- public void setUp() throws Exception {
+ void setUp() {
final PluginManager manager = new PluginManager(Core.CATEGORY_NAME);
manager.collectPlugins();
plugin = (PluginType) manager.getPluginType("failover");
@@ -66,7 +66,7 @@ public void setUp() throws Exception {
}
@Test
- public void testDoesNotLog_NoParameterThatMatchesElement_message() {
+ void testDoesNotLog_NoParameterThatMatchesElement_message() {
final StoringStatusListener listener = new StoringStatusListener();
// @formatter:off
final PluginBuilder builder = new PluginBuilder(plugin)
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithGenericBuilderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithGenericBuilderTest.java
index 25d753aa995..6c6090438ff 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithGenericBuilderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithGenericBuilderTest.java
@@ -29,14 +29,14 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class ValidatingPluginWithGenericBuilderTest {
+class ValidatingPluginWithGenericBuilderTest {
private PluginType plugin;
private Node node;
@SuppressWarnings("unchecked")
@BeforeEach
- public void setUp() throws Exception {
+ void setUp() {
final PluginManager manager = new PluginManager("Test");
manager.collectPlugins();
plugin = (PluginType)
@@ -46,7 +46,7 @@ public void setUp() throws Exception {
}
@Test
- public void testNullDefaultValue() throws Exception {
+ void testNullDefaultValue() {
final ValidatingPluginWithGenericBuilder validatingPlugin =
(ValidatingPluginWithGenericBuilder) new PluginBuilder(plugin)
.withConfiguration(new NullConfiguration())
@@ -56,7 +56,7 @@ public void testNullDefaultValue() throws Exception {
}
@Test
- public void testNonNullValue() throws Exception {
+ void testNonNullValue() {
node.getAttributes().put("name", "foo");
final ValidatingPluginWithGenericBuilder validatingPlugin =
(ValidatingPluginWithGenericBuilder) new PluginBuilder(plugin)
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithGenericSubclassFoo1BuilderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithGenericSubclassFoo1BuilderTest.java
index 91bcc5b89a2..e3360258b7d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithGenericSubclassFoo1BuilderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithGenericSubclassFoo1BuilderTest.java
@@ -29,14 +29,14 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class ValidatingPluginWithGenericSubclassFoo1BuilderTest {
+class ValidatingPluginWithGenericSubclassFoo1BuilderTest {
private PluginType plugin;
private Node node;
@SuppressWarnings("unchecked")
@BeforeEach
- public void setUp() throws Exception {
+ void setUp() {
final PluginManager manager = new PluginManager("Test");
manager.collectPlugins();
plugin = (PluginType)
@@ -46,7 +46,7 @@ public void setUp() throws Exception {
}
@Test
- public void testNullDefaultValue() throws Exception {
+ void testNullDefaultValue() {
final PluginWithGenericSubclassFoo1Builder validatingPlugin =
(PluginWithGenericSubclassFoo1Builder) new PluginBuilder(plugin)
.withConfiguration(new NullConfiguration())
@@ -56,7 +56,7 @@ public void testNullDefaultValue() throws Exception {
}
@Test
- public void testNonNullValue() throws Exception {
+ void testNonNullValue() {
node.getAttributes().put("thing", "thing1");
node.getAttributes().put("foo1", "foo1");
final PluginWithGenericSubclassFoo1Builder validatingPlugin =
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithTypedBuilderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithTypedBuilderTest.java
index caed8b7267f..579be80385e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithTypedBuilderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithTypedBuilderTest.java
@@ -29,14 +29,14 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class ValidatingPluginWithTypedBuilderTest {
+class ValidatingPluginWithTypedBuilderTest {
private PluginType plugin;
private Node node;
@SuppressWarnings("unchecked")
@BeforeEach
- public void setUp() throws Exception {
+ void setUp() {
final PluginManager manager = new PluginManager("Test");
manager.collectPlugins();
plugin = (PluginType)
@@ -46,7 +46,7 @@ public void setUp() throws Exception {
}
@Test
- public void testNullDefaultValue() throws Exception {
+ void testNullDefaultValue() {
// @formatter:off
final ValidatingPluginWithTypedBuilder validatingPlugin =
(ValidatingPluginWithTypedBuilder) new PluginBuilder(plugin)
@@ -58,7 +58,7 @@ public void testNullDefaultValue() throws Exception {
}
@Test
- public void testNonNullValue() throws Exception {
+ void testNonNullValue() {
node.getAttributes().put("name", "foo");
// @formatter:off
final ValidatingPluginWithTypedBuilder validatingPlugin =
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
index 5a3329a5b17..181879489ca 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
@@ -19,8 +19,8 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Map;
@@ -46,7 +46,7 @@ class PropertiesConfigurationTest {
@Test
@LoggerContextSource("log4j2-properties.properties")
void testPropertiesConfiguration(final Configuration config) {
- assertEquals(config.getState(), LifeCycle.State.STARTED, "Incorrect State: " + config.getState());
+ assertEquals(LifeCycle.State.STARTED, config.getState(), "Incorrect State: " + config.getState());
final Map appenders = config.getAppenders();
assertNotNull(appenders);
assertEquals(1, appenders.size(), "Incorrect number of Appenders: " + appenders.size());
@@ -55,7 +55,7 @@ void testPropertiesConfiguration(final Configuration config) {
assertEquals(2, loggers.size(), "Incorrect number of LoggerConfigs: " + loggers.size());
final Filter filter = config.getFilter();
assertNotNull(filter, "No Filter");
- assertTrue(filter instanceof ThresholdFilter, "Not a Threshold Filter");
+ assertInstanceOf(ThresholdFilter.class, filter, "Not a Threshold Filter");
final Logger logger = LogManager.getLogger(getClass());
logger.info("Welcome to Log4j!");
}
@@ -63,13 +63,13 @@ void testPropertiesConfiguration(final Configuration config) {
@Test
@LoggerContextSource("log4j2-properties-root-only.properties")
void testRootLoggerOnly(final Configuration config) {
- assertEquals(config.getState(), LifeCycle.State.STARTED, "Incorrect State: " + config.getState());
+ assertEquals(LifeCycle.State.STARTED, config.getState(), "Incorrect State: " + config.getState());
final Map appenders = config.getAppenders();
assertNotNull(appenders);
- assertEquals(appenders.size(), 1, "Incorrect number of Appenders: " + appenders.size());
+ assertEquals(1, appenders.size(), "Incorrect number of Appenders: " + appenders.size());
final Map loggers = config.getLoggers();
assertNotNull(loggers);
- assertEquals(loggers.size(), 1, "Incorrect number of LoggerConfigs: " + loggers.size());
+ assertEquals(1, loggers.size(), "Incorrect number of LoggerConfigs: " + loggers.size());
final Filter filter = config.getFilter();
assertNotNull(filter, "No Filter");
assertThat(filter, instanceOf(ThresholdFilter.class));
@@ -80,13 +80,13 @@ void testRootLoggerOnly(final Configuration config) {
@Test
@LoggerContextSource("log4j-rolling.properties")
void testRollingFile(final Configuration config) {
- assertEquals(config.getState(), LifeCycle.State.STARTED, "Incorrect State: " + config.getState());
+ assertEquals(LifeCycle.State.STARTED, config.getState(), "Incorrect State: " + config.getState());
final Map appenders = config.getAppenders();
assertNotNull(appenders);
- assertEquals(appenders.size(), 3, "Incorrect number of Appenders: " + appenders.size());
+ assertEquals(3, appenders.size(), "Incorrect number of Appenders: " + appenders.size());
final Map loggers = config.getLoggers();
assertNotNull(loggers);
- assertEquals(loggers.size(), 2, "Incorrect number of LoggerConfigs: " + loggers.size());
+ assertEquals(2, loggers.size(), "Incorrect number of LoggerConfigs: " + loggers.size());
final Filter filter = config.getFilter();
assertNotNull(filter, "No Filter");
assertThat(filter, instanceOf(ThresholdFilter.class));
@@ -97,13 +97,13 @@ void testRollingFile(final Configuration config) {
@Test
@LoggerContextSource("log4j2-properties-trailing-space-on-level.properties")
void testTrailingSpaceOnLevel(final Configuration config) {
- assertEquals(config.getState(), LifeCycle.State.STARTED, "Incorrect State: " + config.getState());
+ assertEquals(LifeCycle.State.STARTED, config.getState(), "Incorrect State: " + config.getState());
final Map appenders = config.getAppenders();
assertNotNull(appenders);
- assertEquals(appenders.size(), 1, "Incorrect number of Appenders: " + appenders.size());
+ assertEquals(1, appenders.size(), "Incorrect number of Appenders: " + appenders.size());
final Map loggers = config.getLoggers();
assertNotNull(loggers);
- assertEquals(loggers.size(), 2, "Incorrect number of LoggerConfigs: " + loggers.size());
+ assertEquals(2, loggers.size(), "Incorrect number of LoggerConfigs: " + loggers.size());
final Filter filter = config.getFilter();
assertNotNull(filter, "No Filter");
assertThat(filter, instanceOf(ThresholdFilter.class));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationSecurity.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationSecurity.java
index 07608bb0c1a..64aa3aa4d63 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationSecurity.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlConfigurationSecurity.java
@@ -18,7 +18,6 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import java.io.IOException;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
import org.junit.jupiter.api.Tag;
@@ -27,11 +26,11 @@
@Tag("functional")
@Tag("security")
-public class XmlConfigurationSecurity {
+class XmlConfigurationSecurity {
@Test
@Timeout(5)
- public void xmlSecurity() throws IOException {
+ void xmlSecurity() {
final LoggerContext context =
Configurator.initialize("XmlConfigurationSecurity", "XmlConfigurationSecurity.xml");
assertNotNull(context.getConfiguration().getAppender("list"));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
index 203790718a4..81d36e00d41 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
@@ -32,7 +32,7 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-public class XmlLoggerPropsTest {
+class XmlLoggerPropsTest {
@BeforeAll
static void setupClass() {
@@ -46,7 +46,7 @@ static void tearDownClass() {
@Test
@LoggerContextSource("log4j-loggerprops.xml")
- public void testWithProps(final LoggerContext context, @Named("List") final ListAppender listAppender) {
+ void testWithProps(final LoggerContext context, @Named("List") final ListAppender listAppender) {
assertThat(context.getConfiguration(), is(instanceOf(XmlConfiguration.class)));
context.getLogger(getClass()).debug("Test with props");
context.getLogger("tiny.bubbles").debug("Test on root");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/context/internal/GarbageFreeSortedArrayThreadContextMapTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/context/internal/GarbageFreeSortedArrayThreadContextMapTest.java
index 192c72e85ce..54a4a23a15f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/context/internal/GarbageFreeSortedArrayThreadContextMapTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/context/internal/GarbageFreeSortedArrayThreadContextMapTest.java
@@ -28,7 +28,7 @@
import org.apache.logging.log4j.util.PropertiesUtil;
import org.junit.jupiter.api.Test;
-public class GarbageFreeSortedArrayThreadContextMapTest extends ThreadContextMapSuite {
+class GarbageFreeSortedArrayThreadContextMapTest extends ThreadContextMapSuite {
private GarbageFreeSortedArrayThreadContextMap createThreadContextMap() {
return new GarbageFreeSortedArrayThreadContextMap();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterTest.java
index 34f0f7e6967..8996b9f2f16 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterTest.java
@@ -29,10 +29,10 @@
/**
* Tests the AbstractFilter test.
*/
-public class AbstractFilterTest {
+class AbstractFilterTest {
@Test
- public void testUnrolledBackwardsCompatible() {
+ void testUnrolledBackwardsCompatible() {
final ConcreteFilter filter = new ConcreteFilter();
final Filter.Result expected = Filter.Result.DENY;
verifyMethodsWithUnrolledVarargs(filter, Filter.Result.DENY);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java
index fec1da628c3..4f117a1ccf5 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java
@@ -18,26 +18,26 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.Filter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class AbstractFilterableTest {
+class AbstractFilterableTest {
MockedAbstractFilterable filterable;
@BeforeEach
- public void setup() {
+ void setup() {
filterable = new MockedAbstractFilterable();
}
@Test
- public void testAddSimpleFilter() throws Exception {
+ void testAddSimpleFilter() {
final Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
filterable.addFilter(filter);
@@ -45,7 +45,7 @@ public void testAddSimpleFilter() throws Exception {
}
@Test
- public void testAddMultipleSimpleFilters() throws Exception {
+ void testAddMultipleSimpleFilters() {
final Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
filterable.addFilter(filter);
@@ -53,12 +53,12 @@ public void testAddMultipleSimpleFilters() throws Exception {
// adding a second filter converts the filter
// into a CompositeFilter.class
filterable.addFilter(filter);
- assertTrue(filterable.getFilter() instanceof CompositeFilter);
+ assertInstanceOf(CompositeFilter.class, filterable.getFilter());
assertEquals(2, ((CompositeFilter) filterable.getFilter()).getFilters().size());
}
@Test
- public void testAddMultipleEqualSimpleFilter() throws Exception {
+ void testAddMultipleEqualSimpleFilter() {
final Filter filter = new EqualFilter("test");
filterable.addFilter(filter);
@@ -66,12 +66,12 @@ public void testAddMultipleEqualSimpleFilter() throws Exception {
// adding a second filter converts the filter
// into a CompositeFilter.class
filterable.addFilter(filter);
- assertTrue(filterable.getFilter() instanceof CompositeFilter);
+ assertInstanceOf(CompositeFilter.class, filterable.getFilter());
assertEquals(2, ((CompositeFilter) filterable.getFilter()).getFilters().size());
}
@Test
- public void testAddCompositeFilter() throws Exception {
+ void testAddCompositeFilter() {
final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter compositeFilter = CompositeFilter.createFilters(filter1, filter2);
@@ -81,7 +81,7 @@ public void testAddCompositeFilter() throws Exception {
}
@Test
- public void testAddMultipleCompositeFilters() throws Exception {
+ void testAddMultipleCompositeFilters() {
final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter filter3 = ThresholdFilter.createFilter(Level.ERROR, null, null);
@@ -92,12 +92,12 @@ public void testAddMultipleCompositeFilters() throws Exception {
// adding a second filter converts the filter
// into a CompositeFilter.class
filterable.addFilter(compositeFilter);
- assertTrue(filterable.getFilter() instanceof CompositeFilter);
+ assertInstanceOf(CompositeFilter.class, filterable.getFilter());
assertEquals(6, ((CompositeFilter) filterable.getFilter()).getFilters().size());
}
@Test
- public void testAddSimpleFilterAndCompositeFilter() throws Exception {
+ void testAddSimpleFilterAndCompositeFilter() {
final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter notInCompositeFilterFilter = ThresholdFilter.createFilter(Level.ERROR, null, null);
@@ -108,12 +108,12 @@ public void testAddSimpleFilterAndCompositeFilter() throws Exception {
// adding a second filter converts the filter
// into a CompositeFilter.class
filterable.addFilter(compositeFilter);
- assertTrue(filterable.getFilter() instanceof CompositeFilter);
+ assertInstanceOf(CompositeFilter.class, filterable.getFilter());
assertEquals(2, ((CompositeFilter) filterable.getFilter()).getFilters().size());
}
@Test
- public void testAddCompositeFilterAndSimpleFilter() throws Exception {
+ void testAddCompositeFilterAndSimpleFilter() {
final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter notInCompositeFilterFilter = ThresholdFilter.createFilter(Level.ERROR, null, null);
@@ -124,12 +124,12 @@ public void testAddCompositeFilterAndSimpleFilter() throws Exception {
// adding a second filter converts the filter
// into a CompositeFilter.class
filterable.addFilter(notInCompositeFilterFilter);
- assertTrue(filterable.getFilter() instanceof CompositeFilter);
+ assertInstanceOf(CompositeFilter.class, filterable.getFilter());
assertEquals(3, ((CompositeFilter) filterable.getFilter()).getFilters().size());
}
@Test
- public void testRemoveSimpleFilterFromSimpleFilter() throws Exception {
+ void testRemoveSimpleFilterFromSimpleFilter() {
final Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
filterable.addFilter(filter);
@@ -138,7 +138,7 @@ public void testRemoveSimpleFilterFromSimpleFilter() throws Exception {
}
@Test
- public void testRemoveSimpleEqualFilterFromSimpleFilter() throws Exception {
+ void testRemoveSimpleEqualFilterFromSimpleFilter() {
final Filter filterOriginal = new EqualFilter("test");
final Filter filterCopy = new EqualFilter("test");
@@ -148,7 +148,7 @@ public void testRemoveSimpleEqualFilterFromSimpleFilter() throws Exception {
}
@Test
- public void testRemoveSimpleEqualFilterFromTwoSimpleFilters() throws Exception {
+ void testRemoveSimpleEqualFilterFromTwoSimpleFilters() {
final Filter filterOriginal = new EqualFilter("test");
final Filter filterCopy = new EqualFilter("test");
@@ -161,7 +161,7 @@ public void testRemoveSimpleEqualFilterFromTwoSimpleFilters() throws Exception {
}
@Test
- public void testRemoveSimpleEqualFilterFromMultipleSimpleFilters() throws Exception {
+ void testRemoveSimpleEqualFilterFromMultipleSimpleFilters() {
final Filter filterOriginal = new EqualFilter("test");
final Filter filterCopy = new EqualFilter("test");
@@ -169,7 +169,7 @@ public void testRemoveSimpleEqualFilterFromMultipleSimpleFilters() throws Except
filterable.addFilter(filterOriginal);
filterable.addFilter(filterCopy);
filterable.removeFilter(filterCopy);
- assertTrue(filterable.getFilter() instanceof CompositeFilter);
+ assertInstanceOf(CompositeFilter.class, filterable.getFilter());
assertEquals(2, ((CompositeFilter) filterable.getFilter()).getFilters().size());
filterable.removeFilter(filterCopy);
assertEquals(filterOriginal, filterable.getFilter());
@@ -178,7 +178,7 @@ public void testRemoveSimpleEqualFilterFromMultipleSimpleFilters() throws Except
}
@Test
- public void testRemoveNullFromSingleSimpleFilter() throws Exception {
+ void testRemoveNullFromSingleSimpleFilter() {
final Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
filterable.addFilter(filter);
@@ -187,7 +187,7 @@ public void testRemoveNullFromSingleSimpleFilter() throws Exception {
}
@Test
- public void testRemoveNonExistingFilterFromSingleSimpleFilter() throws Exception {
+ void testRemoveNonExistingFilterFromSingleSimpleFilter() {
final Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter newFilter = ThresholdFilter.createFilter(Level.WARN, null, null);
@@ -197,7 +197,7 @@ public void testRemoveNonExistingFilterFromSingleSimpleFilter() throws Exception
}
@Test
- public void testRemoveSimpleFilterFromCompositeFilter() {
+ void testRemoveSimpleFilterFromCompositeFilter() {
final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter compositeFilter = CompositeFilter.createFilters(filter1, filter2);
@@ -212,7 +212,7 @@ public void testRemoveSimpleFilterFromCompositeFilter() {
}
@Test
- public void testRemoveSimpleFilterFromCompositeAndSimpleFilter() {
+ void testRemoveSimpleFilterFromCompositeAndSimpleFilter() {
final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter compositeFilter = CompositeFilter.createFilters(filter1, filter2);
@@ -223,12 +223,12 @@ public void testRemoveSimpleFilterFromCompositeAndSimpleFilter() {
// should not remove internal filter of compositeFilter
filterable.removeFilter(anotherFilter);
- assertTrue(filterable.getFilter() instanceof CompositeFilter);
+ assertInstanceOf(CompositeFilter.class, filterable.getFilter());
assertEquals(2, ((CompositeFilter) filterable.getFilter()).getFilters().size());
}
@Test
- public void testRemoveCompositeFilterFromCompositeFilter() {
+ void testRemoveCompositeFilterFromCompositeFilter() {
final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter compositeFilter = CompositeFilter.createFilters(filter1, filter2);
@@ -239,7 +239,7 @@ public void testRemoveCompositeFilterFromCompositeFilter() {
}
@Test
- public void testRemoveFiltersFromComposite() {
+ void testRemoveFiltersFromComposite() {
final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
final Filter compositeFilter = CompositeFilter.createFilters(filter1, filter2);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractScriptFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractScriptFilterTest.java
index d883eaec78a..a9fcb1fc0ae 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractScriptFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/AbstractScriptFilterTest.java
@@ -34,7 +34,7 @@
public abstract class AbstractScriptFilterTest {
@Test
- public void testGroovyFilter(final LoggerContext context, @Named("List") final ListAppender app) throws Exception {
+ public void testGroovyFilter(final LoggerContext context, @Named("List") final ListAppender app) {
final Logger logger = context.getLogger("TestGroovyFilter");
logger.traceEntry();
logger.info("This should not be logged");
@@ -44,15 +44,14 @@ public void testGroovyFilter(final LoggerContext context, @Named("List") final L
try {
final List messages = app.getMessages();
assertNotNull(messages, "No Messages");
- assertEquals(messages.size(), 2, "Incorrect number of messages. Expected 2, Actual " + messages.size());
+ assertEquals(2, messages.size(), "Incorrect number of messages. Expected 2, Actual " + messages.size());
} finally {
app.clear();
}
}
@Test
- public void testJavascriptFilter(final LoggerContext context, @Named("List") final ListAppender app)
- throws Exception {
+ public void testJavascriptFilter(final LoggerContext context, @Named("List") final ListAppender app) {
final Logger logger = context.getLogger("TestJavaScriptFilter");
logger.traceEntry();
logger.info("This should not be logged");
@@ -62,7 +61,7 @@ public void testJavascriptFilter(final LoggerContext context, @Named("List") fin
final List messages = app.getMessages();
try {
assertNotNull(messages, "No Messages");
- assertEquals(messages.size(), 2, "Incorrect number of messages. Expected 2, Actual " + messages.size());
+ assertEquals(2, messages.size(), "Incorrect number of messages. Expected 2, Actual " + messages.size());
} finally {
app.clear();
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterLogDelayTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterLogDelayTest.java
index 8c78bf29c08..8fd101038eb 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterLogDelayTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterLogDelayTest.java
@@ -27,10 +27,10 @@
/**
* Unit test for BurstFilter
.
*/
-public class BurstFilterLogDelayTest {
+class BurstFilterLogDelayTest {
@Test
- public void testCompareToOverflow() {
+ void testCompareToOverflow() {
// no overflow, but close
final Delayed d1 =
BurstFilter.createLogDelay(Long.MAX_VALUE - TimeUnit.SECONDS.toNanos(10) - System.nanoTime());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java
index e76bf6c6f05..4d03e838b9e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java
@@ -33,7 +33,7 @@
* Unit test for BurstFilter
.
*/
@LoggerContextSource("log4j-burst.xml")
-public class BurstFilterTest {
+class BurstFilterTest {
private final ListAppender app;
private final BurstFilter filter;
@@ -52,7 +52,7 @@ public BurstFilterTest(final LoggerContext context, @Named("ListAppender") final
* sure the filter allows the appropriate number of messages to be logged.
*/
@Test
- public void test() throws Exception {
+ void test() throws Exception {
System.nanoTime();
for (int i = 0; i < 110; i++) {
if (i % 10 == 0) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/CompositeFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/CompositeFilterTest.java
index a7782595620..71b2d99c992 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/CompositeFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/CompositeFilterTest.java
@@ -23,10 +23,10 @@
import org.apache.logging.log4j.core.Filter.Result;
import org.junit.jupiter.api.Test;
-public class CompositeFilterTest {
+class CompositeFilterTest {
@Test
- public void testConcatenation() {
+ void testConcatenation() {
final Filter a = DenyAllFilter.newBuilder().setOnMatch(Result.ACCEPT).build();
final Filter b = DenyAllFilter.newBuilder().setOnMatch(Result.NEUTRAL).build();
final Filter c = DenyAllFilter.newBuilder().setOnMatch(Result.DENY).build();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java
index 469d7167bcb..2bbaa0c5551 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java
@@ -17,6 +17,7 @@
package org.apache.logging.log4j.core.filter;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -35,10 +36,10 @@
import org.junit.jupiter.api.Test;
@UsingThreadContextMap
-public class DynamicThresholdFilterTest {
+class DynamicThresholdFilterTest {
@Test
- public void testFilter() {
+ void testFilter() {
ThreadContext.put("userid", "testuser");
ThreadContext.put("organization", "apache");
final KeyValuePair[] pairs =
@@ -47,8 +48,8 @@ public void testFilter() {
DynamicThresholdFilter.createFilter("userid", pairs, Level.ERROR, null, null);
filter.start();
assertTrue(filter.isStarted());
- assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
- assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.ERROR, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.DEBUG, null, (Object) null, null));
+ assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.ERROR, null, (Object) null, null));
ThreadContext.clearMap();
ThreadContext.put("userid", "JohnDoe");
ThreadContext.put("organization", "apache");
@@ -66,7 +67,7 @@ public void testFilter() {
}
@Test
- public void testFilterWorksWhenParamsArePassedAsArguments() {
+ void testFilterWorksWhenParamsArePassedAsArguments() {
ThreadContext.put("userid", "testuser");
ThreadContext.put("organization", "apache");
final KeyValuePair[] pairs =
@@ -85,10 +86,10 @@ public void testFilterWorksWhenParamsArePassedAsArguments() {
@Test
@LoggerContextSource("log4j2-dynamicfilter.xml")
- public void testConfig(final Configuration config) {
+ void testConfig(final Configuration config) {
final Filter filter = config.getFilter();
assertNotNull(filter, "No DynamicThresholdFilter");
- assertTrue(filter instanceof DynamicThresholdFilter, "Not a DynamicThresholdFilter");
+ assertInstanceOf(DynamicThresholdFilter.class, filter, "Not a DynamicThresholdFilter");
final DynamicThresholdFilter dynamic = (DynamicThresholdFilter) filter;
final String key = dynamic.getKey();
assertNotNull(key, "Key is null");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java
index 68bf0e63d9e..49a4bf9066f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java
@@ -18,6 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -39,10 +40,10 @@
import org.apache.logging.log4j.util.IndexedReadOnlyStringMap;
import org.junit.jupiter.api.Test;
-public class MapFilterTest {
+class MapFilterTest {
@Test
- public void testFilter() {
+ void testFilter() {
final KeyValuePair[] pairs =
new KeyValuePair[] {new KeyValuePair("FromAccount", "211000"), new KeyValuePair("ToAccount", "123456")};
MapFilter filter = MapFilter.createFilter(pairs, "and", null, null);
@@ -71,10 +72,10 @@ public void testFilter() {
@Test
@LoggerContextSource("log4j2-mapfilter.xml")
- public void testConfig(final Configuration config, @Named("LIST") final ListAppender app) {
+ void testConfig(final Configuration config, @Named("LIST") final ListAppender app) {
final Filter filter = config.getFilter();
assertNotNull(filter, "No MapFilter");
- assertTrue(filter instanceof MapFilter, "Not a MapFilter");
+ assertInstanceOf(MapFilter.class, filter, "Not a MapFilter");
final MapFilter mapFilter = (MapFilter) filter;
assertFalse(mapFilter.isAnd(), "Should not be And filter");
final IndexedReadOnlyStringMap map = mapFilter.getStringMap();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java
index aa4864d668a..82812e4da98 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java
@@ -28,10 +28,10 @@
import org.apache.logging.log4j.message.SimpleMessage;
import org.junit.jupiter.api.Test;
-public class MarkerFilterTest {
+class MarkerFilterTest {
@Test
- public void testMarkers() {
+ void testMarkers() {
final Marker parent = MarkerManager.getMarker("Parent");
final Marker child = MarkerManager.getMarker("Child").setParents(parent);
final Marker grandChild = MarkerManager.getMarker("GrandChild").setParents(child);
@@ -40,9 +40,9 @@ public void testMarkers() {
MarkerFilter filter = MarkerFilter.createFilter("Parent", null, null);
filter.start();
assertTrue(filter.isStarted());
- assertSame(Filter.Result.DENY, filter.filter(null, null, stranger, (Object) null, (Throwable) null));
- assertSame(Filter.Result.NEUTRAL, filter.filter(null, null, child, (Object) null, (Throwable) null));
- assertSame(Filter.Result.NEUTRAL, filter.filter(null, null, grandChild, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.DENY, filter.filter(null, null, stranger, (Object) null, null));
+ assertSame(Filter.Result.NEUTRAL, filter.filter(null, null, child, (Object) null, null));
+ assertSame(Filter.Result.NEUTRAL, filter.filter(null, null, grandChild, (Object) null, null));
filter.stop();
LogEvent event = Log4jLogEvent.newBuilder() //
.setMarker(grandChild) //
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/NoMarkerFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/NoMarkerFilterTest.java
index b39dbf1ffa5..cf51067dee4 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/NoMarkerFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/NoMarkerFilterTest.java
@@ -28,16 +28,16 @@
import org.apache.logging.log4j.message.SimpleMessage;
import org.junit.jupiter.api.Test;
-public class NoMarkerFilterTest {
+class NoMarkerFilterTest {
@Test
- public void testMarkers() {
+ void testMarkers() {
final Marker sampleMarker = MarkerManager.getMarker("SampleMarker");
final NoMarkerFilter filter = NoMarkerFilter.newBuilder().build();
filter.start();
assertTrue(filter.isStarted());
- assertSame(Filter.Result.DENY, filter.filter(null, null, sampleMarker, (Object) null, (Throwable) null));
- assertSame(Filter.Result.NEUTRAL, filter.filter(null, null, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.DENY, filter.filter(null, null, sampleMarker, (Object) null, null));
+ assertSame(Filter.Result.NEUTRAL, filter.filter(null, null, null, (Object) null, null));
filter.stop();
LogEvent event = Log4jLogEvent.newBuilder() //
.setLevel(Level.DEBUG) //
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java
index a3e8bf3d025..a71e3dad18d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java
@@ -33,22 +33,20 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-public class RegexFilterTest {
+class RegexFilterTest {
@BeforeAll
- public static void before() {
+ static void before() {
StatusLogger.getLogger().setLevel(Level.OFF);
}
@Test
- public void testThresholds() throws Exception {
+ void testThresholds() throws Exception {
RegexFilter filter = RegexFilter.createFilter(".* test .*", null, false, null, null);
filter.start();
assertTrue(filter.isStarted());
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(null, Level.DEBUG, null, (Object) "This is a test message", (Throwable) null));
- assertSame(Filter.Result.DENY, filter.filter(null, Level.ERROR, null, (Object) "This is not a test", (Throwable)
- null));
+ Filter.Result.NEUTRAL, filter.filter(null, Level.DEBUG, null, (Object) "This is a test message", null));
+ assertSame(Filter.Result.DENY, filter.filter(null, Level.ERROR, null, (Object) "This is not a test", null));
LogEvent event = Log4jLogEvent.newBuilder() //
.setLevel(Level.DEBUG) //
.setMessage(new SimpleMessage("Another test message")) //
@@ -64,29 +62,29 @@ public void testThresholds() throws Exception {
}
@Test
- public void testDotAllPattern() throws Exception {
+ void testDotAllPattern() throws Exception {
final String singleLine = "test single line matches";
final String multiLine = "test multi line matches\nsome more lines";
final RegexFilter filter = RegexFilter.createFilter(
".*line.*", new String[] {"DOTALL", "COMMENTS"}, false, Filter.Result.DENY, Filter.Result.ACCEPT);
- final Result singleLineResult = filter.filter(null, null, null, (Object) singleLine, (Throwable) null);
- final Result multiLineResult = filter.filter(null, null, null, (Object) multiLine, (Throwable) null);
+ final Result singleLineResult = filter.filter(null, null, null, (Object) singleLine, null);
+ final Result multiLineResult = filter.filter(null, null, null, (Object) multiLine, null);
assertThat(singleLineResult, equalTo(Result.DENY));
assertThat(multiLineResult, equalTo(Result.DENY));
}
@Test
- public void testNoMsg() throws Exception {
+ void testNoMsg() throws Exception {
final RegexFilter filter = RegexFilter.createFilter(".* test .*", null, false, null, null);
filter.start();
assertTrue(filter.isStarted());
- assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
- assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Message) null, (Throwable) null));
+ assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, null));
+ assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Message) null, null));
assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, null, (Object[]) null));
}
@Test
- public void testParameterizedMsg() throws Exception {
+ void testParameterizedMsg() throws Exception {
final String msg = "params {} {}";
final Object[] params = {"foo", "bar"};
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/StringMatchFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/StringMatchFilterTest.java
index 3479975ae65..c95f607347f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/StringMatchFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/StringMatchFilterTest.java
@@ -20,25 +20,25 @@
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* Unit test for {@link StringMatchFilter}.
*/
-public class StringMatchFilterTest {
+class StringMatchFilterTest {
/**
* Test that if no match-string is set on the builder, the '{@link StringMatchFilter.Builder#build()}' returns
* {@code null}.
*/
@Test
- public void testFilterBuilderFailsWithNullText() {
- Assertions.assertNull(StringMatchFilter.newBuilder().build());
+ void testFilterBuilderFailsWithNullText() {
+ assertNull(StringMatchFilter.newBuilder().build());
}
/**
@@ -46,7 +46,7 @@ public void testFilterBuilderFailsWithNullText() {
*/
@Test
void testFilterBuilderFailsWithExceptionOnNullText() {
- Assertions.assertThrows(IllegalArgumentException.class, () -> StringMatchFilter.newBuilder()
+ assertThrows(IllegalArgumentException.class, () -> StringMatchFilter.newBuilder()
.setText(null));
}
@@ -55,7 +55,7 @@ void testFilterBuilderFailsWithExceptionOnNullText() {
*/
@Test
void testFilterBuilderFailsWithExceptionOnEmptyText() {
- Assertions.assertThrows(IllegalArgumentException.class, () -> StringMatchFilter.newBuilder()
+ assertThrows(IllegalArgumentException.class, () -> StringMatchFilter.newBuilder()
.setText(""));
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/StructuredDataFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/StructuredDataFilterTest.java
index 35388d17e76..5e33aaf8b36 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/StructuredDataFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/StructuredDataFilterTest.java
@@ -18,6 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -32,10 +33,10 @@
import org.apache.logging.log4j.util.IndexedReadOnlyStringMap;
import org.junit.jupiter.api.Test;
-public class StructuredDataFilterTest {
+class StructuredDataFilterTest {
@Test
- public void testFilter() {
+ void testFilter() {
final KeyValuePair[] pairs = new KeyValuePair[] {
new KeyValuePair("id.name", "AccountTransfer"), new KeyValuePair("ToAccount", "123456")
};
@@ -65,10 +66,10 @@ public void testFilter() {
@Test
@LoggerContextSource("log4j2-sdfilter.xml")
- public void testConfig(final Configuration config) {
+ void testConfig(final Configuration config) {
final Filter filter = config.getFilter();
assertNotNull(filter, "No StructuredDataFilter");
- assertTrue(filter instanceof StructuredDataFilter, "Not a StructuredDataFilter");
+ assertInstanceOf(StructuredDataFilter.class, filter, "Not a StructuredDataFilter");
final StructuredDataFilter sdFilter = (StructuredDataFilter) filter;
assertFalse(sdFilter.isAnd(), "Should not be And filter");
final IndexedReadOnlyStringMap map = sdFilter.getStringMap();
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java
index 5858c7013f1..fed69b81d47 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java
@@ -26,10 +26,10 @@
import org.apache.logging.log4j.core.util.KeyValuePair;
import org.junit.jupiter.api.Test;
-public class ThreadContextMapFilterTest {
+class ThreadContextMapFilterTest {
@Test
- public void testFilter() {
+ void testFilter() {
ThreadContext.put("userid", "testuser");
ThreadContext.put("organization", "Apache");
final KeyValuePair[] pairs =
@@ -38,13 +38,13 @@ public void testFilter() {
assertNotNull(filter);
filter.start();
assertTrue(filter.isStarted());
- assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, null));
ThreadContext.remove("userid");
- assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, null));
ThreadContext.put("userid", "JohnDoe");
- assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.ERROR, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.ERROR, null, (Object) null, null));
ThreadContext.put("organization", "ASF");
- assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, null));
ThreadContext.clearMap();
filter = ThreadContextMapFilter.createFilter(pairs, "or", null, null);
assertNotNull(filter);
@@ -52,17 +52,17 @@ public void testFilter() {
assertTrue(filter.isStarted());
ThreadContext.put("userid", "testuser");
ThreadContext.put("organization", "Apache");
- assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.DEBUG, null, (Object) null, null));
ThreadContext.put("organization", "ASF");
- assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, null));
ThreadContext.remove("organization");
- assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, null));
final KeyValuePair[] single = new KeyValuePair[] {new KeyValuePair("userid", "testuser")};
filter = ThreadContextMapFilter.createFilter(single, null, null, null);
assertNotNull(filter);
filter.start();
assertTrue(filter.isStarted());
- assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.DEBUG, null, (Object) null, null));
ThreadContext.clearMap();
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/ThresholdFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/ThresholdFilterTest.java
index d9e3f6800aa..0b956bc1a59 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/ThresholdFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/ThresholdFilterTest.java
@@ -26,15 +26,15 @@
import org.apache.logging.log4j.message.SimpleMessage;
import org.junit.jupiter.api.Test;
-public class ThresholdFilterTest {
+class ThresholdFilterTest {
@Test
- public void testThresholds() {
+ void testThresholds() {
final ThresholdFilter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
filter.start();
assertTrue(filter.isStarted());
- assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
- assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.ERROR, null, (Object) null, (Throwable) null));
+ assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, null));
+ assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.ERROR, null, (Object) null, null));
LogEvent event = Log4jLogEvent.newBuilder() //
.setLevel(Level.DEBUG) //
.setMessage(new SimpleMessage("Test")) //
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/TimeFilterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/TimeFilterTest.java
index a3b0bec0782..643d69355c9 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/TimeFilterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/filter/TimeFilterTest.java
@@ -35,7 +35,7 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-public class TimeFilterTest {
+class TimeFilterTest {
private static long CLOCKTIME = System.currentTimeMillis();
/** Helper class */
@@ -47,17 +47,17 @@ public long currentTimeMillis() {
}
@BeforeAll
- public static void beforeClass() {
+ static void beforeClass() {
System.setProperty(ClockFactory.PROPERTY_NAME, FixedTimeClock.class.getName());
}
@AfterAll
- public static void afterClass() throws IllegalAccessException {
+ static void afterClass() throws IllegalAccessException {
ClockFactoryTest.resetClocks();
}
@Test
- public void springForward() {
+ void springForward() {
final TimeFilter filter = new TimeFilter(
LocalTime.of(2, 0),
LocalTime.of(3, 0),
@@ -71,27 +71,20 @@ public void springForward() {
CLOCKTIME = date.toInstant().toEpochMilli();
LogEvent event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
date = date.plusDays(1).withHour(2);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
date = date.withHour(4);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
- assertSame(
- Filter.Result.DENY,
- filter.filter(event),
- "Time " + CLOCKTIME + " is within range: " + filter.toString());
+ assertSame(Filter.Result.DENY, filter.filter(event), "Time " + CLOCKTIME + " is within range: " + filter);
}
@Test
- public void fallBack() {
+ void fallBack() {
final TimeFilter filter = new TimeFilter(
LocalTime.of(1, 0),
LocalTime.of(2, 0),
@@ -106,35 +99,25 @@ public void fallBack() {
CLOCKTIME = date.toInstant().toEpochMilli();
LogEvent event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
date = ZonedDateTime.of(2020, 11, 1, 1, 6, 30, 0, ZoneId.of("America/Los_Angeles"))
.withLaterOffsetAtOverlap();
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
- assertSame(
- Filter.Result.DENY,
- filter.filter(event),
- "Time " + CLOCKTIME + " is within range: " + filter.toString());
+ assertSame(Filter.Result.DENY, filter.filter(event), "Time " + CLOCKTIME + " is within range: " + filter);
date = date.plusDays(1).withHour(1).withMinute(30);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
date = date.withHour(4);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
- assertSame(
- Filter.Result.DENY,
- filter.filter(event),
- "Time " + CLOCKTIME + " is within range: " + filter.toString());
+ assertSame(Filter.Result.DENY, filter.filter(event), "Time " + CLOCKTIME + " is within range: " + filter);
}
@Test
- public void overnight() {
+ void overnight() {
final TimeFilter filter = new TimeFilter(
LocalTime.of(23, 0),
LocalTime.of(1, 0),
@@ -149,34 +132,25 @@ public void overnight() {
CLOCKTIME = date.toInstant().toEpochMilli();
LogEvent event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
date = date.plusHours(1);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
date = date.plusHours(1);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
- assertSame(
- Filter.Result.DENY,
- filter.filter(event),
- "Time " + CLOCKTIME + " is within range: " + filter.toString());
+ assertSame(Filter.Result.DENY, filter.filter(event), "Time " + CLOCKTIME + " is within range: " + filter);
date = date.plusDays(1).withHour(0);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
}
@Test
- public void overnightForward() {
+ void overnightForward() {
final TimeFilter filter = new TimeFilter(
LocalTime.of(23, 0),
LocalTime.of(2, 0),
@@ -191,34 +165,25 @@ public void overnightForward() {
CLOCKTIME = date.toInstant().toEpochMilli();
LogEvent event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
date = date.plusHours(1);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
date = date.plusHours(2);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
- assertSame(
- Filter.Result.DENY,
- filter.filter(event),
- "Time " + CLOCKTIME + " is within range: " + filter.toString());
+ assertSame(Filter.Result.DENY, filter.filter(event), "Time " + CLOCKTIME + " is within range: " + filter);
date = date.plusDays(1).withHour(0);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
}
@Test
- public void overnightFallback() {
+ void overnightFallback() {
final TimeFilter filter = new TimeFilter(
LocalTime.of(23, 0),
LocalTime.of(2, 0),
@@ -233,34 +198,25 @@ public void overnightFallback() {
CLOCKTIME = date.toInstant().toEpochMilli();
LogEvent event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
date = date.plusHours(1);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
date = date.plusHours(2);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
- assertSame(
- Filter.Result.DENY,
- filter.filter(event),
- "Time " + CLOCKTIME + " is within range: " + filter.toString());
+ assertSame(Filter.Result.DENY, filter.filter(event), "Time " + CLOCKTIME + " is within range: " + filter);
date = date.plusDays(1).withHour(0);
CLOCKTIME = date.toInstant().toEpochMilli();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
}
@Test
- public void testTime() {
+ void testTime() {
// https://garygregory.wordpress.com/2013/06/18/what-are-the-java-timezone-ids/
final TimeFilter filter = TimeFilter.createFilter("02:00:00", "03:00:00", "America/Los_Angeles", null, null);
filter.start();
@@ -271,27 +227,20 @@ public void testTime() {
LogEvent event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
// assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.ERROR, null, (Object) null, (Throwable) null));
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
cal.add(Calendar.DATE, 1);
cal.set(Calendar.HOUR_OF_DAY, 2);
CLOCKTIME = cal.getTimeInMillis();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
assertSame(
- Filter.Result.NEUTRAL,
- filter.filter(event),
- "Time " + CLOCKTIME + " is not within range: " + filter.toString());
+ Filter.Result.NEUTRAL, filter.filter(event), "Time " + CLOCKTIME + " is not within range: " + filter);
// assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.ERROR, null, (Object) null, (Throwable) null));
cal.set(Calendar.HOUR_OF_DAY, 4);
CLOCKTIME = cal.getTimeInMillis();
event = Log4jLogEvent.newBuilder().setTimeMillis(CLOCKTIME).build();
// assertSame(Filter.Result.DENY, filter.filter(null, Level.ERROR, null, (Object) null, (Throwable) null));
- assertSame(
- Filter.Result.DENY,
- filter.filter(event),
- "Time " + CLOCKTIME + " is within range: " + filter.toString());
+ assertSame(Filter.Result.DENY, filter.filter(event), "Time " + CLOCKTIME + " is within range: " + filter);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetMissingConstructorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetMissingConstructorTest.java
index e54cff6997d..5ed076bd85a 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetMissingConstructorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetMissingConstructorTest.java
@@ -17,7 +17,7 @@
package org.apache.logging.log4j.core.impl;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import java.lang.reflect.Field;
import org.apache.logging.log4j.util.SortedArrayStringMap;
@@ -26,12 +26,12 @@
/**
* Tests the ContextDataFactory class.
*/
-public class ContextDataFactoryPropertySetMissingConstructorTest {
+class ContextDataFactoryPropertySetMissingConstructorTest {
@Test
- public void intArgReturnsSortedArrayStringMapIfPropertySpecifiedButMissingIntConstructor() throws Exception {
+ void intArgReturnsSortedArrayStringMapIfPropertySpecifiedButMissingIntConstructor() throws Exception {
System.setProperty("log4j2.ContextData", FactoryTestStringMapWithoutIntConstructor.class.getName());
- assertTrue(ContextDataFactory.createContextData(2) instanceof SortedArrayStringMap);
+ assertInstanceOf(SortedArrayStringMap.class, ContextDataFactory.createContextData(2));
final SortedArrayStringMap actual = (SortedArrayStringMap) ContextDataFactory.createContextData(2);
final Field thresholdField = SortedArrayStringMap.class.getDeclaredField("threshold");
thresholdField.setAccessible(true);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetTest.java
index b22e54a38c6..03d8f46dae0 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetTest.java
@@ -17,31 +17,31 @@
package org.apache.logging.log4j.core.impl;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import org.junit.jupiter.api.Test;
/**
* Tests the ContextDataFactory class.
*/
-public class ContextDataFactoryPropertySetTest {
+class ContextDataFactoryPropertySetTest {
@Test
- public void noArgReturnsSpecifiedImplIfPropertySpecified() throws Exception {
+ void noArgReturnsSpecifiedImplIfPropertySpecified() {
System.setProperty("log4j2.ContextData", FactoryTestStringMap.class.getName());
- assertTrue(ContextDataFactory.createContextData() instanceof FactoryTestStringMap);
+ assertInstanceOf(FactoryTestStringMap.class, ContextDataFactory.createContextData());
System.clearProperty("log4j2.ContextData");
}
@Test
- public void intArgReturnsSpecifiedImplIfPropertySpecified() throws Exception {
+ void intArgReturnsSpecifiedImplIfPropertySpecified() {
System.setProperty("log4j2.ContextData", FactoryTestStringMap.class.getName());
- assertTrue(ContextDataFactory.createContextData(2) instanceof FactoryTestStringMap);
+ assertInstanceOf(FactoryTestStringMap.class, ContextDataFactory.createContextData(2));
System.clearProperty("log4j2.ContextData");
}
@Test
- public void intArgSetsCapacityIfPropertySpecified() throws Exception {
+ void intArgSetsCapacityIfPropertySpecified() {
System.setProperty("log4j2.ContextData", FactoryTestStringMap.class.getName());
final FactoryTestStringMap actual = (FactoryTestStringMap) ContextDataFactory.createContextData(2);
assertEquals(2, actual.initialCapacity);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryTest.java
index 828d51b9d17..c14ba5070ec 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryTest.java
@@ -17,7 +17,7 @@
package org.apache.logging.log4j.core.impl;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import java.lang.reflect.Field;
import org.apache.logging.log4j.util.SortedArrayStringMap;
@@ -26,19 +26,19 @@
/**
* Tests the ContextDataFactory class.
*/
-public class ContextDataFactoryTest {
+class ContextDataFactoryTest {
@Test
- public void noArgReturnsSortedArrayStringMapIfNoPropertySpecified() throws Exception {
- assertTrue(ContextDataFactory.createContextData() instanceof SortedArrayStringMap);
+ void noArgReturnsSortedArrayStringMapIfNoPropertySpecified() {
+ assertInstanceOf(SortedArrayStringMap.class, ContextDataFactory.createContextData());
}
@Test
- public void intArgReturnsSortedArrayStringMapIfNoPropertySpecified() throws Exception {
- assertTrue(ContextDataFactory.createContextData(2) instanceof SortedArrayStringMap);
+ void intArgReturnsSortedArrayStringMapIfNoPropertySpecified() {
+ assertInstanceOf(SortedArrayStringMap.class, ContextDataFactory.createContextData(2));
}
@Test
- public void intArgSetsCapacityIfNoPropertySpecified() throws Exception {
+ void intArgSetsCapacityIfNoPropertySpecified() throws Exception {
final SortedArrayStringMap actual = (SortedArrayStringMap) ContextDataFactory.createContextData(2);
final Field thresholdField = SortedArrayStringMap.class.getDeclaredField("threshold");
thresholdField.setAccessible(true);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/JdkMapAdapterStringMapTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/JdkMapAdapterStringMapTest.java
index 81ff33dd260..7b06a23a32e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/JdkMapAdapterStringMapTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/JdkMapAdapterStringMapTest.java
@@ -44,15 +44,15 @@
/**
* Tests the JdkMapAdapterStringMap class.
*/
-public class JdkMapAdapterStringMapTest {
+class JdkMapAdapterStringMapTest {
@Test
- public void testConstructorDisallowsNull() {
+ void testConstructorDisallowsNull() {
assertThrows(NullPointerException.class, () -> new JdkMapAdapterStringMap(null, false));
}
@Test
- public void testToString() {
+ void testToString() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("a2", "bvalue");
@@ -63,7 +63,7 @@ public void testToString() {
}
@Test
- public void testSerialization() throws Exception {
+ void testSerialization() throws Exception {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("B", "Bvalue");
@@ -89,7 +89,7 @@ private JdkMapAdapterStringMap deserialize(final byte[] binary) throws IOExcepti
}
@Test
- public void testPutAll() throws Exception {
+ void testPutAll() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("B", "Bvalue");
@@ -110,7 +110,7 @@ public void testPutAll() throws Exception {
}
@Test
- public void testPutAll_overwritesSameKeys2() throws Exception {
+ void testPutAll_overwritesSameKeys2() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aORIG");
original.putValue("b", "bORIG");
@@ -136,7 +136,7 @@ public void testPutAll_overwritesSameKeys2() throws Exception {
}
@Test
- public void testPutAll_nullKeyInLargeOriginal() throws Exception {
+ void testPutAll_nullKeyInLargeOriginal() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue(null, "nullORIG");
original.putValue("a", "aORIG");
@@ -161,7 +161,7 @@ public void testPutAll_nullKeyInLargeOriginal() throws Exception {
}
@Test
- public void testPutAll_nullKeyInSmallOriginal() throws Exception {
+ void testPutAll_nullKeyInSmallOriginal() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue(null, "nullORIG");
original.putValue("a", "aORIG");
@@ -184,7 +184,7 @@ public void testPutAll_nullKeyInSmallOriginal() throws Exception {
}
@Test
- public void testPutAll_nullKeyInSmallAdditional() throws Exception {
+ void testPutAll_nullKeyInSmallAdditional() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aORIG");
original.putValue("b", "bORIG");
@@ -209,7 +209,7 @@ public void testPutAll_nullKeyInSmallAdditional() throws Exception {
}
@Test
- public void testPutAll_nullKeyInLargeAdditional() throws Exception {
+ void testPutAll_nullKeyInLargeAdditional() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aORIG");
original.putValue("b", "bORIG");
@@ -232,7 +232,7 @@ public void testPutAll_nullKeyInLargeAdditional() throws Exception {
}
@Test
- public void testPutAll_nullKeyInBoth_LargeOriginal() throws Exception {
+ void testPutAll_nullKeyInBoth_LargeOriginal() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue(null, "nullORIG");
original.putValue("a", "aORIG");
@@ -258,7 +258,7 @@ public void testPutAll_nullKeyInBoth_LargeOriginal() throws Exception {
}
@Test
- public void testPutAll_nullKeyInBoth_SmallOriginal() throws Exception {
+ void testPutAll_nullKeyInBoth_SmallOriginal() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue(null, "nullORIG");
original.putValue("a", "aORIG");
@@ -282,7 +282,7 @@ public void testPutAll_nullKeyInBoth_SmallOriginal() throws Exception {
}
@Test
- public void testPutAll_overwritesSameKeys1() throws Exception {
+ void testPutAll_overwritesSameKeys1() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aORIG");
original.putValue("b", "bORIG");
@@ -304,7 +304,7 @@ public void testPutAll_overwritesSameKeys1() throws Exception {
}
@Test
- public void testEquals() {
+ void testEquals() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("B", "Bvalue");
@@ -332,7 +332,7 @@ public void testEquals() {
}
@Test
- public void testToMap() throws Exception {
+ void testToMap() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("B", "Bvalue");
@@ -353,7 +353,7 @@ public void testToMap() throws Exception {
}
@Test
- public void testPutAll_KeepsExistingValues() {
+ void testPutAll_KeepsExistingValues() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "bbb");
@@ -383,7 +383,7 @@ public void testPutAll_KeepsExistingValues() {
}
@Test
- public void testPutAll_sizePowerOfTwo() {
+ void testPutAll_sizePowerOfTwo() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "bbb");
@@ -418,7 +418,7 @@ public void testPutAll_sizePowerOfTwo() {
}
@Test
- public void testPutAll_largeAddition() {
+ void testPutAll_largeAddition() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue(null, "nullVal");
original.putValue("a", "aaa");
@@ -446,7 +446,7 @@ public void testPutAll_largeAddition() {
}
@Test
- public void testPutAllSelfDoesNotModify() {
+ void testPutAllSelfDoesNotModify() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "bbb");
@@ -462,7 +462,7 @@ public void testPutAllSelfDoesNotModify() {
}
@Test
- public void testNoConcurrentModificationBiConsumerPut() {
+ void testNoConcurrentModificationBiConsumerPut() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "aaa");
@@ -473,7 +473,7 @@ public void testNoConcurrentModificationBiConsumerPut() {
}
@Test
- public void testNoConcurrentModificationBiConsumerPutValue() {
+ void testNoConcurrentModificationBiConsumerPutValue() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "aaa");
@@ -484,7 +484,7 @@ public void testNoConcurrentModificationBiConsumerPutValue() {
}
@Test
- public void testNoConcurrentModificationBiConsumerRemove() {
+ void testNoConcurrentModificationBiConsumerRemove() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "aaa");
@@ -493,7 +493,7 @@ public void testNoConcurrentModificationBiConsumerRemove() {
}
@Test
- public void testNoConcurrentModificationBiConsumerClear() {
+ void testNoConcurrentModificationBiConsumerClear() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "aaa");
@@ -504,7 +504,7 @@ public void testNoConcurrentModificationBiConsumerClear() {
}
@Test
- public void testNoConcurrentModificationTriConsumerPut() {
+ void testNoConcurrentModificationTriConsumerPut() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "aaa");
@@ -514,7 +514,7 @@ public void testNoConcurrentModificationTriConsumerPut() {
}
@Test
- public void testNoConcurrentModificationTriConsumerPutValue() {
+ void testNoConcurrentModificationTriConsumerPutValue() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "aaa");
@@ -525,7 +525,7 @@ public void testNoConcurrentModificationTriConsumerPutValue() {
}
@Test
- public void testNoConcurrentModificationTriConsumerRemove() {
+ void testNoConcurrentModificationTriConsumerRemove() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "aaa");
@@ -534,7 +534,7 @@ public void testNoConcurrentModificationTriConsumerRemove() {
}
@Test
- public void testNoConcurrentModificationTriConsumerClear() {
+ void testNoConcurrentModificationTriConsumerClear() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.putValue("b", "aaa");
@@ -544,12 +544,12 @@ public void testNoConcurrentModificationTriConsumerClear() {
}
@Test
- public void testInitiallyNotFrozen() {
+ void testInitiallyNotFrozen() {
assertFalse(new JdkMapAdapterStringMap().isFrozen());
}
@Test
- public void testIsFrozenAfterCallingFreeze() {
+ void testIsFrozenAfterCallingFreeze() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
assertFalse(original.isFrozen(), "before freeze");
original.freeze();
@@ -557,14 +557,14 @@ public void testIsFrozenAfterCallingFreeze() {
}
@Test
- public void testFreezeProhibitsPutValue() {
+ void testFreezeProhibitsPutValue() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.freeze();
assertThrows(UnsupportedOperationException.class, () -> original.putValue("a", "aaa"));
}
@Test
- public void testFreezeProhibitsRemove() {
+ void testFreezeProhibitsRemove() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("b", "bbb");
original.freeze();
@@ -574,7 +574,7 @@ public void testFreezeProhibitsRemove() {
}
@Test
- public void testFreezeAllowsRemoveOfNonExistingKey() {
+ void testFreezeAllowsRemoveOfNonExistingKey() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("b", "bbb");
original.freeze();
@@ -582,14 +582,14 @@ public void testFreezeAllowsRemoveOfNonExistingKey() {
}
@Test
- public void testFreezeAllowsRemoveIfEmpty() {
+ void testFreezeAllowsRemoveIfEmpty() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.freeze();
original.remove("a"); // no exception
}
@Test
- public void testFreezeProhibitsClear() {
+ void testFreezeProhibitsClear() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "aaa");
original.freeze();
@@ -597,14 +597,14 @@ public void testFreezeProhibitsClear() {
}
@Test
- public void testFreezeAllowsClearIfEmpty() {
+ void testFreezeAllowsClearIfEmpty() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.freeze();
original.clear();
}
@Test
- public void testNullKeysAllowed() {
+ void testNullKeysAllowed() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("B", "Bvalue");
@@ -631,7 +631,7 @@ public void testNullKeysAllowed() {
}
@Test
- public void testNullKeysCopiedToAsMap() {
+ void testNullKeysCopiedToAsMap() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("B", "Bvalue");
@@ -670,7 +670,7 @@ public void testNullKeysCopiedToAsMap() {
}
@Test
- public void testRemove() {
+ void testRemove() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
assertEquals(1, original.size());
@@ -686,7 +686,7 @@ public void testRemove() {
}
@Test
- public void testRemoveWhenFull() throws Exception {
+ void testRemoveWhenFull() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("b", "bvalue");
@@ -696,7 +696,7 @@ public void testRemoveWhenFull() throws Exception {
}
@Test
- public void testNullValuesArePreserved() {
+ void testNullValuesArePreserved() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
assertEquals(1, original.size());
@@ -712,7 +712,7 @@ public void testNullValuesArePreserved() {
}
@Test
- public void testGet() throws Exception {
+ void testGet() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("B", "Bvalue");
@@ -730,7 +730,7 @@ public void testGet() throws Exception {
}
@Test
- public void testClear() throws Exception {
+ void testClear() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("B", "Bvalue");
@@ -742,7 +742,7 @@ public void testClear() throws Exception {
}
@Test
- public void testContainsKey() throws Exception {
+ void testContainsKey() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
assertFalse(original.containsKey("a"), "a");
assertFalse(original.containsKey("B"), "B");
@@ -775,7 +775,7 @@ public void testContainsKey() throws Exception {
}
@Test
- public void testSizeAndIsEmpty() throws Exception {
+ void testSizeAndIsEmpty() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
assertEquals(0, original.size());
assertTrue(original.isEmpty(), "initial");
@@ -806,7 +806,7 @@ public void testSizeAndIsEmpty() throws Exception {
}
@Test
- public void testForEachBiConsumer() throws Exception {
+ void testForEachBiConsumer() throws Exception {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("B", "Bvalue");
@@ -838,7 +838,7 @@ static class State {
};
@Test
- public void testForEachTriConsumer() throws Exception {
+ void testForEachTriConsumer() {
final JdkMapAdapterStringMap original = new JdkMapAdapterStringMap();
original.putValue("a", "avalue");
original.putValue("B", "Bvalue");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java
index 7c7efd7ba8e..82c091336ea 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java
@@ -17,6 +17,7 @@
package org.apache.logging.log4j.core.impl;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -38,32 +39,32 @@
import org.junit.jupiter.api.Test;
@Tag("functional")
-public class Log4jLogEventNanoTimeTest {
+class Log4jLogEventNanoTimeTest {
@BeforeAll
- public static void beforeClass() {
+ static void beforeClass() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "NanoTimeToFileTest.xml");
}
@AfterAll
- public static void afterClass() {
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testLog4jLogEventUsesNanoTimeClock() throws Exception {
+ void testLog4jLogEventUsesNanoTimeClock() throws Exception {
final File file = new File("target", "NanoTimeToFileTest.log");
// System.out.println(f.getAbsolutePath());
file.delete();
final Logger log = LogManager.getLogger("com.foo.Bar");
final long before = System.nanoTime();
log.info("Use actual System.nanoTime()");
- assertTrue(Log4jLogEvent.getNanoClock() instanceof SystemNanoClock, "using SystemNanoClock");
+ assertInstanceOf(SystemNanoClock.class, Log4jLogEvent.getNanoClock(), "using SystemNanoClock");
final long DUMMYNANOTIME = 123;
Log4jLogEvent.setNanoClock(new DummyNanoClock(DUMMYNANOTIME));
log.info("Use dummy nano clock");
- assertTrue(Log4jLogEvent.getNanoClock() instanceof DummyNanoClock, "using SystemNanoClock");
+ assertInstanceOf(DummyNanoClock.class, Log4jLogEvent.getNanoClock(), "using SystemNanoClock");
CoreLoggerContexts.stopLoggerContext(file); // stop async thread
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventTest.java
index 119e3dd1ccc..bc90e594d28 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventTest.java
@@ -20,6 +20,7 @@
import static org.apache.logging.log4j.test.junit.SerialUtil.serialize;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -69,23 +70,23 @@ public long currentTimeMillis() {
}
@BeforeAll
- public static void beforeClass() {
+ static void beforeClass() {
System.setProperty(ClockFactory.PROPERTY_NAME, FixedTimeClock.class.getName());
}
@AfterAll
- public static void afterClass() throws IllegalAccessException {
+ static void afterClass() throws IllegalAccessException {
ClockFactoryTest.resetClocks();
}
@Test
- public void testToImmutableSame() {
+ void testToImmutableSame() {
final LogEvent logEvent = new Log4jLogEvent();
assertSame(logEvent, logEvent.toImmutable());
}
@Test
- public void testToImmutableNotSame() {
+ void testToImmutableNotSame() {
final LogEvent logEvent = new Log4jLogEvent.Builder()
.setMessage(new ReusableObjectMessage())
.build();
@@ -95,7 +96,7 @@ public void testToImmutableNotSame() {
}
@Test
- public void testJavaIoSerializable() throws Exception {
+ void testJavaIoSerializable() {
final Log4jLogEvent evt = Log4jLogEvent.newBuilder() //
.setLoggerName("some.test") //
.setLoggerFqcn(Strings.EMPTY) //
@@ -123,7 +124,7 @@ public void testJavaIoSerializable() throws Exception {
}
@Test
- public void testJavaIoSerializableWithThrown() throws Exception {
+ void testJavaIoSerializableWithThrown() {
final Error thrown = new InternalError("test error");
final Log4jLogEvent evt = Log4jLogEvent.newBuilder() //
.setLoggerName("some.test") //
@@ -164,7 +165,7 @@ public void testJavaIoSerializableWithThrown() throws Exception {
// };
@Test
- public void testJavaIoSerializableWithUnknownThrowable() throws Exception {
+ void testJavaIoSerializableWithUnknownThrowable() {
final String loggerName = "some.test";
final Marker marker = null;
final String loggerFQN = Strings.EMPTY;
@@ -202,7 +203,7 @@ public void testJavaIoSerializableWithUnknownThrowable() throws Exception {
}
@Test
- public void testNullLevelReplacedWithOFF() throws Exception {
+ void testNullLevelReplacedWithOFF() {
final Level NULL_LEVEL = null;
final Log4jLogEvent evt =
Log4jLogEvent.newBuilder().setLevel(NULL_LEVEL).build();
@@ -210,19 +211,19 @@ public void testNullLevelReplacedWithOFF() throws Exception {
}
@Test
- public void testTimestampGeneratedByClock() {
+ void testTimestampGeneratedByClock() {
final LogEvent evt = Log4jLogEvent.newBuilder().build();
assertEquals(FixedTimeClock.FIXED_TIME, evt.getTimeMillis());
}
@Test
- public void testInitiallyDummyNanoClock() {
- assertTrue(Log4jLogEvent.getNanoClock() instanceof DummyNanoClock);
+ void testInitiallyDummyNanoClock() {
+ assertInstanceOf(DummyNanoClock.class, Log4jLogEvent.getNanoClock());
assertEquals(0, Log4jLogEvent.getNanoClock().nanoTime(), "initial dummy nanotime");
}
@Test
- public void testNanoTimeGeneratedByNanoClock() {
+ void testNanoTimeGeneratedByNanoClock() {
Log4jLogEvent.setNanoClock(new DummyNanoClock(123));
verifyNanoTimeWithAllConstructors(123);
Log4jLogEvent.setNanoClock(new DummyNanoClock(87654));
@@ -251,7 +252,7 @@ private void verifyNanoTimeWithAllConstructors(final long expected) {
@SuppressWarnings("deprecation")
@Test
- public void testBuilderCorrectlyCopiesAllEventAttributes() {
+ void testBuilderCorrectlyCopiesAllEventAttributes() {
final StringMap contextData = ContextDataFactory.createContextData();
contextData.putValue("A", "B");
final ContextStack contextStack = ThreadContext.getImmutableStack();
@@ -300,7 +301,7 @@ public void testBuilderCorrectlyCopiesAllEventAttributes() {
}
@Test
- public void testBuilderCorrectlyCopiesAllEventAttributesInclContextData() {
+ void testBuilderCorrectlyCopiesAllEventAttributesInclContextData() {
final StringMap contextData = new SortedArrayStringMap();
contextData.putValue("A", "B");
final ContextStack contextStack = ThreadContext.getImmutableStack();
@@ -349,7 +350,7 @@ public void testBuilderCorrectlyCopiesAllEventAttributesInclContextData() {
}
@Test
- public void testBuilderCorrectlyCopiesMutableLogEvent() throws Exception {
+ void testBuilderCorrectlyCopiesMutableLogEvent() throws Exception {
final StringMap contextData = new SortedArrayStringMap();
contextData.putValue("A", "B");
final ContextStack contextStack = ThreadContext.getImmutableStack();
@@ -417,7 +418,7 @@ public void testBuilderCorrectlyCopiesMutableLogEvent() throws Exception {
@SuppressWarnings("deprecation")
@Test
- public void testEquals() {
+ void testEquals() {
final StringMap contextData = ContextDataFactory.createContextData();
contextData.putValue("A", "B");
ThreadContext.push("first");
@@ -536,7 +537,7 @@ private void different(final String reason, final Log4jLogEvent.Builder builder,
}
@Test
- public void testToString() {
+ void testToString() {
// Throws an NPE in 2.6.2
assertNotNull(new Log4jLogEvent().toString());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
index 0723d6ff735..7f4ebd2d4bb 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
@@ -47,7 +47,7 @@
/**
* Tests the MutableLogEvent class.
*/
-public class MutableLogEventTest {
+class MutableLogEventTest {
private static final StringMap CONTEXT_DATA = createContextData();
private static final ThreadContext.ContextStack STACK = new MutableThreadContextStack(Arrays.asList("abc", "xyz"));
@@ -59,13 +59,13 @@ private static StringMap createContextData() {
}
@Test
- public void testToImmutable() {
+ void testToImmutable() {
final LogEvent logEvent = new MutableLogEvent();
assertNotSame(logEvent, logEvent.toImmutable());
}
@Test
- public void testInitFromCopiesAllFields() {
+ void testInitFromCopiesAllFields() {
// private ThrowableProxy thrownProxy;
final Log4jLogEvent source = Log4jLogEvent.newBuilder() //
.setContextData(CONTEXT_DATA) //
@@ -107,7 +107,7 @@ public void testInitFromCopiesAllFields() {
}
@Test
- public void testInitFromReusableCopiesFormatString() {
+ void testInitFromReusableCopiesFormatString() {
final Message message = ReusableMessageFactory.INSTANCE.newMessage("msg in a {}", "bottle");
final Log4jLogEvent source = Log4jLogEvent.newBuilder() //
.setContextData(CONTEXT_DATA) //
@@ -150,7 +150,7 @@ public void testInitFromReusableCopiesFormatString() {
}
@Test
- public void testInitFromReusableObjectCopiesParameter() {
+ void testInitFromReusableObjectCopiesParameter() {
final Object param = new Object();
final Message message = ReusableMessageFactory.INSTANCE.newMessage(param);
final Log4jLogEvent source = Log4jLogEvent.newBuilder()
@@ -183,7 +183,7 @@ public void testInitFromReusableObjectCopiesParameter() {
}
@Test
- public void testClear() {
+ void testClear() {
final MutableLogEvent mutable = new MutableLogEvent();
// initialize the event with an empty message
final ReusableSimpleMessage simpleMessage = new ReusableSimpleMessage();
@@ -268,7 +268,7 @@ public void testClear() {
}
@Test
- public void testJavaIoSerializable() throws Exception {
+ void testJavaIoSerializable() {
final MutableLogEvent evt = new MutableLogEvent();
evt.setContextData(CONTEXT_DATA);
evt.setContextStack(STACK);
@@ -312,7 +312,7 @@ public void testJavaIoSerializable() throws Exception {
}
@Test
- public void testJavaIoSerializableWithThrown() throws Exception {
+ void testJavaIoSerializableWithThrown() {
final MutableLogEvent evt = new MutableLogEvent();
evt.setContextData(CONTEXT_DATA);
evt.setContextStack(STACK);
@@ -358,7 +358,7 @@ public void testJavaIoSerializableWithThrown() throws Exception {
}
@Test
- public void testPreservesLocation() {
+ void testPreservesLocation() {
final StackTraceElement source = new RuntimeException().getStackTrace()[0];
final MutableLogEvent mutable = new MutableLogEvent();
mutable.setSource(source);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java
index f0fed9d133b..a970031732c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java
@@ -31,10 +31,10 @@
/**
* Tests the ReusableLogEventFactory class.
*/
-public class ReusableLogEventFactoryTest {
+class ReusableLogEventFactoryTest {
@Test
- public void testCreateEventReturnsDifferentInstanceIfNotReleased() throws Exception {
+ void testCreateEventReturnsDifferentInstanceIfNotReleased() {
final ReusableLogEventFactory factory = new ReusableLogEventFactory();
final LogEvent event1 = callCreateEvent(factory, "a", Level.DEBUG, new SimpleMessage("abc"), null);
final LogEvent event2 = callCreateEvent(factory, "b", Level.INFO, new SimpleMessage("xyz"), null);
@@ -44,7 +44,7 @@ public void testCreateEventReturnsDifferentInstanceIfNotReleased() throws Except
}
@Test
- public void testCreateEventReturnsSameInstance() throws Exception {
+ void testCreateEventReturnsSameInstance() {
final ReusableLogEventFactory factory = new ReusableLogEventFactory();
final LogEvent event1 = callCreateEvent(factory, "a", Level.DEBUG, new SimpleMessage("abc"), null);
ReusableLogEventFactory.release(event1);
@@ -58,7 +58,7 @@ public void testCreateEventReturnsSameInstance() throws Exception {
}
@Test
- public void testCreateEventOverwritesFields() throws Exception {
+ void testCreateEventOverwritesFields() {
final ReusableLogEventFactory factory = new ReusableLogEventFactory();
final LogEvent event1 = callCreateEvent(factory, "a", Level.DEBUG, new SimpleMessage("abc"), null);
assertEquals("a", event1.getLoggerName(), "logger");
@@ -87,7 +87,7 @@ private LogEvent callCreateEvent(
}
@Test
- public void testCreateEventReturnsThreadLocalInstance() throws Exception {
+ void testCreateEventReturnsThreadLocalInstance() throws Exception {
final ReusableLogEventFactory factory = new ReusableLogEventFactory();
final AtomicReference event1 = new AtomicReference<>();
final AtomicReference event2 = new AtomicReference<>();
@@ -127,7 +127,7 @@ public void run() {
@SuppressWarnings("deprecation")
@Test
- public void testCreateEventInitFieldsProperly() throws Exception {
+ void testCreateEventInitFieldsProperly() {
final ReusableLogEventFactory factory = new ReusableLogEventFactory();
final LogEvent event = callCreateEvent(factory, "logger", Level.INFO, new SimpleMessage("xyz"), null);
try {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java
index 896d0d2d8b7..b2bdb145548 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java
@@ -66,7 +66,7 @@ private static void resetThreadContextMap() {
}
@Before
- public void before() throws ReflectiveOperationException {
+ public void before() {
System.setProperty("log4j2.threadContextMap", threadContextMapClassName);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/JacksonIssue429MyNamesTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/JacksonIssue429MyNamesTest.java
index 767464d2d32..a0114d9717b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/JacksonIssue429MyNamesTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/JacksonIssue429MyNamesTest.java
@@ -16,9 +16,11 @@
*/
package org.apache.logging.log4j.core.jackson;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -28,14 +30,12 @@
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.util.ClassUtil;
import java.io.IOException;
-import org.apache.logging.log4j.core.test.categories.Layouts;
import org.apache.logging.log4j.util.Strings;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(Layouts.Json.class)
-public class JacksonIssue429MyNamesTest {
+@Tag("Layouts.Json")
+class JacksonIssue429MyNamesTest {
@SuppressWarnings("serial")
static class MyStackTraceElementDeserializer extends StdScalarDeserializer {
@@ -49,7 +49,7 @@ public MyStackTraceElementDeserializer() {
@Override
public StackTraceElement deserialize(final JsonParser jp, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
+ throws IOException {
JsonToken t = jp.getCurrentToken();
// Must get an Object
if (t == JsonToken.START_OBJECT) {
@@ -108,15 +108,15 @@ protected ObjectMapper objectMapper() {
}
@Test
- public void testStackTraceElementWithCustom() throws Exception {
+ void testStackTraceElementWithCustom() throws Exception {
// first, via bean that contains StackTraceElement
final StackTraceBean bean = MAPPER.readValue(
aposToQuotes(
"{'Location':{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':13}}"),
StackTraceBean.class);
- Assert.assertNotNull(bean);
- Assert.assertNotNull(bean.location);
- Assert.assertEquals(StackTraceBean.NUM, bean.location.getLineNumber());
+ assertNotNull(bean);
+ assertNotNull(bean.location);
+ assertEquals(StackTraceBean.NUM, bean.location.getLineNumber());
// and then directly, iff registered
final ObjectMapper mapper = new ObjectMapper();
@@ -127,7 +127,7 @@ public void testStackTraceElementWithCustom() throws Exception {
final StackTraceElement elem = mapper.readValue(
aposToQuotes("{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':13}"),
StackTraceElement.class);
- Assert.assertNotNull(elem);
- Assert.assertEquals(StackTraceBean.NUM, elem.getLineNumber());
+ assertNotNull(elem);
+ assertEquals(StackTraceBean.NUM, elem.getLineNumber());
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/JacksonIssue429Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/JacksonIssue429Test.java
index e9edda0b788..e2ccda0a49d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/JacksonIssue429Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/JacksonIssue429Test.java
@@ -16,22 +16,22 @@
*/
package org.apache.logging.log4j.core.jackson;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.io.IOException;
-import org.apache.logging.log4j.core.test.categories.Layouts;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(Layouts.Json.class)
-public class JacksonIssue429Test {
+@Tag("Layouts.Json")
+class JacksonIssue429Test {
@SuppressWarnings("serial")
static class Jackson429StackTraceElementDeserializer extends StdDeserializer {
@@ -43,7 +43,7 @@ public Jackson429StackTraceElementDeserializer() {
@Override
public StackTraceElement deserialize(final JsonParser jp, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
+ throws IOException {
jp.skipChildren();
return new StackTraceElement("a", "b", "b", StackTraceBean.NUM);
}
@@ -70,12 +70,12 @@ protected ObjectMapper objectMapper() {
}
@Test
- public void testStackTraceElementWithCustom() throws Exception {
+ void testStackTraceElementWithCustom() throws Exception {
// first, via bean that contains StackTraceElement
final StackTraceBean bean = MAPPER.readValue(aposToQuotes("{'Location':'foobar'}"), StackTraceBean.class);
- Assert.assertNotNull(bean);
- Assert.assertNotNull(bean.location);
- Assert.assertEquals(StackTraceBean.NUM, bean.location.getLineNumber());
+ assertNotNull(bean);
+ assertNotNull(bean.location);
+ assertEquals(StackTraceBean.NUM, bean.location.getLineNumber());
// and then directly, iff registered
final ObjectMapper mapper = new ObjectMapper();
@@ -86,7 +86,7 @@ public void testStackTraceElementWithCustom() throws Exception {
final StackTraceElement elem = mapper.readValue(
aposToQuotes("{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':123}"),
StackTraceElement.class);
- Assert.assertNotNull(elem);
- Assert.assertEquals(StackTraceBean.NUM, elem.getLineNumber());
+ assertNotNull(elem);
+ assertEquals(StackTraceBean.NUM, elem.getLineNumber());
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/LevelMixInXmlTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/LevelMixInXmlTest.java
index 34f8ad792c7..acc7d439582 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/LevelMixInXmlTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/LevelMixInXmlTest.java
@@ -21,7 +21,7 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
-public class LevelMixInXmlTest extends LevelMixInTest {
+class LevelMixInXmlTest extends LevelMixInTest {
@Override
protected ObjectMapper newObjectMapper() {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/StackTraceElementMixInTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/StackTraceElementMixInTest.java
index 55070004120..2d73af1c432 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/StackTraceElementMixInTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jackson/StackTraceElementMixInTest.java
@@ -16,27 +16,27 @@
*/
package org.apache.logging.log4j.core.jackson;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.io.IOException;
-import org.apache.logging.log4j.core.test.categories.Layouts;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(Layouts.Json.class)
-public class StackTraceElementMixInTest {
+@Tag("Layouts.Json")
+class StackTraceElementMixInTest {
@Test
- public void testLog4jJsonObjectMapper() throws Exception {
+ void testLog4jJsonObjectMapper() throws Exception {
this.roundtrip(new Log4jJsonObjectMapper());
}
@Test
- public void testLog4jYamlObjectMapper() throws Exception {
+ void testLog4jYamlObjectMapper() throws Exception {
this.roundtrip(new Log4jYamlObjectMapper());
}
@@ -53,11 +53,11 @@ private void roundtrip(final ObjectMapper mapper)
new StackTraceElement("package.SomeClass", "someMethod", "SomeClass.java", 123);
final String s = mapper.writeValueAsString(expected);
final StackTraceElement actual = mapper.readValue(s, StackTraceElement.class);
- Assert.assertEquals(expected, actual);
+ assertEquals(expected, actual);
}
@Test
- public void testLog4jXmlObjectMapper() throws Exception {
+ void testLog4jXmlObjectMapper() throws Exception {
this.roundtrip(new Log4jXmlObjectMapper());
}
@@ -66,7 +66,7 @@ protected String aposToQuotes(final String json) {
}
@Test
- public void testFromJsonWithSimpleModule() throws Exception {
+ void testFromJsonWithSimpleModule() throws Exception {
final ObjectMapper mapper = new ObjectMapper();
final SimpleModule module = new SimpleModule();
module.addDeserializer(StackTraceElement.class, new Log4jStackTraceElementDeserializer());
@@ -76,11 +76,11 @@ public void testFromJsonWithSimpleModule() throws Exception {
final String s = this.aposToQuotes(
"{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':123}");
final StackTraceElement actual = mapper.readValue(s, StackTraceElement.class);
- Assert.assertEquals(expected, actual);
+ assertEquals(expected, actual);
}
@Test
- public void testFromJsonWithLog4jModule() throws Exception {
+ void testFromJsonWithLog4jModule() throws Exception {
final ObjectMapper mapper = new ObjectMapper();
final boolean encodeThreadContextAsList = false;
final SimpleModule module = new Log4jJsonModule(encodeThreadContextAsList, true, false, false);
@@ -91,6 +91,6 @@ public void testFromJsonWithLog4jModule() throws Exception {
final String s = this.aposToQuotes(
"{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':123}");
final StackTraceElement actual = mapper.readValue(s, StackTraceElement.class);
- Assert.assertEquals(expected, actual);
+ assertEquals(expected, actual);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jmx/ServerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jmx/ServerTest.java
index 958785dee8a..501988fa3f2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jmx/ServerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/jmx/ServerTest.java
@@ -24,10 +24,10 @@
/**
* Unit tests for the Server class.
*/
-public class ServerTest {
+class ServerTest {
@Test
- public void testEscapeQuotesButDoesNotEscapeEquals() throws Exception {
+ void testEscapeQuotesButDoesNotEscapeEquals() throws Exception {
final String ctx = "WebAppClassLoader=1320771902@4eb9613e"; // LOG4J2-492
final String ctxName = Server.escape(ctx);
assertEquals("\"WebAppClassLoader=1320771902@4eb9613e\"", ctxName);
@@ -36,7 +36,7 @@ public void testEscapeQuotesButDoesNotEscapeEquals() throws Exception {
}
@Test
- public void testEscapeQuotesButDoesNotEscapeComma() throws Exception {
+ void testEscapeQuotesButDoesNotEscapeComma() throws Exception {
final String ctx = "a,b,c";
final String ctxName = Server.escape(ctx);
assertEquals("\"a,b,c\"", ctxName);
@@ -45,7 +45,7 @@ public void testEscapeQuotesButDoesNotEscapeComma() throws Exception {
}
@Test
- public void testEscapeQuotesButDoesNotEscapeColon() throws Exception {
+ void testEscapeQuotesButDoesNotEscapeColon() throws Exception {
final String ctx = "a:b:c";
final String ctxName = Server.escape(ctx);
assertEquals("\"a:b:c\"", ctxName);
@@ -54,7 +54,7 @@ public void testEscapeQuotesButDoesNotEscapeColon() throws Exception {
}
@Test
- public void testEscapeQuotesAndEscapesQuestion() throws Exception {
+ void testEscapeQuotesAndEscapesQuestion() throws Exception {
final String ctx = "a?c";
final String ctxName = Server.escape(ctx);
assertEquals("\"a\\?c\"", ctxName);
@@ -63,7 +63,7 @@ public void testEscapeQuotesAndEscapesQuestion() throws Exception {
}
@Test
- public void testEscapeQuotesAndEscapesStar() throws Exception {
+ void testEscapeQuotesAndEscapesStar() throws Exception {
final String ctx = "a*c";
final String ctxName = Server.escape(ctx);
assertEquals("\"a\\*c\"", ctxName);
@@ -72,7 +72,7 @@ public void testEscapeQuotesAndEscapesStar() throws Exception {
}
@Test
- public void testEscapeQuotesAndEscapesBackslash() throws Exception {
+ void testEscapeQuotesAndEscapesBackslash() throws Exception {
final String ctx = "a\\c";
final String ctxName = Server.escape(ctx);
assertEquals("\"a\\\\c\"", ctxName);
@@ -81,7 +81,7 @@ public void testEscapeQuotesAndEscapesBackslash() throws Exception {
}
@Test
- public void testEscapeQuotesAndEscapesQuote() throws Exception {
+ void testEscapeQuotesAndEscapesQuote() throws Exception {
final String ctx = "a\"c";
final String ctxName = Server.escape(ctx);
assertEquals("\"a\\\"c\"", ctxName);
@@ -90,7 +90,7 @@ public void testEscapeQuotesAndEscapesQuote() throws Exception {
}
@Test
- public void testEscapeIgnoresSpaces() throws Exception {
+ void testEscapeIgnoresSpaces() throws Exception {
final String ctx = "a c";
final String ctxName = Server.escape(ctx);
assertEquals("a c", ctxName);
@@ -99,7 +99,7 @@ public void testEscapeIgnoresSpaces() throws Exception {
}
@Test
- public void testEscapeEscapesLineFeed() throws Exception {
+ void testEscapeEscapesLineFeed() throws Exception {
final String ctx = "a\rc";
final String ctxName = Server.escape(ctx);
assertEquals("ac", ctxName);
@@ -108,7 +108,7 @@ public void testEscapeEscapesLineFeed() throws Exception {
}
@Test
- public void testEscapeEscapesCarriageReturn() throws Exception {
+ void testEscapeEscapesCarriageReturn() throws Exception {
final String ctx = "a\nc";
final String ctxName = Server.escape(ctx);
assertEquals("\"a\\nc\"", ctxName);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java
index e48c90f6b54..d15961bca51 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java
@@ -30,7 +30,7 @@
/**
* Tests AbstractStringLayout.
*/
-public class AbstractStringLayoutTest {
+class AbstractStringLayoutTest {
// Configuration explicitly null
private static final Serializer serializer = new SerializerBuilder()
@@ -57,7 +57,7 @@ public String toSerializable(final LogEvent event) {
}
@Test
- public void testGetStringBuilderCapacityRestrictedToMax() throws Exception {
+ void testGetStringBuilderCapacityRestrictedToMax() {
final StringBuilder sb = ConcreteStringLayout.getStringBuilder();
final int initialCapacity = sb.capacity();
assertEquals(ConcreteStringLayout.DEFAULT_STRING_BUILDER_SIZE, sb.capacity(), "initial capacity");
@@ -93,7 +93,7 @@ public void testGetStringBuilderCapacityRestrictedToMax() throws Exception {
}
@Test
- public void testNullConfigurationIsAllowed() {
+ void testNullConfigurationIsAllowed() {
try {
final ConcreteStringLayout layout = new ConcreteStringLayout();
layout.serializeToString(serializer);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/ConcurrentLoggingWithGelfLayoutTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/ConcurrentLoggingWithGelfLayoutTest.java
index 06f1b4a13f8..5736383b419 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/ConcurrentLoggingWithGelfLayoutTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/ConcurrentLoggingWithGelfLayoutTest.java
@@ -44,7 +44,7 @@
* @since 2.8
*/
@Tag("concurrency")
-public class ConcurrentLoggingWithGelfLayoutTest {
+class ConcurrentLoggingWithGelfLayoutTest {
private static final Path PATH = Paths.get("target", "test-gelf-layout.log");
@AfterAll
@@ -55,7 +55,7 @@ static void after() throws IOException {
@Test
@LoggerContextSource("log4j2-gelf-layout.xml")
- public void testConcurrentLogging(final LoggerContext context) throws Throwable {
+ void testConcurrentLogging(final LoggerContext context) throws Throwable {
final Logger log = context.getLogger(ConcurrentLoggingWithGelfLayoutTest.class);
final int threadCount = Runtime.getRuntime().availableProcessors() * 2;
final CountDownLatch latch = new CountDownLatch(threadCount);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/ConcurrentLoggingWithJsonLayoutTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/ConcurrentLoggingWithJsonLayoutTest.java
index addaf794232..8224b7473f6 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/ConcurrentLoggingWithJsonLayoutTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/ConcurrentLoggingWithJsonLayoutTest.java
@@ -18,7 +18,7 @@
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.endsWith;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import java.io.File;
import java.nio.charset.Charset;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java
index 4f85617f5a7..fadd4a0fecf 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java
@@ -149,27 +149,27 @@ private void testLayout(
}
@Test
- public void testLayoutDefault() throws Exception {
+ public void testLayoutDefault() {
testLayout(CSVFormat.DEFAULT);
}
@Test
- public void testLayoutExcel() throws Exception {
+ public void testLayoutExcel() {
testLayout(CSVFormat.EXCEL);
}
@Test
- public void testLayoutMySQL() throws Exception {
+ public void testLayoutMySQL() {
testLayout(CSVFormat.MYSQL);
}
@Test
- public void testLayoutRFC4180() throws Exception {
+ public void testLayoutRFC4180() {
testLayout(CSVFormat.RFC4180);
}
@Test
- public void testLayoutTab() throws Exception {
+ public void testLayoutTab() {
testLayout(CSVFormat.TDF);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java
index 571795ffadf..1bcb5ffcf22 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java
@@ -21,47 +21,46 @@
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.async.AsyncLoggerContextSelector;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.test.categories.Layouts;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests {@link AbstractCsvLayout} with all loggers async.
*
* @since 2.6
*/
-@Category(Layouts.Csv.class)
-public class CsvParameterLayoutAllAsyncTest {
+@Tag("Layouts.Csv")
+class CsvParameterLayoutAllAsyncTest {
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void beforeClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerTest.xml");
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void afterClass() {
System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
}
@Test
- public void testLayoutDefaultNormal() throws Exception {
+ void testLayoutDefaultNormal() throws Exception {
final Logger root = (Logger) LogManager.getRootLogger();
CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), false);
}
@Test
- public void testLayoutDefaultObjectArrayMessage() throws Exception {
+ void testLayoutDefaultObjectArrayMessage() throws Exception {
final Logger root = (Logger) LogManager.getRootLogger();
CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), true);
}
@Test
- public void testLayoutTab() throws Exception {
+ void testLayoutTab() throws Exception {
final Logger root = (Logger) LogManager.getRootLogger();
CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createLayout(CSVFormat.TDF), true);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
index e7913c992ea..50bff2beac7 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
@@ -172,7 +172,7 @@ public void testLayoutTab() throws Exception {
@Test
public void testLogJsonArgument() throws InterruptedException {
- final ListAppender appender = (ListAppender) init.getAppender("List");
+ final ListAppender appender = init.getAppender("List");
appender.countDownLatch = new CountDownLatch(4);
appender.clear();
final Logger logger = (Logger) LogManager.getRootLogger();
@@ -180,7 +180,7 @@ public void testLogJsonArgument() throws InterruptedException {
logger.error("log:{}", json);
// wait until background thread finished processing
final int msgCount = 1;
- if (appender.getMessages().size() < msgCount) {
+ if (appender.getMessages().isEmpty()) {
appender.countDownLatch.await(5, TimeUnit.SECONDS);
}
assertEquals(
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayout2Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayout2Test.java
index eb05ec10287..47bc55eafde 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayout2Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayout2Test.java
@@ -30,10 +30,10 @@
import org.junit.jupiter.api.Test;
@LoggerContextSource("GelfLayout2Test.xml")
-public class GelfLayout2Test {
+class GelfLayout2Test {
@Test
- public void gelfLayout(final LoggerContext context, @Named final ListAppender list) throws IOException {
+ void gelfLayout(final LoggerContext context, @Named final ListAppender list) throws IOException {
list.clear();
final Logger logger = context.getLogger(getClass());
logger.info("Message");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayout3Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayout3Test.java
index 7bc09bcbc28..ba67f16a8c2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayout3Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayout3Test.java
@@ -38,10 +38,10 @@
@LoggerContextSource("GelfLayout3Test.xml")
@UsingAnyThreadContext
@Tag("json")
-public class GelfLayout3Test {
+class GelfLayout3Test {
@Test
- public void gelfLayout(final LoggerContext context, @Named final ListAppender list) throws IOException {
+ void gelfLayout(final LoggerContext context, @Named final ListAppender list) throws IOException {
list.clear();
final Logger logger = context.getLogger(getClass());
ThreadContext.put("loginId", "rgoers");
@@ -66,7 +66,7 @@ public void gelfLayout(final LoggerContext context, @Named final ListAppender li
}
@Test
- public void mapMessage(final LoggerContext context, @Named final ListAppender list) throws IOException {
+ void mapMessage(final LoggerContext context, @Named final ListAppender list) throws IOException {
list.clear();
final Logger logger = context.getLogger(getClass());
ThreadContext.put("loginId", "rgoers");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutPatternSelectorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutPatternSelectorTest.java
index a7acf02f450..9eb4493ac3d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutPatternSelectorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutPatternSelectorTest.java
@@ -39,10 +39,10 @@
@LoggerContextSource("GelfLayoutPatternSelectorTest.xml")
@UsingAnyThreadContext
@Tag("json")
-public class GelfLayoutPatternSelectorTest {
+class GelfLayoutPatternSelectorTest {
@Test
- public void gelfLayout(final LoggerContext context, @Named final ListAppender list) throws IOException {
+ void gelfLayout(final LoggerContext context, @Named final ListAppender list) throws IOException {
list.clear();
final Logger logger = context.getLogger(getClass());
ThreadContext.put("loginId", "rgoers");
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
index 8d547079645..569a6698511 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
@@ -49,7 +49,7 @@
import org.junit.jupiter.api.Test;
@UsingAnyThreadContext
-public class GelfLayoutTest {
+class GelfLayoutTest {
static ConfigurationFactory configFactory = new BasicConfigurationFactory();
@@ -66,12 +66,12 @@ public class GelfLayoutTest {
private static final String VALUE1 = "Value1";
@AfterAll
- public static void cleanupClass() {
+ static void cleanupClass() {
ConfigurationFactory.removeConfigurationFactory(configFactory);
}
@BeforeAll
- public static void setupClass() {
+ static void setupClass() {
ConfigurationFactory.setConfigurationFactory(configFactory);
final LoggerContext ctx = LoggerContext.getContext();
ctx.reconfigure();
@@ -254,47 +254,47 @@ private void testCompressedLayout(
}
@Test
- public void testLayoutGzipCompression() throws Exception {
+ void testLayoutGzipCompression() throws Exception {
testCompressedLayout(CompressionType.GZIP, true, true, HOSTNAME, false, false);
}
@Test
- public void testLayoutNoCompression() throws Exception {
+ void testLayoutNoCompression() throws Exception {
testCompressedLayout(CompressionType.OFF, true, true, HOSTNAME, false, false);
}
@Test
- public void testLayoutZlibCompression() throws Exception {
+ void testLayoutZlibCompression() throws Exception {
testCompressedLayout(CompressionType.ZLIB, true, true, HOSTNAME, false, false);
}
@Test
- public void testLayoutNoStacktrace() throws Exception {
+ void testLayoutNoStacktrace() throws Exception {
testCompressedLayout(CompressionType.OFF, false, true, HOSTNAME, false, false);
}
@Test
- public void testLayoutNoThreadContext() throws Exception {
+ void testLayoutNoThreadContext() throws Exception {
testCompressedLayout(CompressionType.OFF, true, false, HOSTNAME, false, false);
}
@Test
- public void testLayoutNoHost() throws Exception {
+ void testLayoutNoHost() throws Exception {
testCompressedLayout(CompressionType.OFF, true, true, null, false, false);
}
@Test
- public void testLayoutNullDelimiter() throws Exception {
+ void testLayoutNullDelimiter() throws Exception {
testCompressedLayout(CompressionType.OFF, false, true, HOSTNAME, true, false);
}
@Test
- public void testLayoutNewLineDelimiter() throws Exception {
+ void testLayoutNewLineDelimiter() throws Exception {
testCompressedLayout(CompressionType.OFF, true, true, HOSTNAME, false, true);
}
@Test
- public void testFormatTimestamp() {
+ void testFormatTimestamp() {
assertEquals("0", GelfLayout.formatTimestamp(0L).toString());
assertEquals("1.000", GelfLayout.formatTimestamp(1000L).toString());
assertEquals("1.001", GelfLayout.formatTimestamp(1001L).toString());
@@ -316,17 +316,17 @@ private void testRequiresLocation(final String messagePattern, final Boolean req
}
@Test
- public void testRequiresLocationPatternNotSet() {
+ void testRequiresLocationPatternNotSet() {
testRequiresLocation(null, false);
}
@Test
- public void testRequiresLocationPatternNotContainsLocation() {
+ void testRequiresLocationPatternNotContainsLocation() {
testRequiresLocation("%m %n", false);
}
@Test
- public void testRequiresLocationPatternContainsLocation() {
+ void testRequiresLocationPatternContainsLocation() {
testRequiresLocation("%C %m %t", true);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java
index 9a222e5145f..13901d3af08 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java
@@ -51,7 +51,7 @@
import org.junit.jupiter.api.Test;
@UsingAnyThreadContext
-public class HtmlLayoutTest {
+class HtmlLayoutTest {
private static class MyLogEvent extends AbstractLogEvent {
private static final long serialVersionUID = 0;
@@ -87,14 +87,14 @@ public Message getMessage() {
static ConfigurationFactory cf = new BasicConfigurationFactory();
@BeforeAll
- public static void setupClass() {
+ static void setupClass() {
ConfigurationFactory.setConfigurationFactory(cf);
final LoggerContext ctx = LoggerContext.getContext();
ctx.reconfigure();
}
@AfterAll
- public static void cleanupClass() {
+ static void cleanupClass() {
ConfigurationFactory.removeConfigurationFactory(cf);
}
@@ -104,13 +104,13 @@ public static void cleanupClass() {
private static final String multiLine = "First line Second line | ";
@Test
- public void testDefaultContentType() {
+ void testDefaultContentType() {
final HtmlLayout layout = HtmlLayout.createDefaultLayout();
assertEquals("text/html; charset=UTF-8", layout.getContentType());
}
@Test
- public void testContentType() {
+ void testContentType() {
final HtmlLayout layout = HtmlLayout.newBuilder()
.withContentType("text/html; charset=UTF-16")
.build();
@@ -120,7 +120,7 @@ public void testContentType() {
}
@Test
- public void testDefaultCharset() {
+ void testDefaultCharset() {
final HtmlLayout layout = HtmlLayout.createDefaultLayout();
assertEquals(StandardCharsets.UTF_8, layout.getCharset());
}
@@ -129,16 +129,16 @@ public void testDefaultCharset() {
* Test case for MDC conversion pattern.
*/
@Test
- public void testLayoutIncludeLocationNo() throws Exception {
+ void testLayoutIncludeLocationNo() throws Exception {
testLayout(false);
}
@Test
- public void testLayoutIncludeLocationYes() throws Exception {
+ void testLayoutIncludeLocationYes() throws Exception {
testLayout(true);
}
- private void testLayout(final boolean includeLocation) throws Exception {
+ private void testLayout(final boolean includeLocation) {
final Map appenders = root.getAppenders();
for (final Appender appender : appenders.values()) {
root.removeAppender(appender);
@@ -184,9 +184,9 @@ private void testLayout(final boolean includeLocation) throws Exception {
assertEquals("Log4j Log Messages", list.get(4), "Incorrect title");
assertEquals("