To continue with writing integration tests. When testing asynchronous operations, such as sending message to a queue, waiting for a response and completing some task, we need to introduce some kind of wait time in the test. Instead of using Thread.sleep(), we can use something called Awaitility... Documentation is pretty self explanatory... Testing asynchronous systems … Continue reading Thread.sleep()
Category: Java
Spring Integration Testing – WireMock and MQ
When writing integration tests for parts of the application that talk to other applications, for example calling REST APIs or sending JMS messages, sometimes we just want to test the application and not do end to end test. In this case, we would need to mock these other applications or their behavior. Mocking REST For … Continue reading Spring Integration Testing – WireMock and MQ
IntelliJ auto import on copy-paste
Very nice feature of IntelliJ is auto-importing dependencies and dependencies cleanup (optimize imports), especially useful when copy pasting entire code blocks, deleting stuff etc... Here is a screenshot of where to enable the settings and a link to IntelliJ docs... Auto import Optimize imports
Multiple projects inside one IntelliJ instance
When you are working with multiple projects, for example a number of microservices, it becomes problematic to have an IntelliJ instance open for each of those. There is a trick that allows us to have multiple projects open inside one IntelliJ instance (this saves time, space and RAM :)). Basics steps are as follows: Create … Continue reading Multiple projects inside one IntelliJ instance
MapStruct
When working with Spring services and exposing REST API calls, you would usually want to have a set of customized objects exposed to the outside world. These objects, usually called DTOs, can expose some of the domain objects or some projection made out of domain objects (or something else). For mapping between domain data objects … Continue reading MapStruct
Multi-stage docker images
When working with docker images, it would be a good idea to keep the final image (especially for production) as small as possible. Usually, when building apps, there are a lot of extra stuff included that are really not necessary for the final image. This can be most obvious with Spring Boot applications, where build … Continue reading Multi-stage docker images
SpringBoot, Axon, Multiple Data Sources = ? are you doin’?
Ok, so, after playing with this for few days, I have decided to put this into a form of a post, to serve mostly as a reference for anyone facing the same or similar problem. After all, how do you think I solve my problems? Just like that, I search online for solution, then for … Continue reading SpringBoot, Axon, Multiple Data Sources = ? are you doin’?
Run SpringBoot app inside alpine docker container
# From alpine:latest FROM alpine # Install open JDK 11 RUN apk add openjdk11 # Create temp volume VOLUME /tmp # Add and run your app ADD /spring-boot-web-0.0.1-SNAPSHOT.jar myapp.jar ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/myapp.jar"] Build the image: docker build -t alpine-java-3 . Run the image, map the ports 8080 to host machine: docker run -d … Continue reading Run SpringBoot app inside alpine docker container
Start Tomcat as a Windows service in the debug mode
From the tomcat/bin directory, start the tomcat exe or right click it to get to the properties. In the properties dialog, click the Java tab and BEFORE all of the -D options, add something like this: -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8998 Make sure they are first on the list and each in their own line. From then on, … Continue reading Start Tomcat as a Windows service in the debug mode