1

I have a microservice where multiple @DataJpaIntegrationTest junit tests are present. As soon as I am adding @EnableBatchProcessing , all junits annotated with @DataJpaIntegrationTest are failing.

Problem seem to be as no transaction is happening.

I am using custom batch configurer to use Map based JobRepository utilizing Resourceless transactionManager.

@DataJpaIntegrationTest looks as below:

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@SpringBootTest
@Transactional
@AutoConfigureDataJpa
@AutoConfigureTestDatabase
@AutoConfigureTestEntityManager
@TestPropertySource(properties = {
        "spring.cloud.stream.function.definition="
})
public @interface DataJpaIntegrationTest {
}

Let me know if further details are required

I got the root cause of the problem but unaware of the solution. As soon as I removed custom batch configurer , everything started working fine.

However, @DataJpaTest is still failing with below reason

"eventSource":"org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer","message":"No transaction manager was provided, using a DataSourceTransactionManager"

How can I have the jpa transaction intact while using map based repository.

user2800089
  • 2,015
  • 6
  • 26
  • 47
  • Have you had any dice with this, I am haping the same problem, inserts being delayed and unit tests failing? – Jim Oct 30 '20 at 12:22
  • @Jim I don't remember clearly but when I could not find any concrete solution , i moved to testcontainers instead of in-memory db – user2800089 Feb 13 '21 at 17:43

0 Answers0