Shields4j
![Coverage](https://camo.githubusercontent.com/7ba9a10e2706ad1574ba52e8314f5fe474acd3c0a51fbea4bcbfecf779ebe61f/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6f72672e746f7563686269742e736869656c6473346a253341736869656c6473346a2d706172656e74266d65747269633d636f76657261676526626c696e6b696e673d74727565)
Lightweight java HTTP-client for the shields.io service.
Full documentation is available on the shields4j.readthedocs.io
Briefly
Java client
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");
}
}
TestNG listener
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");
}
}