* History of GlassFish tests and testing applications using GlassFish as a platform.
* Options for testing Jakarta EE based applications
* Example: Using TestContainers with Eclipse GlassFish to test a simple web application.
Server 8 Java EE was born, standardization. Extremely buggy version Unfinished prototyping 2009 Sun GlassFish Enterprise Server 2.1.1.2 Production ready again 1997 Netscape iPlanet 2003 SunOne 7 Quite reliable, WebArchive (war), Single UI manages several instances. Enterprise solution, commercial Java version required. 2011 Oracle GlassFish 3.1 Java EE 6 Users started losing patience 2017 Oracle GlassFish 5.0 Java EE 8 Very buggy
GlassFish 6 Jakarta EE train gains speed Remaining community evaluates 2022 Eclipse GlassFish 7 Production ready again Jakarta EE 10 Java 11-23 supported (17 rec.) Stable development Bugfixes Improvements Refactoring Commercial support Community is slowly growing 2017 Oracle donated GlassFish Why? To be able to validate JEE Specifications 2019 Eclipse GlassFish 5.1 Same as Oracle GlassFish 5.0, but under Eclipse Foundation 2025 Eclipse GlassFish 8 Jakarta EE 11 Java 21+ supported Already releasing milestones To Be Continued …
EE Platform making things easier … but without any support for automated tests … making things pretty uneasy • Ejb3Unit (died too soon, supported just simple features) • EasyMock, Mockito (but mocks were so complicated!) • Integration Tests (but the server was always still running!) • GlassFish used around 65000 integration tests: usually small war application testing single scenario ◦ How long could it run in 2005???
Jakarta EE Platform making things easier • We have much better support many people don’t know • JUnit5, EasyMock, Mockito, Weld-Junit, HK2 based tests, TestContainers, GlassFish Test Utilities, JMH, Selenium, Embedded GlassFish … and their combinations!!! • Integration Tests ◦ GlassFish still uses around 65000 integration tests ◦ Execution take some 8 hours ◦ Can run them locally
- reset Defines actions for test classes and methods Uses environment Can be combined 3 Global Environment System dependencies, file system, ports, network interfaces, cpu, memory, … resources. 4 Test Method Send Input to the application, verify results @BeforeEach, @AfterEach, 1 Test Class Defines some unit @BeforeAll, @AfterAll 2
weld = WeldInitiator.of(Foo.class); @Test public void testFoo() { // Note that Weld container is started automatically // WeldInitiator can be used to perform programmatic lookup of beans assertEquals("baz", weld.select(Foo.class).get().getBaz()); // WeldInitiator can be used to fire a CDI event weld.event().select(Baz.class).fire(new Baz()); } } 9
Docker Image • Supported platforms: amd64 and arm64 • Id: ghcr.io/eclipse-ee4j/glassfish:7.0.18 • We are still waiting for the merge of the PR for DockerHub
awful things to your data • Postgress container, MySql, etc. • The database is destroyed after the test • Similar way you can create containers for anything just as if you would build a virtual network
of your Java code with JPA, JTA, JDBC, and real SQL database. When you want to check compatibility with several versions of the database. Idea: 1. Implement tool able to copy consistent data from some source and use it for selective dumps. 2. Maintain such source using the application. 3. Dump those data from time to time and add them to GIT (csv, json, unl, …) 4. Use @Container and your own impl loading dump before the test. 5. Run some test sequence whenever you want.