org.springframework.batch.item.ParseException Java Examples
The following examples show how to use
org.springframework.batch.item.ParseException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LecturerMappingReaderTest.java From olat with Apache License 2.0 | 9 votes |
@Test public void read_twoLecturersList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { List<Lecturer> twoLecturersList = new ArrayList<Lecturer>(); Lecturer lecturerMock1 = mock(Lecturer.class); Lecturer lecturerMock2 = mock(Lecturer.class); twoLecturersList.add(lecturerMock1); twoLecturersList.add(lecturerMock2); when(daoManagerMock.getAllLecturers()).thenReturn(twoLecturersList); lecturerMappingReaderTestObject.init(); // The first read delivers the first lecturer assertNotNull(lecturerMappingReaderTestObject.read()); // The second read delivers the second lecturer assertNotNull(lecturerMappingReaderTestObject.read()); // The third read delivers null assertNull(lecturerMappingReaderTestObject.read()); }
Example #2
Source File: CantonConfig.java From SpringBootBucket with MIT License | 6 votes |
/** * step步骤,包含ItemReader,ItemProcessor和ItemWriter * * @param stepBuilderFactory * @param reader * @param writer * @param processor * @return */ @Bean(name = "cantonStep1") public Step cantonStep1(StepBuilderFactory stepBuilderFactory, @Qualifier("cantonReader") ItemReader<Canton> reader, @Qualifier("cantonWriter") ItemWriter<Canton> writer, @Qualifier("cantonProcessor") ItemProcessor<Canton, Canton> processor) { return stepBuilderFactory .get("cantonStep1") .<Canton, Canton>chunk(5000)//批处理每次提交5000条数据 .reader(reader)//给step绑定reader .processor(processor)//给step绑定processor .writer(writer)//给step绑定writer .faultTolerant() .retry(Exception.class) // 重试 .noRetry(ParseException.class) .retryLimit(1) //每条记录重试一次 .skip(Exception.class) .skipLimit(200) //一共允许跳过200次异常 // .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好 // .throttleLimit(10) //并发任务数为 10,默认为4 .build(); }
Example #3
Source File: MetricsTestItemReader.java From spring-boot-starter-batch-web with Apache License 2.0 | 6 votes |
@Override public Item read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { if (readerTransactional) { businessMetrics.increment(MetricNames.READ_COUNT.getName()); businessMetrics.submit(MetricNames.READ_GAUGE.getName(), 5); } else { businessMetrics.incrementNonTransactional(MetricNames.READ_COUNT.getName()); businessMetrics.submitNonTransactional(MetricNames.READ_GAUGE.getName(), 5); } Item item = delegate.read(); if (item != null && item.getActions().contains(Action.FAIL_ON_READ)) { throw new MetricsTestException(Action.FAIL_ON_READ); } LOGGER.debug("Read item: {}", item); return item; }
Example #4
Source File: StudentMappingReaderTest.java From olat with Apache License 2.0 | 6 votes |
@Test public void read_twoStudentsList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { List<Student> twoStudentsList = new ArrayList<Student>(); Student studentMock1 = mock(Student.class); Student studentMock2 = mock(Student.class); twoStudentsList.add(studentMock1); twoStudentsList.add(studentMock2); when(daoManagerMock.getAllStudents()).thenReturn(twoStudentsList); studentMappingReaderTestObject.init(); // The first read delivers the first student assertNotNull(studentMappingReaderTestObject.read()); // The second read delivers the second student assertNotNull(studentMappingReaderTestObject.read()); // The third read delivers null assertNull(studentMappingReaderTestObject.read()); }
Example #5
Source File: SynchronizationReaderTest.java From olat with Apache License 2.0 | 6 votes |
@Test public void read_twoCoursesList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { when(daoManagerMock.chekImportedData()).thenReturn(true); List<Long> CreatedSapCourcesIds = new ArrayList<Long>(); CreatedSapCourcesIds.add(100L); CreatedSapCourcesIds.add(200L); when(daoManagerMock.getAllCreatedSapCourcesIds()).thenReturn(CreatedSapCourcesIds); CampusCourseImportTO courseMock1 = mock(CampusCourseImportTO.class); CampusCourseImportTO courseMock2 = mock(CampusCourseImportTO.class); when(daoManagerMock.getSapCampusCourse(100L)).thenReturn(courseMock1); when(daoManagerMock.getSapCampusCourse(200L)).thenReturn(courseMock2); synchronizationReaderTestObject.init(); // The first read delivers the first course assertNotNull(synchronizationReaderTestObject.read()); // The second read delivers the second course assertNotNull(synchronizationReaderTestObject.read()); // The third read delivers null assertNull(synchronizationReaderTestObject.read()); }
Example #6
Source File: SeedMultiResourceItemReader.java From seed with Apache License 2.0 | 6 votes |
/** * Reads the next item, jumping to next resource if necessary. */ @Override public T read() throws Exception, UnexpectedInputException, ParseException { if (noInput) { return null; } // If there is no resource, then this is the first item, set the current // resource to 0 and open the first delegate. if (currentResource == -1) { currentResource = 0; delegate.setResource(resources[currentResource]); delegate.open(new ExecutionContext()); } return readNextItem(); }
Example #7
Source File: AppConfig.java From SpringBootBucket with MIT License | 6 votes |
/** * step步骤,包含ItemReader,ItemProcessor和ItemWriter * * @param stepBuilderFactory * @param reader * @param writer * @param processor * @return */ @Bean(name = "zappStep1") public Step zappStep1(StepBuilderFactory stepBuilderFactory, @Qualifier("appReader") ItemReader<App> reader, @Qualifier("appWriter") ItemWriter<App> writer, @Qualifier("appProcessor") ItemProcessor<App, App> processor) { return stepBuilderFactory .get("zappStep1") .<App, App>chunk(5000)//批处理每次提交5000条数据 .reader(reader)//给step绑定reader .processor(processor)//给step绑定processor .writer(writer)//给step绑定writer .faultTolerant() .retry(Exception.class) // 重试 .noRetry(ParseException.class) .retryLimit(1) //每条记录重试一次 .skip(Exception.class) .skipLimit(200) //一共允许跳过200次异常 // .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好 // .throttleLimit(10) //并发任务数为 10,默认为4 .build(); }
Example #8
Source File: LogConfig.java From SpringBootBucket with MIT License | 6 votes |
/** * step步骤,包含ItemReader,ItemProcessor和ItemWriter * * @param stepBuilderFactory * @param reader * @param writer * @param processor * @return */ @Bean(name = "logStep1") public Step logStep1(StepBuilderFactory stepBuilderFactory, @Qualifier("logReader") ItemReader<Log> reader, @Qualifier("logWriter") ItemWriter<Log> writer, @Qualifier("logProcessor") ItemProcessor<Log, Log> processor) { return stepBuilderFactory .get("logStep1") .<Log, Log>chunk(5000)//批处理每次提交5000条数据 .reader(reader)//给step绑定reader .processor(processor)//给step绑定processor .writer(writer)//给step绑定writer .faultTolerant() .retry(Exception.class) // 重试 .noRetry(ParseException.class) .retryLimit(1) //每条记录重试一次 .skip(Exception.class) .skipLimit(200) //一共允许跳过200次异常 // .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好 // .throttleLimit(10) //并发任务数为 10,默认为4 .build(); }
Example #9
Source File: BudgetVtollConfig.java From SpringBootBucket with MIT License | 6 votes |
/** * step步骤,包含ItemReader,ItemProcessor和ItemWriter * * @param stepBuilderFactory * @param reader * @param writer * @param processor * @return */ @Bean(name = "vtollStep1") public Step vtollStep1(StepBuilderFactory stepBuilderFactory, @Qualifier("vtollReader") ItemReader<BudgetVtoll> reader, @Qualifier("vtollWriter") ItemWriter<BudgetVtoll> writer, @Qualifier("vtollProcessor") ItemProcessor<BudgetVtoll, BudgetVtoll> processor) { return stepBuilderFactory .get("vtollStep1") .<BudgetVtoll, BudgetVtoll>chunk(5000)//批处理每次提交5000条数据 .reader(reader)//给step绑定reader .processor(processor)//给step绑定processor .writer(writer)//给step绑定writer .faultTolerant() .retry(Exception.class) // 重试 .noRetry(ParseException.class) .retryLimit(1) //每条记录重试一次 .skip(Exception.class) .skipLimit(200) //一共允许跳过200次异常 // .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好 // .throttleLimit(10) //并发任务数为 10,默认为4 .build(); }
Example #10
Source File: SkipItemReader.java From spring-cloud-task with Apache License 2.0 | 5 votes |
@Override public Object read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { String result = "1"; if (this.failCount < 2) { this.failCount++; throw new IllegalStateException("Reader FOOBAR"); } if (this.finished) { result = null; } this.finished = true; return result; }
Example #11
Source File: SynchronizationReader.java From olat with Apache License 2.0 | 5 votes |
/** * Reads a {@link CampusCourseImportTo} via the {@link DaoManager} with the given course id from the list of the sapCoursesIds. <br> * It returns null at the end of the list of the sapCoursesIds */ public CampusCourseImportTO read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { if (ListUtil.isNotBlank(sapCoursesIds)) { return daoManager.getSapCampusCourse(sapCoursesIds.remove(0)); } return null; }
Example #12
Source File: HelloWorldReader.java From blog with MIT License | 5 votes |
public Object read() throws Exception, UnexpectedInputException, ParseException { Object o = null; if (executionTimes > 0) { executionTimes--; o = new Object(); } return o; }
Example #13
Source File: SynchronizationReaderTest.java From olat with Apache License 2.0 | 4 votes |
@Test public void read_nullCoursesList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { when(daoManagerMock.getAllCreatedSapCources()).thenReturn(null); synchronizationReaderTestObject.init(); assertNull(synchronizationReaderTestObject.read()); }
Example #14
Source File: SynchronizationReaderTest.java From olat with Apache License 2.0 | 4 votes |
@Test public void read_emptyCoursesList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { when(daoManagerMock.getAllCreatedSapCources()).thenReturn(Collections.emptyList()); synchronizationReaderTestObject.init(); assertNull(synchronizationReaderTestObject.read()); }
Example #15
Source File: StudentMappingReaderTest.java From olat with Apache License 2.0 | 4 votes |
@Test public void read_nullStudentsList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { when(daoManagerMock.getAllStudents()).thenReturn(null); studentMappingReaderTestObject.init(); assertNull(studentMappingReaderTestObject.read()); }
Example #16
Source File: StudentMappingReaderTest.java From olat with Apache License 2.0 | 4 votes |
@Test public void read_emptyStudentsList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { when(daoManagerMock.getAllStudents()).thenReturn(Collections.emptyList()); studentMappingReaderTestObject.init(); assertNull(studentMappingReaderTestObject.read()); }
Example #17
Source File: LecturerMappingReaderTest.java From olat with Apache License 2.0 | 4 votes |
@Test public void read_nullLecturersList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { when(daoManagerMock.getAllLecturers()).thenReturn(null); lecturerMappingReaderTestObject.init(); assertNull(lecturerMappingReaderTestObject.read()); }
Example #18
Source File: LecturerMappingReaderTest.java From olat with Apache License 2.0 | 4 votes |
@Test public void read_emptyLecturersList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { when(daoManagerMock.getAllLecturers()).thenReturn(Collections.emptyList()); lecturerMappingReaderTestObject.init(); assertNull(lecturerMappingReaderTestObject.read()); }
Example #19
Source File: AgentCountReader.java From pinpoint with Apache License 2.0 | 4 votes |
@Override public ApplicationAgentsList read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { return queue.poll(); }