01: /*
02: * Copyright 2006-2007, Unitils.org
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.unitils.database.annotations;
17:
18: import static java.lang.annotation.ElementType.TYPE;
19: import static java.lang.annotation.RetentionPolicy.RUNTIME;
20: import static org.unitils.database.util.TransactionMode.DEFAULT;
21: import org.unitils.database.util.TransactionMode;
22:
23: import java.lang.annotation.Inherited;
24: import java.lang.annotation.Retention;
25: import java.lang.annotation.Target;
26:
27: /**
28: * Annotation enabling to specify if tests should be run in a transaction and, if yes, whether at the end of the test,
29: * the transaction should be <i>committed</i> or <i>rollbacked</i>.
30: * <p/>
31: * This annotation can be specified on a class, and is valid for all tests in the annotated class and its subclasses. A
32: * class level annotation overrides the settings of a superclass annotation.
33: * <p/>
34: * The value attribute defines whether the annotated test(s) run in a transaction and, if yes, what will be the
35: * commit/rollback behavior. The default behavior is defined by the unitils property
36: * <code>DatabaseModule.Transactional.value.default</code>. This configured default will be used when the value property
37: * is unspecified or explicitly set to {@link TransactionMode#DEFAULT}.
38: *
39: * @see TransactionMode
40: *
41: * @author Filip Neven
42: * @author Tim Ducheyne
43: */
44: @Target({TYPE})
45: @Retention(RUNTIME)
46: @Inherited
47: public @interface Transactional {
48:
49: /**
50: * Defines whether the annotated test(s) run in a transaction and, if yes, what will be commit/rollback behavior.
51: * The default behavior is defined by the unitils property <code>DatabaseModule.Transactional.value.default</code>.
52: * This configured default will be used when the value property
53: * is unspecified or explicitly set to {@link TransactionMode#DEFAULT}.
54: *
55: * @return The TransactionMode
56: */
57: TransactionMode value() default DEFAULT;
58: }
|