Skip to main content

Welcome to Geoff Hayward's Weblog

Commenting on Java, JavaFX, Java EE, Joomla, and IoT.

Java singleton's are hard to unit test because the state of the singleton is altered as each test runs. But for testing sake you can reset the singleton's state use reflection. Here is an example that worked for me.

public void setup() throws NoSuchFieldException, IllegalAccessException {
        Field instance = RemoteMessageTranslation.class.getDeclaredField("set");
        instance.setBoolean(null, false);

I hope this helps


Here is how to find a Java regex pattern within a string.

public void stringContainsRegexPattern() {
	assertTrue(Pattern.compile("pattern(?:\\s[a-z]+){2}\\setc\\.").matcher("Here is the pattern and that etc.").find());


In an earlier post this year, 'Convert an ArrayList to an Array in Java', I commented on a way to convert an ArrayList to an Array in Java. Here is the example code from the earlier post.

List<String> results = new ArrayList<>();
results.toArray(new String[results.size()]);

This earlier way works fine, however it's old school. Here is the Java 8 Lambda way to convert an ArrayList to an Array:

Long[] longArray =

This example works by mapping a new object for each item in the ArrayList's stream to the new stream, and then collecting that stream as an array.


I am very happy to be attending Devoxx Poland 2016; I enjoyed Devoxx Poland last year very much. As well as Krakow.

This year I am looking forward to talks on: Java 9 Flow API; Angular 2; Microservices; lambdas; and many other topics. But, worryingly there does not seem to be a single talk with "Java EE" in the title. Like last year Devoxx Poland has attracted many great speakers.

Also, the food last year was delicious, so I hoping for the same this year.

Here is Devoxx 2015 video


It is easy to generate a SOAP client from a WSDL with Java. Java comes with the tool named 'wsimport'. The wsimport tool is part of the Java JDK, found in the JDK bin folder. By default when you run the tool it will create and keep the compiled .class files. If you do not need the .class files just add -Xnocompile to the command.

wsimport http://localhost:8080/demo?wsdl -Xnocompile


Mailing List

Responsive Media

With the ResponsiveMedia plugin for Joomla it is easy to add 3rd party content from YouTube, Vimeo, and Instagram right in to any Joomla! article.