Package org.olat.core.commons.scheduler

Source Code of org.olat.core.commons.scheduler.SchedulerTest

/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS,
* <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.scheduler;

import java.util.Date;

import junit.framework.Test;
import junit.framework.TestSuite;

import org.springframework.scheduling.quartz.JobDetailBean;
import org.springframework.scheduling.quartz.SimpleTriggerBean;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;

/**
* Description:<br>
* TODO: guido Class Description for SchedulerTest
* <P>
* Initial Date: 03.03.2008 <br>
*
* @author guido
*/
public class SchedulerTest extends AbstractDependencyInjectionSpringContextTests {
 

  @Override
  protected String[] getConfigLocations() {
    return new String[] {"classpath:org/olat/core/commons/scheduler/testContext.xml"};
  }

  public void testSimpleTrigger() {
    Date start = new Date();
    JobDetailBean job = (JobDetailBean)applicationContext.getBean("schedulerTestJobSimple");
    assertNotNull(job);
    //wait until the job is executed
    try {
      Thread.sleep(5000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    SimpleTriggerBean trigger = (SimpleTriggerBean) applicationContext.getBean("schedulerTestJobSimpleTrigger");
    Date end = new Date();
    assertEquals(5, trigger.computeNumTimesFiredBetween(start, end));
  }
 
  public static Test suite() throws Exception {
    return new TestSuite(SchedulerTest.class);
  }
 
}
TOP

Related Classes of org.olat.core.commons.scheduler.SchedulerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.