Skip to content

Commit

Permalink
Update dependencies, Javadoc and tinylog's READMEs
Browse files Browse the repository at this point in the history
* Bump org.codehaus.mojo:license-maven-plugin from 2.4.0 to 2.5.0

Bumps [org.codehaus.mojo:license-maven-plugin](https://github.com/mojohaus/license-maven-plugin) from 2.4.0 to 2.5.0.
- [Release notes](https://github.com/mojohaus/license-maven-plugin/releases)
- [Commits](mojohaus/license-maven-plugin@2.4.0...2.5.0)

---
updated-dependencies:
- dependency-name: org.codehaus.mojo:license-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.11.1 to 3.11.2

Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.11.1 to 3.11.2.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](apache/maven-javadoc-plugin@maven-javadoc-plugin-3.11.1...maven-javadoc-plugin-3.11.2)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Fix Javadoc issues

* package-info for tinylog-writer

* Update ChangeLog, prepare next version

* Update READMEs

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
vitalijr2 and dependabot[bot] authored Dec 10, 2024
1 parent 0cde73b commit a746c84
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 26 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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

- Update Javadoc

## 1.1.0 - 2024-11-28

- Add tinylog modules: provider and writer
Expand Down
4 changes: 2 additions & 2 deletions commons-logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<dependency>
<artifactId>mock-loggers-core</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>mockito-core</artifactId>
Expand All @@ -62,7 +62,7 @@
<parent>
<artifactId>mock-loggers</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</parent>
<profiles>
<profile>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@
<parent>
<artifactId>mock-loggers</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public class MockLoggerKeeper {
cleaners = new CopyOnWriteArraySet<>();
}

/**
* Get a singleton.
*
* @return instance of logger keeper
*/
@NotNull
public static MockLoggerKeeper getInstance() {
return INSTANCE;
Expand Down
5 changes: 2 additions & 3 deletions jdk-platform-logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<dependency>
<artifactId>mock-loggers-core</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>mockito-core</artifactId>
Expand All @@ -57,8 +57,7 @@
<parent>
<artifactId>mock-loggers</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<relativePath>../pom.xml</relativePath>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</parent>
<profiles>
<profile>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@
</execution>
</executions>
<groupId>org.codehaus.mojo</groupId>
<version>2.4.0</version>
<version>2.5.0</version>
</plugin>
</plugins>
</build>
Expand Down Expand Up @@ -515,7 +515,7 @@
</profiles>
<properties>
<java.version>11</java.version>
<javadoc-plugin.version>3.11.1</javadoc-plugin.version>
<javadoc-plugin.version>3.11.2</javadoc-plugin.version>
<junit.version>5.11.3</junit.version>
<mockito.version>5.14.2</mockito.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -526,5 +526,5 @@
<url>https://github.com/vitalijr2/mock-loggers</url>
</scm>
<url>https://github.com/vitalijr2/mock-loggers</url>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</project>
4 changes: 2 additions & 2 deletions slf4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<dependency>
<artifactId>mock-loggers-core</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>mockito-core</artifactId>
Expand All @@ -62,7 +62,7 @@
<parent>
<artifactId>mock-loggers</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</parent>
<profiles>
<profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public MockLoggerFactory() {
}

@VisibleForTesting
public MockLoggerFactory(Map<String, Logger> loggers) {
MockLoggerFactory(Map<String, Logger> loggers) {
this.loggers = loggers;
subscribeToNotifications();
}
Expand Down
4 changes: 2 additions & 2 deletions tinylog-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<dependency>
<artifactId>mock-loggers-core</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>mockito-core</artifactId>
Expand All @@ -72,7 +72,7 @@
<parent>
<artifactId>mock-loggers</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</parent>
<profiles>
<profile>
Expand Down
16 changes: 10 additions & 6 deletions tinylog-provider/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

## Foreword

Using a provider is complicated by the need to set the results of additional methods.
Therefore, I recommend using testing using [Writer](../tinylog-writer).
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

Expand All @@ -29,8 +30,11 @@ Just put a test dependency to your POM:
</dependency>
```

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;

@Test
void helloWorld() {
when(logger.getMinimumLevel(isNull())).thenReturn(Level.INFO);
Expand All @@ -45,9 +49,9 @@ void helloWorld() {
See more details at [HelloServiceBasicTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceBasicTest.java)

> [!IMPORTANT]
> Keep in mind that all loggers are initialized only once during the test run.
> Keep in mind that the logger is 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 logger after (or before) each test:
```java
// the static logger instance
@MockTinylogProvider
Expand Down Expand Up @@ -76,7 +80,7 @@ void names(String name) {
```
See more details at [HelloServiceFullTest.java](src/it/hello-tinylog-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 the mock logger you can use the [jUnit extension][junit-extension] for automation:
```java
@ExtendWith(MockLoggerExtension.class)
class HelloServiceExtensionTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class MockLoggingProvider implements LoggingProvider, MockLoggerCleaner {
prepareMockInstance();
}

/**
* Create a provider.
*/
public MockLoggingProvider() {
subscribeToNotifications();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
*/
public class MockTinylogProviderException extends RuntimeException {

/**
* Common exception.
*
* @param message message
* @param cause cause
*/
public MockTinylogProviderException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
4 changes: 2 additions & 2 deletions tinylog-writer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<dependency>
<artifactId>mock-loggers-core</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>mockito-core</artifactId>
Expand Down Expand Up @@ -77,7 +77,7 @@
<parent>
<artifactId>mock-loggers</artifactId>
<groupId>io.github.vitalijr2.logging</groupId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</parent>
<profiles>
<profile>
Expand Down
13 changes: 9 additions & 4 deletions tinylog-writer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
[![Maven Central][maven-central]][maven-central-link]
[![Javadoc][javadoc]][javadoc-link]

## 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.

## How to use

Just put a test dependency to your POM:
Expand All @@ -24,7 +29,7 @@ Just put a test dependency to your POM:
</dependency>
```

The simplest usage example looks like this:
Use the `MockTinylogWriter` annotation to access the mock writer. The simplest usage example looks like this:
```java
@Test
void helloWorld() {
Expand All @@ -38,9 +43,9 @@ void helloWorld() {
See more details at [HelloServiceBasicTest.java](src/it/hello-tinylog-world/src/test/java/example/hello/HelloServiceBasicTest.java)

> [!IMPORTANT]
> Keep in mind that all loggers are initialized only once during the test run.
> Keep in mind that the writer 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 writer after (or before) each test:
```java
// the static logger instance
@Captor
Expand Down Expand Up @@ -70,7 +75,7 @@ void names(String name) {
```
See more details at [HelloServiceFullTest.java](src/it/hello-tinylog-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 writer you can use the [jUnit extension][junit-extension] for automation:
```java
@ExtendWith({MockitoExtension.class, MockLoggerExtension.class})
class HelloServiceExtensionTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
*/
public class MockTinylogWriterException extends RuntimeException {

/**
* Common exception.
*
* @param message message
* @param cause cause
*/
public MockTinylogWriterException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public class MockWriter implements Writer, MockLoggerCleaner {
subscribeToNotifications();
}

/**
* Create a writer.
*
* @param properties configuration, not used in a mock
*/
@SuppressWarnings("PMD.UnusedFormalParameter")
public MockWriter(Map<String, String> properties) {
this();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Mock loggers for <a href="https://tinylog.org/v2/">tinylog</a> backed by <a
* href="https://site.mockito.org/">Mockito</a>.
*
* @since 1.1.0
*/
package io.github.vitalijr2.logging.mock.tinylog;

0 comments on commit a746c84

Please sign in to comment.