1   package org.apache.turbine.modules.scheduledjob;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.turbine.modules.ScheduledJob;
23  import org.apache.turbine.services.schedule.JobEntry;
24  
25  /***
26   * Simple job for use with unit testing of the scheduler service.  This
27   * job merely increments a static counter variable when it is run.  You
28   * can check the counter to verify the job has run.
29   *
30   * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
31   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
32   * @version $Id: SimpleJob.java 534527 2007-05-02 16:10:59Z tv $
33   */
34  public class SimpleJob
35          extends ScheduledJob
36  {
37      /*** The test counter */
38      private static int counter = 0;
39  
40      /***
41       * Run the Jobentry from the scheduler queue.
42       *
43       * @param job The job to run.
44       * @throws java.lang.Exception generic exception
45       */
46      public void run(JobEntry job)
47              throws Exception
48      {
49          counter++;
50          System.out.println("\n\nI AM RUNNING!\n\n");
51  
52      }
53      /***
54       * Returns the counter value.
55       *
56       * @return The counter value
57       */
58      public static int getCounter()
59      {
60          return counter;
61      }
62  
63      /***
64       * Sets the counter.
65       *
66       * @param i The new counter value
67       */
68      public static void setCounter(int i)
69      {
70          counter = i;
71      }
72  }