- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.5k
Add a description for a job both with the XML and Java configuration styles #4830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            minkukjo
  wants to merge
  6
  commits into
  spring-projects:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
minkukjo:GH-4826
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      88ebaab
              
                GH-4826: Add support for job descriptions
              
              
                minkukjo b200b1e
              
                fix description setting
              
              
                minkukjo 2be4de9
              
                Merge branch 'main' into GH-4826
              
              
                minkukjo 0875802
              
                Merge branch 'main' into GH-4826
              
              
                minkukjo 8f8b674
              
                Merge branch 'main' into GH-4826
              
              
                minkukjo 8b91ae2
              
                Fix conflict
              
              
                minkukjo File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            44 changes: 44 additions & 0 deletions
          
          44 
        
  ...core/src/test/java/org/springframework/batch/core/job/builder/JobXmlDescriptionTests.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Copyright 2020-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. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.springframework.batch.core.job.builder; | ||
|  | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.batch.core.job.Job; | ||
| import org.springframework.batch.core.job.SimpleJob; | ||
| import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|  | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|  | ||
| /** | ||
| * @author Minkuk Jo | ||
| */ | ||
| class JobXmlDescriptionTests { | ||
|  | ||
| @Test | ||
| void testJobDescriptionFromXml() { | ||
| // given | ||
| ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( | ||
| "/org/springframework/batch/core/job/builder/JobXmlDescriptionTests-context.xml"); | ||
|  | ||
| // when | ||
| Job job = context.getBean("job", Job.class); | ||
|  | ||
| // then | ||
| assertThat(job).isInstanceOf(SimpleJob.class); | ||
| assertThat(((SimpleJob) job).getDescription()).isEqualTo("A job that processes football data"); | ||
| } | ||
|  | ||
| } | 
        
          
          
            33 changes: 33 additions & 0 deletions
          
          33 
        
  spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/TestTasklet.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Copyright 2020-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. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.springframework.batch.core.job.builder; | ||
|  | ||
| import org.springframework.batch.core.scope.context.ChunkContext; | ||
| import org.springframework.batch.core.step.StepContribution; | ||
| import org.springframework.batch.core.step.tasklet.Tasklet; | ||
| import org.springframework.batch.repeat.RepeatStatus; | ||
|  | ||
| /** | ||
| * @author Minkuk Jo | ||
| */ | ||
| public class TestTasklet implements Tasklet { | ||
|  | ||
| @Override | ||
| public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) { | ||
| return RepeatStatus.FINISHED; | ||
| } | ||
|  | ||
| } | ||
        
          
          
            46 changes: 46 additions & 0 deletions
          
          46 
        
  ...t/resources/org/springframework/batch/core/job/builder/JobXmlDescriptionTests-context.xml
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <beans xmlns="http://www.springframework.org/schema/beans" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns:batch="http://www.springframework.org/schema/batch" | ||
| xmlns:jdbc="http://www.springframework.org/schema/jdbc" | ||
| xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
| http://www.springframework.org/schema/beans/spring-beans.xsd | ||
| http://www.springframework.org/schema/batch | ||
| http://www.springframework.org/schema/batch/spring-batch.xsd | ||
| http://www.springframework.org/schema/jdbc | ||
| http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"> | ||
|  | ||
| <bean id="job" class="org.springframework.batch.core.job.SimpleJob"> | ||
| <property name="name" value="job"/> | ||
| <property name="description" value="A job that processes football data"/> | ||
| <property name="jobRepository" ref="jobRepository"/> | ||
| <property name="steps"> | ||
| <list> | ||
| <ref bean="step1"/> | ||
| </list> | ||
| </property> | ||
| </bean> | ||
|  | ||
| <bean id="step1" class="org.springframework.batch.core.step.tasklet.TaskletStep"> | ||
| <property name="tasklet" ref="tasklet"/> | ||
| <property name="jobRepository" ref="jobRepository"/> | ||
| <property name="transactionManager" ref="transactionManager"/> | ||
| </bean> | ||
|  | ||
| <bean id="tasklet" class="org.springframework.batch.core.job.builder.TestTasklet"/> | ||
|  | ||
| <jdbc:embedded-database id="dataSource" type="HSQL"> | ||
| <jdbc:script location="classpath:org/springframework/batch/core/schema-hsqldb.sql"/> | ||
| </jdbc:embedded-database> | ||
|  | ||
| <bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"> | ||
| <property name="databaseType" value="hsql"/> | ||
| <property name="dataSource" ref="dataSource"/> | ||
| <property name="transactionManager" ref="transactionManager"/> | ||
| </bean> | ||
|  | ||
| <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> | ||
| <property name="dataSource" ref="dataSource"/> | ||
| </bean> | ||
|  | ||
| </beans> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created this class expecting it to be used globally in my tests, but would it have been better to create it as an inner class in JobXmlDescriptionTests?