/** * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { if(args.length < 2) { throw new RequiredException("Usage: java "+CommandLineTimestampJobRunner.class.getName()+" job.xml jobid"); } String[] commandLineArgs = new String[args.length+1]; Date start = Calendar.getInstance().getTime(); String timestamp = Text.formatDate(timestampFormat, start); System.arraycopy(args, 0, commandLineArgs, 0, args.length); commandLineArgs[args.length] = new StringBuilder().append(timestampParameterName).append("=").append(timestamp).toString(); try { //Test Service Factory creation ServiceFactory.getInstance(); CommandLineJobRunner.main(commandLineArgs); } catch (Exception e) { throw handleJobException(e); } }
public static void main(String[] args) throws Exception { CommandLineJobRunner.main( new String[]{"org/yggd/springbatch/showcase/repository/repositoryConfig.xml", "repositoryJob", "aaa=hoge"}); }
/** * エントリポイント * * @param args 引数 */ public static void main(String[] args) throws Exception { CommandLineJobRunner.main( new String[]{JavaConfig.class.getName(), "firstJob", "aaa=hoge"} ); }
@Test public void run() throws Exception { final Queue<Integer> exitCode = new ArrayBlockingQueue<Integer>(1); CommandLineJobRunner.presetSystemExiter(new SystemExiter() { @Override public void exit(int status) { exitCode.add(status); } }); CommandLineJobRunner.main(new String[]{ JOB_CONTEXT, "importProductsJob" }); assertThat(exitCode.poll().intValue()).isEqualTo(0); CommandLineJobRunner.main(new String[]{ JOB_CONTEXT, "importProductsJob", "exit.status=COMPLETED" }); assertThat(exitCode.poll().intValue()).isEqualTo(0); CommandLineJobRunner.main(new String[]{ JOB_CONTEXT, "importProductsJob", "exit.status=FAILED" }); assertThat(exitCode.poll().intValue()).isEqualTo(1); CommandLineJobRunner.main(new String[]{ JOB_CONTEXT, "importProductsJob", "exit.status=COMPLETED WITH SKIPS" }); assertThat(exitCode.poll().intValue()).isEqualTo(3); CommandLineJobRunner.main(new String[]{ JOB_CONTEXT, "importProductsJob", "exit.status=ANYTHING" }); assertThat(exitCode.poll().intValue()).isEqualTo(2); }
/** * XMLのBean定義ファイルから起動 * * @param args 引数 */ public static void main(String[] args) throws Exception { CommandLineJobRunner.main(new String[]{"org/yggd/springbatch/showcase/firststep/beanDefinition.xml", "firstJob", "aaa=hoge"}); }