Skip to content

Commit

Permalink
fix: additional sample test for both transactionManager work together. (
Browse files Browse the repository at this point in the history
#1848)

This pr adds an integration test to `spring-cloud-gcp-data-multi-sample` for the scenario of both Datastore and Spanner Transaction manager working in the same app.
It is a followup on #1412
  • Loading branch information
zhumin8 authored May 22, 2023
1 parent f937b36 commit 219adb3
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;

Expand All @@ -31,7 +32,7 @@
@ExtendWith(SpringExtension.class)
@EnabledIfSystemProperty(named = "it.multisample", matches = "true")
@TestPropertySource("classpath:application-test.properties")
@EnableAutoConfiguration
@SpringBootTest
class MultipleDataModuleIntegrationTest {

// The Spanner Repo
Expand All @@ -40,6 +41,10 @@ class MultipleDataModuleIntegrationTest {
// The Datastore Repo
@Autowired PersonRepository datastorePersonRepository;

@Autowired TraderService traderService;

@Autowired PersonService personService;

@Test
void testMultipleModulesTogether() {

Expand All @@ -55,4 +60,20 @@ void testMultipleModulesTogether() {
assertThat(this.traderRepository.count()).isEqualTo(1L);
assertThat(this.datastorePersonRepository.count()).isEqualTo(1L);
}

@Test
void testMultipleModulesTogetherWithTransaction() {

this.traderService.deleteAll();
this.personService.deleteAll();

assertThat(this.traderService.count()).isZero();
assertThat(this.personService.count()).isZero();

this.traderService.save(new Trader("id1", "trader", "one"));
this.personService.save(new Person(1L, "person1"));

assertThat(this.traderService.count()).isEqualTo(1L);
assertThat(this.personService.count()).isEqualTo(1L);
}
}

0 comments on commit 219adb3

Please sign in to comment.