This repository has been archived by the owner on Jan 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
313 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
exclude_paths: | ||
- "**/mock-jdk-platform-logging.css" | ||
- "**/prism.css" | ||
- "**/prism.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Mock of JDK Platform Logging | ||
|
||
JDK Platform Logging Service with mocked loggers backed by [Mockito][]. | ||
|
||
## How to use | ||
|
||
Just put to your POM: | ||
```xml | ||
<dependencies> | ||
... | ||
<dependency> | ||
<artifactId>mock-jdk-platform-logging</artifactId> | ||
<groupId>io.github.vitalijr2.logging</groupId> | ||
<scope>test</scope> | ||
<version>1.0.0</version> | ||
</dependency> | ||
... | ||
</dependencies> | ||
|
||
``` | ||
|
||
Example: | ||
```java | ||
// the static logger instance | ||
private static Logger logger; | ||
|
||
// initialize it once | ||
@BeforeAll | ||
static void setUpClass() { | ||
logger = System.getLogger("test"); | ||
} | ||
|
||
// clean it after each test | ||
@AfterEach | ||
void tearDown() { | ||
clearInvocations(logger); | ||
} | ||
|
||
// use the mock in a test | ||
@DisplayName("Test") | ||
@ParameterizedTest | ||
@ValueSource(strings = {"TRACE", "DEBUG", "INFO", "WARNING", "ERROR"}) | ||
void test(Level level) { | ||
// given | ||
var logger = System.getLogger("test") | ||
|
||
// when | ||
logger.log(level, "test message"); | ||
|
||
// then | ||
verify(logger).log(level, "test message"); | ||
} | ||
``` | ||
|
||
## Credits | ||
|
||
There are two projects which inspired me to make this library: | ||
|
||
- [s4u/slf4j-mock][slf4j-mock] | ||
- [ocarlsen/mock-slf4j-impl][mock-slf4j-impl] | ||
|
||
## Contributing | ||
|
||
Please read [Contributing](contributing.md). | ||
|
||
## History | ||
|
||
See [Changelog](changelog.md) | ||
|
||
## License | ||
|
||
Copyright 2023-2024 Vitalij Berdinskih | ||
|
||
Licensed 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 | ||
|
||
<https://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. | ||
|
||
[Apache License v2.0](LICENSE) | ||
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html) | ||
|
||
[Mockito]: https://site.mockito.org | ||
|
||
[slf4j-mock]: https://github.com/s4u/slf4j-mock | ||
|
||
[mock-slf4j-impl]: https://github.com/ocarlsen/mock-slf4j-impl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* JDK Platform Logging Service implementation. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
package io.github.vitalijr2.mock.jdk.platform.logging; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Mock of JDK Platform Logging</title> | ||
</head> | ||
<body> | ||
<h1>Mock of JDK Platform Logging</h1> | ||
<p>JDK Platform Logging Service with mocked loggers backed by <a href="https://site.mockito.org/">Mockito</a>.</p> | ||
<p id="badges"> | ||
<a href="https://app.codacy.com/gh/vitalijr2/mock-jdk-platform-logging/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade"><img | ||
alt="Codacy Badge" src="https://app.codacy.com/project/badge/Grade/9be380deaf3e40138ad306a40532289c"></a> | ||
<a href="https://app.codacy.com/gh/vitalijr2/mock-jdk-platform-logging/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage"><img | ||
alt="Codacy Coverage" src="https://app.codacy.com/project/badge/Coverage/9be380deaf3e40138ad306a40532289c"></a> | ||
<a href="https://libraries.io/github/vitalijr2/mock-jdk-platform-logging"><img | ||
alt="Libraries.io dependency status for GitHub repo" | ||
src="https://img.shields.io/librariesio/github/vitalijr2/mock-jdk-platform-logging"></a> | ||
<a href="https://www.oracle.com/java/technologies/downloads/#java11"><img | ||
alt="Java Version" | ||
src="https://img.shields.io/static/v1?label=java&message=11&color=blue&logo=java&logoColor=E23D28"></a> | ||
</p> | ||
Example: | ||
<pre><code class="language-java"> | ||
// the static logger instance | ||
private static Logger logger; | ||
|
||
// initialize it once | ||
{@literal @}BeforeAll | ||
static void setUpClass() { | ||
logger = System.getLogger("test"); | ||
} | ||
|
||
// clean it after each test | ||
{@literal @}AfterEach | ||
void tearDown() { | ||
clearInvocations(logger); | ||
} | ||
|
||
// use the mock in a test | ||
{@literal @}DisplayName("Test") | ||
{@literal @}ParameterizedTest | ||
{@literal @}ValueSource(strings = {"TRACE", "DEBUG", "INFO", "WARNING", "ERROR"}) | ||
void test(Level level) { | ||
// given | ||
var logger = System.getLogger("test") | ||
|
||
// when | ||
logger.log(level, "test message"); | ||
|
||
// then | ||
verify(logger).log(level, "test message"); | ||
} | ||
</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.tooltip { | ||
border-bottom: 1px dotted #4d7a97; | ||
display: inline-block; | ||
position: relative; | ||
} | ||
|
||
.tooltip .tooltiptext { | ||
background-color: #f8981d; | ||
border: 1px dotted #4d7a97; | ||
-moz-border-radius: 6px; | ||
-ms-border-radius: 6px; | ||
-webkit-border-radius: 6px; | ||
border-radius: 6px; | ||
color: #253441; | ||
left: 113%; | ||
padding: 5px 3px; | ||
position: absolute; | ||
text-align: center; | ||
top: -5px; | ||
visibility: hidden; | ||
width: 97px; | ||
z-index: 1; | ||
} | ||
|
||
.tooltip:hover .tooltiptext { | ||
visibility: visible; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.