forked from i-Run/testy-box
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/add-redis-embedded-module' into develop
- Loading branch information
Showing
19 changed files
with
389 additions
and
13 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
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
7 changes: 7 additions & 0 deletions
7
testy-core-box/src/main/java/fr/ght1pc9kc/testy/core/exceptions/RandomPortException.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,7 @@ | ||
package fr.ght1pc9kc.testy.core.exceptions; | ||
|
||
public class RandomPortException extends RuntimeException { | ||
public RandomPortException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
testy-core-box/src/main/java/fr/ght1pc9kc/testy/core/utils/PortUtils.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,24 @@ | ||
package fr.ght1pc9kc.testy.core.utils; | ||
|
||
import fr.ght1pc9kc.testy.core.exceptions.RandomPortException; | ||
import lombok.experimental.UtilityClass; | ||
|
||
import java.io.IOException; | ||
import java.net.ServerSocket; | ||
|
||
@UtilityClass | ||
public class PortUtils { | ||
/** | ||
* Find a free random port on the local machine | ||
* Use {@link ServerSocket}. | ||
* | ||
* @return the free port as integer | ||
*/ | ||
public static int randomFreePort() { | ||
try (ServerSocket socket = new ServerSocket(0)) { | ||
return socket.getLocalPort(); | ||
} catch (IOException e) { | ||
throw new RandomPortException("Unable to found a free port !", e); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
testy-core-box/src/test/java/fr/ght1pc9kc/testy/core/utils/PortUtilsTest.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,11 @@ | ||
package fr.ght1pc9kc.testy.core.utils; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class PortUtilsTest { | ||
@Test | ||
void should_find_free_port() { | ||
Assertions.assertThat(PortUtils.randomFreePort()).isPositive(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -17,4 +17,7 @@ public interface MongoDataSet<T> { | |
*/ | ||
List<T> documents(); | ||
|
||
default String identifier() { | ||
return "_id"; | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
testy-mongo-box/src/test/java/fr/ght1pc9kc/testy/mongo/sample/ClazzDataSet.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,20 @@ | ||
package fr.ght1pc9kc.testy.mongo.sample; | ||
|
||
import fr.ght1pc9kc.testy.dummy.Dummy; | ||
import fr.ght1pc9kc.testy.mongo.MongoDataSet; | ||
|
||
import java.util.List; | ||
|
||
public class ClazzDataSet implements MongoDataSet<Dummy> { | ||
@Override | ||
public List<Dummy> documents() { | ||
return List.of( | ||
new Dummy("Luke", "Skywalker"), | ||
new Dummy("Obiwan", "Kenobi")); | ||
} | ||
|
||
@Override | ||
public String identifier() { | ||
return "foo"; | ||
} | ||
} |
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,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>fr.ght1pc9kc</groupId> | ||
<artifactId>testy-box</artifactId> | ||
<version>1.7.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>testy-redis-box</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>fr.ght1pc9kc</groupId> | ||
<artifactId>testy-core-box</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.codemonstur</groupId> | ||
<artifactId>embedded-redis</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.lettuce</groupId> | ||
<artifactId>lettuce-core</artifactId> | ||
</dependency> | ||
|
||
<!-- PROVIDED--> | ||
<dependency> | ||
<groupId>org.jetbrains</groupId> | ||
<artifactId>annotations</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- TEST --> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
11 changes: 11 additions & 0 deletions
11
testy-redis-box/src/main/java/fr/ght1pc9kc/testy/redis/RedisPort.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,11 @@ | ||
package fr.ght1pc9kc.testy.redis; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.PARAMETER}) | ||
public @interface RedisPort { | ||
} |
Oops, something went wrong.