@Test public void testJavaConfig() throws Exception { String[] args = new String[] { "org.springframework.batch.core.launch.support.CommandLineJobRunnerTests$Configuration1", "invalidJobName"}; CommandLineJobRunner.presetSystemExiter(new StubSystemExiter()); CommandLineJobRunner.main(args); assertEquals(1, StubSystemExiter.status); String errorMessage = CommandLineJobRunner.getErrorMessage(); assertTrue("Wrong error message: " + errorMessage, errorMessage.contains("A JobLauncher must be provided. Please add one to the configuration.")); }
@Test public void testInvalidArgs() throws Exception { String[] args = new String[] {}; CommandLineJobRunner.presetSystemExiter(new StubSystemExiter()); CommandLineJobRunner.main(args); assertEquals(1, StubSystemExiter.status); String errorMessage = CommandLineJobRunner.getErrorMessage(); assertTrue("Wrong error message: " + errorMessage, errorMessage.contains("At least 2 arguments are required: JobPath/JobClass and jobIdentifier.")); }