This repository has been archived by the owner on Nov 27, 2024. 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.
* Bump org.sonatype.central:central-publishing-maven-plugin Bumps [org.sonatype.central:central-publishing-maven-plugin](https://github.com/sonatype/central-publishing-maven-plugin) from 0.4.0 to 0.5.0. - [Commits](https://github.com/sonatype/central-publishing-maven-plugin/commits) --- updated-dependencies: - dependency-name: org.sonatype.central:central-publishing-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Prepare integration tests * Add a demo integration test * Add a demo integration test * Codacy: ignore the demo * CodeNarc: ignore the demo * Update README * Update README * Add badges for Maven Central and Javadoc.io --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
22e7cde
commit b263243
Showing
9 changed files
with
271 additions
and
8 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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
--- | ||
engines: | ||
codenarc: | ||
exclude_paths: | ||
- "src/it/**" | ||
exclude_paths: | ||
- "src/it/**" | ||
- "**/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,99 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<artifactId>basic</artifactId> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<release>${java.version}</release> | ||
</configuration> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<version>3.13.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<version>3.3.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<includes> | ||
<include>**/*Test.java</include> | ||
</includes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<version>3.3.1</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<!-- test --> | ||
<dependency> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<groupId>org.junit.jupiter</groupId> | ||
<scope>test</scope> | ||
<version>${junit-jupiter.version}</version> | ||
</dependency> | ||
<dependency> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<groupId>org.junit.jupiter</groupId> | ||
<scope>test</scope> | ||
<version>${junit-jupiter.version}</version> | ||
</dependency> | ||
<dependency> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<groupId>org.junit.jupiter</groupId> | ||
<scope>test</scope> | ||
<version>${junit-jupiter.version}</version> | ||
</dependency> | ||
<dependency> | ||
<artifactId>mockito-core</artifactId> | ||
<groupId>org.mockito</groupId> | ||
<scope>test</scope> | ||
<version>${mockito.version}</version> | ||
</dependency> | ||
<dependency> | ||
<artifactId>mockito-junit-jupiter</artifactId> | ||
<groupId>org.mockito</groupId> | ||
<scope>test</scope> | ||
<version>${mockito.version}</version> | ||
</dependency> | ||
<dependency> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<groupId>@project.groupId@</groupId> | ||
<scope>test</scope> | ||
<version>@project.version@</version> | ||
</dependency> | ||
<dependency> | ||
<artifactId>hamcrest</artifactId> | ||
<groupId>org.hamcrest</groupId> | ||
<scope>test</scope> | ||
<version>2.2</version> | ||
</dependency> | ||
</dependencies> | ||
<description>Basic example</description> | ||
<groupId>example.hello</groupId> | ||
<modelVersion>4.0.0</modelVersion> | ||
<properties> | ||
<java.version>11</java.version> | ||
<junit-jupiter.version>5.10.3</junit-jupiter.version> | ||
<mockito.version>5.12.0</mockito.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<version>1.0.0</version> | ||
</project> |
27 changes: 27 additions & 0 deletions
27
src/it/hello-world/src/main/java/example/hello/HelloService.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,27 @@ | ||
package example.hello; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.lang.System.Logger; | ||
|
||
public class HelloService { | ||
|
||
private final Logger logger = System.getLogger("HelloService"); | ||
|
||
public String sayHelloWorld() { | ||
return sayHello("World"); | ||
} | ||
|
||
public String sayHello(String name) { | ||
if (requireNonNull(name, "Name is missed").isBlank()) { | ||
throw new IllegalArgumentException("Name is empty"); | ||
} | ||
|
||
var greeting = "Hello " + name + "!"; | ||
|
||
logger.log(System.Logger.Level.INFO, greeting); | ||
|
||
return greeting; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/it/hello-world/src/test/java/example/hello/HelloServiceBasicTest.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,21 @@ | ||
package example.hello; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.mockito.Mockito.verify; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class HelloServiceBasicTest { | ||
|
||
@DisplayName("Hello world") | ||
@Test | ||
void helloWorld() { | ||
var helloService = new HelloService(); | ||
|
||
assertDoesNotThrow(helloService::sayHelloWorld); | ||
|
||
verify(System.getLogger("HelloService")).log(System.Logger.Level.INFO, "Hello World!"); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
src/it/hello-world/src/test/java/example/hello/HelloServiceFullTest.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,63 @@ | ||
package example.hello; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.StringStartsWith.startsWith; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.mockito.Mockito.clearInvocations; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.verifyNoInteractions; | ||
import static org.mockito.Mockito.verifyNoMoreInteractions; | ||
|
||
import java.lang.System.Logger; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.NullAndEmptySource; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
class HelloServiceFullTest { | ||
|
||
private static Logger logger; | ||
|
||
@BeforeAll | ||
static void setUpClass() throws Exception { | ||
logger = System.getLogger("HelloService"); | ||
} | ||
|
||
@BeforeEach | ||
void setUp() throws Exception { | ||
clearInvocations(logger); | ||
} | ||
|
||
@DisplayName("Names") | ||
@ParameterizedTest(name = "<{0}>") | ||
@ValueSource(strings = {"John", "Jane"}) | ||
void names(String name) { | ||
var helloService = new HelloService(); | ||
|
||
assertDoesNotThrow(() -> helloService.sayHello(name)); | ||
|
||
var logger = System.getLogger("HelloService"); | ||
|
||
verify(logger).log(System.Logger.Level.INFO, "Hello " + name + "!"); | ||
verifyNoMoreInteractions(logger); | ||
} | ||
|
||
@DisplayName("Null or empty name") | ||
@ParameterizedTest(name = "<{0}>") | ||
@NullAndEmptySource | ||
@ValueSource(strings = " ") | ||
void nullOrEmptyName(String name) { | ||
var helloService = new HelloService(); | ||
|
||
var exception = assertThrows(RuntimeException.class, () -> helloService.sayHello(name)); | ||
|
||
verifyNoInteractions(System.getLogger("HelloService")); | ||
|
||
assertThat(exception.getMessage(), startsWith("Name is")); | ||
} | ||
|
||
|
||
} |
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 @@ | ||
println "Hello World!" |
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,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<settings> | ||
<profiles> | ||
<profile> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
<id>it-repo</id> | ||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>local.central</id> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
<url>@localRepositoryUrl@</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
<repositories> | ||
<repository> | ||
<id>local.central</id> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
<url>@localRepositoryUrl@</url> | ||
</repository> | ||
</repositories> | ||
</profile> | ||
</profiles> | ||
</settings> |