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
Configuring StatisticsListener (using annotations)
In this post under Spring Retry, I will show with example how to configure StatisticsListener using annotations. As explained in previous posts, StatisticsListener class provided by Spring Retry framework collects statistics of a particular retry operations. The statistics information involves1) Abort Count –> How many times the retry was aborted2) Complete Count –> How many…… Continue reading Configuring StatisticsListener (using annotations)
Assertions using Supplier interface
In this post under JUnit 5, I will show with example, the new version of assert method which takes a Supplier interface implementation as an argument. In previous versions of JUnit, we have seen variety of assert methods, which takes the below arguments.1) The expected value (optional)2) The actual value (required)3) String message when the…… Continue reading Assertions using Supplier interface
JUnit 5 Simple example
In this post under JUnit 5, I will introduce to new version of JUnit with simple example. JUnit 5 is divided into three subprojects as shown below JUnit Platform –> This is the base subproject on which other subproject depends. It has TestEngine API which will be implemented by other subprojects. Its main purpose is…… Continue reading JUnit 5 Simple example
Configuring Recovery Callback (using annotations)
In this post under Spring Retry, I will show with example how to configure a Recovery callback using annotations. Spring Retry retries fail operations for fixed number of times. If the operations fails even after last attempt, we don’t have any other option but to recover from that failure. Spring Retry provides an annotation that…… Continue reading Configuring Recovery Callback (using annotations)
Configuring exceptions to exclude from retry (using annotations)
In the previous post under Spring Retry, I showed with example how to specify the exceptions through annotation, for which a annotated operation has to be retried. In this post, I will show with example how to mention the exceptions through annotation, that when thrown by a annotated operation, Spring retry shouldn’t retry that operation.…… Continue reading Configuring exceptions to exclude from retry (using annotations)
Configuring Exceptions to include for retry (using annotations)
In this post under Spring Retry, I will show with example how to configure the exceptions for which retry has to happen. For the example I will use the below service class. Service8 1 import org.springframework.retry.annotation.Retryable; 2 import org.springframework.stereotype.Service; 3 4 @Service 5 public class Service8 { 6 private int i = 0; 7 8…… Continue reading Configuring Exceptions to include for retry (using annotations)