Automated tests for Spring Boot WebSocket server

Developing WebSocket server for your Spring Boot app is fairly simple and well described and documented. However when it comes to making sure that it 'actually works' is done manually in most cases. Below I will show how I do the automated integration tests for Websocket server using Spring's StompClient. I assume that you are … Continue reading Automated tests for Spring Boot WebSocket server

Java 8 StringJoiner demo

Finally Java has convenient and intuitive API for joining strings with delimiters! Since Java 8 there is StringJoiner class. It is an API that you may know from Guava Joiner classes (see my post: https://looksok.wordpress.com/2015/10/17/guava-joiner-join-all-strings-in-an-array-or-map/). Here is a short StringJoiner demo. Basic String joins The most basic usage is to create StringJoiner instance with delimiter … Continue reading Java 8 StringJoiner demo

Guava collection initializers

Jacek Milewski

Java requires quite verbose collection initialization (due to generics) like this: Map<String, Map<String, Integer>> lookupTraditional = new HashMap<String, Map<String, Integer>>(); It barely fits one line... It's long and readability is reduced. Java 7 introduced the Diamond Operator, so the developer does not have to repeat all the types declaration after the new operator: Map<String, Map<String, … Continue reading Guava collection initializers

Guava Multimap demo

The problem Handling maps that store collection of items under each key is very common. The thing I have in mind is this: Map<String, List<Integer>> playerScoresMap = new HashMap<String, List<Integer>>(); Let's assume that it stores scores for players. The player name is the key, and the value is a list of points scored by the … Continue reading Guava Multimap demo

Guava Cache basic demo

Here I go with the caching! Caching (and cache invalidation) is second one of the most difficult thing to do while programming (the first one is the naming things problem :P ). I'll show the demo with Guava Cache (18.0). Source Code for this tutorial is on my GitHub: https://github.com/yacekmm/looksok/tree/GuavaCacheDemo/Guava/GuavaCacheDemo Caches Explained You may want … Continue reading Guava Cache basic demo