Broken Links Matchers
NoBrokenLinks is a Hamcrest matchers that checks your XML/HTML document and catches links that point to incorrect locations, for example:
import com.jcabi.matchers.NoBrokenLinks;
import org.hamcrest.MatcherAssert;
public class FooTest {
@Test
public void htmlHasNoBrokenLinks() {
MatcherAssert.assertThat(
"<html><a href='not-found.html'>hey</a></html>",
new NoBrokenLinks()
);
}
}
These dependencies you will need in your pom.xml:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-http</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.18.1</version>
<scope>test</scope>
</dependency>