https://github.com/librudder/rudder
https://github.com/librudder/rudder
containers containers-java docker gradle java maven test testing tools
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/librudder/rudder
- Owner: librudder
- License: mit
- Created: 2020-02-25T18:56:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-18T16:48:41.000Z (about 2 years ago)
- Last Synced: 2024-04-18T18:22:36.822Z (about 2 years ago)
- Topics: containers, containers-java, docker, gradle, java, maven, test, testing, tools
- Language: Java
- Size: 226 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 85
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
////
DO NOT EDIT THIS FILE. IT WAS GENERATED.
Manual changes to this file will be lost when it is generated again.
Edit the files in the src/main/asciidoc/ directory instead.
////
= rudder
//.*Project health*
image:https://img.shields.io/lgtm/grade/java/g/librudder/rudder.svg?logo=lgtm&logoWidth=18["Language grade: Java", link="https://lgtm.com/projects/g/librudder/rudder/context:java"]
image:https://circleci.com/gh/librudder/rudder.svg?style=svg["CircleCI", link="https://circleci.com/gh/librudder/rudder"]
image:https://codecov.io/gh/librudder/rudder/branch/master/graph/badge.svg["CodeCov", link="https://codecov.io/gh/librudder/rudder"]
image:https://img.shields.io/maven-central/v/com.github.librudder/rudder?color=green["Maven Central", link="http://search.maven.org/#artifactdetails%7Ccom.github.librudder%7Crudder"]
This project provides ability to run pieces of Java code inside 🐳Docker
container and access objects like they're outside.
== Installation
:numbered!:
=== Maven
Add this to your pom.xml:
[source,xml,subs="attributes+"]
----
com.github.librudder
rudder
{artifact-version}
----
=== Gradle
Add this to your build.gradle:
[source,groovy,subs="attributes+"]
----
implementation 'com.github.librudder:rudder:{artifact-version}'
----
== Usage
Inherit from application you want to test. This application must have
`public static void main` method and must implement
`RudderApplication` where T is application class. Also
there must be a static `setReadyCallback(Consumer)`
Example class to test:
[source,java]
----
import java.util.function.Consumer;
class TestApplication {
public static void main(String[] args){
}
public String getCurrentHostname() {
return System.getenv("HOSTNAME");
}
}
class TestRudderApplication implements RudderApplication {
private static Consumer callback;
public static void setReadyCallback(final Consumer callback) {
TestRudderApplication.callback = callback;
}
public static void main(String[] args){
TestApplication.main(args);
callback.apply(new TestRudderApplicatiion());
}
}
----
And our test starter:
[source, java]
----
class Tester {
public static void main(String[] args){
Class> clazz = TestApplication.class;
ContaineredApplication container = new ContaineredApplication<>("adoptopenjdk/openjdk11:x86_64-ubuntu-jdk-11.28", clazz, List.of("raz", "dva"));
container.start();
final TestApplication application = container.getApplication();
System.out.println(application.getCurrentHostname());
}
}
----
This example will print the `HOSTNAME` environment variable defined inside the container (usually it's container ID).
For more real life example check link:spring_example.html[Spring example].
== Building
Just run
[source,sh,subs="attributes+"]
----
./mvnw clean install
----
in the root project directory
== Contributing