Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
474ab7f6
Commit
474ab7f6
authored
Sep 16, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt tests to deprecations in Spring Batch
parent
28b0f64e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
57 deletions
+6
-57
BatchAutoConfigurationTests.java
...boot/autoconfigure/batch/BatchAutoConfigurationTests.java
+1
-52
JobLauncherApplicationRunnerTests.java
...utoconfigure/batch/JobLauncherApplicationRunnerTests.java
+5
-5
No files found.
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java
View file @
474ab7f6
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -35,13 +35,9 @@ import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
...
@@ -35,13 +35,9 @@ import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
import
org.springframework.batch.core.configuration.annotation.EnableBatchProcessing
;
import
org.springframework.batch.core.configuration.annotation.EnableBatchProcessing
;
import
org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor
;
import
org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor
;
import
org.springframework.batch.core.explore.JobExplorer
;
import
org.springframework.batch.core.explore.JobExplorer
;
import
org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean
;
import
org.springframework.batch.core.job.AbstractJob
;
import
org.springframework.batch.core.job.AbstractJob
;
import
org.springframework.batch.core.launch.JobLauncher
;
import
org.springframework.batch.core.launch.JobLauncher
;
import
org.springframework.batch.core.launch.support.SimpleJobLauncher
;
import
org.springframework.batch.core.repository.JobRepository
;
import
org.springframework.batch.core.repository.JobRepository
;
import
org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean
;
import
org.springframework.batch.support.transaction.ResourcelessTransactionManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.DefaultApplicationArguments
;
import
org.springframework.boot.DefaultApplicationArguments
;
...
@@ -105,15 +101,6 @@ class BatchAutoConfigurationTests {
...
@@ -105,15 +101,6 @@ class BatchAutoConfigurationTests {
.
run
((
context
)
->
assertThat
(
context
).
doesNotHaveBean
(
BatchConfigurer
.
class
));
.
run
((
context
)
->
assertThat
(
context
).
doesNotHaveBean
(
BatchConfigurer
.
class
));
}
}
@Test
void
testCustomConfigurationWithNoDatabase
()
{
this
.
contextRunner
.
withUserConfiguration
(
TestCustomConfiguration
.
class
).
run
((
context
)
->
{
assertThat
(
context
).
hasSingleBean
(
JobLauncher
.
class
);
JobExplorer
explorer
=
context
.
getBean
(
JobExplorer
.
class
);
assertThat
(
explorer
.
getJobInstances
(
"job"
,
0
,
100
)).
isEmpty
();
});
}
@Test
@Test
void
testNoBatchConfiguration
()
{
void
testNoBatchConfiguration
()
{
this
.
contextRunner
.
withUserConfiguration
(
EmptyConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
)
this
.
contextRunner
.
withUserConfiguration
(
EmptyConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
)
...
@@ -319,44 +306,6 @@ class BatchAutoConfigurationTests {
...
@@ -319,44 +306,6 @@ class BatchAutoConfigurationTests {
}
}
@EnableBatchProcessing
@TestAutoConfigurationPackage
(
City
.
class
)
static
class
TestCustomConfiguration
implements
BatchConfigurer
{
private
JobRepository
jobRepository
;
private
MapJobRepositoryFactoryBean
factory
=
new
MapJobRepositoryFactoryBean
();
@Override
public
JobRepository
getJobRepository
()
throws
Exception
{
if
(
this
.
jobRepository
==
null
)
{
this
.
factory
.
afterPropertiesSet
();
this
.
jobRepository
=
this
.
factory
.
getObject
();
}
return
this
.
jobRepository
;
}
@Override
public
PlatformTransactionManager
getTransactionManager
()
{
return
new
ResourcelessTransactionManager
();
}
@Override
public
JobLauncher
getJobLauncher
()
{
SimpleJobLauncher
launcher
=
new
SimpleJobLauncher
();
launcher
.
setJobRepository
(
this
.
jobRepository
);
return
launcher
;
}
@Override
public
JobExplorer
getJobExplorer
()
throws
Exception
{
MapJobExplorerFactoryBean
explorer
=
new
MapJobExplorerFactoryBean
(
this
.
factory
);
explorer
.
afterPropertiesSet
();
return
explorer
.
getObject
();
}
}
@Configuration
(
proxyBeanMethods
=
false
)
@Configuration
(
proxyBeanMethods
=
false
)
@EnableBatchProcessing
@EnableBatchProcessing
static
class
NamedJobConfigurationWithRegisteredJob
{
static
class
NamedJobConfigurationWithRegisteredJob
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherApplicationRunnerTests.java
View file @
474ab7f6
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -31,13 +31,11 @@ import org.springframework.batch.core.configuration.annotation.EnableBatchProces
...
@@ -31,13 +31,11 @@ import org.springframework.batch.core.configuration.annotation.EnableBatchProces
import
org.springframework.batch.core.configuration.annotation.JobBuilderFactory
;
import
org.springframework.batch.core.configuration.annotation.JobBuilderFactory
;
import
org.springframework.batch.core.configuration.annotation.StepBuilderFactory
;
import
org.springframework.batch.core.configuration.annotation.StepBuilderFactory
;
import
org.springframework.batch.core.explore.JobExplorer
;
import
org.springframework.batch.core.explore.JobExplorer
;
import
org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean
;
import
org.springframework.batch.core.launch.JobLauncher
;
import
org.springframework.batch.core.launch.JobLauncher
;
import
org.springframework.batch.core.launch.support.RunIdIncrementer
;
import
org.springframework.batch.core.launch.support.RunIdIncrementer
;
import
org.springframework.batch.core.launch.support.SimpleJobLauncher
;
import
org.springframework.batch.core.launch.support.SimpleJobLauncher
;
import
org.springframework.batch.core.repository.JobRepository
;
import
org.springframework.batch.core.repository.JobRepository
;
import
org.springframework.batch.core.repository.JobRestartException
;
import
org.springframework.batch.core.repository.JobRestartException
;
import
org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean
;
import
org.springframework.batch.core.step.tasklet.Tasklet
;
import
org.springframework.batch.core.step.tasklet.Tasklet
;
import
org.springframework.batch.support.transaction.ResourcelessTransactionManager
;
import
org.springframework.batch.support.transaction.ResourcelessTransactionManager
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
...
@@ -201,13 +199,14 @@ class JobLauncherApplicationRunnerTests {
...
@@ -201,13 +199,14 @@ class JobLauncherApplicationRunnerTests {
@Configuration
(
proxyBeanMethods
=
false
)
@Configuration
(
proxyBeanMethods
=
false
)
@EnableBatchProcessing
@EnableBatchProcessing
@SuppressWarnings
(
"deprecation"
)
static
class
BatchConfiguration
implements
BatchConfigurer
{
static
class
BatchConfiguration
implements
BatchConfigurer
{
private
ResourcelessTransactionManager
transactionManager
=
new
ResourcelessTransactionManager
();
private
ResourcelessTransactionManager
transactionManager
=
new
ResourcelessTransactionManager
();
private
JobRepository
jobRepository
;
private
JobRepository
jobRepository
;
private
MapJobRepositoryFactoryBean
jobRepositoryFactory
=
new
MapJobRepositoryFactoryBean
(
private
org
.
springframework
.
batch
.
core
.
repository
.
support
.
MapJobRepositoryFactoryBean
jobRepositoryFactory
=
new
org
.
springframework
.
batch
.
core
.
repository
.
support
.
MapJobRepositoryFactoryBean
(
this
.
transactionManager
);
this
.
transactionManager
);
BatchConfiguration
()
throws
Exception
{
BatchConfiguration
()
throws
Exception
{
...
@@ -238,7 +237,8 @@ class JobLauncherApplicationRunnerTests {
...
@@ -238,7 +237,8 @@ class JobLauncherApplicationRunnerTests {
@Override
@Override
public
JobExplorer
getJobExplorer
()
throws
Exception
{
public
JobExplorer
getJobExplorer
()
throws
Exception
{
return
new
MapJobExplorerFactoryBean
(
this
.
jobRepositoryFactory
).
getObject
();
return
new
org
.
springframework
.
batch
.
core
.
explore
.
support
.
MapJobExplorerFactoryBean
(
this
.
jobRepositoryFactory
).
getObject
();
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment