Browse Source
This commit deletes all test annotations from the spring-orm module in order to reduce unnecessary confusion between these "copies" and the real, current versions of such classes in the spring-test module. Furthermore, the legacy abstract JUnit 3.8 base classes and test cases have been refactored accordingly.pull/568/head
Sam Brannen
11 years ago
23 changed files with 129 additions and 1022 deletions
@ -1,51 +0,0 @@
@@ -1,51 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2012 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* <p> |
||||
* Test annotation to indicate that a test method <em>dirties</em> the context |
||||
* for the current test. |
||||
* </p> |
||||
* <p> |
||||
* Using this annotation in conjunction with |
||||
* {@link AbstractAnnotationAwareTransactionalTests} is less error-prone than |
||||
* calling |
||||
* {@link org.springframework.test.AbstractSingleSpringContextTests#setDirty() setDirty()} |
||||
* explicitly because the call to {@code setDirty()} is guaranteed to |
||||
* occur, even if the test failed. If only a particular code path in the test |
||||
* dirties the context, prefer calling {@code setDirty()} explicitly -- |
||||
* and take care! |
||||
* </p> |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Sam Brannen |
||||
* @since 2.0 |
||||
* @see org.springframework.test.AbstractSingleSpringContextTests |
||||
*/ |
||||
@Target( { ElementType.METHOD }) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
public @interface DirtiesContext { |
||||
|
||||
} |
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2007 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Test annotation to indicate that a test method is required to throw the |
||||
* specified exception. |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Sam Brannen |
||||
* @since 2.0 |
||||
*/ |
||||
@Target( { ElementType.METHOD }) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
public @interface ExpectedException { |
||||
|
||||
Class<? extends Throwable> value(); |
||||
|
||||
} |
@ -1,102 +0,0 @@
@@ -1,102 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2012 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Inherited; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* <p> |
||||
* Test annotation to indicate that a test is enabled for a specific testing |
||||
* profile or environment. If the configured {@link ProfileValueSource} returns |
||||
* a matching {@link #value() value} for the provided {@link #name() name}, the |
||||
* test will be enabled. |
||||
* </p> |
||||
* <p> |
||||
* Note: {@link IfProfileValue @IfProfileValue} can be applied at either the |
||||
* class or method level. |
||||
* </p> |
||||
* <p> |
||||
* Examples: when using {@link SystemProfileValueSource} as the |
||||
* {@link ProfileValueSource} implementation, you can configure a test method to |
||||
* run only on Java VMs from Sun Microsystems as follows: |
||||
* </p> |
||||
* |
||||
* <pre class="code"> |
||||
* {@link IfProfileValue @IfProfileValue}(name="java.vendor", value="Sun Microsystems Inc.") |
||||
* testSomething() { |
||||
* // ...
|
||||
* } |
||||
* </pre> |
||||
* |
||||
* <p> |
||||
* You can alternatively configure {@link IfProfileValue @IfProfileValue} with |
||||
* <em>OR</em> semantics for multiple {@link #values() values} as follows |
||||
* (assuming a {@link ProfileValueSource} has been appropriately configured for |
||||
* the "test-groups" name): |
||||
* </p> |
||||
* |
||||
* <pre class="code"> |
||||
* {@link IfProfileValue @IfProfileValue}(name="test-groups", values={"unit-tests", "integration-tests"}) |
||||
* public void testWhichRunsForUnitOrIntegrationTestGroups() { |
||||
* // ...
|
||||
* } |
||||
* </pre> |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Sam Brannen |
||||
* @since 2.0 |
||||
* @see ProfileValueSource |
||||
* @see ProfileValueSourceConfiguration |
||||
* @see ProfileValueUtils |
||||
* @see AbstractAnnotationAwareTransactionalTests |
||||
* @see org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests |
||||
* @see org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests |
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner |
||||
*/ |
||||
@Target({ElementType.TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Inherited |
||||
@Documented |
||||
public @interface IfProfileValue { |
||||
|
||||
/** |
||||
* The {@code name} of the <em>profile value</em> against which to test. |
||||
*/ |
||||
String name(); |
||||
|
||||
/** |
||||
* A single, permissible {@code value} of the <em>profile value</em> |
||||
* for the given {@link #name() name}. |
||||
* <p>Note: Assigning values to both {@link #value()} and {@link #values()} |
||||
* will lead to a configuration conflict. |
||||
*/ |
||||
String value() default ""; |
||||
|
||||
/** |
||||
* A list of all permissible {@code values} of the |
||||
* <em>profile value</em> for the given {@link #name() name}. |
||||
* <p>Note: Assigning values to both {@link #value()} and {@link #values()} |
||||
* will lead to a configuration conflict. |
||||
*/ |
||||
String[] values() default {}; |
||||
|
||||
} |
@ -1,37 +0,0 @@
@@ -1,37 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2007 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Test annotation to indicate that a method is not transactional. |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Sam Brannen |
||||
* @since 2.0 |
||||
*/ |
||||
@Target( { ElementType.METHOD }) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
public @interface NotTransactional { |
||||
|
||||
} |
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2012 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
/** |
||||
* <p> |
||||
* Strategy interface for retrieving <em>profile values</em> for a given |
||||
* testing environment. |
||||
* </p> |
||||
* <p> |
||||
* Concrete implementations must provide a {@code public} no-args |
||||
* constructor. |
||||
* </p> |
||||
* <p> |
||||
* Spring provides the following out-of-the-box implementations: |
||||
* </p> |
||||
* <ul> |
||||
* <li>{@link SystemProfileValueSource}</li> |
||||
* </ul> |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Sam Brannen |
||||
* @since 2.0 |
||||
* @see ProfileValueSourceConfiguration |
||||
* @see IfProfileValue |
||||
* @see ProfileValueUtils |
||||
*/ |
||||
public interface ProfileValueSource { |
||||
|
||||
/** |
||||
* Get the <em>profile value</em> indicated by the specified key. |
||||
* @param key the name of the <em>profile value</em> |
||||
* @return the String value of the <em>profile value</em>, or {@code null} |
||||
* if there is no <em>profile value</em> with that key |
||||
*/ |
||||
String get(String key); |
||||
|
||||
} |
@ -1,56 +0,0 @@
@@ -1,56 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2007 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Inherited; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* <p> |
||||
* ProfileValueSourceConfiguration is a class-level annotation which is used to |
||||
* specify what type of {@link ProfileValueSource} to use when retrieving |
||||
* <em>profile values</em> configured via the |
||||
* {@link IfProfileValue @IfProfileValue} annotation. |
||||
* </p> |
||||
* |
||||
* @author Sam Brannen |
||||
* @since 2.5 |
||||
* @see ProfileValueSource |
||||
* @see IfProfileValue |
||||
* @see ProfileValueUtils |
||||
*/ |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Target(ElementType.TYPE) |
||||
@Inherited |
||||
@Documented |
||||
public @interface ProfileValueSourceConfiguration { |
||||
|
||||
/** |
||||
* <p> |
||||
* The type of {@link ProfileValueSource} to use when retrieving |
||||
* <em>profile values</em>. |
||||
* </p> |
||||
* |
||||
* @see SystemProfileValueSource |
||||
*/ |
||||
Class<? extends ProfileValueSource> value() default SystemProfileValueSource.class; |
||||
|
||||
} |
@ -1,213 +0,0 @@
@@ -1,213 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2012 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
import java.lang.reflect.Method; |
||||
|
||||
import org.apache.commons.logging.Log; |
||||
import org.apache.commons.logging.LogFactory; |
||||
|
||||
import org.springframework.core.annotation.AnnotationUtils; |
||||
import org.springframework.util.Assert; |
||||
import org.springframework.util.ObjectUtils; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
/** |
||||
* General utility methods for working with <em>profile values</em>. |
||||
* |
||||
* @author Sam Brannen |
||||
* @author Juergen Hoeller |
||||
* @since 2.5 |
||||
* @see ProfileValueSource |
||||
* @see ProfileValueSourceConfiguration |
||||
* @see IfProfileValue |
||||
*/ |
||||
public abstract class ProfileValueUtils { |
||||
|
||||
private static final Log logger = LogFactory.getLog(ProfileValueUtils.class); |
||||
|
||||
|
||||
/** |
||||
* Retrieves the {@link ProfileValueSource} type for the specified |
||||
* {@link Class test class} as configured via the |
||||
* {@link ProfileValueSourceConfiguration @ProfileValueSourceConfiguration} |
||||
* annotation and instantiates a new instance of that type. |
||||
* <p> |
||||
* If |
||||
* {@link ProfileValueSourceConfiguration @ProfileValueSourceConfiguration} |
||||
* is not present on the specified class or if a custom |
||||
* {@link ProfileValueSource} is not declared, the default |
||||
* {@link SystemProfileValueSource} will be returned instead. |
||||
* |
||||
* @param testClass The test class for which the ProfileValueSource should |
||||
* be retrieved |
||||
* @return the configured (or default) ProfileValueSource for the specified |
||||
* class |
||||
* @see SystemProfileValueSource |
||||
*/ |
||||
@SuppressWarnings("unchecked") |
||||
public static ProfileValueSource retrieveProfileValueSource(Class<?> testClass) { |
||||
Assert.notNull(testClass, "testClass must not be null"); |
||||
|
||||
Class<ProfileValueSourceConfiguration> annotationType = ProfileValueSourceConfiguration.class; |
||||
ProfileValueSourceConfiguration config = testClass.getAnnotation(annotationType); |
||||
if (logger.isDebugEnabled()) { |
||||
logger.debug("Retrieved @ProfileValueSourceConfiguration [" + config + "] for test class [" |
||||
+ testClass.getName() + "]"); |
||||
} |
||||
|
||||
Class<? extends ProfileValueSource> profileValueSourceType; |
||||
if (config != null) { |
||||
profileValueSourceType = config.value(); |
||||
} |
||||
else { |
||||
profileValueSourceType = (Class<? extends ProfileValueSource>) AnnotationUtils.getDefaultValue(annotationType); |
||||
} |
||||
if (logger.isDebugEnabled()) { |
||||
logger.debug("Retrieved ProfileValueSource type [" + profileValueSourceType + "] for class [" |
||||
+ testClass.getName() + "]"); |
||||
} |
||||
|
||||
ProfileValueSource profileValueSource; |
||||
if (SystemProfileValueSource.class.equals(profileValueSourceType)) { |
||||
profileValueSource = SystemProfileValueSource.getInstance(); |
||||
} |
||||
else { |
||||
try { |
||||
profileValueSource = profileValueSourceType.newInstance(); |
||||
} |
||||
catch (Exception e) { |
||||
if (logger.isWarnEnabled()) { |
||||
logger.warn("Could not instantiate a ProfileValueSource of type [" + profileValueSourceType |
||||
+ "] for class [" + testClass.getName() + "]: using default.", e); |
||||
} |
||||
profileValueSource = SystemProfileValueSource.getInstance(); |
||||
} |
||||
} |
||||
|
||||
return profileValueSource; |
||||
} |
||||
|
||||
/** |
||||
* Determine if the supplied {@code testClass} is <em>enabled</em> |
||||
* in the current environment, as specified by the |
||||
* {@link IfProfileValue @IfProfileValue} annotation at the class level. |
||||
* <p> |
||||
* Defaults to {@code true} if no |
||||
* {@link IfProfileValue @IfProfileValue} annotation is declared. |
||||
* |
||||
* @param testClass the test class |
||||
* @return {@code true} if the test is <em>enabled</em> in the |
||||
* current environment |
||||
*/ |
||||
public static boolean isTestEnabledInThisEnvironment(Class<?> testClass) { |
||||
IfProfileValue ifProfileValue = testClass.getAnnotation(IfProfileValue.class); |
||||
if (ifProfileValue == null) { |
||||
return true; |
||||
} |
||||
ProfileValueSource profileValueSource = retrieveProfileValueSource(testClass); |
||||
return isTestEnabledInThisEnvironment(profileValueSource, ifProfileValue); |
||||
} |
||||
|
||||
/** |
||||
* Determine if the supplied {@code testMethod} is <em>enabled</em> |
||||
* in the current environment, as specified by the |
||||
* {@link IfProfileValue @IfProfileValue} annotation, which may be declared |
||||
* on the test method itself or at the class level. |
||||
* <p> |
||||
* Defaults to {@code true} if no |
||||
* {@link IfProfileValue @IfProfileValue} annotation is declared. |
||||
* |
||||
* @param testMethod the test method |
||||
* @param testClass the test class |
||||
* @return {@code true} if the test is <em>enabled</em> in the |
||||
* current environment |
||||
*/ |
||||
public static boolean isTestEnabledInThisEnvironment(Method testMethod, Class<?> testClass) { |
||||
IfProfileValue ifProfileValue = testMethod.getAnnotation(IfProfileValue.class); |
||||
if (ifProfileValue == null) { |
||||
ifProfileValue = testClass.getAnnotation(IfProfileValue.class); |
||||
if (ifProfileValue == null) { |
||||
return true; |
||||
} |
||||
} |
||||
ProfileValueSource profileValueSource = retrieveProfileValueSource(testClass); |
||||
return isTestEnabledInThisEnvironment(profileValueSource, ifProfileValue); |
||||
} |
||||
|
||||
/** |
||||
* Determine if the supplied {@code testMethod} is <em>enabled</em> |
||||
* in the current environment, as specified by the |
||||
* {@link IfProfileValue @IfProfileValue} annotation, which may be declared |
||||
* on the test method itself or at the class level. |
||||
* <p> |
||||
* Defaults to {@code true} if no |
||||
* {@link IfProfileValue @IfProfileValue} annotation is declared. |
||||
* |
||||
* @param profileValueSource the ProfileValueSource to use to determine if |
||||
* the test is enabled |
||||
* @param testMethod the test method |
||||
* @param testClass the test class |
||||
* @return {@code true} if the test is <em>enabled</em> in the |
||||
* current environment |
||||
*/ |
||||
public static boolean isTestEnabledInThisEnvironment(ProfileValueSource profileValueSource, Method testMethod, |
||||
Class<?> testClass) { |
||||
|
||||
IfProfileValue ifProfileValue = testMethod.getAnnotation(IfProfileValue.class); |
||||
if (ifProfileValue == null) { |
||||
ifProfileValue = testClass.getAnnotation(IfProfileValue.class); |
||||
if (ifProfileValue == null) { |
||||
return true; |
||||
} |
||||
} |
||||
return isTestEnabledInThisEnvironment(profileValueSource, ifProfileValue); |
||||
} |
||||
|
||||
/** |
||||
* Determine if the {@code value} (or one of the {@code values}) |
||||
* in the supplied {@link IfProfileValue @IfProfileValue} annotation is |
||||
* <em>enabled</em> in the current environment. |
||||
* |
||||
* @param profileValueSource the ProfileValueSource to use to determine if |
||||
* the test is enabled |
||||
* @param ifProfileValue the annotation to introspect |
||||
* @return {@code true} if the test is <em>enabled</em> in the |
||||
* current environment |
||||
*/ |
||||
private static boolean isTestEnabledInThisEnvironment(ProfileValueSource profileValueSource, |
||||
IfProfileValue ifProfileValue) { |
||||
|
||||
String environmentValue = profileValueSource.get(ifProfileValue.name()); |
||||
String[] annotatedValues = ifProfileValue.values(); |
||||
if (StringUtils.hasLength(ifProfileValue.value())) { |
||||
if (annotatedValues.length > 0) { |
||||
throw new IllegalArgumentException("Setting both the 'value' and 'values' attributes " |
||||
+ "of @IfProfileValue is not allowed: choose one or the other."); |
||||
} |
||||
annotatedValues = new String[] { ifProfileValue.value() }; |
||||
} |
||||
|
||||
for (String value : annotatedValues) { |
||||
if (ObjectUtils.nullSafeEquals(value, environmentValue)) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -1,43 +0,0 @@
@@ -1,43 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2008 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Test annotation to indicate that a test method should be invoked repeatedly. |
||||
* <p /> |
||||
* Note that the scope of execution to be repeated includes execution of the |
||||
* test method itself as well as any <em>set up</em> or <em>tear down</em> |
||||
* of the test fixture. |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Sam Brannen |
||||
* @since 2.0 |
||||
*/ |
||||
@Target( { ElementType.METHOD }) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
public @interface Repeat { |
||||
|
||||
int value() default 1; |
||||
|
||||
} |
@ -1,47 +0,0 @@
@@ -1,47 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2012 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Test annotation to indicate whether or not the transaction for the annotated |
||||
* test method should be <em>rolled back</em> after the test method has |
||||
* completed. If {@code true}, the transaction will be rolled back; |
||||
* otherwise, the transaction will be committed. |
||||
* |
||||
* @author Sam Brannen |
||||
* @since 2.5 |
||||
*/ |
||||
@Target( { ElementType.METHOD }) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
public @interface Rollback { |
||||
|
||||
/** |
||||
* <p> |
||||
* Whether or not the transaction for the annotated method should be rolled |
||||
* back after the method has completed. |
||||
* </p> |
||||
*/ |
||||
boolean value() default true; |
||||
|
||||
} |
@ -1,59 +0,0 @@
@@ -1,59 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2012 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
import org.springframework.util.Assert; |
||||
|
||||
/** |
||||
* Implementation of {@link ProfileValueSource} which uses system properties as |
||||
* the underlying source. |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Sam Brannen |
||||
* @since 2.0 |
||||
*/ |
||||
public class SystemProfileValueSource implements ProfileValueSource { |
||||
|
||||
private static final SystemProfileValueSource INSTANCE = new SystemProfileValueSource(); |
||||
|
||||
|
||||
/** |
||||
* Obtain the canonical instance of this ProfileValueSource. |
||||
*/ |
||||
public static final SystemProfileValueSource getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Private constructor, enforcing the singleton pattern. |
||||
*/ |
||||
private SystemProfileValueSource() { |
||||
} |
||||
|
||||
/** |
||||
* Get the <em>profile value</em> indicated by the specified key from the |
||||
* system properties. |
||||
* @see System#getProperty(String) |
||||
*/ |
||||
@Override |
||||
public String get(String key) { |
||||
Assert.hasText(key, "'key' must not be empty"); |
||||
return System.getProperty(key); |
||||
} |
||||
|
||||
} |
@ -1,57 +0,0 @@
@@ -1,57 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2008 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.annotation; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* <p> |
||||
* Test-specific annotation to indicate that a test method has to finish |
||||
* execution in a {@link #millis() specified time period}. |
||||
* </p> |
||||
* <p> |
||||
* If the text execution takes longer than the specified time period, then the |
||||
* test is to be considered failed. |
||||
* </p> |
||||
* <p> |
||||
* Note that the time period includes execution of the test method itself, any |
||||
* {@link Repeat repetitions} of the test, and any <em>set up</em> or |
||||
* <em>tear down</em> of the test fixture. |
||||
* </p> |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Sam Brannen |
||||
* @since 2.0 |
||||
* @see Repeat |
||||
* @see AbstractAnnotationAwareTransactionalTests |
||||
*/ |
||||
@Target({ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
public @interface Timed { |
||||
|
||||
/** |
||||
* The maximum amount of time (in milliseconds) that a test execution can |
||||
* take without being marked as failed due to taking too long. |
||||
*/ |
||||
long millis(); |
||||
|
||||
} |
Loading…
Reference in new issue