{"id":19154352,"url":"https://github.com/baloise/resteasy-test","last_synced_at":"2026-06-11T20:31:48.292Z","repository":{"id":70609636,"uuid":"138804110","full_name":"baloise/resteasy-test","owner":"baloise","description":"Test JAX-RS REST endpoints in JUnit without hassle","archived":false,"fork":false,"pushed_at":"2019-11-01T21:28:43.000Z","size":22,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T21:27:03.646Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baloise.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-26T23:22:02.000Z","updated_at":"2020-11-06T14:48:50.000Z","dependencies_parsed_at":"2023-03-24T03:33:02.667Z","dependency_job_id":null,"html_url":"https://github.com/baloise/resteasy-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/baloise/resteasy-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baloise%2Fresteasy-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baloise%2Fresteasy-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baloise%2Fresteasy-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baloise%2Fresteasy-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baloise","download_url":"https://codeload.github.com/baloise/resteasy-test/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baloise%2Fresteasy-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34217312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:26:33.479Z","updated_at":"2026-06-11T20:31:48.249Z","avatar_url":"https://github.com/baloise.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ResteasyTest\nResteasyTest provides a convenient way to test JAX-RS resources in your JUnit test. It allows you to define your REST endpoints in your tests classes and verify that the exposed resources work properly. ResteasyTest is similar to [JerseyTest](https://github.com/jersey/jersey/blob/master/test-framework/core/src/main/java/org/glassfish/jersey/test/JerseyTest.java) but uses [Resteasy](https://resteasy.github.io/) as provider and is not as feature rich. The dependencies used are the same as in JBoss EAP / WildFly. These are [undertow](http://undertow.io/) as ServletContainer, [Resteasy](https://resteasy.github.io/) as JAX-RS implementation and [jackson 2](https://github.com/FasterXML/jackson) for JSON support. \n\n# How does it work\nResteasyTest starts undertow using a free port on your system. In your JUnit test you define JAX-RS endpoints which are deployed to undertow. These endpoints can be tested with the methods `post()` and `get()` which use [ResteasyClient](https://docs.jboss.org/resteasy/docs/3.0-beta-3/userguide/html/RESTEasy_Client_Framework.html) to send the requests to the started undertow instance. \n\n# Setup dependencies\nBecause ResteasyTest isn't available as Maven dependency in the Maven Central Repository, you need to include it in your project yourself. If demanded, I will make the effort to upload it. \n\nTo get ResteasyTest running, you need to include the following Maven dependencies in your `\u003cdependencies\u003e\u003c/dependencies\u003e` section:\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.undertow\u003c/groupId\u003e\n    \u003cartifactId\u003eundertow-servlet\u003c/artifactId\u003e\n    \u003cversion\u003e${undertow.version}\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.undertow\u003c/groupId\u003e\n    \u003cartifactId\u003eundertow-core\u003c/artifactId\u003e\n    \u003cversion\u003e${undertow.version}\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e    \n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.jboss.resteasy\u003c/groupId\u003e\n    \u003cartifactId\u003eresteasy-undertow\u003c/artifactId\u003e\n    \u003cversion\u003e${resteasy.version}\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.jboss.resteasy\u003c/groupId\u003e\n    \u003cartifactId\u003eresteasy-jaxrs\u003c/artifactId\u003e\n    \u003cversion\u003e${resteasy.version}\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.jboss.resteasy\u003c/groupId\u003e\n    \u003cartifactId\u003eresteasy-jackson2-provider\u003c/artifactId\u003e\n    \u003cversion\u003e${resteasy.version}\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\nTo add JAXB annotation support, you might want to add these dependency too:\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.fasterxml.jackson.module\u003c/groupId\u003e\n    \u003cartifactId\u003ejackson-module-jaxb-annotations\u003c/artifactId\u003e\n    \u003cversion\u003e${jackson.version}\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\nFor `java.time` support, you need to this dependency, if the used Jackson version is below 2.8.5. This is the case for JBoss EAP 7.0 or WildFly 10. \n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.fasterxml.jackson.datatype\u003c/groupId\u003e\n    \u003cartifactId\u003ejackson-datatype-jsr310\u003c/artifactId\u003e\n    \u003cversion\u003e${jackson.version}\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\nIf your Jackson version is above 2.8.5 (like in JBoss EAP 7.1+), you need to use the [jackson-modules-java8](https://github.com/FasterXML/jackson-modules-java8). This isn't tested yet.\n\n### JBossEAP 7.0 / WildFly 10 dependency versions\nFor JBoss EAP 7.0 and WildFly 10 (upstream project) use the following dependency versions:\n```\n\u003cproperties\u003e\n    \u003cresteasy.version\u003e3.0.16.Final\u003c/resteasy.version\u003e\n    \u003cundertow.version\u003e1.3.21.Final\u003c/undertow.version\u003e\n    \u003cjackson.version\u003e2.6.3\u003c/jackson.version\u003e\n\u003c/properties\u003e\n```\nSo you use the same artifacts and versions as in your application server. \n\n### JBoss EAP 7.1 / WildFly 11 dependency versions\nFor JBoss EAP 7.1 and WildFly 11 (upstream project) use the these dependency versions. This setup isn't tested from me yet but should work. If you use additional Jackson modules, make sure these are compatible with these versions.\n```\n\u003cproperties\u003e\n    \u003cresteasy.version\u003e3.0.24.Final\u003c/resteasy.version\u003e\n    \u003cundertow.version\u003e1.3.25.Final\u003c/undertow.version\u003e\n    \u003cjackson.version\u003e2.8.9\u003c/jackson.version\u003e\n\u003c/properties\u003e\n```\n\n# Usage\nTo use ResteasyTest, you need to include [ResteasyTest.java](https://raw.githubusercontent.com/niiku/resteasy-test/master/src/main/java/io/nikio/jaxrs/ResteasyTest.java) in your maven module where you want to test a JAX-RS resource. \n\nTo test a JAX-RS endpoint, create a test class and inherit the now included `ResteasyTest.java` class. Override the method `configureResource()` to add an instance of your REST endpoint to ResteasyTest. \n```\npublic class RestEndpointTest extends ResteasyTest {\n    @Override\n    public List\u003cObject\u003e configureResources() {\n        return Stream.of(new RestEndpoint()).collect(Collectors.toList());\n    }\n}\n```\nTo declare a provider (eg. for custom field mappings) override `configureProvider()`.\n```\n@Override\npublic List\u003cObject\u003e configureProvider() {\n    return Stream.of(new ObjectMapperContextResolver()).collect(Collectors.toList());\n}\n```\n\nNow you can simply use `get()` and `post()` to test your endpoint:\n```\n@Test\npublic void testGetPojo() {\n    Pojo expectedPojo = new Pojo(\"Hello\");\n    Pojo actualPojo = get(\"/resource/pojo\", Pojo.class);\n    Assert.assertEquals(expectedPojo, actualPojo);\n}\n@Test\npublic void testPostPojo() {\n    Pojo world = new Pojo(\"World\");\n    Pojo response = post(\"/resource/post\", world, Pojo.class);\n    Assert.assertEquals(\"Hello World\", response.getName());\n}\n```\nTo get the result without deserialization, simply put `String.class` as last argument to `post()` or `get()`. You find complete examples in [ResteasyTestTest.java](https://github.com/niiku/resteasy-test/blob/master/src/test/java/io/nikio/jaxrs/ResteasyTestTest.java). \n\n\n# CDI Support\nResteasyTest doesn't support CDI directly. But you can use [cdi-unit](http://bryncooke.github.io/cdi-unit/) to inject a REST endpoint in your JUnit test and return it in the overriden `configureResources()` method. But for the most cases I would recommend using [mockito](http://site.mockito.org/) with its `MockitoJUnitRunner.class` to satisfy `@Inject` points. `cdi-unit` is slow because it's using [Weld](http://weld.cdi-spec.org/). I think the purpose should be to test your REST endpoints serialization/deserialization and URL only. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaloise%2Fresteasy-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaloise%2Fresteasy-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaloise%2Fresteasy-test/lists"}