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
Author: sumanthprabhakar
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)
Configuring RetryListener (using annotations)
In this post under Spring Retry, I will show with example how to configure RetryListener using annotations. For our example we will need the below “CustomRetryListener2” class CustomRetryListener2 import org.springframework.retry.RetryCallback; import org.springframework.retry.RetryContext; import org.springframework.retry.RetryListener; import org.springframework.stereotype.Component; @Component public class CustomRetryListener2 implements RetryListener { @Override public <T, E extends Throwable> void close(RetryContext arg0, RetryCallback<T, E> arg1,…… Continue reading Configuring RetryListener (using annotations)
Validating html documents against whitelist of html attributes
In one of my previous posts under Jsoup, I showed how to verify html documents against a whitelist of html tags. In this post I will show how to verify html documents against a whitelist of html attributes along with whitelist of html tags. Below is the complete main code for your reference Main class…… Continue reading Validating html documents against whitelist of html attributes
Cloning an html document
In this post under jsoup, I will show with example how to clone the entire html document. For our example we will use the below html document Input1.html <html> <head> <title>Input1</title> </head> <body> <p>Input1</p> </body> </html> Below is the main code that contains the logic for cloning the entire document. Main Class 1 import java.io.File;…… Continue reading Cloning an html document
Getting all html elements in a document
In this post under Jsoup, I will show with example how to get a list of all html elements in a document. Below is the main class Main Class 1 import java.io.File; 2 import java.io.IOException; 3 import java.util.Iterator; 4 5 import org.jsoup.Jsoup; 6 import org.jsoup.nodes.Document; 7 import org.jsoup.nodes.Element; 8 import org.jsoup.select.Elements; 9 10 public class…… Continue reading Getting all html elements in a document
Spring Retry traversingCauses example (using RetryTemplateBuilder)
In my previous post under Spring Retry, I showed with example how to retry failed operations only for specific exceptions. So for example if we configure Spring Retry (as shown in the below code) to retry only when NullPointerException is thrown Code snippet 1 RetryTemplateBuilder retryTemplateBuilder = RetryTemplate.builder(); retryTemplateBuilder.retryOn(NullPointerException.class) Spring Retry will retry the failed…… Continue reading Spring Retry traversingCauses example (using RetryTemplateBuilder)