Java tutorial
/* * Copyright 2005-2020 Daxia Team All rights reserved. * Support: zhangzhen * License: Daxia Team license */ package com.ling.spring.task; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:spring-task.xml") public class TestTask { @Autowired private ApplicationContext applicationContext; @Test public void testTaskExecutor() { TaskExecutorExample task = (TaskExecutorExample) applicationContext.getBean("taskExecutorExample"); task.printMessages(); } @Test public void testFixedTime() { try { Thread.currentThread().sleep(20000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }