Z2-environment Version 2.9 is Available

Finally, Version 2.9 is available for download and use. Version 2.9 comes with some useful improvements.

Please check out the wiki and online documentation.

Support for Java 15

Version 2.9 requires Java 11 and runs with Java up to Version 16 and supports a language level up to Java 15 based on the Eclipse Java Compiler ECJ 4.19 (#2088).

With Java 15, we have now finally multi-line text blocks, saving us some painful reformatting when needing markup or code blocks or long messages as string literals.

@Test
public void multilineStrings() {
	// Text blocks are kind of
	// nice for mark up, messages and code
	err.println("""
	create extension pg_stat_statements;
	select  
	pd.datname, 
	substring(pss.query,1,100) as query,
	calls,
	pss.rows as totalRowCount,
	(pss.total_time / 1000) AS duration,
	((pss.total_time / 1000)/calls) as "avg"  
	from pg_stat_statements as pss 
	join pg_database as pd on pss.dbid=pd.oid 
	order by duration desc limit 20;
	""");
}

Check out the JDK 15 Documentation for more on Java 15.

Upgrade to Jetty 10.0.1

This version now embeds Jetty 10.0.1 as its Web container (#2090). Jetty 10 is the last version supporting the Jakarta EE 8 namespace and the first to support the Servlet 4.0 API.

NOTE: With the next upgrade (Version 2.10) we will move on to Jakarta 9 that is NOT backwards compatible with previous versions of the Jakarta EE or Java EE APIs. This is mainly because package names change from “javax.*” to “jakarta.*” throughout the EE APIs.

See also Understanding Jakarta EE 9.

Supporting JUnit 5 (a.k.a. JUnit Jupiter)

This is arguably the coolest new feature in Z2. Previously Z2 already included an extremely useful in-container testing feature z2 Unit that was built on JUnit 4. I described it in detail in In-system testing re-invented. This is so useful for integration testing of anything that may call itself a meaningful application that I could not imagine developing without it anymore.

Hence it was all the more painful that it took so long to support the JUnit 5 API. Compared to JUnit 4, JUnit 5 is not only completely different but also significantly more complex from the perspective of an extender. However, it is also architecturally cleaner and allows for more testing features and testing flexibilty.

The new implementation of #2036, called z2 Jupiter, now allows to run remote integration tests transparently to the client (IDE, ANT, Jenkins,… etc) without compromising on JUnit 5 features in your tests – even more so than z2Unit did.

package mytest;

import org.junit.jupiter.api.Test;

import com.zfabrik.dev.z2jupiter.Z2JupiterTestable;

@Z2JupiterTestable(componentName="my_tests/java")
public class AZ2IntegratedUnitTest {

    @Test
    public void someTestMethod() {  
        System.out.println("Hello World!");
    }
}

I will described the implementation approach in another blog post. For now please check out How to Unit Test in Z2.

More…

Check out the version page for more details. Go to download and getting started in five minutes or check out some samples.

Posted in z2