Fix tests

This commit is contained in:
Mahmoud Ben Hassine
2025-06-09 15:43:52 +02:00
parent 72694e628d
commit e35c87ccdd
4 changed files with 10 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.configuration.JobLocator;
import org.springframework.batch.core.configuration.JobRegistry;
import org.springframework.batch.core.configuration.support.ApplicationContextFactory;
import org.springframework.batch.core.configuration.support.AutomaticJobRegistrar;
import org.springframework.batch.core.configuration.support.GenericApplicationContextFactory;
@@ -71,7 +71,7 @@ class JobLoaderConfigurationTests {
System.arraycopy(config, 0, configs, 1, config.length);
configs[0] = DataSourceConfiguration.class;
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configs);
Job job = jobName == null ? context.getBean(Job.class) : context.getBean(JobLocator.class).getJob(jobName);
Job job = jobName == null ? context.getBean(Job.class) : context.getBean(JobRegistry.class).getJob(jobName);
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
JobExecution execution = jobLauncher.run(job,
new JobParametersBuilder().addLong("run.id", (long) (Math.random() * Long.MAX_VALUE))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.configuration.ListableJobLocator;
import org.springframework.batch.core.configuration.JobRegistry;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -34,7 +34,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
public class JobRegistryJobParserTests implements ApplicationContextAware {
@Autowired
private ListableJobLocator jobRegistry;
private JobRegistry jobRegistry;
private ApplicationContext applicationContext;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import java.util.HashMap;
import java.util.Map;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.configuration.ListableJobLocator;
import org.springframework.batch.core.configuration.JobRegistry;
import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.BeansException;
@@ -32,7 +32,7 @@ import org.springframework.util.Assert;
public class DefaultJobLoader implements JobLoader, ApplicationContextAware {
private ListableJobLocator registry;
private JobRegistry registry;
private ApplicationContext applicationContext;
@@ -43,7 +43,7 @@ public class DefaultJobLoader implements JobLoader, ApplicationContextAware {
this.applicationContext = applicationContext;
}
public void setRegistry(ListableJobLocator registry) {
public void setRegistry(JobRegistry registry) {
this.registry = registry;
}

View File

@@ -6,10 +6,6 @@
<import resource="classpath:data-source-context.xml" />
<bean class="org.springframework.batch.core.configuration.support.JobRegistrySmartInitializingSingleton">
<property name="jobRegistry" ref="jobRegistry"/>
</bean>
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JdbcJobRepositoryFactoryBean"
p:dataSource-ref="dataSource" p:transactionManager-ref="transactionManager"/>