-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DATAJPA-1023 - StreamExceution now rejects non-transactional execution.
StreamExecution now makes use of the newly introduced SurroundingTransactionDetectingMethodInterceptor to find out about whether the transaction is used in code that already has a transaction running. This is necessary to make sure the Stream returned by the method can actually be consumed as the surrounding transaction keeps the transaction open. Related tickets: DATACMNS-959.
- Loading branch information
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2008-2015 the original author or authors. | ||
* Copyright 2008-2016 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. | ||
|
@@ -22,10 +22,12 @@ | |
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.dao.InvalidDataAccessApiUsageException; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Slice; | ||
|
@@ -37,6 +39,7 @@ | |
import org.springframework.data.repository.query.QueryLookupStrategy; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.transaction.annotation.Propagation; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
/** | ||
|
@@ -68,6 +71,13 @@ public void setUp() { | |
oliver = userRepository.save(new User("Oliver August", "Matthews", "[email protected]")); | ||
} | ||
|
||
@After | ||
public void clearUp() { | ||
|
||
userRepository.deleteAll(); | ||
roleRepository.deleteAll(); | ||
} | ||
|
||
/** | ||
* Tests creation of a simple query. | ||
*/ | ||
|
@@ -234,4 +244,13 @@ public void translatesNotContainsToNotMemberOf() { | |
public void executesQueryWithProjectionContainingReferenceToPluralAttribute() { | ||
assertThat(userRepository.findRolesAndFirstnameBy(), is(notNullValue())); | ||
} | ||
|
||
/** | ||
* @see DATAJPA-1023, DATACMNS-959 | ||
*/ | ||
@Test(expected = InvalidDataAccessApiUsageException.class) | ||
@Transactional(propagation = Propagation.NOT_SUPPORTED) | ||
public void rejectsStreamExecutionIfNoSurroundingTransactionActive() { | ||
userRepository.findAllByCustomQueryAndStream(); | ||
} | ||
} |