001/*
002 * Copyright 2002-2016 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.annotation;
018
019import java.lang.annotation.Documented;
020import java.lang.annotation.ElementType;
021import java.lang.annotation.Inherited;
022import java.lang.annotation.Retention;
023import java.lang.annotation.RetentionPolicy;
024import java.lang.annotation.Target;
025
026/**
027 * {@code @Commit} is a test annotation that is used to indicate that a
028 * <em>test-managed transaction</em> should be <em>committed</em> after
029 * the test method has completed.
030 *
031 * <p>Consult the class-level Javadoc for
032 * {@link org.springframework.test.context.transaction.TransactionalTestExecutionListener}
033 * for an explanation of <em>test-managed transactions</em>.
034 *
035 * <p>When declared as a class-level annotation, {@code @Commit} defines
036 * the default commit semantics for all test methods within the test class
037 * hierarchy. When declared as a method-level annotation, {@code @Commit}
038 * defines commit semantics for the specific test method, potentially
039 * overriding class-level default commit or rollback semantics.
040 *
041 * <p><strong>Warning</strong>: {@code @Commit} can be used as direct
042 * replacement for {@code @Rollback(false)}; however, it should
043 * <strong>not</strong> be declared alongside {@code @Rollback}. Declaring
044 * {@code @Commit} and {@code @Rollback} on the same test method or on the
045 * same test class is unsupported and may lead to unpredictable results.
046 *
047 * @author Sam Brannen
048 * @since 4.2
049 * @see Rollback
050 * @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
051 */
052@Target({ElementType.TYPE, ElementType.METHOD})
053@Retention(RetentionPolicy.RUNTIME)
054@Documented
055@Inherited
056@Rollback(false)
057public @interface Commit {
058}