001/*
002 * Copyright 2002-2015 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.test.context.transaction;
018
019import org.springframework.core.style.ToStringCreator;
020import org.springframework.transaction.PlatformTransactionManager;
021import org.springframework.util.Assert;
022
023/**
024 * Configuration attributes for configuring transactional tests.
025 *
026 * @author Sam Brannen
027 * @author Juergen Hoeller
028 * @since 2.5
029 * @see TransactionConfiguration
030 * @deprecated As of Spring Framework 4.2, this class is officially deprecated
031 * and will be removed when {@code @TransactionConfiguration} is removed.
032 */
033@Deprecated
034public class TransactionConfigurationAttributes {
035
036        private final String transactionManagerName;
037
038        private final boolean defaultRollback;
039
040
041        /**
042         * Construct a new {@code TransactionConfigurationAttributes} instance
043         * using an empty string for the bean name of the
044         * {@link PlatformTransactionManager} and {@code true} for the default
045         * rollback flag.
046         * @see #TransactionConfigurationAttributes(String, boolean)
047         */
048        public TransactionConfigurationAttributes() {
049                this("", true);
050        }
051
052        /**
053         * Construct a new {@code TransactionConfigurationAttributes} instance
054         * from the supplied arguments.
055         * @param transactionManagerName the bean name of the
056         * {@link PlatformTransactionManager} that is to be used to drive
057         * <em>test-managed transactions</em>
058         * @param defaultRollback whether or not <em>test-managed transactions</em>
059         * should be rolled back by default
060         */
061        public TransactionConfigurationAttributes(String transactionManagerName, boolean defaultRollback) {
062                Assert.notNull(transactionManagerName, "transactionManagerName must not be null");
063                this.transactionManagerName = transactionManagerName;
064                this.defaultRollback = defaultRollback;
065        }
066
067
068        /**
069         * Get the bean name of the {@link PlatformTransactionManager} that is to
070         * be used to drive <em>test-managed transactions</em>.
071         */
072        public final String getTransactionManagerName() {
073                return this.transactionManagerName;
074        }
075
076        /**
077         * Whether <em>test-managed transactions</em> should be rolled back by default.
078         * @return the <em>default rollback</em> flag
079         */
080        public final boolean isDefaultRollback() {
081                return this.defaultRollback;
082        }
083
084
085        @Override
086        public String toString() {
087                return new ToStringCreator(this)
088                                .append("transactionManagerName", this.transactionManagerName)
089                                .append("defaultRollback", this.defaultRollback)
090                                .toString();
091        }
092
093}