diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml
index 1633c40..4574b5e 100644
--- a/.github/workflows/check-release.yml
+++ b/.github/workflows/check-release.yml
@@ -17,8 +17,8 @@ jobs:
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
- distribution: 'corretto'
- java-version: 11
+ distribution: 'zulu'
+ java-version: '11'
- name: Build with Maven
env:
SIGN_KEY: ${{ secrets.SIGN_KEY }}
diff --git a/.github/workflows/codacy.yml b/.github/workflows/codacy.yml
index 8c0b98d..db6800b 100644
--- a/.github/workflows/codacy.yml
+++ b/.github/workflows/codacy.yml
@@ -21,12 +21,12 @@ jobs:
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
- distribution: 'corretto'
- java-version: 11
+ distribution: 'zulu'
+ java-version: '11'
- name: Build with Maven
run: ./mvnw --batch-mode
- name: Temporarily save target and test requests
- uses: actions/upload-artifact@master
+ uses: actions/upload-artifact@v4
with:
name: targets
path: |
@@ -65,7 +65,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Retrieve saved test requests and target
- uses: actions/download-artifact@master
+ uses: actions/download-artifact@v4
with:
name: targets
path: .
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 214c5cf..17c3255 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -30,8 +30,8 @@ jobs:
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
- distribution: 'corretto'
- java-version: 11
+ distribution: 'zulu'
+ java-version: '11'
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
diff --git a/.github/workflows/sonatype.yml b/.github/workflows/sonatype.yml
index a289e7c..beff91e 100644
--- a/.github/workflows/sonatype.yml
+++ b/.github/workflows/sonatype.yml
@@ -17,8 +17,8 @@ jobs:
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
- distribution: 'corretto'
- java-version: 11
+ distribution: 'zulu'
+ java-version: '11'
- name: Build and publish with Maven
env:
SIGN_KEY: ${{ secrets.SIGN_KEY }}
diff --git a/.markdownlint.json b/.markdownlint.json
new file mode 100644
index 0000000..b79993a
--- /dev/null
+++ b/.markdownlint.json
@@ -0,0 +1,11 @@
+{
+ "line-length": {
+ "headings": false,
+ "line_length": 80,
+ "code_blocks": false,
+ "tables": false
+ },
+ "no-duplicate-heading": {
+ "siblings_only": true
+ }
+}
diff --git a/THIRD-PARTY.txt b/THIRD-PARTY.txt
index 8a0660b..d64f3b8 100644
--- a/THIRD-PARTY.txt
+++ b/THIRD-PARTY.txt
@@ -1,13 +1,13 @@
Lists of 13 third-party dependencies.
(Apache License version 2.0) Apache Commons Logging (commons-logging:commons-logging:1.3.4 - https://commons.apache.org/proper/commons-logging/)
- (Apache License version 2.0) Byte Buddy (without dependencies) (net.bytebuddy:byte-buddy:1.15.4 - https://bytebuddy.net/byte-buddy)
- (Apache License version 2.0) Byte Buddy agent (net.bytebuddy:byte-buddy-agent:1.15.4 - https://bytebuddy.net/byte-buddy-agent)
+ (Apache License version 2.0) Byte Buddy (without dependencies) (net.bytebuddy:byte-buddy:1.15.11 - https://bytebuddy.net/byte-buddy)
+ (Apache License version 2.0) Byte Buddy agent (net.bytebuddy:byte-buddy-agent:1.15.11 - https://bytebuddy.net/byte-buddy-agent)
(Apache License version 2.0) org.apiguardian:apiguardian-api (org.apiguardian:apiguardian-api:1.1.2 - https://github.com/apiguardian-team/apiguardian)
(Apache License version 2.0) JetBrains Java Annotations (org.jetbrains:annotations:26.0.1 - https://github.com/JetBrains/java-annotations)
- (Eclipse Public License - v 2.0) JUnit Jupiter API (org.junit.jupiter:junit-jupiter-api:5.11.3 - https://junit.org/junit5/)
- (Eclipse Public License - v 2.0) JUnit Platform Commons (org.junit.platform:junit-platform-commons:1.11.3 - https://junit.org/junit5/)
- (MIT License) mockito-core (org.mockito:mockito-core:5.14.2 - https://github.com/mockito/mockito)
+ (Eclipse Public License - v 2.0) JUnit Jupiter API (org.junit.jupiter:junit-jupiter-api:5.11.4 - https://junit.org/junit5/)
+ (Eclipse Public License - v 2.0) JUnit Platform Commons (org.junit.platform:junit-platform-commons:1.11.4 - https://junit.org/junit5/)
+ (MIT License) mockito-core (org.mockito:mockito-core:5.15.2 - https://github.com/mockito/mockito)
(Apache License version 2.0) Objenesis (org.objenesis:objenesis:3.3 - http://objenesis.org/objenesis)
(Apache License version 2.0) org.opentest4j:opentest4j (org.opentest4j:opentest4j:1.3.0 - https://github.com/ota4j-team/opentest4j)
(MIT License) SLF4J API Module (org.slf4j:slf4j-api:2.0.16 - http://www.slf4j.org)
diff --git a/changelog.md b/changelog.md
index b323fce..387b2dd 100644
--- a/changelog.md
+++ b/changelog.md
@@ -5,45 +5,77 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## Unreleased
+## 1.1.1 - 2025-01-02 - Modules
+### Added
+
+- Added modules
+
+### Changed
+
+- Update Mockito to 5.15.2
- Update Javadoc
+- Update jUnit to 5.11.4
## 1.1.0 - 2024-11-28
+### Added
+
- Add tinylog modules: provider and writer
+
+### Changed
+
- Fix dependencies' scopes
## 1.0.0 - 2024-11-13 - Mock Loggers
-- Rename to **Mock Loggers**
+### Added
+
- Add SLF4J and Apache Commons Logging modules
+### Changed
+
+- Rename to **Mock Loggers**
+
## 1.1.3 - 2024-11-09
+### Added
+
- Improved Javadoc
- Use BOM for jUnit and Mockito
- Add activity badges, update other
-- Update Maven plugins: invoker, javadoc, surefire and failsafe
- Custom annotation @MockLoggers
+### Changed
+
+- Update Maven plugins: invoker, javadoc, surefire and failsafe
+
## 1.1.2 - 2024-10-21
+### Changed
+
- Update jUnit Jupiter and Platform
- Update Mockito to 5.14
-- Update a bunch of Maven plugins: javadoc, surefire, failsafe, invoker, central-publishing, jetbrains annotations
+- Update a bunch of Maven plugins: javadoc, surefire, failsafe, invoker,
+ central-publishing, jetbrains annotations
## 1.1.1 - 2024-08-20
+### Changed
+
- Update jUnit to 5.11
- Improve extension's logging
- Clean the Maven publishing plugin's configuration.
## 1.1.0 - 2024-07-19
+### Added
+
- Implement jUnit extension.
## 1.0.0 - 2024-07-15 - Mock of JDK Platform Logging
+### Added
+
- Implement a logger finder.
- Add Javadocs.
diff --git a/commons-logging/pom.xml b/commons-logging/pom.xml
index 0e18ccf..361e5ca 100644
--- a/commons-logging/pom.xml
+++ b/commons-logging/pom.xml
@@ -13,6 +13,17 @@
maven-failsafe-pluginorg.apache.maven.plugins
+
+ maven-jar-plugin
+
+
+
+ mock.loggers.commons
+
+
+
+ org.apache.maven.plugins
+ jacoco-maven-pluginorg.jacoco
@@ -44,7 +55,7 @@
mock-loggers-coreio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1mockito-core
@@ -62,9 +73,23 @@
mock-loggersio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1
+
+
+
+
+ license-maven-plugin
+
+ false
+
+ org.codehaus.mojo
+
+
+
+ prepare-and-check
+
diff --git a/commons-logging/readme.md b/commons-logging/readme.md
index e7c68ad..b3a543d 100644
--- a/commons-logging/readme.md
+++ b/commons-logging/readme.md
@@ -1,6 +1,7 @@
# Mock loggers for Apache Commons Logging
-[Apache Commons Logging][commons-logging] factory with mock loggers backed by [Mockito][].
+[Apache Commons Logging][commons-logging] factory with mock loggers
+backed by [Mockito][].
> [!WARNING]
> This library does not support _parallel test execution_.
@@ -15,16 +16,18 @@
## How to use
Just put a test dependency to your POM:
+
```xml
mock-loggers-commons-loggingio.github.vitalijr2.loggingtest
- 1.1.0
+ 1.1.1
```
The simplest usage example looks like this:
+
```java
@Test
void helloWorld() {
@@ -35,12 +38,15 @@ void helloWorld() {
verify(LogFactory.getLog(helloService.getClass())).info("Hello World!");
}
```
+
See more details at [HelloServiceBasicTest.java](src/it/hello-commons-logging-world/src/test/java/example/hello/HelloServiceBasicTest.java)
> [!IMPORTANT]
> Keep in mind that all loggers are initialized only once during the test run.
-Therefore, a more complex example cleans the loggers after (or before) each test:
+Therefore, a more complex example cleans the loggers after (or before)
+each test:
+
```java
// the static logger instance
private static Log log;
@@ -72,9 +78,12 @@ void names(String name) {
verifyNoMoreInteractions(actualLog);
}
```
+
See more details at [HelloServiceFullTest.java](src/it/hello-commons-logging-world/src/test/java/example/hello/HelloServiceFullTest.java)
-To avoid manual cleaning of mock loggers you can use the [jUnit extension][junit-extension] for automation:
+To avoid manual cleaning of mock loggers you can use
+the [jUnit extension][junit-extension] for automation:
+
```java
@ExtendWith(MockLoggerExtension.class)
class HelloServiceExtensionTest {
@@ -102,9 +111,11 @@ class HelloServiceExtensionTest {
}
```
+
See more details at [HelloServiceExtensionTest.java](src/it/hello-commons-logging-world/src/test/java/example/hello/HelloServiceExtensionTest.java)
Also you can use the annotation for automation:
+
```java
@MockLoggers
class HelloServiceAnnotationTest {
@@ -132,6 +143,7 @@ class HelloServiceAnnotationTest {
}
```
+
See more details at [HelloServiceAnnotationTest.java](src/it/hello-commons-logging-world/src/test/java/example/hello/HelloServiceAnnotationTest.java)
[commons-logging]: https://commons.apache.org/proper/commons-logging/
@@ -144,7 +156,7 @@ See more details at [HelloServiceAnnotationTest.java](src/it/hello-commons-loggi
[commons-logging-version]: https://img.shields.io/static/v1?label=commons-logging&message=1.3.4&color=blue&logoColor=E23D28
-[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.14.2&color=blue&logoColor=E23D28
+[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.15.2&color=blue&logoColor=E23D28
[maven-central-last-update]: https://img.shields.io/maven-central/last-update/io.github.vitalijr2.logging/mock-loggers-commons-logging
diff --git a/commons-logging/src/it/hello-commons-logging-world/pom.xml b/commons-logging/src/it/hello-commons-logging-world/pom.xml
index da491b4..7a654a2 100644
--- a/commons-logging/src/it/hello-commons-logging-world/pom.xml
+++ b/commons-logging/src/it/hello-commons-logging-world/pom.xml
@@ -76,7 +76,7 @@
115.11.3
- 5.14.2
+ 5.15.2UTF-81.0.0
diff --git a/core/pom.xml b/core/pom.xml
index 4910f79..fab174d 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -13,6 +13,17 @@
maven-failsafe-pluginorg.apache.maven.plugins
+
+ maven-jar-plugin
+
+
+
+ mock.loggers.core
+
+
+
+ org.apache.maven.plugins
+ jacoco-maven-pluginorg.jacoco
@@ -37,11 +48,6 @@
junit-jupiter-engineorg.junit.jupiter
-
- junit-platform-commons
- org.junit.platform
- provided
- mockito-coreorg.mockito
@@ -60,6 +66,22 @@
mock-loggersio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1
+
+
+
+
+
+ license-maven-plugin
+
+ false
+
+ org.codehaus.mojo
+
+
+
+ prepare-and-check
+
+
diff --git a/core/readme.md b/core/readme.md
index 7b7144c..3428b11 100644
--- a/core/readme.md
+++ b/core/readme.md
@@ -1,8 +1,10 @@
# Logger Keeper and jUnit Extension
-The observer pattern is implemented here: cleaners subscribe to notifications from a keeper, who sends
-alerts when mock loggers need to be cleaned and reset. Logger factories should implement the cleaner interface and
-register themselves with the keeper. The jUnit extension manages the keeper and sends alerts before and after tests.
+The observer pattern is implemented here: cleaners subscribe to notifications
+from a keeper, who sends alerts when mock loggers need to be cleaned and reset.
+Logger factories should implement the cleaner interface and register
+themselves with the keeper. The jUnit extension manages the keeper
+and sends alerts before and after tests.
[![Java Version][java-version]][jdk-download]
![jUnit Version][junit-version]
diff --git a/core/src/main/java/io/github/vitalijr2/logging/mock/MockLoggerExtension.java b/core/src/main/java/io/github/vitalijr2/logging/mock/MockLoggerExtension.java
index 080dda2..53322b6 100644
--- a/core/src/main/java/io/github/vitalijr2/logging/mock/MockLoggerExtension.java
+++ b/core/src/main/java/io/github/vitalijr2/logging/mock/MockLoggerExtension.java
@@ -19,12 +19,11 @@
*/
package io.github.vitalijr2.logging.mock;
+import java.lang.System.Logger.Level;
import org.jetbrains.annotations.VisibleForTesting;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.platform.commons.logging.Logger;
-import org.junit.platform.commons.logging.LoggerFactory;
/**
* A jUnit extension to clean and reset mock loggers.
@@ -64,18 +63,18 @@
*/
public class MockLoggerExtension implements AfterEachCallback, BeforeEachCallback {
- private final Logger extensionLogger;
+ private final System.Logger extensionLogger;
private final MockLoggerKeeper loggerKeeper;
/**
* Create an extension.
*/
public MockLoggerExtension() {
- this(MockLoggerKeeper.getInstance(), LoggerFactory.getLogger(MockLoggerExtension.class));
+ this(MockLoggerKeeper.getInstance(), System.getLogger(MockLoggerExtension.class.getName()));
}
@VisibleForTesting
- MockLoggerExtension(MockLoggerKeeper loggerKeeper, Logger extensionLogger) {
+ MockLoggerExtension(MockLoggerKeeper loggerKeeper, System.Logger extensionLogger) {
this.loggerKeeper = loggerKeeper;
this.extensionLogger = extensionLogger;
}
@@ -90,7 +89,7 @@ public MockLoggerExtension() {
public void afterEach(ExtensionContext context) {
var loggerNames = loggerKeeper.cleanAndReset();
- extensionLogger.debug(() -> "Clean and reset the loggers: " + String.join(", ", loggerNames));
+ extensionLogger.log(Level.DEBUG, () -> "Clean and reset the loggers: " + String.join(", ", loggerNames));
}
/**
@@ -103,7 +102,7 @@ public void afterEach(ExtensionContext context) {
public void beforeEach(ExtensionContext context) {
var loggerNames = loggerKeeper.cleanAndReset();
- extensionLogger.debug(() -> "Clean and reset the loggers: " + String.join(", ", loggerNames));
+ extensionLogger.log(Level.DEBUG, () -> "Clean and reset the loggers: " + String.join(", ", loggerNames));
}
}
diff --git a/core/src/test/java/io/github/vitalijr2/logging/mock/MockLoggerExtensionFastTest.java b/core/src/test/java/io/github/vitalijr2/logging/mock/MockLoggerExtensionFastTest.java
index dca6ed5..29728a4 100644
--- a/core/src/test/java/io/github/vitalijr2/logging/mock/MockLoggerExtensionFastTest.java
+++ b/core/src/test/java/io/github/vitalijr2/logging/mock/MockLoggerExtensionFastTest.java
@@ -2,10 +2,12 @@
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
+import java.lang.System.Logger.Level;
import java.util.List;
import java.util.function.Supplier;
import org.junit.jupiter.api.BeforeEach;
@@ -30,7 +32,7 @@ class MockLoggerExtensionFastTest {
@Mock
private ExtensionContext extensionContext;
@Mock
- private org.junit.platform.commons.logging.Logger extensionLogger;
+ private System.Logger extensionLogger;
private MockLoggerExtension extension;
@@ -51,7 +53,7 @@ void resetLoggersAfterEachTest() {
// then
verifyNoInteractions(extensionContext);
- verify(extensionLogger).debug(messageCaptor.capture());
+ verify(extensionLogger).log(eq(Level.DEBUG), messageCaptor.capture());
verify(loggerKeeper).cleanAndReset();
assertEquals("Clean and reset the loggers: a, b, c", messageCaptor.getValue().get(),
@@ -69,7 +71,7 @@ void resetLoggersBeforeEachTest() {
// then
verifyNoInteractions(extensionContext);
- verify(extensionLogger).debug(messageCaptor.capture());
+ verify(extensionLogger).log(eq(Level.DEBUG), messageCaptor.capture());
verify(loggerKeeper).cleanAndReset();
assertEquals("Clean and reset the loggers: a, b, c", messageCaptor.getValue().get(),
diff --git a/jdk-platform-logging/pom.xml b/jdk-platform-logging/pom.xml
index 23ea101..427b27e 100644
--- a/jdk-platform-logging/pom.xml
+++ b/jdk-platform-logging/pom.xml
@@ -13,6 +13,17 @@
maven-failsafe-pluginorg.apache.maven.plugins
+
+ maven-jar-plugin
+
+
+
+ mock.loggers.platform
+
+
+
+ org.apache.maven.plugins
+ jacoco-maven-pluginorg.jacoco
@@ -39,7 +50,7 @@
mock-loggers-coreio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1mockito-core
@@ -57,9 +68,23 @@
mock-loggersio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1
+
+
+
+
+ license-maven-plugin
+
+ false
+
+ org.codehaus.mojo
+
+
+
+ prepare-and-check
+
diff --git a/jdk-platform-logging/readme.md b/jdk-platform-logging/readme.md
index ad9d4dc..3a811a3 100644
--- a/jdk-platform-logging/readme.md
+++ b/jdk-platform-logging/readme.md
@@ -1,6 +1,7 @@
# Mock loggers for JDK Platform Logging
-[JDK Platform Logging][jdk-logging] service with mock loggers backed by [Mockito][].
+[JDK Platform Logging][jdk-logging] service with mock loggers
+backed by [Mockito][].
> [!WARNING]
> This library does not support _parallel test execution_.
@@ -14,16 +15,18 @@
## How to use
Just put a test dependency to your POM:
+
```xml
mock-loggers-jdk-platform-loggingio.github.vitalijr2.loggingtest
- 1.1.0
+ 1.1.1
```
The simplest usage example looks like this:
+
```java
@Test
void helloWorld() {
@@ -34,12 +37,15 @@ void helloWorld() {
verify(System.getLogger("HelloService")).log(Level.INFO, "Hello World!");
}
```
+
See more details at [HelloServiceBasicTest.java](src/it/hello-jdk-platform-logging-world/src/test/java/example/hello/HelloServiceBasicTest.java)
> [!IMPORTANT]
> Keep in mind that all loggers are initialized only once during the test run.
-Therefore, a more complex example cleans the loggers after (or before) each test:
+Therefore, a more complex example cleans the loggers after (or before)
+each test:
+
```java
// the static logger instance
private static Logger logger;
@@ -71,9 +77,12 @@ void names(String name) {
verifyNoMoreInteractions(logger);
}
```
+
See more details at [HelloServiceFullTest.java](src/it/hello-jdk-platform-logging-world/src/test/java/example/hello/HelloServiceFullTest.java)
-To avoid manual cleaning of mock loggers you can use the [jUnit extension][junit-extension] for automation:
+To avoid manual cleaning of mock loggers you can use
+the [jUnit extension][junit-extension] for automation:
+
```java
@ExtendWith(MockLoggerExtension.class)
class HelloServiceExtensionTest {
@@ -101,9 +110,11 @@ class HelloServiceExtensionTest {
}
```
+
See more details at [HelloServiceExtensionTest.java](src/it/hello-jdk-platform-logging-world/src/test/java/example/hello/HelloServiceExtensionTest.java)
Also you can use the annotation for automation:
+
```java
@MockLoggers
class HelloServiceAnnotationTest {
@@ -131,6 +142,7 @@ class HelloServiceAnnotationTest {
}
```
+
See more details at [HelloServiceAnnotationTest.java](src/it/hello-jdk-platform-logging-world/src/test/java/example/hello/HelloServiceAnnotationTest.java)
[jdk-logging]: https://www.baeldung.com/java-9-logging-api "Java Platform Logging API"
@@ -141,7 +153,7 @@ See more details at [HelloServiceAnnotationTest.java](src/it/hello-jdk-platform-
[jdk-download]: https://www.oracle.com/java/technologies/downloads/#java11
-[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.14.2&color=blue&logoColor=E23D28
+[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.15.2&color=blue&logoColor=E23D28
[maven-central-last-update]: https://img.shields.io/maven-central/last-update/io.github.vitalijr2.logging/mock-loggers-jdk-platform-logging
diff --git a/jdk-platform-logging/src/it/hello-jdk-platform-logging-world/pom.xml b/jdk-platform-logging/src/it/hello-jdk-platform-logging-world/pom.xml
index 2be8443..36954dc 100644
--- a/jdk-platform-logging/src/it/hello-jdk-platform-logging-world/pom.xml
+++ b/jdk-platform-logging/src/it/hello-jdk-platform-logging-world/pom.xml
@@ -71,7 +71,7 @@
115.11.3
- 5.14.2
+ 5.15.2UTF-81.0.0
diff --git a/pom.xml b/pom.xml
index 4a537ef..ad1dceb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,6 +120,7 @@
${java.version}${java.version}
+ trueorg.apache.maven.plugins3.13.0
@@ -177,7 +178,7 @@
org.apache.maven.plugins
- 3.8.1
+ 3.9.0maven-jar-plugin
@@ -283,6 +284,10 @@
org.apache.maven.plugins3.5.0
+
+ flatten-maven-plugin
+ org.codehaus.mojo
+
@@ -321,12 +326,6 @@
test${junit.version}
-
- junit-platform-commons
- org.junit.platform
- test
- 1.11.3
- mockito-coreorg.mockito
@@ -382,42 +381,54 @@
+
+
+
+ license-maven-plugin
+
+
+
+ false
+ true
+ test
+
+ **/package-info.java
+
+ io\.github\.vitalijr2\.logging
+ ${project.inceptionYear}
+
+
+ Apache License version 2.0|The Apache Software License, Version 2.0|The Apache License, Version 2.0|Apache License, Version 2.0|Apache-2.0|Apache 2
+ Eclipse Public License - v 2.0|Eclipse Public License v2.0
+ MIT License|MIT
+
+ apache_v2
+
+ Vitalij Berdinskih
+ ${project.basedir}
+ ---------------LICENSE_END-------------------
+ ---------------LICENSE_START-----------------
+ Mock Loggers
+
+ src/main/java
+
+ ---------------------------------------------
+ true
+
+ default-cli
+
+
+ org.codehaus.mojo
+ 2.5.0
+
+
+ license-maven-plugin
-
-
-
- false
- true
- test
-
- **/package-info.java
-
- io\.github\.vitalijr2\.logging
- ${project.inceptionYear}
-
-
- Apache License version 2.0|The Apache Software License, Version 2.0|The Apache License, Version 2.0|Apache License, Version 2.0|Apache-2.0|Apache 2
- Eclipse Public License - v 2.0|Eclipse Public License v2.0
- MIT License|MIT
-
- apache_v2
-
- Vitalij Berdinskih
- ${project.basedir}
- ---------------LICENSE_END-------------------
- ---------------LICENSE_START-----------------
- Mock Loggers
-
- src/main/java
-
- ---------------------------------------------
- true
-
- default-cli
-
-
+
+ true
+ org.codehaus.mojo2.5.0
@@ -516,8 +527,8 @@
113.11.2
- 5.11.3
- 5.14.2
+ 5.11.4
+ 5.15.2UTF-8
@@ -526,5 +537,5 @@
https://github.com/vitalijr2/mock-loggershttps://github.com/vitalijr2/mock-loggers
- 1.1.1-SNAPSHOT
+ 1.1.1
diff --git a/readme.md b/readme.md
index adbe18c..cd3d340 100644
--- a/readme.md
+++ b/readme.md
@@ -8,7 +8,7 @@ Different logging services can be tested using mock loggers backed by [Mockito][
[![Java Version][java-version]][jdk-download]
![jUnit Version][junit-version]
![Mockito Version][mockito-version]
-[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html)
+[![License][license-badge]][license-link]
[![GitHub master check runs][github-master-check-runs]][github-master-check-runs-link]
[![Codacy Badge][codacy-badge]][codacy-badge-link]
[![Codacy Coverage][codacy-coverage]][codacy-coverage-link]
@@ -18,6 +18,7 @@ Different logging services can be tested using mock loggers backed by [Mockito][
## How to use
The simplest usage example looks like this:
+
```java
@Test
void helloWorld() {
@@ -61,7 +62,7 @@ See [Changelog](changelog.md)
## License
-```
+```text
Copyright (C) 2024 Vitalij Berdinskih
Licensed under the Apache License, Version 2.0 (the "License");
@@ -95,7 +96,7 @@ See full text [here](LICENSE "the LICENSE file").
[junit-version]: https://img.shields.io/static/v1?label=jUnit&message=5.11.3&color=blue&logo=junit5&logoColor=E23D28
-[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.14.2&color=blue&logoColor=E23D28
+[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.15.2&color=blue&logoColor=E23D28
[github-master-check-runs]: https://img.shields.io/github/check-runs/vitalijr2/mock-loggers/master
@@ -122,3 +123,7 @@ See full text [here](LICENSE "the LICENSE file").
[slf4j-mock]: https://github.com/s4u/slf4j-mock
[mock-slf4j-impl]: https://github.com/ocarlsen/mock-slf4j-impl
+
+[license-badge]: https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat
+
+[license-link]: https://www.apache.org/licenses/LICENSE-2.0.html
diff --git a/slf4j/pom.xml b/slf4j/pom.xml
index 1505c5f..514b49e 100644
--- a/slf4j/pom.xml
+++ b/slf4j/pom.xml
@@ -13,6 +13,17 @@
maven-failsafe-pluginorg.apache.maven.plugins
+
+ maven-jar-plugin
+
+
+
+ mock.loggers.slf4j
+
+
+
+ org.apache.maven.plugins
+ jacoco-maven-pluginorg.jacoco
@@ -39,7 +50,7 @@
mock-loggers-coreio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1mockito-core
@@ -62,9 +73,23 @@
mock-loggersio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1
+
+
+
+
+ license-maven-plugin
+
+ false
+
+ org.codehaus.mojo
+
+
+
+ prepare-and-check
+
diff --git a/slf4j/readme.md b/slf4j/readme.md
index 14506f7..f8539c1 100644
--- a/slf4j/readme.md
+++ b/slf4j/readme.md
@@ -15,16 +15,18 @@
## How to use
Just put a test dependency to your POM:
+
```xml
mock-loggers-slf4jio.github.vitalijr2.loggingtest
- 1.1.0
+ 1.1.1
```
The simplest usage example looks like this:
+
```java
@Test
void helloWorld() {
@@ -35,12 +37,15 @@ void helloWorld() {
verify(LoggerFactory.getLogger(helloService.getClass())).info("Hello World!");
}
```
+
See more details at [HelloServiceBasicTest.java](src/it/hello-slf4j-world/src/test/java/example/hello/HelloServiceBasicTest.java)
> [!IMPORTANT]
> Keep in mind that all loggers are initialized only once during the test run.
-Therefore, a more complex example cleans the loggers after (or before) each test:
+Therefore, a more complex example cleans the loggers after (or before)
+each test:
+
```java
// the static logger instance
private static Logger logger;
@@ -72,9 +77,12 @@ void names(String name) {
verifyNoMoreInteractions(actualLogger);
}
```
+
See more details at [HelloServiceFullTest.java](src/it/hello-slf4j-world/src/test/java/example/hello/HelloServiceFullTest.java)
-To avoid manual cleaning of mock loggers you can use the [jUnit extension][junit-extension] for automation:
+To avoid manual cleaning of mock loggers you can use
+the [jUnit extension][junit-extension] for automation:
+
```java
@ExtendWith(MockLoggerExtension.class)
class HelloServiceExtensionTest {
@@ -102,9 +110,11 @@ class HelloServiceExtensionTest {
}
```
+
See more details at [HelloServiceExtensionTest.java](src/it/hello-slf4j-world/src/test/java/example/hello/HelloServiceExtensionTest.java)
Also you can use the annotation for automation:
+
```java
@MockLoggers
class HelloServiceAnnotationTest {
@@ -132,6 +142,7 @@ class HelloServiceAnnotationTest {
}
```
+
See more details at [HelloServiceAnnotationTest.java](src/it/hello-slf4j-world/src/test/java/example/hello/HelloServiceAnnotationTest.java)
[slf4j]: https://www.slf4j.org/
@@ -144,7 +155,7 @@ See more details at [HelloServiceAnnotationTest.java](src/it/hello-slf4j-world/s
[slf4j-version]: https://img.shields.io/static/v1?label=SLF4J&message=2.0.16&color=blue&logoColor=E23D28
-[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.14.2&color=blue&logoColor=E23D28
+[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.15.2&color=blue&logoColor=E23D28
[maven-central-last-update]: https://img.shields.io/maven-central/last-update/io.github.vitalijr2.logging/mock-loggers-slf4j
diff --git a/slf4j/src/it/hello-slf4j-world/pom.xml b/slf4j/src/it/hello-slf4j-world/pom.xml
index 60d995d..8ee0f39 100644
--- a/slf4j/src/it/hello-slf4j-world/pom.xml
+++ b/slf4j/src/it/hello-slf4j-world/pom.xml
@@ -76,7 +76,7 @@
115.11.3
- 5.14.2
+ 5.15.2UTF-81.0.0
diff --git a/tinylog-provider/pom.xml b/tinylog-provider/pom.xml
index b343a4d..594996e 100644
--- a/tinylog-provider/pom.xml
+++ b/tinylog-provider/pom.xml
@@ -13,6 +13,17 @@
maven-failsafe-pluginorg.apache.maven.plugins
+
+ maven-jar-plugin
+
+
+
+ mock.loggers.tinylog.provider
+
+
+
+ org.apache.maven.plugins
+ jacoco-maven-pluginorg.jacoco
@@ -41,15 +52,10 @@
junit-jupiter-paramsorg.junit.jupiter
-
- junit-platform-commons
- org.junit.platform
- provided
- mock-loggers-coreio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1mockito-core
@@ -72,9 +78,23 @@
mock-loggersio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1
+
+
+
+
+ license-maven-plugin
+
+ false
+
+ org.codehaus.mojo
+
+
+
+ prepare-and-check
+
diff --git a/tinylog-provider/readme.md b/tinylog-provider/readme.md
index 34450ff..f45fd39 100644
--- a/tinylog-provider/readme.md
+++ b/tinylog-provider/readme.md
@@ -14,23 +14,28 @@
## Foreword
-Unlike the traditional approach where each class or even instance has its own named logger,
-tinylog uses a singleton logger. And the provider implementation is a bit complicated to check access to the logger.
+Unlike the traditional approach where each class or even instance has
+its own named logger, tinylog uses a singleton logger.
+And the provider implementation is a bit complicated
+to check access to the logger.
Therefore, I recommend using the [Writer](../tinylog-writer) for testing.
## How to use
Just put a test dependency to your POM:
+
```xml
mock-loggers-tinylog-providerio.github.vitalijr2.loggingtest
- 1.1.0
+ 1.1.1
```
-Use the `MockTinylogProvider` annotation to access the mock provider. The simplest usage example looks like this:
+Use the `MockTinylogProvider` annotation to access the mock provider.
+The simplest usage example looks like this:
+
```java
@MockTinylogProvider
private static LoggingProvider logger;
@@ -46,12 +51,15 @@ void helloWorld() {
verify(logger).log(anyInt(), isNull(), eq(Level.INFO), isNull(), isNull(), anyString(), isNull());
}
```
+
See more details at [HelloServiceBasicTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceBasicTest.java)
> [!IMPORTANT]
> Keep in mind that the logger is initialized only once during the test run.
-Therefore, a more complex example cleans the logger after (or before) each test:
+Therefore, a more complex example cleans the logger after (or before)
+each test:
+
```java
// the static logger instance
@MockTinylogProvider
@@ -78,9 +86,12 @@ void names(String name) {
eq("Hello " + name + "!"), isNull());
}
```
+
See more details at [HelloServiceFullTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceFullTest.java)
-To avoid manual cleaning of the mock logger you can use the [jUnit extension][junit-extension] for automation:
+To avoid manual cleaning of the mock logger you can use
+the [jUnit extension][junit-extension] for automation:
+
```java
@ExtendWith(MockLoggerExtension.class)
class HelloServiceExtensionTest {
@@ -104,9 +115,11 @@ class HelloServiceExtensionTest {
}
```
+
See more details at [HelloServiceExtensionTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceExtensionTest.java)
Also you can use the annotation for automation:
+
```java
@MockLoggers
class HelloServiceAnnotationTest {
@@ -130,11 +143,14 @@ class HelloServiceAnnotationTest {
}
```
+
See more details at [HelloServiceAnnotationTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceAnnotationTest.java)
### LoggingProvider as a parameter
-This library can also inject a mock provider instance as a parameter of a test method:
+This library can also inject a mock provider instance
+as a parameter of a test method:
+
```java
@ExtendWith({MockLoggerExtension.class,MockTinylogProviderExtension.class})
class HelloServiceParameterTest {
@@ -153,12 +169,14 @@ class HelloServiceParameterTest {
}
```
+
See more details ad [HelloServiceParameterTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceParameterTest.java)
### Configuration
-If your application is bundled with another tinylog provider and it is present on the test classpath,
-use the configuration to specify the use of the mock provider.
+If your application is bundled with another tinylog provider,
+and it is present on the test classpath, use the configuration
+to specify the use of the mock provider.
See [tinylog.properties](src/it/hello-custom-tinylog-world/src/test/resources/tinylog.properties).
[tinylog]: https://tinylog.org/v2/
@@ -171,7 +189,7 @@ See [tinylog.properties](src/it/hello-custom-tinylog-world/src/test/resources/ti
[tinylog-version]: https://img.shields.io/static/v1?label=tinylog&message=2.7.0&color=blue&logoColor=E23D28
-[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.14.2&color=blue&logoColor=E23D28
+[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.15.2&color=blue&logoColor=E23D28
[maven-central-last-update]: https://img.shields.io/maven-central/last-update/io.github.vitalijr2.logging/mock-loggers-tinylog-provider
diff --git a/tinylog-provider/src/it/hello-custom-tinylog-world/pom.xml b/tinylog-provider/src/it/hello-custom-tinylog-world/pom.xml
index 3a55f43..7d58c2f 100644
--- a/tinylog-provider/src/it/hello-custom-tinylog-world/pom.xml
+++ b/tinylog-provider/src/it/hello-custom-tinylog-world/pom.xml
@@ -81,7 +81,7 @@
115.11.3
- 5.14.2
+ 5.15.2UTF-82.7.0
diff --git a/tinylog-provider/src/it/hello-tinylog-world/pom.xml b/tinylog-provider/src/it/hello-tinylog-world/pom.xml
index f62dffd..fab4113 100644
--- a/tinylog-provider/src/it/hello-tinylog-world/pom.xml
+++ b/tinylog-provider/src/it/hello-tinylog-world/pom.xml
@@ -76,7 +76,7 @@
115.11.3
- 5.14.2
+ 5.15.2UTF-81.0.0
diff --git a/tinylog-writer/pom.xml b/tinylog-writer/pom.xml
index e4a1310..ce8e81d 100644
--- a/tinylog-writer/pom.xml
+++ b/tinylog-writer/pom.xml
@@ -13,6 +13,17 @@
maven-failsafe-pluginorg.apache.maven.plugins
+
+ maven-jar-plugin
+
+
+
+ mock.loggers.tinylog.writer
+
+
+
+ org.apache.maven.plugins
+ jacoco-maven-pluginorg.jacoco
@@ -41,15 +52,10 @@
junit-jupiter-paramsorg.junit.jupiter
-
- junit-platform-commons
- org.junit.platform
- provided
- mock-loggers-coreio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1mockito-core
@@ -77,9 +83,23 @@
mock-loggersio.github.vitalijr2.logging
- 1.1.1-SNAPSHOT
+ 1.1.1
+
+
+
+
+ license-maven-plugin
+
+ false
+
+ org.codehaus.mojo
+
+
+
+ prepare-and-check
+
diff --git a/tinylog-writer/readme.md b/tinylog-writer/readme.md
index e582362..458c3c1 100644
--- a/tinylog-writer/readme.md
+++ b/tinylog-writer/readme.md
@@ -14,22 +14,26 @@
## Foreword
-Unlike the traditional approach where each class or even instance has its own named logger,
-tinylog uses a singleton logger. Keep this in mind when testing logger calls.
+Unlike the traditional approach where each class or even instance has
+its own named logger, tinylog uses a singleton logger.
+Keep this in mind when testing logger calls.
## How to use
Just put a test dependency to your POM:
+
```xml
mock-loggers-tinylog-writerio.github.vitalijr2.loggingtest
- 1.1.0
+ 1.1.1
```
-Use the `MockTinylogWriter` annotation to access the mock writer. The simplest usage example looks like this:
+Use the `MockTinylogWriter` annotation to access the mock writer.
+The simplest usage example looks like this:
+
```java
@MockTinylogWriter
private static Writer writer;
@@ -43,12 +47,15 @@ void helloWorld() {
verify(writer).write(isA(LogEntry.class));
}
```
+
See more details at [HelloServiceBasicTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceBasicTest.java)
> [!IMPORTANT]
> Keep in mind that the writer are initialized only once during the test run.
-Therefore, a more complex example cleans the writer after (or before) each test:
+Therefore, a more complex example cleans the writer after (or before)
+each test:
+
```java
// the static logger instance
@Captor
@@ -76,9 +83,12 @@ void names(String name) {
assertEquals("Hello " + name + "!", logEntryCaptor.getValue().getMessage());
}
```
+
See more details at [HelloServiceFullTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceFullTest.java)
-To avoid manual cleaning of mock writer you can use the [jUnit extension][junit-extension] for automation:
+To avoid manual cleaning of mock writer you can use
+the [jUnit extension][junit-extension] for automation:
+
```java
@ExtendWith({MockitoExtension.class, MockLoggerExtension.class})
class HelloServiceExtensionTest {
@@ -103,9 +113,11 @@ class HelloServiceExtensionTest {
}
```
+
See more details at [HelloServiceExtensionTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceExtensionTest.java)
Also you can use the annotation for automation:
+
```java
@ExtendWith(MockitoExtension.class)
@MockLoggers
@@ -133,11 +145,14 @@ class HelloServiceAnnotationTest {
}
```
+
See more details at [HelloServiceAnnotationTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceAnnotationTest.java)
### Writer as a parameter
-This library can also inject a mock writer instance as a parameter of a test method:
+This library can also inject a mock writer instance
+as a parameter of a test method:
+
```java
@ExtendWith({MockLoggerExtension.class,MockTinylogWriterExtension.class})
class HelloServiceParameterTest {
@@ -156,6 +171,7 @@ class HelloServiceParameterTest {
}
```
+
See more details ad [HelloServiceParameterTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceParameterTest.java)
### Configuration
@@ -175,7 +191,7 @@ See [tinylog.properties](src/it/hello-tinylog-world/src/test/resources/tinylog.p
[tinylog-version]: https://img.shields.io/static/v1?label=tinylog&message=2.7.0&color=blue&logoColor=E23D28
-[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.14.2&color=blue&logoColor=E23D28
+[mockito-version]: https://img.shields.io/static/v1?label=Mockito&message=5.15.2&color=blue&logoColor=E23D28
[maven-central-last-update]: https://img.shields.io/maven-central/last-update/io.github.vitalijr2.logging/mock-loggers-tinylog-writer
diff --git a/tinylog-writer/src/it/hello-tinylog-world/pom.xml b/tinylog-writer/src/it/hello-tinylog-world/pom.xml
index f62dffd..fab4113 100644
--- a/tinylog-writer/src/it/hello-tinylog-world/pom.xml
+++ b/tinylog-writer/src/it/hello-tinylog-world/pom.xml
@@ -76,7 +76,7 @@
115.11.3
- 5.14.2
+ 5.15.2UTF-81.0.0