What I Learned in Week-14, 2020

What I Learned in Week-14, 2020

It’s been tough time for everyone due to the Corona virus situation. Staying at home for weeks and weeks is not easy, but it is very necessary thing to do so that we don’t spread the virus. However, if I look on the bright side I used to spend minimum 3 hours for office commute everyday. Now I am using that time for various other activities including learning some new things.

Continue reading »
Imposing Code Structure Guidelines using ArchUnit

Imposing Code Structure Guidelines using ArchUnit

While building the software, we all agree, as a team, to follow a set of guidelines which are typically considered as best practices. But during the development, developers might violate those guidelines unknowingly or ignorance. Typically, we rely upon code reviews or code quality checking tools like SonarQube, PMD, etc. to check for such violations. But some of the guidelines could be opinionated decisions which might not be able to automate using SonarQube, PMD etc.

Continue reading »
What I Learned in Week-11, 2020

What I Learned in Week-11, 2020

I come across many blog posts from various sources like Twitter, StackOverflow etc and some of them are very helpful. Also, in day to day work I learn few new things, explore some new tools. Usually I keep track of this information using Browser Bookmarks and Pocket. I thought may be this information could be useful for others too. So, I am going to share it weekly on my blog.

Continue reading »
SpringBoot Integration Testing using TestContainers Starter

SpringBoot Integration Testing using TestContainers Starter

One of the many reasons for huge popularity of Spring and SpringBoot is it’s great support for Testing. We can write unit tests using Mockito without requiring any Spring features. And, we can write Integration Tests using Spring testing support by creating Spring ApplicationContext. Read Guide to Testing SpringBoot Applications While running integration tests we might need to interact with external services like relational databases, NoSQL datastores, Kafka etc. We can spin up those external services as Docker containers and run tests against them.

Continue reading »
Creating Yeoman based SpringBoot Generator

Creating Yeoman based SpringBoot Generator

I have been working with Spring and SpringBoot for many years and I needed to create lot of Spring(Boot) applications for various reasons like blog posts, sample apps, book sample code and for my personal learning as well. So, I needed some tool/mechanism to quickly create Spring(Boot) application with most commonly used configuration. I know we have the most popular SpringBoot Initializer to create SpringBoot applications. But, it generates the application with only selected starter dependencies added and nothing more.

Continue reading »
Testing REST APIs using Postman and Newman

Testing REST APIs using Postman and Newman

<strong>Postman</strong> is the most popular tool for testing REST APIs. I guess most of the developers are familiar with how to use Postman to send various types (GET, POST, PUT, DELETE, etc) of HTTP requests with various types of payloads (form data, JSON etc). In addition to triggering one API request and verifying the response, I frequently come across some common needs like Call an API and assert response Parameterize variables based on the environment Trigger a series of API calls to simulate some user flow Trigger one API request with different inputs and assert expected response Load test by simulating load on the server by firing a series of requests repeatedly with a certain delay Run Postman collection to do Smoke Test from Build Pipeline As I am already using Postman to test my REST APIs, I thought of exploring if I can do all these tasks using Postman itself and it turns out I can.

Continue reading »
Testing SpringBoot Applications

Testing SpringBoot Applications

SpringBoot is the most popular tech stack for building Java based REST APIs. In this tutorial we will learn how to write tests for SpringBoot applications. Create SpringBoot Application Unit Testing using JUnit 5 and Mockito Integration Testing using TestContainers Testing MicroService Integrations using MockServer As we all know, we write unit tests for testing single component (a class) behaviour where as we write integration tests for testing a feature which may involve interaction with multiple components.

Continue reading »
Kafka Tutorial - Producer and Consumer using SpringBoot

Kafka Tutorial - Producer and Consumer using SpringBoot

In the previous post Kafka Tutorial - Java Producer and Consumer we have learned how to implement a Producer and Consumer for a Kafka topic using plain Java Client API. In this post we are going to look at how to use Spring for Kafka which provides high level abstraction over Kafka Java Client API to make it easier to work with Kafka. You can find the source code for this article at https://github.

Continue reading »
Kafka Tutorial - Java Producer and Consumer

Kafka Tutorial - Java Producer and Consumer

Kafka, depending on how you use it, can be seen as a Message Broker, Event Store or a Streaming Platform etc. Kafka became a preferred technology for many of the modern applications because of various reasons like: Kafka can be used as an Event Store if you are using Event Driven Microservices architecture Kafka can be used as a Message Broker to enable communication across multiple applications Kafka can be used as Streaming platform for processing events in realtime etc etc.

Continue reading »
SpringBoot Best Practices

SpringBoot Best Practices

I have been working with SpringBoot for many years and over the time I worked with many SpringBoot based codebases. There are few common mistakes that I observe in the projects that use SpringBoot. So, I thought of writing down few good practices that can be followed while using SpringBoot. 1. Understand SpringBoot Core Concepts I know, this sounds very obvious but I see many developers jumping onto using SpringBoot without having any prior knowledge on Spring, Dependency Injection.

Continue reading »