DataSource dataSource = TestContextTransactionUtils.retrieveDataSource(testContext, dsName); PlatformTransactionManager txMgr = TestContextTransactionUtils.retrieveTransactionManager(testContext, tmName); boolean newTxRequired = (mergedSqlConfig.getTransactionMode() == TransactionMode.ISOLATED); int propagation = (newTxRequired ? TransactionDefinition.PROPAGATION_REQUIRES_NEW : TransactionDefinition.PROPAGATION_REQUIRED); TransactionAttribute txAttr = TestContextTransactionUtils.createDelegatingTransactionAttribute( testContext, new DefaultTransactionAttribute(propagation)); new TransactionTemplate(txMgr, txAttr).execute(status -> {
logBeansException(testContext, ex, PlatformTransactionManager.class); logBeansException(testContext, ex, DataSource.class); return null;
/** * Get the {@linkplain PlatformTransactionManager transaction manager} * to use for the supplied {@linkplain TestContext test context}. * <p>The default implementation simply delegates to * {@link TestContextTransactionUtils#retrieveTransactionManager}. * @param testContext the test context for which the transaction manager * should be retrieved * @return the transaction manager to use, or {@code null} if not found * @throws BeansException if an error occurs while retrieving an explicitly * named transaction manager * @throws IllegalStateException if more than one TransactionManagementConfigurer * exists in the ApplicationContext * @see #getTransactionManager(TestContext, String) */ @Nullable protected PlatformTransactionManager getTransactionManager(TestContext testContext) { return TestContextTransactionUtils.retrieveTransactionManager(testContext, null); }
transactionAttribute = TestContextTransactionUtils.createDelegatingTransactionAttribute(testContext, transactionAttribute);
/** * Get the {@linkplain PlatformTransactionManager transaction manager} * to use for the supplied {@linkplain TestContext test context}. * <p>The default implementation simply delegates to * {@link TestContextTransactionUtils#retrieveTransactionManager}. * @param testContext the test context for which the transaction manager * should be retrieved * @return the transaction manager to use, or {@code null} if not found * @throws BeansException if an error occurs while retrieving an explicitly * named transaction manager * @throws IllegalStateException if more than one TransactionManagementConfigurer * exists in the ApplicationContext * @see #getTransactionManager(TestContext, String) */ @Nullable protected PlatformTransactionManager getTransactionManager(TestContext testContext) { return TestContextTransactionUtils.retrieveTransactionManager(testContext, null); }
transactionAttribute = TestContextTransactionUtils.createDelegatingTransactionAttribute(testContext, transactionAttribute);
DataSource dataSource = TestContextTransactionUtils.retrieveDataSource(testContext, dsName); PlatformTransactionManager txMgr = TestContextTransactionUtils.retrieveTransactionManager(testContext, tmName); boolean newTxRequired = (mergedSqlConfig.getTransactionMode() == TransactionMode.ISOLATED); int propagation = (newTxRequired ? TransactionDefinition.PROPAGATION_REQUIRES_NEW : TransactionDefinition.PROPAGATION_REQUIRED); TransactionAttribute txAttr = TestContextTransactionUtils.createDelegatingTransactionAttribute( testContext, new DefaultTransactionAttribute(propagation)); new TransactionTemplate(txMgr, txAttr).execute(status -> {
logBeansException(testContext, ex, PlatformTransactionManager.class); logBeansException(testContext, ex, PlatformTransactionManager.class); return null;
/** * Get the {@linkplain PlatformTransactionManager transaction manager} * to use for the supplied {@linkplain TestContext test context}. * <p>The default implementation simply delegates to * {@link TestContextTransactionUtils#retrieveTransactionManager}. * @param testContext the test context for which the transaction manager * should be retrieved * @return the transaction manager to use, or {@code null} if not found * @throws BeansException if an error occurs while retrieving an explicitly * named transaction manager * @throws IllegalStateException if more than one TransactionManagementConfigurer * exists in the ApplicationContext * @see #getTransactionManager(TestContext, String) */ protected PlatformTransactionManager getTransactionManager(TestContext testContext) { @SuppressWarnings("deprecation") String tmName = retrieveConfigurationAttributes(testContext).getTransactionManagerName(); return TestContextTransactionUtils.retrieveTransactionManager(testContext, tmName); }
transactionAttribute = TestContextTransactionUtils.createDelegatingTransactionAttribute(testContext, transactionAttribute);
DataSource dataSource = TestContextTransactionUtils.retrieveDataSource(testContext, dsName); PlatformTransactionManager txMgr = TestContextTransactionUtils.retrieveTransactionManager(testContext, tmName); boolean newTxRequired = (mergedSqlConfig.getTransactionMode() == TransactionMode.ISOLATED); int propagation = (newTxRequired ? TransactionDefinition.PROPAGATION_REQUIRES_NEW : TransactionDefinition.PROPAGATION_REQUIRED); TransactionAttribute txAttr = TestContextTransactionUtils.createDelegatingTransactionAttribute( testContext, new DefaultTransactionAttribute(propagation)); new TransactionTemplate(txMgr, txAttr).execute(new TransactionCallbackWithoutResult() {
logBeansException(testContext, ex, PlatformTransactionManager.class); logBeansException(testContext, ex, DataSource.class); return null;
logBeansException(testContext, ex, PlatformTransactionManager.class); logBeansException(testContext, ex, DataSource.class); return null;
logBeansException(testContext, ex, PlatformTransactionManager.class); logBeansException(testContext, ex, PlatformTransactionManager.class); return null;
logBeansException(testContext, ex, PlatformTransactionManager.class); logBeansException(testContext, ex, PlatformTransactionManager.class); return null;