diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java index 3f09ea8390..8f635ed76b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2021 the original author or authors. + * Copyright 2006-2022 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. @@ -35,6 +35,7 @@ import org.springframework.batch.repeat.RepeatStatus; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.support.ScopeNotActiveException; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -117,7 +118,9 @@ public void testIntentionallyBlowUpOnMissingContextWithProxyTargetClass() throws SimpleHolder value = context.getBean(SimpleHolder.class); assertEquals("JOB", value.call()); }); - assertTrue(expectedException.getMessage().contains("job scope")); + assertTrue(expectedException instanceof ScopeNotActiveException); + String message = expectedException.getCause().getMessage(); + assertTrue(message.contains("job scope")); } @Test @@ -128,7 +131,9 @@ public void testIntentionallyBlowupWithForcedInterface() throws Exception { SimpleHolder value = context.getBean(SimpleHolder.class); assertEquals("JOB", value.call()); }); - assertTrue(expectedException.getMessage().contains("job scope")); + assertTrue(expectedException instanceof ScopeNotActiveException); + String message = expectedException.getCause().getMessage(); + assertTrue(message.contains("job scope")); } @Test @@ -148,7 +153,9 @@ public void testIntentionallyBlowUpOnMissingContextWithInterface() throws Except Callable value = context.getBean(Callable.class); assertEquals("JOB", value.call()); }); - assertTrue(expectedException.getMessage().contains("job scope")); + assertTrue(expectedException instanceof ScopeNotActiveException); + String message = expectedException.getCause().getMessage(); + assertTrue(message.contains("job scope")); } public void init(Class... config) throws Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java index 994c1b403b..4eb5cfd2fe 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2021 the original author or authors. + * Copyright 2006-2022 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. @@ -28,6 +28,7 @@ import org.springframework.batch.repeat.RepeatStatus; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.support.ScopeNotActiveException; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -116,7 +117,9 @@ public void testIntentionallyBlowUpOnMissingContextWithProxyTargetClass() throws SimpleHolder value = context.getBean(SimpleHolder.class); assertEquals("STEP", value.call()); }); - assertTrue(expectedException.getMessage().contains("step scope")); + assertTrue(expectedException instanceof ScopeNotActiveException); + String message = expectedException.getCause().getMessage(); + assertTrue(message.contains("step scope")); } @Test @@ -127,7 +130,9 @@ public void testIntentionallyBlowupWithForcedInterface() throws Exception { SimpleHolder value = context.getBean(SimpleHolder.class); assertEquals("STEP", value.call()); }); - assertTrue(expectedException.getMessage().contains("step scope")); + assertTrue(expectedException instanceof ScopeNotActiveException); + String message = expectedException.getCause().getMessage(); + assertTrue(message.contains("step scope")); } @Test @@ -148,7 +153,9 @@ public void testIntentionallyBlowUpOnMissingContextWithInterface() throws Except Callable value = context.getBean(Callable.class); assertEquals("STEP", value.call()); }); - assertTrue(expectedException.getMessage().contains("step scope")); + assertTrue(expectedException instanceof ScopeNotActiveException); + String message = expectedException.getCause().getMessage(); + assertTrue(message.contains("step scope")); } public void init(Class... config) throws Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/ChunkElementParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/ChunkElementParserTests.java index d28c863681..120c0033b0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/ChunkElementParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/ChunkElementParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2022 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. @@ -180,7 +180,7 @@ public void testProcessorNonTransactionalNotAllowedWithTransactionalReader() thr fail("Expected BeanCreationException"); } catch (BeanCreationException e) { - String msg = e.getMessage(); + String msg = e.getRootCause().getMessage(); assertTrue("Wrong message: " + msg, msg.contains("The field 'processor-transactional' cannot be false if 'reader-transactional")); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobParserExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobParserExceptionTests.java index 1bddb0f54c..14b0cde801 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobParserExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobParserExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2014 the original author or authors. + * Copyright 2009-2022 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. @@ -58,7 +58,7 @@ public void testNextOutOfScope() { fail("Error expected"); } catch (BeanCreationException e) { - String message = e.getMessage(); + String message = e.getRootCause().getMessage(); assertTrue("Wrong message: " + message, message .matches(".*Missing state for \\[StateTransition: \\[state=.*s2, pattern=\\*, next=.*s3\\]\\]")); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java index 16c5836056..4759ae010e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2021 the original author or authors. + * Copyright 2006-2022 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. @@ -622,8 +622,8 @@ public void write(List item) throws Exception { StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); repository.add(stepExecution); step.execute(stepExecution); - String message = stepExecution.getFailureExceptions().get(0).getMessage(); - assertTrue("Wrong message: " + message, message.contains("Write error - planned but not skippable.")); + String message = stepExecution.getFailureExceptions().get(0).getCause().getMessage(); + assertEquals("Wrong message: " + message, "Write error - planned but not skippable.", message); List expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("")); assertEquals(expectedOutput, written); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ChunkMessageItemWriterIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ChunkMessageItemWriterIntegrationTests.java index 526cda85ea..76e2b30fa4 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ChunkMessageItemWriterIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ChunkMessageItemWriterIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 the original author or authors. + * Copyright 2021-2022 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. @@ -79,7 +79,7 @@ public class ChunkMessageItemWriterIntegrationTests { @Before public void setUp() throws Exception { - EmbeddedDatabase embeddedDatabase = new EmbeddedDatabaseBuilder() + EmbeddedDatabase embeddedDatabase = new EmbeddedDatabaseBuilder().generateUniqueName(true) .addScript("/org/springframework/batch/core/schema-drop-hsqldb.sql") .addScript("/org/springframework/batch/core/schema-hsqldb.sql").build(); DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(embeddedDatabase); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/launch/JobLaunchingGatewayIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/launch/JobLaunchingGatewayIntegrationTests.java index 8104d87a2b..41c150c5cd 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/launch/JobLaunchingGatewayIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/launch/JobLaunchingGatewayIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2022 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. @@ -91,7 +91,7 @@ public void testNoReply() { fail(); } catch (MessagingException e) { - String message = e.getMessage(); + String message = e.getCause().getMessage(); assertTrue("Wrong message: " + message, message.contains("replyChannel")); } Message executionMessage = (Message) responseChannel.receive(1000); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/launch/JobLaunchingMessageHandlerIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/launch/JobLaunchingMessageHandlerIntegrationTests.java index 10ea0ef645..a4e81842f8 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/launch/JobLaunchingMessageHandlerIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/launch/JobLaunchingMessageHandlerIntegrationTests.java @@ -1,3 +1,18 @@ +/* + * Copyright 2008-2022 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.integration.launch; import static org.junit.Assert.assertNotNull; @@ -57,7 +72,7 @@ public void testNoReply() { requestChannel.send(trigger); } catch (MessagingException e) { - String message = e.getMessage(); + String message = e.getCause().getMessage(); assertTrue("Wrong message: " + message, message.contains("replyChannel")); } Message executionMessage = (Message) responseChannel.receive(1000);