1   /**
2    * Copyright 2005-2006 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.services.scheduling;
16  
17  import junit.framework.Test;
18  import junit.framework.TestCase;
19  import junit.framework.TestSuite;
20  import org.figure8.join.core.InvalidParameterException;
21  /**
22   * JUnit test case for tesing the QuartzCronInfo class.
23   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
24   * @version Revision$
25   */
26  public class QuartzCronInfoTest extends TestCase{
27  
28     // Constructors -------------------------------------------------------------
29  
30     /** Default constructor. Build a test case using a name. */
31     public QuartzCronInfoTest(String testName){
32        super(testName);
33     }
34  
35  
36     // Override of TestCase -----------------------------------------------------
37  
38     /**
39      * Make this class a TestSuite.
40      * @return A TestSuite containing this TestCase.
41      */
42     public static Test suite(){
43        TestSuite suite = new TestSuite(QuartzCronInfoTest.class);
44        return suite;
45     }
46     
47     
48     // Public -------------------------------------------------------------------
49  
50     /** Test the checking of job class. */
51     public void testJobClassCheck(){
52        try{
53           // Create a quartz cron info with corret job class.
54           QuartzCronInfo cronInfo = new QuartzCronInfo("name", "expression", "type",
55                   "org.figure8.join.services.scheduling.EchoQuartzJob");
56        }
57        catch (InvalidParameterException e){
58           fail("QuartzCronInfo creation should not fail ...");
59        }
60        // Will an exception be thrown if job class is not correct ?
61        boolean exception = false;
62        try{
63           // Create a quartz cron info with fake job class.
64           QuartzCronInfo cronInfo = new QuartzCronInfo("name", "expression", "type",
65                   "org.figure8.join.services.scheduling.MyFakeQuartzJob");
66        }
67        catch (Exception e){
68           exception = true;
69           assertTrue("Exception should be an InvalidParameterException", e instanceof InvalidParameterException);
70        }
71        assertTrue("An exception has been thrown when creating a job with wrong class", exception);
72     }
73  }