diff --git a/spring-batch-infrastructure/pom.xml b/spring-batch-infrastructure/pom.xml
index c4beeca27..56448ec1c 100644
--- a/spring-batch-infrastructure/pom.xml
+++ b/spring-batch-infrastructure/pom.xml
@@ -103,6 +103,10 @@
com.fasterxml.jackson.core
jackson-core
+
+ org.slf4j
+ slf4j-api
+
@@ -146,18 +150,36 @@
spring-data-commons
${spring-data-commons.version}
true
+
+
+ org.slf4j
+ slf4j-api
+
+
org.springframework.data
spring-data-mongodb
${spring-data-mongodb.version}
true
+
+
+ org.slf4j
+ slf4j-api
+
+
org.springframework.data
spring-data-jpa
${spring-data-jpa.version}
true
+
+
+ org.slf4j
+ slf4j-api
+
+
org.mongodb
@@ -170,6 +192,12 @@
spring-ldap-core
${spring-ldap.version}
true
+
+
+ org.slf4j
+ slf4j-api
+
+
org.springframework.ldap
@@ -355,12 +383,6 @@
${mockito.version}
test
-
- org.apache.logging.log4j
- log4j-core
- ${log4j.version}
- test
-
org.hibernate.validator
hibernate-validator
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java
index 042a845a9..43b9ff289 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2022 the original author or authors.
+ * Copyright 2009-2023 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.
@@ -52,7 +52,7 @@ public abstract class AbstractDatabaseItemStreamItemReaderTests extends Abstract
* Sub-classes can override this and create their own context.
*/
protected void initializeContext() throws Exception {
- ctx = new ClassPathXmlApplicationContext("org/springframework/batch/item/database/data-source-context.xml");
+ ctx = new ClassPathXmlApplicationContext("data-source-context.xml");
}
@Test
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractGenericDataSourceItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractGenericDataSourceItemReaderIntegrationTests.java
index 4487f78c1..a3d08e246 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractGenericDataSourceItemReaderIntegrationTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractGenericDataSourceItemReaderIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2022 the original author or authors.
+ * Copyright 2010-2023 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,8 +23,9 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
* from database. Uses a common test context and HSQLDB database.
*
* @author Thomas Risberg
+ * @author Mahmoud Ben Hassine
*/
-@SpringJUnitConfig(locations = "data-source-context.xml")
+@SpringJUnitConfig(locations = "classpath:data-source-context.xml")
abstract class AbstractGenericDataSourceItemReaderIntegrationTests
extends AbstractDataSourceItemReaderIntegrationTests {
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorProjectionItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorProjectionItemReaderIntegrationTests.java
index deceae0ab..e79849849 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorProjectionItemReaderIntegrationTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorProjectionItemReaderIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2022 the original author or authors.
+ * Copyright 2008-2023 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,8 +35,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
* Tests for {@link HibernateCursorItemReader} using {@link StatelessSession}.
*
* @author Robert Kasanicky
+ * @author Mahmoud Ben Hassine
*/
-@SpringJUnitConfig(locations = "data-source-context.xml")
+@SpringJUnitConfig(locations = "classpath:data-source-context.xml")
class HibernateCursorProjectionItemReaderIntegrationTests {
@Autowired
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaCursorItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaCursorItemReaderCommonTests.java
index 8fe20bfdc..1a5a069e2 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaCursorItemReaderCommonTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaCursorItemReaderCommonTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 the original author or authors.
+ * Copyright 2020-2023 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.
@@ -30,7 +30,7 @@ public class JpaCursorItemReaderCommonTests extends AbstractDatabaseItemStreamIt
protected ItemReader getItemReader() throws Exception {
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
factoryBean.setDataSource(getDataSource());
- factoryBean.setPersistenceUnitName("bar");
+ factoryBean.setPersistenceUnitName("foo");
factoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
factoryBean.afterPropertiesSet();
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderIntegrationTests.java
index d6e14ebad..0ce01a85b 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderIntegrationTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2021 the original author or authors.
+ * Copyright 2008-2023 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.
@@ -37,7 +37,7 @@ public class JpaPagingItemReaderIntegrationTests extends AbstractGenericDataSour
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
factoryBean.setDataSource(dataSource);
factoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
- factoryBean.setPersistenceUnitName("bar");
+ factoryBean.setPersistenceUnitName("foo");
factoryBean.afterPropertiesSet();
EntityManagerFactory entityManagerFactory = factoryBean.getObject();
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderNativeQueryIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderNativeQueryIntegrationTests.java
index 841bb3c68..82d8e72d4 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderNativeQueryIntegrationTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderNativeQueryIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2022 the original author or authors.
+ * Copyright 2010-2023 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.
@@ -75,7 +75,7 @@ public class JpaPagingItemReaderNativeQueryIntegrationTests extends AbstractPagi
@Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL)
- .addScript("org/springframework/batch/item/database/init-foo-schema-hsqldb.sql")
+ .addScript("org/springframework/batch/item/database/init-foo-schema.sql")
.generateUniqueName(true)
.build();
}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderCommonTests.java
index a5b7190c4..b8034a410 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderCommonTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderCommonTests.java
@@ -16,6 +16,7 @@
package org.springframework.batch.item.database;
import org.hsqldb.types.Types;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
@@ -26,6 +27,7 @@ import org.springframework.jdbc.core.SqlParameter;
import static org.junit.jupiter.api.Assertions.assertThrows;
+@Disabled("see FIXME in init-foo-schema.sql")
class StoredProcedureItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests {
@Override
@@ -41,8 +43,7 @@ class StoredProcedureItemReaderCommonTests extends AbstractDatabaseItemStreamIte
@Override
protected void initializeContext() {
- ctx = new ClassPathXmlApplicationContext(
- "org/springframework/batch/item/database/stored-procedure-context.xml");
+ ctx = new ClassPathXmlApplicationContext("data-source-context.xml");
}
@Test
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderIntegrationTests.java
index 6a216699c..65afab37b 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderIntegrationTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2022 the original author or authors.
+ * Copyright 2010-2023 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.
@@ -15,15 +15,18 @@
*/
package org.springframework.batch.item.database;
+import org.junit.jupiter.api.Disabled;
+
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.sample.Foo;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
-@SpringJUnitConfig(locations = "stored-procedure-context.xml")
+@Disabled("see FIXME in init-foo-schema.sql")
+@SpringJUnitConfig(locations = "classpath:data-source-context.xml")
public class StoredProcedureItemReaderIntegrationTests extends AbstractDataSourceItemReaderIntegrationTests {
@Override
- protected ItemReader createItemReader() throws Exception {
+ protected ItemReader createItemReader() {
StoredProcedureItemReader reader = new StoredProcedureItemReader<>();
reader.setDataSource(dataSource);
reader.setProcedureName("read_foos");
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/HibernateCursorItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/HibernateCursorItemReaderBuilderTests.java
index 1c8422c8a..0611e6b53 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/HibernateCursorItemReaderBuilderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/HibernateCursorItemReaderBuilderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-2022 the original author or authors.
+ * Copyright 2017-2023 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.
@@ -45,6 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Michael Minella
+ * @author Mahmoud Ben Hassine
*/
class HibernateCursorItemReaderBuilderTests {
@@ -219,8 +220,7 @@ class HibernateCursorItemReaderBuilderTests {
DataSourceInitializer dataSourceInitializer = new DataSourceInitializer();
dataSourceInitializer.setDataSource(dataSource);
- Resource create = new ClassPathResource(
- "org/springframework/batch/item/database/init-foo-schema-hsqldb.sql");
+ Resource create = new ClassPathResource("org/springframework/batch/item/database/init-foo-schema.sql");
dataSourceInitializer.setDatabasePopulator(new ResourceDatabasePopulator(create));
return dataSourceInitializer;
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/HibernatePagingItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/HibernatePagingItemReaderBuilderTests.java
index 869ac644a..843cc867b 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/HibernatePagingItemReaderBuilderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/HibernatePagingItemReaderBuilderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-2022 the original author or authors.
+ * Copyright 2017-2023 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.
@@ -206,8 +206,7 @@ class HibernatePagingItemReaderBuilderTests {
DataSourceInitializer dataSourceInitializer = new DataSourceInitializer();
dataSourceInitializer.setDataSource(dataSource);
- Resource create = new ClassPathResource(
- "org/springframework/batch/item/database/init-foo-schema-hsqldb.sql");
+ Resource create = new ClassPathResource("org/springframework/batch/item/database/init-foo-schema.sql");
dataSourceInitializer.setDatabasePopulator(new ResourceDatabasePopulator(create));
return dataSourceInitializer;
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JpaCursorItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JpaCursorItemReaderBuilderTests.java
index 4316085c2..d24fca1a7 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JpaCursorItemReaderBuilderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JpaCursorItemReaderBuilderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 the original author or authors.
+ * Copyright 2020-2023 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.
@@ -223,8 +223,7 @@ class JpaCursorItemReaderBuilderTests {
DataSourceInitializer dataSourceInitializer = new DataSourceInitializer();
dataSourceInitializer.setDataSource(dataSource);
- Resource create = new ClassPathResource(
- "org/springframework/batch/item/database/init-foo-schema-hsqldb.sql");
+ Resource create = new ClassPathResource("org/springframework/batch/item/database/init-foo-schema.sql");
dataSourceInitializer.setDatabasePopulator(new ResourceDatabasePopulator(create));
return dataSourceInitializer;
@@ -235,7 +234,7 @@ class JpaCursorItemReaderBuilderTests {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource());
- entityManagerFactoryBean.setPersistenceUnitName("bar");
+ entityManagerFactoryBean.setPersistenceUnitName("foo");
entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
return entityManagerFactoryBean;
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JpaPagingItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JpaPagingItemReaderBuilderTests.java
index f41949f2f..8fce0376b 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JpaPagingItemReaderBuilderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JpaPagingItemReaderBuilderTests.java
@@ -235,8 +235,7 @@ class JpaPagingItemReaderBuilderTests {
DataSourceInitializer dataSourceInitializer = new DataSourceInitializer();
dataSourceInitializer.setDataSource(dataSource);
- Resource create = new ClassPathResource(
- "org/springframework/batch/item/database/init-foo-schema-hsqldb.sql");
+ Resource create = new ClassPathResource("org/springframework/batch/item/database/init-foo-schema.sql");
dataSourceInitializer.setDatabasePopulator(new ResourceDatabasePopulator(create));
return dataSourceInitializer;
@@ -247,7 +246,7 @@ class JpaPagingItemReaderBuilderTests {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource());
- entityManagerFactoryBean.setPersistenceUnitName("bar");
+ entityManagerFactoryBean.setPersistenceUnitName("foo");
entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
return entityManagerFactoryBean;
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/StoredProcedureItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/StoredProcedureItemReaderBuilderTests.java
index 5d0be260d..57bf5d032 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/StoredProcedureItemReaderBuilderTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/StoredProcedureItemReaderBuilderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-2022 the original author or authors.
+ * Copyright 2017-2023 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,27 +17,15 @@ package org.springframework.batch.item.database.builder;
import javax.sql.DataSource;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import test.jdbc.datasource.DataSourceInitializer;
-import test.jdbc.datasource.DerbyDataSourceFactoryBean;
-import test.jdbc.datasource.DerbyShutdownBean;
+import org.mockito.Mockito;
-import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.database.FooRowMapper;
import org.springframework.batch.item.database.StoredProcedureItemReader;
import org.springframework.batch.item.sample.Foo;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.core.ArgumentPreparedStatementSetter;
import org.springframework.jdbc.core.SqlParameter;
-import org.springframework.jdbc.support.JdbcTransactionManager;
import org.springframework.test.util.ReflectionTestUtils;
-import org.springframework.transaction.PlatformTransactionManager;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -50,39 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*/
class StoredProcedureItemReaderBuilderTests {
- private DataSource dataSource;
-
- private ConfigurableApplicationContext context;
-
- @BeforeEach
- void setUp() {
- this.context = new AnnotationConfigApplicationContext(TestDataSourceConfiguration.class);
- this.dataSource = (DataSource) this.context.getBean("dataSource");
- }
-
- @AfterEach
- void tearDown() {
- this.context.close();
- }
-
- @Test
- void testSunnyScenario() throws Exception {
- StoredProcedureItemReader reader = new StoredProcedureItemReaderBuilder().name("foo_reader")
- .dataSource(this.dataSource)
- .procedureName("read_foos")
- .rowMapper(new FooRowMapper())
- .verifyCursorPosition(false)
- .build();
-
- reader.open(new ExecutionContext());
-
- Foo item1 = reader.read();
- assertEquals(1, item1.getId());
- assertEquals("bar1", item1.getName());
- assertEquals(1, item1.getValue());
-
- reader.close();
- }
+ private final DataSource dataSource = Mockito.mock(DataSource.class);
@Test
void testConfiguration() {
@@ -123,28 +79,6 @@ class StoredProcedureItemReaderBuilderTests {
assertFalse((Boolean) ReflectionTestUtils.getField(reader, "ignoreWarnings"));
}
- @Test
- void testNoSaveState() throws Exception {
- StoredProcedureItemReader reader = new StoredProcedureItemReaderBuilder().dataSource(this.dataSource)
- .procedureName("read_foos")
- .rowMapper(new FooRowMapper())
- .verifyCursorPosition(false)
- .saveState(false)
- .build();
-
- ExecutionContext executionContext = new ExecutionContext();
- reader.open(executionContext);
-
- reader.read();
- reader.read();
-
- reader.update(executionContext);
-
- assertEquals(0, executionContext.size());
-
- reader.close();
- }
-
@Test
void testValidation() {
var builder = new StoredProcedureItemReaderBuilder();
@@ -166,49 +100,4 @@ class StoredProcedureItemReaderBuilderTests {
assertEquals("A rowmapper is required", exception.getMessage());
}
- @Configuration
- public static class TestDataSourceConfiguration {
-
- @Bean
- public DerbyDataSourceFactoryBean dataSource() {
- DerbyDataSourceFactoryBean derbyDataSourceFactoryBean = new DerbyDataSourceFactoryBean();
-
- derbyDataSourceFactoryBean.setDataDirectory("target/derby-home");
-
- return derbyDataSourceFactoryBean;
- }
-
- @Bean
- public DerbyShutdownBean dbShutdown(DataSource dataSource) {
- DerbyShutdownBean shutdownBean = new DerbyShutdownBean();
-
- shutdownBean.setDataSource(dataSource);
-
- return shutdownBean;
- }
-
- @Bean
- public PlatformTransactionManager transactionManager(DataSource dataSource) {
- JdbcTransactionManager transactionManager = new JdbcTransactionManager();
-
- transactionManager.setDataSource(dataSource);
-
- return transactionManager;
- }
-
- @Bean
- public DataSourceInitializer initializer(DataSource dataSource) {
- DataSourceInitializer initializer = new DataSourceInitializer();
-
- initializer.setDataSource(dataSource);
- initializer.setInitScripts(new ClassPathResource[] {
- new ClassPathResource("org/springframework/batch/item/database/init-foo-schema-derby.sql") });
- initializer.setDestroyScripts(new ClassPathResource[] {
- new ClassPathResource("org/springframework/batch/item/database/drop-foo-schema-derby.sql") });
-
- return initializer;
- }
-
- }
-
}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/HibernateNativeQueryProviderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/HibernateNativeQueryProviderIntegrationTests.java
index b1cf762d9..a8a20696f 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/HibernateNativeQueryProviderIntegrationTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/HibernateNativeQueryProviderIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2022 the original author or authors.
+ * Copyright 2006-2023 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.
@@ -39,8 +39,9 @@ import org.springframework.transaction.annotation.Transactional;
/**
* @author Anatoly Polinsky
* @author Dave Syer
+ * @author Mahmoud Ben Hassine
*/
-@SpringJUnitConfig(locations = "../data-source-context.xml")
+@SpringJUnitConfig(locations = "classpath:data-source-context.xml")
class HibernateNativeQueryProviderIntegrationTests {
@Autowired
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandlerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandlerTests.java
index 458d03bbb..fcdf70080 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandlerTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandlerTests.java
@@ -18,21 +18,11 @@ package org.springframework.batch.repeat.exception;
import java.io.StringWriter;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.WriterAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.classify.ClassifierSupport;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.exception.LogOrRethrowExceptionHandler.Level;
+import org.springframework.classify.ClassifierSupport;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -46,19 +36,6 @@ class LogOrRethrowExceptionHandlerTests {
private final RepeatContext context = null;
- @BeforeEach
- void setUp() {
- Logger logger = LoggerFactory.getLogger(LogOrRethrowExceptionHandler.class);
- LoggerContext loggerContext = (LoggerContext) LogManager.getContext();
- Configuration configuration = loggerContext.getConfiguration();
-
- LoggerConfig rootLoggerConfig = configuration.getLoggerConfig(logger.getName());
- rootLoggerConfig.getAppenders().forEach((name, appender) -> rootLoggerConfig.removeAppender(name));
- Appender appender = WriterAppender.createAppender(PatternLayout.createDefaultLayout(), null, writer,
- "TESTWriter", false, false);
- rootLoggerConfig.addAppender(appender, org.apache.logging.log4j.Level.DEBUG, null);
- }
-
@Test
void testRuntimeException() {
Exception exception = assertThrows(RuntimeException.class,
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeIntegrationTests.java
index 536bb22cc..71451f7b5 100644
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeIntegrationTests.java
+++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/DatabaseTypeIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2022 the original author or authors.
+ * Copyright 2006-2023 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.
@@ -16,30 +16,36 @@
package org.springframework.batch.support;
+import javax.sql.DataSource;
+
import org.junit.jupiter.api.Test;
-import javax.sql.DataSource;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Dave Syer
+ * @author Mahmoud Ben Hassine
*
*/
class DatabaseTypeIntegrationTests {
@Test
void testH2() throws Exception {
- DataSource dataSource = DatabaseTypeTestUtils.getDataSource(org.h2.Driver.class,
- "jdbc:h2:file:./target/data/sample");
+ DataSource dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2)
+ .generateUniqueName(true)
+ .build();
assertEquals(DatabaseType.H2, DatabaseType.fromMetaData(dataSource));
dataSource.getConnection();
}
@Test
void testDerby() throws Exception {
- DataSource dataSource = DatabaseTypeTestUtils.getDataSource(org.apache.derby.jdbc.EmbeddedDriver.class,
- "jdbc:derby:./target/derby-home/test;create=true", "sa", "");
+ DataSource dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.DERBY)
+ .generateUniqueName(true)
+ .build();
assertEquals(DatabaseType.DERBY, DatabaseType.fromMetaData(dataSource));
dataSource.getConnection();
}
diff --git a/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyDataSourceFactoryBean.java b/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyDataSourceFactoryBean.java
deleted file mode 100644
index f8274543e..000000000
--- a/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyDataSourceFactoryBean.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2010-2018 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 test.jdbc.datasource;
-
-import java.io.File;
-
-import javax.sql.DataSource;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-
-public class DerbyDataSourceFactoryBean extends AbstractFactoryBean {
-
- private static Log logger = LogFactory.getLog(DerbyDataSourceFactoryBean.class);
-
- private String dataDirectory = "target/derby-home";
-
- public void setDataDirectory(String dataDirectory) {
- this.dataDirectory = dataDirectory;
- }
-
- @Override
- protected DataSource createInstance() throws Exception {
- File directory = new File(dataDirectory);
- System.setProperty("derby.system.home", directory.getCanonicalPath());
- System.setProperty("derby.storage.fileSyncTransactionLog", "true");
- System.setProperty("derby.storage.pageCacheSize", "100");
-
- final EmbeddedDataSource ds = new EmbeddedDataSource();
- ds.setDatabaseName("target/derbydb");
- ds.setCreateDatabase("create");
-
- logger.info("Created instance of " + ds.toString());
-
- return ds;
- }
-
- @Override
- public Class getObjectType() {
- return DataSource.class;
- }
-
-}
diff --git a/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyShutdownBean.java b/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyShutdownBean.java
deleted file mode 100644
index ce88d402b..000000000
--- a/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyShutdownBean.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2010-2023 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 test.jdbc.datasource;
-
-import java.sql.SQLException;
-
-import javax.sql.DataSource;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.springframework.beans.factory.DisposableBean;
-
-public class DerbyShutdownBean implements DisposableBean {
-
- private static Log logger = LogFactory.getLog(DerbyShutdownBean.class);
-
- private DataSource dataSource;
-
- private boolean isShutdown = false;
-
- public void setDataSource(DataSource dataSource) {
- this.dataSource = dataSource;
- }
-
- @Override
- public void destroy() throws Exception {
- logger.info("Attempting Derby database shut down on: " + dataSource);
- if (!isShutdown && dataSource != null && dataSource instanceof EmbeddedDataSource ds) {
- try {
- ds.setShutdownDatabase("shutdown");
- ds.getConnection();
- }
- catch (SQLException except) {
- if (except.getSQLState().equals("08006")) {
- // SQLState derby throws when shutting down the database
- logger.info("Derby database is now shut down.");
- isShutdown = true;
- }
- else {
- logger.error("Problem shutting down Derby " + except.getMessage());
- }
- }
- }
- }
-
-}
diff --git a/spring-batch-infrastructure/src/test/java/test/jdbc/proc/derby/TestProcedures.java b/spring-batch-infrastructure/src/test/java/test/jdbc/proc/derby/TestProcedures.java
deleted file mode 100644
index f4f61f3bc..000000000
--- a/spring-batch-infrastructure/src/test/java/test/jdbc/proc/derby/TestProcedures.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2010 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 test.jdbc.proc.derby;
-
-import java.sql.*;
-
-/**
- * @author trisberg
- *
- * CALL SQLJ.install_jar('testproc.jar', 'APP.TESTPROC', 0); CALL
- * SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', 'APP.TESTPROC');
- *
- * CALL SQLJ.replace_jar('testproc.jar', 'APP.TESTPROC');
- *
- * CALL SQLJ.remove_jar('APP.TESTPROC', 0)
- *
- */
-
-public class TestProcedures {
-
- public static void readFoos(ResultSet[] rs) throws SQLException {
- String SQL = "SELECT id, name, value FROM T_FOOS";
- Connection conn = DriverManager.getConnection("jdbc:default:connection");
- PreparedStatement ps1 = conn.prepareStatement(SQL);
- rs[0] = ps1.executeQuery();
- }
-
- public static void readSomeFoos(int fromId, int toId, ResultSet[] rs) throws SQLException {
- String SQL = "SELECT id, name, value FROM T_FOOS WHERE id between ? and ?";
- Connection conn = DriverManager.getConnection("jdbc:default:connection");
- PreparedStatement ps2 = conn.prepareStatement(SQL);
- ps2.setInt(1, fromId);
- ps2.setInt(2, toId);
- rs[0] = ps2.executeQuery();
- }
-
-}
diff --git a/spring-batch-infrastructure/src/test/resources/META-INF/persistence.xml b/spring-batch-infrastructure/src/test/resources/META-INF/persistence.xml
index c5f634cbf..bb489174a 100644
--- a/spring-batch-infrastructure/src/test/resources/META-INF/persistence.xml
+++ b/spring-batch-infrastructure/src/test/resources/META-INF/persistence.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence https://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
-
+
org.springframework.batch.item.sample.Foo
true
diff --git a/spring-batch-infrastructure/src/test/resources/batch-derby.properties b/spring-batch-infrastructure/src/test/resources/batch-derby.properties
deleted file mode 100644
index b4d4053b3..000000000
--- a/spring-batch-infrastructure/src/test/resources/batch-derby.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# Placeholders batch.*
-# for Derby:
-batch.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
-batch.jdbc.url=jdbc:derby:target/derby-home/test;create=true
-batch.jdbc.user=app
-batch.jdbc.password=
-batch.jdbc.testWhileIdle=false
-batch.jdbc.validationQuery=
-batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-derby.sql
-batch.schema.script=classpath:org/springframework/batch/item/database/init-foo-schema-derby.sql
-batch.business.schema.script=classpath:/org/springframework/batch/jms/init.sql
-batch.data.source.init=true
-batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer
-batch.database.incrementer.parent=columnIncrementerParent
-batch.verify.cursor.position=false
diff --git a/spring-batch-infrastructure/src/test/resources/batch-hana.properties b/spring-batch-infrastructure/src/test/resources/batch-hana.properties
deleted file mode 100644
index f1adc3049..000000000
--- a/spring-batch-infrastructure/src/test/resources/batch-hana.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# Placeholders batch.*
-# for SAP HANA:
-batch.jdbc.driver=com.sap.db.jdbc.Driver
-batch.jdbc.url=jdbc:sap://localhost:39015/
-batch.jdbc.user=SPRING_TEST
-batch.jdbc.password=Spr1ng_test
-batch.jdbc.testWhileIdle=false
-batch.jdbc.validationQuery=
-batch.schema.script=classpath:org/springframework/batch/item/database/init-foo-schema-hana.sql
-batch.business.schema.script=classpath:/org/springframework/batch/jms/init.sql
-batch.data.source.init=true
-batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.HanaSequenceMaxValueIncrementer
-batch.database.incrementer.parent=sequenceIncrementerParent
-batch.verify.cursor.position=true
diff --git a/spring-batch-infrastructure/src/test/resources/batch-hsql.properties b/spring-batch-infrastructure/src/test/resources/batch-hsql.properties
deleted file mode 100644
index 548eb7f8f..000000000
--- a/spring-batch-infrastructure/src/test/resources/batch-hsql.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-# Placeholders batch.*
-# for HSQLDB:
-batch.jdbc.driver=org.hsqldb.jdbcDriver
-batch.jdbc.url=jdbc:hsqldb:mem:testdb;sql.enforce_strict_size=true;hsqldb.tx=mvcc
-# use this one for a separate server process so you can inspect the results
-# (or add it to system properties with -D to override at run time).
-# batch.jdbc.url=jdbc:hsqldb:hsql://localhost:9005/samples
-batch.jdbc.user=sa
-batch.jdbc.password=
-batch.jdbc.testWhileIdle=false
-batch.jdbc.validationQuery=
-batch.schema.script=classpath:org/springframework/batch/item/database/init-foo-schema-hsqldb.sql
-batch.business.schema.script=classpath:/org/springframework/batch/jms/init.sql
-batch.data.source.init=true
-batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer
-batch.database.incrementer.parent=columnIncrementerParent
-batch.verify.cursor.position=true
diff --git a/spring-batch-infrastructure/src/test/resources/batch-oracle.properties b/spring-batch-infrastructure/src/test/resources/batch-oracle.properties
deleted file mode 100644
index f275145d3..000000000
--- a/spring-batch-infrastructure/src/test/resources/batch-oracle.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# Placeholders batch.*
-# for Oracle:
-batch.jdbc.driver=oracle.jdbc.OracleDriver
-batch.jdbc.url=jdbc:oracle:thin:@oracle:1521:xe
-batch.jdbc.user=spring
-batch.jdbc.password=spring
-batch.jdbc.testWhileIdle=false
-batch.jdbc.validationQuery=
-batch.schema.script=classpath:org/springframework/batch/item/database/init-foo-schema-oracle.sql
-batch.business.schema.script=classpath:/org/springframework/batch/jms/init.sql
-batch.data.source.init=true
-batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer
-batch.database.incrementer.parent=sequenceIncrementerParent
-batch.verify.cursor.position=true
diff --git a/spring-batch-infrastructure/src/test/resources/batch-postgres.properties b/spring-batch-infrastructure/src/test/resources/batch-postgres.properties
deleted file mode 100644
index fc4eb9f70..000000000
--- a/spring-batch-infrastructure/src/test/resources/batch-postgres.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# Placeholders batch.*
-# for Oracle:
-batch.jdbc.driver=org.postgresql.Driver
-batch.jdbc.url=jdbc:postgresql://localhost:9432/test
-batch.jdbc.user=test
-batch.jdbc.password=test
-batch.jdbc.testWhileIdle=false
-batch.jdbc.validationQuery=
-batch.schema.script=classpath:org/springframework/batch/item/database/init-foo-schema-postgres.sql
-batch.business.schema.script=classpath:/org/springframework/batch/jms/init.sql
-batch.data.source.init=true
-batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer
-batch.database.incrementer.parent=sequenceIncrementerParent
-batch.verify.cursor.position=true
diff --git a/spring-batch-infrastructure/src/test/resources/data-source-context.xml b/spring-batch-infrastructure/src/test/resources/data-source-context.xml
index ffd2e89e7..6f565074a 100644
--- a/spring-batch-infrastructure/src/test/resources/data-source-context.xml
+++ b/spring-batch-infrastructure/src/test/resources/data-source-context.xml
@@ -1,65 +1,15 @@
+ xmlns:jdbc="http://www.springframework.org/schema/jdbc"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
-
-
-
-
-
- ${batch.business.schema.script}
-
-
-
+
+
+
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/spring-batch-infrastructure/src/test/resources/log4j.properties b/spring-batch-infrastructure/src/test/resources/log4j.properties
deleted file mode 100644
index a53c07b34..000000000
--- a/spring-batch-infrastructure/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-log4j.rootCategory=INFO, stdout
-
-log4j.appender.stdout=org.apache.logging.log4j.core.appender.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.logging.log4j.core.layout.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %p %t [%c] - <%m>%n
-
-#log4j.category.org.springframework.batch=DEBUG
-log4j.category.org.springframework.transaction=INFO
-log4j.category.org.springframework.batch.support.transaction.ResourcelessTransactionManager=INFO
-log4j.category.org.springframework.jdbc.datasource=INFO
diff --git a/spring-batch-infrastructure/src/test/resources/broker.xml b/spring-batch-infrastructure/src/test/resources/message-broker-configuration.xml
similarity index 100%
rename from spring-batch-infrastructure/src/test/resources/broker.xml
rename to spring-batch-infrastructure/src/test/resources/message-broker-configuration.xml
diff --git a/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/JdbcPagingItemReaderCommonTests-context.xml b/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/JdbcPagingItemReaderCommonTests-context.xml
index 93a8eb4af..b1414e130 100644
--- a/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/JdbcPagingItemReaderCommonTests-context.xml
+++ b/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/JdbcPagingItemReaderCommonTests-context.xml
@@ -1,21 +1,7 @@
+ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/JdbcPagingItemReaderConfigTests-context.xml b/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/JdbcPagingItemReaderConfigTests-context.xml
index c709adb34..c477ffdc1 100644
--- a/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/JdbcPagingItemReaderConfigTests-context.xml
+++ b/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/JdbcPagingItemReaderConfigTests-context.xml
@@ -1,17 +1,8 @@
+ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
-
-
-
-
-
-
-
-
+
@@ -19,7 +10,7 @@
-
+