In JUnit 5, we can use @Timeout to fail a test if the execution time exceeds a given duration. P.S Tested with JUnit 5.5.2 1. @Timeout TimeOutExample1.java package com.mkyong.timeout; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import java.util.concurrent.TimeUnit; public class TimeOutExample1 { // timed out after 5 seconds @BeforeEach @Timeout(5) void setUpDB() throws InterruptedException { //TimeUnit.SECONDS.sleep(10); […]

Read more JUnit 5 Timeouts Examples

This article shows you how to use the OkHttp library to send an HTTP GET/POST requests and some frequent used examples. P.S Tested with OkHttp 4.2.2 pom.xml <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>4.2.2</version> </dependency> 1. Synchronous Get Request OkHttpExample1.java package com.mkyong.http; import okhttp3.Headers; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import java.io.IOException; public class OkHttpExample1 { // only […]

Read more OkHttp – How to send HTTP requests

The session timeout in a web application can be configurable in two ways 1) Timeout in the deployment descriptor (web.xml) – Specified the timeout value in “minute” , enclose with “session-config” element. <web-app …> <session-config> <session-timeout>20</session-timeout> </session-config> </web-app> The above setting is apply for the entire web application, and session will be kill by container […]

Read more How to configure the session timeout in servlet