-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document that @DataNeo4jTest does not support transactional tests with a reactive setup #23630
Comments
That test never worked the way you expect. The Test context framework does not have support for
Where have you seen that? |
The newest See here
|
In the orignal SDN rx, there is another |
That's not in the Spring Boot codebase so you shouldn't rely on that. I am aware of what SDN Rx did and I think I've already mentioned that we've decided to go another route. Please read my comment again. I mentioned that this test never worked the way you expect. Let's document the limitation in the meantime. |
Removing |
Is there any workaround to make my testing codes working again? |
@snicoll Return to use |
We've decided to remove |
Another option would be to keep it |
@sbrannen I was confused that why transational became a must in this version? |
@sbrannen AIUI, that won't work as there will be no |
@wilkinsona, I don't think that's the case. In the code above, if the propagation is set to I'll see if I can throw together a simple test case that demonstrates this. |
The following test passes. package example;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.transaction.annotation.Propagation.NOT_SUPPORTED;
@SpringJUnitConfig
@TransactionalSliceTest
@Transactional(propagation = NOT_SUPPORTED)
class NonTransactionalTests {
@Test
void nonTransactional() {
assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isFalse();
}
@Configuration
static class Config {
// no PlatformTransactionManager bean present
}
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Transactional
@interface TransactionalSliceTest {
} If you comment out the
|
Thanks, @sbrannen. I tried with Does never need to be treated differently to not supported? If there's no transaction manager then, presumably, there's never going to be a transaction so you don't need one to enforce never's fail-if-there-is-a-transaction semantics. |
I can understand why you'd think See the Javadoc and reference manual for details.
Good point. I think it would be safe to support TBH, that check was added as a workaround for the removal of the old But it certainly won't hurt to make that change. I'll get that done in time for Spring Framework 5.3 GA (see spring-projects/spring-framework#25909). |
In case of
The fact this test passes with a non reactive transaction manager puzzles me quite a lot. We'll have to investigate a bit more. |
We've changed our mind again based on @sbrannen's feedback and the fact we prefer an extra setup for the minority rather than breaking the mainstream use case. We will have to revisit this arrangement sooner than later which may lead us to remove |
The former SDN rx provides a
@ReactiveDataNeo4jTest
for reactive applications.I am try to use
@DataNeo4jTest
(it declared working with Servlet stack and reactive stack) in the new sample, it failed.Check the test examples: PostRepositoryTest.java
When running this test, I got a transaction exception.
The text was updated successfully, but these errors were encountered: