From f8f5cf2fb40ba02241a2ff8ca4ae5641c5f10766 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Thu, 3 Dec 2020 16:03:49 +0100 Subject: [PATCH] Fix ignored tests --- .../core/listener/ItemListenerErrorTests.java | 17 +++++++++++++---- ...tStepFactoryBeanUnexpectedRollbackTests.java | 4 +--- .../JdbcPagingQueryIntegrationTests.java | 1 - ...AsyncItemProcessorMessagingGatewayTests.java | 5 ++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java index c79ed1c14..42b6fcadb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -21,7 +21,6 @@ import java.util.Collections; import java.util.List; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,6 +30,7 @@ import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.Step; +import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; @@ -52,6 +52,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * BATCH-2322 * * @author Michael Minella + * @author Mahmoud Ben Hassine */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {ItemListenerErrorTests.BatchConfiguration.class}) @@ -93,7 +94,6 @@ public class ItemListenerErrorTests { assertEquals(BatchStatus.COMPLETED, execution.getStatus()); } - @Ignore @Test @DirtiesContext public void testOnReadError() throws Exception { @@ -101,7 +101,16 @@ public class ItemListenerErrorTests { reader.setGoingToFail(true); JobExecution execution = jobLauncher.run(job, new JobParameters()); - assertEquals(BatchStatus.COMPLETED, execution.getStatus()); + assertEquals(BatchStatus.FAILED, execution.getStatus()); + StepExecution stepExecution = execution.getStepExecutions().iterator().next(); + assertEquals(0, stepExecution.getReadCount()); + assertEquals(50, stepExecution.getReadSkipCount()); + List failureExceptions = stepExecution.getFailureExceptions(); + assertEquals(1, failureExceptions.size()); + Throwable failureException = failureExceptions.iterator().next(); + assertEquals("Skip limit of '50' exceeded", failureException.getMessage()); + assertEquals("Error in onReadError.", failureException.getCause().getMessage()); + assertEquals("onReadError caused this Exception", failureException.getCause().getCause().getMessage()); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java index dc2e034a9..175e52788 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2014 the original author or authors. + * Copyright 2010-2020 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. @@ -17,7 +17,6 @@ package org.springframework.batch.core.step.item; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; @@ -56,7 +55,6 @@ public class FaultTolerantStepFactoryBeanUnexpectedRollbackTests { private DataSource dataSource; @Test - @Ignore //FIXME public void testTransactionException() throws Exception { final SkipWriterStub writer = new SkipWriterStub<>(); diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingQueryIntegrationTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingQueryIntegrationTests.java index fd8596d32..8ff6aa8e0 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingQueryIntegrationTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingQueryIntegrationTests.java @@ -174,7 +174,6 @@ public class JdbcPagingQueryIntegrationTests { } @Test - @Ignore public void testJumpToItem() throws Exception { PagingQueryProvider queryProvider = getPagingQueryProvider(); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/async/AsyncItemProcessorMessagingGatewayTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/async/AsyncItemProcessorMessagingGatewayTests.java index def528062..40f75c1c6 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/async/AsyncItemProcessorMessagingGatewayTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/async/AsyncItemProcessorMessagingGatewayTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2020 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. @@ -23,7 +23,6 @@ import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.Future; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.MethodRule; @@ -78,7 +77,7 @@ public class AsyncItemProcessorMessagingGatewayTests { @Autowired private ItemProcessor delegate; - @Test @Ignore // TODO: Need to figure out why the Rule doesn't work with Spring 4 + @Test public void testMultiExecution() throws Exception { processor.setDelegate(delegate); processor.setTaskExecutor(new SimpleAsyncTaskExecutor());