{"id":37027103,"url":"https://github.com/codegeny/jakartron","last_synced_at":"2026-01-14T03:12:26.230Z","repository":{"id":43112889,"uuid":"267864068","full_name":"codegeny/jakartron","owner":"codegeny","description":"Bootstrap your Jakarta EE application/tests with annotations","archived":false,"fork":false,"pushed_at":"2023-09-18T14:26:36.000Z","size":802,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-04T07:51:44.959Z","etag":null,"topics":["java"],"latest_commit_sha":null,"homepage":"","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/codegeny.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}},"created_at":"2020-05-29T13:25:32.000Z","updated_at":"2024-07-17T14:26:42.000Z","dependencies_parsed_at":"2023-02-10T14:01:35.700Z","dependency_job_id":null,"html_url":"https://github.com/codegeny/jakartron","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codegeny/jakartron","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codegeny%2Fjakartron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codegeny%2Fjakartron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codegeny%2Fjakartron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codegeny%2Fjakartron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codegeny","download_url":"https://codeload.github.com/codegeny/jakartron/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codegeny%2Fjakartron/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"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":["java"],"created_at":"2026-01-14T03:12:25.562Z","updated_at":"2026-01-14T03:12:26.224Z","avatar_url":"https://github.com/codegeny.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Java CI](https://github.com/codegeny/jakartron/actions/workflows/build.yaml/badge.svg)](https://github.com/codegeny/jakartron/actions/workflows/build.yaml)\n\n# Jakartron\n\nJakartron is a small library built on top of CDI-SE and heavily inspired by CDI-Unit.\nIts primary use is for testing applications targeting the Jakarta EE platform.\n\nThis library could be used to launch standalone applications à la Spring-Boot but the\nmaturity is not there yet as many shortcuts have been made that are good enough for\ntesting but certainly not for production-grade applications.\n\nJakartron is split in multiple modules which represent sub-specifications of the Jakarta EE specification.\n\nIn your `pom.xml`, import the module you need in your application:\n```xml\n\u003cdependencyManagement\u003e\n    \u003cdependencies\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003eorg.codegeny.jakartron\u003c/groupId\u003e\n            \u003cartifactId\u003ejakartron-bom\u003c/artifactId\u003e\n            \u003cversion\u003e0.0.1\u003c/version\u003e\n            \u003ctype\u003epom\u003c/type\u003e\n            \u003cscope\u003eimport\u003c/scope\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n\u003c/dependencyManagement\u003e\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ejakarta.platform\u003c/groupId\u003e\n        \u003cartifactId\u003ejakarta.jakartaee-api\u003c/artifactId\u003e\n        \u003cversion\u003e8.0.0\u003c/version\u003e\n        \u003cscope\u003eprovided\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.codegeny.jakartron\u003c/groupId\u003e\n        \u003cartifactId\u003ejakartron-jpa\u003c/artifactId\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.codegeny.jakartron\u003c/groupId\u003e\n        \u003cartifactId\u003ejakartron-junit\u003c/artifactId\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\nIn your test:\n```java\n@ExtendWithJakartron\n@DataSourceDefinition(name = \"mydb\", className = \"org.h2.jdbcx.JdbcDataSource\", minPoolSize = 5, maxPoolSize = 25, url = \"jdbc:h2:mem:mydb\")\n@PersistenceUnitDefinition(unitName = \"tests\", nonJtaDataSourceName = \"mydb\", transactionType = RESOURCE_LOCAL, managedClasses = JPADBTest.President.class, properties = {\n        @Property(name = \"javax.persistence.schema-generation.database.action\", value = \"create\")\n})\npublic class JPATest {\n\n    @Entity(name = \"President\")\n    @NamedQuery(name = \"countPresidents\", query = \"select count(p) from President p\")\n    public static class President {\n\n        @Id\n        @GeneratedValue\n        private Long id;\n\n        President() {}\n\n        public President(String name) {\n            this.name = name;\n        }\n\n        private String name;\n\n        public String getName() {\n            return name;\n        }\n    }\n\n    @PersistenceContext(unitName = \"tests\", type = PersistenceContextType.EXTENDED)\n    private EntityManager entityManager;\n\n    @Test\n    public void test() {\n        entityManager.getTransaction().begin();\n        entityManager.persist(new President(\"G. Washington\"));\n        entityManager.persist(new President(\"A. Lincoln\"));\n        entityManager.getTransaction().commit();\n\n        entityManager.clear();\n\n        entityManager.getTransaction().begin();\n        Assertions.assertEquals(2, entityManager.createNamedQuery(\"countPresidents\", Number.class).getSingleResult().intValue());\n        entityManager.getTransaction().rollback();\n    }\n}\n```\n\n## Annotations\n\nJakartron annotations follow closely the semantics of the initializing methods present on the `SeContainerInitializer` class from CDI-SE and must be put on your bootstrap class (or test class).\n\n`@AdditionalClasses` allows adding beans/interceptors/decorators/extensions classes that are not automatically discovered (either because `bean-discovery-mode=\"none\"` is used or `@DisableDiscovery` is present).\n\n`@AdditionalPackages` allows adding whole package (recursively or not).\n\n`@EnabledAlternatives` allows enabling CDI alternatives.\n\n`@DisableDiscovery` allows disabling the whole discovery process.\n\n### Meta-annotations\n\nAll Jakartron annotations can be used as meta-annotations to group common features.\n\nInstead of doing this:\n```java\n@AdditionalClasses({Foo.class, Bar.class, FooBar.class})\n@EnabledAlternatives(Baz.class)\npublic class MyFirstTest {}\n\n@AdditionalClasses({Foo.class, Bar.class, FooBar.class})\n@EnabledAlternatives(Baz.class)\npublic class MySecondTest {}\n```\nPrefer creating a meta-annotation like this:\n```java\n@AdditionalClasses({Foo.class, Bar.class, FooBar.class})\n@EnabledAlternatives(Baz.class)\n@Retention(RetentionPolicy.RUNTIME)\npublic @interface EnableFoo {}\n\n@EnableFoo\npublic class MyFirstTest {}\n\n@EnableFoo\npublic class MySecondTest {}\n```\nJakartron itselfs uses that feature for its `@EnableJPA`, `@EnableJTA`, `@EnableJMS`... annotations.\n\n\n## Auto-discovery\n\nJakartron modules are CDI extensions which are automatically discovered at runtime.\n\nIf your tests contains CDI alternatives or other beans, they may conflict or create ambiguity with the CDI beans present in your application.\nTherefore, it is recommended (unless you know what you do) to disable auto-discovery in your test classpath by setting `bean-discovery-mode=\"none\"` in your test `META-INF/beans.xml`:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cbeans xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"2.0\" bean-discovery-mode=\"none\"\n       xmlns=\"http://xmlns.jcp.org/xml/ns/javaee\"\n       xsi:schemaLocation=\"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd\"/\u003e\n```\n\nPutting this file in your test resources won't prevent CDI beans from being discovered in your main java folder.\n\nIt is also possible to **completely** disable auto-discovery by annotating your test class with `@DisableDiscovery`.\nIf you do that, you will need to manually add each bean with `@AdditionalClasses` and enable the needed Jakartron modules.\n\n## Modules\n\n### Core\n\nThe core module contains the Jakartron annotations and the logic to initialize CDI by scanning those annotations from the test/main class.\n\nThis module depends on Weld.\n\n### JUnit 5\n\nUse `@ExtendWithJakartron` on your test class (or a meta-annotation) to register the Jakartron JUnit 5 extension.\n\nThis extension will make sure your test class annotations are scanned and added to the CDI application definition.\nThis extension allows parameter injection in your JUnit test methods.\n\nCDI interceptors can also be applied to test methods.\n\nThis module depends on JUnit 5.\n\n### JTA\n\nTODO\n\nThis module depends on Narayana JTA Transaction Manager.\n\n### JPA\n\nTODO\n\nThis module depends on Hibernate ORM.\n\n### JMS\n\nTODO\n\nThis module depends on ActiveMQ Artemis.\n\n### EJB\n\nTODO\n\nMost of EJB features have been re-implemented using CDI constructs.\n\n### Servlet\n\nTODO\n\nThis module depends on Jetty.\n\n### JAX-RS\n\nTODO\n\nThis module depends on RESTEasy.\n\n### Validation\n\nTODO\n\nThis module depends on Hibernate Validator.\n\n### JSF\n\nTODO\n\nThis module depends on the JSF Reference Implementation.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodegeny%2Fjakartron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodegeny%2Fjakartron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodegeny%2Fjakartron/lists"}