Skip to content

Commit c2ef757

Browse files
committed
Merge branch '2.3.x' into 2.4.x
Closes gh-26460
2 parents 73131e9 + 4444749 commit c2ef757

File tree

7 files changed

+54
-19
lines changed

7 files changed

+54
-19
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ manifest.yml
3636
out
3737
overridedb.*
3838
target
39-
transaction-logs
4039
.flattened-pom.xml
4140
secrets.yml
4241
.gradletasknamecache

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.boot.autoconfigure.orm.jpa;
1818

19+
import java.io.File;
1920
import java.util.HashMap;
2021
import java.util.Map;
2122
import java.util.UUID;
@@ -37,6 +38,7 @@
3738
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3839
import org.springframework.boot.test.context.runner.ContextConsumer;
3940
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
41+
import org.springframework.boot.testsupport.BuildOutput;
4042
import org.springframework.boot.web.servlet.FilterRegistrationBean;
4143
import org.springframework.context.annotation.Bean;
4244
import org.springframework.context.annotation.Configuration;
@@ -69,7 +71,9 @@ abstract class AbstractJpaAutoConfigurationTests {
6971
protected AbstractJpaAutoConfigurationTests(Class<?> autoConfiguredClass) {
7072
this.autoConfiguredClass = autoConfiguredClass;
7173
this.contextRunner = new ApplicationContextRunner()
72-
.withPropertyValues("spring.datasource.generate-unique-name=true")
74+
.withPropertyValues("spring.datasource.generate-unique-name=true",
75+
"spring.jta.log-dir="
76+
+ new File(new BuildOutput(getClass()).getRootLocation(), "transaction-logs"))
7377
.withUserConfiguration(TestConfiguration.class).withConfiguration(AutoConfigurations.of(
7478
DataSourceAutoConfiguration.class, TransactionAutoConfiguration.class, autoConfiguredClass));
7579
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfigurationTests.java

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,6 +48,7 @@
4848
import org.springframework.boot.jta.atomikos.AtomikosDependsOnBeanFactoryPostProcessor;
4949
import org.springframework.boot.jta.atomikos.AtomikosProperties;
5050
import org.springframework.boot.test.util.TestPropertyValues;
51+
import org.springframework.boot.testsupport.BuildOutput;
5152
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
5253
import org.springframework.context.annotation.Bean;
5354
import org.springframework.context.annotation.Configuration;
@@ -70,6 +71,8 @@
7071
// @SuppressWarnings("deprecation")
7172
class JtaAutoConfigurationTests {
7273

74+
private final File buildOutput = new BuildOutput(JtaAutoConfigurationTests.class).getRootLocation();
75+
7376
private AnnotationConfigApplicationContext context;
7477

7578
@AfterEach
@@ -100,7 +103,11 @@ void disableJtaSupport() {
100103

101104
@Test
102105
void atomikosSanityCheck() {
103-
this.context = new AnnotationConfigApplicationContext(JtaProperties.class, AtomikosJtaConfiguration.class);
106+
this.context = new AnnotationConfigApplicationContext();
107+
TestPropertyValues.of("spring.jta.log-dir:" + new File(this.buildOutput, "atomikos-logs"))
108+
.applyTo(this.context);
109+
this.context.register(JtaProperties.class, AtomikosJtaConfiguration.class);
110+
this.context.refresh();
104111
this.context.getBean(AtomikosProperties.class);
105112
this.context.getBean(UserTransactionService.class);
106113
this.context.getBean(UserTransactionManager.class);
@@ -114,7 +121,11 @@ void atomikosSanityCheck() {
114121
@Test
115122
@Deprecated
116123
void bitronixSanityCheck() {
117-
this.context = new AnnotationConfigApplicationContext(JtaProperties.class, BitronixJtaConfiguration.class);
124+
this.context = new AnnotationConfigApplicationContext();
125+
TestPropertyValues.of("spring.jta.log-dir:" + new File(this.buildOutput, "bitronix-logs"))
126+
.applyTo(this.context);
127+
this.context.register(JtaProperties.class, BitronixJtaConfiguration.class);
128+
this.context.refresh();
118129
this.context.getBean(bitronix.tm.Configuration.class);
119130
this.context.getBean(TransactionManager.class);
120131
this.context.getBean(XADataSourceWrapper.class);
@@ -126,7 +137,11 @@ void bitronixSanityCheck() {
126137
@Test
127138
@Deprecated
128139
void defaultBitronixServerId() throws UnknownHostException {
129-
this.context = new AnnotationConfigApplicationContext(BitronixJtaConfiguration.class);
140+
this.context = new AnnotationConfigApplicationContext();
141+
TestPropertyValues.of("spring.jta.log-dir:" + new File(this.buildOutput, "bitronix-logs"))
142+
.applyTo(this.context);
143+
this.context.register(BitronixJtaConfiguration.class);
144+
this.context.refresh();
130145
String serverId = this.context.getBean(bitronix.tm.Configuration.class).getServerId();
131146
assertThat(serverId).isEqualTo(InetAddress.getLocalHost().getHostAddress());
132147
}
@@ -135,7 +150,8 @@ void defaultBitronixServerId() throws UnknownHostException {
135150
@Deprecated
136151
void customBitronixServerId() {
137152
this.context = new AnnotationConfigApplicationContext();
138-
TestPropertyValues.of("spring.jta.transactionManagerId:custom").applyTo(this.context);
153+
TestPropertyValues.of("spring.jta.transactionManagerId:custom",
154+
"spring.jta.log-dir:" + new File(this.buildOutput, "bitronix-logs")).applyTo(this.context);
139155
this.context.register(BitronixJtaConfiguration.class);
140156
this.context.refresh();
141157
String serverId = this.context.getBean(bitronix.tm.Configuration.class).getServerId();
@@ -158,7 +174,8 @@ void defaultAtomikosTransactionManagerName(@TempDir Path dir) throws IOException
158174
void atomikosConnectionFactoryPoolConfiguration() {
159175
this.context = new AnnotationConfigApplicationContext();
160176
TestPropertyValues.of("spring.jta.atomikos.connectionfactory.minPoolSize:5",
161-
"spring.jta.atomikos.connectionfactory.maxPoolSize:10").applyTo(this.context);
177+
"spring.jta.atomikos.connectionfactory.maxPoolSize:10",
178+
"spring.jta.log-dir:" + new File(this.buildOutput, "atomikos-logs")).applyTo(this.context);
162179
this.context.register(AtomikosJtaConfiguration.class, PoolConfiguration.class);
163180
this.context.refresh();
164181
AtomikosConnectionFactoryBean connectionFactory = this.context.getBean(AtomikosConnectionFactoryBean.class);
@@ -171,7 +188,8 @@ void atomikosConnectionFactoryPoolConfiguration() {
171188
void bitronixConnectionFactoryPoolConfiguration() {
172189
this.context = new AnnotationConfigApplicationContext();
173190
TestPropertyValues.of("spring.jta.bitronix.connectionfactory.minPoolSize:5",
174-
"spring.jta.bitronix.connectionfactory.maxPoolSize:10").applyTo(this.context);
191+
"spring.jta.bitronix.connectionfactory.maxPoolSize:10",
192+
"spring.jta.log-dir:" + new File(this.buildOutput, "bitronix-logs")).applyTo(this.context);
175193
this.context.register(BitronixJtaConfiguration.class, PoolConfiguration.class);
176194
this.context.refresh();
177195
org.springframework.boot.jta.bitronix.PoolingConnectionFactoryBean connectionFactory = this.context
@@ -184,7 +202,8 @@ void bitronixConnectionFactoryPoolConfiguration() {
184202
void atomikosDataSourcePoolConfiguration() {
185203
this.context = new AnnotationConfigApplicationContext();
186204
TestPropertyValues
187-
.of("spring.jta.atomikos.datasource.minPoolSize:5", "spring.jta.atomikos.datasource.maxPoolSize:10")
205+
.of("spring.jta.atomikos.datasource.minPoolSize:5", "spring.jta.atomikos.datasource.maxPoolSize:10",
206+
"spring.jta.log-dir:" + new File(this.buildOutput, "atomikos-logs"))
188207
.applyTo(this.context);
189208
this.context.register(AtomikosJtaConfiguration.class, PoolConfiguration.class);
190209
this.context.refresh();
@@ -198,7 +217,8 @@ void atomikosDataSourcePoolConfiguration() {
198217
void bitronixDataSourcePoolConfiguration() {
199218
this.context = new AnnotationConfigApplicationContext();
200219
TestPropertyValues
201-
.of("spring.jta.bitronix.datasource.minPoolSize:5", "spring.jta.bitronix.datasource.maxPoolSize:10")
220+
.of("spring.jta.bitronix.datasource.minPoolSize:5", "spring.jta.bitronix.datasource.maxPoolSize:10",
221+
"spring.jta.log-dir:" + new File(this.buildOutput, "bitronix-logs"))
202222
.applyTo(this.context);
203223
this.context.register(BitronixJtaConfiguration.class, PoolConfiguration.class);
204224
this.context.refresh();
@@ -212,7 +232,8 @@ void bitronixDataSourcePoolConfiguration() {
212232
void atomikosCustomizeJtaTransactionManagerUsingProperties() {
213233
this.context = new AnnotationConfigApplicationContext();
214234
TestPropertyValues
215-
.of("spring.transaction.default-timeout:30", "spring.transaction.rollback-on-commit-failure:true")
235+
.of("spring.transaction.default-timeout:30", "spring.transaction.rollback-on-commit-failure:true",
236+
"spring.jta.log-dir:" + new File(this.buildOutput, "atomikos-logs"))
216237
.applyTo(this.context);
217238
this.context.register(AtomikosJtaConfiguration.class, TransactionAutoConfiguration.class);
218239
this.context.refresh();
@@ -226,7 +247,8 @@ void atomikosCustomizeJtaTransactionManagerUsingProperties() {
226247
void bitronixCustomizeJtaTransactionManagerUsingProperties() {
227248
this.context = new AnnotationConfigApplicationContext();
228249
TestPropertyValues
229-
.of("spring.transaction.default-timeout:30", "spring.transaction.rollback-on-commit-failure:true")
250+
.of("spring.transaction.default-timeout:30", "spring.transaction.rollback-on-commit-failure:true",
251+
"spring.jta.log-dir:" + new File(this.buildOutput, "bitronix-logs"))
230252
.applyTo(this.context);
231253
this.context.register(BitronixJtaConfiguration.class, TransactionAutoConfiguration.class);
232254
this.context.refresh();

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-atomikos/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies {
99
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-artemis"))
1010
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-jpa"))
1111
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-jta-atomikos"))
12+
implementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
1213
if (JavaVersion.current().java9Compatible) {
1314
implementation("jakarta.xml.bind:jakarta.xml.bind-api")
1415
}

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-atomikos/src/test/java/smoketest/atomikos/SampleAtomikosApplicationTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,13 +16,15 @@
1616

1717
package smoketest.atomikos;
1818

19+
import java.io.File;
1920
import java.util.function.Consumer;
2021

2122
import org.junit.jupiter.api.Test;
2223
import org.junit.jupiter.api.extension.ExtendWith;
2324

2425
import org.springframework.boot.test.system.CapturedOutput;
2526
import org.springframework.boot.test.system.OutputCaptureExtension;
27+
import org.springframework.boot.testsupport.BuildOutput;
2628
import org.springframework.util.StringUtils;
2729

2830
import static org.assertj.core.api.Assertions.assertThat;
@@ -37,7 +39,8 @@ class SampleAtomikosApplicationTests {
3739

3840
@Test
3941
void testTransactionRollback(CapturedOutput output) throws Exception {
40-
SampleAtomikosApplication.main(new String[] {});
42+
File logDir = new File(new BuildOutput(getClass()).getRootLocation(), "atomikos-logs");
43+
SampleAtomikosApplication.main(new String[] { "--spring.jta.log-dir=" + logDir });
4144
assertThat(output).satisfies(numberOfOccurrences("---->", 1));
4245
assertThat(output).satisfies(numberOfOccurrences("----> josh", 1));
4346
assertThat(output).satisfies(numberOfOccurrences("Count is 1", 2));

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-bitronix/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies {
99
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-artemis"))
1010
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-jpa"))
1111
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-jta-bitronix"))
12+
implementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
1213
if (JavaVersion.current().java9Compatible) {
1314
implementation("jakarta.xml.bind:jakarta.xml.bind-api")
1415
}

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-bitronix/src/test/java/smoketest/bitronix/SampleBitronixApplicationTests.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package smoketest.bitronix;
1818

19+
import java.io.File;
1920
import java.util.function.Consumer;
2021

2122
import bitronix.tm.resource.jms.PoolingConnectionFactory;
@@ -25,6 +26,7 @@
2526
import org.springframework.boot.SpringApplication;
2627
import org.springframework.boot.test.system.CapturedOutput;
2728
import org.springframework.boot.test.system.OutputCaptureExtension;
29+
import org.springframework.boot.testsupport.BuildOutput;
2830
import org.springframework.context.ApplicationContext;
2931
import org.springframework.util.StringUtils;
3032

@@ -38,9 +40,11 @@
3840
@ExtendWith(OutputCaptureExtension.class)
3941
class SampleBitronixApplicationTests {
4042

43+
private final File jtaLogDir = new File(new BuildOutput(getClass()).getRootLocation(), "bitronix-logs");
44+
4145
@Test
4246
void testTransactionRollback(CapturedOutput output) throws Exception {
43-
SampleBitronixApplication.main(new String[] {});
47+
SampleBitronixApplication.main(new String[] { "--spring.jta.log-dir=" + this.jtaLogDir });
4448
assertThat(output).satisfies(numberOfOccurrences("---->", 1));
4549
assertThat(output).satisfies(numberOfOccurrences("----> josh", 1));
4650
assertThat(output).satisfies(numberOfOccurrences("Count is 1", 2));
@@ -49,7 +53,8 @@ void testTransactionRollback(CapturedOutput output) throws Exception {
4953

5054
@Test
5155
void testExposesXaAndNonXa() {
52-
ApplicationContext context = SpringApplication.run(SampleBitronixApplication.class);
56+
ApplicationContext context = SpringApplication.run(SampleBitronixApplication.class,
57+
"--spring.jta.log-dir=" + this.jtaLogDir);
5358
Object jmsConnectionFactory = context.getBean("jmsConnectionFactory");
5459
Object xaJmsConnectionFactory = context.getBean("xaJmsConnectionFactory");
5560
Object nonXaJmsConnectionFactory = context.getBean("nonXaJmsConnectionFactory");

0 commit comments

Comments
 (0)