List of usage examples for org.springframework.batch.test MetaDataInstanceFactory createStepExecution
public static StepExecution createStepExecution(ExecutionContext executionContext)
From source file:de.langmi.spring.batch.examples.readers.file.flatfileitemreader.FlatFileItemReaderDoInStepscopeTest.java
/** * Test should read succesfully.//w w w . j a v a2s. c o m * * @throws Exception */ @Test public void testSuccessfulReading() throws Exception { // setup Map<String, JobParameter> jobParametersMap = new HashMap<String, JobParameter>(); jobParametersMap.put("time", new JobParameter(System.currentTimeMillis())); jobParametersMap.put("input.file", new JobParameter("file:src/test/resources/input/file/simple/input.txt")); StepExecution execution = MetaDataInstanceFactory.createStepExecution(new JobParameters(jobParametersMap)); int count = StepScopeTestUtils.doInStepScope(execution, new Callable<Integer>() { @Override public Integer call() throws Exception { int count = 0; itemReaderStream.open(new ExecutionContext()); String line; try { while ((line = itemReaderStream.read()) != null) { assertEquals(String.valueOf(count), line); count++; } } finally { itemReaderStream.close(); } return count; } }); assertEquals(EXPECTED_COUNT, count); }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.issues.readers.CsvIssuesReaderTest.java
public StepExecution getStepExecution() { final Map<String, JobParameter> map = new HashMap<String, JobParameter>(); map.put("mantis.filepath", new JobParameter("issuesId.csv")); final StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(new JobParameters(map)); return stepExecution; }
From source file:de.langmi.spring.batch.examples.readers.file.flatfileitemreader.FlatFileItemReaderContextStepScopeTest.java
/** * Mandatory method for stepScope Test./*from w w w .j av a2s.c o m*/ * * @return * @see StepScopeTestExecutionListener */ public StepExecution getStepExection() { Map<String, JobParameter> jobParametersMap = new HashMap<String, JobParameter>(); jobParametersMap.put("time", new JobParameter(System.currentTimeMillis())); jobParametersMap.put("input.file", new JobParameter("file:src/test/resources/input/file/simple/input.txt")); execution = MetaDataInstanceFactory.createStepExecution(new JobParameters(jobParametersMap)); return execution; }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.enums.EnumsReadersTest.java
public StepExecution getStepExecution() { final Map<String, JobParameter> map = new HashMap<String, JobParameter>(); map.put("mantis.username", new JobParameter("toto")); map.put("mantis.password", new JobParameter("passwd")); final StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(new JobParameters(map)); return stepExecution; }