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 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

Java 8 streams demo part 2: Stream of custom objects

Following the List with primitive types like in post here: Java 8 Streams demo, now it's time to demonstrate streams with custom objects. Please read mentioned post first to get the idea of this one faster. Introduction Now I want to have a list of Users. User is a POJO having a name and age. … Continue reading Java 8 streams demo part 2: Stream of custom objects

Android SQLite schema migration with patches

When upgrading your Android application you often need to change its data model. When the model is stored in SQLite database, then its schema must be updated as well. I recommend the concept of patching and versioning the database This is very well described in this article: http://www.greenmoonsoftware.com/2012/02/sqlite-schema-migration-in-android/ The idea behind it Android lets you … Continue reading Android SQLite schema migration with patches

Custom Java Annotation tutorial – How often do you use them?

@Override, @Test and @Deprecated annotations are widely used. They make code more readable and clean. You can facilitate Java Annotations features fully by creating your custom annotation for classes, fields etc. The use case Simple example, I figured out to illustrate this post, regards the PersonInfo class. This is in fact data class that contains... … Continue reading Custom Java Annotation tutorial – How often do you use them?

Android status bar notifications [complete tutorial with source code]

Displaying status bar notification is a common way to unobtrusively inform user that something has happened (like new GMail message notification). In your app you can display it whenever you want. I will guide you how to do it from basics. This is how notifications are presented to the user: Google's documentation regarding the notifications … Continue reading Android status bar notifications [complete tutorial with source code]