io.github.binout:jaxrs-unit-resteasy

A library for unit testing of JAX-RS application

License

License

Categories

Categories

RESTEasy Program Interface REST Frameworks
GroupId

GroupId

io.github.binout
ArtifactId

ArtifactId

jaxrs-unit-resteasy
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

A library for unit testing of JAX-RS application

Download jaxrs-unit-resteasy

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.binout/jaxrs-unit-resteasy/ -->
<dependency>
    <groupId>io.github.binout</groupId>
    <artifactId>jaxrs-unit-resteasy</artifactId>
    <version>1.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.binout/jaxrs-unit-resteasy/
implementation 'io.github.binout:jaxrs-unit-resteasy:1.1.1'
// https://jarcasting.com/artifacts/io.github.binout/jaxrs-unit-resteasy/
implementation ("io.github.binout:jaxrs-unit-resteasy:1.1.1")
'io.github.binout:jaxrs-unit-resteasy:jar:1.1.1'
<dependency org="io.github.binout" name="jaxrs-unit-resteasy" rev="1.1.1">
  <artifact name="jaxrs-unit-resteasy" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.binout', module='jaxrs-unit-resteasy', version='1.1.1')
)
libraryDependencies += "io.github.binout" % "jaxrs-unit-resteasy" % "1.1.1"
[io.github.binout/jaxrs-unit-resteasy "1.1.1"]

Dependencies

compile (3)

Group / Artifact Type Version
io.github.binout : jaxrs-unit-api jar 1.1.1
org.jboss.resteasy : resteasy-jaxrs jar 2.3.5.Final
org.jboss.resteasy : resteasy-jackson-provider jar 2.3.5.Final

test (1)

Group / Artifact Type Version
io.github.binout : jaxrs-unit-tck jar 1.1.1

Project Modules

There are no modules declared in this project.

jaxrs-unit

A library for unit testing of JAX-RS application.

Description

The goal is to write unit tests without a real JavaEE server. But tests use real JAX-RS implementation (Jersey or RestEasy) with in-memory containers.

JaxRS Unit provides an API to encapsulate the specific im-memory containers.

Build status

Build Status

Environment

  • java-1.8

Build

mvn clean verify

Usage

Maven

You have to add api dependency :

<dependency>
    <groupId>io.github.binout</groupId>
    <artifactId>jaxrs-unit-api</artifactId>
    <version>${version}</version>
    <scope>test</scope>
</dependency>

You have to choose an implementation :

  • RestEasy

<dependency>
    <groupId>io.github.binout</groupId>
    <artifactId>jaxrs-unit-resteasy</artifactId>
    <version>${version}</version>
    <scope>test</scope>
</dependency>
  • Jersey

<dependency>
    <groupId>io.github.binout</groupId>
    <artifactId>jaxrs-unit-jersey</artifactId>
    <version>${version}</version>
    <scope>test</scope>
</dependency>

Hello World

Considering a JAX-RS resource :

@Path("/hello")
public class HelloResource {
    @GET
    public String hello() {
        return "hello";
    }
}

You can write a unit test like this :

public class HelloTest {
    private JaxrsServer server;

    @Before
    public void init() {
        server = JaxrsUnit.newServer(HelloResource.class);
    }

    @Test
    public void should_return_hello() {
        JaxrsResource resource = server.resource("/hello");

        JaxrsResponse response = resource.get();

        assertThat(response.ok()).isTrue();
        assertThat(response.content()).isEqualTo("hello");
    }
}

TODO

  • resource injection

Versions

Version
1.1.1
1.1.0