Fix tests catching nested exceptions
These tests started failing after an upstream change in Spring Framework [1]. [1]: https://github.com/spring-projects/spring-framework/issues/25162
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
12bd08de07
commit
451db9a968
@@ -24,7 +24,6 @@ import java.util.concurrent.Callable;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -36,6 +35,7 @@ import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
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;
|
||||
@@ -110,7 +110,6 @@ public class JobScopeConfigurationTests {
|
||||
assertEquals("JOB", value.call());
|
||||
}
|
||||
|
||||
@Ignore // FIXME git bissect and check when this started to fail
|
||||
@Test
|
||||
public void testIntentionallyBlowUpOnMissingContextWithProxyTargetClass() throws Exception {
|
||||
init(JobScopeConfigurationRequiringProxyTargetClass.class);
|
||||
@@ -119,10 +118,11 @@ public class JobScopeConfigurationTests {
|
||||
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"));
|
||||
}
|
||||
|
||||
@Ignore // FIXME git bissect and check when this started to fail
|
||||
@Test
|
||||
public void testIntentionallyBlowupWithForcedInterface() throws Exception {
|
||||
init(JobScopeConfigurationForcingInterfaceProxy.class);
|
||||
@@ -131,7 +131,9 @@ public class JobScopeConfigurationTests {
|
||||
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
|
||||
@@ -142,7 +144,6 @@ public class JobScopeConfigurationTests {
|
||||
assertEquals("JOB", value.call());
|
||||
}
|
||||
|
||||
@Ignore // FIXME git bissect and check when this started to fail
|
||||
@Test
|
||||
public void testIntentionallyBlowUpOnMissingContextWithInterface() throws Exception {
|
||||
init(JobScopeConfigurationWithDefaults.class);
|
||||
@@ -152,7 +153,9 @@ public class JobScopeConfigurationTests {
|
||||
Callable<String> 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 {
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.batch.core.configuration.annotation;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
@@ -29,6 +28,7 @@ import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
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;
|
||||
@@ -108,7 +108,6 @@ public class StepScopeConfigurationTests {
|
||||
assertEquals("STEP", value.call());
|
||||
}
|
||||
|
||||
@Ignore // FIXME git bissect and check when this started to fail
|
||||
@Test
|
||||
public void testIntentionallyBlowUpOnMissingContextWithProxyTargetClass() throws Exception {
|
||||
init(StepScopeConfigurationRequiringProxyTargetClass.class);
|
||||
@@ -118,10 +117,11 @@ public class StepScopeConfigurationTests {
|
||||
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"));
|
||||
}
|
||||
|
||||
@Ignore // FIXME git bissect and check when this started to fail
|
||||
@Test
|
||||
public void testIntentionallyBlowupWithForcedInterface() throws Exception {
|
||||
init(StepScopeConfigurationForcingInterfaceProxy.class);
|
||||
@@ -130,7 +130,9 @@ public class StepScopeConfigurationTests {
|
||||
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
|
||||
@@ -141,7 +143,6 @@ public class StepScopeConfigurationTests {
|
||||
assertEquals("STEP", value.call());
|
||||
}
|
||||
|
||||
@Ignore // FIXME git bissect and check when this started to fail
|
||||
@Test
|
||||
public void testIntentionallyBlowUpOnMissingContextWithInterface() throws Exception {
|
||||
init(StepScopeConfigurationWithDefaults.class);
|
||||
@@ -152,7 +153,9 @@ public class StepScopeConfigurationTests {
|
||||
Callable<String> 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 {
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.Step;
|
||||
@@ -175,7 +174,6 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME git bissect and check when this started to fail
|
||||
public void testProcessorNonTransactionalNotAllowedWithTransactionalReader() throws Exception {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext(
|
||||
@@ -183,7 +181,7 @@ public class ChunkElementParserTests {
|
||||
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"));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.batch.core.configuration.xml;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
@@ -52,7 +51,6 @@ public class JobParserExceptionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME git bissect and check when this started to fail
|
||||
public void testNextOutOfScope() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext(
|
||||
@@ -60,7 +58,7 @@ public class JobParserExceptionTests {
|
||||
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\\]\\]"));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.Map;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
@@ -589,7 +588,6 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
@Ignore // FIXME git bissect and check when this started to fail
|
||||
public void testNonSkippableException() throws Exception {
|
||||
|
||||
// Very specific skippable exception
|
||||
@@ -624,8 +622,8 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
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<String> expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray(""));
|
||||
assertEquals(expectedOutput, written);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 class JobLaunchingGatewayIntegrationTests {
|
||||
fail();
|
||||
}
|
||||
catch (MessagingException e) {
|
||||
String message = e.getMessage();
|
||||
String message = e.getCause().getMessage();
|
||||
assertTrue("Wrong message: " + message, message.contains("replyChannel"));
|
||||
}
|
||||
Message<JobExecution> executionMessage = (Message<JobExecution>) responseChannel.receive(1000);
|
||||
|
||||
@@ -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 class JobLaunchingMessageHandlerIntegrationTests {
|
||||
requestChannel.send(trigger);
|
||||
}
|
||||
catch (MessagingException e) {
|
||||
String message = e.getMessage();
|
||||
String message = e.getCause().getMessage();
|
||||
assertTrue("Wrong message: " + message, message.contains("replyChannel"));
|
||||
}
|
||||
Message<JobExecution> executionMessage = (Message<JobExecution>) responseChannel.receive(1000);
|
||||
|
||||
Reference in New Issue
Block a user