SOLID Design Principle Explained with Java

Introduction SOLID design principle is one of the most popular set of design principles in object-oriented software development. It’s a mnemonic acronym for the following five design principles: S – Single Responsiblity Principle O – Open Closed Principle L – Liskov Substitution Principle I – Interface Segregation Principle D – Dependency Inversion Principle

Mock ObjectMapper.readValue() using Junit Mockito

Introduction This example will show you how to mock ObjectMapper.readValue() using Junit Mockito. When we write Junit test cases or classes, we generally do not test on real object that are injected into the class that has to be tested using Junit to avoid any test case failure at some point, instead we want to test the business logic out…

Mock an Autowired @Value field in Spring with Junit Mockito

Mock @Value Field The below example will show you how to mock an Autowired @Value field in Spring with Junit Mockito. Generally you read some configuration values from properties file into Spring bean or component class using @Value annotated attributes but when you want to test such service or component class using Junit test class then it is required to…

Junit Mockito Verify Example

Introduction The tutorial Junit Mockito Verify method will show you how to verify a Java class method has been executed at least once or not. When you write Junit test case for void method then you cannot return anything from your actual method test but at the same time you also don’t know whether your actual method has been executed…

Junit Testing Of File Upload And Download

Junit Test Here in this tutorial you will see examples on Junit testing of file upload and download in Spring REST Controllers. You might have seen how to write Junit test cases on Spring REST Controllers in my other tutorials but I did not show how to write Junit testing of file upload and download in Spring REST Controllers but…

How To Remove Namespace from XML Using XSLT

Removing Namespace In this tutorial I will show you how to remove namespace from XML using XSLT. Removing namespaces from an XML document is not recommended and is in essence comparable to removing namespaces from a programming framework or library. It may risk name clashes and lose the ability to differentiate between distinct elements. But if you need absolutely to…

Transforming XML to HTML using XSLT

Introduction Here we will see the example on transforming XML to HTML using XSLT. We can also use Java code to transform XML to HTML but that would require a many LoC to finish the job but using XSLT it is quite easy to transform. XSLT stands for XSL Transformations. The Extensible Stylesheet Language (XSL) is a family of recommendations and…

Writing Junit Test on Java Thread

Introduction In this tutorial you will see how to write test case on Java thread using junit. Writing junit test on Java thread will show an example on single threaded environment.

Calculate Future Or Past Date In Java

Introduction This tutorial will show you how you can calculate future or past date in Java. The calculation is done on future date from a particular date to “plus a number of given days” or past date from a particular date to “minus a number of given days”. Future or past date calculation may be required for various purposes such…

Generating jaxb classes from xsd using Gradle

This tutorial will show you how to generate Java classes from XSD file using JAXB API and Gradle. Generating JAXB classes from xsd using Gradle is not an easy task because Gradle does not have yet any ready-made plugin like Maven. So to generate Java classes from XSD schema using Gradle you have to write an an Ant Task. The below…