Custom Matchers, Better Messages: JAX-RS Client Rulz v0.0.4 released 📎
The v0.0.4 release of the JUnit JAX-RS Rules 13kB JAR comes with additional matchers: clientError()
, redirection()
, informational()
and other()
, as well as, improved matcher messages, like e.g.
Expected: is 2xx family of successful responses
but: Internal Server Error 500 returned
Installation:
<dependency>
<groupId>com.airhacks.rulz</groupId>
<artifactId>jaxrsclient</artifactId>
<version>v0.0.4</version>
<scope>test</scope>
</dependency>
Sample usage:
import static com.airhacks.rulz.jaxrsclient.HttpMatchers.successful;
public class JAXRSClientProviderTest {
@Rule
public JAXRSClientProvider provider = JAXRSClientProvider.buildWithURI("http://adambien.blog");
@Test
public void pingJavaAndVerifyWithMatcher() {
Response response = (...)
assertThat(response, is(successful()));
}
Meet rulz at Java EE 7 Testing and Code Quality workshop at MUC airport.
Junit rules are also explained in the episode "JAX-RS Rules For JUnit" of the online Effective Java EE 7 workshop and episodes "AOP For JUnit - Writing Custom Rules" and "JAX-RS Test Rules" of the online version of Java EE Testing workshop.