JAVA-33535: Fix errors after mockito upgrade. (#16389)
* Fix eureka-client * Fix eureka-server * Fix spring-cloud-zuul * Fix spring-reactive-data-couchbase * Fix and cleanup apache-poi
This commit is contained in:
		
							parent
							
								
									4d6b46699c
								
							
						
					
					
						commit
						f18a5c4472
					
				| @ -14,14 +14,16 @@ import org.springframework.stereotype.Component; | ||||
|   matchIfMissing = true) | ||||
| @Component | ||||
| public class ApplicationRunnerTaskExecutor implements ApplicationRunner { | ||||
|     private TaskService taskService; | ||||
| 
 | ||||
|     private final TaskService taskService; | ||||
| 
 | ||||
|     public ApplicationRunnerTaskExecutor(TaskService taskService) { | ||||
|         this.taskService = taskService; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void run(ApplicationArguments args) throws Exception { | ||||
|     public void run(ApplicationArguments args) { | ||||
|         taskService.execute("application runner task"); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -13,14 +13,14 @@ import org.springframework.stereotype.Component; | ||||
|   matchIfMissing = true) | ||||
| @Component | ||||
| public class CommandLineTaskExecutor implements CommandLineRunner { | ||||
|     private TaskService taskService; | ||||
|     private final TaskService taskService; | ||||
| 
 | ||||
|     public CommandLineTaskExecutor(TaskService taskService) { | ||||
|         this.taskService = taskService; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void run(String... args) throws Exception { | ||||
|     public void run(String... args) { | ||||
|         taskService.execute("command line runner task"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -6,9 +6,9 @@ import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
| public class TaskService { | ||||
|     private static Logger logger = LoggerFactory.getLogger(TaskService.class); | ||||
|     private static final Logger logger = LoggerFactory.getLogger(TaskService.class); | ||||
| 
 | ||||
|     public void execute(String task) { | ||||
|         logger.info("do " + task); | ||||
|         logger.info("do {}", task); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,16 +1,13 @@ | ||||
| package com.baeldung.prevent.commandline.application.runner.execution; | ||||
| 
 | ||||
| import org.junit.jupiter.api.Test; | ||||
| import org.springframework.boot.test.context.SpringBootTest; | ||||
| import org.springframework.boot.test.mock.mockito.SpyBean; | ||||
| 
 | ||||
| import com.baeldung.prevent.commandline.application.runner.execution.ApplicationRunnerTaskExecutor; | ||||
| import com.baeldung.prevent.commandline.application.runner.execution.CommandLineTaskExecutor; | ||||
| 
 | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| 
 | ||||
| import org.junit.jupiter.api.Test; | ||||
| import org.springframework.boot.test.context.SpringBootTest; | ||||
| import org.springframework.boot.test.mock.mockito.SpyBean; | ||||
| 
 | ||||
| @SpringBootTest | ||||
| class RunApplicationIntegrationTest { | ||||
|     @SpyBean | ||||
| @ -21,6 +18,6 @@ class RunApplicationIntegrationTest { | ||||
|     @Test | ||||
|     void whenContextLoads_thenRunnersRun() throws Exception { | ||||
|         verify(applicationRunnerTaskExecutor, times(1)).run(any()); | ||||
|         verify(commandLineTaskExecutor, times(1)).run(any()); | ||||
|         verify(commandLineTaskExecutor, times(1)).run(any(String[].class)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -44,8 +44,18 @@ | ||||
|             <version>${spring-boot.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>net.bytebuddy</groupId> | ||||
|             <artifactId>byte-buddy</artifactId> | ||||
|             <version>${byte-buddy.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <properties> | ||||
|         <byte-buddy.version>1.14.13</byte-buddy.version> | ||||
|     </properties> | ||||
| 
 | ||||
|     <build> | ||||
|         <plugins> | ||||
|             <plugin> | ||||
|  | ||||
| @ -44,8 +44,18 @@ | ||||
|             <version>${spring-boot.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>net.bytebuddy</groupId> | ||||
|             <artifactId>byte-buddy</artifactId> | ||||
|             <version>${byte-buddy.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <properties> | ||||
|         <byte-buddy.version>1.14.13</byte-buddy.version> | ||||
|     </properties> | ||||
| 
 | ||||
|     <build> | ||||
|         <plugins> | ||||
|             <plugin> | ||||
|  | ||||
| @ -60,6 +60,12 @@ | ||||
|             <artifactId>spring-boot-starter-test</artifactId> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>net.bytebuddy</groupId> | ||||
|             <artifactId>byte-buddy</artifactId> | ||||
|             <version>${byte-buddy.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <build> | ||||
| @ -82,6 +88,7 @@ | ||||
|     <properties> | ||||
|         <spring-cloud-dependencies.version>2021.0.3</spring-cloud-dependencies.version> | ||||
|         <spring-cloud-netflix-zuul.version>2.2.7.RELEASE</spring-cloud-netflix-zuul.version> | ||||
|         <byte-buddy.version>1.14.13</byte-buddy.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
| @ -65,6 +65,12 @@ | ||||
|             <version>${couchbaseMock.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>net.bytebuddy</groupId> | ||||
|             <artifactId>byte-buddy</artifactId> | ||||
|             <version>${byte-buddy.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <build> | ||||
| @ -129,6 +135,7 @@ | ||||
|         <maven.compiler.source>11</maven.compiler.source> | ||||
|         <maven.compiler.target>11</maven.compiler.target> | ||||
|         <java.version>11</java.version> | ||||
|         <byte-buddy.version>1.14.13</byte-buddy.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user