{"id":17997310,"url":"https://github.com/thma/fmek","last_synced_at":"2025-03-26T04:31:16.205Z","repository":{"id":44882566,"uuid":"42583894","full_name":"thma/fmek","owner":"thma","description":"Emulating a jee 7 container with SpringBoot.","archived":false,"fork":false,"pushed_at":"2024-10-25T11:31:54.000Z","size":97,"stargazers_count":3,"open_issues_count":7,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T22:40:11.341Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thma.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":"2015-09-16T11:47:40.000Z","updated_at":"2024-08-13T08:51:18.000Z","dependencies_parsed_at":"2024-10-25T14:27:51.149Z","dependency_job_id":"f13ad14f-4454-4891-8713-78f4168b8807","html_url":"https://github.com/thma/fmek","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thma%2Ffmek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thma%2Ffmek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thma%2Ffmek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thma%2Ffmek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thma","download_url":"https://codeload.github.com/thma/fmek/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245589254,"owners_count":20640251,"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-10-29T21:17:40.396Z","updated_at":"2025-03-26T04:31:15.500Z","avatar_url":"https://github.com/thma.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/thma/fmek.svg)](https://travis-ci.org/thma/fmek)\n# fmek\n\nEmulating a JEE 7 container with SpringBoot.\nHighlights:\n-  unit testing of JEE components \n-  Providing a lightweight JEE 7 runtime container based on SpringBoot  \n-  Developing Spring application with minimal code dependencies on Spring\n\n\u003e \"The Fmeks are a diminutive sapient species native to the planet Fmoo, they are the sworn enemies of the Arquillians.\"  \n-- [aliens.wikia]\n\n\n## Supported Features:\n\n- JSR-330 'javax.inject.Inject' CDI Annotations\n- JSR-299/318 'javax.interceptor.Interceptor' CDI Annotations (based on a patched version of springcdi https://github.com/nschlimm/spring-interceptor)\n- JTA\n- JPA\n- JMS\n- Message Driven Beans\n- JAX-RS\n- Servlets\n\n## Not supported (and not planning to do so...):\n\n- EJB Session Beans\n\n## Use cases\n-  **unit testing of JEE components**  \n    Unit testing JEE components can be quite a hazzle if you want to test across different software layers (without using mocks) or if you want to test container provided features like JTA transactions including two phase commit synchronizing different XA resources.  \n\n    Typical solutions use specialized Junit Testrunners like CDI-Unit CdiRunner or the DeltaSpike CdiTestRunner which provide a Weld CDI container for unit tests. This is great for testing CDI dependency injection. But integrating JAX-RS or JTA with this approach is far from trivial.  \n    \n    The classical fullblown approach is to use tools like Arquillian which provide the complete JEE infrastructure to your junit tests. The downside with Arquillian is that the assembly of the container can be quite complex and tends to slow down the execution of the junit tests.  \n    \n    The **fmek** approach is simple: just provide all required JEE dependencies of your application by a SpringBoot Maven POM. The Junit test will be executed by the SpringJUnit4ClassRunner which sets up the Spring container serving all required components:\n\n```java\n@RunWith(SpringJUnit4ClassRunner.class)\n@ContextConfiguration(classes = {HelloWorldRestApplication.class, \n                                 EmulateJeeContainerConfiguration.class})\npublic class GreetingTests {\n\n  @Inject\n  private CountService countService;\n\n  @Inject\n  private GreetingCrudService greetingCrudService;\n\n  @Inject\n  private GreetingPostingService postingService;\n\n  private static final String template = \"Hello, %s!\";\n\n  @Test\n  @Transactional\n  public void testGreetings() throws JMSException {\n    createAndSaveAGreeting();\n    createAndSaveAGreeting();\n    createAndSaveAGreeting();\n\n    Greeting g = greetingCrudService.getGreeting(1);\n    assertNotNull(g);\n    assertEquals(1, g.getId());\n    assertEquals(\"Hello, user-1!\", g.getContent());\n\n    List\u003cGreeting\u003e allGreetings =  greetingCrudService.getAllGreetings();\n    assertEquals(3, allGreetings.size());\n  }\n\n  private void createAndSaveAGreeting() throws JMSException {\n    long id = countService.incrementAndGet();\n    Greeting greeting = new Greeting(id, String.format(template, \"user-\" + id));\n    greetingCrudService.store(greeting);\n    postingService.sendGreeting(greeting);\n  }\n\n}  \n```\n    \n-  **Providing a lightweight JEE 7 runtime container based on SpringBoot**  \n    Of course a Spring container is not only useful in a testing environment but can also be used as a full-fledged deployment and runtime environment for production.\n\n    All you need is a main class that is annotated as \u003ccode\u003e@SpringBootApplication\u003c/code\u003e that starts up the Spring container by calling \u003ccode\u003eSpringApplication.run\u003c/code\u003e:\n```java\n@SpringBootApplication\npublic class HelloWorldRestApplication extends ResourceConfig {\n\n    public HelloWorldRestApplication() {\n      register(RequestContextFilter.class);\n      register(HelloWorldResource.class);\n    }\n\n  public static void main(String[] args) {\n    Object[] contextClasses = {HelloWorldRestApplication.class, EmulateJeeContainerConfiguration.class};\n    SpringApplication.run(contextClasses, args);\n  }\n}\n\n```\n\nBy calling \u003ccode\u003emvn install\u003c/code\u003e this main class and all its dependencies are assembled to an executable jar. Thus no application deployment is needed.   \n    \nYou can even add extended support for application monitoring and managing by adding a dependency to Spring Boot Actuator in your POM File:\n    \n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n        \u003cartifactId\u003espring-boot-starter-actuator\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n\n-  **Developing Spring application with minimal code dependencies on Spring**  \n    If you don't intend to deploy your application to a JEE container it still makes sense to minimize explicit Spring dependencies in your code. As an example have a look at the following service class which exclusively uses JEE standard APIs can be completely managed by Spring:\n```java\npackage org.fmek.example.services;\n\nimport org.fmek.example.domain.Greeting;\nimport org.fmek.example.interceptors.Log;\nimport javax.inject.Inject;\nimport javax.inject.Named;\nimport javax.persistence.EntityManager;\nimport javax.persistence.TypedQuery;\nimport javax.transaction.Transactional;\nimport java.util.List;\n\n@Named\n@Transactional\n@Log\npublic class GreetingCrudService {\n\n  @Inject\n  private EntityManager entityManager;\n\n  public void store(Greeting g) {\n    entityManager.merge(g);\n  }\n\n  public List\u003cGreeting\u003e getAllGreetings() {\n    TypedQuery\u003cGreeting\u003e q = entityManager.createQuery(\"SELECT g FROM Greeting g\", Greeting.class);\n    return q.getResultList();\n  }\n\n  public Greeting getGreeting(long id) {\n    return entityManager.find(Greeting.class, id);\n  }\n}\n```\n\n## Docs:\nhttp://thma.github.io/fmek/\n\n[aliens.wikia]: http://aliens.wikia.com/wiki/Fmek\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthma%2Ffmek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthma%2Ffmek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthma%2Ffmek/lists"}