devxlogo

Enterprise

Cron Job Listing in Linux

Cron jobs are also known as scheduled jobs. After adding several of them, you might want to identify what jobs have been added. The following command helps. [root@rivers cron]# crontab

Grouping Assertions in JUnit 5

Starting with JUnit 5, we can easily group assertions, as in the following example: @Testvoid allAssertions() {assertAll(“cart”, ()-assertEquals(“Shirt”,cart.getItemName()), ()-assertEquals(“White”,cart.getItemColor()));} In a grouped assertion, all assertions are executed together and if

Creating a Spring Read Only and Native Query

To allow your query methods to be transactional, you should use @Transactional at the repository interface that you define. For reading operations, the transaction configuration readOnly flag should be set

Using a JDBC Template

Spring provides a nice abstraction on top of the JDBC API using JdbcTemplate and also provides great transaction management capabilities using annotation-based approach. By using the JdbcTemplate and NamedParameterjdbcTemplate classes,

Use the @RestController Annotation

It is a good idea to use @RestController (instead of simply @Controller), because it ensures you that it will return a Java Object rather than a reference to an HTML

Failing Test After Time Expired in Mockito

Failing test after expiring the set period of time in Mockito: @Timed(millis=2000)public void testTwoSecondTimeout(){ // some logic that should not take longer than 2 seconds to execute}

Defining a Parameter in Jenkins

As you know, Jenkins accept parameters in different kind of projects, including pipelines. Depending on the operating system where Jenkins is running, we can refer to the parameters as follows,