我有一个春季项目。它适用于junit测试用例。juint 调用 applicationcontext.xml 并且项目成功运行。但我想在不使用 jUnit 的情况下运行该项目。这是我的 jUnit 测试用例
package com.dataload;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.util.StopWatch;
@ContextConfiguration(locations = "classpath:com/dataload/applicationcontext.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
public class SICSVDataTestCase {
private final static Logger logger = Logger
.getLogger(SICSVDataTestCase.class);
@Autowired
private JobLauncher launcher;
@Autowired
private Job job;
private JobParameters jobParameters = new JobParameters();
@Test
public void testLaunchJob() throws Exception {
StopWatch sw = new StopWatch();
sw.start();
launcher.run(job, jobParameters);
sw.stop();
logger.info(">>> TIME ELAPSED:" + sw.prettyPrint());
}
}
这个测试用例运行项目。但我想使用另一个可以调用 applicationcontext.xml 并运行项目的类。
那是,
package com.dataload;
public class insertCSV
{
public static void main(String args[])
{
/* Code to run the project */
}
}
谁能建议我如何编码?谢谢