Skip to content

Commit

Permalink
HSEARCH-4755 Migrate Spring Integration Tests and showcase to Spring …
Browse files Browse the repository at this point in the history
…Boot 3.1.1
  • Loading branch information
marko-bekhta authored and yrodiere committed Jul 3, 2023
1 parent 0637ce4 commit 20003b5
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 27 deletions.
5 changes: 3 additions & 2 deletions integrationtest/mapper/orm-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jta-atomikos</artifactId>
<groupId>com.atomikos</groupId>
<artifactId>transactions-spring-boot3-starter</artifactId>
<version>${version.com.atomikos}</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void useSingleSearchSessionFromMultipleThreads() {
assertThat( entityFromThread1_2 ).returns( entityFromThread1_1.getId(), IndexedEntity::getId );
assertThat( entityFromThread1_2 ).isSameAs( entityFromThread1_1 );

// Same call from another thread: another underlying session is used, so we should a different entity instance
// Same call from another thread: another underlying session is used, so we should get a different entity instance
ThreadPoolExecutor executorService = new ThreadPoolExecutor(
1, 1, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>( 10 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringRunner.class)
@SpringBootTest
// Adding a property here is just a "workaround" to make sure that a different context is used for this test
// otherwise there can be build errors when running all the tests via maven.
@SpringBootTest(properties = "spring.jta.atomikos.datasource.bean-name=hsearch-datasource1")
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class TransactionIT {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ spring.jpa:
use_second_level_cache: false
use_query_cache: false

spring.jta.bitronix:
datasource:
unique-name: xaDataSource
allow-local-transactions: true
min-pool-size: 5
max-pool-size: 100
properties:
journal: 'null'
spring:
jta:
atomikos:
datasource:
borrow-connection-timeout: 3000
local-transaction-mode: true # allow-local-transactions ?
min-pool-size: 5
max-pool-size: 100
properties:
transaction-manager-unique-name: xaDataSource
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ spring.jpa:
session.events.auto: org.hibernate.search.integrationtest.spring.jta.timeout.TimeoutSessionEventListener
search:
background_failure_handler: org.hibernate.search.integrationtest.spring.jta.timeout.TimeoutFailureCollector

spring.jta.atomikos:
atomikos:
properties:
defaultJtaTimeout: 1000
default-jta-timeout: 1000
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ logging.level:
# Default environment variable values for IDEs that are unable to extract them from the maven-failsafe configuration
# These values are overridden when running tests from Intellij IDEA or directly from Maven
JDBC_URL: jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1

# since atomikos connection pool has a max size set to 1 ...
# we will not be able to execute more than one transaction at a time, leading to errors in tests
spring:
jta:
atomikos:
datasource:
bean-name: hsearch-datasource
min-pool-size: 2
max-pool-size: 10

21 changes: 17 additions & 4 deletions integrationtest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,39 @@
<module>mapper/pojo-standalone-realbackend</module>
<module>mapper/orm</module>
<module>mapper/orm-cdi</module>
<!-- <module>mapper/orm-spring</module>-->
<module>mapper/orm-envers</module>
<module>mapper/orm-realbackend</module>
<module>mapper/orm-coordination-outbox-polling</module>
<module>mapper/orm-batch-jsr352</module>
<module>performance</module>
<!-- <module>showcase/library</module>-->
<module>v5migrationhelper/engine</module>
<module>v5migrationhelper/orm</module>
</modules>

<profiles>
<profile>
<id>javaModuleITs</id>
<id>springITs</id>
<activation>
<property>
<name>java-version.test.release</name>
<value>!8</value>
<value>!11</value>
</property>
</activation>
<modules>
<!-- Spring Boot 3 requires at minimum JDK 17. Hence, we want to ignore these modules on JDK 11: -->
<module>mapper/orm-spring</module>
<module>showcase/library</module>
</modules>
</profile>
<profile>
<!--
We want to keep these module path tests within their own profile,
so we can easily exclude building them all in some scenarios like eclipse compiler profile etc.
-->
<id>javaModuleITs</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<modules>
<module>java/modules/orm-elasticsearch</module>
<module>java/modules/orm-lucene</module>
Expand Down
12 changes: 4 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@
<version.org.google.guava>31.1-jre</version.org.google.guava>

<!-- >>> Spring integration tests -->
<version.org.springframework.boot>2.7.7</version.org.springframework.boot>
<version.org.springframework.boot>3.1.1</version.org.springframework.boot>
<!-- Spring Boot 3 Atomikos starter and related libs version: -->
<version.com.atomikos>6.0.0</version.com.atomikos>

<!-- Maven plugins versions -->

Expand Down Expand Up @@ -2500,10 +2502,6 @@
-Djdk.attach.allowAttachSelf=true
-Dnet.bytebuddy.experimental=true
</surefire.jvm.args.java-version>
<!-- Spring isn't ready for JDK20 yet -->
<failsafe.spring.skip>true</failsafe.spring.skip>
<!-- impsort-maven-plugin doesn't work with JDK20 yet -->
<!-- See https://github.com/javaparser/javaparser/blob/master/javaparser-core/src/main/java/com/github/javaparser/ParserConfiguration.java#L169 -->
<format.skip>true</format.skip>
</properties>
</profile>
Expand All @@ -2522,8 +2520,6 @@
-Djdk.attach.allowAttachSelf=true
-Dnet.bytebuddy.experimental=true
</surefire.jvm.args.java-version>
<!-- Spring isn't ready for JDK21 yet -->
<failsafe.spring.skip>true</failsafe.spring.skip>
<!-- impsort-maven-plugin doesn't work with JDK21 yet -->
<format.skip>true</format.skip>
</properties>
Expand All @@ -2543,7 +2539,7 @@
-Djdk.attach.allowAttachSelf=true
-Dnet.bytebuddy.experimental=true
</surefire.jvm.args.java-version>
<!-- Spring isn't ready for JDK22 yet -->
<!-- Spring Boot 3 isn't ready for JDK22 yet -->
<failsafe.spring.skip>true</failsafe.spring.skip>
<!-- impsort-maven-plugin doesn't work with JDK22 yet -->
<format.skip>true</format.skip>
Expand Down

0 comments on commit 20003b5

Please sign in to comment.