@Test public void testMultipleDataSources() { this.applicationContext = SpringApplication.run(new Class[] {JobConfigurationMultipleDataSources.class, PropertyPlaceholderAutoConfiguration.class, EmbeddedDataSourceConfiguration.class, BatchAutoConfiguration.class, TaskBatchAutoConfiguration.class}, ARGS); TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class); Page<TaskExecution> page = taskExplorer.findTaskExecutionsByName("application", new PageRequest(0, 1)); Set<Long> jobExecutionIds = taskExplorer.getJobExecutionIdsByTaskExecutionId(page.iterator().next().getExecutionId()); assertEquals(1, jobExecutionIds.size()); assertEquals(1, taskExplorer.getTaskExecution(jobExecutionIds.iterator().next()).getExecutionId()); }
@Test public void testAutobuiltDataSourceNoJob() { this.applicationContext = SpringApplication.run(new Class[] {NoJobConfiguration.class, PropertyPlaceholderAutoConfiguration.class, EmbeddedDataSourceConfiguration.class, BatchAutoConfiguration.class, TaskBatchAutoConfiguration.class}, ARGS); TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class); Page<TaskExecution> page = taskExplorer.findTaskExecutionsByName("application", PageRequest.of(0, 1)); Set<Long> jobExecutionIds = taskExplorer.getJobExecutionIdsByTaskExecutionId(page.iterator().next().getExecutionId()); assertEquals(0, jobExecutionIds.size()); }
@Test public void testMapBased() { this.applicationContext = SpringApplication.run(new Class[] {JobConfiguration.class, PropertyPlaceholderAutoConfiguration.class, EmbeddedDataSourceConfiguration.class, BatchAutoConfiguration.class, TaskBatchAutoConfiguration.class}, ARGS); TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class); Page<TaskExecution> page = taskExplorer.findTaskExecutionsByName("application", PageRequest.of(0, 1)); Set<Long> jobExecutionIds = taskExplorer.getJobExecutionIdsByTaskExecutionId(page.iterator().next().getExecutionId()); assertEquals(1, jobExecutionIds.size()); assertEquals(1, (long) taskExplorer.getTaskExecutionIdByJobExecutionId(jobExecutionIds.iterator().next())); }
@Test public void testMultipleJobs() { this.applicationContext = SpringApplication.run(new Class[] {EmbeddedDataSourceConfiguration.class, MultipleJobConfiguration.class, PropertyPlaceholderAutoConfiguration.class, BatchAutoConfiguration.class, TaskBatchAutoConfiguration.class}, ARGS); TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class); Page<TaskExecution> page = taskExplorer.findTaskExecutionsByName("application", PageRequest.of(0, 1)); Set<Long> jobExecutionIds = taskExplorer.getJobExecutionIdsByTaskExecutionId(page.iterator().next().getExecutionId()); assertEquals(2, jobExecutionIds.size()); Iterator<Long> jobExecutionIdsIterator = jobExecutionIds.iterator(); assertEquals(1, (long) taskExplorer.getTaskExecutionIdByJobExecutionId(jobExecutionIdsIterator.next())); assertEquals(1, (long) taskExplorer.getTaskExecutionIdByJobExecutionId(jobExecutionIdsIterator.next())); }
private void setupContextForGraph(String graph) { String[] ARGS = new String[] {CLOSE_CONTEXT_ARG, TASK_NAME_ARG, "--graph=" + graph}; this.applicationContext = SpringApplication.run(new Object[] {ComposedRunnerVisitorConfiguration.class, PropertyPlaceholderAutoConfiguration.class, EmbeddedDataSourceConfiguration.class, BatchAutoConfiguration.class, TaskBatchAutoConfiguration.class}, ARGS); }
@Test public void testAutobuiltDataSource() { this.applicationContext = SpringApplication.run(new Class[] {JobConfiguration.class, PropertyPlaceholderAutoConfiguration.class, EmbeddedDataSourceConfiguration.class, BatchAutoConfiguration.class, TaskBatchAutoConfiguration.class}, ARGS); validateContext(); }
@Test public void testFactoryBean() { this.applicationContext = SpringApplication.run(new Class[]{JobFactoryBeanConfiguration.class, PropertyPlaceholderAutoConfiguration.class, EmbeddedDataSourceConfiguration.class, BatchAutoConfiguration.class, TaskBatchAutoConfiguration.class}, ARGS); validateContext(); }