Administrator

Lokesh Gupta

A fun-loving family man, passionate about computers and problem-solving, with over 15 years of experience in Java and related technologies. An avid Sci-Fi movie enthusiast and a fan of Christopher Nolan and Quentin Tarantino.

Website: https://howtodoinjava.com

Github: https://github.com/lokeshgupta1981/

Twitter: @HowToDoInJAVA

LinkedIn: https://www.linkedin.com/in/lokeshgupta1981/

My Articles:

JUnit 5 Test Templates for Eclipse

Eclipse has great tooling support for JUnit test cases. Having code templates for JUnit test cases configured in Eclipse is a great addition in faster test development. Learn to create and import JUnit 5 test templates in eclipse.

JUnit 5 Expected Exception: assertThrows() Example

When writing unit tests, it makes sense to check whether certain methods throw the expected exceptions when we supply invalid inputs or pre-conditions that are not satisfied. Junit 5 provides the following assertion methods for handling test exceptions. These method names are self-explanatory enough to suggest their usage. Please continue …

JUnit 5 @Disabled Test Example

JUnit @Disabled annotation can be used to disable the test methods from test suite. This annotation can be applied over a test class as well as over individual test methods.

JUnit 5 Assumptions

JUnit 5 Assumptions class provides static methods to support conditional test execution based on assumptions. A failed assumption results in a test being aborted. Assumptions are typically used whenever it does not make sense to continue execution of a given test method. In test report, these test will be marked as passed.

JUnit 5 Assertions – JUnit assert Examples

JUnit 5 assertions help in validating the expected output with actual output of a testcase. To keep things simple, all JUnit Jupiter assertions are static methods in the org.junit.jupiter.Assertions class.

JUnit 5 Test LifeCycle

In JUnit 5, test lifecycle is driven by 4 primary annotations i.e. @BeforeAll, @BeforeEach, @AfterEach and @AfterAll. Along with it, each test method must be marked with @Test annotation. @Test annotation is virtually unchanged, although it no longer takes optional arguments.

JUnit 5 with Gradle

Learn to configure junit 5 with gradle, its juniper and platform modules and how to use them to create and execute tests.

JUnit 5 Maven Dependency

Learn to configure junit 5 with maven, its jupiter and platform different modules and how to use them to create and execute tests.

JUnit 5 @Tag Example: Label, Filter and Run Tests

JUnit 5 @Tag can be used to filter testcases from test plans. It can help in create multiple different test plans for different environments, different use-cases or any specific requirement. You can execute set of tests by including only those tagged tests in test plan OR by excluding other tests from test plan.

JUnit 5 Test @Suite with Examples

JUnit 5 test suites are written with @Suite annotation. Suites help us run the tests spread into multiple classes and packages. We can use Include and Exclude annotations (discussed later in this tutorial) for filtering test packages, test classes, or even test methods. @RunWith(JUnitPlatform.class) has been deprecated in favor of …

JUnit 5 @RepeatedTest

JUnit 5 @RepeatedTest annotation enable to write repeatable test templates which could be run multiple times. The frequency can be configured as parameter to @RepeatedTest annotation.

JUnit 5 @AfterAll

JUnit 5 @AfterAll annotation is replacement of @AfterClass annotation in JUnit 4. The annotated method should be executed after all tests in test class.

JUnit 5 @AfterEach

JUnit 5 @AfterEach annotation is replacement of @After annotation in JUnit 4.The annotated method should be executed after each @Test method in test class.

JUnit 5 @BeforeEach

JUnit 5 @BeforeEach annotation is replacement of @Before annotation in JUnit 4. Annotated method should be executed before each @Test method in test class.

JUnit 5 @BeforeAll

JUnit 5 @BeforeAll annotation is replacement of @BeforeClass and is used to signal that annotated method should be executed before all tests in test class.

Execute JUnit 5 Tests in Eclipse

Learn to execute JUnit 5 tests in Eclipse IDE. Maven has been used to import dependencies in this JUnit 5 example. 1. Add JUnit 5 Maven Dependencies To run JUnit 5 tests in Eclipse, at minimum, we will need the latest versions of the following dependencies. 2. Use @Test Annotation …

Java XMLGregorianCalendar

Learn to convert XMLGregorianCalendar to Date class or string value. Also learn to apply timezone changes and daylight saving effects as well.

Building HATEOAS Links with JAX-RS

Learn to build JAX-RS 2.0 HATEOAS links in REST resources using it’s javax.ws.rs.core.Link, javax.ws.rs.core.UriBuilder and javax.ws.rs.core.UriInfo classes.

Tomcat – Get Real IP behind Load Balancer

Mostly for logging and security purposes, we need the IP address information for incoming requests. 1. HTTPServletRequest.getRemoteAddr() In a Java web application, we can get IP address using HTTPServletRequest.getRemoteAddr() method. String ipAddress = httpServletRequest.getRemoteAddr(); BUT, if our application is running behind a load balancer proxy and we would like to …

Spring Boot – Get All Loaded Beans in Runtime

Spring boot loads lots of beans internally to run the application with minimal configuration. In this example, we will learn to find out all those loaded beans by Spring Boot and their class type information. Using ApplicationContext to get all loaded beans To execute a method automatically, when the application …

Serving JSP with Spring Boot 3

In Spring Boot 3 JSP example, learn to configure the Spring MVC with JstlView.class and serve JSP pages with static content and triage some common issues.

FizzBuzz Program in Java

In fizz buzz game, we say numbers such that if that number is a multiple of five, we say “fizz”, if multiple of seven, we say “buzz”, multiple of both, we say “fizzbuzz.”

Java CORS Filter Example

Learn to use Java CORS filter. CORS is a mechanism that allows JavaScript on a web page to make AJAX requests to another domain.

Format XMLGregorianCalendar to String

Learn to format XMLGregorianCalendar instance to string in multiple patterns e.g. ‘MM/dd/yyyy hh:mm a z’ using DateTimeFormatter and SimpleDateFormat classes in Java.

Java Stream distinct(): Collect Unique Values

Using java 8 stream API, you can use stream.distinct() method to filter or collect all distinct elements from a collection. Let’s learn how to find distinct elements with java stream API.

Vaadin ComboBox Examples

In this tutorial, we will learn to work with Vaadin ComboBox UI component including setting values, filtering, adding new values and event handling.

Vaadin Text Field Examples

Learn to setup, style and validate vaadin text field control with these simple to follow code examples.

Java WatchService Tutorial

Learn to register for changes in a directory, sub-directories and files using the Java WatchService API, handle the changes and cancel it.

Python Httplib2

Python httplib2 module provides methods for accessing Web resources via HTTP GET and POST requests, authentication, caching, redirects, and compression.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.