You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2024/03/26 05:09:54 UTC
(logging-log4j2) branch fix/rollback-log4j-api updated (72d1120d46 -> da5632a2a1)
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a change to branch fix/rollback-log4j-api
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
omit 72d1120d46 Rollback `log4j-api` to version from `2.x`
add d31e9e41f8 Rename `log4j-sdk` to `log4j-kit`
add 1b510c25ac Rename `sdk` to `kit` also in OSGi tests
add f6825d2414 Add `PropertyEnvironment` to `log4j-sdk`
add c624e01cc4 Add support for default values
add 64ebf0ddaa Corrections due to #2307 review
add 7c09141a56 Fix environment variable names
add f1b306daa6 Make location and formatted message more lazy
add 9068465d54 Fix `log4j-1.2-api` OSGi descriptor
add 590a205df1 Fix Javadoc generation
add 79b6316312 Apply review suggestions
add e18403a619 Fix `PropertiesUtil` source
add 35c0f02012 Generalize DI usage
add c2b121dc19 Revert `ConfigurationFactory` renaming
add a75bd17047 Revert `LogEventWrapper` changes
add 68e22a7428 Revert changes to methods used by Spring Boot
add c3f4261f98 Replace `PropertiesUtil` with `PropertyEnvironment`
add 17f1336e35 Fix Javadoc
add 076fa05e4a Move `Recycler` to `log4j-kit`
add bb350df692 Update @since tag
add 960c287da5 Downgrade to `log4j-api` version `2.24.0-SNAPSHOT`
add b764fa0075 Rebase `log4j-to-jul` upon Log4j API 2.24.0
add 67b0fefa7a Rebase `log4j-to-slf4j` upon Log4j API 2.24.0
add c2a0909b3c Replace `o.a.l.l.lang` annotations with JSpecify
add cff6547762 Move `ReflectionUtil` to `log4j-plugins`
add 0ca03caebb Inline missing `String.trimToOptional`
add 5abda8ce08 Adapt `Log4jExtension` to Log4j API 2.x
add 11a0a43aa3 Adapt `log4j-plugins` to Log4j API 2.x
add 00ac582ecf Adapt `log4j-core` to Log4j API 2.x
add b867e1321d Adapt `log4j-async-logger` to Log4j API 2.x
add f5def618a5 Adapt `log4j-flume-ng` to Log4j API 2.x
add 76419ecd45 Adapt `log4j-layout-template-json` to Log4j API 2.x
add c046f76f88 Adapt `log4j-gc-test` to Log4j API 2.x
add 8772d927b7 Adapt `log4j-jdbc` to Log4j API 2.x
add 5e5e0b1ed2 Adapt `log4j-layout-template-json-test` to Log4j API 2.x
add 8c2ac517b6 Adapt `log4j-perf-test` to Log4j API 2.x
add 030e2da078 Fix OSGi configuration
new da5632a2a1 Remove Log4j API 3.x
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (72d1120d46)
\
N -- N -- N refs/heads/fix/rollback-log4j-api (da5632a2a1)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
log4j-1.2-api/pom.xml | 11 +-
.../org/apache/log4j/PropertyConfigurator.java | 3 +-
.../org/apache/log4j/bridge/LogEventWrapper.java | 8 +-
.../apache/log4j/config/Log4j1Configuration.java | 14 +-
.../log4j/config/PropertiesConfiguration.java | 30 +-
.../config/PropertiesConfigurationFactory.java | 28 +-
.../org/apache/log4j/helpers/OptionConverter.java | 2 +
.../org/apache/log4j/xml/XmlConfiguration.java | 8 +-
.../apache/log4j/xml/XmlConfigurationFactory.java | 28 +-
.../apache/log4j/BasicConfigurationFactory.java | 2 +-
.../org/apache/log4j/config/AutoConfigTest.java | 8 +-
.../log4j/config/MapRewriteAppenderTest.java | 5 +-
.../config/PropertiesConfigurationFactoryTest.java | 6 +-
.../PropertiesRollingWithPropertiesTest.java | 8 +-
.../apache/log4j/config/RewriteAppenderTest.java | 8 +-
.../apache/log4j/config/SyslogAppenderTest.java | 6 +-
.../log4j/config/XmlConfigurationFactoryTest.java | 5 +-
.../log4j/config/XmlRollingWithPropertiesTest.java | 8 +-
log4j-api-test/pom.xml | 168 -
.../logging/log4j/test/ListStatusListener.java | 43 -
.../org/apache/logging/log4j/test/TestLogger.java | 268 --
.../logging/log4j/test/TestLoggerContext.java | 66 -
.../log4j/test/TestLoggerContextFactory.java | 54 -
.../apache/logging/log4j/test/TestProperties.java | 44 -
.../logging/log4j/test/ThreadContextHolder.java | 78 -
.../log4j/test/ThreadContextUtilityClass.java | 118 -
.../java/org/apache/logging/log4j/test/Timer.java | 294 --
.../log4j/test/junit/AbstractFileCleaner.java | 83 -
.../logging/log4j/test/junit/ClassMatchers.java | 36 -
.../log4j/test/junit/CleanUpDirectories.java | 44 -
.../logging/log4j/test/junit/CleanUpFiles.java | 44 -
.../logging/log4j/test/junit/DirectoryCleaner.java | 74 -
.../log4j/test/junit/ExtensionContextAnchor.java | 108 -
.../logging/log4j/test/junit/FileCleaner.java | 51 -
.../log4j/test/junit/InitializesThreadContext.java | 39 -
.../test/junit/LoggerContextFactoryExtension.java | 53 -
.../apache/logging/log4j/test/junit/Resources.java | 30 -
.../logging/log4j/test/junit/SetTestProperty.java | 61 -
.../log4j/test/junit/StatusLoggerExtension.java | 200 -
.../test/junit/StatusLoggerLevelExtension.java | 48 -
.../logging/log4j/test/junit/TempLoggingDir.java | 45 -
.../log4j/test/junit/TempLoggingDirectory.java | 190 -
.../log4j/test/junit/TestPropertyResolver.java | 68 -
.../log4j/test/junit/TestPropertySource.java | 133 -
.../log4j/test/junit/ThreadContextInitializer.java | 49 -
.../test/junit/ThreadContextMapExtension.java | 44 -
.../log4j/test/junit/ThreadContextRule.java | 80 -
.../test/junit/ThreadContextStackExtension.java | 46 -
.../log4j/test/junit/ThreadContextStackRule.java | 39 -
.../log4j/test/junit/UsingAnyThreadContext.java | 38 -
.../log4j/test/junit/UsingStatusListener.java | 41 -
.../log4j/test/junit/UsingTestProperties.java | 44 -
.../log4j/test/junit/UsingThreadContextMap.java | 43 -
.../log4j/test/junit/UsingThreadContextStack.java | 40 -
.../org.apache.logging.log4j.util.PropertySource | 15 -
.../org.junit.jupiter.api.extension.Extension | 15 -
...junit.platform.launcher.LauncherSessionListener | 16 -
.../apache/logging/log4j/AbstractLoggerTest.java | 1472 ------
.../logging/log4j/CloseableThreadContextTest.java | 239 -
.../org/apache/logging/log4j/EventLoggerTest.java | 56 -
.../org/apache/logging/log4j/LambdaLoggerTest.java | 1413 ------
.../java/org/apache/logging/log4j/LevelTest.java | 284 --
.../org/apache/logging/log4j/LogManagerTest.java | 131 -
.../apache/logging/log4j/LoggerSupplierTest.java | 200 -
.../java/org/apache/logging/log4j/LoggerTest.java | 658 ---
.../java/org/apache/logging/log4j/MarkerTest.java | 109 -
.../org/apache/logging/log4j/TestProvider.java | 29 -
.../log4j/ThreadContextInheritanceTest.java | 174 -
.../org/apache/logging/log4j/TraceLoggingTest.java | 381 --
.../log4j/internal/DefaultLogBuilderTest.java | 47 -
.../internal/recycler/RecyclerFactoryTestUtil.java | 47 -
.../log4j/message/FormattedMessageTest.java | 153 -
.../apache/logging/log4j/message/JsonMessage.java | 64 -
.../log4j/message/LocalizedMessageFactoryTest.java | 116 -
.../log4j/message/LocalizedMessageTest.java | 86 -
.../logging/log4j/message/MapMessageTest.java | 330 --
.../log4j/message/MessageFormatMessageTest.java | 115 -
.../logging/log4j/message/ObjectMessageTest.java | 80 -
.../log4j/message/ParameterFormatterTest.java | 158 -
.../log4j/message/ParameterizedMessageTest.java | 145 -
.../log4j/message/ReusableMessageFactoryTest.java | 136 -
.../log4j/message/ReusableObjectMessageTest.java | 124 -
.../message/ReusableParameterizedMessageTest.java | 178 -
.../log4j/message/ReusableSimpleMessageTest.java | 124 -
.../logging/log4j/message/SimpleMessageTest.java | 40 -
.../log4j/message/StringFormattedMessageTest.java | 132 -
.../log4j/message/StructuredDataMessageTest.java | 125 -
.../log4j/message/ThreadDumpMessageTest.java | 166 -
.../logging/log4j/simple/SimpleLoggerTest.java | 69 -
.../log4j/spi/DefaultThreadContextStackTest.java | 342 --
.../logging/log4j/spi/LoggerAdapterTest.java | 187 -
.../log4j/spi/MutableThreadContextStackTest.java | 371 --
.../log4j/status/StatusConsoleListenerTest.java | 147 -
.../apache/logging/log4j/test/BetterService.java | 19 -
.../org/apache/logging/log4j/test/Service2.java | 19 -
.../logging/log4j/test/ThreadContextTest.java | 184 -
.../log4j/test/junit/TempLoggingDirectoryTest.java | 45 -
.../log4j/test/junit/TestPropertySourceTest.java | 57 -
.../org/apache/logging/log4j/util/AssertTest.java | 53 -
.../org/apache/logging/log4j/util/CharsTest.java | 46 -
.../apache/logging/log4j/util/ConstantsTest.java | 32 -
.../logging/log4j/util/DeserializerHelper.java | 48 -
.../log4j/util/EnvironmentPropertySourceTest.java | 47 -
.../apache/logging/log4j/util/LambdaUtilTest.java | 117 -
.../org/apache/logging/log4j/util/LazyTest.java | 187 -
.../util/LegacyPropertiesCompatibilityTest.java | 82 -
.../log4j/util/Log4jCharsetsPropertiesTest.java | 47 -
.../log4j/util/PropertiesPropertySourceTest.java | 47 -
.../log4j/util/PropertiesUtilOrderTest.java | 146 -
.../logging/log4j/util/PropertiesUtilTest.java | 228 -
.../log4j/util/PropertySourceCamelCaseTest.java | 43 -
.../log4j/util/PropertySourceTokenizerTest.java | 61 -
.../logging/log4j/util/ProviderUtilTest.java | 51 -
.../logging/log4j/util/ServiceLoaderUtilTest.java | 70 -
.../log4j/util/SortedArrayStringMapTest.java | 993 ----
.../logging/log4j/util/StackLocatorUtilTest.java | 169 -
.../logging/log4j/util/StringBuildersTest.java | 93 -
.../org/apache/logging/log4j/util/StringsTest.java | 89 -
.../logging/log4j/util/SystemPropertiesMain.java | 48 -
.../util/SystemPropertiesPropertySourceTest.java | 68 -
.../org/apache/logging/log4j/util/Unbox1Test.java | 187 -
.../logging/log4j/util/Unbox2ConfigurableTest.java | 81 -
.../src/test/resources/Jira3413Test.properties | 34 -
.../src/test/resources/META-INF/log4j2.my-app.json | 16 -
.../services/org.apache.logging.log4j.spi.Provider | 1 -
.../org.apache.logging.log4j.test.BetterService | 16 -
.../services/org.apache.logging.log4j.test.Service | 31 -
.../src/test/resources/MF_en_US.properties | 19 -
log4j-api-test/src/test/resources/MF_fr.properties | 19 -
.../src/test/resources/MF_fr_CH.properties | 18 -
.../resources/PropertiesUtilOrderTest.properties | 26 -
.../src/test/resources/PropertiesUtilTest.json | 25 -
.../test/resources/PropertiesUtilTest.properties | 32 -
.../src/test/resources/SF_en_US.properties | 19 -
log4j-api-test/src/test/resources/SF_fr.properties | 19 -
.../src/test/resources/SF_fr_CH.properties | 18 -
.../src/test/resources/log4j2.my-app.json | 16 -
.../src/test/resources/log4j2.propertyMapping.json | 96 -
.../src/test/resources/log4j2.system.properties | 17 -
.../logging/log4j/test/ForceLinkageError.class | 0
log4j-api/pom.xml | 63 -
.../java/org/apache/logging/log4j/BridgeAware.java | 33 -
.../logging/log4j/CloseableThreadContext.java | 227 -
.../java/org/apache/logging/log4j/EventLogger.java | 58 -
.../main/java/org/apache/logging/log4j/Level.java | 374 --
.../java/org/apache/logging/log4j/LogBuilder.java | 299 --
.../java/org/apache/logging/log4j/LogManager.java | 658 ---
.../main/java/org/apache/logging/log4j/Logger.java | 4774 --------------------
.../org/apache/logging/log4j/LoggingException.java | 56 -
.../main/java/org/apache/logging/log4j/Marker.java | 113 -
.../org/apache/logging/log4j/MarkerManager.java | 413 --
.../org/apache/logging/log4j/ThreadContext.java | 626 ---
.../log4j/internal/CopyOnWriteNavigableSet.java | 269 --
.../logging/log4j/internal/DefaultLogBuilder.java | 398 --
.../log4j/internal/DefaultObjectInputFilter.java | 92 -
.../org/apache/logging/log4j/lang/NonNull.java | 35 -
.../org/apache/logging/log4j/lang/NullMarked.java | 36 -
.../apache/logging/log4j/lang/NullUnmarked.java | 37 -
.../org/apache/logging/log4j/lang/Nullable.java | 36 -
.../apache/logging/log4j/lang/package-info.java | 28 -
.../log4j/message/AbstractMessageFactory.java | 190 -
.../log4j/message/AsynchronouslyFormattable.java | 59 -
.../log4j/message/BasicThreadInformation.java | 106 -
.../apache/logging/log4j/message/Clearable.java | 31 -
.../log4j/message/DefaultFlowMessageFactory.java | 261 --
.../logging/log4j/message/FlowMessageFactory.java | 87 -
.../logging/log4j/message/FormattedMessage.java | 237 -
.../log4j/message/FormattedMessageFactory.java | 176 -
.../logging/log4j/message/LocalizedMessage.java | 260 --
.../log4j/message/LocalizedMessageFactory.java | 92 -
.../log4j/message/LoggerNameAwareMessage.java | 34 -
.../apache/logging/log4j/message/MapMessage.java | 756 ----
.../log4j/message/MapMessageJsonFormatter.java | 394 --
.../org/apache/logging/log4j/message/Message.java | 97 -
.../log4j/message/MessageCollectionMessage.java | 23 -
.../logging/log4j/message/MessageFactory.java | 281 --
.../logging/log4j/message/MessageFactory2.java | 200 -
.../log4j/message/MessageFormatMessage.java | 142 -
.../log4j/message/MessageFormatMessageFactory.java | 177 -
.../logging/log4j/message/MultiformatMessage.java | 42 -
.../logging/log4j/message/ObjectArrayMessage.java | 118 -
.../logging/log4j/message/ObjectMessage.java | 128 -
.../logging/log4j/message/ParameterConsumer.java | 41 -
.../logging/log4j/message/ParameterFormatter.java | 624 ---
.../logging/log4j/message/ParameterVisitable.java | 45 -
.../log4j/message/ParameterizedMessage.java | 302 --
.../log4j/message/ParameterizedMessageFactory.java | 192 -
.../ParameterizedNoReferenceMessageFactory.java | 105 -
.../logging/log4j/message/ReusableMessage.java | 81 -
.../log4j/message/ReusableObjectMessage.java | 137 -
.../message/ReusableParameterizedMessage.java | 391 --
.../log4j/message/ReusableSimpleMessage.java | 111 -
.../logging/log4j/message/SimpleMessage.java | 144 -
.../log4j/message/SimpleMessageFactory.java | 191 -
.../log4j/message/StringFormattedMessage.java | 152 -
.../message/StringFormatterMessageFactory.java | 189 -
.../logging/log4j/message/StringMapMessage.java | 67 -
.../message/StructuredDataCollectionMessage.java | 100 -
.../logging/log4j/message/StructuredDataId.java | 268 --
.../log4j/message/StructuredDataMessage.java | 518 ---
.../logging/log4j/message/ThreadDumpMessage.java | 143 -
.../logging/log4j/message/ThreadInformation.java | 36 -
.../logging/log4j/message/TimestampMessage.java | 29 -
.../org/apache/logging/log4j/package-info.java | 44 -
.../apache/logging/log4j/simple/SimpleLogger.java | 330 --
.../log4j/simple/SimpleLoggerConfiguration.java | 80 -
.../logging/log4j/simple/SimpleLoggerContext.java | 130 -
.../log4j/simple/SimpleLoggerContextFactory.java | 59 -
.../apache/logging/log4j/simple/package-info.java | 27 -
.../apache/logging/log4j/spi/AbstractLogger.java | 3848 ----------------
.../logging/log4j/spi/AbstractLoggerAdapter.java | 149 -
.../log4j/spi/CleanableThreadContextMap.java | 38 -
.../org/apache/logging/log4j/spi/CopyOnWrite.java | 25 -
.../CopyOnWriteSortedArrayThreadContextMap.java | 266 --
.../logging/log4j/spi/DefaultThreadContextMap.java | 239 -
.../log4j/spi/DefaultThreadContextStack.java | 319 --
.../apache/logging/log4j/spi/ExtendedLogger.java | 668 ---
.../logging/log4j/spi/ExtendedLoggerWrapper.java | 281 --
.../GarbageFreeSortedArrayThreadContextMap.java | 255 --
.../apache/logging/log4j/spi/LoggerAdapter.java | 38 -
.../apache/logging/log4j/spi/LoggerContext.java | 189 -
.../logging/log4j/spi/LoggerContextFactory.java | 123 -
.../log4j/spi/LoggerContextShutdownAware.java | 26 -
.../apache/logging/log4j/spi/LoggerRegistry.java | 188 -
.../apache/logging/log4j/spi/LoggingSystem.java | 368 --
.../logging/log4j/spi/LoggingSystemProperty.java | 490 --
.../logging/log4j/spi/MessageFactory2Adapter.java | 157 -
.../log4j/spi/MutableThreadContextStack.java | 255 --
.../logging/log4j/spi/NoOpThreadContextMap.java | 62 -
.../logging/log4j/spi/ObjectThreadContextMap.java | 53 -
.../logging/log4j/spi/PropertyComponent.java | 87 -
.../org/apache/logging/log4j/spi/Provider.java | 245 -
.../log4j/spi/ReadOnlyThreadContextMap.java | 95 -
.../apache/logging/log4j/spi/StandardLevel.java | 103 -
.../org/apache/logging/log4j/spi/Terminable.java | 32 -
.../apache/logging/log4j/spi/ThreadContextMap.java | 88 -
.../logging/log4j/spi/ThreadContextMap2.java | 52 -
.../logging/log4j/spi/ThreadContextMapFactory.java | 145 -
.../logging/log4j/spi/ThreadContextStack.java | 26 -
.../spi/recycler/RecyclerFactoryRegistry.java | 119 -
.../logging/log4j/spi/recycler/package-info.java | 26 -
.../log4j/status/StatusConsoleListener.java | 132 -
.../apache/logging/log4j/status/StatusData.java | 158 -
.../logging/log4j/status/StatusListener.java | 39 -
.../apache/logging/log4j/status/StatusLogger.java | 435 --
.../log4j/status/StatusLoggerConfiguration.java | 58 -
.../logging/log4j/status/StatusLoggerFactory.java | 54 -
.../apache/logging/log4j/status/package-info.java | 26 -
.../org/apache/logging/log4j/util/BiConsumer.java | 39 -
.../java/org/apache/logging/log4j/util/Cast.java | 40 -
.../java/org/apache/logging/log4j/util/Chars.java | 88 -
.../org/apache/logging/log4j/util/Constants.java | 145 -
.../log4j/util/ContextAwarePropertySource.java | 195 -
.../apache/logging/log4j/util/EnglishEnums.java | 71 -
.../log4j/util/EnvironmentPropertySource.java | 71 -
.../log4j/util/FilteredObjectInputStream.java | 94 -
.../log4j/util/IndexedReadOnlyStringMap.java | 64 -
.../logging/log4j/util/IndexedStringMap.java | 34 -
.../org/apache/logging/log4j/util/InternalApi.java | 31 -
.../org/apache/logging/log4j/util/LambdaUtil.java | 95 -
.../java/org/apache/logging/log4j/util/Lazy.java | 95 -
.../org/apache/logging/log4j/util/LazyBoolean.java | 66 -
.../org/apache/logging/log4j/util/LazyUtil.java | 214 -
.../org/apache/logging/log4j/util/LoaderUtil.java | 612 ---
.../apache/logging/log4j/util/LowLevelLogUtil.java | 145 -
.../apache/logging/log4j/util/MessageSupplier.java | 44 -
.../util/MultiFormatStringBuilderFormattable.java | 40 -
.../org/apache/logging/log4j/util/NameUtil.java | 76 -
.../logging/log4j/util/PerformanceSensitive.java | 39 -
.../log4j/util/PropertiesPropertySource.java | 92 -
.../apache/logging/log4j/util/PropertiesUtil.java | 1023 -----
.../logging/log4j/util/PropertyEnvironment.java | 445 --
.../log4j/util/PropertyFilePropertySource.java | 54 -
.../apache/logging/log4j/util/PropertySource.java | 257 --
.../logging/log4j/util/ProviderActivator.java | 53 -
.../apache/logging/log4j/util/ProviderUtil.java | 178 -
.../logging/log4j/util/ReadOnlyStringMap.java | 109 -
.../logging/log4j/util/ServiceLoaderUtil.java | 87 -
.../logging/log4j/util/SortedArrayStringMap.java | 473 --
.../apache/logging/log4j/util/StackLocator.java | 127 -
.../logging/log4j/util/StackLocatorUtil.java | 129 -
.../apache/logging/log4j/util/StringBuilders.java | 383 --
.../org/apache/logging/log4j/util/StringMap.java | 102 -
.../org/apache/logging/log4j/util/Strings.java | 323 --
.../org/apache/logging/log4j/util/Supplier.java | 44 -
.../log4j/util/SystemPropertiesPropertySource.java | 154 -
.../org/apache/logging/log4j/util/TimeUnit.java | 58 -
.../org/apache/logging/log4j/util/TriConsumer.java | 39 -
.../java/org/apache/logging/log4j/util/Unbox.java | 236 -
.../apache/logging/log4j/util/package-info.java | 27 -
.../src/main/resources/Log4j-charsets.properties | 50 -
.../src/main/resources/log4j2.propertyMapping.json | 64 -
.../logging/log4j/async/logger/AsyncLogger.java | 128 +-
.../log4j/async/logger/AsyncLoggerConfig.java | 74 +-
.../async/logger/AsyncLoggerConfigDelegate.java | 10 -
.../async/logger/AsyncLoggerConfigDisruptor.java | 116 +-
.../log4j/async/logger/AsyncLoggerContext.java | 106 +-
.../async/logger/AsyncLoggerContextSelector.java | 6 +-
.../log4j/async/logger/AsyncLoggerDisruptor.java | 34 +-
.../log4j/async/logger/AsyncLoggerKeys.java | 75 +
.../async/logger/AsyncWaitStrategyFactory.java | 9 +-
.../logger/BasicAsyncLoggerContextSelector.java | 8 +-
.../logger/DefaultAsyncWaitStrategyFactory.java | 85 -
.../log4j/async/logger/DisruptorConfiguration.java | 63 +-
.../logging/log4j/async/logger/DisruptorUtil.java | 128 -
.../log4j/async/logger/RingBufferLogEvent.java | 6 +
.../async/logger/RingBufferLogEventTranslator.java | 87 +-
.../internal/DefaultAsyncWaitStrategyFactory.java | 75 +
.../log4j/async/logger/internal/DefaultBundle.java | 73 +
.../log4j/async/logger/internal/DisruptorUtil.java | 94 +
.../internal/InstanceFactoryPostProcessor.java | 13 +-
.../TimeoutBlockingWaitStrategy.java | 5 +-
.../logger/AsyncLoggerClassLoadDeadlockTest.java | 2 +-
.../logger/AsyncLoggerConfigAutoFlushTest.java | 13 +-
.../logger/AsyncLoggerConfigErrorOnFormat.java | 8 +-
.../log4j/async/logger/AsyncLoggerConfigTest.java | 3 +-
.../log4j/async/logger/AsyncLoggerContextTest.java | 13 +-
.../AsyncLoggerCustomSelectorLocationTest.java | 4 +-
.../AsyncLoggerEventTranslationExceptionTest.java | 10 +-
.../AsyncLoggerTestArgumentFreedOnErrorTest.java | 8 +-
.../log4j/async/logger/AsyncThreadContextTest.java | 18 +-
.../async/logger/DefaultIncludeLocationTest.java | 9 +-
.../logger/DisruptorConfigurationInvalidTest.java | 1 +
.../async/logger/DisruptorConfigurationTest.java | 7 +-
.../async/logger/QueueFullAsyncAbstractTest.java | 8 +-
.../async/logger/QueueFullAsyncLogger2Test.java | 4 +-
.../async/logger/QueueFullAsyncLogger3Test.java | 9 +-
.../logger/QueueFullAsyncLoggerConfig2Test.java | 4 +-
...lAsyncLoggerConfigLoggingFromToString2Test.java | 4 +-
...llAsyncLoggerConfigLoggingFromToStringTest.java | 8 +-
.../logger/QueueFullAsyncLoggerConfigTest.java | 4 +-
...ueueFullAsyncLoggerLoggingFromToStringTest.java | 4 +-
.../async/logger/QueueFullAsyncLoggerTest.java | 4 +-
.../log4j/async/logger/RingBufferLogEventTest.java | 11 +-
.../config/properties/JavaPropsConfiguration.java | 7 +-
.../properties/JavaPropsConfigurationFactory.java | 2 +-
.../log4j/config/yaml/YamlConfiguration.java | 1 +
.../config/yaml/YamlConfigurationFactory.java | 2 +-
.../log4j/core/test/BasicConfigurationFactory.java | 19 +-
.../logging/log4j/core/test/TestConstants.java | 127 +
.../config/AbstractNestedLoggerConfigTest.java | 7 +-
.../test/junit/AbstractExternalFileCleaner.java | 2 +-
.../logging/log4j/core}/test/junit/CleanFiles.java | 2 +-
.../log4j/core}/test/junit/CleanFolders.java | 2 +-
.../core/test/junit/ConfigurationFactoryType.java | 3 +-
.../log4j/core/test/junit/Log4jExtension.java | 74 +-
.../log4j/core/test/junit/LoggerContextRule.java | 2 -
.../logging/log4j/core/test/junit/Named.java | 6 +-
.../log4j/core/test/layout/Log4j2_1482_Test.java | 2 +-
.../log4j/core/EventParameterMemoryLeakTest.java | 8 +-
.../apache/logging/log4j/core/Log4j1222Test.java | 6 +-
.../logging/log4j/core/LoggerContextTest.java | 46 -
.../org/apache/logging/log4j/core/LoggerTest.java | 31 +-
.../log4j/core/appender/ConsoleAppenderTest.java | 6 +-
.../core/appender/OutputStreamManagerTest.java | 3 +
.../core/appender/ReconfigureAppenderTest.java | 8 +-
.../appender/rolling/RollingAppenderCronTest.java | 5 +-
.../RollingAppenderDirectWriteStartupSizeTest.java | 2 +-
...llingAppenderDirectWriteWithHtmlLayoutTest.java | 2 +-
.../RollingFileAppenderInterruptedThreadTest.java | 2 +-
.../rolling/action/AbstractActionTest.java | 7 +-
.../async/AsyncAppenderConfigTest_LOG4J2_2032.java | 15 +-
.../async/AsyncQueueFullPolicyFactoryTest.java | 99 +-
.../logging/log4j/core/config/AdvertiserTest.java | 6 +-
.../config/CompositeConfigurationMissingTest.java | 8 +-
.../log4j/core/config/JiraLog4j2_2134Test.java | 5 +-
.../LoggerContextAwarePostProcessorTest.java | 5 +-
.../log4j/core/config/LoggersPluginTest.java | 5 +-
.../log4j/core/config/ReliabilityStrategyTest.java | 8 +-
.../log4j/core/config/TestConfigurator.java | 6 +-
.../log4j/core/config/TestConfiguratorError.java | 4 +-
.../ValidatingPluginWithFailoverTest.java | 24 +-
.../core/config/xml/XmlConfigurationPropsTest.java | 8 +-
.../filter/MutableThreadContextMapFilterTest.java | 11 +-
...taFactoryPropertySetMissingConstructorTest.java | 17 +-
.../impl/ContextDataFactoryPropertySetTest.java | 7 +-
.../log4j/core/impl/ContextDataFactoryTest.java | 6 +-
.../log4j/core/impl/MutableLogEventTest.java | 6 +-
.../logging/log4j/core/impl/TestPropertyKeys.java | 10 +-
.../core/impl/ThreadContextDataInjectorTest.java | 92 +-
.../logging/log4j/core/layout/HtmlLayoutTest.java | 12 +-
.../log4j/core/lookup/InterpolatorTest.java | 14 +-
.../logging/log4j/core/lookup/MainLookupTest.java | 3 +-
.../log4j/core/lookup/StrSubstitutorTest.java | 77 +-
.../log4j/core/net/UrlConnectionFactoryTest.java | 18 +-
.../core/net/ssl/FilePasswordProviderTest.java | 11 +-
.../core/net/ssl/SslConfigurationFactoryTest.java | 44 +-
.../log4j/core/pattern/PatternParserTest2.java | 6 +-
.../log4j/core/pattern/StyleConverterTest.java | 15 +-
.../selector/ClassLoaderContextSelectorTest.java | 2 +-
.../log4j/core/tools/GenerateCustomLoggerTest.java | 4 +-
.../core/tools/GenerateExtendedLoggerTest.java | 4 +-
.../log4j/core/util/ContextDataProviderTest.java | 4 +-
.../logging/log4j/core/util/JsonUtilsTest.java | 68 -
.../util/NamedLoggerContextPropertiesTest.java | 12 +-
.../core/util/ShutdownCallbackRegistryTest.java | 3 +
.../logging/log4j/core/util/WatchHttpTest.java | 9 +-
.../logging/log4j/core/util/WatchManagerTest.java | 7 +-
.../MutableThreadContextMapFilterTest.xml | 3 +-
log4j-core/pom.xml | 9 +-
.../logging/log4j/core/AbstractLogEvent.java | 6 +
.../org/apache/logging/log4j/core/LogEvent.java | 29 +-
.../java/org/apache/logging/log4j/core/Logger.java | 79 +-
.../apache/logging/log4j/core/LoggerContext.java | 343 +-
.../core/annotation/OnPropertyKeyCondition.java | 51 -
.../log4j/core/annotation/package-info.java | 22 -
.../logging/log4j/core/appender/AsyncAppender.java | 8 +-
.../log4j/core/appender/ConsoleAppender.java | 40 +-
.../core/appender/MemoryMappedFileManager.java | 2 +-
.../log4j/core/appender/SyslogAppender.java | 6 +-
.../core/appender/rewrite/RewriteAppender.java | 3 +-
.../appender/rolling/DefaultRolloverStrategy.java | 2 +-
.../core/async/AsyncQueueFullPolicyFactory.java | 26 +-
.../log4j/core/async/InternalAsyncUtil.java | 34 +
.../log4j/core/config/AbstractConfiguration.java | 116 +-
.../AwaitUnconditionallyReliabilityStrategy.java | 12 +-
.../logging/log4j/core/config/Configuration.java | 12 +-
.../config/ConfigurationAwarePostProcessor.java | 2 +-
.../log4j/core/config/ConfigurationFactory.java | 76 +-
.../log4j/core/config/ConfigurationScheduler.java | 5 +-
.../log4j/core/config/ConfigurationSource.java | 10 +-
.../logging/log4j/core/config/Configurator.java | 2 +-
.../log4j/core/config/DefaultConfiguration.java | 17 +-
.../core/config/DefaultConfigurationFactory.java | 146 +-
.../logging/log4j/core/config/HttpWatcher.java | 4 +-
.../logging/log4j/core/config/LoggerConfig.java | 179 +-
.../config/LoggerContextAwarePostProcessor.java | 2 +-
.../log4j/core/config/NullConfiguration.java | 11 +-
.../core/config/ReliabilityStrategyFactory.java | 13 +-
.../log4j/core/config/URIConfigurationFactory.java | 86 +
.../config/builder/impl/BuiltConfiguration.java | 16 +-
.../config/composite/CompositeConfiguration.java | 14 +-
.../log4j/core/config/json/JsonConfiguration.java | 2 +-
.../util/LegacyPluginAttributeFactoryResolver.java | 2 +-
...egacyPluginBuilderAttributeFactoryResolver.java | 2 +-
.../plugins/util/PluginAttributeNameProvider.java | 6 +-
.../util/PluginBuilderAttributeNameProvider.java | 6 +-
.../plugins/util/PluginElementNameProvider.java | 6 +-
.../plugins/util/PluginValueNameProvider.java | 6 +-
.../core/config/plugins/util/package-info.java | 2 +-
.../log4j/core/config/xml/XmlConfiguration.java | 19 +-
.../core/config/xml/XmlConfigurationFactory.java | 2 +-
.../core/filter/MutableThreadContextMapFilter.java | 8 +-
.../log4j/core/filter/StructuredDataFilter.java | 4 +-
.../log4j/core/impl/ContextDataFactory.java | 23 +-
.../core/impl/ContextDataInjectorFactory.java | 13 +-
.../apache/logging/log4j/core/impl/CoreKeys.java | 221 +
.../logging/log4j/core/impl/DefaultBundle.java | 102 +-
.../log4j/core/impl/Log4jContextFactory.java | 121 +-
.../impl/Log4jInstanceFactoryPostProcessor.java | 68 +-
.../logging/log4j/core/impl/Log4jLogEvent.java | 23 +-
.../logging/log4j/core/impl/Log4jPropertyKey.java | 457 --
.../logging/log4j/core/impl/Log4jProvider.java | 48 +-
.../logging/log4j/core/impl/MementoLogEvent.java | 79 +-
.../logging/log4j/core/impl/MutableLogEvent.java | 46 +-
.../log4j/core/impl/ReusableLogEventFactory.java | 4 +-
.../log4j/core/impl/SystemPropertyBundle.java | 110 -
.../log4j/core/impl/ThreadContextDataInjector.java | 12 +-
.../log4j/core/impl/internal/Activator.java | 17 +-
.../core/impl/internal/InternalLoggerContext.java | 311 --
.../impl/internal}/ReusableMessageFactory.java | 99 +-
.../log4j/core/layout/AbstractStringLayout.java | 13 +-
.../logging/log4j/core/layout/HtmlLayout.java | 10 -
.../logging/log4j/core/layout/PatternLayout.java | 18 +-
.../log4j/core/layout/StringBuilderEncoder.java | 2 +-
.../logging/log4j/core/lookup/Interpolator.java | 47 +-
.../log4j/core/net/UrlConnectionFactory.java | 11 +-
.../log4j/core/net/ssl/FilePasswordProvider.java | 9 +-
.../log4j/core/net/ssl/KeyStoreConfiguration.java | 15 +-
.../core/net/ssl/SslConfigurationFactory.java | 85 +-
.../core/net/ssl/TrustStoreConfiguration.java | 17 +-
.../log4j/core/pattern/DatePatternConverter.java | 2 +-
.../logging/log4j/core/pattern/PatternParser.java | 1 +
.../core/selector/AbstractContextSelector.java | 35 +-
.../log4j/core/selector/BasicContextSelector.java | 8 +-
.../core/selector/ClassLoaderContextSelector.java | 34 +-
.../logging/log4j/core/time/ClockFactory.java | 12 +-
.../log4j/core/time/internal/SystemClock.java | 10 +-
.../apache/logging/log4j/core/tools/Generate.java | 8 +-
.../log4j/core/util/AuthorizationProvider.java | 23 +-
.../core/util/BasicAuthorizationProvider.java | 23 +-
.../apache/logging/log4j/core/util/Constants.java | 77 +-
.../apache/logging/log4j/core/util/JsonUtils.java | 117 -
.../org/apache/logging/log4j/core/util/Loader.java | 11 +-
.../logging/log4j/core/util/OptionConverter.java | 4 +-
.../apache/logging/log4j/core/util/UuidUtil.java | 8 +-
.../logging/log4j/core/util/WatchManager.java | 9 +-
.../core/util/internal/HttpInputStreamUtil.java | 2 +-
.../log4j/csv/layout/CsvLogEventLayout.java | 2 +-
.../log4j/csv/layout/CsvParameterLayout.java | 2 +-
.../csv/layout/CsvParameterLayoutAllAsyncTest.java | 15 +-
.../apache/logging/log4j/docker/DockerLookup.java | 5 +-
.../log4j/flume/appender/FlumeAppender.java | 9 +-
.../log4j/flume/appender/FlumeEmbeddedManager.java | 32 +-
.../logging/log4j/flume/appender/FlumeEvent.java | 6 +
.../log4j/flume/appender/FlumeAppenderTest.java | 28 +-
.../flume/appender/FlumeEmbeddedAgentTest.java | 6 +-
.../flume/appender/FlumeEmbeddedAppenderTest.java | 6 +-
.../appender/FlumePersistentAppenderTest.java | 6 +-
.../log4j/flume/appender/FlumePersistentPerf.java | 6 +-
log4j-gc-test/pom.xml | 5 +
.../log4j/gctests/GcFreeAsyncLoggingTest.java | 16 +-
.../log4j/gctests/GcFreeLoggingTestUtil.java | 31 +-
.../gctests/GcFreeMixedSyncAsyncLoggingTest.java | 4 +-
.../gctests/GcFreeSynchronousLoggingTest.java | 4 +-
.../gctests/JsonTemplateLayoutGcFreeTest.java | 4 +-
.../jctools/JCToolsRecyclerFactoryProvider.java | 21 +-
.../JCToolsRecyclerFactoryProviderTest.java | 12 +-
...ing.log4j.kit.recycler.RecyclerFactoryProvider} | 0
.../jdbc/appender/DataSourceConnectionSource.java | 3 +-
.../logging/log4j/jdbc/appender/JdbcAppender.java | 2 +-
.../log4j/jdbc/appender/internal/JndiUtil.java | 4 +
.../AbstractJdbcAppenderDataSourceTest.java | 3 +-
.../appender/DataSourceConnectionSourceTest.java | 3 +-
.../JdbcAppenderMapMessageDataSourceTest.java | 3 +-
.../routing/RoutingAppenderWithJndiTest.java | 3 +-
.../log4j/jndi/lookup/InterpolatorTest.java | 32 +-
.../logging/log4j/jndi/lookup/JndiLookupTest.java | 3 +-
.../jndi/lookup/JndiRestrictedLookupTest.java | 3 +-
.../org/apache/logging/log4j/jndi/JNDIKeys.java | 16 +-
.../org/apache/logging/log4j/jndi/JndiManager.java | 12 +-
.../logging/log4j/jndi/lookup/JndiLookup.java | 3 +-
.../log4j/jndi/selector/JndiContextSelector.java | 21 +-
log4j-jul/pom.xml | 2 +-
.../java/org/apache/logging/log4j/jul/JulKeys.java | 16 +-
.../apache/logging/log4j/jul/JulPropertyKey.java | 72 -
.../apache/logging/log4j/jul/LevelConverter.java | 2 +-
.../apache/logging/log4j/jul/LevelTranslator.java | 12 +-
.../org/apache/logging/log4j/jul/LogManager.java | 15 +-
.../logging/log4j/jul/test/ApiLoggerTest.java | 9 +-
.../log4j/jul/test/AsyncLoggerThreadsTest.java | 12 +-
.../apache/logging/log4j/jul/test/JulTestKeys.java | 14 +-
{log4j-sdk => log4j-kit}/pom.xml | 30 +-
.../logging/log4j/kit/env/Log4jProperty.java | 36 +-
.../logging/log4j/kit/env/PropertyEnvironment.java | 187 +
.../logging/log4j/kit/env/PropertySource.java | 30 +-
.../ContextualEnvironmentPropertySource.java | 80 +
.../ContextualJavaPropsPropertySource.java | 65 +
.../PropertiesUtilPropertyEnvironment.java | 51 +
.../log4j/kit/env/internal/package-info.java | 9 +-
.../apache/logging/log4j/kit/env/package-info.java | 9 +-
.../kit/env/support/BasicPropertyEnvironment.java | 337 ++
.../support/ClassLoaderPropertyEnvironment.java | 23 +-
.../env/support/CompositePropertyEnvironment.java | 69 +
.../log4j/kit/env/support/package-info.java | 9 +-
.../apache/logging/log4j/kit/json}/JsonReader.java | 2 +-
.../logging/log4j/kit/json}/package-info.java | 2 +-
.../logging/log4j/kit}/logger/AbstractLogger.java | 145 +-
.../kit}/logger/internal/DefaultLogBuilder.java | 6 +-
.../logging/log4j/kit/logger}/package-info.java | 2 +-
.../log4j/kit/message/RecyclingMessageFactory.java | 29 +-
.../logging/log4j/kit/message}/package-info.java | 2 +-
.../logging/log4j/kit}/recycler/Recycler.java | 2 +-
.../logging/log4j/kit}/recycler/RecyclerAware.java | 5 +-
.../log4j/kit}/recycler/RecyclerFactory.java | 2 +-
.../kit}/recycler/RecyclerFactoryProvider.java | 11 +-
.../logging/log4j/kit/recycler/RecyclerKeys.java | 25 +-
.../log4j/kit/recycler/internal}/ArrayQueue.java | 2 +-
.../internal}/DummyRecyclerFactoryProvider.java | 14 +-
.../internal}/QueueingRecyclerFactoryProvider.java | 17 +-
.../ThreadLocalRecyclerFactoryProvider.java | 35 +-
.../logging/log4j/kit/recycler}/package-info.java | 2 +-
.../kit/recycler/support}/AbstractRecycler.java | 10 +-
.../log4j/kit/recycler/support}/package-info.java | 5 +-
.../log4j/kit/env/TestPropertyEnvironment.java | 24 +-
.../env/internal/AbstractPropertyNamesTest.java | 42 +
.../ContextualEnvironmentPropertySourceTest.java | 31 +-
.../ContextualJavaPropsPropertySourceTest.java | 28 +-
.../PropertiesUtilPropertyEnvironmentTest.java | 51 +
.../env/support/BasicPropertyEnvironmentTest.java | 224 +
.../logging/log4j/kit/json}/JsonReaderTest.java | 3 +-
.../log4j/kit}/logger/AbstractLoggerTest.java | 18 +-
.../logging/log4j/kit/logger/TestListLogger.java | 73 +
.../kit/recycler/internal}/ArrayQueueTest.java | 2 +-
.../internal}/RecyclerFactoryRegistryTest.java | 25 +-
.../recycler/internal/RecyclerFactoryTestUtil.java | 51 +
.../ThreadLocalRecyclerFactoryProviderTest.java | 19 +-
.../kubernetes/KubernetesClientProperties.java | 71 +-
.../JsonTemplateLayoutAdditionalFieldTest.java | 2 +-
.../log4j/layout/template/json/TestHelpers.java | 2 +-
.../json/resolver/CounterResolverTest.java | 2 +-
.../json/resolver/MessageResolverTest.java | 2 +-
.../layout/template/json/JsonTemplateLayout.java | 2 +-
.../template/json/JsonTemplateLayoutDefaults.java | 5 +-
.../json/resolver/CaseConverterResolver.java | 2 +-
.../template/json/resolver/CounterResolver.java | 2 +-
.../resolver/EventAdditionalFieldInterceptor.java | 2 +-
.../json/resolver/MessageParameterResolver.java | 2 +-
.../json/resolver/ReadOnlyStringMapResolver.java | 4 +-
.../json/resolver/StackTraceStringResolver.java | 4 +-
.../template/json/resolver/TemplateResolvers.java | 2 +-
.../log4j/osgi/tests/AbstractLoadBundleTest.java | 34 +-
.../logging/log4j/osgi/tests/CoreOsgiTest.java | 2 +-
.../osgi/tests/CustomConfigurationFactory.java | 2 +-
log4j-perf-test/pom.xml | 4 +
.../json/JsonTemplateLayoutBenchmarkReport.java | 2 +-
.../log4j/perf/jmh/AsyncLoggersBenchmark.java | 10 +-
.../jmh/ConcurrentAsyncLoggerToFileBenchmark.java | 22 +-
.../perf/jmh/FileAppenderThrowableBenchmark.java | 15 +-
.../log4j/perf/jmh/JdbcAppenderBenchmark.java | 6 +-
.../log4j/perf/jmh/ThreadContextBenchmark.java | 6 +-
.../CopyOnWriteOpenHashMapThreadContextMap.java | 8 +-
.../GarbageFreeOpenHashMapThreadContextMap.java | 8 +-
.../condition/OnPresentBindingsConditionTest.java | 71 +
.../plugins/condition/OnPropertyConditionTest.java | 8 +-
.../log4j/plugins/util/AnnotationUtilTest.java | 1 +
log4j-plugins/pom.xml | 9 +-
.../org/apache/logging/log4j/plugins/Ordered.java | 3 +-
.../log4j/plugins/condition/ConditionContext.java | 5 +-
.../condition/ConditionalOnPresentBindings.java | 18 +-
.../condition/OnPresentBindingsCondition.java | 28 +-
.../plugins/condition/OnPropertyCondition.java | 2 +-
.../plugins/di/ConfigurableInstanceFactory.java | 18 +-
.../org/apache/logging/log4j/plugins/di/DI.java | 8 +-
.../log4j/plugins/di/DefaultInstanceFactory.java | 45 +-
.../org/apache/logging/log4j/plugins/di/Key.java | 4 +-
.../org/apache/logging/log4j/plugins/di/Keys.java | 6 +-
.../logging/log4j/plugins/di/package-info.java | 2 +-
.../resolver/AbstractAttributeFactoryResolver.java | 2 +-
.../di/resolver/OptionalFactoryResolver.java | 2 +-
.../resolver/PluginAttributeFactoryResolver.java | 2 +-
.../PluginBuilderAttributeFactoryResolver.java | 2 +-
.../di/resolver/PluginElementFactoryResolver.java | 2 +-
.../log4j/plugins/di/resolver/package-info.java | 2 +-
.../log4j/plugins/di/spi/DependencyChains.java | 2 +-
.../log4j/plugins/di/spi/ReflectionAgent.java | 4 +-
.../logging/log4j/plugins/di/spi/package-info.java | 2 +-
.../{ => internal}/util/AnnotatedAnnotation.java | 2 +-
.../{ => internal}/util/AnnotationUtil.java | 6 +-
.../log4j/plugins/internal/util/BeanUtils.java | 1 -
.../log4j/plugins/internal/util/BindingMap.java | 2 +-
.../plugins/internal/util/DefaultBindingMap.java | 2 +-
.../log4j/plugins/model/PluginRegistry.java | 67 +-
.../logging/log4j/plugins/model/PluginType.java | 3 +-
.../log4j/plugins/name/CategoryNameProvider.java | 6 +-
.../plugins/name/NamedQualifierNameProvider.java | 6 +-
.../plugins/name/PluginAttributeNameProvider.java | 6 +-
.../name/PluginBuilderAttributeNameProvider.java | 6 +-
.../plugins/name/PluginElementNameProvider.java | 6 +-
.../log4j/plugins/name/PluginNameProvider.java | 5 +-
.../plugins/name/PluginValueNameProvider.java | 6 +-
.../apache/logging/log4j/plugins}/util/Assert.java | 2 +-
.../log4j/plugins}/util/InternalException.java | 2 +-
.../log4j/plugins/util/OrderedComparator.java | 1 +
.../log4j/plugins}/util/ReflectionUtil.java | 2 +-
.../logging/log4j/plugins/util/package-info.java | 2 +-
.../validators/RequiredPropertyValidator.java | 4 +-
.../validation/validators/RequiredValidator.java | 2 +-
.../apache/logging/log4j/script/ScriptKeys.java | 21 +-
.../logging/log4j/script/ScriptManagerImpl.java | 7 +-
.../logging/log4j/script/ScriptPropertyKey.java | 80 -
.../script/factory/ScriptManagerFactoryImpl.java | 9 +-
.../apache/logging/log4j/script/TestConstants.java | 11 +-
.../appender/ScriptAppenderSelectorTest.java | 6 +-
.../RollingAppenderDeleteScriptFri13thTest.java | 5 +-
.../rolling/RollingAppenderDeleteScriptTest.java | 5 +-
.../rolling/action/ScriptConditionTest.java | 6 +-
.../routing/DefaultRouteScriptAppenderTest.java | 5 +-
.../appender/routing/RoutesScriptAppenderTest.java | 5 +-
.../log4j/script/config/TestConfigurator.java | 6 +-
.../script/config/arbiter/ScriptArbiterTest.java | 6 +-
.../config/builder/ConfigurationAssemblerTest.java | 17 +-
.../filter/ScriptFileFilterPropertiesTest.java | 6 +-
.../log4j/script/filter/ScriptFileFilterTest.java | 6 +-
.../log4j/script/filter/ScriptFilterTest.java | 6 +-
.../log4j/script/filter/ScriptRefFilterTest.java | 6 +-
.../log4j/script/layout/PatternSelectorTest.java | 6 +-
log4j-to-jul/pom.xml | 7 +-
.../org/apache/logging/log4j/tojul/Activator.java | 23 +-
.../apache/logging/log4j/tojul/JULProvider.java | 19 +-
.../apache/logging/log4j/tojul/package-info.java | 2 +-
log4j-to-slf4j/pom.xml | 5 -
.../org/apache/logging/slf4j/SLF4JProvider.java | 18 +-
.../org/apache/logging/slf4j/package-info.java | 2 +-
pom.xml | 13 +-
675 files changed, 5264 insertions(+), 53548 deletions(-)
delete mode 100644 log4j-api-test/pom.xml
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/ListStatusListener.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLogger.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLoggerContext.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLoggerContextFactory.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestProperties.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/ThreadContextHolder.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/ThreadContextUtilityClass.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/Timer.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/AbstractFileCleaner.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ClassMatchers.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpDirectories.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpFiles.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/DirectoryCleaner.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ExtensionContextAnchor.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/FileCleaner.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/InitializesThreadContext.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/LoggerContextFactoryExtension.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Resources.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SetTestProperty.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerExtension.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerLevelExtension.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDir.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDirectory.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertyResolver.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertySource.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextInitializer.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextMapExtension.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextRule.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextStackExtension.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextStackRule.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingAnyThreadContext.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingStatusListener.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingTestProperties.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingThreadContextMap.java
delete mode 100644 log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingThreadContextStack.java
delete mode 100644 log4j-api-test/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource
delete mode 100644 log4j-api-test/src/main/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
delete mode 100644 log4j-api-test/src/main/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/CloseableThreadContextTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/EventLoggerTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/LambdaLoggerTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/LevelTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/LogManagerTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerSupplierTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/MarkerTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/TestProvider.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/ThreadContextInheritanceTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/TraceLoggingTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/internal/DefaultLogBuilderTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/RecyclerFactoryTestUtil.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/FormattedMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/JsonMessage.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageFactoryTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/MessageFormatMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/ObjectMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/ParameterFormatterTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/ParameterizedMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/ReusableMessageFactoryTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/ReusableObjectMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/ReusableParameterizedMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/ReusableSimpleMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/SimpleMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/StringFormattedMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/StructuredDataMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/simple/SimpleLoggerTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/spi/DefaultThreadContextStackTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/spi/LoggerAdapterTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/spi/MutableThreadContextStackTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/status/StatusConsoleListenerTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/test/BetterService.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/test/Service2.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/test/ThreadContextTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/test/junit/TempLoggingDirectoryTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/test/junit/TestPropertySourceTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/AssertTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/CharsTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/ConstantsTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/DeserializerHelper.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/EnvironmentPropertySourceTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/LambdaUtilTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/LazyTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/LegacyPropertiesCompatibilityTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/Log4jCharsetsPropertiesTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesPropertySourceTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesUtilOrderTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertiesUtilTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertySourceCamelCaseTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/PropertySourceTokenizerTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/ProviderUtilTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/ServiceLoaderUtilTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/SortedArrayStringMapTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/StackLocatorUtilTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/StringBuildersTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/StringsTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/SystemPropertiesMain.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/SystemPropertiesPropertySourceTest.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/Unbox1Test.java
delete mode 100644 log4j-api-test/src/test/java/org/apache/logging/log4j/util/Unbox2ConfigurableTest.java
delete mode 100644 log4j-api-test/src/test/resources/Jira3413Test.properties
delete mode 100644 log4j-api-test/src/test/resources/META-INF/log4j2.my-app.json
delete mode 100644 log4j-api-test/src/test/resources/META-INF/services/org.apache.logging.log4j.spi.Provider
delete mode 100644 log4j-api-test/src/test/resources/META-INF/services/org.apache.logging.log4j.test.BetterService
delete mode 100644 log4j-api-test/src/test/resources/META-INF/services/org.apache.logging.log4j.test.Service
delete mode 100644 log4j-api-test/src/test/resources/MF_en_US.properties
delete mode 100644 log4j-api-test/src/test/resources/MF_fr.properties
delete mode 100644 log4j-api-test/src/test/resources/MF_fr_CH.properties
delete mode 100644 log4j-api-test/src/test/resources/PropertiesUtilOrderTest.properties
delete mode 100644 log4j-api-test/src/test/resources/PropertiesUtilTest.json
delete mode 100644 log4j-api-test/src/test/resources/PropertiesUtilTest.properties
delete mode 100644 log4j-api-test/src/test/resources/SF_en_US.properties
delete mode 100644 log4j-api-test/src/test/resources/SF_fr.properties
delete mode 100644 log4j-api-test/src/test/resources/SF_fr_CH.properties
delete mode 100644 log4j-api-test/src/test/resources/log4j2.my-app.json
delete mode 100644 log4j-api-test/src/test/resources/log4j2.propertyMapping.json
delete mode 100644 log4j-api-test/src/test/resources/log4j2.system.properties
delete mode 100644 log4j-api-test/src/test/resources/org/apache/logging/log4j/test/ForceLinkageError.class
delete mode 100644 log4j-api/pom.xml
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/BridgeAware.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/EventLogger.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/Level.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/LogBuilder.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/LoggingException.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/Marker.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/MarkerManager.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/internal/CopyOnWriteNavigableSet.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/internal/DefaultLogBuilder.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/internal/DefaultObjectInputFilter.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/lang/NonNull.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/lang/NullMarked.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/lang/NullUnmarked.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/lang/Nullable.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/lang/package-info.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/AbstractMessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/AsynchronouslyFormattable.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/BasicThreadInformation.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/Clearable.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/DefaultFlowMessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/FlowMessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/FormattedMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/FormattedMessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/LocalizedMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/LocalizedMessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/LoggerNameAwareMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessageJsonFormatter.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/Message.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/MessageCollectionMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFactory2.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/MultiformatMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectArrayMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterConsumer.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterVisitable.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedNoReferenceMessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/StringFormattedMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/StringFormatterMessageFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/StringMapMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataCollectionMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/ThreadInformation.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/message/TimestampMessage.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/package-info.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerConfiguration.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContextFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/simple/package-info.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerAdapter.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/CleanableThreadContextMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/CopyOnWrite.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/CopyOnWriteSortedArrayThreadContextMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextStack.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLogger.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLoggerWrapper.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/GarbageFreeSortedArrayThreadContextMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerAdapter.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerContextFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerContextShutdownAware.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerRegistry.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggingSystem.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggingSystemProperty.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/MessageFactory2Adapter.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/MutableThreadContextStack.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/NoOpThreadContextMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/ObjectThreadContextMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/PropertyComponent.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/Provider.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/ReadOnlyThreadContextMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/StandardLevel.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/Terminable.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextMap2.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextMapFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/recycler/RecyclerFactoryRegistry.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/spi/recycler/package-info.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/status/StatusListener.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLoggerConfiguration.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLoggerFactory.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/status/package-info.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/BiConsumer.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/Cast.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/Chars.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/Constants.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/ContextAwarePropertySource.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/EnglishEnums.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/EnvironmentPropertySource.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/FilteredObjectInputStream.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedReadOnlyStringMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/IndexedStringMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/InternalApi.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/Lazy.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/LazyBoolean.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/LazyUtil.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/LowLevelLogUtil.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/MessageSupplier.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/MultiFormatStringBuilderFormattable.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/NameUtil.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/PerformanceSensitive.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesPropertySource.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/PropertyEnvironment.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/PropertyFilePropertySource.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/PropertySource.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/ProviderActivator.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/ProviderUtil.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/ReadOnlyStringMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/ServiceLoaderUtil.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/SortedArrayStringMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocatorUtil.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilders.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/StringMap.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/Strings.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/Supplier.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/SystemPropertiesPropertySource.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/TimeUnit.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/TriConsumer.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java
delete mode 100644 log4j-api/src/main/java/org/apache/logging/log4j/util/package-info.java
delete mode 100644 log4j-api/src/main/resources/Log4j-charsets.properties
delete mode 100644 log4j-api/src/main/resources/log4j2.propertyMapping.json
create mode 100644 log4j-async-logger/src/main/java/org/apache/logging/log4j/async/logger/AsyncLoggerKeys.java
delete mode 100644 log4j-async-logger/src/main/java/org/apache/logging/log4j/async/logger/DefaultAsyncWaitStrategyFactory.java
delete mode 100644 log4j-async-logger/src/main/java/org/apache/logging/log4j/async/logger/DisruptorUtil.java
create mode 100644 log4j-async-logger/src/main/java/org/apache/logging/log4j/async/logger/internal/DefaultAsyncWaitStrategyFactory.java
create mode 100644 log4j-async-logger/src/main/java/org/apache/logging/log4j/async/logger/internal/DefaultBundle.java
create mode 100644 log4j-async-logger/src/main/java/org/apache/logging/log4j/async/logger/internal/DisruptorUtil.java
copy log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jInstanceFactoryPostProcessor.java => log4j-async-logger/src/main/java/org/apache/logging/log4j/async/logger/internal/InstanceFactoryPostProcessor.java (73%)
rename log4j-async-logger/src/main/java/org/apache/logging/log4j/async/logger/{ => internal}/TimeoutBlockingWaitStrategy.java (96%)
create mode 100644 log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/TestConstants.java
rename {log4j-api-test/src/main/java/org/apache/logging/log4j => log4j-core-test/src/main/java/org/apache/logging/log4j/core}/test/junit/AbstractExternalFileCleaner.java (99%)
rename {log4j-api-test/src/main/java/org/apache/logging/log4j => log4j-core-test/src/main/java/org/apache/logging/log4j/core}/test/junit/CleanFiles.java (97%)
rename {log4j-api-test/src/main/java/org/apache/logging/log4j => log4j-core-test/src/main/java/org/apache/logging/log4j/core}/test/junit/CleanFolders.java (98%)
delete mode 100644 log4j-core-test/src/test/java/org/apache/logging/log4j/core/LoggerContextTest.java
rename log4j-api/src/main/java/org/apache/logging/log4j/message/EntryMessage.java => log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/TestPropertyKeys.java (83%)
delete mode 100644 log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/JsonUtilsTest.java
delete mode 100644 log4j-core/src/main/java/org/apache/logging/log4j/core/annotation/OnPropertyKeyCondition.java
delete mode 100644 log4j-core/src/main/java/org/apache/logging/log4j/core/annotation/package-info.java
create mode 100644 log4j-core/src/main/java/org/apache/logging/log4j/core/config/URIConfigurationFactory.java
create mode 100644 log4j-core/src/main/java/org/apache/logging/log4j/core/impl/CoreKeys.java
delete mode 100644 log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jPropertyKey.java
delete mode 100644 log4j-core/src/main/java/org/apache/logging/log4j/core/impl/SystemPropertyBundle.java
rename log4j-api-test/src/test/java/org/apache/logging/log4j/util/ClassNameLocator.java => log4j-core/src/main/java/org/apache/logging/log4j/core/impl/internal/Activator.java (61%)
delete mode 100644 log4j-core/src/main/java/org/apache/logging/log4j/core/impl/internal/InternalLoggerContext.java
rename {log4j-api/src/main/java/org/apache/logging/log4j/message => log4j-core/src/main/java/org/apache/logging/log4j/core/impl/internal}/ReusableMessageFactory.java (67%)
copy log4j-async-logger/src/main/java/org/apache/logging/log4j/async/logger/BasicAsyncLoggerContextSelector.java => log4j-core/src/main/java/org/apache/logging/log4j/core/selector/AbstractContextSelector.java (54%)
delete mode 100644 log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java
rename log4j-jctools/src/test/resources/META-INF/services/{org.apache.logging.log4j.spi.recycler.RecyclerFactoryProvider => org.apache.logging.log4j.kit.recycler.RecyclerFactoryProvider} (100%)
rename log4j-api-test/src/test/java/org/apache/logging/log4j/util/ClassLocator.java => log4j-jndi/src/main/java/org/apache/logging/log4j/jndi/JNDIKeys.java (74%)
rename log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerContextShutdownEnabled.java => log4j-jul/src/main/java/org/apache/logging/log4j/jul/JulKeys.java (66%)
delete mode 100644 log4j-jul/src/main/java/org/apache/logging/log4j/jul/JulPropertyKey.java
rename log4j-api/src/main/java/org/apache/logging/log4j/message/ExitMessage.java => log4j-jul/src/test/java/org/apache/logging/log4j/jul/test/JulTestKeys.java (81%)
rename {log4j-sdk => log4j-kit}/pom.xml (75%)
rename log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerLevel.java => log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/Log4jProperty.java (64%)
create mode 100644 log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/PropertyEnvironment.java
rename log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java => log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/PropertySource.java (51%)
create mode 100644 log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/internal/ContextualEnvironmentPropertySource.java
create mode 100644 log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/internal/ContextualJavaPropsPropertySource.java
create mode 100644 log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/internal/PropertiesUtilPropertyEnvironment.java
rename log4j-api-test/src/test/java/org/apache/logging/log4j/message/ObjectMapMessage.java => log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/internal/package-info.java (78%)
rename log4j-api-test/src/test/java/org/apache/logging/log4j/test/Service1.java => log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/package-info.java (79%)
create mode 100644 log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/support/BasicPropertyEnvironment.java
rename log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Log4j2LauncherSessionListener.java => log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/support/ClassLoaderPropertyEnvironment.java (57%)
create mode 100644 log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/support/CompositePropertyEnvironment.java
rename log4j-api-test/src/test/java/org/apache/logging/log4j/test/Service.java => log4j-kit/src/main/java/org/apache/logging/log4j/kit/env/support/package-info.java (78%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/util => log4j-kit/src/main/java/org/apache/logging/log4j/kit/json}/JsonReader.java (99%)
rename {log4j-api-test/src/main/java/org/apache/logging/log4j/test => log4j-kit/src/main/java/org/apache/logging/log4j/kit/json}/package-info.java (95%)
rename {log4j-sdk/src/main/java/org/apache/logging/log4j/sdk => log4j-kit/src/main/java/org/apache/logging/log4j/kit}/logger/AbstractLogger.java (95%)
rename {log4j-sdk/src/main/java/org/apache/logging/log4j/sdk => log4j-kit/src/main/java/org/apache/logging/log4j/kit}/logger/internal/DefaultLogBuilder.java (98%)
rename {log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit => log4j-kit/src/main/java/org/apache/logging/log4j/kit/logger}/package-info.java (95%)
rename log4j-api/src/main/java/org/apache/logging/log4j/spi/LocationAwareLogger.java => log4j-kit/src/main/java/org/apache/logging/log4j/kit/message/RecyclingMessageFactory.java (60%)
rename {log4j-sdk/src/main/java/org/apache/logging/log4j/sdk/logger => log4j-kit/src/main/java/org/apache/logging/log4j/kit/message}/package-info.java (95%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/spi => log4j-kit/src/main/java/org/apache/logging/log4j/kit}/recycler/Recycler.java (97%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/spi => log4j-kit/src/main/java/org/apache/logging/log4j/kit}/recycler/RecyclerAware.java (91%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/spi => log4j-kit/src/main/java/org/apache/logging/log4j/kit}/recycler/RecyclerFactory.java (97%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/spi => log4j-kit/src/main/java/org/apache/logging/log4j/kit}/recycler/RecyclerFactoryProvider.java (87%)
rename log4j-api/src/main/java/org/apache/logging/log4j/message/FlowMessage.java => log4j-kit/src/main/java/org/apache/logging/log4j/kit/recycler/RecyclerKeys.java (62%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/internal/recycler => log4j-kit/src/main/java/org/apache/logging/log4j/kit/recycler/internal}/ArrayQueue.java (97%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/internal/recycler => log4j-kit/src/main/java/org/apache/logging/log4j/kit/recycler/internal}/DummyRecyclerFactoryProvider.java (83%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/internal/recycler => log4j-kit/src/main/java/org/apache/logging/log4j/kit/recycler/internal}/QueueingRecyclerFactoryProvider.java (84%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/internal/recycler => log4j-kit/src/main/java/org/apache/logging/log4j/kit/recycler/internal}/ThreadLocalRecyclerFactoryProvider.java (79%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/spi => log4j-kit/src/main/java/org/apache/logging/log4j/kit/recycler}/package-info.java (95%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/spi/recycler => log4j-kit/src/main/java/org/apache/logging/log4j/kit/recycler/support}/AbstractRecycler.java (81%)
rename {log4j-api/src/main/java/org/apache/logging/log4j/message => log4j-kit/src/main/java/org/apache/logging/log4j/kit/recycler/support}/package-info.java (88%)
copy log4j-api/src/main/java/org/apache/logging/log4j/util/PropertyKey.java => log4j-kit/src/test/java/org/apache/logging/log4j/kit/env/TestPropertyEnvironment.java (54%)
create mode 100644 log4j-kit/src/test/java/org/apache/logging/log4j/kit/env/internal/AbstractPropertyNamesTest.java
rename log4j-api-test/src/test/java/org/apache/logging/log4j/message/ObjectArrayMessageTest.java => log4j-kit/src/test/java/org/apache/logging/log4j/kit/env/internal/ContextualEnvironmentPropertySourceTest.java (50%)
rename log4j-api-test/src/test/java/org/apache/logging/log4j/NoopThreadContextTest.java => log4j-kit/src/test/java/org/apache/logging/log4j/kit/env/internal/ContextualJavaPropsPropertySourceTest.java (51%)
create mode 100644 log4j-kit/src/test/java/org/apache/logging/log4j/kit/env/internal/PropertiesUtilPropertyEnvironmentTest.java
create mode 100644 log4j-kit/src/test/java/org/apache/logging/log4j/kit/env/support/BasicPropertyEnvironmentTest.java
rename {log4j-core-test/src/test/java/org/apache/logging/log4j/core/util => log4j-kit/src/test/java/org/apache/logging/log4j/kit/json}/JsonReaderTest.java (99%)
rename {log4j-sdk/src/test/java/org/apache/logging/log4j/sdk => log4j-kit/src/test/java/org/apache/logging/log4j/kit}/logger/AbstractLoggerTest.java (72%)
create mode 100644 log4j-kit/src/test/java/org/apache/logging/log4j/kit/logger/TestListLogger.java
rename {log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler => log4j-kit/src/test/java/org/apache/logging/log4j/kit/recycler/internal}/ArrayQueueTest.java (98%)
rename {log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler => log4j-kit/src/test/java/org/apache/logging/log4j/kit/recycler/internal}/RecyclerFactoryRegistryTest.java (72%)
create mode 100644 log4j-kit/src/test/java/org/apache/logging/log4j/kit/recycler/internal/RecyclerFactoryTestUtil.java
rename {log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler => log4j-kit/src/test/java/org/apache/logging/log4j/kit/recycler/internal}/ThreadLocalRecyclerFactoryProviderTest.java (80%)
create mode 100644 log4j-plugins-test/src/test/java/org/apache/logging/log4j/plugins/condition/OnPresentBindingsConditionTest.java
rename log4j-core/src/main/java/org/apache/logging/log4j/core/annotation/ConditionalOnPropertyKey.java => log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/condition/ConditionalOnPresentBindings.java (69%)
rename log4j-api-test/src/test/java/org/apache/logging/log4j/util/CharsetForNameMain.java => log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/condition/OnPresentBindingsCondition.java (54%)
rename log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/{ => internal}/util/AnnotatedAnnotation.java (95%)
rename log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/{ => internal}/util/AnnotationUtil.java (98%)
rename {log4j-api/src/main/java/org/apache/logging/log4j => log4j-plugins/src/main/java/org/apache/logging/log4j/plugins}/util/Assert.java (98%)
rename {log4j-api/src/main/java/org/apache/logging/log4j => log4j-plugins/src/main/java/org/apache/logging/log4j/plugins}/util/InternalException.java (97%)
rename {log4j-api/src/main/java/org/apache/logging/log4j => log4j-plugins/src/main/java/org/apache/logging/log4j/plugins}/util/ReflectionUtil.java (99%)
rename log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Mutable.java => log4j-script/src/main/java/org/apache/logging/log4j/script/ScriptKeys.java (71%)
delete mode 100644 log4j-script/src/main/java/org/apache/logging/log4j/script/ScriptPropertyKey.java
rename log4j-api/src/main/java/org/apache/logging/log4j/util/ReloadablePropertySource.java => log4j-script/src/test/java/org/apache/logging/log4j/script/TestConstants.java (80%)
rename log4j-api/src/main/java/org/apache/logging/log4j/util/PropertyKey.java => log4j-to-jul/src/main/java/org/apache/logging/log4j/tojul/Activator.java (65%)
(logging-log4j2) 01/01: Remove Log4j API 3.x
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch fix/rollback-log4j-api
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit da5632a2a1b248dff876ddaa82584103413b076d
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Tue Mar 26 06:09:31 2024 +0100
Remove Log4j API 3.x
---
log4j-api-test/pom.xml | 168 -
.../logging/log4j/test/ListStatusListener.java | 43 -
.../org/apache/logging/log4j/test/TestLogger.java | 268 --
.../logging/log4j/test/TestLoggerContext.java | 66 -
.../log4j/test/TestLoggerContextFactory.java | 54 -
.../apache/logging/log4j/test/TestProperties.java | 44 -
.../logging/log4j/test/ThreadContextHolder.java | 78 -
.../log4j/test/ThreadContextUtilityClass.java | 114 -
.../java/org/apache/logging/log4j/test/Timer.java | 294 --
.../log4j/test/junit/AbstractFileCleaner.java | 83 -
.../logging/log4j/test/junit/ClassMatchers.java | 36 -
.../log4j/test/junit/CleanUpDirectories.java | 44 -
.../logging/log4j/test/junit/CleanUpFiles.java | 44 -
.../logging/log4j/test/junit/DirectoryCleaner.java | 74 -
.../log4j/test/junit/ExtensionContextAnchor.java | 108 -
.../logging/log4j/test/junit/FileCleaner.java | 51 -
.../log4j/test/junit/InitializesThreadContext.java | 39 -
.../test/junit/Log4j2LauncherSessionListener.java | 34 -
.../test/junit/LoggerContextFactoryExtension.java | 53 -
.../apache/logging/log4j/test/junit/Mutable.java | 34 -
.../apache/logging/log4j/test/junit/Resources.java | 55 -
.../logging/log4j/test/junit/SetTestProperty.java | 61 -
.../log4j/test/junit/StatusLoggerExtension.java | 203 -
.../log4j/test/junit/StatusLoggerLevel.java | 42 -
.../test/junit/StatusLoggerLevelExtension.java | 48 -
.../org/apache/logging/log4j/test/junit/Tags.java | 33 -
.../logging/log4j/test/junit/TempLoggingDir.java | 45 -
.../log4j/test/junit/TempLoggingDirectory.java | 190 -
.../log4j/test/junit/TestPropertyResolver.java | 68 -
.../log4j/test/junit/TestPropertySource.java | 137 -
.../log4j/test/junit/ThreadContextInitializer.java | 49 -
.../test/junit/ThreadContextMapExtension.java | 44 -
.../log4j/test/junit/ThreadContextRule.java | 80 -
.../test/junit/ThreadContextStackExtension.java | 46 -
.../log4j/test/junit/ThreadContextStackRule.java | 39 -
.../log4j/test/junit/UsingAnyThreadContext.java | 38 -
.../log4j/test/junit/UsingStatusListener.java | 41 -
.../log4j/test/junit/UsingTestProperties.java | 44 -
.../log4j/test/junit/UsingThreadContextMap.java | 43 -
.../log4j/test/junit/UsingThreadContextStack.java | 40 -
.../logging/log4j/test/junit/package-info.java | 22 -
.../apache/logging/log4j/test/package-info.java | 22 -
.../org.apache.logging.log4j.util.PropertySource | 15 -
.../org.junit.jupiter.api.extension.Extension | 15 -
...junit.platform.launcher.LauncherSessionListener | 16 -
.../apache/logging/log4j/AbstractLoggerTest.java | 1472 ------
.../logging/log4j/CloseableThreadContextTest.java | 239 -
.../org/apache/logging/log4j/EventLoggerTest.java | 56 -
.../org/apache/logging/log4j/LambdaLoggerTest.java | 1413 ------
.../java/org/apache/logging/log4j/LevelTest.java | 284 --
.../org/apache/logging/log4j/LogManagerTest.java | 131 -
.../apache/logging/log4j/LoggerSupplierTest.java | 200 -
.../java/org/apache/logging/log4j/LoggerTest.java | 693 ---
.../java/org/apache/logging/log4j/MarkerTest.java | 109 -
.../logging/log4j/NoopThreadContextTest.java | 42 -
.../org/apache/logging/log4j/TestProvider.java | 29 -
.../log4j/ThreadContextInheritanceTest.java | 160 -
.../org/apache/logging/log4j/TraceLoggingTest.java | 381 --
.../log4j/internal/DefaultLogBuilderTest.java | 47 -
.../log4j/internal/recycler/ArrayQueueTest.java | 101 -
.../recycler/RecyclerFactoryRegistryTest.java | 85 -
.../internal/recycler/RecyclerFactoryTestUtil.java | 47 -
.../ThreadLocalRecyclerFactoryProviderTest.java | 114 -
.../log4j/message/FormattedMessageTest.java | 153 -
.../apache/logging/log4j/message/JsonMessage.java | 64 -
.../log4j/message/LocalizedMessageFactoryTest.java | 116 -
.../log4j/message/LocalizedMessageTest.java | 86 -
.../logging/log4j/message/MapMessageTest.java | 330 --
.../log4j/message/MessageFormatMessageTest.java | 115 -
.../log4j/message/ObjectArrayMessageTest.java | 41 -
.../logging/log4j/message/ObjectMapMessage.java | 19 -
.../logging/log4j/message/ObjectMessageTest.java | 80 -
.../log4j/message/ParameterFormatterTest.java | 158 -
.../log4j/message/ParameterizedMessageTest.java | 145 -
.../log4j/message/ReusableMessageFactoryTest.java | 136 -
.../log4j/message/ReusableObjectMessageTest.java | 124 -
.../message/ReusableParameterizedMessageTest.java | 178 -
.../log4j/message/ReusableSimpleMessageTest.java | 124 -
.../logging/log4j/message/SimpleMessageTest.java | 40 -
.../log4j/message/StringFormattedMessageTest.java | 132 -
.../log4j/message/StructuredDataMessageTest.java | 125 -
.../log4j/message/ThreadDumpMessageTest.java | 166 -
.../logging/log4j/simple/SimpleLoggerTest.java | 69 -
.../log4j/spi/DefaultThreadContextStackTest.java | 342 --
.../logging/log4j/spi/LoggerAdapterTest.java | 187 -
.../log4j/spi/MutableThreadContextStackTest.java | 371 --
.../log4j/status/StatusConsoleListenerTest.java | 147 -
.../apache/logging/log4j/test/BetterService.java | 19 -
.../org/apache/logging/log4j/test/Service.java | 19 -
.../org/apache/logging/log4j/test/Service1.java | 19 -
.../org/apache/logging/log4j/test/Service2.java | 19 -
.../logging/log4j/test/ThreadContextTest.java | 184 -
.../log4j/test/junit/TempLoggingDirectoryTest.java | 45 -
.../log4j/test/junit/TestPropertySourceTest.java | 57 -
.../org/apache/logging/log4j/util/AssertTest.java | 53 -
.../org/apache/logging/log4j/util/CharsTest.java | 46 -
.../logging/log4j/util/CharsetForNameMain.java | 37 -
.../apache/logging/log4j/util/ClassLocator.java | 27 -
.../logging/log4j/util/ClassNameLocator.java | 27 -
.../apache/logging/log4j/util/ConstantsTest.java | 32 -
.../logging/log4j/util/DeserializerHelper.java | 48 -
.../log4j/util/EnvironmentPropertySourceTest.java | 47 -
.../apache/logging/log4j/util/LambdaUtilTest.java | 117 -
.../org/apache/logging/log4j/util/LazyTest.java | 187 -
.../util/LegacyPropertiesCompatibilityTest.java | 82 -
.../apache/logging/log4j/util/LoaderUtilTest.java | 61 -
.../log4j/util/Log4jCharsetsPropertiesTest.java | 47 -
.../log4j/util/PropertiesPropertySourceTest.java | 47 -
.../log4j/util/PropertiesUtilOrderTest.java | 146 -
.../logging/log4j/util/PropertiesUtilTest.java | 228 -
.../log4j/util/PropertySourceCamelCaseTest.java | 43 -
.../log4j/util/PropertySourceTokenizerTest.java | 61 -
.../logging/log4j/util/ProviderUtilTest.java | 51 -
.../logging/log4j/util/ServiceLoaderUtilTest.java | 70 -
.../log4j/util/SortedArrayStringMapTest.java | 993 ----
.../logging/log4j/util/StackLocatorUtilTest.java | 169 -
.../logging/log4j/util/StringBuildersTest.java | 93 -
.../org/apache/logging/log4j/util/StringsTest.java | 89 -
.../logging/log4j/util/SystemPropertiesMain.java | 48 -
.../util/SystemPropertiesPropertySourceTest.java | 68 -
.../org/apache/logging/log4j/util/Unbox1Test.java | 187 -
.../logging/log4j/util/Unbox2ConfigurableTest.java | 81 -
.../src/test/resources/Jira3413Test.properties | 34 -
.../src/test/resources/META-INF/log4j2.my-app.json | 16 -
.../src/test/resources/MF_en_US.properties | 19 -
log4j-api-test/src/test/resources/MF_fr.properties | 19 -
.../src/test/resources/MF_fr_CH.properties | 18 -
.../resources/PropertiesUtilOrderTest.properties | 26 -
.../src/test/resources/PropertiesUtilTest.json | 25 -
.../test/resources/PropertiesUtilTest.properties | 32 -
.../src/test/resources/SF_en_US.properties | 19 -
log4j-api-test/src/test/resources/SF_fr.properties | 19 -
.../src/test/resources/SF_fr_CH.properties | 18 -
.../src/test/resources/log4j2.my-app.json | 16 -
.../src/test/resources/log4j2.propertyMapping.json | 96 -
.../src/test/resources/log4j2.system.properties | 17 -
.../logging/log4j/test/ForceLinkageError.class | 0
log4j-api/pom.xml | 55 -
.../java/org/apache/logging/log4j/BridgeAware.java | 33 -
.../logging/log4j/CloseableThreadContext.java | 227 -
.../java/org/apache/logging/log4j/EventLogger.java | 58 -
.../main/java/org/apache/logging/log4j/Level.java | 366 --
.../java/org/apache/logging/log4j/LogBuilder.java | 299 --
.../java/org/apache/logging/log4j/LogManager.java | 683 ---
.../main/java/org/apache/logging/log4j/Logger.java | 4788 --------------------
.../org/apache/logging/log4j/LoggingException.java | 56 -
.../main/java/org/apache/logging/log4j/Marker.java | 114 -
.../org/apache/logging/log4j/MarkerManager.java | 389 --
.../org/apache/logging/log4j/ThreadContext.java | 570 ---
.../log4j/internal/CopyOnWriteNavigableSet.java | 269 --
.../logging/log4j/internal/DefaultLogBuilder.java | 415 --
.../log4j/internal/DefaultObjectInputFilter.java | 92 -
.../log4j/internal/recycler/ArrayQueue.java | 100 -
.../recycler/DummyRecyclerFactoryProvider.java | 81 -
.../recycler/QueueingRecyclerFactoryProvider.java | 106 -
.../ThreadLocalRecyclerFactoryProvider.java | 124 -
.../org/apache/logging/log4j/lang/NonNull.java | 35 -
.../org/apache/logging/log4j/lang/NullMarked.java | 36 -
.../apache/logging/log4j/lang/NullUnmarked.java | 37 -
.../org/apache/logging/log4j/lang/Nullable.java | 36 -
.../apache/logging/log4j/lang/package-info.java | 28 -
.../log4j/message/AbstractMessageFactory.java | 26 -
.../log4j/message/AsynchronouslyFormattable.java | 59 -
.../log4j/message/BasicThreadInformation.java | 106 -
.../apache/logging/log4j/message/Clearable.java | 31 -
.../log4j/message/DefaultFlowMessageFactory.java | 261 --
.../apache/logging/log4j/message/EntryMessage.java | 26 -
.../apache/logging/log4j/message/ExitMessage.java | 26 -
.../apache/logging/log4j/message/FlowMessage.java | 39 -
.../logging/log4j/message/FlowMessageFactory.java | 87 -
.../logging/log4j/message/FormattedMessage.java | 237 -
.../log4j/message/FormattedMessageFactory.java | 176 -
.../logging/log4j/message/LocalizedMessage.java | 260 --
.../log4j/message/LocalizedMessageFactory.java | 92 -
.../log4j/message/LoggerNameAwareMessage.java | 34 -
.../apache/logging/log4j/message/MapMessage.java | 756 ----
.../log4j/message/MapMessageJsonFormatter.java | 394 --
.../org/apache/logging/log4j/message/Message.java | 97 -
.../log4j/message/MessageCollectionMessage.java | 23 -
.../logging/log4j/message/MessageFactory.java | 281 --
.../logging/log4j/message/MessageFactory2.java | 26 -
.../log4j/message/MessageFormatMessage.java | 142 -
.../log4j/message/MessageFormatMessageFactory.java | 177 -
.../logging/log4j/message/MultiformatMessage.java | 42 -
.../logging/log4j/message/ObjectArrayMessage.java | 118 -
.../logging/log4j/message/ObjectMessage.java | 128 -
.../logging/log4j/message/ParameterConsumer.java | 41 -
.../logging/log4j/message/ParameterFormatter.java | 624 ---
.../logging/log4j/message/ParameterVisitable.java | 45 -
.../log4j/message/ParameterizedMessage.java | 302 --
.../ParameterizedNoReferenceMessageFactory.java | 105 -
.../logging/log4j/message/ReusableMessage.java | 81 -
.../log4j/message/ReusableMessageFactory.java | 239 -
.../log4j/message/ReusableObjectMessage.java | 137 -
.../message/ReusableParameterizedMessage.java | 391 --
.../log4j/message/ReusableSimpleMessage.java | 111 -
.../logging/log4j/message/SimpleMessage.java | 144 -
.../log4j/message/SimpleMessageFactory.java | 191 -
.../log4j/message/StringFormattedMessage.java | 152 -
.../message/StringFormatterMessageFactory.java | 189 -
.../logging/log4j/message/StringMapMessage.java | 67 -
.../message/StructuredDataCollectionMessage.java | 100 -
.../logging/log4j/message/StructuredDataId.java | 268 --
.../log4j/message/StructuredDataMessage.java | 518 ---
.../logging/log4j/message/ThreadDumpMessage.java | 143 -
.../logging/log4j/message/ThreadInformation.java | 36 -
.../logging/log4j/message/TimestampMessage.java | 29 -
.../apache/logging/log4j/message/package-info.java | 26 -
.../org/apache/logging/log4j/package-info.java | 44 -
.../apache/logging/log4j/simple/SimpleLogger.java | 330 --
.../log4j/simple/SimpleLoggerConfiguration.java | 80 -
.../logging/log4j/simple/SimpleLoggerContext.java | 130 -
.../log4j/simple/SimpleLoggerContextFactory.java | 59 -
.../apache/logging/log4j/simple/package-info.java | 27 -
.../apache/logging/log4j/spi/AbstractLogger.java | 3760 ---------------
.../logging/log4j/spi/AbstractLoggerAdapter.java | 149 -
.../log4j/spi/CleanableThreadContextMap.java | 28 -
.../org/apache/logging/log4j/spi/CopyOnWrite.java | 25 -
.../CopyOnWriteSortedArrayThreadContextMap.java | 252 --
.../log4j/spi/DefaultThreadContextStack.java | 319 --
.../apache/logging/log4j/spi/ExtendedLogger.java | 668 ---
.../logging/log4j/spi/ExtendedLoggerWrapper.java | 281 --
.../GarbageFreeSortedArrayThreadContextMap.java | 255 --
.../apache/logging/log4j/spi/LoggerAdapter.java | 38 -
.../apache/logging/log4j/spi/LoggerContext.java | 178 -
.../logging/log4j/spi/LoggerContextFactory.java | 123 -
.../log4j/spi/LoggerContextShutdownAware.java | 26 -
.../log4j/spi/LoggerContextShutdownEnabled.java | 29 -
.../apache/logging/log4j/spi/LoggerRegistry.java | 188 -
.../apache/logging/log4j/spi/LoggingSystem.java | 242 -
.../logging/log4j/spi/LoggingSystemProperty.java | 490 --
.../logging/log4j/spi/MessageFactory2Adapter.java | 157 -
.../log4j/spi/MutableThreadContextStack.java | 255 --
.../logging/log4j/spi/NoOpThreadContextMap.java | 80 -
.../logging/log4j/spi/ObjectThreadContextMap.java | 28 -
.../logging/log4j/spi/PropertyComponent.java | 87 -
.../org/apache/logging/log4j/spi/Provider.java | 372 --
.../log4j/spi/ReadOnlyThreadContextMap.java | 96 -
.../apache/logging/log4j/spi/StandardLevel.java | 103 -
.../org/apache/logging/log4j/spi/Terminable.java | 32 -
.../apache/logging/log4j/spi/ThreadContextMap.java | 175 -
.../logging/log4j/spi/ThreadContextMap2.java | 28 -
.../logging/log4j/spi/ThreadContextStack.java | 26 -
.../org/apache/logging/log4j/spi/package-info.java | 26 -
.../log4j/spi/recycler/AbstractRecycler.java | 40 -
.../logging/log4j/spi/recycler/Recycler.java | 48 -
.../logging/log4j/spi/recycler/RecyclerAware.java | 25 -
.../log4j/spi/recycler/RecyclerFactory.java | 58 -
.../spi/recycler/RecyclerFactoryProvider.java | 59 -
.../spi/recycler/RecyclerFactoryRegistry.java | 119 -
.../logging/log4j/spi/recycler/package-info.java | 26 -
.../log4j/status/StatusConsoleListener.java | 132 -
.../apache/logging/log4j/status/StatusData.java | 158 -
.../logging/log4j/status/StatusListener.java | 39 -
.../apache/logging/log4j/status/StatusLogger.java | 435 --
.../log4j/status/StatusLoggerConfiguration.java | 58 -
.../logging/log4j/status/StatusLoggerFactory.java | 54 -
.../apache/logging/log4j/status/package-info.java | 26 -
.../org/apache/logging/log4j/util/BiConsumer.java | 39 -
.../java/org/apache/logging/log4j/util/Cast.java | 40 -
.../java/org/apache/logging/log4j/util/Chars.java | 88 -
.../org/apache/logging/log4j/util/Constants.java | 104 -
.../log4j/util/ContextAwarePropertySource.java | 195 -
.../apache/logging/log4j/util/EnglishEnums.java | 71 -
.../log4j/util/EnvironmentPropertySource.java | 71 -
.../log4j/util/FilteredObjectInputStream.java | 94 -
.../log4j/util/IndexedReadOnlyStringMap.java | 64 -
.../logging/log4j/util/IndexedStringMap.java | 34 -
.../org/apache/logging/log4j/util/InternalApi.java | 31 -
.../org/apache/logging/log4j/util/LambdaUtil.java | 95 -
.../java/org/apache/logging/log4j/util/Lazy.java | 95 -
.../org/apache/logging/log4j/util/LazyBoolean.java | 66 -
.../org/apache/logging/log4j/util/LazyUtil.java | 214 -
.../org/apache/logging/log4j/util/LoaderUtil.java | 508 ---
.../apache/logging/log4j/util/LowLevelLogUtil.java | 145 -
.../apache/logging/log4j/util/MessageSupplier.java | 36 -
.../util/MultiFormatStringBuilderFormattable.java | 40 -
.../logging/log4j/util/PerformanceSensitive.java | 39 -
.../log4j/util/PropertiesPropertySource.java | 92 -
.../apache/logging/log4j/util/PropertiesUtil.java | 997 ----
.../logging/log4j/util/PropertyEnvironment.java | 445 --
.../log4j/util/PropertyFilePropertySource.java | 54 -
.../org/apache/logging/log4j/util/PropertyKey.java | 35 -
.../apache/logging/log4j/util/PropertySource.java | 341 --
.../logging/log4j/util/ReadOnlyStringMap.java | 109 -
.../log4j/util/ReloadablePropertySource.java | 25 -
.../logging/log4j/util/ServiceLoaderUtil.java | 94 -
.../logging/log4j/util/SortedArrayStringMap.java | 473 --
.../apache/logging/log4j/util/StackLocator.java | 127 -
.../logging/log4j/util/StackLocatorUtil.java | 129 -
.../log4j/util/StringBuilderFormattable.java | 35 -
.../apache/logging/log4j/util/StringBuilders.java | 383 --
.../org/apache/logging/log4j/util/StringMap.java | 102 -
.../org/apache/logging/log4j/util/Strings.java | 323 --
.../org/apache/logging/log4j/util/Supplier.java | 35 -
.../log4j/util/SystemPropertiesPropertySource.java | 154 -
.../org/apache/logging/log4j/util/TimeUnit.java | 58 -
.../org/apache/logging/log4j/util/TriConsumer.java | 39 -
.../java/org/apache/logging/log4j/util/Unbox.java | 236 -
.../apache/logging/log4j/util/package-info.java | 27 -
.../src/main/resources/Log4j-charsets.properties | 50 -
.../src/main/resources/log4j2.propertyMapping.json | 64 -
302 files changed, 49676 deletions(-)
diff --git a/log4j-api-test/pom.xml b/log4j-api-test/pom.xml
deleted file mode 100644
index f615fd4121..0000000000
--- a/log4j-api-test/pom.xml
+++ /dev/null
@@ -1,168 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${revision}</version>
- <relativePath>../log4j-parent</relativePath>
- </parent>
-
- <artifactId>log4j-api-test</artifactId>
- <packaging>jar</packaging>
- <name>Apache Log4j API Tests</name>
- <description>The Apache Log4j API Test</description>
- <properties>
- <!-- Ignore less important (high rank) bugs for test artifacts -->
- <spotbugs.maxRank>9</spotbugs.maxRank>
-
- <!--
- ~ OSGi and JPMS options
- -->
- <bnd-module-name>org.apache.logging.log4j.test</bnd-module-name>
- <bnd-extra-package-options>
- org.apache.commons.lang3.*;resolution:=optional,
- <!-- Both JUnit 4 and JUnit 5 are not required -->
- org.junit.*;resolution:=optional,
- org.hamcrest.*;resolution:=optional,
- org.junitpioneer.*;resolution:=optional,
- org.apache.maven.*;resolution:=optional,
- org.codehaus.plexus.util.*;resolution:=optional,
- org.mockito.*;resolution:=optional
- </bnd-extra-package-options>
- <bnd-extra-module-options>
- <!-- Non-transitive static modules -->
- junit;transitive=false,
- org.hamcrest;transitive=false,
- org.junit.jupiter.api;transitive=false,
- org.junitpioneer;transitive=false,
- <!-- Filebased module names: MUST be static -->
- maven.core;substitute="maven-core";transitive=false;static=true,
- maven.model;substitute="maven-model";transitive=false;static=true,
- maven.model.builder;substitute="maven-model-builder";transitive=false;static=true,
- plexus.utils;substitute="plexus-utils";transitive=false;static=true
- </bnd-extra-module-options>
- </properties>
- <!--
- ~ The dependency list has been checked with:
- ~
- ~ ./mvnw dependency:analyze -pl log4j-api-test
- -->
- <dependencies>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.junit-pioneer</groupId>
- <artifactId>junit-pioneer</artifactId>
- </dependency>
- <dependency>
- <groupId>org.junit.platform</groupId>
- <artifactId>junit-platform-commons</artifactId>
- </dependency>
- <dependency>
- <groupId>org.junit.platform</groupId>
- <artifactId>junit-platform-launcher</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opentest4j</groupId>
- <artifactId>opentest4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <!-- Required for JSON support -->
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- <scope>test</scope>
- </dependency>
- <!-- Required for JSON support -->
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-params</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>uk.org.webcompere</groupId>
- <artifactId>system-stubs-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>uk.org.webcompere</groupId>
- <artifactId>system-stubs-jupiter</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <configuration>
- <useModulePath>false</useModulePath>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <useModulePath>false</useModulePath>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-</project>
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ListStatusListener.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ListStatusListener.java
deleted file mode 100644
index fb19e5b7ae..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ListStatusListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test;
-
-import java.util.stream.Stream;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.status.StatusData;
-import org.apache.logging.log4j.status.StatusListener;
-import org.osgi.annotation.versioning.ProviderType;
-
-/**
- * A {@link StatusListener} that collects messages for further inspection.
- */
-@ProviderType
-public interface ListStatusListener extends StatusListener {
-
- void clear();
-
- Stream<StatusData> getStatusData();
-
- default Stream<StatusData> findStatusData(Level level) {
- return getStatusData().filter(data -> level.isLessSpecificThan(data.getLevel()));
- }
-
- default Stream<StatusData> findStatusData(Level level, String regex) {
- return findStatusData(level)
- .filter(data -> data.getMessage().getFormattedMessage().matches(regex));
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLogger.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLogger.java
deleted file mode 100644
index a784637615..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLogger.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.MessageFactory;
-import org.apache.logging.log4j.spi.AbstractLogger;
-
-/**
- *
- */
-public class TestLogger extends AbstractLogger {
-
- private static final long serialVersionUID = 1L;
-
- public TestLogger() {
- super();
- }
-
- public TestLogger(final String name, final MessageFactory messageFactory) {
- super(name, messageFactory);
- }
-
- public TestLogger(final String name) {
- super(name);
- }
-
- private final List<String> list = new ArrayList<>();
-
- public List<String> getEntries() {
- return list;
- }
-
- @Override
- public void logMessage(
- final String fqcn, final Level level, final Marker marker, final Message msg, final Throwable throwable) {
- log(level, marker, fqcn, null, msg, throwable);
- }
-
- @Override
- protected void log(
- final Level level,
- final Marker marker,
- final String fqcn,
- final StackTraceElement location,
- final Message message,
- final Throwable throwable) {
- final StringBuilder sb = new StringBuilder();
- if (marker != null) {
- sb.append(marker);
- }
- sb.append(' ');
- sb.append(level.toString());
- sb.append(' ');
- if (location != null) {
- sb.append(location.toString());
- sb.append(' ');
- }
- sb.append(message.getFormattedMessage());
- final Map<String, String> mdc = ThreadContext.getImmutableContext();
- if (mdc.size() > 0) {
- sb.append(' ');
- sb.append(mdc.toString());
- sb.append(' ');
- }
- final Object[] params = message.getParameters();
- Throwable t;
- if (throwable == null
- && params != null
- && params.length > 0
- && params[params.length - 1] instanceof Throwable) {
- t = (Throwable) params[params.length - 1];
- } else {
- t = throwable;
- }
- if (t != null) {
- sb.append(' ');
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- t.printStackTrace(new PrintStream(baos));
- sb.append(baos.toString());
- }
- list.add(sb.toString());
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String msg) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String msg, final Throwable t) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String msg, final Object... p1) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level, final Marker marker, final String message, final Object p0, final Object p1) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8,
- final Object p9) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final CharSequence msg, final Throwable t) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Object msg, final Throwable t) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Message msg, final Throwable t) {
- return true;
- }
-
- @Override
- public Level getLevel() {
- return Level.ALL;
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLoggerContext.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLoggerContext.java
deleted file mode 100644
index 7b0ae7c7ab..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLoggerContext.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.logging.log4j.message.MessageFactory;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- *
- */
-public class TestLoggerContext implements LoggerContext {
- private final Map<String, ExtendedLogger> map = new ConcurrentHashMap<>();
-
- @Override
- public ExtendedLogger getLogger(final String name) {
- final ExtendedLogger extendedLogger = map.get(name);
- if (extendedLogger != null) {
- return extendedLogger;
- }
- final ExtendedLogger logger = new TestLogger(name);
- map.put(name, logger);
- return logger;
- }
-
- @Override
- public ExtendedLogger getLogger(final String name, final MessageFactory messageFactory) {
- return new TestLogger(name, messageFactory);
- }
-
- @Override
- public Object getExternalContext() {
- return null;
- }
-
- @Override
- public boolean hasLogger(final String name) {
- return false;
- }
-
- @Override
- public boolean hasLogger(final String name, final MessageFactory messageFactory) {
- return false;
- }
-
- @Override
- public boolean hasLogger(final String name, final Class<? extends MessageFactory> messageFactoryClass) {
- return false;
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLoggerContextFactory.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLoggerContextFactory.java
deleted file mode 100644
index 132b04ee70..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestLoggerContextFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test;
-
-import java.net.URI;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-
-/**
- *
- */
-public class TestLoggerContextFactory implements LoggerContextFactory {
-
- private static final LoggerContext context = new TestLoggerContext();
-
- @Override
- public LoggerContext getContext(
- final String fqcn, final ClassLoader loader, final Object externalContext, final boolean currentContext) {
- return context;
- }
-
- @Override
- public LoggerContext getContext(
- final String fqcn,
- final ClassLoader loader,
- final Object externalContext,
- final boolean currentContext,
- final URI configLocation,
- final String name) {
- return context;
- }
-
- @Override
- public void removeContext(final LoggerContext context) {}
-
- @Override
- public boolean isClassLoaderDependent() {
- return false;
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestProperties.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestProperties.java
deleted file mode 100644
index 9942990520..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/TestProperties.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test;
-
-/**
- * A container for per-test properties.
- */
-public interface TestProperties {
-
- /**
- * Path to a directory specific to the test class,
- */
- public static final String LOGGING_PATH = "logging.path";
-
- String getProperty(final String key);
-
- boolean containsProperty(final String key);
-
- void setProperty(final String key, final String value);
-
- default void setProperty(final String key, final boolean value) {
- setProperty(key, value ? "true" : "false");
- }
-
- default void setProperty(final String key, final int value) {
- setProperty(key, Integer.toString(value));
- }
-
- void clearProperty(final String key);
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ThreadContextHolder.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ThreadContextHolder.java
deleted file mode 100644
index 2407e23730..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ThreadContextHolder.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test;
-
-import java.util.Map;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.ThreadContext.ContextStack;
-
-/**
- * Holds an immutable copy of the ThreadContext stack and map.
- *
- * TODO Use LOG4J2-1517 Add ThreadContext.setContext(Map<String, String>)
- *
- * or
- *
- * TODO Might be replaced by something from LOG4J2-1447.
- *
- * or do nothing.
- *
- * @since 2.7
- */
-public class ThreadContextHolder {
-
- private final Map<String, String> immutableContext;
- private final ContextStack immutableStack;
- private final boolean restoreContext;
- private final boolean restoreStack;
-
- /**
- * Constructs a new holder initialized with an immutable copy of the ThreadContext stack and map.
- *
- * @param restoreContext
- * @param restoreStack
- */
- public ThreadContextHolder(final boolean restoreContext, final boolean restoreStack) {
- this.restoreContext = restoreContext;
- this.restoreStack = restoreStack;
- this.immutableContext = restoreContext ? ThreadContext.getImmutableContext() : null;
- this.immutableStack = restoreStack ? ThreadContext.getImmutableStack() : null;
- }
-
- /**
- * Restores the ThreadContext stack and map based on the values saved in the constructor.
- */
- public void restore() {
- if (restoreStack) {
- ThreadContext.setStack(immutableStack);
- }
- if (restoreContext) {
- // TODO LOG4J2-1517 Add ThreadContext.setContext(Map<String, String>)
- // Use:
- // ThreadContext.setContext(immutableContext);
- // Instead of:
- ThreadContext.clearMap();
- ThreadContext.putAll(immutableContext);
- //
- // or:
- // ThreadContext.clearMap();
- // for (Map.Entry<String, String> entry : immutableContext.entrySet()) {
- // ThreadContext.put(entry.getKey(), entry.getValue());
- // }
- }
- }
-}
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
deleted file mode 100644
index 61cd380829..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/ThreadContextUtilityClass.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test;
-
-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;
-
-import java.util.Map;
-import org.apache.logging.log4j.ThreadContext;
-
-public class ThreadContextUtilityClass {
-
- public static void perfTest() {
- ThreadContext.clearMap();
- final Timer complete = new Timer("ThreadContextTest");
- complete.start();
- ThreadContext.put("Var1", "value 1");
- ThreadContext.put("Var2", "value 2");
- ThreadContext.put("Var3", "value 3");
- ThreadContext.put("Var4", "value 4");
- ThreadContext.put("Var5", "value 5");
- ThreadContext.put("Var6", "value 6");
- ThreadContext.put("Var7", "value 7");
- ThreadContext.put("Var8", "value 8");
- ThreadContext.put("Var9", "value 9");
- ThreadContext.put("Var10", "value 10");
- final int loopCount = 1000000;
- final Timer timer = new Timer("ThreadContextCopy", loopCount);
- timer.start();
- for (int i = 0; i < loopCount; ++i) {
- final Map<String, String> map = ThreadContext.getImmutableContext();
- assertNotNull(map);
- }
- timer.stop();
- complete.stop();
- System.out.println(timer.toString());
- System.out.println(complete.toString());
- }
-
- public static void testGetContextReturnsEmptyMapIfEmpty() {
- ThreadContext.clearMap();
- assertTrue(ThreadContext.getContext().isEmpty());
- }
-
- public static void testGetContextReturnsMutableCopy() {
- ThreadContext.clearMap();
- final Map<String, String> map1 = ThreadContext.getContext();
- assertTrue(map1.isEmpty());
- map1.put("K", "val"); // no error
- assertEquals("val", map1.get("K"));
-
- // adding to copy does not affect thread context map
- assertTrue(ThreadContext.getContext().isEmpty());
-
- ThreadContext.put("key", "val2");
- final Map<String, String> map2 = ThreadContext.getContext();
- assertEquals(1, map2.size());
- assertEquals("val2", map2.get("key"));
- map2.put("K", "val"); // no error
- assertEquals("val", map2.get("K"));
-
- // first copy is not affected
- assertNotSame(map1, map2);
- assertEquals(1, map1.size());
- }
-
- public static void testGetImmutableContextReturnsEmptyMapIfEmpty() {
- ThreadContext.clearMap();
- assertTrue(ThreadContext.getImmutableContext().isEmpty());
- }
-
- public static void testGetImmutableContextReturnsImmutableMapIfNonEmpty() {
- ThreadContext.clearMap();
- ThreadContext.put("key", "val");
- final Map<String, String> immutable = ThreadContext.getImmutableContext();
- assertThrows(UnsupportedOperationException.class, () -> immutable.put("otherkey", "otherval"));
- }
-
- public static void testGetImmutableContextReturnsImmutableMapIfEmpty() {
- ThreadContext.clearMap();
- final Map<String, String> immutable = ThreadContext.getImmutableContext();
- assertThrows(UnsupportedOperationException.class, () -> immutable.put("otherkey", "otherval"));
- }
-
- public static void testGetImmutableStackReturnsEmptyStackIfEmpty() {
- ThreadContext.clearStack();
- assertTrue(ThreadContext.getImmutableStack().asList().isEmpty());
- }
-
- public static void testPut() {
- ThreadContext.clearMap();
- assertNull(ThreadContext.get("testKey"));
- ThreadContext.put("testKey", "testValue");
- assertEquals("testValue", ThreadContext.get("testKey"));
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/Timer.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/Timer.java
deleted file mode 100644
index 939e6e527f..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/Timer.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test;
-
-import java.text.DecimalFormat;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import org.apache.logging.log4j.util.StringBuilderFormattable;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Primarily used in unit tests, but can be used to track elapsed time for a request or portion of any other operation
- * so long as all the timer methods are called on the same thread in which it was started. Calling start on
- * multiple threads will cause the times to be aggregated.
- */
-public class Timer implements StringBuilderFormattable {
-
- private final String name; // The timer's name
-
- public enum Status {
- Started,
- Stopped,
- Paused
- }
-
- private Status status; // The timer's status
- private long elapsedTime; // The elapsed time
- private final int iterations;
- private static final long NANO_PER_SECOND = 1000000000L;
- private static final long NANO_PER_MINUTE = NANO_PER_SECOND * 60;
- private static final long NANO_PER_HOUR = NANO_PER_MINUTE * 60;
- private final ThreadLocal<Long> startTime = ThreadLocal.withInitial(() -> 0L);
- private final Lock stateChangeLock = new ReentrantLock();
-
- /**
- * Constructor.
- * @param name the timer name.
- */
- public Timer(final String name) {
- this(name, 0);
- }
-
- /**
- * Constructor.
- *
- * @param name the timer name.
- * @param iterations the number of iterations that will take place.
- */
- public Timer(final String name, final int iterations) {
- this.name = name;
- status = Status.Stopped;
- this.iterations = (iterations > 0) ? iterations : 0;
- }
-
- /**
- * Start the timer.
- */
- public void start() {
- stateChangeLock.lock();
- try {
- startTime.set(System.nanoTime());
- elapsedTime = 0;
- status = Status.Started;
- } finally {
- stateChangeLock.unlock();
- }
- }
-
- public void startOrResume() {
- stateChangeLock.lock();
- try {
- if (status == Status.Stopped) {
- start();
- } else {
- resume();
- }
- } finally {
- stateChangeLock.unlock();
- }
- }
-
- /**
- * Stop the timer.
- * @return the String result of the timer completing.
- */
- public String stop() {
- stateChangeLock.lock();
- try {
- elapsedTime += System.nanoTime() - startTime.get();
- startTime.set(0L);
- status = Status.Stopped;
- return toString();
- } finally {
- stateChangeLock.unlock();
- }
- }
-
- /**
- * Pause the timer.
- */
- public void pause() {
- stateChangeLock.lock();
- try {
- elapsedTime += System.nanoTime() - startTime.get();
- startTime.set(0L);
- status = Status.Paused;
- } finally {
- stateChangeLock.unlock();
- }
- }
-
- /**
- * Resume the timer.
- */
- public void resume() {
- stateChangeLock.lock();
- try {
- startTime.set(System.nanoTime());
- status = Status.Started;
- } finally {
- stateChangeLock.unlock();
- }
- }
-
- /**
- * Accessor for the name.
- * @return the timer's name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Access the elapsed time.
- *
- * @return the elapsed time.
- */
- public long getElapsedTime() {
- return elapsedTime / 1000000;
- }
-
- /**
- * Access the elapsed time.
- *
- * @return the elapsed time.
- */
- public long getElapsedNanoTime() {
- return elapsedTime;
- }
-
- /**
- * Returns the name of the last operation performed on this timer (Start, Stop, Pause or
- * Resume).
- * @return the string representing the last operation performed.
- */
- public Status getStatus() {
- return status;
- }
-
- /**
- * Returns the String representation of the timer based upon its current state
- */
- @Override
- public String toString() {
- final StringBuilder result = new StringBuilder();
- formatTo(result);
- return result.toString();
- }
-
- @Override
- public void formatTo(final StringBuilder buffer) {
- buffer.append("Timer ").append(name);
- switch (status) {
- case Started:
- buffer.append(" started");
- break;
- case Paused:
- buffer.append(" paused");
- break;
- case Stopped:
- long nanoseconds = elapsedTime;
- // Get elapsed hours
- long hours = nanoseconds / NANO_PER_HOUR;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_HOUR;
- // Get minutes
- long minutes = nanoseconds / NANO_PER_MINUTE;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_MINUTE;
- // Get seconds
- long seconds = nanoseconds / NANO_PER_SECOND;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_SECOND;
-
- String elapsed = Strings.EMPTY;
-
- if (hours > 0) {
- elapsed += hours + " hours ";
- }
- if (minutes > 0 || hours > 0) {
- elapsed += minutes + " minutes ";
- }
-
- DecimalFormat numFormat;
- numFormat = new DecimalFormat("#0");
- elapsed += numFormat.format(seconds) + '.';
- numFormat = new DecimalFormat("000000000");
- elapsed += numFormat.format(nanoseconds) + " seconds";
- buffer.append(" stopped. Elapsed time: ").append(elapsed);
- if (iterations > 0) {
- nanoseconds = elapsedTime / iterations;
- // Get elapsed hours
- hours = nanoseconds / NANO_PER_HOUR;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_HOUR;
- // Get minutes
- minutes = nanoseconds / NANO_PER_MINUTE;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_MINUTE;
- // Get seconds
- seconds = nanoseconds / NANO_PER_SECOND;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_SECOND;
-
- elapsed = Strings.EMPTY;
-
- if (hours > 0) {
- elapsed += hours + " hours ";
- }
- if (minutes > 0 || hours > 0) {
- elapsed += minutes + " minutes ";
- }
-
- numFormat = new DecimalFormat("#0");
- elapsed += numFormat.format(seconds) + '.';
- numFormat = new DecimalFormat("000000000");
- elapsed += numFormat.format(nanoseconds) + " seconds";
- buffer.append(" Average per iteration: ").append(elapsed);
- }
- break;
- default:
- buffer.append(' ').append(status);
- break;
- }
- }
-
- @Override
- public boolean equals(final Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof Timer)) {
- return false;
- }
-
- final Timer timer = (Timer) o;
-
- if (elapsedTime != timer.elapsedTime) {
- return false;
- }
- if (startTime != timer.startTime) {
- return false;
- }
- if (name != null ? !name.equals(timer.name) : timer.name != null) {
- return false;
- }
- return status != null ? status.equals(timer.status) : timer.status == null;
- }
-
- @Override
- public int hashCode() {
- int result;
- result = (name != null ? name.hashCode() : 0);
- result = 29 * result + (status != null ? status.hashCode() : 0);
- final long time = startTime.get();
- result = 29 * result + (int) (time ^ (time >>> 32));
- result = 29 * result + (int) (elapsedTime ^ (elapsedTime >>> 32));
- return result;
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/AbstractFileCleaner.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/AbstractFileCleaner.java
deleted file mode 100644
index 113d83976c..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/AbstractFileCleaner.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.LockSupport;
-import java.util.stream.Collectors;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-abstract class AbstractFileCleaner implements BeforeEachCallback {
-
- private static final int MAX_TRIES = Integer.getInteger("log4j2.junit.fileCleanerMaxTries", 10);
-
- private static final int SLEEP_PERIOD_MILLIS = Integer.getInteger("log4j2.junit.fileCleanerSleepPeriodMillis", 200);
- private static final int SLEEP_BASE_PERIOD_MILLIS = SLEEP_PERIOD_MILLIS / MAX_TRIES;
-
- @Override
- public void beforeEach(final ExtensionContext context) throws Exception {
- clean(context);
- }
-
- private void clean(final ExtensionContext context) {
- final Collection<Path> paths = getPathsForTest(context);
- if (paths.isEmpty()) {
- return;
- }
- final Map<Path, IOException> failures = new ConcurrentHashMap<>();
- for (final Path path : paths) {
- if (Files.exists(path)) {
- for (int i = 0, sleepMillis = SLEEP_BASE_PERIOD_MILLIS; i < MAX_TRIES; i++, sleepMillis <<= 1) {
- try {
- if (delete(path)) {
- failures.remove(path);
- break;
- }
- } catch (final IOException e) {
- failures.put(path, e);
- }
- LockSupport.parkNanos(path, TimeUnit.MILLISECONDS.toNanos(sleepMillis));
- if (Thread.interrupted()) {
- failures.put(path, new InterruptedIOException());
- Thread.currentThread().interrupt();
- break;
- }
- }
- }
- }
- if (!failures.isEmpty()) {
- final String message = failures.entrySet().stream()
- .map(e -> e.getKey() + " failed with " + e.getValue())
- .collect(Collectors.joining(", "));
- fail(message);
- }
- }
-
- abstract Collection<Path> getPathsForTest(final ExtensionContext context);
-
- abstract boolean delete(final Path path) throws IOException;
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ClassMatchers.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ClassMatchers.java
deleted file mode 100644
index 4795f74a42..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ClassMatchers.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import org.apache.logging.log4j.util.LoaderUtil;
-import org.hamcrest.CustomTypeSafeMatcher;
-import org.hamcrest.Matcher;
-
-public final class ClassMatchers {
-
- private static final Matcher<String> LOADABLE_CLASS_NAME =
- new CustomTypeSafeMatcher<String>("a loadable class name") {
- @Override
- protected boolean matchesSafely(final String item) {
- return LoaderUtil.isClassAvailable(item);
- }
- };
-
- public static Matcher<String> loadableClassName() {
- return LOADABLE_CLASS_NAME;
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpDirectories.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpDirectories.java
deleted file mode 100644
index 841f6d1fcc..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpDirectories.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.junit.jupiter.api.extension.ExtendWith;
-
-/**
- * JUnit extension to automatically clean up a list of directories and their contents before and after test execution.
- * This will automatically retry deletion up to 10 times per file while pausing for 200ms each time.
- * These can be overridden with system properties {@code log4j2.junit.fileCleanerMaxTries} and
- * {@code log4j2.junit.fileCleanerSleepPeriodMillis}.
- *
- * @see DirectoryCleaner
- * @see CleanUpFiles
- * @since 2.14.0
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Documented
-@Inherited
-@ExtendWith(DirectoryCleaner.class)
-public @interface CleanUpDirectories {
- String[] value();
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpFiles.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpFiles.java
deleted file mode 100644
index 7ab44f6d7b..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpFiles.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.junit.jupiter.api.extension.ExtendWith;
-
-/**
- * JUnit extension to automatically clean up a list of files before and after test execution.
- * This will automatically retry deletion up to 10 times per file while pausing for 200ms each time.
- * These can be overridden with system properties {@code log4j2.junit.fileCleanerMaxTries} and
- * {@code log4j2.junit.fileCleanerSleepPeriodMillis}.
- *
- * @see FileCleaner
- * @see CleanUpDirectories
- * @since 2.14.0
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Documented
-@Inherited
-@ExtendWith(FileCleaner.class)
-public @interface CleanUpFiles {
- String[] value();
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/DirectoryCleaner.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/DirectoryCleaner.java
deleted file mode 100644
index bfb146b0ef..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/DirectoryCleaner.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.io.IOException;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Collection;
-import java.util.HashSet;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-class DirectoryCleaner extends AbstractFileCleaner {
- @Override
- Collection<Path> getPathsForTest(final ExtensionContext context) {
- final Collection<Path> paths = new HashSet<>();
- final CleanUpDirectories testClassAnnotation =
- context.getRequiredTestClass().getAnnotation(CleanUpDirectories.class);
- if (testClassAnnotation != null) {
- for (final String path : testClassAnnotation.value()) {
- paths.add(Paths.get(path));
- }
- }
- final CleanUpDirectories testMethodAnnotation =
- context.getRequiredTestMethod().getAnnotation(CleanUpDirectories.class);
- if (testMethodAnnotation != null) {
- for (final String path : testMethodAnnotation.value()) {
- paths.add(Paths.get(path));
- }
- }
- return paths;
- }
-
- @Override
- boolean delete(final Path path) throws IOException {
- return deleteDirectory(path);
- }
-
- static boolean deleteDirectory(final Path path) throws IOException {
- if (Files.exists(path) && Files.isDirectory(path)) {
- Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
- Files.deleteIfExists(file);
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
- Files.deleteIfExists(dir);
- return FileVisitResult.CONTINUE;
- }
- });
- }
- return true;
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ExtensionContextAnchor.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ExtensionContextAnchor.java
deleted file mode 100644
index da3e37c1c8..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ExtensionContextAnchor.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import org.apache.logging.log4j.lang.NullMarked;
-import org.apache.logging.log4j.lang.Nullable;
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
-import org.junit.platform.commons.PreconditionViolationException;
-
-@NullMarked
-public class ExtensionContextAnchor
- implements BeforeAllCallback, BeforeEachCallback, AfterAllCallback, AfterEachCallback {
-
- public static Namespace LOG4J2_NAMESPACE = Namespace.create("org.apache.logging.log4j.junit");
- private static final ThreadLocal<@Nullable ExtensionContext> EXTENSION_CONTEXT = new InheritableThreadLocal<>();
-
- private static void bind(final ExtensionContext context) {
- EXTENSION_CONTEXT.set(context);
- }
-
- private static void unbind(final ExtensionContext context) {
- EXTENSION_CONTEXT.set(context.getParent().orElse(null));
- }
-
- public static @Nullable ExtensionContext getContext() {
- return EXTENSION_CONTEXT.get();
- }
-
- public static @Nullable ExtensionContext getContext(final @Nullable ExtensionContext context) {
- return context != null ? context : EXTENSION_CONTEXT.get();
- }
-
- public static ExtensionContext getRequiredContext(final @Nullable ExtensionContext context) {
- final ExtensionContext actualContext = getContext(context);
- if (actualContext == null) {
- throw new PreconditionViolationException("No ExtensionContext available");
- }
- return actualContext;
- }
-
- public static ExtensionContext.Store getRequiredStore(final @Nullable ExtensionContext context) {
- return getRequiredContext(context).getStore(LOG4J2_NAMESPACE);
- }
-
- public static <T> @Nullable T getAttribute(
- final Object key, final Class<T> clazz, final @Nullable ExtensionContext context) {
- return getRequiredStore(context).get(key, clazz);
- }
-
- public static <T> T getRequiredAttribute(
- final Object key, final Class<T> clazz, final @Nullable ExtensionContext context) {
- final T attribute = getRequiredStore(context).get(key, clazz);
- if (attribute == null) {
- throw new PreconditionViolationException("Unable to find instance of " + clazz.getCanonicalName());
- }
- return attribute;
- }
-
- public static void setAttribute(final Object key, final Object value, final @Nullable ExtensionContext context) {
- getRequiredStore(context).put(key, value);
- }
-
- public static void removeAttribute(final Object key, final @Nullable ExtensionContext context) {
- final ExtensionContext actualContext = getContext(context);
- if (actualContext != null) {
- actualContext.getStore(LOG4J2_NAMESPACE).remove(key);
- }
- }
-
- @Override
- public void afterEach(final ExtensionContext context) throws Exception {
- unbind(context);
- }
-
- @Override
- public void afterAll(final ExtensionContext context) throws Exception {
- unbind(context);
- }
-
- @Override
- public void beforeEach(final ExtensionContext context) throws Exception {
- bind(context);
- }
-
- @Override
- public void beforeAll(final ExtensionContext context) throws Exception {
- bind(context);
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/FileCleaner.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/FileCleaner.java
deleted file mode 100644
index ece4b189d4..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/FileCleaner.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.HashSet;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-class FileCleaner extends AbstractFileCleaner {
- @Override
- Collection<Path> getPathsForTest(final ExtensionContext context) {
- final Collection<Path> paths = new HashSet<>();
- final CleanUpFiles testClassAnnotation = context.getRequiredTestClass().getAnnotation(CleanUpFiles.class);
- if (testClassAnnotation != null) {
- for (final String path : testClassAnnotation.value()) {
- paths.add(Paths.get(path));
- }
- }
- final CleanUpFiles testMethodAnnotation =
- context.getRequiredTestMethod().getAnnotation(CleanUpFiles.class);
- if (testMethodAnnotation != null) {
- for (final String path : testMethodAnnotation.value()) {
- paths.add(Paths.get(path));
- }
- }
- return paths;
- }
-
- @Override
- boolean delete(final Path path) throws IOException {
- return Files.deleteIfExists(path);
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/InitializesThreadContext.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/InitializesThreadContext.java
deleted file mode 100644
index 7c55de82f1..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/InitializesThreadContext.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.logging.log4j.ThreadContext;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.jupiter.api.parallel.ResourceAccessMode;
-import org.junit.jupiter.api.parallel.ResourceLock;
-
-/**
- * Marks a test class that initializes the {@link ThreadContext} class;
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Documented
-@Inherited
-@ExtendWith(ThreadContextInitializer.class)
-@ResourceLock(value = Resources.THREAD_CONTEXT, mode = ResourceAccessMode.READ_WRITE)
-public @interface InitializesThreadContext {}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Log4j2LauncherSessionListener.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Log4j2LauncherSessionListener.java
deleted file mode 100644
index 5ea29ff1c7..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Log4j2LauncherSessionListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import org.apache.logging.log4j.util.PropertiesUtil;
-import org.junit.platform.launcher.LauncherSession;
-import org.junit.platform.launcher.LauncherSessionListener;
-
-/**
- * Global Log4j2 test setup.
- */
-public class Log4j2LauncherSessionListener implements LauncherSessionListener {
-
- @Override
- public void launcherSessionOpened(final LauncherSession session) {
- // Prevents `PropertiesUtil` from initializing (and caching the results)
- // in the middle of a test.
- PropertiesUtil.getProperties();
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/LoggerContextFactoryExtension.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/LoggerContextFactoryExtension.java
deleted file mode 100644
index f81ac73688..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/LoggerContextFactoryExtension.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-/**
- * JUnit 5 extension that sets a particular {@link LoggerContextFactory} for the entire run of tests in a class.
- *
- * @since 2.14.0
- */
-public class LoggerContextFactoryExtension implements BeforeAllCallback, AfterAllCallback {
-
- private static final String KEY = "previousFactory";
- private final LoggerContextFactory loggerContextFactory;
-
- public LoggerContextFactoryExtension(final LoggerContextFactory loggerContextFactory) {
- this.loggerContextFactory = loggerContextFactory;
- }
-
- @Override
- public void beforeAll(final ExtensionContext context) throws Exception {
- getStore(context).put(KEY, LogManager.getFactory());
- LogManager.setFactory(loggerContextFactory);
- }
-
- @Override
- public void afterAll(final ExtensionContext context) throws Exception {
- LogManager.setFactory(getStore(context).get(KEY, LoggerContextFactory.class));
- }
-
- private ExtensionContext.Store getStore(final ExtensionContext context) {
- return context.getStore(ExtensionContext.Namespace.create(getClass()));
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Mutable.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Mutable.java
deleted file mode 100644
index f9f1a12185..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Mutable.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-/**
- * Helper class for JUnit tests.
- */
-public class Mutable {
- private String value;
-
- public Mutable set(final String value) {
- this.value = value;
- return this;
- }
-
- @Override
- public String toString() {
- return this.value;
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Resources.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Resources.java
deleted file mode 100644
index 8956311e49..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Resources.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import org.junit.jupiter.api.parallel.ResourceLock;
-
-/**
- * Constants to use the {@link ResourceLock} annotation.
- */
-public final class Resources {
-
- /**
- * Marks tests that require access to {@link org.apache.logging.log4j.LogManager} methods or change its
- * underlying {@link org.apache.logging.log4j.spi.LoggerContextFactory} implementation.
- */
- public static final String LOG_MANAGER = "log4j.LogManager";
-
- /**
- * Marks tests that require access to {@link org.apache.logging.log4j.ThreadContext} methods or change its
- * underlying {@link org.apache.logging.log4j.spi.ThreadContextMap} implementation.
- */
- public static final String THREAD_CONTEXT = "log4j.ThreadContext";
-
- /**
- * Marks tests that require access to {@link org.apache.logging.log4j.MarkerManager} methods.
- */
- public static final String MARKER_MANAGER = "log4j.MarkerManager";
-
- /**
- * Marks tests that requires access to {@link org.apache.logging.log4j.Level} static methods to create new levels.
- */
- public static final String LEVEL = "log4j.Level";
-
- /**
- * Marks tests that require access to {@link org.apache.logging.log4j.status.StatusLogger} static methods or
- * change its underlying implementation.
- */
- public static final String STATUS_LOGGER = "log4j.StatusLogger";
-
- private Resources() {}
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SetTestProperty.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SetTestProperty.java
deleted file mode 100644
index ff9a175d7a..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SetTestProperty.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junitpioneer.jupiter.ReadsEnvironmentVariable;
-import org.junitpioneer.jupiter.ReadsSystemProperty;
-
-/**
- * Registers a Log4j2 system property with the {@link TestPropertySource}. The
- * property will also be available in configuration files using the
- * {@code ${test:...} lookup.
- *
- */
-@Retention(RUNTIME)
-@Target({TYPE, METHOD})
-@Inherited
-@Documented
-@ExtendWith(ExtensionContextAnchor.class)
-@ExtendWith(TestPropertyResolver.class)
-@Repeatable(SetTestProperty.SetTestProperties.class)
-@ReadsSystemProperty
-@ReadsEnvironmentVariable
-public @interface SetTestProperty {
-
- String key();
-
- String value();
-
- @Retention(RUNTIME)
- @Target({TYPE, METHOD})
- @Documented
- @Inherited
- public @interface SetTestProperties {
-
- SetTestProperty[] value();
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerExtension.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerExtension.java
deleted file mode 100644
index 7737023bda..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerExtension.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.io.IOException;
-import java.time.Instant;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Stream;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.message.ParameterizedNoReferenceMessageFactory;
-import org.apache.logging.log4j.simple.SimpleLogger;
-import org.apache.logging.log4j.status.StatusData;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.test.ListStatusListener;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResource;
-import org.junit.jupiter.api.extension.ExtensionContextException;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
-import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver;
-import org.junit.platform.commons.support.HierarchyTraversalMode;
-import org.junit.platform.commons.support.ModifierSupport;
-import org.junit.platform.commons.support.ReflectionSupport;
-
-class StatusLoggerExtension extends TypeBasedParameterResolver<ListStatusListener>
- implements BeforeAllCallback, BeforeEachCallback, TestExecutionExceptionHandler {
-
- private static final Object KEY = ListStatusListener.class;
-
- @Override
- public void beforeAll(ExtensionContext context) throws Exception {
- // Stores the per-class status listener to catch the messages caused by other
- // `beforeAll` methods and extensions.
- final ListStatusListenerHolder holder = new ListStatusListenerHolder(context, null);
- ExtensionContextAnchor.setAttribute(KEY, holder, context);
- ReflectionSupport.findFields(
- context.getRequiredTestClass(),
- f -> ModifierSupport.isStatic(f) && f.getType().equals(ListStatusListener.class),
- HierarchyTraversalMode.TOP_DOWN)
- .forEach(f -> {
- try {
- f.setAccessible(true);
- f.set(null, holder.getStatusListener());
- } catch (final ReflectiveOperationException e) {
- throw new ExtensionContextException("Failed to inject field.", e);
- }
- });
- }
-
- @Override
- public void beforeEach(final ExtensionContext context) throws Exception {
- // Retrieves the per-class status listener
- final ListStatusListenerHolder parentHolder =
- ExtensionContextAnchor.getAttribute(KEY, ListStatusListenerHolder.class, context);
- final ListStatusListener parent = parentHolder != null ? parentHolder.getStatusListener() : null;
- final ListStatusListenerHolder holder = new ListStatusListenerHolder(context, parent);
- ExtensionContextAnchor.setAttribute(KEY, holder, context);
- ReflectionSupport.findFields(
- context.getRequiredTestClass(),
- f -> ModifierSupport.isNotStatic(f) && f.getType().equals(ListStatusListener.class),
- HierarchyTraversalMode.TOP_DOWN)
- .forEach(f -> {
- try {
- f.setAccessible(true);
- f.set(context.getRequiredTestInstance(), holder.getStatusListener());
- } catch (final ReflectiveOperationException e) {
- throw new ExtensionContextException("Failed to inject field.", e);
- }
- });
- }
-
- @Override
- public void handleTestExecutionException(final ExtensionContext context, final Throwable throwable)
- throws Throwable {
- final ListStatusListenerHolder holder =
- ExtensionContextAnchor.getAttribute(KEY, ListStatusListenerHolder.class, context);
- if (holder != null) {
- holder.handleException(context, throwable);
- }
- throw throwable;
- }
-
- @Override
- public ListStatusListener resolveParameter(
- final ParameterContext parameterContext, final ExtensionContext extensionContext)
- throws ParameterResolutionException {
- final ListStatusListenerHolder holder =
- ExtensionContextAnchor.getAttribute(KEY, ListStatusListenerHolder.class, extensionContext);
- if (holder == null) {
- throw new ParameterResolutionException("Unable to resolve ListStatusListener");
- }
- return holder.getStatusListener();
- }
-
- private static class ListStatusListenerHolder implements CloseableResource {
-
- private final StatusLogger statusLogger;
- private final ListStatusListener statusListener;
-
- public ListStatusListenerHolder(final ExtensionContext context, final ListStatusListener parent) {
- this.statusLogger = StatusLogger.getLogger();
- this.statusListener = new JUnitListStatusListener(context, parent);
- statusLogger.registerListener(statusListener);
- }
-
- public ListStatusListener getStatusListener() {
- return statusListener;
- }
-
- @Override
- public void close() throws Throwable {
- statusLogger.removeListener(statusListener);
- }
-
- public void handleException(final ExtensionContext context, final Throwable throwable) {
- final Logger logger = new SimpleLogger(
- "StatusLoggerExtension",
- ParameterizedNoReferenceMessageFactory.INSTANCE,
- System.err,
- Level.ALL,
- null,
- false);
- logger.error("Test {} failed.\nDumping status data:", context.getDisplayName());
- final DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_TIME.withZone(ZoneId.systemDefault());
- statusListener.getStatusData().forEach(data -> {
- logger.atLevel(data.getLevel())
- .withThrowable(data.getThrowable())
- .withLocation(data.getStackTraceElement())
- .log(
- "{} {}",
- formatter.format(Instant.ofEpochMilli(data.getTimestamp())),
- data.getMessage().getFormattedMessage());
- });
- }
- }
-
- private static class JUnitListStatusListener implements ListStatusListener {
-
- private final ExtensionContext context;
- private final ListStatusListener parent;
- private final ArrayList<StatusData> statusData = new ArrayList<>();
-
- public JUnitListStatusListener(final ExtensionContext context, final ListStatusListener parent) {
- this.context = context;
- this.parent = parent;
- }
-
- @Override
- public void log(final StatusData data) {
- if (context.equals(ExtensionContextAnchor.getContext())) {
- synchronized (statusData) {
- statusData.add(data);
- }
- }
- }
-
- @Override
- public Level getStatusLevel() {
- return Level.DEBUG;
- }
-
- @Override
- public void close() throws IOException {
- // NOP
- }
-
- @Override
- public Stream<StatusData> getStatusData() {
- synchronized (statusData) {
- final List<StatusData> clone = (List<StatusData>) statusData.clone();
- return parent != null ? Stream.concat(parent.getStatusData(), clone.stream()) : clone.stream();
- }
- }
-
- @Override
- public void clear() {
- synchronized (statusData) {
- statusData.clear();
- }
- }
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerLevel.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerLevel.java
deleted file mode 100644
index ffeeee07a9..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerLevel.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.jupiter.api.parallel.ResourceLock;
-
-/**
- * JUnit 5 test extension that sets a specific StatusLogger logging level for each test.
- *
- * @since 2.14.0
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented
-@Inherited
-@ExtendWith(StatusLoggerLevelExtension.class)
-@ResourceLock("log4j2.StatusLogger")
-public @interface StatusLoggerLevel {
- /** Name of {@link org.apache.logging.log4j.Level} to use for status logger. */
- String value();
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerLevelExtension.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerLevelExtension.java
deleted file mode 100644
index 54534ed9dc..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/StatusLoggerLevelExtension.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-class StatusLoggerLevelExtension implements BeforeEachCallback, AfterEachCallback {
-
- private static final String KEY = "previousLevel";
-
- @Override
- public void beforeEach(final ExtensionContext context) throws Exception {
- final StatusLoggerLevel annotation = context.getRequiredTestClass().getAnnotation(StatusLoggerLevel.class);
- if (annotation == null) {
- return;
- }
- final StatusLogger logger = StatusLogger.getLogger();
- getStore(context).put(KEY, logger.getLevel());
- logger.setLevel(Level.valueOf(annotation.value()));
- }
-
- @Override
- public void afterEach(final ExtensionContext context) throws Exception {
- StatusLogger.getLogger().setLevel(getStore(context).get(KEY, Level.class));
- }
-
- private ExtensionContext.Store getStore(final ExtensionContext context) {
- return context.getStore(ExtensionContext.Namespace.create(getClass(), context.getRequiredTestInstance()));
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Tags.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Tags.java
deleted file mode 100644
index 06bef43b06..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Tags.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-/**
- * A set of tags for JUnit 5 tests.
- */
-public final class Tags {
-
- /**
- * Marks tests that don't modify the global environment.
- * <p>
- * These tests can safely be run in parallel.
- * </p>
- */
- public static final String PARALLEL = "parallel";
-
- private Tags() {}
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDir.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDir.java
deleted file mode 100644
index 8a6af4c820..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDir.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.jupiter.api.io.CleanupMode;
-
-/**
- * Injects the given static field with a per test logging directory.
- * <p>
- * The same directory is set as "logging.path" Log4j2 property.
- * </p>
- */
-@Retention(RUNTIME)
-@Target({FIELD, PARAMETER})
-@Inherited
-@Documented
-@ExtendWith(ExtensionContextAnchor.class)
-@ExtendWith(TempLoggingDirectory.class)
-public @interface TempLoggingDir {
-
- CleanupMode cleanup() default CleanupMode.DEFAULT;
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDirectory.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDirectory.java
deleted file mode 100644
index 0b65f3ef88..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDirectory.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import static org.junit.jupiter.api.io.CleanupMode.NEVER;
-import static org.junit.jupiter.api.io.CleanupMode.ON_SUCCESS;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.test.TestProperties;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResource;
-import org.junit.jupiter.api.extension.ExtensionContextException;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.ParameterResolver;
-import org.junit.jupiter.api.io.CleanupMode;
-import org.junit.platform.commons.support.AnnotationSupport;
-import org.junit.platform.commons.support.ModifierSupport;
-
-public class TempLoggingDirectory implements BeforeAllCallback, BeforeEachCallback, ParameterResolver {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- @Override
- public void beforeAll(ExtensionContext context) throws Exception {
- final List<Field> fields = AnnotationSupport.findAnnotatedFields(
- context.getRequiredTestClass(), TempLoggingDir.class, ModifierSupport::isStatic);
- Path loggingPath = null;
- for (final Field field : fields) {
- if (loggingPath != null) {
- LOGGER.warn("Multiple fields with @TempLoggingDir annotation are not supported.");
- } else {
- final CleanupMode cleanup = determineCleanupMode(field);
- loggingPath = createLoggingPath(context, cleanup).getPath();
- }
- field.setAccessible(true);
- field.set(null, loggingPath);
- }
- }
-
- @Override
- public void beforeEach(ExtensionContext context) throws Exception {
- // JUnit 5 does not set an error on the parent context if one of the children
- // fail. We record the list of children.
- context.getParent().ifPresent(c -> {
- final PathHolder holder = ExtensionContextAnchor.getAttribute(PathHolder.class, PathHolder.class, c);
- if (holder != null) {
- holder.addContext(context);
- }
- });
- // Inject fields
- final List<Field> fields = AnnotationSupport.findAnnotatedFields(
- context.getRequiredTestClass(), TempLoggingDir.class, ModifierSupport::isNotStatic);
- Path loggingPath = null;
- final Object instance = context.getRequiredTestInstance();
- for (final Field field : fields) {
- if (loggingPath != null) {
- LOGGER.warn("Multiple fields with @TempLoggingDir annotation are not supported.");
- } else {
- final CleanupMode cleanup = determineCleanupMode(field);
- loggingPath = createLoggingPath(context, cleanup).getPath();
- }
- field.setAccessible(true);
- field.set(instance, loggingPath);
- }
- }
-
- @Override
- public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
- throws ParameterResolutionException {
- if (parameterContext.getParameter().getType().isAssignableFrom(Path.class)) {
- return parameterContext.findAnnotation(TempLoggingDir.class).isPresent();
- }
- return false;
- }
-
- @Override
- public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
- throws ParameterResolutionException {
- final TempLoggingDir annotation = parameterContext
- .findAnnotation(TempLoggingDir.class)
- .orElseThrow(() -> new ParameterResolutionException("No @TempLoggingDir annotation found"));
- // Get or create temporary directory
- PathHolder holder = ExtensionContextAnchor.getAttribute(PathHolder.class, PathHolder.class, extensionContext);
- if (holder == null || !extensionContext.equals(holder.getMainContext())) {
- final CleanupMode mode = determineCleanupMode(annotation);
- holder = createLoggingPath(extensionContext, mode);
- }
- return holder.getPath();
- }
-
- private PathHolder createLoggingPath(final ExtensionContext context, final CleanupMode cleanup) {
- final TestProperties props = TestPropertySource.createProperties(context);
- // Create temporary directory
- final String baseDir = System.getProperty("basedir");
- final Path basePath = (baseDir != null ? Paths.get(baseDir, "target") : Paths.get(".")).resolve("logs");
- final Class<?> clazz = context.getRequiredTestClass();
- final String dir = clazz.getName().replaceAll("[.$]", File.separatorChar == '\\' ? "\\\\" : File.separator);
- final Path perClassPath = basePath.resolve(dir);
- // Per test subfolder
- final Path loggingPath = context.getTestMethod()
- .map(m -> perClassPath.resolve(m.getName()))
- .orElse(perClassPath);
- try {
- Files.createDirectories(loggingPath);
- } catch (final IOException e) {
- throw new ExtensionContextException("Failed to create temporary directory.", e);
- }
- props.setProperty(TestProperties.LOGGING_PATH, loggingPath.toString());
- // Register deletion
- final PathHolder holder = new PathHolder(loggingPath, cleanup, context);
- ExtensionContextAnchor.setAttribute(PathHolder.class, holder, context);
- return holder;
- }
-
- private CleanupMode determineCleanupMode(final TempLoggingDir annotation) {
- final CleanupMode mode = annotation.cleanup();
- // TODO: use JupiterConfiguration
- return mode != CleanupMode.DEFAULT ? mode : CleanupMode.ON_SUCCESS;
- }
-
- private CleanupMode determineCleanupMode(final Field field) {
- return determineCleanupMode(field.getAnnotation(TempLoggingDir.class));
- }
-
- private static class PathHolder implements CloseableResource {
-
- private final Path path;
- private final CleanupMode cleanupMode;
- private final ExtensionContext mainContext;
- private final Map<ExtensionContext, Boolean> contexts = new ConcurrentHashMap<>();
-
- public PathHolder(final Path path, final CleanupMode cleanup, final ExtensionContext context) {
- this.path = path;
- this.cleanupMode = cleanup;
- this.contexts.put(context, Boolean.TRUE);
- this.mainContext = context;
- }
-
- public void addContext(final ExtensionContext context) {
- this.contexts.put(context, Boolean.TRUE);
- }
-
- public Path getPath() {
- return path;
- }
-
- public ExtensionContext getMainContext() {
- return mainContext;
- }
-
- @Override
- public void close() throws IOException {
- if (cleanupMode == NEVER
- || (cleanupMode == ON_SUCCESS
- && contexts.keySet().stream().anyMatch(context -> context.getExecutionException()
- .isPresent()))) {
- LOGGER.debug("Skipping cleanup of directory {}.", path);
- return;
- }
- DirectoryCleaner.deleteDirectory(path);
- }
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertyResolver.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertyResolver.java
deleted file mode 100644
index 7957331d49..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertyResolver.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import org.apache.logging.log4j.test.TestProperties;
-import org.apache.logging.log4j.util.ReflectionUtil;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver;
-import org.junit.platform.commons.support.AnnotationSupport;
-import org.junit.platform.commons.support.HierarchyTraversalMode;
-import org.junit.platform.commons.support.ModifierSupport;
-import org.junit.platform.commons.support.ReflectionSupport;
-
-public class TestPropertyResolver extends TypeBasedParameterResolver<TestProperties>
- implements BeforeAllCallback, BeforeEachCallback {
-
- @Override
- public void beforeEach(final ExtensionContext context) throws Exception {
- final TestProperties props = TestPropertySource.createProperties(context);
- AnnotationSupport.findRepeatableAnnotations(context.getRequiredTestMethod(), SetTestProperty.class)
- .forEach(setProperty -> props.setProperty(setProperty.key(), setProperty.value()));
- final Class<?> testClass = context.getRequiredTestClass();
- final Object testInstance = context.getRequiredTestInstance();
- ReflectionSupport.findFields(
- testClass,
- field -> ModifierSupport.isNotStatic(field) && TestProperties.class.equals(field.getType()),
- HierarchyTraversalMode.BOTTOM_UP)
- .forEach(field -> ReflectionUtil.setFieldValue(field, testInstance, props));
- }
-
- @Override
- public void beforeAll(final ExtensionContext context) throws Exception {
- final TestProperties props = TestPropertySource.createProperties(context);
- AnnotationSupport.findRepeatableAnnotations(context.getRequiredTestClass(), SetTestProperty.class)
- .forEach(setProperty -> props.setProperty(setProperty.key(), setProperty.value()));
- final Class<?> testClass = context.getRequiredTestClass();
- ReflectionSupport.findFields(
- testClass,
- field -> ModifierSupport.isStatic(field) && TestProperties.class.equals(field.getType()),
- HierarchyTraversalMode.BOTTOM_UP)
- .forEach(field -> ReflectionUtil.setStaticFieldValue(field, props));
- }
-
- @Override
- public TestProperties resolveParameter(
- final ParameterContext parameterContext, final ExtensionContext extensionContext)
- throws ParameterResolutionException {
- return TestPropertySource.createProperties(extensionContext);
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertySource.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertySource.java
deleted file mode 100644
index b9331ef03b..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TestPropertySource.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import org.apache.logging.log4j.test.TestProperties;
-import org.apache.logging.log4j.util.PropertySource;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
-import org.junit.jupiter.api.extension.ExtensionContext.Store;
-
-public class TestPropertySource implements PropertySource {
-
- private static final String PREFIX = "log4j2.";
- private static final Namespace NAMESPACE = ExtensionContextAnchor.LOG4J2_NAMESPACE.append("properties");
- private static final TestProperties EMPTY_PROPERTIES = new EmptyTestProperties();
-
- @Override
- public int getPriority() {
- // Highest priority
- return Integer.MIN_VALUE;
- }
-
- public static TestProperties createProperties(final ExtensionContext context) {
- // Make sure that the properties do not come from the parent ExtensionContext
- if (getProperties(context) instanceof JUnitTestProperties props && context.equals(props.context)) {
- return props;
- }
- final TestProperties props = new JUnitTestProperties(context);
- ExtensionContextAnchor.setAttribute(TestProperties.class, props, context);
- return props;
- }
-
- public static TestProperties getProperties() {
- return getProperties(null);
- }
-
- private static TestProperties getProperties(final ExtensionContext context) {
- final ExtensionContext actualContext = context != null ? context : ExtensionContextAnchor.getContext();
- if (actualContext != null) {
- final TestProperties props =
- ExtensionContextAnchor.getAttribute(TestProperties.class, TestProperties.class, actualContext);
- if (props != null) {
- return props;
- }
- }
- return EMPTY_PROPERTIES;
- }
-
- @Override
- public CharSequence getNormalForm(final Iterable<? extends CharSequence> tokens) {
- final CharSequence camelCase = Util.joinAsCamelCase(tokens);
- // Do not use Strings to prevent recursive initialization
- return camelCase.length() > 0 ? camelCase.toString() : null;
- }
-
- @Override
- public String getProperty(final String key) {
- return getProperties().getProperty(removePrefix(key));
- }
-
- @Override
- public boolean containsProperty(final String key) {
- return getProperties().containsProperty(removePrefix(key));
- }
-
- private static String removePrefix(final String key) {
- return key.startsWith(PREFIX) ? key.substring(PREFIX.length()) : key;
- }
-
- private static class JUnitTestProperties implements TestProperties {
-
- private final ExtensionContext context;
- private final Store store;
-
- public JUnitTestProperties(final ExtensionContext context) {
- this.context = context;
- this.store = context.getStore(NAMESPACE);
- }
-
- @Override
- public String getProperty(final String key) {
- return store.get(key, String.class);
- }
-
- @Override
- public boolean containsProperty(final String key) {
- return getProperty(key) != null;
- }
-
- @Override
- public void setProperty(final String key, final String value) {
- store.put(key, value);
- }
-
- @Override
- public void clearProperty(final String key) {
- store.remove(key, String.class);
- }
- }
-
- private static class EmptyTestProperties implements TestProperties {
-
- @Override
- public String getProperty(final String key) {
- return null;
- }
-
- @Override
- public boolean containsProperty(final String key) {
- return false;
- }
-
- @Override
- public void setProperty(final String key, final String value) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clearProperty(final String key) {
- throw new UnsupportedOperationException();
- }
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextInitializer.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextInitializer.java
deleted file mode 100644
index 309fb2fcb4..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextInitializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import org.apache.logging.log4j.ThreadContext;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResource;
-import org.junit.platform.commons.support.AnnotationSupport;
-
-class ThreadContextInitializer implements BeforeAllCallback, BeforeEachCallback {
-
- @Override
- public void beforeAll(final ExtensionContext context) throws Exception {
- if (AnnotationSupport.isAnnotated(context.getRequiredTestClass(), InitializesThreadContext.class)) {
- resetThreadContext(context);
- }
- }
-
- @Override
- public void beforeEach(final ExtensionContext context) throws Exception {
- if (AnnotationSupport.isAnnotated(context.getRequiredTestMethod(), InitializesThreadContext.class)) {
- resetThreadContext(context);
- }
- }
-
- private void resetThreadContext(final ExtensionContext context) {
- ThreadContext.init();
- // We use `CloseableResource` instead of `afterAll` to reset the
- // ThreadContextFactory
- // *after* the `@SetSystemProperty` extension has restored the properties
- ExtensionContextAnchor.setAttribute(ThreadContext.class, (CloseableResource) ThreadContext::init, context);
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextMapExtension.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextMapExtension.java
deleted file mode 100644
index 3afab2f9d4..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextMapExtension.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.util.Map;
-import org.apache.logging.log4j.ThreadContext;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-class ThreadContextMapExtension implements BeforeEachCallback {
- private static final class ThreadContextMapStore implements ExtensionContext.Store.CloseableResource {
- private final Map<String, String> previousMap = ThreadContext.getImmutableContext();
-
- private ThreadContextMapStore() {
- ThreadContext.clearMap();
- }
-
- @Override
- public void close() throws Throwable {
- // TODO LOG4J2-1517 Add ThreadContext.setContext(Map<String, String>)
- ThreadContext.clearMap();
- ThreadContext.putAll(previousMap);
- }
- }
-
- @Override
- public void beforeEach(final ExtensionContext context) throws Exception {
- context.getStore(ExtensionContextAnchor.LOG4J2_NAMESPACE).getOrComputeIfAbsent(ThreadContextMapStore.class);
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextRule.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextRule.java
deleted file mode 100644
index 1a85c7c7a2..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextRule.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.test.ThreadContextHolder;
-import org.junit.rules.ExternalResource;
-
-/**
- * Restores the ThreadContext to it's initial map and stack values after a JUnit test.
- *
- * Usage:
- *
- * <pre>
- * @Rule
- * public final ThreadContextRule threadContextRule = new ThreadContextRule();
- * </pre>
- *
- * @deprecated use {@link UsingAnyThreadContext} with JUnit 5
- */
-@Deprecated
-public class ThreadContextRule extends ExternalResource {
-
- private final boolean restoreMap;
- private final boolean restoreStack;
- private ThreadContextHolder threadContextHolder;
-
- /**
- * Constructs an instance initialized to restore the stack and map.
- */
- public ThreadContextRule() {
- this(true, true);
- }
-
- /**
- * Constructs an instance initialized to restore the given structures.
- *
- * @param restoreMap
- * Whether to restore the thread context map.
- * @param restoreStack
- * Whether to restore the thread context stack.
- */
- public ThreadContextRule(final boolean restoreMap, final boolean restoreStack) {
- super();
- this.restoreMap = restoreMap;
- this.restoreStack = restoreStack;
- }
-
- @Override
- protected void after() {
- if (threadContextHolder != null) {
- threadContextHolder.restore();
- }
- }
-
- @Override
- protected void before() throws Throwable {
- threadContextHolder = new ThreadContextHolder(restoreMap, restoreStack);
- if (restoreMap) {
- ThreadContext.clearMap();
- }
- if (restoreStack) {
- ThreadContext.clearStack();
- }
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextStackExtension.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextStackExtension.java
deleted file mode 100644
index 75bb8fe4c0..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextStackExtension.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.util.Collection;
-import org.apache.logging.log4j.ThreadContext;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
-import org.junit.jupiter.api.extension.ExtensionContext.Store;
-
-class ThreadContextStackExtension implements BeforeEachCallback {
- private static final class ThreadContextStackStore implements Store.CloseableResource {
- private final Collection<String> previousStack = ThreadContext.getImmutableStack();
-
- private ThreadContextStackStore() {
- ThreadContext.clearStack();
- }
-
- @Override
- public void close() throws Throwable {
- ThreadContext.setStack(previousStack);
- }
- }
-
- @Override
- public void beforeEach(final ExtensionContext context) throws Exception {
- context.getStore(Namespace.create(
- ThreadContext.class, context.getRequiredTestClass(), context.getRequiredTestInstance()))
- .getOrComputeIfAbsent(ThreadContextStackStore.class);
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextStackRule.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextStackRule.java
deleted file mode 100644
index 452c322a52..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/ThreadContextStackRule.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-/**
- * Restores the ThreadContext to it's initial stack values after a JUnit test.
- *
- * Usage:
- *
- * <pre>
- * @Rule
- * public final ThreadContextStackRule threadContextRule = new ThreadContextStackRule();
- * </pre>
- * @deprecated use {@link UsingThreadContextStack} with JUnit 5
- */
-@Deprecated
-public class ThreadContextStackRule extends ThreadContextRule {
-
- /**
- * Constructs an initialized instance.
- */
- public ThreadContextStackRule() {
- super(false, true);
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingAnyThreadContext.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingAnyThreadContext.java
deleted file mode 100644
index 6e8750da2f..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingAnyThreadContext.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marks a test class as using {@link org.apache.logging.log4j.ThreadContext} APIs. This will automatically clear and restore
- * both the thread context map and stack for each test invocation.
- *
- * @since 2.14.0
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
-@Documented
-@Inherited
-@UsingThreadContextMap
-@UsingThreadContextStack
-public @interface UsingAnyThreadContext {}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingStatusListener.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingStatusListener.java
deleted file mode 100644
index e54deb6b42..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingStatusListener.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import org.apache.logging.log4j.status.StatusListener;
-import org.apache.logging.log4j.test.ListStatusListener;
-import org.junit.jupiter.api.extension.ExtendWith;
-
-/**
- * Configures and injects a {@link StatusListener} of type
- * {@link ListStatusListener}, that will collect status messages for the test
- * context.
- */
-@Retention(RUNTIME)
-@Target({TYPE, METHOD})
-@Documented
-@ExtendWith(ExtensionContextAnchor.class)
-@ExtendWith(TestPropertyResolver.class)
-@ExtendWith(StatusLoggerExtension.class)
-public @interface UsingStatusListener {}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingTestProperties.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingTestProperties.java
deleted file mode 100644
index 1a37b99832..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingTestProperties.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import org.apache.logging.log4j.test.TestProperties;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junitpioneer.jupiter.ReadsEnvironmentVariable;
-import org.junitpioneer.jupiter.ReadsSystemProperty;
-
-/**
- * A field or method parameter of type {@link TestProperties} will be injected with a per-test source of Log4j2's
- * system properties.
- */
-@Retention(RUNTIME)
-@Target({TYPE, METHOD})
-@Inherited
-@Documented
-@ExtendWith(ExtensionContextAnchor.class)
-@ExtendWith(TestPropertyResolver.class)
-@ReadsSystemProperty
-@ReadsEnvironmentVariable
-public @interface UsingTestProperties {}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingThreadContextMap.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingThreadContextMap.java
deleted file mode 100644
index 2995e4c804..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingThreadContextMap.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.jupiter.api.parallel.ResourceAccessMode;
-import org.junit.jupiter.api.parallel.ResourceLock;
-import org.junitpioneer.jupiter.ReadsSystemProperty;
-
-/**
- * Marks a test class as using {@link org.apache.logging.log4j.spi.ThreadContextMap} APIs. This will automatically clear and
- * restore the thread context map (MDC) for each test invocation.
- *
- * @since 2.14.0
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
-@Documented
-@Inherited
-@ExtendWith(ThreadContextMapExtension.class)
-@ReadsSystemProperty
-@ResourceLock(value = Resources.THREAD_CONTEXT, mode = ResourceAccessMode.READ)
-public @interface UsingThreadContextMap {}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingThreadContextStack.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingThreadContextStack.java
deleted file mode 100644
index 7a96355ea4..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/UsingThreadContextStack.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.test.junit;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junitpioneer.jupiter.ReadsSystemProperty;
-
-/**
- * Marks a test class as using {@link org.apache.logging.log4j.spi.ThreadContextStack} APIs. This will automatically clear and
- * restore the thread context stack (NDC) for each test invocation.
- *
- * @since 2.14.0
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
-@Documented
-@Inherited
-@ExtendWith(ThreadContextStackExtension.class)
-@ReadsSystemProperty
-public @interface UsingThreadContextStack {}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/package-info.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/package-info.java
deleted file mode 100644
index f299b2f928..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Export
-@Version("3.0.0")
-package org.apache.logging.log4j.test.junit;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/package-info.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/package-info.java
deleted file mode 100644
index 676a0e74fe..0000000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Export
-@Version("3.0.0")
-package org.apache.logging.log4j.test;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-api-test/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource b/log4j-api-test/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource
deleted file mode 100644
index 2c7cb498d9..0000000000
--- a/log4j-api-test/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource
+++ /dev/null
@@ -1,15 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache license, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the license for the specific language governing permissions and
-# limitations under the license.
-org.apache.logging.log4j.test.junit.TestPropertySource
diff --git a/log4j-api-test/src/main/resources/META-INF/services/org.junit.jupiter.api.extension.Extension b/log4j-api-test/src/main/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
deleted file mode 100644
index ca7ce84edd..0000000000
--- a/log4j-api-test/src/main/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
+++ /dev/null
@@ -1,15 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache license, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the license for the specific language governing permissions and
-# limitations under the license.
-org.apache.logging.log4j.test.junit.ExtensionContextAnchor
\ No newline at end of file
diff --git a/log4j-api-test/src/main/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener b/log4j-api-test/src/main/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener
deleted file mode 100644
index e492405c76..0000000000
--- a/log4j-api-test/src/main/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache license, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the license for the specific language governing permissions and
-# limitations under the license.
-
-org.apache.logging.log4j.test.junit.Log4j2LauncherSessionListener
\ No newline at end of file
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
deleted file mode 100644
index 0f1d4f0078..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
+++ /dev/null
@@ -1,1472 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.MatcherAssert.assertThat;
-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.util.List;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.ObjectMessage;
-import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.logging.log4j.message.ReusableMessageFactory;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.status.StatusData;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.test.junit.Resources;
-import org.apache.logging.log4j.test.junit.StatusLoggerLevel;
-import org.apache.logging.log4j.util.MessageSupplier;
-import org.apache.logging.log4j.util.Supplier;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.parallel.ResourceAccessMode;
-import org.junit.jupiter.api.parallel.ResourceLock;
-
-@StatusLoggerLevel("WARN")
-@ResourceLock(value = Resources.MARKER_MANAGER, mode = ResourceAccessMode.READ)
-public class AbstractLoggerTest {
-
- private static final StringBuilder CHAR_SEQ = new StringBuilder("CharSeq");
-
- // TODO add proper tests for ReusableMessage
-
- @SuppressWarnings("ThrowableInstanceNeverThrown")
- private static final Throwable t = new UnsupportedOperationException("Test");
-
- private static final Class<AbstractLogger> obj = AbstractLogger.class;
- private static final String pattern = "{}, {}";
- private static final String p1 = "Long Beach";
-
- private static final String p2 = "California";
- private static final Message charSeq = new SimpleMessage(CHAR_SEQ);
- private static final Message simple = new SimpleMessage("Hello");
- private static final Message object = new ObjectMessage(obj);
-
- private static final Message param = new ParameterizedMessage(pattern, p1, p2);
-
- private final Marker MARKER = MarkerManager.getMarker("TEST");
- private static final String MARKER_NAME = "TEST";
-
- private static final LogEvent[] EVENTS = new LogEvent[] {
- new LogEvent(null, simple, null),
- new LogEvent(MARKER_NAME, simple, null),
- new LogEvent(null, simple, t),
- new LogEvent(MARKER_NAME, simple, t),
- new LogEvent(null, object, null),
- new LogEvent(MARKER_NAME, object, null),
- new LogEvent(null, object, t),
- new LogEvent(MARKER_NAME, object, t),
- new LogEvent(null, param, null),
- new LogEvent(MARKER_NAME, param, null),
- new LogEvent(null, simple, null),
- new LogEvent(null, simple, t),
- new LogEvent(MARKER_NAME, simple, null),
- new LogEvent(MARKER_NAME, simple, t),
- new LogEvent(MARKER_NAME, simple, null),
- new LogEvent(null, charSeq, null),
- new LogEvent(null, charSeq, t),
- new LogEvent(MARKER_NAME, charSeq, null),
- new LogEvent(MARKER_NAME, charSeq, t),
- };
-
- @Test
- public void testDebug() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.DEBUG);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.debug("Hello");
- logger.debug((Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.debug(MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.debug("Hello", t);
- logger.debug((Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.debug(MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.debug(obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.debug(MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.debug(obj, t);
- logger.debug((Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.debug(MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.debug(pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.debug(MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.debug(simple);
- logger.debug((Marker) null, simple);
- logger.debug((Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.debug(simple, t);
- logger.debug((Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.debug(MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.debug(MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.debug(MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.debug(CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.debug(CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.debug(MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.debug(MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testError() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.ERROR);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.error("Hello");
- logger.error((Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.error(MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.error("Hello", t);
- logger.error((Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.error(MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.error(obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.error(MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.error(obj, t);
- logger.error((Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.error(MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.error(pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.error(MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.error(simple);
- logger.error((Marker) null, simple);
- logger.error((Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.error(simple, t);
- logger.error((Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.error(MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.error(MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.error(MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.error(CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.error(CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.error(MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.error(MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testFatal() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.FATAL);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.fatal("Hello");
- logger.fatal((Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.fatal(MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.fatal("Hello", t);
- logger.fatal((Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.fatal(MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.fatal(obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.fatal(MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.fatal(obj, t);
- logger.fatal((Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.fatal(MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.fatal(pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.fatal(MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.fatal(simple);
- logger.fatal((Marker) null, simple);
- logger.fatal((Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.fatal(simple, t);
- logger.fatal((Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.fatal(MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.fatal(MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.fatal(MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.fatal(CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.fatal(CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.fatal(MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.fatal(MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testInfo() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.INFO);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.info("Hello");
- logger.info((Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.info(MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.info("Hello", t);
- logger.info((Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.info(MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.info(obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.info(MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.info(obj, t);
- logger.info((Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.info(MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.info(pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.info(MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.info(simple);
- logger.info((Marker) null, simple);
- logger.info((Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.info(simple, t);
- logger.info((Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.info(MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.info(MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.info(MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.info(CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.info(CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.info(MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.info(MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testLogDebug() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.DEBUG);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.log(Level.DEBUG, "Hello");
- logger.log(Level.DEBUG, (Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.log(Level.DEBUG, MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.log(Level.DEBUG, "Hello", t);
- logger.log(Level.DEBUG, (Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.log(Level.DEBUG, MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.log(Level.DEBUG, obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.log(Level.DEBUG, MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.log(Level.DEBUG, obj, t);
- logger.log(Level.DEBUG, (Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.log(Level.DEBUG, MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.log(Level.DEBUG, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.log(Level.DEBUG, MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.log(Level.DEBUG, simple);
- logger.log(Level.DEBUG, (Marker) null, simple);
- logger.log(Level.DEBUG, (Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.log(Level.DEBUG, simple, t);
- logger.log(Level.DEBUG, (Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.log(Level.DEBUG, MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.log(Level.DEBUG, MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.log(Level.DEBUG, MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.log(Level.DEBUG, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.log(Level.DEBUG, CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.log(Level.DEBUG, MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.log(Level.DEBUG, MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testLogError() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.ERROR);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.log(Level.ERROR, "Hello");
- logger.log(Level.ERROR, (Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.log(Level.ERROR, MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.log(Level.ERROR, "Hello", t);
- logger.log(Level.ERROR, (Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.log(Level.ERROR, MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.log(Level.ERROR, obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.log(Level.ERROR, MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.log(Level.ERROR, obj, t);
- logger.log(Level.ERROR, (Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.log(Level.ERROR, MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.log(Level.ERROR, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.log(Level.ERROR, MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.log(Level.ERROR, simple);
- logger.log(Level.ERROR, (Marker) null, simple);
- logger.log(Level.ERROR, (Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.log(Level.ERROR, simple, t);
- logger.log(Level.ERROR, (Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.log(Level.ERROR, MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.log(Level.ERROR, MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.log(Level.ERROR, MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.log(Level.ERROR, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.log(Level.ERROR, CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.log(Level.ERROR, MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.log(Level.ERROR, MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testLogFatal() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.FATAL);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.log(Level.FATAL, "Hello");
- logger.log(Level.FATAL, (Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.log(Level.FATAL, MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.log(Level.FATAL, "Hello", t);
- logger.log(Level.FATAL, (Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.log(Level.FATAL, MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.log(Level.FATAL, obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.log(Level.FATAL, MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.log(Level.FATAL, obj, t);
- logger.log(Level.FATAL, (Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.log(Level.FATAL, MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.log(Level.FATAL, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.log(Level.FATAL, MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.log(Level.FATAL, simple);
- logger.log(Level.FATAL, (Marker) null, simple);
- logger.log(Level.FATAL, (Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.log(Level.FATAL, simple, t);
- logger.log(Level.FATAL, (Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.log(Level.FATAL, MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.log(Level.FATAL, MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.log(Level.FATAL, MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.log(Level.FATAL, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.log(Level.FATAL, CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.log(Level.FATAL, MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.log(Level.FATAL, MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testLogInfo() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.INFO);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.log(Level.INFO, "Hello");
- logger.log(Level.INFO, (Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.log(Level.INFO, MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.log(Level.INFO, "Hello", t);
- logger.log(Level.INFO, (Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.log(Level.INFO, MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.log(Level.INFO, obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.log(Level.INFO, MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.log(Level.INFO, obj, t);
- logger.log(Level.INFO, (Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.log(Level.INFO, MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.log(Level.INFO, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.log(Level.INFO, MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.log(Level.INFO, simple);
- logger.log(Level.INFO, (Marker) null, simple);
- logger.log(Level.INFO, (Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.log(Level.INFO, simple, t);
- logger.log(Level.INFO, (Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.log(Level.INFO, MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.log(Level.INFO, MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.log(Level.INFO, MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.log(Level.INFO, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.log(Level.INFO, CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.log(Level.INFO, MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.log(Level.INFO, MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testLogTrace() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.TRACE);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.log(Level.TRACE, "Hello");
- logger.log(Level.TRACE, (Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.log(Level.TRACE, MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.log(Level.TRACE, "Hello", t);
- logger.log(Level.TRACE, (Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.log(Level.TRACE, MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.log(Level.TRACE, obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.log(Level.TRACE, MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.log(Level.TRACE, obj, t);
- logger.log(Level.TRACE, (Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.log(Level.TRACE, MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.log(Level.TRACE, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.log(Level.TRACE, MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.log(Level.TRACE, simple);
- logger.log(Level.TRACE, (Marker) null, simple);
- logger.log(Level.TRACE, (Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.log(Level.TRACE, simple, t);
- logger.log(Level.TRACE, (Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.log(Level.TRACE, MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.log(Level.TRACE, MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.log(Level.TRACE, MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.log(Level.TRACE, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.log(Level.TRACE, CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.log(Level.TRACE, MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.log(Level.TRACE, MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testLogWarn() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.WARN);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.log(Level.WARN, "Hello");
- logger.log(Level.WARN, (Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.log(Level.WARN, MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.log(Level.WARN, "Hello", t);
- logger.log(Level.WARN, (Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.log(Level.WARN, MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.log(Level.WARN, obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.log(Level.WARN, MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.log(Level.WARN, obj, t);
- logger.log(Level.WARN, (Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.log(Level.WARN, MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.log(Level.WARN, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.log(Level.WARN, MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.log(Level.WARN, simple);
- logger.log(Level.WARN, (Marker) null, simple);
- logger.log(Level.WARN, (Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.log(Level.WARN, simple, t);
- logger.log(Level.WARN, (Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.log(Level.WARN, MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.log(Level.WARN, MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.log(Level.WARN, MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.log(Level.WARN, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.log(Level.WARN, CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.log(Level.WARN, MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.log(Level.WARN, MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testTrace() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.TRACE);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.trace("Hello");
- logger.trace((Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.trace(MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.trace("Hello", t);
- logger.trace((Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.trace(MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.trace(obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.trace(MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.trace(obj, t);
- logger.trace((Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.trace(MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.trace(pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.trace(MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.trace(simple);
- logger.trace((Marker) null, simple);
- logger.trace((Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.trace(simple, t);
- logger.trace((Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.trace(MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.trace(MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.trace(MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.trace(CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.trace(CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.trace(MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.trace(MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testWarn() {
- final CountingLogger logger = new CountingLogger();
- logger.setCurrentLevel(Level.WARN);
-
- logger.setCurrentEvent(EVENTS[0]);
- logger.warn("Hello");
- logger.warn((Marker) null, "Hello");
- logger.setCurrentEvent(EVENTS[1]);
- logger.warn(MARKER, "Hello");
- logger.setCurrentEvent(EVENTS[2]);
- logger.warn("Hello", t);
- logger.warn((Marker) null, "Hello", t);
- logger.setCurrentEvent(EVENTS[3]);
- logger.warn(MARKER, "Hello", t);
- logger.setCurrentEvent(EVENTS[4]);
- logger.warn(obj);
- logger.setCurrentEvent(EVENTS[5]);
- logger.warn(MARKER, obj);
- logger.setCurrentEvent(EVENTS[6]);
- logger.warn(obj, t);
- logger.warn((Marker) null, obj, t);
- logger.setCurrentEvent(EVENTS[7]);
- logger.warn(MARKER, obj, t);
- logger.setCurrentEvent(EVENTS[8]);
- logger.warn(pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[9]);
- logger.warn(MARKER, pattern, p1, p2);
- logger.setCurrentEvent(EVENTS[10]);
- logger.warn(simple);
- logger.warn((Marker) null, simple);
- logger.warn((Marker) null, simple, null);
- logger.setCurrentEvent(EVENTS[11]);
- logger.warn(simple, t);
- logger.warn((Marker) null, simple, t);
- logger.setCurrentEvent(EVENTS[12]);
- logger.warn(MARKER, simple, null);
- logger.setCurrentEvent(EVENTS[13]);
- logger.warn(MARKER, simple, t);
- logger.setCurrentEvent(EVENTS[14]);
- logger.warn(MARKER, simple);
-
- logger.setCurrentEvent(EVENTS[15]);
- logger.warn(CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[16]);
- logger.warn(CHAR_SEQ, t);
- logger.setCurrentEvent(EVENTS[17]);
- logger.warn(MARKER, CHAR_SEQ);
- logger.setCurrentEvent(EVENTS[18]);
- logger.warn(MARKER, CHAR_SEQ, t);
-
- assertEquals(4, logger.getCharSeqCount(), "log(CharSeq) invocations");
- assertEquals(5, logger.getObjectCount(), "log(Object) invocations");
- }
-
- @Test
- public void testMessageWithThrowable() {
- final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(true);
- final ThrowableMessage message = new ThrowableMessage(t);
-
- logger.debug(message);
- logger.error(message);
- logger.fatal(message);
- logger.info(message);
- logger.trace(message);
- logger.warn(message);
- logger.log(Level.INFO, message);
-
- logger.debug(MARKER, message);
- logger.error(MARKER, message);
- logger.fatal(MARKER, message);
- logger.info(MARKER, message);
- logger.trace(MARKER, message);
- logger.warn(MARKER, message);
- logger.log(Level.INFO, MARKER, message);
- }
-
- @Test
- public void testMessageWithoutThrowable() {
- final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
- final ThrowableMessage message = new ThrowableMessage(null);
-
- logger.debug(message);
- logger.error(message);
- logger.fatal(message);
- logger.info(message);
- logger.trace(message);
- logger.warn(message);
- logger.log(Level.INFO, message);
-
- logger.debug(MARKER, message);
- logger.error(MARKER, message);
- logger.fatal(MARKER, message);
- logger.info(MARKER, message);
- logger.trace(MARKER, message);
- logger.warn(MARKER, message);
- logger.log(Level.INFO, MARKER, message);
- }
-
- @Test
- public void testMessageSupplierWithThrowable() {
- final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(true);
- final ThrowableMessage message = new ThrowableMessage(t);
- final MessageSupplier supplier = () -> message;
-
- logger.debug(supplier);
- logger.error(supplier);
- logger.fatal(supplier);
- logger.info(supplier);
- logger.trace(supplier);
- logger.warn(supplier);
- logger.log(Level.INFO, supplier);
-
- logger.debug(MARKER, supplier);
- logger.error(MARKER, supplier);
- logger.fatal(MARKER, supplier);
- logger.info(MARKER, supplier);
- logger.trace(MARKER, supplier);
- logger.warn(MARKER, supplier);
- logger.log(Level.INFO, MARKER, supplier);
- }
-
- @Test
- public void testMessageSupplierWithoutThrowable() {
- final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
- final ThrowableMessage message = new ThrowableMessage(null);
- final MessageSupplier supplier = () -> message;
-
- logger.debug(supplier);
- logger.error(supplier);
- logger.fatal(supplier);
- logger.info(supplier);
- logger.trace(supplier);
- logger.warn(supplier);
- logger.log(Level.INFO, supplier);
-
- logger.debug(MARKER, supplier);
- logger.error(MARKER, supplier);
- logger.fatal(MARKER, supplier);
- logger.info(MARKER, supplier);
- logger.trace(MARKER, supplier);
- logger.warn(MARKER, supplier);
- logger.log(Level.INFO, MARKER, supplier);
- }
-
- @Test
- public void testSupplierWithThrowable() {
- final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(true);
- final ThrowableMessage message = new ThrowableMessage(t);
- final Supplier<Message> supplier = () -> message;
-
- logger.debug(supplier);
- logger.error(supplier);
- logger.fatal(supplier);
- logger.info(supplier);
- logger.trace(supplier);
- logger.warn(supplier);
- logger.log(Level.INFO, supplier);
-
- logger.debug(MARKER, supplier);
- logger.error(MARKER, supplier);
- logger.fatal(MARKER, supplier);
- logger.info(MARKER, supplier);
- logger.trace(MARKER, supplier);
- logger.warn(MARKER, supplier);
- logger.log(Level.INFO, MARKER, supplier);
- }
-
- @Test
- public void testSupplierWithoutThrowable() {
- final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
- final ThrowableMessage message = new ThrowableMessage(null);
- final Supplier<Message> supplier = () -> message;
-
- logger.debug(supplier);
- logger.error(supplier);
- logger.fatal(supplier);
- logger.info(supplier);
- logger.trace(supplier);
- logger.warn(supplier);
- logger.log(Level.INFO, supplier);
-
- logger.debug(MARKER, supplier);
- logger.error(MARKER, supplier);
- logger.fatal(MARKER, supplier);
- logger.info(MARKER, supplier);
- logger.trace(MARKER, supplier);
- logger.warn(MARKER, supplier);
- logger.log(Level.INFO, MARKER, supplier);
- }
-
- @Test
- @ResourceLock("log4j2.StatusLogger")
- public void testMessageThrows() {
- final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
- logger.error(new TestMessage(
- () -> {
- throw new IllegalStateException("Oops!");
- },
- "Message Format"));
- final List<StatusData> statusDatalist = StatusLogger.getLogger().getStatusData();
- final StatusData mostRecent = statusDatalist.get(statusDatalist.size() - 1);
- assertEquals(Level.WARN, mostRecent.getLevel());
- assertThat(
- mostRecent.getFormattedStatus(),
- containsString("org.apache.logging.log4j.spi.AbstractLogger caught "
- + "java.lang.IllegalStateException logging TestMessage: Message Format"));
- }
-
- @Test
- @ResourceLock("log4j2.StatusLogger")
- public void testMessageThrowsAndNullFormat() {
- final ThrowableExpectingLogger logger = new ThrowableExpectingLogger(false);
- logger.error(new TestMessage(
- () -> {
- throw new IllegalStateException("Oops!");
- },
- null /* format */));
- final List<StatusData> statusDatalist = StatusLogger.getLogger().getStatusData();
- final StatusData mostRecent = statusDatalist.get(statusDatalist.size() - 1);
- assertEquals(Level.WARN, mostRecent.getLevel());
- assertThat(
- mostRecent.getFormattedStatus(),
- containsString("org.apache.logging.log4j.spi.AbstractLogger caught "
- + "java.lang.IllegalStateException logging TestMessage: "));
- }
-
- private static final class TestMessage implements Message {
- private static final long serialVersionUID = 1L;
- private final FormattedMessageSupplier formattedMessageSupplier;
- private final String format;
-
- TestMessage(final FormattedMessageSupplier formattedMessageSupplier, final String format) {
- this.formattedMessageSupplier = formattedMessageSupplier;
- this.format = format;
- }
-
- @Override
- public String getFormattedMessage() {
- return formattedMessageSupplier.getFormattedMessage();
- }
-
- @Override
- public String getFormat() {
- return format;
- }
-
- @Override
- public Object[] getParameters() {
- return new Object[0];
- }
-
- @Override
- public Throwable getThrowable() {
- return null;
- }
-
- interface FormattedMessageSupplier {
- String getFormattedMessage();
- }
- }
-
- private static class CountingLogger extends AbstractLogger {
- private static final long serialVersionUID = -3171452617952475480L;
-
- private Level currentLevel;
- private LogEvent currentEvent;
- private int charSeqCount;
- private int objectCount;
-
- CountingLogger() {
- super("CountingLogger", new ReusableMessageFactory());
- }
-
- void setCurrentLevel(final Level currentLevel) {
- this.currentLevel = currentLevel;
- }
-
- void setCurrentEvent(final LogEvent currentEvent) {
- this.currentEvent = currentEvent;
- }
-
- int getCharSeqCount() {
- return charSeqCount;
- }
-
- int getObjectCount() {
- return objectCount;
- }
-
- @Override
- public Level getLevel() {
- return currentLevel;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) {
- assertEquals(level, currentLevel, "Incorrect Level. Expected " + currentLevel + ", actual " + level);
- if (marker == null) {
- if (currentEvent.markerName != null) {
- fail("Incorrect marker. Expected " + currentEvent.markerName + ", actual is null");
- }
- } else {
- if (currentEvent.markerName == null) {
- fail("Incorrect marker. Expected null. Actual is " + marker.getName());
- } else {
- assertEquals(
- currentEvent.markerName,
- marker.getName(),
- "Incorrect marker. Expected " + currentEvent.markerName + ", actual " + marker.getName());
- }
- }
- if (data == null) {
- if (currentEvent.data != null) {
- fail("Incorrect message. Expected " + currentEvent.data + ", actual is null");
- }
- } else {
- if (currentEvent.data == null) {
- fail("Incorrect message. Expected null. Actual is " + data.getFormattedMessage());
- } else {
- assertTrue(
- data.getClass().isAssignableFrom(currentEvent.data.getClass()),
- "Incorrect message type. Expected " + currentEvent.data + ", actual " + data);
- assertEquals(
- currentEvent.data.getFormattedMessage(),
- data.getFormattedMessage(),
- "Incorrect message. Expected " + currentEvent.data.getFormattedMessage() + ", actual "
- + data.getFormattedMessage());
- }
- }
- if (t == null) {
- if (currentEvent.t != null) {
- fail("Incorrect Throwable. Expected " + currentEvent.t + ", actual is null");
- }
- } else {
- if (currentEvent.t == null) {
- fail("Incorrect Throwable. Expected null. Actual is " + t);
- } else {
- assertEquals(
- currentEvent.t, t, "Incorrect Throwable. Expected " + currentEvent.t + ", actual " + t);
- }
- }
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final CharSequence data, final Throwable t) {
- charSeqCount++;
- return isEnabled(level, marker, (Message) new SimpleMessage(data), t);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) {
- objectCount++;
- return isEnabled(level, marker, new ObjectMessage(data), t);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data) {
- return isEnabled(level, marker, (Message) new SimpleMessage(data), null);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) {
- return isEnabled(level, marker, new ParameterizedMessage(data, p1), null);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level, final Marker marker, final String message, final Object p0, final Object p1) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8) {
- return isEnabled(
- level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8,
- final Object p9) {
- return isEnabled(
- level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9), null);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) {
- return isEnabled(level, marker, (Message) new SimpleMessage(data), t);
- }
-
- @Override
- public void logMessage(
- final String fqcn, final Level level, final Marker marker, final Message data, final Throwable t) {
- assertEquals(level, currentLevel, "Incorrect Level. Expected " + currentLevel + ", actual " + level);
- if (marker == null) {
- if (currentEvent.markerName != null) {
- fail("Incorrect marker. Expected " + currentEvent.markerName + ", actual is null");
- }
- } else {
- if (currentEvent.markerName == null) {
- fail("Incorrect marker. Expected null. Actual is " + marker.getName());
- } else {
- assertEquals(
- currentEvent.markerName,
- marker.getName(),
- "Incorrect marker. Expected " + currentEvent.markerName + ", actual " + marker.getName());
- }
- }
- if (data == null) {
- if (currentEvent.data != null) {
- fail("Incorrect message. Expected " + currentEvent.data + ", actual is null");
- }
- } else {
- if (currentEvent.data == null) {
- fail("Incorrect message. Expected null. Actual is " + data.getFormattedMessage());
- } else {
- assertTrue(
- data.getClass().isAssignableFrom(currentEvent.data.getClass()),
- "Incorrect message type. Expected " + currentEvent.data + ", actual " + data);
- assertEquals(
- currentEvent.data.getFormattedMessage(),
- data.getFormattedMessage(),
- "Incorrect message. Expected " + currentEvent.data.getFormattedMessage() + ", actual "
- + data.getFormattedMessage());
- }
- }
- if (t == null) {
- if (currentEvent.t != null) {
- fail("Incorrect Throwable. Expected " + currentEvent.t + ", actual is null");
- }
- } else {
- if (currentEvent.t == null) {
- fail("Incorrect Throwable. Expected null. Actual is " + t);
- } else {
- assertEquals(
- currentEvent.t, t, "Incorrect Throwable. Expected " + currentEvent.t + ", actual " + t);
- }
- }
- }
- }
-
- private static class LogEvent {
- String markerName;
- Message data;
- Throwable t;
-
- public LogEvent(final String markerName, final Message data, final Throwable t) {
- this.markerName = markerName;
- this.data = data;
- this.t = t;
- }
- }
-
- private static class ThrowableExpectingLogger extends AbstractLogger {
- private final boolean expectingThrowables;
-
- ThrowableExpectingLogger(final boolean expectingThrowables) {
- super("ThrowableExpectingLogger", new ReusableMessageFactory());
- this.expectingThrowables = expectingThrowables;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Message message, final Throwable t) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level, final Marker marker, final CharSequence message, final Throwable t) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Object message, final Throwable t) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Throwable t) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Object... params) {
- return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level, final Marker marker, final String message, final Object p0, final Object p1) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8) {
- return true;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8,
- final Object p9) {
- return true;
- }
-
- @Override
- public void logMessage(
- final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) {
- if (expectingThrowables) {
- assertNotNull(t, "Expected a Throwable but received null!");
- } else {
- assertNull(t, "Expected null but received a Throwable! " + t);
- }
- if (message != null) {
- message.getFormattedMessage();
- }
- }
-
- @Override
- public Level getLevel() {
- return Level.INFO;
- }
- }
-
- private static class ThrowableMessage implements Message {
- private final Throwable throwable;
-
- public ThrowableMessage(final Throwable throwable) {
- this.throwable = throwable;
- }
-
- @Override
- public String getFormattedMessage() {
- return null;
- }
-
- @Override
- public String getFormat() {
- return null;
- }
-
- @Override
- public Object[] getParameters() {
- return new Object[0];
- }
-
- @Override
- public Throwable getThrowable() {
- return throwable;
- }
- }
-}
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
deleted file mode 100644
index fb1e8df5f6..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/CloseableThreadContextTest.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-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.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.logging.log4j.test.junit.UsingAnyThreadContext;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.ReadsSystemProperty;
-
-/**
- * Tests {@link CloseableThreadContext}.
- *
- * @since 2.6
- */
-@ReadsSystemProperty
-@UsingAnyThreadContext
-public class CloseableThreadContextTest {
-
- private final String key = "key";
- private final String value = "value";
-
- @Test
- public void shouldAddAnEntryToTheMap() {
- try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.put(key, value)) {
- assertNotNull(ignored);
- assertEquals(value, ThreadContext.get(key));
- }
- }
-
- @Test
- public void shouldAddTwoEntriesToTheMap() {
- final String key2 = "key2";
- final String value2 = "value2";
- try (final CloseableThreadContext.Instance ignored =
- CloseableThreadContext.put(key, value).put(key2, value2)) {
- assertNotNull(ignored);
- assertEquals(value, ThreadContext.get(key));
- assertEquals(value2, ThreadContext.get(key2));
- }
- }
-
- @Test
- public void shouldNestEntries() {
- final String oldValue = "oldValue";
- final String innerValue = "innerValue";
- ThreadContext.put(key, oldValue);
- try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.put(key, value)) {
- assertNotNull(ignored);
- assertEquals(value, ThreadContext.get(key));
- try (final CloseableThreadContext.Instance ignored2 = CloseableThreadContext.put(key, innerValue)) {
- assertNotNull(ignored2);
- assertEquals(innerValue, ThreadContext.get(key));
- }
- assertEquals(value, ThreadContext.get(key));
- }
- assertEquals(oldValue, ThreadContext.get(key));
- }
-
- @Test
- public void shouldPreserveOldEntriesFromTheMapWhenAutoClosed() {
- final String oldValue = "oldValue";
- ThreadContext.put(key, oldValue);
- try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.put(key, value)) {
- assertNotNull(ignored);
- assertEquals(value, ThreadContext.get(key));
- }
- assertEquals(oldValue, ThreadContext.get(key));
- }
-
- @Test
- public void ifTheSameKeyIsAddedTwiceTheOriginalShouldBeUsed() {
- final String oldValue = "oldValue";
- final String secondValue = "innerValue";
- ThreadContext.put(key, oldValue);
- try (final CloseableThreadContext.Instance ignored =
- CloseableThreadContext.put(key, value).put(key, secondValue)) {
- assertNotNull(ignored);
- assertEquals(secondValue, ThreadContext.get(key));
- }
- assertEquals(oldValue, ThreadContext.get(key));
- }
-
- @Test
- public void shouldPushAndPopAnEntryToTheStack() {
- final String message = "message";
- try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.push(message)) {
- assertNotNull(ignored);
- assertEquals(message, ThreadContext.peek());
- }
- assertEquals("", ThreadContext.peek());
- }
-
- @Test
- public void shouldPushAndPopTwoEntriesToTheStack() {
- final String message1 = "message1";
- final String message2 = "message2";
- try (final CloseableThreadContext.Instance ignored =
- CloseableThreadContext.push(message1).push(message2)) {
- assertNotNull(ignored);
- assertEquals(message2, ThreadContext.peek());
- }
- assertEquals("", ThreadContext.peek());
- }
-
- @Test
- public void shouldPushAndPopAParameterizedEntryToTheStack() {
- final String parameterizedMessage = "message {}";
- final String parameterizedMessageParameter = "param";
- final String formattedMessage = parameterizedMessage.replace("{}", parameterizedMessageParameter);
- try (final CloseableThreadContext.Instance ignored =
- CloseableThreadContext.push(parameterizedMessage, parameterizedMessageParameter)) {
- assertNotNull(ignored);
- assertEquals(formattedMessage, ThreadContext.peek());
- }
- assertEquals("", ThreadContext.peek());
- }
-
- @Test
- public void shouldRemoveAnEntryFromTheMapWhenAutoClosed() {
- try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.put(key, value)) {
- assertNotNull(ignored);
- assertEquals(value, ThreadContext.get(key));
- }
- assertFalse(ThreadContext.containsKey(key));
- }
-
- @Test
- public void shouldAddEntriesToBothStackAndMap() {
- final String stackValue = "something";
- try (final CloseableThreadContext.Instance ignored =
- CloseableThreadContext.put(key, value).push(stackValue)) {
- assertNotNull(ignored);
- assertEquals(value, ThreadContext.get(key));
- assertEquals(stackValue, ThreadContext.peek());
- }
- assertFalse(ThreadContext.containsKey(key));
- assertEquals("", ThreadContext.peek());
- }
-
- @Test
- public void canReuseCloseableThreadContext() {
- final String stackValue = "something";
- // Create a ctc and close it
- final CloseableThreadContext.Instance ctc =
- CloseableThreadContext.push(stackValue).put(key, value);
- assertNotNull(ctc);
- assertEquals(value, ThreadContext.get(key));
- assertEquals(stackValue, ThreadContext.peek());
- ctc.close();
-
- assertFalse(ThreadContext.containsKey(key));
- assertEquals("", ThreadContext.peek());
-
- final String anotherKey = "key2";
- final String anotherValue = "value2";
- final String anotherStackValue = "something else";
- // Use it again
- ctc.push(anotherStackValue).put(anotherKey, anotherValue);
- assertEquals(anotherValue, ThreadContext.get(anotherKey));
- assertEquals(anotherStackValue, ThreadContext.peek());
- ctc.close();
-
- assertFalse(ThreadContext.containsKey(anotherKey));
- assertEquals("", ThreadContext.peek());
- }
-
- @Test
- public void closeIsIdempotent() {
-
- final String originalMapValue = "map to keep";
- final String originalStackValue = "stack to keep";
- ThreadContext.put(key, originalMapValue);
- ThreadContext.push(originalStackValue);
-
- final String newMapValue = "temp map value";
- final String newStackValue = "temp stack to keep";
- final CloseableThreadContext.Instance ctc =
- CloseableThreadContext.push(newStackValue).put(key, newMapValue);
- assertNotNull(ctc);
-
- ctc.close();
- assertEquals(originalMapValue, ThreadContext.get(key));
- assertEquals(originalStackValue, ThreadContext.peek());
-
- ctc.close();
- assertEquals(originalMapValue, ThreadContext.get(key));
- assertEquals(originalStackValue, ThreadContext.peek());
- }
-
- @Test
- public void putAllWillPutAllValues() {
-
- final String oldValue = "oldValue";
- ThreadContext.put(key, oldValue);
-
- final Map<String, String> valuesToPut = new HashMap<>();
- valuesToPut.put(key, value);
-
- try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.putAll(valuesToPut)) {
- assertNotNull(ignored);
- assertEquals(value, ThreadContext.get(key));
- }
- assertEquals(oldValue, ThreadContext.get(key));
- }
-
- @Test
- public void pushAllWillPushAllValues() {
-
- ThreadContext.push(key);
- final List<String> messages = ThreadContext.getImmutableStack().asList();
- ThreadContext.pop();
-
- try (final CloseableThreadContext.Instance ignored = CloseableThreadContext.pushAll(messages)) {
- assertNotNull(ignored);
- assertEquals(key, ThreadContext.peek());
- }
- assertEquals("", ThreadContext.peek());
- }
-}
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
deleted file mode 100644
index 3b2176a4be..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/EventLoggerTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.List;
-import java.util.Locale;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.apache.logging.log4j.test.TestLogger;
-import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-@UsingThreadContextMap
-public class EventLoggerTest {
-
- TestLogger logger = (TestLogger) LogManager.getLogger("EventLogger");
- List<String> results = logger.getEntries();
-
- @BeforeEach
- public void setup() {
- results.clear();
- }
-
- @Test
- public void structuredData() {
- ThreadContext.put("loginId", "JohnDoe");
- ThreadContext.put("ipAddress", "192.168.0.120");
- ThreadContext.put("locale", Locale.US.getDisplayName());
- final StructuredDataMessage msg = new StructuredDataMessage("Transfer@18060", "Transfer Complete", "Audit");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "123457");
- msg.put("Amount", "200.00");
- EventLogger.logEvent(msg);
- ThreadContext.clearMap();
- assertThat(results).hasSize(1);
- final String expected =
- "EVENT OFF Audit [Transfer@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete";
- assertThat(results.get(0)).startsWith(expected);
- }
-}
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
deleted file mode 100644
index bbe04b2446..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/LambdaLoggerTest.java
+++ /dev/null
@@ -1,1413 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.ReusableMessage;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.util.Supplier;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * Tests the AbstractLogger implementation of the Logger2 interface.
- */
-public class LambdaLoggerTest {
-
- private static class LogEvent {
- @SuppressWarnings("unused")
- final String fqcn;
-
- final Level level;
- final Marker marker;
- final Message message;
- final Throwable throwable;
-
- public LogEvent(
- final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) {
- this.fqcn = fqcn;
- this.level = level;
- this.marker = marker;
- this.message = (message instanceof ReusableMessage) ? ((ReusableMessage) message).memento() : message;
- this.throwable = t;
- }
- }
-
- private static class Logger2Impl extends AbstractLogger {
- private static final long serialVersionUID = 1L;
-
- boolean enabled = true;
- final List<LambdaLoggerTest.LogEvent> list = new ArrayList<>();
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Message message, final Throwable t) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(
- final Level level, final Marker marker, final CharSequence message, final Throwable t) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Object message, final Throwable t) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Throwable t) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Object... params) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(
- final Level level, final Marker marker, final String message, final Object p0, final Object p1) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8) {
- return enabled;
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8,
- final Object p9) {
- return enabled;
- }
-
- @Override
- public void logMessage(
- final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) {
- list.add(new LogEvent(fqcn, level, marker, message, t));
- }
-
- @Override
- public Level getLevel() {
- return null;
- }
-
- public AbstractLogger disable() {
- enabled = false;
- return this;
- }
-
- public AbstractLogger enable() {
- enabled = true;
- return this;
- }
- }
-
- final Logger2Impl logger2 = new Logger2Impl();
- final String stringMessage = "Hi";
- final Message message = new SimpleMessage("HiMessage");
- final Throwable throwable = new Error("I'm Bad");
- final Marker marker = MarkerManager.getMarker("test");
-
- private class MyMessageSupplier implements Supplier<Message> {
- public boolean invoked = false;
-
- @Override
- public Message get() {
- invoked = true;
- return message;
- }
- }
-
- final MyMessageSupplier messageSupplier = new MyMessageSupplier();
-
- private class MySupplier implements Supplier<String> {
- public boolean invoked = false;
-
- @Override
- public String get() {
- invoked = true;
- return stringMessage;
- }
- }
-
- final MySupplier supplier = new MySupplier();
- final MySupplier supplier2 = new MySupplier();
- final Supplier<?>[] supplierArray1 = new Supplier<?>[] {supplier};
- final Supplier<?>[] supplierArray2 = new Supplier<?>[] {supplier, supplier2};
-
- @BeforeEach
- public void beforeEachTest() {
- logger2.list.clear();
- supplier.invoked = false;
- messageSupplier.invoked = false;
- }
-
- @Test
- public void testDebugMarkerMessageSupplier() {
- logger2.disable().debug(marker, messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().debug(marker, messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.DEBUG, event.level);
- assertSame(message, event.message);
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testDebugMessageSupplier() {
- logger2.disable().debug(messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().debug(messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.DEBUG, event.level);
- assertSame(message, event.message);
- }
-
- @Test
- public void testDebugMarkerMessageSupplierThrowable() {
- logger2.disable().debug(marker, messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().debug(marker, messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.DEBUG, event.level);
- assertSame(marker, event.marker);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testDebugMessageSupplierThrowable() {
- logger2.disable().debug(messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().debug(messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.DEBUG, event.level);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testDebugMarkerSupplier() {
- logger2.disable().debug(marker, supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().debug(marker, supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.DEBUG, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testDebugSupplier() {
- logger2.disable().debug(supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().debug(supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.DEBUG, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- }
-
- @Test
- public void testDebugMarkerSupplierThrowable() {
- logger2.disable().debug(marker, supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().debug(marker, supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.DEBUG, event.level);
- assertSame(marker, event.marker);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testDebugSupplierThrowable() {
- logger2.disable().debug(supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().debug(supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.DEBUG, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testDebugStringParamSupplier() {
- logger2.disable().debug("abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().debug("abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.DEBUG, event.level);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testDebugMarkerStringParamSupplier() {
- logger2.disable().debug(marker, "abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().debug(marker, "abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.DEBUG, event.level);
- assertSame(marker, event.marker);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testErrorMarkerMessageSupplier() {
- logger2.disable().error(marker, messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().error(marker, messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.ERROR, event.level);
- assertSame(message, event.message);
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testErrorMessageSupplier() {
- logger2.disable().error(messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().error(messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.ERROR, event.level);
- assertSame(message, event.message);
- }
-
- @Test
- public void testErrorMarkerMessageSupplierThrowable() {
- logger2.disable().error(marker, messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().error(marker, messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.ERROR, event.level);
- assertSame(marker, event.marker);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testErrorMessageSupplierThrowable() {
- logger2.disable().error(messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().error(messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.ERROR, event.level);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testErrorMarkerSupplier() {
- logger2.disable().error(marker, supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().error(marker, supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.ERROR, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testErrorSupplier() {
- logger2.disable().error(supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().error(supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.ERROR, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- }
-
- @Test
- public void testErrorMarkerSupplierThrowable() {
- logger2.disable().error(marker, supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().error(marker, supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.ERROR, event.level);
- assertSame(marker, event.marker);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testErrorSupplierThrowable() {
- logger2.disable().error(supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().error(supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.ERROR, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testErrorStringParamSupplier() {
- logger2.disable().error("abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().error("abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.ERROR, event.level);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testErrorMarkerStringParamSupplier() {
- logger2.disable().error(marker, "abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().error(marker, "abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.ERROR, event.level);
- assertSame(marker, event.marker);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testFatalMarkerMessageSupplier() {
- logger2.disable().fatal(marker, messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().fatal(marker, messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertSame(message, event.message);
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testFatalMessageSupplier() {
- logger2.disable().fatal(messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().fatal(messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertSame(message, event.message);
- }
-
- @Test
- public void testFatalMarkerMessageSupplierThrowable() {
- logger2.disable().fatal(marker, messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().fatal(marker, messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertSame(marker, event.marker);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testFatalMessageSupplierThrowable() {
- logger2.disable().fatal(messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().fatal(messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testFatalMarkerSupplier() {
- logger2.disable().fatal(marker, supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().fatal(marker, supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testFatalSupplier() {
- logger2.disable().fatal(supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().fatal(supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- }
-
- @Test
- public void testFatalMarkerSupplierThrowable() {
- logger2.disable().fatal(marker, supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().fatal(marker, supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertSame(marker, event.marker);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testFatalSupplierThrowable() {
- logger2.disable().fatal(supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().fatal(supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testFatalStringParamSupplier() {
- logger2.disable().fatal("abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().fatal("abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testFatalStringParam2Suppliers() {
- logger2.disable().fatal("abc {}{}", supplierArray2);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
- assertFalse(supplier2.invoked);
-
- logger2.enable().fatal("abc {}{}", supplierArray2);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
- assertTrue(supplier2.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertEquals("abc HiHi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testFatalMarkerStringParamSupplier() {
- logger2.disable().fatal(marker, "abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().fatal(marker, "abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.FATAL, event.level);
- assertSame(marker, event.marker);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testInfoMarkerMessageSupplier() {
- logger2.disable().info(marker, messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().info(marker, messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.INFO, event.level);
- assertSame(message, event.message);
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testInfoMessageSupplier() {
- logger2.disable().info(messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().info(messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.INFO, event.level);
- assertSame(message, event.message);
- }
-
- @Test
- public void testInfoMarkerMessageSupplierThrowable() {
- logger2.disable().info(marker, messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().info(marker, messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.INFO, event.level);
- assertSame(marker, event.marker);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testInfoMessageSupplierThrowable() {
- logger2.disable().info(messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().info(messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.INFO, event.level);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testInfoMarkerSupplier() {
- logger2.disable().info(marker, supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().info(marker, supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.INFO, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testInfoSupplier() {
- logger2.disable().info(supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().info(supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.INFO, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- }
-
- @Test
- public void testInfoMarkerSupplierThrowable() {
- logger2.disable().info(marker, supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().info(marker, supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.INFO, event.level);
- assertSame(marker, event.marker);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testInfoSupplierThrowable() {
- logger2.disable().info(supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().info(supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.INFO, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testInfoStringParamSupplier() {
- logger2.disable().info("abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().info("abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.INFO, event.level);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testInfoMarkerStringParamSupplier() {
- logger2.disable().info(marker, "abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().info(marker, "abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.INFO, event.level);
- assertSame(marker, event.marker);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testTraceMarkerMessageSupplier() {
- logger2.disable().trace(marker, messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().trace(marker, messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.TRACE, event.level);
- assertSame(message, event.message);
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testTraceMessageSupplier() {
- logger2.disable().trace(messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().trace(messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.TRACE, event.level);
- assertSame(message, event.message);
- }
-
- @Test
- public void testTraceMarkerMessageSupplierThrowable() {
- logger2.disable().trace(marker, messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().trace(marker, messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.TRACE, event.level);
- assertSame(marker, event.marker);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testTraceMessageSupplierThrowable() {
- logger2.disable().trace(messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().trace(messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.TRACE, event.level);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testTraceMarkerSupplier() {
- logger2.disable().trace(marker, supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().trace(marker, supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.TRACE, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testTraceSupplier() {
- logger2.disable().trace(supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().trace(supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.TRACE, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- }
-
- @Test
- public void testTraceMarkerSupplierThrowable() {
- logger2.disable().trace(marker, supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().trace(marker, supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.TRACE, event.level);
- assertSame(marker, event.marker);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testTraceSupplierThrowable() {
- logger2.disable().trace(supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().trace(supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.TRACE, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testTraceStringParamSupplier() {
- logger2.disable().trace("abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().trace("abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.TRACE, event.level);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testTraceMarkerStringParamSupplier() {
- logger2.disable().trace(marker, "abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().trace(marker, "abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.TRACE, event.level);
- assertSame(marker, event.marker);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testWarnMarkerMessageSupplier() {
- logger2.disable().warn(marker, messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().warn(marker, messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(message, event.message);
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testWarnMessageSupplier() {
- logger2.disable().warn(messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().warn(messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(message, event.message);
- }
-
- @Test
- public void testWarnMarkerMessageSupplierThrowable() {
- logger2.disable().warn(marker, messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().warn(marker, messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(marker, event.marker);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testWarnMessageSupplierThrowable() {
- logger2.disable().warn(messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().warn(messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testWarnMarkerSupplier() {
- logger2.disable().warn(marker, supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().warn(marker, supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testWarnSupplier() {
- logger2.disable().warn(supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().warn(supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- }
-
- @Test
- public void testWarnMarkerSupplierThrowable() {
- logger2.disable().warn(marker, supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().warn(marker, supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(marker, event.marker);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testWarnSupplierThrowable() {
- logger2.disable().warn(supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().warn(supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testWarnStringParamSupplier() {
- logger2.disable().warn("abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().warn("abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testWarnMarkerStringParamSupplier() {
- logger2.disable().warn(marker, "abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().warn(marker, "abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(marker, event.marker);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testLogMarkerMessageSupplier() {
- logger2.disable().log(Level.WARN, marker, messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().log(Level.WARN, marker, messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(message, event.message);
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testLogMessageSupplier() {
- logger2.disable().log(Level.WARN, messageSupplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().log(Level.WARN, messageSupplier);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(message, event.message);
- }
-
- @Test
- public void testLogMarkerMessageSupplierThrowable() {
- logger2.disable().log(Level.WARN, marker, messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().log(Level.WARN, marker, messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(marker, event.marker);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testLogMessageSupplierThrowable() {
- logger2.disable().log(Level.WARN, messageSupplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(messageSupplier.invoked);
-
- logger2.enable().log(Level.WARN, messageSupplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(messageSupplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(message, event.message);
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testLogMarkerSupplier() {
- logger2.disable().log(Level.WARN, marker, supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().log(Level.WARN, marker, supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(marker, event.marker);
- }
-
- @Test
- public void testLogSupplier() {
- logger2.disable().log(Level.WARN, supplier);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().log(Level.WARN, supplier);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- }
-
- @Test
- public void testLogMarkerSupplierThrowable() {
- logger2.disable().log(Level.WARN, marker, supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().log(Level.WARN, marker, supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(marker, event.marker);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testLogSupplierThrowable() {
- logger2.disable().log(Level.WARN, supplier, throwable);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().log(Level.WARN, supplier, throwable);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(stringMessage, event.message.getFormattedMessage());
- assertSame(throwable, event.throwable);
- }
-
- @Test
- public void testLogStringParamSupplier() {
- logger2.disable().log(Level.WARN, "abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().log(Level.WARN, "abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-
- @Test
- public void testLogMarkerStringParamSupplier() {
- logger2.disable().log(Level.WARN, marker, "abc {}", supplierArray1);
- assertTrue(logger2.list.isEmpty());
- assertFalse(supplier.invoked);
-
- logger2.enable().log(Level.WARN, marker, "abc {}", supplierArray1);
- assertEquals(1, logger2.list.size());
- assertTrue(supplier.invoked);
-
- final LogEvent event = logger2.list.get(0);
- assertEquals(Level.WARN, event.level);
- assertSame(marker, event.marker);
- assertEquals("abc Hi", event.message.getFormattedMessage());
- }
-}
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
deleted file mode 100644
index a666126872..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/LevelTest.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-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.assertThrowsExactly;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.junit.jupiter.api.Test;
-
-public class LevelTest {
-
- @Test
- public void testDefault() {
- final Level level = Level.toLevel("Information", Level.ERROR);
- assertNotNull(level);
- assertEquals(Level.ERROR, level);
- }
-
- @Test
- public void testForNameEquals() {
- final String name = "Foo";
- final int intValue = 1;
- final Level level = Level.forName(name, intValue);
- assertNotNull(level);
- assertEquals(level, Level.forName(name, intValue));
- assertEquals(level, Level.getLevel(name));
- assertEquals(level, Level.toLevel(name));
- assertEquals(intValue, Level.getLevel(name).intLevel());
- }
-
- @Test
- public 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
- assertNull(Level.getLevel("Bar"));
- assertThrowsExactly(IllegalArgumentException.class, () -> Level.forName("Bar", -1));
- }
-
- @Test
- public void testGoodLevels() {
- final Level level = Level.toLevel("INFO");
- assertNotNull(level);
- assertEquals(Level.INFO, level);
- }
-
- @Test
- public void testLevelsWithSpaces() {
- Level level = Level.toLevel(" INFO ");
- assertNotNull(level);
- assertEquals(Level.INFO, level);
-
- level = Level.valueOf(" INFO ");
- assertNotNull(level);
- assertEquals(Level.INFO, level);
- }
-
- @Test
- public 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));
- assertTrue(Level.WARN.isInRange(Level.ERROR, Level.DEBUG));
- assertTrue(Level.INFO.isInRange(Level.ERROR, Level.DEBUG));
- assertTrue(Level.DEBUG.isInRange(Level.ERROR, Level.DEBUG));
- assertFalse(Level.TRACE.isInRange(Level.ERROR, Level.DEBUG));
- assertFalse(Level.ALL.isInRange(Level.ERROR, Level.DEBUG));
- }
-
- @Test
- public 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));
- assertTrue(Level.WARN.isInRange(Level.FATAL, Level.TRACE));
- assertTrue(Level.INFO.isInRange(Level.FATAL, Level.TRACE));
- assertTrue(Level.DEBUG.isInRange(Level.FATAL, Level.TRACE));
- assertTrue(Level.TRACE.isInRange(Level.FATAL, Level.TRACE));
- assertFalse(Level.ALL.isInRange(Level.FATAL, Level.TRACE));
- }
-
- @Test
- public 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));
- assertTrue(Level.WARN.isInRange(Level.OFF, Level.ALL));
- assertTrue(Level.INFO.isInRange(Level.OFF, Level.ALL));
- assertTrue(Level.DEBUG.isInRange(Level.OFF, Level.ALL));
- assertTrue(Level.TRACE.isInRange(Level.OFF, Level.ALL));
- assertTrue(Level.ALL.isInRange(Level.OFF, Level.ALL));
- }
-
- @Test
- public void testIsInRangeSameLevels() {
- // Level.OFF
- assertTrue(Level.OFF.isInRange(Level.OFF, Level.OFF));
- assertFalse(Level.OFF.isInRange(Level.FATAL, Level.FATAL));
- assertFalse(Level.OFF.isInRange(Level.ERROR, Level.ERROR));
- assertFalse(Level.OFF.isInRange(Level.WARN, Level.WARN));
- assertFalse(Level.OFF.isInRange(Level.INFO, Level.INFO));
- assertFalse(Level.OFF.isInRange(Level.DEBUG, Level.DEBUG));
- assertFalse(Level.OFF.isInRange(Level.TRACE, Level.TRACE));
- assertFalse(Level.OFF.isInRange(Level.ALL, Level.ALL));
- // Level.FATAL
- assertFalse(Level.FATAL.isInRange(Level.OFF, Level.OFF));
- assertTrue(Level.FATAL.isInRange(Level.FATAL, Level.FATAL));
- assertFalse(Level.FATAL.isInRange(Level.ERROR, Level.ERROR));
- assertFalse(Level.FATAL.isInRange(Level.WARN, Level.WARN));
- assertFalse(Level.FATAL.isInRange(Level.INFO, Level.INFO));
- assertFalse(Level.FATAL.isInRange(Level.DEBUG, Level.DEBUG));
- assertFalse(Level.FATAL.isInRange(Level.TRACE, Level.TRACE));
- assertFalse(Level.FATAL.isInRange(Level.ALL, Level.ALL));
- // Level.ERROR
- assertFalse(Level.ERROR.isInRange(Level.OFF, Level.OFF));
- assertFalse(Level.ERROR.isInRange(Level.FATAL, Level.FATAL));
- assertTrue(Level.ERROR.isInRange(Level.ERROR, Level.ERROR));
- assertFalse(Level.ERROR.isInRange(Level.WARN, Level.WARN));
- assertFalse(Level.ERROR.isInRange(Level.INFO, Level.INFO));
- assertFalse(Level.ERROR.isInRange(Level.DEBUG, Level.DEBUG));
- assertFalse(Level.ERROR.isInRange(Level.TRACE, Level.TRACE));
- assertFalse(Level.ERROR.isInRange(Level.ALL, Level.ALL));
- // Level.WARN
- assertFalse(Level.WARN.isInRange(Level.OFF, Level.OFF));
- assertFalse(Level.WARN.isInRange(Level.FATAL, Level.FATAL));
- assertFalse(Level.WARN.isInRange(Level.ERROR, Level.ERROR));
- assertTrue(Level.WARN.isInRange(Level.WARN, Level.WARN));
- assertFalse(Level.WARN.isInRange(Level.INFO, Level.INFO));
- assertFalse(Level.WARN.isInRange(Level.DEBUG, Level.DEBUG));
- assertFalse(Level.WARN.isInRange(Level.TRACE, Level.TRACE));
- assertFalse(Level.WARN.isInRange(Level.ALL, Level.ALL));
- // Level.INFO
- assertFalse(Level.INFO.isInRange(Level.OFF, Level.OFF));
- assertFalse(Level.INFO.isInRange(Level.FATAL, Level.FATAL));
- assertFalse(Level.INFO.isInRange(Level.ERROR, Level.ERROR));
- assertFalse(Level.INFO.isInRange(Level.WARN, Level.WARN));
- assertTrue(Level.INFO.isInRange(Level.INFO, Level.INFO));
- assertFalse(Level.INFO.isInRange(Level.DEBUG, Level.DEBUG));
- assertFalse(Level.INFO.isInRange(Level.TRACE, Level.TRACE));
- assertFalse(Level.INFO.isInRange(Level.ALL, Level.ALL));
- // Level.DEBUG
- assertFalse(Level.DEBUG.isInRange(Level.OFF, Level.OFF));
- assertFalse(Level.DEBUG.isInRange(Level.FATAL, Level.FATAL));
- assertFalse(Level.DEBUG.isInRange(Level.ERROR, Level.ERROR));
- assertFalse(Level.DEBUG.isInRange(Level.WARN, Level.WARN));
- assertFalse(Level.DEBUG.isInRange(Level.INFO, Level.INFO));
- assertTrue(Level.DEBUG.isInRange(Level.DEBUG, Level.DEBUG));
- assertFalse(Level.DEBUG.isInRange(Level.TRACE, Level.TRACE));
- assertFalse(Level.DEBUG.isInRange(Level.ALL, Level.ALL));
- // Level.TRACE
- assertFalse(Level.TRACE.isInRange(Level.OFF, Level.OFF));
- assertFalse(Level.TRACE.isInRange(Level.FATAL, Level.FATAL));
- assertFalse(Level.TRACE.isInRange(Level.ERROR, Level.ERROR));
- assertFalse(Level.TRACE.isInRange(Level.WARN, Level.WARN));
- assertFalse(Level.TRACE.isInRange(Level.INFO, Level.INFO));
- assertFalse(Level.TRACE.isInRange(Level.DEBUG, Level.DEBUG));
- assertTrue(Level.TRACE.isInRange(Level.TRACE, Level.TRACE));
- assertFalse(Level.TRACE.isInRange(Level.ALL, Level.ALL));
- // Level.ALL
- assertFalse(Level.ALL.isInRange(Level.OFF, Level.OFF));
- assertFalse(Level.ALL.isInRange(Level.FATAL, Level.FATAL));
- assertFalse(Level.ALL.isInRange(Level.ERROR, Level.ERROR));
- assertFalse(Level.ALL.isInRange(Level.WARN, Level.WARN));
- assertFalse(Level.ALL.isInRange(Level.INFO, Level.INFO));
- assertFalse(Level.ALL.isInRange(Level.DEBUG, Level.DEBUG));
- assertFalse(Level.ALL.isInRange(Level.TRACE, Level.TRACE));
- assertTrue(Level.ALL.isInRange(Level.ALL, Level.ALL));
- }
-
- @Test
- public 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));
- assertTrue(Level.WARN.isInRange(Level.WARN, Level.INFO));
- assertTrue(Level.INFO.isInRange(Level.WARN, Level.INFO));
- assertFalse(Level.DEBUG.isInRange(Level.WARN, Level.INFO));
- assertFalse(Level.TRACE.isInRange(Level.WARN, Level.INFO));
- assertFalse(Level.ALL.isInRange(Level.WARN, Level.INFO));
- }
-
- @Test
- public void testIsLessSpecificThan() {
- // Level.OFF
- assertTrue(Level.OFF.isLessSpecificThan(Level.OFF));
- assertFalse(Level.OFF.isLessSpecificThan(Level.FATAL));
- assertFalse(Level.OFF.isLessSpecificThan(Level.ERROR));
- assertFalse(Level.OFF.isLessSpecificThan(Level.WARN));
- assertFalse(Level.OFF.isLessSpecificThan(Level.INFO));
- assertFalse(Level.OFF.isLessSpecificThan(Level.DEBUG));
- assertFalse(Level.OFF.isLessSpecificThan(Level.TRACE));
- assertFalse(Level.OFF.isLessSpecificThan(Level.ALL));
- // Level.FATAL
- assertTrue(Level.FATAL.isLessSpecificThan(Level.OFF));
- assertTrue(Level.FATAL.isLessSpecificThan(Level.FATAL));
- assertFalse(Level.FATAL.isLessSpecificThan(Level.ERROR));
- assertFalse(Level.FATAL.isLessSpecificThan(Level.WARN));
- assertFalse(Level.FATAL.isLessSpecificThan(Level.INFO));
- assertFalse(Level.FATAL.isLessSpecificThan(Level.DEBUG));
- assertFalse(Level.FATAL.isLessSpecificThan(Level.TRACE));
- assertFalse(Level.FATAL.isLessSpecificThan(Level.ALL));
- // Level.ERROR
- assertTrue(Level.ERROR.isLessSpecificThan(Level.OFF));
- assertTrue(Level.ERROR.isLessSpecificThan(Level.FATAL));
- assertTrue(Level.ERROR.isLessSpecificThan(Level.ERROR));
- assertFalse(Level.ERROR.isLessSpecificThan(Level.WARN));
- assertFalse(Level.ERROR.isLessSpecificThan(Level.INFO));
- assertFalse(Level.ERROR.isLessSpecificThan(Level.DEBUG));
- assertFalse(Level.ERROR.isLessSpecificThan(Level.TRACE));
- assertFalse(Level.ERROR.isLessSpecificThan(Level.ALL));
- // Level.ERROR
- assertTrue(Level.WARN.isLessSpecificThan(Level.OFF));
- assertTrue(Level.WARN.isLessSpecificThan(Level.FATAL));
- assertTrue(Level.WARN.isLessSpecificThan(Level.ERROR));
- assertTrue(Level.WARN.isLessSpecificThan(Level.WARN));
- assertFalse(Level.WARN.isLessSpecificThan(Level.INFO));
- assertFalse(Level.WARN.isLessSpecificThan(Level.DEBUG));
- assertFalse(Level.WARN.isLessSpecificThan(Level.TRACE));
- assertFalse(Level.WARN.isLessSpecificThan(Level.ALL));
- // Level.WARN
- assertTrue(Level.WARN.isLessSpecificThan(Level.OFF));
- assertTrue(Level.WARN.isLessSpecificThan(Level.FATAL));
- assertTrue(Level.WARN.isLessSpecificThan(Level.ERROR));
- assertTrue(Level.WARN.isLessSpecificThan(Level.WARN));
- assertFalse(Level.WARN.isLessSpecificThan(Level.INFO));
- assertFalse(Level.WARN.isLessSpecificThan(Level.DEBUG));
- assertFalse(Level.WARN.isLessSpecificThan(Level.TRACE));
- assertFalse(Level.WARN.isLessSpecificThan(Level.ALL));
- // Level.INFO
- assertTrue(Level.INFO.isLessSpecificThan(Level.OFF));
- assertTrue(Level.INFO.isLessSpecificThan(Level.FATAL));
- assertTrue(Level.INFO.isLessSpecificThan(Level.ERROR));
- assertTrue(Level.INFO.isLessSpecificThan(Level.WARN));
- assertTrue(Level.INFO.isLessSpecificThan(Level.INFO));
- assertFalse(Level.INFO.isLessSpecificThan(Level.DEBUG));
- assertFalse(Level.INFO.isLessSpecificThan(Level.TRACE));
- assertFalse(Level.INFO.isLessSpecificThan(Level.ALL));
- // Level.DEBUG
- assertTrue(Level.DEBUG.isLessSpecificThan(Level.OFF));
- assertTrue(Level.DEBUG.isLessSpecificThan(Level.FATAL));
- assertTrue(Level.DEBUG.isLessSpecificThan(Level.ERROR));
- assertTrue(Level.DEBUG.isLessSpecificThan(Level.WARN));
- assertTrue(Level.DEBUG.isLessSpecificThan(Level.INFO));
- assertTrue(Level.DEBUG.isLessSpecificThan(Level.DEBUG));
- assertFalse(Level.DEBUG.isLessSpecificThan(Level.TRACE));
- assertFalse(Level.DEBUG.isLessSpecificThan(Level.ALL));
- // Level.TRACE
- assertTrue(Level.TRACE.isLessSpecificThan(Level.OFF));
- assertTrue(Level.TRACE.isLessSpecificThan(Level.FATAL));
- assertTrue(Level.TRACE.isLessSpecificThan(Level.ERROR));
- assertTrue(Level.TRACE.isLessSpecificThan(Level.WARN));
- assertTrue(Level.TRACE.isLessSpecificThan(Level.INFO));
- assertTrue(Level.TRACE.isLessSpecificThan(Level.DEBUG));
- assertTrue(Level.TRACE.isLessSpecificThan(Level.TRACE));
- assertFalse(Level.TRACE.isLessSpecificThan(Level.ALL));
- // Level.ALL
- assertTrue(Level.ALL.isLessSpecificThan(Level.OFF));
- assertTrue(Level.ALL.isLessSpecificThan(Level.FATAL));
- assertTrue(Level.ALL.isLessSpecificThan(Level.ERROR));
- assertTrue(Level.ALL.isLessSpecificThan(Level.WARN));
- assertTrue(Level.ALL.isLessSpecificThan(Level.INFO));
- assertTrue(Level.ALL.isLessSpecificThan(Level.DEBUG));
- assertTrue(Level.ALL.isLessSpecificThan(Level.TRACE));
- assertTrue(Level.ALL.isLessSpecificThan(Level.ALL));
- }
-}
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
deleted file mode 100644
index 2e767bc7cf..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/LogManagerTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import java.io.Closeable;
-import java.io.IOException;
-import org.apache.logging.log4j.message.ReusableMessageFactory;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.ReadsSystemProperty;
-
-@ReadsSystemProperty
-public class LogManagerTest {
-
- @SuppressWarnings("InnerClassMayBeStatic")
- class Inner {
- final Logger LOGGER = LogManager.getLogger();
- }
-
- @SuppressWarnings("InnerClassMayBeStatic")
- class InnerByClass {
- final Logger LOGGER = LogManager.getLogger(InnerByClass.class);
- }
-
- static class StaticInner {
- static final Logger LOGGER = LogManager.getLogger();
- }
-
- static class StaticInnerByClass {
- static final Logger LOGGER = LogManager.getLogger(StaticInnerByClass.class);
- }
-
- @Test
- public void testGetLogger() {
- Logger logger = LogManager.getLogger();
- assertNotNull(logger, "No Logger returned");
- assertEquals(LogManagerTest.class.getName(), logger.getName(), "Incorrect Logger name: " + logger.getName());
- final ReusableMessageFactory messageFactory = new ReusableMessageFactory();
- logger = LogManager.getLogger(messageFactory);
- assertNotNull(logger, "No Logger returned");
- assertEquals(LogManagerTest.class.getName(), logger.getName(), "Incorrect Logger name: " + logger.getName());
- logger = LogManager.getLogger((Class<?>) null);
- assertNotNull(logger, "No Logger returned");
- assertEquals(LogManagerTest.class.getName(), logger.getName(), "Incorrect Logger name: " + logger.getName());
- logger = LogManager.getLogger((Class<?>) null, messageFactory);
- assertNotNull(logger, "No Logger returned");
- assertEquals(LogManagerTest.class.getName(), logger.getName(), "Incorrect Logger name: " + logger.getName());
- logger = LogManager.getLogger((String) null);
- assertNotNull(logger, "No Logger returned");
- assertEquals(LogManagerTest.class.getName(), logger.getName(), "Incorrect Logger name: " + logger.getName());
- logger = LogManager.getLogger((String) null, messageFactory);
- assertNotNull(logger, "No Logger returned");
- assertEquals(LogManagerTest.class.getName(), logger.getName(), "Incorrect Logger name: " + logger.getName());
- logger = LogManager.getLogger((Object) null);
- assertNotNull(logger, "No Logger returned");
- assertEquals(LogManagerTest.class.getName(), logger.getName(), "Incorrect Logger name: " + logger.getName());
- logger = LogManager.getLogger((Object) null, messageFactory);
- assertNotNull(logger, "No Logger returned");
- assertEquals(LogManagerTest.class.getName(), logger.getName(), "Incorrect Logger name: " + logger.getName());
- }
-
- @Test
- public void testGetLoggerForAnonymousInnerClass1() throws IOException {
- final Closeable closeable = new Closeable() {
-
- final Logger LOGGER = LogManager.getLogger();
-
- @Override
- public void close() throws IOException {
- assertEquals("org.apache.logging.log4j.LogManagerTest$1", LOGGER.getName());
- }
- };
- closeable.close();
- }
-
- @Test
- public void testGetLoggerForAnonymousInnerClass2() throws IOException {
- final Closeable closeable = new Closeable() {
-
- final Logger LOGGER = LogManager.getLogger(getClass());
-
- @Override
- public void close() throws IOException {
- assertEquals("org.apache.logging.log4j.LogManagerTest$2", LOGGER.getName());
- }
- };
- closeable.close();
- }
-
- @Test
- public void testGetLoggerForInner() {
- assertEquals("org.apache.logging.log4j.LogManagerTest.Inner", new Inner().LOGGER.getName());
- }
-
- @Test
- public void testGetLoggerForInnerByClass() {
- assertEquals("org.apache.logging.log4j.LogManagerTest.InnerByClass", new InnerByClass().LOGGER.getName());
- }
-
- @Test
- public void testGetLoggerForStaticInner() {
- assertEquals("org.apache.logging.log4j.LogManagerTest.StaticInner", StaticInner.LOGGER.getName());
- }
-
- @Test
- public void testGetLoggerForStaticInnerByClass() {
- assertEquals("org.apache.logging.log4j.LogManagerTest.StaticInnerByClass", StaticInnerByClass.LOGGER.getName());
- }
-
- @Test
- public 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
deleted file mode 100644
index 609807d8e2..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerSupplierTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.List;
-import java.util.Locale;
-import java.util.Properties;
-import org.apache.logging.log4j.message.FormattedMessage;
-import org.apache.logging.log4j.message.JsonMessage;
-import org.apache.logging.log4j.message.LocalizedMessage;
-import org.apache.logging.log4j.message.MessageFormatMessage;
-import org.apache.logging.log4j.message.ObjectArrayMessage;
-import org.apache.logging.log4j.message.ObjectMessage;
-import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.message.StringFormattedMessage;
-import org.apache.logging.log4j.message.ThreadDumpMessage;
-import org.apache.logging.log4j.test.TestLogger;
-import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
-import org.apache.logging.log4j.util.Supplier;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.parallel.ResourceLock;
-import org.junit.jupiter.api.parallel.Resources;
-
-/**
- * Tests Logger APIs with {@link Supplier}.
- */
-@ResourceLock(Resources.LOCALE)
-@UsingThreadContextMap
-public class LoggerSupplierTest {
-
- private final TestLogger logger = (TestLogger) LogManager.getLogger(LoggerSupplierTest.class);
-
- private final List<String> results = logger.getEntries();
-
- Locale defaultLocale;
-
- @Test
- public void flowTracing_SupplierOfFormattedMessage() {
- logger.traceEntry(() -> new FormattedMessage("int foo={}", 1234567890));
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("(int foo=1234567890)")
- .doesNotContain("FormattedMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfJsonMessage() {
- final Properties props = new Properties();
- props.setProperty("foo", "bar");
- logger.traceEntry(() -> new JsonMessage(props));
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("\"foo\":\"bar\"")
- .doesNotContain("JsonMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfLocalizedMessage() {
- logger.traceEntry(() -> new LocalizedMessage("int foo={}", 1234567890));
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("(int foo=1234567890)")
- .doesNotContain("LocalizedMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfLong() {
- logger.traceEntry(() -> 1234567890L);
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("(1234567890)")
- .doesNotContain("SimpleMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfMessageFormatMessage() {
- logger.traceEntry(() -> new MessageFormatMessage("int foo={0}", 1234567890));
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("(int foo=1,234,567,890)")
- .doesNotContain("MessageFormatMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfObjectArrayMessage() {
- logger.traceEntry(() -> new ObjectArrayMessage(1234567890));
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("([1234567890])")
- .doesNotContain("ObjectArrayMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfObjectMessage() {
- logger.traceEntry(() -> new ObjectMessage(1234567890));
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("(1234567890)")
- .doesNotContain("ObjectMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfParameterizedMessage() {
- logger.traceEntry(() -> new ParameterizedMessage("int foo={}", 1234567890));
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("(int foo=1234567890)")
- .doesNotContain("ParameterizedMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfSimpleMessage() {
- logger.traceEntry(() -> new SimpleMessage("1234567890"));
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("(1234567890)")
- .doesNotContain("SimpleMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfString() {
- logger.traceEntry(() -> "1234567890");
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("(1234567890)")
- .doesNotContain("SimpleMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfStringFormattedMessage() {
- logger.traceEntry(() -> new StringFormattedMessage("int foo=%,d", 1234567890));
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("(int foo=1,234,567,890)")
- .doesNotContain("StringFormattedMessage");
- }
-
- @Test
- public void flowTracing_SupplierOfThreadDumpMessage() {
- logger.traceEntry(() -> new ThreadDumpMessage("Title of ..."));
- assertThat(results).hasSize(1);
- final String entry = results.get(0);
- assertThat(entry)
- .startsWith("ENTER[ FLOW ] TRACE Enter")
- .contains("RUNNABLE", "Title of ...", getClass().getName());
- }
-
- @BeforeEach
- public void setup() {
- results.clear();
- defaultLocale = Locale.getDefault(Locale.Category.FORMAT);
- Locale.setDefault(Locale.Category.FORMAT, java.util.Locale.US);
- }
-
- @AfterEach
- public 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
deleted file mode 100644
index 7f4d6b8b37..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerTest.java
+++ /dev/null
@@ -1,693 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-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.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Properties;
-import org.apache.logging.log4j.message.EntryMessage;
-import org.apache.logging.log4j.message.JsonMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.MessageFactory;
-import org.apache.logging.log4j.message.ObjectMessage;
-import org.apache.logging.log4j.message.ReusableMessageFactory;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.message.SimpleMessageFactory;
-import org.apache.logging.log4j.message.StringFormatterMessageFactory;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.apache.logging.log4j.test.TestLogger;
-import org.apache.logging.log4j.test.TestLoggerContextFactory;
-import org.apache.logging.log4j.test.junit.LoggerContextFactoryExtension;
-import org.apache.logging.log4j.test.junit.Resources;
-import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
-import org.apache.logging.log4j.util.Strings;
-import org.apache.logging.log4j.util.Supplier;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.junit.jupiter.api.parallel.ResourceAccessMode;
-import org.junit.jupiter.api.parallel.ResourceLock;
-import org.junitpioneer.jupiter.ReadsSystemProperty;
-
-@ResourceLock(value = Resources.MARKER_MANAGER, mode = ResourceAccessMode.READ)
-@ReadsSystemProperty
-public class LoggerTest {
-
- @RegisterExtension
- public static final LoggerContextFactoryExtension EXTENSION =
- new LoggerContextFactoryExtension(new TestLoggerContextFactory());
-
- private static class TestReusableMessageFactory {
- // empty
- }
-
- private static class TestStringFormatterMessageFactory {
- // empty
- }
-
- private final TestLogger logger = (TestLogger) LogManager.getLogger(LoggerTest.class);
- private final Marker marker = MarkerManager.getMarker("test");
- private final List<String> results = logger.getEntries();
-
- @Test
- public 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!"));
- assertEquals(3, results.size());
- assertThat(
- "Incorrect message 1",
- results.get(0),
- equalTo(" DEBUG org.apache.logging.log4j.LoggerTest.builder(LoggerTest.java:78) Hello"));
- assertThat("Incorrect message 2", results.get(1), equalTo("test ERROR Hello John"));
- assertThat(
- "Incorrect message 3",
- results.get(2),
- startsWith(" WARN Log4j rocks! java.lang.Throwable: This is a test"));
- assertThat(
- "Throwable incorrect in message 3",
- results.get(2),
- containsString("org.apache.logging.log4j.LoggerTest.builder(LoggerTest.java:80)"));
- }
-
- @Test
- public void basicFlow() {
- logger.traceEntry();
- logger.traceExit();
- assertEquals(2, results.size());
- assertThat(results.get(0)).isEqualTo("ENTER[ FLOW ] TRACE Enter");
- assertThat(results.get(1)).isEqualTo("EXIT[ FLOW ] TRACE Exit");
- }
-
- @Test
- public void flowTracingMessage() {
- final Properties props = new Properties();
- props.setProperty("foo", "bar");
- logger.traceEntry(new JsonMessage(props));
- final Response response = new Response(-1, "Generic error");
- logger.traceExit(new JsonMessage(response), response);
- assertThat(results).hasSize(2);
- assertThat(results.get(0)).startsWith("ENTER[ FLOW ] TRACE Enter").contains("\"foo\":\"bar\"");
- assertThat(results.get(1)).startsWith("EXIT[ FLOW ] TRACE Exit").contains("\"message\":\"Generic error\"");
- }
-
- @Test
- public void flowTracingString_ObjectArray1() {
- logger.traceEntry("doFoo(a={}, b={})", 1, 2);
- logger.traceExit("doFoo(a=1, b=2): {}", 3);
- assertThat(results).hasSize(2);
- assertThat(results.get(0)).startsWith("ENTER[ FLOW ] TRACE Enter").contains("doFoo(a=1, b=2)");
- assertThat(results.get(1)).startsWith("EXIT[ FLOW ] TRACE Exit").contains("doFoo(a=1, b=2): 3");
- }
-
- @Test
- public void flowTracingExitValueOnly() {
- logger.traceEntry("doFoo(a={}, b={})", 1, 2);
- logger.traceExit(3);
- assertThat(results).hasSize(2);
- assertThat(results.get(0)).startsWith("ENTER[ FLOW ] TRACE Enter").contains("doFoo(a=1, b=2)");
- assertThat(results.get(1)).startsWith("EXIT[ FLOW ] TRACE Exit").contains("3");
- }
-
- @Test
- public void flowTracingString_ObjectArray2() {
- final EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", 1, 2);
- logger.traceExit(msg, 3);
- assertThat(results).hasSize(2);
- assertThat(results.get(0)).startsWith("ENTER[ FLOW ] TRACE Enter").contains("doFoo(a=1, b=2)");
- assertThat(results.get(1)).startsWith("EXIT[ FLOW ] TRACE Exit").contains("doFoo(a=1, b=2): 3");
- }
-
- @Test
- public void flowTracingVoidReturn() {
- final EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", 1, 2);
- logger.traceExit(msg);
- assertThat(results).hasSize(2);
- assertThat(results.get(0)).startsWith("ENTER[ FLOW ] TRACE Enter").contains("doFoo(a=1, b=2)");
- assertThat(results.get(1)).startsWith("EXIT[ FLOW ] TRACE Exit").endsWith("doFoo(a=1, b=2)");
- }
-
- @Test
- public void flowTracingNoExitArgs() {
- logger.traceEntry();
- logger.traceExit();
- assertThat(results).hasSize(2);
- assertThat(results.get(0)).startsWith("ENTER[ FLOW ] TRACE Enter");
- assertThat(results.get(1)).startsWith("EXIT[ FLOW ] TRACE Exit");
- }
-
- @Test
- public void flowTracingNoArgs() {
- final EntryMessage message = logger.traceEntry();
- logger.traceExit(message);
- assertThat(results).hasSize(2);
- assertThat(results.get(0)).startsWith("ENTER[ FLOW ] TRACE Enter");
- assertThat(results.get(1)).startsWith("EXIT[ FLOW ] TRACE Exit");
- }
-
- @Test
- public void flowTracingString_SupplierOfObjectMessages() {
- final EntryMessage msg = logger.traceEntry(
- "doFoo(a={}, b={})",
- new Supplier<Message>() {
- @Override
- public Message get() {
- return new ObjectMessage(1);
- }
- },
- new Supplier<Message>() {
- @Override
- public Message get() {
- return new ObjectMessage(2);
- }
- });
- logger.traceExit(msg, 3);
- assertThat(results).hasSize(2);
- assertThat(results.get(0)).startsWith("ENTER[ FLOW ] TRACE Enter").contains("doFoo(a=1, b=2)");
- assertThat(results.get(1)).startsWith("EXIT[ FLOW ] TRACE Exit").contains("doFoo(a=1, b=2): 3");
- }
-
- @Test
- public void flowTracingString_SupplierOfStrings() {
- final EntryMessage msg = logger.traceEntry(
- "doFoo(a={}, b={})",
- new Supplier<String>() {
- @Override
- public String get() {
- return "1";
- }
- },
- new Supplier<String>() {
- @Override
- public String get() {
- return "2";
- }
- });
- logger.traceExit(msg, 3);
- assertThat(results).hasSize(2);
- assertThat(results.get(0)).startsWith("ENTER[ FLOW ] TRACE Enter").contains("doFoo(a=1, b=2)");
- assertThat(results.get(1)).startsWith("EXIT[ FLOW ] TRACE Exit").contains("doFoo(a=1, b=2): 3");
- }
-
- @Test
- public void flowTracingNoFormat() {
- logger.traceEntry(null, 1, "2", new ObjectMessage(3));
- logger.traceExit((String) null, 4);
- assertThat(results).hasSize(2);
- assertThat(results.get(0)).isEqualTo("ENTER[ FLOW ] TRACE Enter params(1, 2, 3)");
- assertThat(results.get(1)).isEqualTo("EXIT[ FLOW ] TRACE Exit with(4)");
- }
-
- @Test
- public void catching() {
- try {
- throw new NullPointerException();
- } catch (final Exception e) {
- logger.catching(e);
- assertEquals(1, results.size());
- assertThat(
- "Incorrect Catching",
- results.get(0),
- startsWith("CATCHING[ EXCEPTION ] ERROR Catching java.lang.NullPointerException"));
- }
- }
-
- @Test
- public void debug() {
- logger.debug("Debug message");
- assertEquals(1, results.size());
- assertTrue(results.get(0).startsWith(" DEBUG Debug message"), "Incorrect message");
- }
-
- @Test
- public void debugObject() {
- logger.debug(new Date());
- assertEquals(1, results.size());
- assertTrue(results.get(0).length() > 7, "Invalid length");
- }
-
- @Test
- public void debugWithParms() {
- logger.debug("Hello, {}", "World");
- assertEquals(1, results.size());
- assertTrue(results.get(0).startsWith(" DEBUG Hello, World"), "Incorrect substitution");
- }
-
- @Test
- public void debugWithParmsAndThrowable() {
- logger.debug("Hello, {}", "World", new RuntimeException("Test Exception"));
- assertEquals(1, results.size());
- assertTrue(
- results.get(0).startsWith(" DEBUG Hello, World java.lang.RuntimeException: Test Exception"),
- "Unexpected results: " + results.get(0));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- @ResourceLock(value = org.junit.jupiter.api.parallel.Resources.LOCALE, mode = ResourceAccessMode.READ)
- public 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();
- final TestLogger altLogger = (TestLogger) LogManager.getFormatterLogger(getClass());
- assertEquals(testLogger.getName(), altLogger.getName());
- assertNotNull(testLogger);
- assertMessageFactoryInstanceOf(testLogger.getMessageFactory(), StringFormatterMessageFactory.class);
- assertEqualMessageFactory(StringFormatterMessageFactory.INSTANCE, testLogger);
- testLogger.debug("%,d", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(
- String.format(" DEBUG %,d", Integer.MAX_VALUE),
- testLogger.getEntries().get(0));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- @ResourceLock(value = org.junit.jupiter.api.parallel.Resources.LOCALE, mode = ResourceAccessMode.READ)
- public 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 =
- (TestLogger) LogManager.getFormatterLogger(TestStringFormatterMessageFactory.class);
- assertNotNull(testLogger);
- assertMessageFactoryInstanceOf(testLogger.getMessageFactory(), StringFormatterMessageFactory.class);
- assertEqualMessageFactory(StringFormatterMessageFactory.INSTANCE, testLogger);
- testLogger.debug("%,d", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(
- String.format(" DEBUG %,d", Integer.MAX_VALUE),
- testLogger.getEntries().get(0));
- }
-
- private static void assertMessageFactoryInstanceOf(final MessageFactory factory, final Class<?> cls) {
- assertTrue(factory.getClass().isAssignableFrom(cls));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- @ResourceLock(value = org.junit.jupiter.api.parallel.Resources.LOCALE, mode = ResourceAccessMode.READ)
- public 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 =
- (TestLogger) LogManager.getFormatterLogger(new TestStringFormatterMessageFactory());
- assertNotNull(testLogger);
- assertMessageFactoryInstanceOf(testLogger.getMessageFactory(), StringFormatterMessageFactory.class);
- assertEqualMessageFactory(StringFormatterMessageFactory.INSTANCE, testLogger);
- testLogger.debug("%,d", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(
- String.format(" DEBUG %,d", Integer.MAX_VALUE),
- testLogger.getEntries().get(0));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- @ResourceLock(value = org.junit.jupiter.api.parallel.Resources.LOCALE, mode = ResourceAccessMode.READ)
- public void getFormatterLogger_String() {
- final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
- final TestLogger testLogger =
- (TestLogger) LogManager.getFormatterLogger("getLogger_String_StringFormatterMessageFactory");
- assertNotNull(testLogger);
- assertMessageFactoryInstanceOf(testLogger.getMessageFactory(), StringFormatterMessageFactory.class);
- assertEqualMessageFactory(messageFactory, testLogger);
- testLogger.debug("%,d", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(
- String.format(" DEBUG %,d", Integer.MAX_VALUE),
- testLogger.getEntries().get(0));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- public void getLogger_Class_ReusableMessageFactory() {
- // 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 MessageFactory messageFactory = new ReusableMessageFactory();
- final TestLogger testLogger =
- (TestLogger) LogManager.getLogger(TestReusableMessageFactory.class, messageFactory);
- assertNotNull(testLogger);
- assertEqualMessageFactory(messageFactory, testLogger);
- testLogger.debug("{}", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(" DEBUG " + Integer.MAX_VALUE, testLogger.getEntries().get(0));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- public 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)
- LogManager.getLogger(TestStringFormatterMessageFactory.class, StringFormatterMessageFactory.INSTANCE);
- assertNotNull(testLogger);
- assertEqualMessageFactory(StringFormatterMessageFactory.INSTANCE, testLogger);
- testLogger.debug("%,d", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(
- String.format(" DEBUG %,d", Integer.MAX_VALUE),
- testLogger.getEntries().get(0));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- public void getLogger_Object_ReusableMessageFactory() {
- // 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 MessageFactory messageFactory = new ReusableMessageFactory();
- final TestLogger testLogger =
- (TestLogger) LogManager.getLogger(new TestReusableMessageFactory(), messageFactory);
- assertNotNull(testLogger);
- assertEqualMessageFactory(messageFactory, testLogger);
- testLogger.debug("{}", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(" DEBUG " + Integer.MAX_VALUE, testLogger.getEntries().get(0));
- }
-
- private void assertEqualMessageFactory(final MessageFactory messageFactory, final TestLogger testLogger) {
- final MessageFactory actual = testLogger.getMessageFactory();
- assertEquals(messageFactory, actual);
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- public 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;
- final TestLogger testLogger =
- (TestLogger) LogManager.getLogger(new TestStringFormatterMessageFactory(), messageFactory);
- assertNotNull(testLogger);
- assertEqualMessageFactory(messageFactory, testLogger);
- testLogger.debug("%,d", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(
- String.format(" DEBUG %,d", Integer.MAX_VALUE),
- testLogger.getEntries().get(0));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- public void getLogger_String_MessageFactoryMismatch() {
- final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
- final TestLogger testLogger =
- (TestLogger) LogManager.getLogger("getLogger_String_MessageFactoryMismatch", messageFactory);
- assertNotNull(testLogger);
- assertEqualMessageFactory(messageFactory, testLogger);
- final TestLogger testLogger2 = (TestLogger)
- LogManager.getLogger("getLogger_String_MessageFactoryMismatch", new ReusableMessageFactory());
- assertNotNull(testLogger2);
- // TODO: How to test?
- // This test context always creates new loggers, other test context impls I tried fail other tests.
- // assertEquals(messageFactory, testLogger2.getMessageFactory());
- testLogger.debug("%,d", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(
- String.format(" DEBUG %,d", Integer.MAX_VALUE),
- testLogger.getEntries().get(0));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- public void getLogger_String_ReusableMessageFactory() {
- final MessageFactory messageFactory = new ReusableMessageFactory();
- final TestLogger testLogger =
- (TestLogger) LogManager.getLogger("getLogger_String_ReusableMessageFactory", messageFactory);
- assertNotNull(testLogger);
- assertEqualMessageFactory(messageFactory, testLogger);
- testLogger.debug("{}", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(" DEBUG " + Integer.MAX_VALUE, testLogger.getEntries().get(0));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- public void getLogger_String_SimpleMessageFactory() {
- final SimpleMessageFactory messageFactory = SimpleMessageFactory.INSTANCE;
- final TestLogger testLogger =
- (TestLogger) LogManager.getLogger("getLogger_String_StringFormatterMessageFactory", messageFactory);
- assertNotNull(testLogger);
- assertEqualMessageFactory(messageFactory, testLogger);
- testLogger.debug("{} %,d {foo}", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(" DEBUG {} %,d {foo}", testLogger.getEntries().get(0));
- }
-
- @Test
- @ResourceLock("log4j2.TestLogger")
- public void getLogger_String_StringFormatterMessageFactory() {
- final StringFormatterMessageFactory messageFactory = StringFormatterMessageFactory.INSTANCE;
- final TestLogger testLogger =
- (TestLogger) LogManager.getLogger("getLogger_String_StringFormatterMessageFactory", messageFactory);
- assertNotNull(testLogger);
- assertEqualMessageFactory(messageFactory, testLogger);
- testLogger.debug("%,d", Integer.MAX_VALUE);
- assertEquals(1, testLogger.getEntries().size());
- assertEquals(
- String.format(" DEBUG %,d", Integer.MAX_VALUE),
- testLogger.getEntries().get(0));
- }
-
- @Test
- public void getLoggerByClass() {
- final Logger classLogger = LogManager.getLogger(LoggerTest.class);
- assertNotNull(classLogger);
- }
-
- @Test
- public void getLoggerByNullClass() {
- // Returns a SimpleLogger
- assertNotNull(LogManager.getLogger((Class<?>) null));
- }
-
- @Test
- public void getLoggerByNullObject() {
- // Returns a SimpleLogger
- assertNotNull(LogManager.getLogger((Object) null));
- }
-
- @Test
- public void getLoggerByNullString() {
- // Returns a SimpleLogger
- assertNotNull(LogManager.getLogger((String) null));
- }
-
- @Test
- public void getLoggerByObject() {
- final Logger classLogger = LogManager.getLogger(this);
- assertNotNull(classLogger);
- assertEquals(classLogger, LogManager.getLogger(LoggerTest.class));
- }
-
- @Test
- public void getRootLogger() {
- assertNotNull(LogManager.getRootLogger());
- assertNotNull(LogManager.getLogger(Strings.EMPTY));
- assertNotNull(LogManager.getLogger(LogManager.ROOT_LOGGER_NAME));
- assertEquals(LogManager.getRootLogger(), LogManager.getLogger(Strings.EMPTY));
- assertEquals(LogManager.getRootLogger(), LogManager.getLogger(LogManager.ROOT_LOGGER_NAME));
- }
-
- @Test
- public void isAllEnabled() {
- assertTrue(logger.isEnabled(Level.ALL), "Incorrect level");
- }
-
- @Test
- public void isDebugEnabled() {
- assertTrue(logger.isDebugEnabled(), "Incorrect level");
- assertTrue(logger.isEnabled(Level.DEBUG), "Incorrect level");
- }
-
- @Test
- public void isErrorEnabled() {
- assertTrue(logger.isErrorEnabled(), "Incorrect level");
- assertTrue(logger.isEnabled(Level.ERROR), "Incorrect level");
- }
-
- @Test
- public void isFatalEnabled() {
- assertTrue(logger.isFatalEnabled(), "Incorrect level");
- assertTrue(logger.isEnabled(Level.FATAL), "Incorrect level");
- }
-
- @Test
- public void isInfoEnabled() {
- assertTrue(logger.isInfoEnabled(), "Incorrect level");
- assertTrue(logger.isEnabled(Level.INFO), "Incorrect level");
- }
-
- @Test
- public void isOffEnabled() {
- assertTrue(logger.isEnabled(Level.OFF), "Incorrect level");
- }
-
- @Test
- public void isTraceEnabled() {
- assertTrue(logger.isTraceEnabled(), "Incorrect level");
- assertTrue(logger.isEnabled(Level.TRACE), "Incorrect level");
- }
-
- @Test
- public void isWarnEnabled() {
- assertTrue(logger.isWarnEnabled(), "Incorrect level");
- assertTrue(logger.isEnabled(Level.WARN), "Incorrect level");
- }
-
- @Test
- public void isAllEnabledWithMarker() {
- assertTrue(logger.isEnabled(Level.ALL, marker), "Incorrect level");
- }
-
- @Test
- public void isDebugEnabledWithMarker() {
- assertTrue(logger.isDebugEnabled(marker), "Incorrect level");
- assertTrue(logger.isEnabled(Level.DEBUG, marker), "Incorrect level");
- }
-
- @Test
- public void isErrorEnabledWithMarker() {
- assertTrue(logger.isErrorEnabled(marker), "Incorrect level");
- assertTrue(logger.isEnabled(Level.ERROR, marker), "Incorrect level");
- }
-
- @Test
- public void isFatalEnabledWithMarker() {
- assertTrue(logger.isFatalEnabled(marker), "Incorrect level");
- assertTrue(logger.isEnabled(Level.FATAL, marker), "Incorrect level");
- }
-
- @Test
- public void isInfoEnabledWithMarker() {
- assertTrue(logger.isInfoEnabled(marker), "Incorrect level");
- assertTrue(logger.isEnabled(Level.INFO, marker), "Incorrect level");
- }
-
- @Test
- public void isOffEnabledWithMarker() {
- assertTrue(logger.isEnabled(Level.OFF, marker), "Incorrect level");
- }
-
- @Test
- public void isTraceEnabledWithMarker() {
- assertTrue(logger.isTraceEnabled(marker), "Incorrect level");
- assertTrue(logger.isEnabled(Level.TRACE, marker), "Incorrect level");
- }
-
- @Test
- public void isWarnEnabledWithMarker() {
- assertTrue(logger.isWarnEnabled(marker), "Incorrect level");
- assertTrue(logger.isEnabled(Level.WARN, marker), "Incorrect level");
- }
-
- @Test
- @UsingThreadContextMap
- public void mdc() {
- ThreadContext.put("TestYear", Integer.valueOf(2010).toString());
- logger.debug("Debug message");
- final String testYear = ThreadContext.get("TestYear");
- assertNotNull(testYear, "Test Year is null");
- assertEquals("2010", testYear, "Incorrect test year: " + testYear);
- ThreadContext.clearMap();
- logger.debug("Debug message");
- assertEquals(2, results.size());
- System.out.println("Log line 1: " + results.get(0));
- System.out.println("log line 2: " + results.get(1));
- assertTrue(
- results.get(0).startsWith(" DEBUG Debug message {TestYear=2010}"), "Incorrect MDC: " + results.get(0));
- assertTrue(results.get(1).startsWith(" DEBUG Debug message"), "MDC not cleared?: " + results.get(1));
- }
-
- @Test
- public 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());
- assertThat("Incorrect message", results.get(0), startsWith(" DEBUG Debug message 1"));
- assertThat("Incorrect message", results.get(1), startsWith("Test DEBUG Debug message 2"));
- }
-
- @BeforeEach
- public void setup() {
- results.clear();
- }
-
- @Test
- public void structuredData() {
- ThreadContext.put("loginId", "JohnDoe");
- ThreadContext.put("ipAddress", "192.168.0.120");
- ThreadContext.put("locale", Locale.US.getDisplayName());
- final StructuredDataMessage msg = new StructuredDataMessage("Audit@18060", "Transfer Complete", "Transfer");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "123457");
- msg.put("Amount", "200.00");
- logger.info(MarkerManager.getMarker("EVENT"), msg);
- ThreadContext.clearMap();
- assertEquals(1, results.size());
- assertThat(
- "Incorrect structured data: ",
- results.get(0),
- startsWith(
- "EVENT INFO Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete"));
- }
-
- @Test
- public void throwing() {
- logger.throwing(new IllegalArgumentException("Test Exception"));
- assertEquals(1, results.size());
- assertThat(
- "Incorrect Throwing",
- results.get(0),
- startsWith("THROWING[ EXCEPTION ] ERROR Throwing java.lang.IllegalArgumentException: Test Exception"));
- }
-
- private static class Response {
- int status;
- String message;
-
- public Response(final int status, final String message) {
- this.status = status;
- this.message = message;
- }
-
- public int getStatus() {
- return status;
- }
-
- public void setStatus(final int status) {
- this.status = status;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(final String message) {
- this.message = message;
- }
- }
-}
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
deleted file mode 100644
index 598aac9388..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/MarkerTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-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 org.apache.logging.log4j.test.junit.Resources;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.parallel.ResourceAccessMode;
-import org.junit.jupiter.api.parallel.ResourceLock;
-
-@ResourceLock(value = Resources.MARKER_MANAGER, mode = ResourceAccessMode.READ_WRITE)
-public class MarkerTest {
-
- @BeforeEach
- public void setUp() {
- MarkerManager.clear();
- }
-
- @Test
- public void testGetMarker() {
- final Marker expected = MarkerManager.getMarker("A");
- assertNull(expected.getParents());
- }
-
- @Test
- public void testGetMarkerWithParents() {
- final Marker expected = MarkerManager.getMarker("A");
- final Marker p1 = MarkerManager.getMarker("P1");
- p1.addParents(MarkerManager.getMarker("PP1"));
- final Marker p2 = MarkerManager.getMarker("P2");
- expected.addParents(p1);
- expected.addParents(p2);
- assertEquals(2, expected.getParents().length);
- }
-
- @Test
- public void testHasParents() {
- final Marker parent = MarkerManager.getMarker("PARENT");
- final Marker existing = MarkerManager.getMarker("EXISTING");
- assertFalse(existing.hasParents());
- existing.setParents(parent);
- assertTrue(existing.hasParents());
- }
-
- @Test
- public void testMarker() {
- final Marker parent = MarkerManager.getMarker("PARENT");
- final Marker test1 = MarkerManager.getMarker("TEST1").setParents(parent);
- final Marker test2 = MarkerManager.getMarker("TEST2").addParents(parent);
- assertTrue(test1.isInstanceOf(parent), "TEST1 is not an instance of PARENT");
- assertTrue(test2.isInstanceOf(parent), "TEST2 is not an instance of PARENT");
- }
-
- @Test
- public void testMultipleParents() {
- final Marker parent1 = MarkerManager.getMarker("PARENT1");
- final Marker parent2 = MarkerManager.getMarker("PARENT2");
- final Marker test1 = MarkerManager.getMarker("TEST1").setParents(parent1, parent2);
- final Marker test2 = MarkerManager.getMarker("TEST2").addParents(parent1, parent2);
- assertTrue(test1.isInstanceOf(parent1), "TEST1 is not an instance of PARENT1");
- assertTrue(test1.isInstanceOf(parent2), "TEST1 is not an instance of PARENT2");
- assertTrue(test2.isInstanceOf(parent1), "TEST2 is not an instance of PARENT1");
- assertTrue(test2.isInstanceOf(parent2), "TEST2 is not an instance of PARENT2");
- }
-
- @Test
- public void testAddToExistingParents() {
- final Marker parent = MarkerManager.getMarker("PARENT");
- final Marker existing = MarkerManager.getMarker("EXISTING");
- final Marker test1 = MarkerManager.getMarker("TEST1").setParents(existing);
- test1.addParents(parent);
- assertTrue(test1.isInstanceOf(parent), "TEST1 is not an instance of PARENT");
- assertTrue(test1.isInstanceOf(existing), "TEST1 is not an instance of EXISTING");
- }
-
- @Test
- public void testDuplicateParents() {
- final Marker parent = MarkerManager.getMarker("PARENT");
- final Marker existing = MarkerManager.getMarker("EXISTING");
- final Marker test1 = MarkerManager.getMarker("TEST1").setParents(existing);
- test1.addParents(parent);
- final Marker[] parents = test1.getParents();
- test1.addParents(existing);
- assertEquals(parents.length, test1.getParents().length, "duplicate add allowed");
- test1.addParents(existing, MarkerManager.getMarker("EXTRA"));
- assertEquals(parents.length + 1, test1.getParents().length, "incorrect add");
- assertTrue(test1.isInstanceOf(parent), "TEST1 is not an instance of PARENT");
- assertTrue(test1.isInstanceOf(existing), "TEST1 is not an instance of 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
deleted file mode 100644
index ef51fdf7d3..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/NoopThreadContextTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import org.apache.logging.log4j.spi.LoggingSystemProperty;
-import org.apache.logging.log4j.test.junit.InitializesThreadContext;
-import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.SetSystemProperty;
-
-/**
- * Tests {@link ThreadContext}.
- */
-public class NoopThreadContextTest {
-
- @Test
- @SetSystemProperty(key = LoggingSystemProperty.Constant.THREAD_CONTEXT_ENABLED, value = "false")
- @SetSystemProperty(key = LoggingSystemProperty.Constant.THREAD_CONTEXT_MAP_ENABLED, value = "false")
- @InitializesThreadContext
- @UsingThreadContextMap
- public 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/TestProvider.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/TestProvider.java
deleted file mode 100644
index 1fb46b581c..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/TestProvider.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-import org.apache.logging.log4j.spi.Provider;
-import org.apache.logging.log4j.test.TestLoggerContextFactory;
-
-/**
- * Binding for the Log4j API.
- */
-public class TestProvider extends Provider {
- public TestProvider() {
- super(0, "3.0.0", TestLoggerContextFactory.class);
- }
-}
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
deleted file mode 100644
index 08f216ba90..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/ThreadContextInheritanceTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-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 org.apache.logging.log4j.spi.LoggingSystemProperty;
-import org.apache.logging.log4j.test.ThreadContextUtilityClass;
-import org.apache.logging.log4j.test.junit.InitializesThreadContext;
-import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
-import org.apache.logging.log4j.test.junit.UsingThreadContextStack;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.SetSystemProperty;
-
-/**
- * Tests {@link ThreadContext}.
- */
-@SetSystemProperty(key = LoggingSystemProperty.Constant.THREAD_CONTEXT_MAP_INHERITABLE, value = "true")
-@InitializesThreadContext
-public class ThreadContextInheritanceTest {
-
- @Test
- @UsingThreadContextStack
- public 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");
- }
-
- @Test
- @SetSystemProperty(key = LoggingSystemProperty.Constant.THREAD_CONTEXT_MAP_INHERITABLE, value = "true")
- @InitializesThreadContext
- public void testInheritanceSwitchedOn() throws Exception {
- ThreadContext.put("Greeting", "Hello");
- StringBuilder sb = new StringBuilder();
- TestThread thread = new TestThread(sb);
- thread.start();
- thread.join();
- String str = sb.toString();
- assertEquals("Hello", str, "Unexpected ThreadContext value. Expected Hello. Actual " + str);
- sb = new StringBuilder();
- thread = new TestThread(sb);
- thread.start();
- thread.join();
- str = sb.toString();
- assertEquals("Hello", str, "Unexpected ThreadContext value. Expected Hello. Actual " + str);
- }
-
- @Test
- @Tag("performance")
- @UsingThreadContextMap
- public void perfTest() {
- ThreadContextUtilityClass.perfTest();
- }
-
- @Test
- @UsingThreadContextMap
- public void testGetContextReturnsEmptyMapIfEmpty() {
- ThreadContextUtilityClass.testGetContextReturnsEmptyMapIfEmpty();
- }
-
- @Test
- @UsingThreadContextMap
- public void testGetContextReturnsMutableCopy() {
- ThreadContextUtilityClass.testGetContextReturnsMutableCopy();
- }
-
- @Test
- @UsingThreadContextMap
- public void testGetImmutableContextReturnsEmptyMapIfEmpty() {
- ThreadContextUtilityClass.testGetImmutableContextReturnsEmptyMapIfEmpty();
- }
-
- @Test
- @UsingThreadContextMap
- public void testGetImmutableContextReturnsImmutableMapIfNonEmpty() {
- ThreadContextUtilityClass.testGetImmutableContextReturnsImmutableMapIfNonEmpty();
- }
-
- @Test
- @UsingThreadContextMap
- public void testGetImmutableContextReturnsImmutableMapIfEmpty() {
- ThreadContextUtilityClass.testGetImmutableContextReturnsImmutableMapIfEmpty();
- }
-
- @Test
- @UsingThreadContextStack
- public void testGetImmutableStackReturnsEmptyStackIfEmpty() {
- ThreadContextUtilityClass.testGetImmutableStackReturnsEmptyStackIfEmpty();
- }
-
- @Test
- @UsingThreadContextMap
- public void testPut() {
- ThreadContextUtilityClass.testPut();
- }
-
- @Test
- @UsingThreadContextMap
- public void testRemove() {
- assertNull(ThreadContext.get("testKey"));
- ThreadContext.put("testKey", "testValue");
- assertEquals("testValue", ThreadContext.get("testKey"));
-
- ThreadContext.remove("testKey");
- assertNull(ThreadContext.get("testKey"));
- assertTrue(ThreadContext.isEmpty());
- }
-
- @Test
- @UsingThreadContextMap
- public void testContainsKey() {
- assertFalse(ThreadContext.containsKey("testKey"));
- ThreadContext.put("testKey", "testValue");
- assertTrue(ThreadContext.containsKey("testKey"));
-
- ThreadContext.remove("testKey");
- assertFalse(ThreadContext.containsKey("testKey"));
- }
-
- private static class TestThread extends Thread {
-
- private final StringBuilder sb;
-
- public TestThread(final StringBuilder sb) {
- this.sb = sb;
- }
-
- @Override
- public void run() {
- final String greeting = ThreadContext.get("Greeting");
- if (greeting == null) {
- sb.append("null");
- } else {
- sb.append(greeting);
- }
- ThreadContext.clearMap();
- }
- }
-}
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
deleted file mode 100644
index dcdd6bd4cf..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/TraceLoggingTest.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import org.apache.logging.log4j.message.DefaultFlowMessageFactory;
-import org.apache.logging.log4j.message.EntryMessage;
-import org.apache.logging.log4j.message.FlowMessageFactory;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.ObjectMessage;
-import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.logging.log4j.message.ReusableParameterizedMessage;
-import org.apache.logging.log4j.message.ReusableParameterizedMessageTest;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.junit.jupiter.api.Test;
-
-public class TraceLoggingTest extends AbstractLogger {
- static final StringBuilder CHAR_SEQ = new StringBuilder("CharSeq");
- private int charSeqCount;
- private int objectCount;
-
- private static class LogEvent {
-
- String markerName;
- Message data;
- Throwable t;
-
- public LogEvent(final String markerName, final Message data, final Throwable t) {
- this.markerName = markerName;
- this.data = data;
- this.t = t;
- }
- }
-
- private static final long serialVersionUID = 1L;
-
- private static Level currentLevel;
-
- private LogEvent currentEvent;
-
- private static final Throwable t = new UnsupportedOperationException("Test");
-
- private static final Class<AbstractLogger> obj = AbstractLogger.class;
- private static final String pattern = "{}, {}";
- private static final String p1 = "Long Beach";
-
- private static final String p2 = "California";
- private static final Message charSeq = new SimpleMessage(CHAR_SEQ);
- private static final Message simple = new SimpleMessage("Hello");
- private static final Message object = new ObjectMessage(obj);
-
- private static final Message param = new ParameterizedMessage(pattern, p1, p2);
-
- private static final String marker = "TEST";
-
- @Override
- public Level getLevel() {
- return currentLevel;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) {
- return true;
- // assertTrue("Incorrect Level. Expected " + currentLevel + ", actual " + level,
- // level.equals(currentLevel));
- // if (marker == null) {
- // if (currentEvent.markerName != null) {
- // fail("Incorrect marker. Expected " + currentEvent.markerName + ", actual is null");
- // }
- // } else {
- // if (currentEvent.markerName == null) {
- // fail("Incorrect marker. Expected null. Actual is " + marker.getName());
- // } else {
- // assertTrue("Incorrect marker. Expected " + currentEvent.markerName + ", actual " +
- // marker.getName(), currentEvent.markerName.equals(marker.getName()));
- // }
- // }
- // if (data == null) {
- // if (currentEvent.data != null) {
- // fail("Incorrect message. Expected " + currentEvent.data + ", actual is null");
- // }
- // } else {
- // if (currentEvent.data == null) {
- // fail("Incorrect message. Expected null. Actual is " + data.getFormattedMessage());
- // } else {
- // assertTrue("Incorrect message type. Expected " + currentEvent.data + ", actual " + data,
- // data.getClass().isAssignableFrom(currentEvent.data.getClass()));
- // assertTrue("Incorrect message. Expected " + currentEvent.data.getFormattedMessage() + ",
- // actual " +
- // data.getFormattedMessage(),
- // currentEvent.data.getFormattedMessage().equals(data.getFormattedMessage()));
- // }
- // }
- // if (t == null) {
- // if (currentEvent.t != null) {
- // fail("Incorrect Throwable. Expected " + currentEvent.t + ", actual is null");
- // }
- // } else {
- // if (currentEvent.t == null) {
- // fail("Incorrect Throwable. Expected null. Actual is " + t);
- // } else {
- // assertTrue("Incorrect Throwable. Expected " + currentEvent.t + ", actual " + t,
- // currentEvent.t.equals(t));
- // }
- // }
- // return true;
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final CharSequence data, final Throwable t) {
- charSeqCount++;
- return isEnabled(level, marker, (Message) new SimpleMessage(data), t);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) {
- objectCount++;
- return isEnabled(level, marker, new ObjectMessage(data), t);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data) {
- return isEnabled(level, marker, (Message) new SimpleMessage(data), null);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) {
- return isEnabled(level, marker, new ParameterizedMessage(data, p1), null);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level, final Marker marker, final String message, final Object p0, final Object p1) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8) {
- return isEnabled(level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8), null);
- }
-
- @Override
- public boolean isEnabled(
- final Level level,
- final Marker marker,
- final String message,
- final Object p0,
- final Object p1,
- final Object p2,
- final Object p3,
- final Object p4,
- final Object p5,
- final Object p6,
- final Object p7,
- final Object p8,
- final Object p9) {
- return isEnabled(
- level, marker, new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9), null);
- }
-
- @Override
- public boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) {
- return isEnabled(level, marker, (Message) new SimpleMessage(data), t);
- }
-
- @Override
- public void logMessage(
- final String fqcn, final Level level, final Marker marker, final Message data, final Throwable t) {
- assertEquals(level, currentLevel, "Incorrect Level. Expected " + currentLevel + ", actual " + level);
- if (marker == null) {
- if (currentEvent.markerName != null) {
- fail("Incorrect marker. Expected " + currentEvent.markerName + ", actual is null");
- }
- } else {
- if (currentEvent.markerName == null) {
- fail("Incorrect marker. Expected null. Actual is " + marker.getName());
- } else {
- assertEquals(
- currentEvent.markerName,
- marker.getName(),
- "Incorrect marker. Expected " + currentEvent.markerName + ", actual " + marker.getName());
- }
- }
- if (data == null) {
- if (currentEvent.data != null) {
- fail("Incorrect message. Expected " + currentEvent.data + ", actual is null");
- }
- } else {
- if (currentEvent.data == null) {
- fail("Incorrect message. Expected null. Actual is " + data.getFormattedMessage());
- } else {
- assertTrue(
- data.getClass().isAssignableFrom(currentEvent.data.getClass()),
- "Incorrect message type. Expected " + currentEvent.data + ", actual " + data);
- assertEquals(
- currentEvent.data.getFormattedMessage(),
- data.getFormattedMessage(),
- "Incorrect message. Expected " + currentEvent.data.getFormattedMessage() + ", actual "
- + data.getFormattedMessage());
- }
- }
- if (t == null) {
- if (currentEvent.t != null) {
- fail("Incorrect Throwable. Expected " + currentEvent.t + ", actual is null");
- }
- } else {
- if (currentEvent.t == null) {
- fail("Incorrect Throwable. Expected null. Actual is " + t);
- } else {
- assertEquals(currentEvent.t, t, "Incorrect Throwable. Expected " + currentEvent.t + ", actual " + t);
- }
- }
- }
-
- @Test
- public void testTraceEntryExit() {
- currentLevel = Level.TRACE;
- final FlowMessageFactory fact = new DefaultFlowMessageFactory();
-
- final ParameterizedMessage paramMsg = new ParameterizedMessage("Tracy {}", "Logan");
- currentEvent = new LogEvent(ENTRY_MARKER.getName(), fact.newEntryMessage(paramMsg), null);
- final EntryMessage entry = traceEntry("Tracy {}", "Logan");
-
- final ReusableParameterizedMessage msg =
- ReusableParameterizedMessageTest.set(new ReusableParameterizedMessage(), "Tracy {}", "Logan");
- ReusableParameterizedMessageTest.set(msg, "Some other message {}", 123);
- currentEvent = new LogEvent(null, msg, null);
- trace("Some other message {}", 123);
-
- // ensure original entry message not overwritten
- assertEquals("Tracy Logan", entry.getMessage().getFormattedMessage());
-
- currentEvent = new LogEvent(EXIT_MARKER.getName(), fact.newExitMessage(entry), null);
- traceExit(entry);
-
- // ensure original entry message not overwritten
- assertEquals("Tracy Logan", entry.getMessage().getFormattedMessage());
- }
-
- @Test
- public void testTraceEntryMessage() {
- currentLevel = Level.TRACE;
- final FlowMessageFactory fact = new DefaultFlowMessageFactory();
-
- final ParameterizedMessage paramMsg = new ParameterizedMessage("Tracy {}", "Logan");
- currentEvent = new LogEvent(ENTRY_MARKER.getName(), fact.newEntryMessage(paramMsg), null);
-
- final ReusableParameterizedMessage msg =
- ReusableParameterizedMessageTest.set(new ReusableParameterizedMessage(), "Tracy {}", "Logan");
- final EntryMessage entry = traceEntry(msg);
-
- ReusableParameterizedMessageTest.set(msg, "Some other message {}", 123);
- currentEvent = new LogEvent(null, msg, null);
- trace("Some other message {}", 123);
-
- // ensure original entry message not overwritten
- assertEquals("Tracy Logan", entry.getMessage().getFormattedMessage());
-
- currentEvent = new LogEvent(EXIT_MARKER.getName(), fact.newExitMessage(entry), null);
- traceExit(entry);
-
- // ensure original entry message not overwritten
- assertEquals("Tracy Logan", entry.getMessage().getFormattedMessage());
- }
-}
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
deleted file mode 100644
index 3ed88257cb..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/DefaultLogBuilderTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.internal;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.Arrays;
-import java.util.List;
-import org.apache.logging.log4j.LogBuilder;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.test.TestLogger;
-import org.junit.jupiter.api.Test;
-
-public class DefaultLogBuilderTest {
-
- private final TestLogger logger1 = (TestLogger) LogManager.getLogger(DefaultLogBuilderTest.class);
- private final TestLogger logger2 = (TestLogger) LogManager.getLogger("second.logger");
-
- @Test
- public void testConcurrentUsage() {
- logger1.getEntries().clear();
- logger2.getEntries().clear();
- final List<LogBuilder> logBuilders =
- Arrays.asList(logger1.atDebug(), logger1.atInfo(), logger2.atDebug(), logger2.atInfo());
- logBuilders.forEach(logBuilder -> logBuilder.log("Hello LogBuilder!"));
- assertThat(logger1.getEntries())
- .hasSize(2)
- .containsExactly(" DEBUG Hello LogBuilder!", " INFO Hello LogBuilder!");
- assertThat(logger2.getEntries())
- .hasSize(2)
- .containsExactly(" DEBUG Hello LogBuilder!", " INFO Hello LogBuilder!");
- }
-}
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/ArrayQueueTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/ArrayQueueTest.java
deleted file mode 100644
index 2ded8ff7a8..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/ArrayQueueTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.internal.recycler;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import java.util.Queue;
-import java.util.Random;
-import java.util.concurrent.ArrayBlockingQueue;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.CsvSource;
-import org.junit.jupiter.params.provider.ValueSource;
-
-public class ArrayQueueTest {
-
- @ParameterizedTest
- @ValueSource(ints = {-1, 0})
- void invalid_capacity_should_not_be_allowed(final int invalidCapacity) {
- assertThatThrownBy(() -> new ArrayQueue<>(invalidCapacity))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessage("invalid capacity: " + invalidCapacity);
- }
-
- @Test
- void should_work_with_capacity_1() {
-
- // Verify initials
- final Queue<String> queue = new ArrayQueue<>(1);
- assertThat(queue.size()).isEqualTo(0);
- assertThat(queue.peek()).isNull();
- assertThat(queue.poll()).isNull();
- assertThat(queue).isEmpty();
-
- // Verify enqueue & deque
- assertThat(queue.offer("foo")).isTrue();
- assertThat(queue.offer("bar")).isFalse();
- assertThat(queue.size()).isEqualTo(1);
- assertThat(queue).containsOnly("foo");
- assertThat(queue.peek()).isEqualTo("foo");
- assertThat(queue.poll()).isEqualTo("foo");
-
- // Verify final state
- assertThat(queue.size()).isEqualTo(0);
- assertThat(queue.peek()).isNull();
- assertThat(queue.poll()).isNull();
- assertThat(queue).isEmpty();
- }
-
- @ParameterizedTest
- @CsvSource({
- "1,0.3", "1,0.5", "1,0.8", "2,0.3", "2,0.5", "2,0.8", "3,0.3", "3,0.5", "3,0.8", "4,0.3", "4,0.5", "4,0.8"
- })
- void ops_should_match_with_std_lib(final int capacity, final double pollRatio) {
-
- // Set the stage
- final Random random = new Random(0);
- final int opCount = random.nextInt(100);
- final Queue<String> queueRef = new ArrayBlockingQueue<>(capacity);
- final Queue<String> queueTarget = new ArrayQueue<>(capacity);
-
- for (int opIndex = 0; opIndex < opCount; opIndex++) {
-
- // Verify entry
- assertThat(queueTarget.size()).isEqualTo(queueRef.size());
- assertThat(queueTarget.peek()).isEqualTo(queueRef.peek());
- assertThat(queueTarget).containsExactlyElementsOf(queueRef);
-
- // Is this a `poll()`?
- if (pollRatio >= random.nextDouble()) {
- assertThat(queueTarget.poll()).isEqualTo(queueRef.poll());
- }
-
- // Then this is an `offer()`
- else {
- final String item = "op@" + opIndex;
- assertThat(queueTarget.offer(item)).isEqualTo(queueRef.offer(item));
- }
-
- // Verify exit
- assertThat(queueTarget.size()).isEqualTo(queueRef.size());
- assertThat(queueTarget.peek()).isEqualTo(queueRef.peek());
- assertThat(queueTarget).containsExactlyElementsOf(queueRef);
- }
- }
-}
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/RecyclerFactoryRegistryTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/RecyclerFactoryRegistryTest.java
deleted file mode 100644
index f6684f63cc..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/RecyclerFactoryRegistryTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.internal.recycler;
-
-import static org.apache.logging.log4j.internal.recycler.RecyclerFactoryTestUtil.createForEnvironment;
-import static org.apache.logging.log4j.spi.recycler.Recycler.DEFAULT_CAPACITY;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.apache.logging.log4j.internal.recycler.DummyRecyclerFactoryProvider.DummyRecyclerFactory;
-import org.apache.logging.log4j.internal.recycler.QueueingRecyclerFactoryProvider.QueueingRecyclerFactory;
-import org.apache.logging.log4j.internal.recycler.ThreadLocalRecyclerFactoryProvider.ThreadLocalRecyclerFactory;
-import org.apache.logging.log4j.spi.recycler.RecyclerFactory;
-import org.apache.logging.log4j.spi.recycler.RecyclerFactoryProvider;
-import org.assertj.core.api.InstanceOfAssertFactories;
-import org.junit.jupiter.api.Test;
-
-public class RecyclerFactoryRegistryTest {
-
- @Test
- void DummyRecyclerFactory_should_work() {
- final RecyclerFactory factory = createForEnvironment(null, "dummy", null);
- assertThat(factory).isInstanceOf(DummyRecyclerFactory.class);
- }
-
- @Test
- void ThreadLocalRecyclerFactory_should_work() {
- final RecyclerFactory factory = createForEnvironment(null, "threadLocal", null);
- assertThat(factory)
- .asInstanceOf(InstanceOfAssertFactories.type(ThreadLocalRecyclerFactory.class))
- .extracting(factory_ -> factory_.capacity)
- .isEqualTo(DEFAULT_CAPACITY);
- }
-
- @Test
- void ThreadLocalRecyclerFactory_should_work_with_capacity() {
- final int capacity = 13;
- final RecyclerFactory factory = createForEnvironment(null, "threadLocal", capacity);
- assertThat(factory)
- .asInstanceOf(InstanceOfAssertFactories.type(ThreadLocalRecyclerFactory.class))
- .extracting(factory_ -> factory_.capacity)
- .isEqualTo(capacity);
- }
-
- @Test
- void QueueingRecyclerFactory_should_work() {
- final RecyclerFactory factory = createForEnvironment(null, "queue", null);
- assertThat(factory)
- .asInstanceOf(InstanceOfAssertFactories.type(QueueingRecyclerFactory.class))
- .extracting(factory_ -> factory_.capacity)
- .isEqualTo(DEFAULT_CAPACITY);
- }
-
- @Test
- void QueueingRecyclerFactory_should_work_with_capacity() {
- final int capacity = 100;
- final RecyclerFactory factory = createForEnvironment(null, "queue", capacity);
- assertThat(factory)
- .asInstanceOf(InstanceOfAssertFactories.type(QueueingRecyclerFactory.class))
- .extracting(factory_ -> factory_.capacity)
- .isEqualTo(capacity);
- }
-
- @Test
- void verify_order() {
- final RecyclerFactoryProvider dummyProvider = new DummyRecyclerFactoryProvider();
- final RecyclerFactoryProvider threadLocalProvider = new ThreadLocalRecyclerFactoryProvider();
- final RecyclerFactoryProvider queueProvider = new QueueingRecyclerFactoryProvider();
- assertThat(dummyProvider.getOrder()).isGreaterThan(queueProvider.getOrder());
- assertThat(queueProvider.getOrder()).isGreaterThan(threadLocalProvider.getOrder());
- }
-}
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/RecyclerFactoryTestUtil.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/RecyclerFactoryTestUtil.java
deleted file mode 100644
index 85ec0c3cdb..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/RecyclerFactoryTestUtil.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.internal.recycler;
-
-import edu.umd.cs.findbugs.annotations.Nullable;
-import java.util.Properties;
-import org.apache.logging.log4j.spi.LoggingSystemProperty;
-import org.apache.logging.log4j.spi.recycler.RecyclerFactory;
-import org.apache.logging.log4j.spi.recycler.RecyclerFactoryRegistry;
-import org.apache.logging.log4j.util.PropertiesUtil;
-import org.apache.logging.log4j.util.PropertyEnvironment;
-
-final class RecyclerFactoryTestUtil {
-
- private RecyclerFactoryTestUtil() {}
-
- @Nullable
- static RecyclerFactory createForEnvironment(
- @Nullable Boolean webApp, @Nullable final String factory, @Nullable final Integer capacity) {
- final Properties properties = new Properties();
- if (webApp != null) {
- properties.setProperty(LoggingSystemProperty.IS_WEBAPP.getSystemKey(), webApp + "");
- }
- if (factory != null) {
- properties.setProperty(LoggingSystemProperty.RECYCLER_FACTORY.getSystemKey(), factory);
- }
- if (capacity != null) {
- properties.setProperty(LoggingSystemProperty.RECYCLER_CAPACITY.getSystemKey(), capacity + "");
- }
- final PropertyEnvironment env = new PropertiesUtil(properties);
- return RecyclerFactoryRegistry.findRecyclerFactory(env);
- }
-}
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/ThreadLocalRecyclerFactoryProviderTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/ThreadLocalRecyclerFactoryProviderTest.java
deleted file mode 100644
index 2d2bdf3710..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/recycler/ThreadLocalRecyclerFactoryProviderTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.internal.recycler;
-
-import static org.apache.logging.log4j.internal.recycler.RecyclerFactoryTestUtil.createForEnvironment;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import java.util.List;
-import java.util.Queue;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import org.apache.logging.log4j.internal.recycler.ThreadLocalRecyclerFactoryProvider.ThreadLocalRecyclerFactory;
-import org.apache.logging.log4j.internal.recycler.ThreadLocalRecyclerFactoryProvider.ThreadLocalRecyclerFactory.ThreadLocalRecycler;
-import org.apache.logging.log4j.spi.recycler.RecyclerFactory;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junitpioneer.jupiter.params.IntRangeSource;
-
-class ThreadLocalRecyclerFactoryProviderTest {
-
- private static final int CAPACITY = 13;
-
- private static class RecyclableObject {}
-
- private ThreadLocalRecycler<RecyclableObject> recycler;
-
- private Queue<RecyclableObject> recyclerQueue;
-
- @BeforeEach
- void setUp() {
- final RecyclerFactory recyclerFactory = createForEnvironment(false, "threadLocal", CAPACITY);
- assertThat(recyclerFactory).isInstanceOf(ThreadLocalRecyclerFactory.class);
- assert recyclerFactory != null;
- recycler = (ThreadLocalRecycler<RecyclableObject>) recyclerFactory.create(RecyclableObject::new);
- recyclerQueue = recycler.queueRef.get();
- }
-
- @Test
- void should_not_be_configured_for_webapps() {
- assertThatThrownBy(() -> createForEnvironment(true, "threadLocal", null))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessageStartingWith("failed to configure recycler");
- }
-
- @ParameterizedTest
- @IntRangeSource(from = 1, to = CAPACITY, closed = true)
- void nested_acquires_should_not_interfere(final int acquisitionCount) {
-
- // pool should start empty
- assertThat(recyclerQueue).isEmpty();
-
- final List<RecyclableObject> acquiredObjects = IntStream.range(0, acquisitionCount)
- .mapToObj(i -> recycler.acquire())
- .collect(Collectors.toList());
-
- // still nothing returned to pool
- assertThat(recyclerQueue).isEmpty();
-
- // don't want any duplicate instances
- assertThat(acquiredObjects).containsOnlyOnceElementsOf(acquiredObjects);
- acquiredObjects.forEach(recycler::release);
-
- // and now they should be back in the pool
- assertThat(recyclerQueue).hasSize(acquisitionCount);
-
- // then reacquire them to see that they're still the same object as we've filled in
- // the thread-local queue with returned objects
- final List<RecyclableObject> reacquiredObjects = IntStream.range(0, acquisitionCount)
- .mapToObj(i -> recycler.acquire())
- .collect(Collectors.toList());
-
- assertThat(reacquiredObjects).containsExactlyElementsOf(acquiredObjects);
- }
-
- @Test
- void nested_acquires_past_max_queue_size_should_discard_extra_releases() {
-
- assertThat(recyclerQueue).isEmpty();
-
- // Simulate a callstack with excessive logging
- final int acquisitionCount = Math.addExact(CAPACITY, 1024);
- final List<RecyclableObject> acquiredObjects = IntStream.range(0, acquisitionCount)
- .mapToObj(i -> recycler.acquire())
- .toList();
-
- // Verify collected instances are all new
- assertThat(acquiredObjects).doesNotHaveDuplicates();
-
- // Verify the pool is still empty
- assertThat(recyclerQueue).isEmpty();
-
- // Release all acquired instances
- acquiredObjects.forEach(recycler::release);
-
- // Verify the queue size is capped
- assertThat(recyclerQueue).hasSize(CAPACITY);
- }
-}
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
deleted file mode 100644
index 638f31b932..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/FormattedMessageTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.message;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.util.Locale;
-import org.apache.logging.log4j.test.junit.Mutable;
-import org.apache.logging.log4j.util.Constants;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.parallel.ResourceAccessMode;
-import org.junit.jupiter.api.parallel.ResourceLock;
-import org.junit.jupiter.api.parallel.Resources;
-
-@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
-public class FormattedMessageTest {
-
- private static final String SPACE = Constants.JAVA_MAJOR_VERSION < 9 ? " " : "\u00a0";
-
- private static final int LOOP_CNT = 500;
- String[] array = new String[LOOP_CNT];
-
- @Test
- public void testStringNoArgs() {
- final String testMsg = "Test message %1s";
- FormattedMessage msg = new FormattedMessage(testMsg, (Object[]) null);
- String result = msg.getFormattedMessage();
- final String expected = "Test message null";
- assertEquals(expected, result);
- final Object[] array = null;
- msg = new FormattedMessage(testMsg, array, null);
- result = msg.getFormattedMessage();
- assertEquals(expected, result);
- }
-
- @Test
- public void tesStringOneStringArg() {
- final String testMsg = "Test message %1s";
- final FormattedMessage msg = new FormattedMessage(testMsg, "Apache");
- final String result = msg.getFormattedMessage();
- final String expected = "Test message Apache";
- assertEquals(expected, result);
- }
-
- @Test
- public 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();
- final String expected = "Test message e = +2,7183";
- assertEquals(expected, result);
- }
-
- @Test
- public 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();
- final String expected = "Test message 12,00" + SPACE + "€";
- assertEquals(expected, result);
- }
-
- @Test
- public 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();
- final String expected = "Test message $12.00";
- assertEquals(expected, result);
- }
-
- @Test
- public 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();
- final String expected = "Test message e = +2.7183";
- assertEquals(expected, result);
- }
-
- @Test
- public void testNoArgs() {
- final String testMsg = "Test message {0}";
- FormattedMessage msg = new FormattedMessage(testMsg, (Object[]) null);
- String result = msg.getFormattedMessage();
- final String expected = "Test message {0}";
- assertEquals(expected, result);
- final Object[] array = null;
- msg = new FormattedMessage(testMsg, array, null);
- result = msg.getFormattedMessage();
- assertEquals(expected, result);
- }
-
- @Test
- public void testOneArg() {
- final String testMsg = "Test message {0}";
- final FormattedMessage msg = new FormattedMessage(testMsg, "Apache");
- final String result = msg.getFormattedMessage();
- final String expected = "Test message Apache";
- assertEquals(expected, result);
- }
-
- @Test
- public void testParamNoArgs() {
- final String testMsg = "Test message {}";
- FormattedMessage msg = new FormattedMessage(testMsg, (Object[]) null);
- String result = msg.getFormattedMessage();
- assertEquals(testMsg, result);
- final Object[] array = null;
- msg = new FormattedMessage(testMsg, array, null);
- result = msg.getFormattedMessage();
- assertEquals(testMsg, result);
- }
-
- @Test
- public void testUnsafeWithMutableParams() { // LOG4J2-763
- final String testMsg = "Test message %s";
- final Mutable param = new Mutable().set("abc");
- final FormattedMessage msg = new FormattedMessage(testMsg, param);
-
- // modify parameter before calling msg.getFormattedMessage
- param.set("XYZ");
- final String actual = msg.getFormattedMessage();
- assertEquals("Test message XYZ", actual, "Expected most recent param value");
- }
-
- @Test
- public void testSafeAfterGetFormattedMessageIsCalled() { // LOG4J2-763
- final String testMsg = "Test message %s";
- final Mutable param = new Mutable().set("abc");
- final FormattedMessage msg = new FormattedMessage(testMsg, param);
-
- // modify parameter after calling msg.getFormattedMessage
- msg.getFormattedMessage(); // freeze the formatted message
- param.set("XYZ");
- final String actual = msg.getFormattedMessage();
- assertEquals("Test message abc", actual, "Should use initial param value");
- }
-}
diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/JsonMessage.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/message/JsonMessage.java
deleted file mode 100644
index ebcebca3ab..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/JsonMessage.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.message;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Converts an Object to a JSON String.
- */
-public class JsonMessage implements Message {
-
- private static final ObjectMapper mapper = new ObjectMapper();
- private final Object object;
-
- /**
- * Constructs a JsonMessage.
- *
- * @param object the Object to serialize.
- */
- public JsonMessage(final Object object) {
- this.object = object;
- }
-
- @Override
- public String getFormattedMessage() {
- try {
- return mapper.writeValueAsString(object);
- } catch (final JsonProcessingException e) {
- StatusLogger.getLogger().catching(e);
- return object.toString();
- }
- }
-
- @Override
- public String getFormat() {
- return object.toString();
- }
-
- @Override
- public Object[] getParameters() {
- return new Object[] {object};
- }
-
- @Override
- public Throwable getThrowable() {
- return null;
- }
-}
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
deleted file mode 100644
index 8ae12a1337..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageFactoryTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.message;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.parallel.ResourceAccessMode;
-import org.junit.jupiter.api.parallel.ResourceLock;
-import org.junit.jupiter.api.parallel.Resources;
-
-/**
- * Tests {@link LocalizedMessageFactory}.
- */
-@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
-public class LocalizedMessageFactoryTest {
-
- @Test
- public void testMessageMarkersDataNo() {
- final LocalizedMessageFactory localizedMessageFactory =
- new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
- final Message message = localizedMessageFactory.newMessage("msg1");
- assertEquals("This is test number {0} with string argument {1}.", message.getFormattedMessage());
- }
-
- @Test
- public void testMessageMarkersNoDataYes() {
- final LocalizedMessageFactory localizedMessageFactory =
- new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
- final Message message = localizedMessageFactory.newMessage("msg1", 1, "two");
- assertEquals("This is test number 1 with string argument two.", message.getFormattedMessage());
- }
-
- @Test
- public void testNewMessage() {
- final LocalizedMessageFactory localizedMessageFactory =
- new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
- final Message message = localizedMessageFactory.newMessage("hello_world");
- assertEquals("Hello world.", message.getFormattedMessage());
- }
-
- @Test
- @ResourceLock(Resources.LOCALE)
- public void testNewMessageUsingBaseName() {
- final Locale defaultLocale = Locale.getDefault();
- Locale.setDefault(Locale.US);
- try {
- final LocalizedMessageFactory localizedMessageFactory = new LocalizedMessageFactory("MF");
- final String testMsg = "hello_world";
- final Message message = localizedMessageFactory.newMessage(testMsg);
- assertEquals("Hello world.", message.getFormattedMessage());
- } finally {
- Locale.setDefault(defaultLocale);
- }
- }
-
- @Test
- public void testNoMatch() {
- final LocalizedMessageFactory localizedMessageFactory =
- new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
- final Message message = localizedMessageFactory.newMessage("no match");
- assertEquals("no match", message.getFormattedMessage());
- }
-
- @Test
- public void testNoMatchPercentInMessageArgsYes() {
- final LocalizedMessageFactory localizedMessageFactory =
- new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
- final Message message = localizedMessageFactory.newMessage(
- "C:/Program%20Files/Some%20Company/Some%20Product%20Name/{0}", "One");
- assertEquals("C:/Program%20Files/Some%20Company/Some%20Product%20Name/One", message.getFormattedMessage());
- }
-
- @Test
- public 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/
- // java.util.UnknownFormatConversionException: Conversion = 'F'
- // at java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2691)
- // at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2720)
- // at java.util.Formatter.parse(Formatter.java:2560)
- // at java.util.Formatter.format(Formatter.java:2501)
- // at java.util.Formatter.format(Formatter.java:2455)
- // at java.lang.String.format(String.java:2981)
- // at org.apache.logging.log4j.message.StringFormattedMessage.formatMessage(StringFormattedMessage.java:116)
- // at
- // org.apache.logging.log4j.message.StringFormattedMessage.getFormattedMessage(StringFormattedMessage.java:88)
- // at org.apache.logging.log4j.message.FormattedMessage.getFormattedMessage(FormattedMessage.java:178)
- // at org.apache.logging.log4j.message.LocalizedMessage.getFormattedMessage(LocalizedMessage.java:196)
- // at
- // org.apache.logging.log4j.message.LocalizedMessageFactoryTest.testNoMatchPercentInMessage(LocalizedMessageFactoryTest.java:60)
- //
- final LocalizedMessageFactory localizedMessageFactory =
- new LocalizedMessageFactory(ResourceBundle.getBundle("MF", Locale.US));
- final Message message =
- localizedMessageFactory.newMessage("C:/Program%20Files/Some%20Company/Some%20Product%20Name/");
- assertEquals("C:/Program%20Files/Some%20Company/Some%20Product%20Name/", message.getFormattedMessage());
- }
-}
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
deleted file mode 100644
index 14ad3ffeab..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/LocalizedMessageTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.message;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.util.Locale;
-import org.apache.logging.log4j.test.junit.Mutable;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.parallel.ResourceAccessMode;
-import org.junit.jupiter.api.parallel.ResourceLock;
-import org.junit.jupiter.api.parallel.Resources;
-
-/**
- * Tests LocalizedMessage.
- */
-@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
-public class LocalizedMessageTest {
-
- @Test
- public 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 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
- final String testMsg = "Test message %s";
- final Mutable param = new Mutable().set("abc");
- final LocalizedMessage msg = new LocalizedMessage(testMsg, param);
-
- // modify parameter before calling msg.getFormattedMessage
- param.set("XYZ");
- final String actual = msg.getFormattedMessage();
- assertEquals("Test message XYZ", actual, "Expected most recent param value");
- }
-
- @Test
- public void testSafeAfterGetFormattedMessageIsCalled() { // LOG4J2-763
- final String testMsg = "Test message %s";
- final Mutable param = new Mutable().set("abc");
- final LocalizedMessage msg = new LocalizedMessage(testMsg, param);
-
- // modify parameter after calling msg.getFormattedMessage
- msg.getFormattedMessage();
- param.set("XYZ");
- final String actual = msg.getFormattedMessage();
- assertEquals("Test message abc", actual, "Should use initial param value");
- }
-
- @Test
- @ResourceLock(Resources.LOCALE)
- public void testMessageUsingBaseName() { // LOG4J2-2850
- final Locale defaultLocale = Locale.getDefault();
- Locale.setDefault(Locale.US);
- try {
- final String testMsg = "hello_world";
- final LocalizedMessage msg = new LocalizedMessage("MF", testMsg, null);
- assertEquals("Hello world.", msg.getFormattedMessage());
- } finally {
- Locale.setDefault(defaultLocale);
- }
- }
-}
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
deleted file mode 100644
index 048801128d..0000000000
--- a/log4j-api-test/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.message;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-import java.math.BigDecimal;
-import java.sql.Date;
-import java.sql.Time;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.logging.log4j.util.StringBuilderFormattable;
-import org.junit.jupiter.api.Test;
-
-/**
- *
- */
-public class MapMessageTest {
-
- @Test
- public void testMap() {
- final String testMsg = "Test message {}";
- final StringMapMessage msg = new StringMapMessage();
- msg.put("message", testMsg);
- msg.put("project", "Log4j");
- final String result = msg.getFormattedMessage();
- final String expected = "message=\"Test message {}\" project=\"Log4j\"";
- assertEquals(expected, result);
- }
-
- @Test
- public void testBuilder() {
- final String testMsg = "Test message {}";
- final StringMapMessage msg =
- new StringMapMessage().with("message", testMsg).with("project", "Log4j");
- final String result = msg.getFormattedMessage();
- final String expected = "message=\"Test message {}\" project=\"Log4j\"";
- assertEquals(expected, result);
- }
-
- @Test
- public void testXML() {
- final String testMsg = "Test message {}";
- final StringMapMessage msg = new StringMapMessage();
- msg.put("message", testMsg);
- msg.put("project", "Log4j");
- final String result = msg.getFormattedMessage(new String[] {"XML"});
- final String expected = "<Map>\n <Entry key=\"message\">Test message {}</Entry>\n"
- + " <Entry key=\"project\">Log4j</Entry>\n" + "</Map>";
- assertEquals(expected, result);
- }
-
- @Test
- public void testXMLEscape() {
- final String testMsg = "Test message <foo>";
- final StringMapMessage msg = new StringMapMessage();
- msg.put("message", testMsg);
- final String result = msg.getFormattedMessage(new String[] {"XML"});
- final String expected = "<Map>\n <Entry key=\"message\">Test message <foo></Entry>\n" + "</Map>";
- assertEquals(expected, result);
- }
-
- @Test
- public void testJSON() {
- final String testMsg = "Test message {}";
- final StringMapMessage msg = new StringMapMessage();
- msg.put("message", testMsg);
- msg.put("project", "Log4j");
- final String result = msg.getFormattedMessage(new String[] {"JSON"});
- final String expected = "{'message':'Test message {}','project':'Log4j'}".replace('\'', '"');
- assertEquals(expected, result);
- }
-
... 41800 lines suppressed ...