Recently I wanted to try out a REST call on my local computer, running my microservice locally. The service calls another microservice, in the SIT environment, that required secure HTTP s connection. As I did not have the certificate installed on my workstation, but wanted to fast test the call anyway, I had to find… Continue reading Bypass SSL certification with Spring RestTemplate
Tag: Java
Create and modification date with Spring Data
Using created and last modified fields for an entity is considered general pattern and a good practice. It provides you the information about what and when happens in your database, therefore makes your life easier when the time of problem solving comes. As we love to automatize such boring tasks, using Hibernate it is common to… Continue reading Create and modification date with Spring Data
Using Docker in your development process
Recently I finished the Docker for Java Developers course from Spring Guru on Udemy. My goal was to learn and understand Docker so far, that I should be able to use it in my development and learning process. start a database for development and test purposes locally. Docker makes it possible to spare the installation process,… Continue reading Using Docker in your development process
Add your own Grafana metrics
Grafana is a great tool to visualize operational information regarding of a running service. Recently I implemented a function, that continuously sends information to the Influx database that backs our Grafana server. It provides information about the number of clients, currently connected to our Spring Boot service, via WebSocket. As in the simplest case you… Continue reading Add your own Grafana metrics
Using Spring Security with Websocket
If you have a Spring Boot application, that already uses Spring Security, it can be tricky to set up the security for Websocket communication. The problem is, that in case of you need to protect your resources with basic authentication, it avoids the connection to your Websocket service, while Websocket can not work together… Continue reading Using Spring Security with Websocket
My favorite Lombok features
I use the Lombok project with a great pleasure. It makes it easier to create a nice code without boilerplate code. My favorite features @Data Maybe the most used annotation. Generates all boilerplate code for a domain object. Getters, setters, equals, hashcode, toString. It is a very good feature to start with. You will never… Continue reading My favorite Lombok features
Using logging in your unit test
When running unit test, you are not supposed to be checking the logs, generated by the test framework. One of the first principles of the test driving development paradigm is, that you should be able to run your tests automatically, without any developer interaction. You also should not be forced to check any output besides… Continue reading Using logging in your unit test
Code templates for Eclipse
In my daily work, I found very productive to use my own code templates for Eclipse. By the time, I have collected a useful set of templates. You can define your own templates by opening the dialog under Preferences\Java\Editor\Templates Defining templates is quite straightforward. If you need a detailed introduction, please refer to the following… Continue reading Code templates for Eclipse
Using reflection in setup phase of unit testing
It is a common practice to use mock framework in the setup phase of a unit test, in order to set the internal state of the dependent objects. Sometimes it is though easier to set a value of a given field directly, in order to test the class accordingly. For modifying field value via reflection,… Continue reading Using reflection in setup phase of unit testing
Different ways to use assertions in Java code
In order to create a clean and save code, I prefer implement as many state checks in my code, as possible or necessary. If a state check fails, you usually want to throw an exception and stop processing the current business step. Failure in state check is always a sign of an implementation problem. As… Continue reading Different ways to use assertions in Java code