JUnit expected exception test

Expected exception test is used for the methods which can throw an exception. We have to specify expected exception in @Test(expected = expectedException.class) action. If expected exception or any of its subclass exception is thrown by the method then JUnit will pass this unit test. Example: DivisionTestCase.java import com.w3schools.business.*; import static org.junit.Assert.*; import org.junit.Test;   … Read more

Junit basic annotation example

Annotations for Junit testing: 1. @Test: It is used to specify the test method. 2. @BeforeClass: It is used to specify that method will be called only once, before starting all the test cases. 3. @AfterClass: It is used to specify that method will be called only once, after finishing all the test cases. 4. … Read more

Struts 2 and Quartz 2 scheduler integration

To integrate Struts 2 and Quartz 2 scheduler we have to use a standard Servlet Listener which links both frameworks together. To create a standard Servlet Listener class implements ServletContextListener interface. ServletContextListener interface provides contextInitialized() method which is executed automatically at the time of Servlet container initialization. Servlet Listener invokes the Quartz scheduler framework in … Read more

Quartz listing all jobs example

Example Explanation: 1. Create multiple jobs by implementing Job interface. 2. Perform your business logic in the execute method. 3. Create a class for executing multiple quartz jobs. 4. Get JobDetail object from JobBuilder and set job detail like name and job class for each job. 5. Create Trigger object from TriggerBuilder and set the … Read more

Quartz multiple jobs example

Example Explanation: 1. Create multiple jobs by implementing Job interface. 2. Perform your business logic in the execute method. 3. Create a class for executing multiple quartz jobs. 4. Get JobDetail object from JobBuilder and set job detail like name and job class for each job. 5. Create Trigger object from TriggerBuilder and set the … Read more

Quartz 2 JobListener

JobListener: JobListener provides the facility to track the status of running jobs. To write a JobListener we have to implements the JobListener interface. Example: SimpleTriggerTest.java import org.quartz.JobBuilder; import org.quartz.JobDetail; import org.quartz.JobKey; import org.quartz.Scheduler; import org.quartz.SimpleScheduleBuilder; import org.quartz.Trigger; import org.quartz.TriggerBuilder; import org.quartz.impl.StdSchedulerFactory; import org.quartz.impl.matchers.KeyMatcher;   /** * This class is used for executing quartz job * … Read more

Quartz 2.1.5 hello world example using CronTrigger

Example Explanation: 1. Create a job by implementing Job interface. 2. Perform your business logic in the execute method. 3. Create a class for executing quartz job. 4. Get a JobDetail object from JobBuilder and set job detail like name and job class. 5. Create Trigger object from TriggerBuilder and set the scheduler timing and … Read more

Quartz 2.1.5 hello world example using SimpleTrigger

Example Explanation: 1. Create a job by implementing Job interface. 2. Perform your business logic in the execute method. 3. Create a class for executing quartz job. 4. Get a JobDetail object from JobBuilder and set job detail like name and job class. 5. Create Trigger object from TriggerBuilder and set the scheduler timing and … Read more

Quartz 1.6 hello world example using CronTrigger

Example Explanation: 1. Create a job by implementing Job interface. 2. Perform your business logic in the execute method. 3. Create a class for executing quartz job. 4. Create a JobDetail object and set job detail like name and job class. 5. Create CronTrigger object and set the scheduler timing and other details. 6. Get … Read more

Quartz 1.6 hello world example using SimpleTrigger

Example Explanation: 1. Create a job by implementing Job interface. 2. Perform your business logic in the execute method. 3. Create a class for executing quartz job. 4. Create a JobDetail object and set job detail like name and job class. 5. Create SimpleTrigger object and set the scheduler timing and other details. 6. Get … Read more