In this post under Junit5, I will show with example, how to use Assumptions feature. Sometimes test case assertions depend on certain conditions. If a condition is met, then test case should be asserted otherwise we should skip the assertion. To test whether the condition is met or not, we take the help of “assumeTrue”…… Continue reading Assumptions in JUnit5
Author: sumanthprabhakar
Parsing simple unsecured JWT containing claims
In this post under JJWT, I will show with example how to parse a simple unsecured JSON Web Token containing claims as payload. Below is the complete main code for your reference Main class 1 package defaultPackage;2 import io.jsonwebtoken.Claims;3 import io.jsonwebtoken.Header;4 import io.jsonwebtoken.Jwt;5 import io.jsonwebtoken.JwtParser;6 import io.jsonwebtoken.JwtParserBuilder;7 import io.jsonwebtoken.Jwts;8 9 public class Example2 {10 public…… Continue reading Parsing simple unsecured JWT containing claims
Creating a simple unsecured JSON Web Token containing claims
In this post under JJWT, I will explain how to create a simple unsecured JSON Web Token whose payload is a set of claims. I will be using JJWT framework for this example and for all the upcoming examples under JJWT. Below is the complete code for your reference Main class 1 package defaultPackage;2 3…… Continue reading Creating a simple unsecured JSON Web Token containing claims
Disabling the tests
In this post under Junit 5, I will show how to disable a test method or all test methods of a class. Junit 5 added a new annotation named “Disabled” to disable a test method or all the test methods of a class. When applied at a particular method, that particular method is disabled. When…… Continue reading Disabling the tests
assertTrue and assertFalse with Supplier Interface
In this post under JUnit 5, I will introduce you to a new overloaded version of “assertTrue” and “assertFalse” methods. In the earlier versions, we used to stored the result of a comparison in local variable of type boolean and when calling assertTrue or assertFalse, we used to pass that local variable as an argument…… Continue reading assertTrue and assertFalse with Supplier Interface
Comparing two arrays for equality
In this post under Java, I will show with example how to check whether two arrays are equal or not. The class Arrays under java.util package has “equals” static method which takes two arrays as arguments and compare their contents to check whether they are same. Below is the code showing an example Main 1…… Continue reading Comparing two arrays for equality
BeforeEach and AfterEach annotations
In this post under JUnit, I will show with example the purpose of BeforeEach and AfterEach annotations. As you know when writing unit test cases, before calling the test method and asserting the output, we should first setup the data on which the test method has to be executed. We can place the code that’s…… Continue reading BeforeEach and AfterEach annotations
Configuring FixedBackOfPolicy (using annotations)
In this post, under Spring Retry I will show with example how to configure FixedBackOfPolicy using annotations. For our example we will use the below service class Service class 1 import java.util.Date; 2 3 import org.springframework.retry.annotation.Backoff; 4 import org.springframework.retry.annotation.Retryable; 5 import org.springframework.stereotype.Service; 6 7 @Service 8 public class Service13 { 9 private int i =…… Continue reading Configuring FixedBackOfPolicy (using annotations)
Configuring maxAttempts for Retry (using annotations)
In this post under Spring Retry, I will explain with example on how to configure maxAttempts for retry operation using annotation. For our example, we will use the below Service class Service Class 1 import org.springframework.retry.annotation.Retryable; 2 import org.springframework.stereotype.Service; 3 4 @Service 5 public class Service12 { 6 private int i = 0; 7 8…… Continue reading Configuring maxAttempts for Retry (using annotations)
AssertThrows example
In this post under Junit 5, I will show with example what is the purpose of and how to use AssertThrows feature. AssertThrows method checks whether the called method throws the user specified exception or not. If the user specified exception is thrown, the test passes otherwise the test fails. For our example, we will…… Continue reading AssertThrows example