{"id":20877443,"url":"https://github.com/t1/jee-testcontainers","last_synced_at":"2025-05-12T16:30:36.851Z","repository":{"id":37883628,"uuid":"225565123","full_name":"t1/jee-testcontainers","owner":"t1","description":"testcontainers.org for Jakarta EE application servers","archived":false,"fork":false,"pushed_at":"2025-04-11T22:48:20.000Z","size":240,"stargazers_count":2,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"trunk","last_synced_at":"2025-04-11T23:34:06.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t1.png","metadata":{"files":{"readme":"README.adoc","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":"2019-12-03T08:11:32.000Z","updated_at":"2025-04-11T22:48:22.000Z","dependencies_parsed_at":"2023-12-23T04:20:54.848Z","dependency_job_id":"4bba431e-658e-4d00-9631-13ee416661fa","html_url":"https://github.com/t1/jee-testcontainers","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1%2Fjee-testcontainers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1%2Fjee-testcontainers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1%2Fjee-testcontainers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1%2Fjee-testcontainers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t1","download_url":"https://codeload.github.com/t1/jee-testcontainers/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253776657,"owners_count":21962521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-18T06:57:02.747Z","updated_at":"2025-05-12T16:30:36.835Z","avatar_url":"https://github.com/t1.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= JEE Testcontainers image:https://maven-badges.herokuapp.com/maven-central/com.github.t1/jee-testcontainers/badge.svg[link=https://search.maven.org/artifact/com.github.t1/jee-testcontainers] image:https://github.com/t1/jee-testcontainers/actions/workflows/maven.yml/badge.svg[link=https://github.com/t1/jee-testcontainers/actions/workflows/maven.yml]\n\nSimply start and stop Jakarta EE containers and deploy applications for your integration tests.\nThis is an extension to https://testcontainers.org[Testcontainers] for Jakarta EE application servers, so Docker is used under the hood, but you don't need to write, e.g., a Dockerfile.\n\nPrototypical Example:\n\n[source,java]\n---------------------------------------------------------------\n@Testcontainers\npublic class MyAppIT {\n    @Container static JeeContainer CONTAINER = JeeContainer.create()\n        .withDeployment(\"target/my-app.war\");\n\n    @Test void shouldGetStatusResponse() {\n        String body = CONTAINER.target().request(APPLICATION_JSON_TYPE).get(String.class);\n\n        then(body).isEqualTo(\"{\\\"status\\\":\\\"okay\\\"}\");\n    }\n}\n---------------------------------------------------------------\n\nOr if you have an implementation of Microprofile Rest Client on your test classpath:\n\n[source,java]\n---------------------------------------------------------------\n@Testcontainers\npublic class MyAppIT {\n    @Container static JeeContainer CONTAINER = JeeContainer.create()\n        .withDeployment(\"target/my-app.war\");\n\n    @Data public static class Status {\n        String condition;\n    }\n\n    public interface StatusApi {\n        @GET Status getStatus();\n    }\n\n    @Test void shouldGetStatusResponse() {\n        StatusApi body = CONTAINER.restClient(StatusApi.class);\n\n        Status status = body.getStatus();\n\n        then(status.getCondition()).isEqualTo(\"okay\");\n    }\n}\n---------------------------------------------------------------\n\nThe console output of the container is piped to the test's output, STDOUT in green and STDERR in blue.\n\n== Deployments\n\nAs seen in the prototypical example above, you can install an application by calling `.withDeployment(\u003cfile\u003e)`.\n\nInstead of a local file, you can also install from an URL.\n\nOr you can use a maven URN like `urn:mvn:org.jolokia:jolokia-war-unsecured:1.6.3:war`.\n\nFinally, you can also build your deployment manually, by adding the classes and other files you want included.\nFor some details, see below.\n\n== Container Image\n\nSet the system property `jee-testcontainer` to one of the keys in the following table to select the corresponding container.\nIdeally you shouldn't have to care about what server your application runs on, or you may even want to test it in multiple containers.\nThen you can run your test suite in your CI pipeline with different system properties.\n\nYou can append a tag to the `jee-testcontainer` separated by a colon `:`.\nThis is often simply the version of the container; e.g. `wildfly:27.0.0.Final`.\n\n[options=\"header\",cols=\"15%,15%,40%,30%\"]\n|=======================\n| Key | Container | Docker Image | Notes\n| `wildfly` | https://wildfly.org[WildFly] | https://quay.io/repository/wildfly/wildfly[`wildfly/wildfly`] | default container on https://quay.io[`quay.io`]\n| `open-liberty` | https://openliberty.io[Open Liberty] | https://hub.docker.com/_/open-liberty[`open-liberty`] | we add `server.xml` with features `javaee-10.0` and `microProfile-5.0`\n| `tomee` | https://tomee.apache.org[TomEE] | https://hub.docker.com/_/tomee[`tomee`] | Official image\n| `payara` | https://www.payara.fish[Payara] | https://hub.docker.com/r/payara/server-full[`payara`] | not an 'official' image on Docker-Hub\n// TODO support | `glassfish` | https://javaee.github.io/glassfish/[Glassfish] | https://hub.docker.com/_/glassfish[`glassfish`] | deprecated image!\n|=======================\n\n== Reuse\n\nYou can reuse a running container instance for all tests as long as the config doesn't change, by calling `withReuse(true)`.\nThis feature is marked as unstable from testcontainers.org.\nYou can achieve the same by setting the system property `testcontainer-reuse` to `true`, which comes in handy when you need it only for certain launch configurations, i.e. local or on CI.\n\n== Ports\n\nBy default, the main port exposed by the container (which accidentally is 8080 in all currently supported JEE servers) is published/bound to a random free port.\nYou can bind it to a fixed port by calling `JeeContainer#withMainPortBoundToFixedPort(int hostPort)`.\nOr you can set the `testcontainer-with-main-port-bound-to-fixed-port` system property for the same effect.\n\nSimilarly, you can publish any port by calling `JeeContainer#withPortBoundToFixedPort(int hostPort, int containerPort)`.\n\nFixing port numbers may be convenient in some cases, but you shouldn't do this without a good reason.\n\n== Modifications\n\nYou can modify the deployable in two ways.\nYou can have multiple and repeated modification to, e.g., rename the file and add multiple libraries.\n\n=== Rename\n\n[source,java]\n---------------------------------------------------------------\nimport static com.github.t1.testcontainers.jee.NamedAsMod.namedAs;\n\n@Testcontainers\npublic class MyAppIT {\n    @Container static JeeContainer CONTAINER = JeeContainer.create()\n        .withDeployment(\"target/my-app.war\", namedAs(\"foo.war\"));\n}\n---------------------------------------------------------------\n\n=== Add Library\n\n[source,java]\n---------------------------------------------------------------\nimport static com.github.t1.testcontainers.jee.AddLibMod.addLib;\n\n@Testcontainers\npublic class MyAppIT {\n    @Container static JeeContainer CONTAINER = JeeContainer.create()\n        .withDeployment(\"target/my-app.war\", addLib(\"urn:mvn:org.jolokia:jolokia-war-unsecured:1.6.3:war\"));\n}\n---------------------------------------------------------------\n\n=== Add Config\n\n[source,java]\n---------------------------------------------------------------\nimport static com.github.t1.testcontainers.jee.ConfigMod.config;\n\n@Testcontainers\npublic class MyAppIT {\n    @Container static JeeContainer CONTAINER = JeeContainer.create()\n        .withDeployment(\"target/my-app.war\", config(\"foo\", \"bar\"));\n}\n---------------------------------------------------------------\n\nConfigure the https://microprofile.io/project/eclipse/microprofile-config[MP Config] key `foo` to be `bar`.\nCreates or appends to `WEB-INF/classes/META-INF/microprofile-config.properties`.\n\n== Container Configuration\n\nYou can configure the log level of a logger, e.g. by calling `withLogLevel`\n(at the moment, this only works for WildFly containers, but we're open for PRs 😀).\n\nYou can also configure a data source by calling `withDataSource(DB)`, where `DB` is a `JdbcDatabaseContainer` (currently only `PostgreSQLContainer` and only on `WildFly`).\n\nFor `WildFly`, you can also call arbitrary `CLI` commands by calling `withCli`.\n\nApart from that, you can't currently configure anything else for your application, e.g. add message queues.\nI will add such things whenever I need it, but again: PRs are welcome.\n\n// TODO health wait strategy\n// TODO configure message queues, etc.\n\n== Building A Test Deployable\n\nThere's a very limited support to build a `war` deployable from scratch.\nSee the API of the https://github.com/t1/jee-testcontainers/blob/trunk/src/main/java/com/github/t1/testcontainers/tools/DeployableBuilder.java[DeployableBuilder] class for details.\nIf you need more, maybe https://github.com/shrinkwrap/shrinkwrap[ShrinkWrap] can help, but I haven't tried that in combination, yet.\n\n== Breaking Changes (Major Versions)\n\n=== 3.0.0\n\n* Drop support for Java 11, because JEE 11 and the libraries used for JEE 11 (e.g. Smallrye Config) require Java 17.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft1%2Fjee-testcontainers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft1%2Fjee-testcontainers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft1%2Fjee-testcontainers/lists"}