001 /*
002 * $Id: RunTestOn.java,v 1.8 2011/11/21 20:46:43 oboehm Exp $
003 *
004 * Copyright (c) 2010 by Oliver Boehm
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 *
018 * (c)reated 27.01.2010 by oliver (ob@oasd.de)
019 */
020
021 package patterntesting.runtime.annotation;
022
023 import static patterntesting.runtime.NullConstants.NULL_STRING;
024
025 import java.lang.annotation.*;
026
027 /**
028 * You have a test which should be run only on Linux or another operationg
029 * system? Then you can use this annotation to run a single test (put the
030 * annotation in front of the test method) or all tests in this class (put
031 * the annotation in front of the class) on the given platform.
032 *
033 * @see SkipTestOn
034 * @author oliver
035 * @since 1.0 (27.01.2010)
036 */
037 @Documented
038 @Target({ElementType.METHOD, ElementType.TYPE})
039 @Retention(RetentionPolicy.RUNTIME)
040 public @interface RunTestOn {
041
042 /**
043 * Here you can define the name of the operating system or version of the
044 * JDK for which a test should be executed. But it is better to use the
045 * attributes "osName" or "javaVersion" here because otherwise
046 * PatternTesting tries to guess what you mean.
047 * <br/>
048 * Since 1.2 wildcards (*, ?) are supported.
049 *
050 * @see #osName()
051 * @see #javaVersion()
052 */
053 String[] value() default NULL_STRING;
054
055 /**
056 * Should a test be run only on a single platform e.g. on Linux?
057 * Use "Linux" and the test will run only on the Linux platform.
058 * Instead of "Linux" you can use any other operation system. The
059 * format must be the same as returned by the system property "os.name".
060 * Valid values are:
061 * <ul>
062 * <li>"Linux"</li>
063 * <li>"Mac OS X" (for Mac),</li>
064 * <li>"Windows XP"</li>
065 * <li>and others
066 * (see {@link "http://lopica.sourceforge.net/os.html"}).
067 * </li>
068 * </ul>
069 * Multiple values like <code>{ "Linux", "Mac OS X" }</code> are allowed.
070 * If no operation system is given you will get an IllegalArgumentException.
071 * <br/>
072 * The format of this attribute must be the same as returned by system
073 * property "os.name".
074 * <br/>
075 * Since 1.2 wildcards (*, ?) are supported.
076 */
077 String[] osName() default NULL_STRING;
078
079 /**
080 * You want the test only to be run on the Intel architecture?
081 * Then you can use this attribute to limit it on this platform.
082 * You can define a single platform like <code>"x86_64"</code> for an
083 * Intel-Mac with 64 bit or multiple platform like
084 * <code>{ "x86_32", "x86_64" }</code> for Intel Mac with 42 or 64 bit.
085 * <br/>
086 * The format of this attribute must be the same as returned by the ystem
087 * property "os.arch".
088 * <br/>
089 * Since 1.2 wildcards (*, ?) are supported.
090 */
091 String[] osArch() default NULL_STRING;
092
093 /**
094 * You want the test only to be run on a special version of the
095 * operating system? Use this attribute to limit it.
096 * In contradiction to the other attributes the real version must start
097 * with the given version. I.e. if you define "10.6" as version this would
098 * match only real version "10.6.1" or "10.6.2".
099 * <br/>
100 * You can't define a range of versions. But several versions are
101 * allowed. So if you want to run the tests in version 10.6.1 till 10.6.3
102 * define { "10.6.1", "10.6.2", "10.6.3" } as values.
103 * <br/>
104 * Since 1.2 wildcards (*, ?) are supported.
105 */
106 String[] osVersion() default NULL_STRING;
107
108 /**
109 * With this attribute you can express that the test should be run on
110 * the given host(s). You can define the host by its name or by its
111 * IP address.
112 * <br/>
113 * Since 1.2 wildcards (*, ?) are supported.
114 */
115 String[] host() default NULL_STRING;
116
117 /**
118 * You want the test to be run on a special version of the VM, e.g. on
119 * version "1.6.0_17" because you know that on this version there is a bug
120 * that caused your test not to work? Then use this attribute.
121 * <br/>
122 * You can't define a range of executed versions. But you regex (regular
123 * expressions) are allowed. And you can define more than one version
124 * (or regex).
125 * <br/>
126 * The format of this attribute must be the same as returned by the
127 * system property "java.version".
128 * <br/>
129 * Since 1.2 wildcards (*, ?) are supported.
130 */
131 String[] javaVersion() default NULL_STRING;
132
133 /**
134 * You want the test to be run on a special vendor VM? Use this attribute
135 * here. The format of this attribute must be the same as returned by the
136 * system property "java.vendor".
137 * Valid values are:
138 * <ul>
139 * <li>"Apple Inc."</li>
140 * <li>and others</li>
141 * </ul>
142 * <br/>
143 * Since 1.2 wildcards (*, ?) are supported.
144 */
145 String[] javaVendor() default NULL_STRING;
146
147 /**
148 * Does the test should be run only for user "Bob" because he is the only
149 * one who has access to a secret webservice?
150 * Use <code>user="bob"</code> to run this test only for his account.
151 * <br/>
152 * Yep, the new boss of the team, Bill, is also allow to call this
153 * webservice. Ok, use <code>user={"bob", "bill"}</code> skip the test for
154 * both accounts.
155 * <br/>
156 * Since 1.2 wildcards (*, ?) are supported.
157 *
158 * @since 1.1
159 */
160 String[] user() default NULL_STRING;
161
162 /**
163 * You have some tests that runs only if you are online? Define a
164 * property (e.g. <code>property="online"</code>).
165 * If this property is set (and its value is
166 * not "false") the test will be executed if you start the JavaVM with
167 * <code>java -Donline ...</code> or <code>java -Donline=true ...</code>.
168 * <br/>
169 * You can control more than property with this attribute. Then all
170 * properties must be "true" to run the test.
171 * <br/>
172 * Wildcards (*, ?) are not yet supported for system properties.
173 */
174 String[] property() default NULL_STRING;
175
176 }