Lightweight java HTTP-client for the shields.io service.
Full documentation is available on the shields4j.readthedocs.io
Add dependency
<dependency>
<groupId>org.touchbit.shields4j</groupId>
<artifactId>client</artifactId>
<version>${shields4j.version}</version>
</dependency>
If you need to get Shields4j versions that are not uploaded to maven central (snapshot/staging), add the Sonatype repository to your pom.xml
<repositories>
<repository>
<id>SonatypeNexus</id>
<url>https://oss.sonatype.org/content/groups/staging/</url>
</repository>
</repositories>
class Example {
public static void main (String[] arg) {
new ShieldsIO()
.withLabel("Shields4J")
.withMessage("1.0")
.writeShieldToFile("minimal.svg");
}
}
With logo and color background
class Example {
public static void main (String[] arg) {
new ShieldsIO()
.withLabel("Shields4J")
.withLabelColor(Color.BLUE)
.withMessage("with Raspberry PI logo")
.withMessageColor(Color.GREEN)
.withStyle(Style.POPOUT)
.withLogo(Logo.RASPBERRY_PI)
.withLogoColor(Color.RED)
.withLogoWidth(30)
.writeShieldToFile("with-logo.svg");
}
}
With custom logo and color background
class Example {
public static void main (String[] arg) {
new ShieldsIO()
.withLabel("Shields4J")
.withLabelColor(Color.BLUE)
.withMessage("with custom logo")
.withMessageColor(Color.GREEN)
.withStyle(Style.POPOUT)
.withBase64Logo(new File("docs/img/status_success.svg"))
.writeShieldToFile("with-custom-logo.svg");
}
}
Add dependency
<dependency>
<groupId>org.touchbit.shields4j</groupId>
<artifactId>testng</artifactId>
<version>${shields4j.version}</version>
</dependency>
Add IShieldsListener to testNG
class Example {
public static void main (String[] arg) {
TestNG testNG = new TestNG();
testNG.addListener(new IShieldsListener());
}
}
or add IShieldsListener in your testng.xml file
<suite>
<listeners>
<listener class-name="org.touchbit.shields4j.testng.IShieldsListener" />
</listeners>
</suite>
To customize the prefixes, create your own listener inherited from IShieldsListener
public class ShieldsListener extends IShieldsListener {
public ShieldsListener() {
withLabelPefix("Integration test");
withFilePefix("testng");
}
}