From c4b5960c130871aa26b677b133cbe23a78ac03d2 Mon Sep 17 00:00:00 2001
From: Sam Brannen
- * Note: @IfProfileValue can be applied at either the
- * class or method level.
+ * Note: @IfProfileValue can be applied at the class level,
+ * the method level, or both. @IfProfileValue at the class
+ * level overrides method-level usage of @IfProfileValue for
+ * any methods within that class.
*
* 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: *
- * + * *
- * @IfProfileValue(name="java.vendor", value="Sun Microsystems Inc.")
+ * @IfProfileValue(name = "java.vendor", value = "Sun Microsystems Inc.")
* public void testSomething() {
- * // ...
+ * // ...
* }
*
- *
*
* You can alternatively configure @IfProfileValue with
* OR semantics for multiple {@link #values() values} as follows
* (assuming a {@link ProfileValueSource} has been appropriately configured for
* the "test-groups" name):
*
- * @IfProfileValue(name="test-groups", values={"unit-tests", "integration-tests"})
+ * @IfProfileValue(name = "test-groups", values = { "unit-tests", "integration-tests" })
* public void testWhichRunsForUnitOrIntegrationTestGroups() {
- * // ...
+ * // ...
* }
*
- *
+ *
* @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})
+@Target( { ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface IfProfileValue {
/**
- * The name of the profile value against which to test.
+ * The name of the profile value against which to
+ * test.
*/
String name();
/**
* A single, permissible value of the profile value
* for the given {@link #name() name}.
- * Note: Assigning values to both {@link #value()} and {@link #values()} + *
+ * Note: Assigning values to both {@link #value()} and {@link #values()}
* will lead to a configuration conflict.
*/
String value() default "";
@@ -94,7 +96,8 @@ public @interface IfProfileValue {
/**
* A list of all permissible values of the
* profile value for the given {@link #name() name}.
- *
Note: Assigning values to both {@link #value()} and {@link #values()} + *
+ * Note: Assigning values to both {@link #value()} and {@link #values()} * will lead to a configuration conflict. */ String[] values() default {}; diff --git a/org.springframework.test/src/main/java/org/springframework/test/annotation/ProfileValueUtils.java b/org.springframework.test/src/main/java/org/springframework/test/annotation/ProfileValueUtils.java index ea1a6797af5..f43ea26f8c6 100644 --- a/org.springframework.test/src/main/java/org/springframework/test/annotation/ProfileValueUtils.java +++ b/org.springframework.test/src/main/java/org/springframework/test/annotation/ProfileValueUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 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. @@ -20,7 +20,6 @@ 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; @@ -28,7 +27,7 @@ import org.springframework.util.StringUtils; /** * General utility methods for working with profile values. - * + * * @author Sam Brannen * @author Juergen Hoeller * @since 2.5 @@ -44,15 +43,15 @@ public abstract class ProfileValueUtils { /** * 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. + * {@link ProfileValueSourceConfiguration + * @ProfileValueSourceConfiguration} annotation and instantiates a new + * instance of that type. *
- * 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.
- *
+ * 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
@@ -103,95 +102,92 @@ public abstract class ProfileValueUtils {
}
/**
- * Determine if the supplied testClass is enabled
- * in the current environment, as specified by the
- * {@link IfProfileValue @IfProfileValue} annotation at the class level.
+ * Determine if the supplied testClass is enabled in
+ * the current environment, as specified by the {@link IfProfileValue
+ * @IfProfileValue} annotation at the class level.
*
- * Defaults to true if no
- * {@link IfProfileValue @IfProfileValue} annotation is declared.
- *
+ * Defaults to true if no {@link IfProfileValue
+ * @IfProfileValue} annotation is declared.
+ *
* @param testClass the test class
- * @return true if the test is enabled in the
- * current environment
+ * @return true if the test is enabled 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);
+ return isTestEnabledInThisEnvironment(retrieveProfileValueSource(testClass), ifProfileValue);
}
/**
- * Determine if the supplied testMethod is enabled
- * 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.
+ * Determine if the supplied testMethod is enabled 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. Class-level usage overrides
+ * method-level usage.
*
- * Defaults to true if no
- * {@link IfProfileValue @IfProfileValue} annotation is declared.
- *
+ * Defaults to true if no {@link IfProfileValue
+ * @IfProfileValue} annotation is declared.
+ *
* @param testMethod the test method
* @param testClass the test class
- * @return true if the test is enabled in the
- * current environment
+ * @return true if the test is enabled 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);
+ return isTestEnabledInThisEnvironment(retrieveProfileValueSource(testClass), testMethod, testClass);
}
/**
- * Determine if the supplied testMethod is enabled
- * 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.
+ * Determine if the supplied testMethod is enabled 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. Class-level usage overrides
+ * method-level usage.
*
- * Defaults to Note that {@link TestExecutionListeners @TestExecutionListeners} is
+ * Verifies proper handling of JUnit's {@link Ignore @Ignore} and Spring's
+ * {@link IfProfileValue @IfProfileValue} and
+ * {@link ProfileValueSourceConfiguration @ProfileValueSourceConfiguration}
+ * (with the implicit, default {@link ProfileValueSource}) annotations in
+ * conjunction with the {@link SpringJUnit4ClassRunner}.
+ *
+ * Note that {@link TestExecutionListeners @TestExecutionListeners} is
* explicitly configured with an empty list, thus disabling all default
* listeners.
- *
+ *
* @author Sam Brannen
* @since 2.5
* @see HardCodedProfileValueSourceSpringRunnerTests
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@TestExecutionListeners({})
+@TestExecutionListeners( {})
public class EnabledAndIgnoredSpringRunnerTests {
protected static final String NAME = "EnabledAndIgnoredSpringRunnerTests.profile_value.name";
diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/HardCodedProfileValueSourceSpringRunnerTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/HardCodedProfileValueSourceSpringRunnerTests.java
index f6ecb2aa282..62118b48df6 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/HardCodedProfileValueSourceSpringRunnerTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/HardCodedProfileValueSourceSpringRunnerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 the original author or authors.
+ * Copyright 2002-2009 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.
@@ -17,20 +17,19 @@
package org.springframework.test.context.junit4;
import org.junit.BeforeClass;
-
import org.springframework.test.annotation.ProfileValueSource;
import org.springframework.test.annotation.ProfileValueSourceConfiguration;
/**
*
- * Verifies proper handling of JUnit's {@link org.junit.Ignore @Ignore} and
- * Spring's
- * {@link org.springframework.test.annotation.IfProfileValue @IfProfileValue}
- * and {@link ProfileValueSourceConfiguration @ProfileValueSourceConfiguration}
- * (with an explicit, custom defined {@link ProfileValueSource})
- * annotations in conjunction with the {@link SpringJUnit4ClassRunner}.
+ * Verifies proper handling of JUnit's {@link org.junit.Ignore @Ignore} and
+ * Spring's {@link org.springframework.test.annotation.IfProfileValue
+ * @IfProfileValue} and {@link ProfileValueSourceConfiguration
+ * @ProfileValueSourceConfiguration} (with an
+ * explicit, custom defined {@link ProfileValueSource}) annotations in
+ * conjunction with the {@link SpringJUnit4ClassRunner}.
* true if no
- * {@link IfProfileValue @IfProfileValue} annotation is declared.
- *
+ * Defaults to 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 true if the test is enabled in the
- * current environment
+ * @return true if the test is enabled 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;
- }
+ IfProfileValue ifProfileValue = testClass.getAnnotation(IfProfileValue.class);
+ boolean classLevelEnabled = isTestEnabledInThisEnvironment(profileValueSource, ifProfileValue);
+
+ if (classLevelEnabled) {
+ ifProfileValue = testMethod.getAnnotation(IfProfileValue.class);
+ return isTestEnabledInThisEnvironment(profileValueSource, ifProfileValue);
}
- return isTestEnabledInThisEnvironment(profileValueSource, ifProfileValue);
+
+ return false;
}
/**
* Determine if the value (or one of the values)
- * in the supplied {@link IfProfileValue @IfProfileValue} annotation is
+ * in the supplied {@link IfProfileValue @IfProfileValue} annotation is
* enabled in the current environment.
- *
+ *
* @param profileValueSource the ProfileValueSource to use to determine if
* the test is enabled
- * @param ifProfileValue the annotation to introspect
- * @return true if the test is enabled in the
- * current environment
+ * @param ifProfileValue the annotation to introspect; may be
+ * null
+ * @return true if the test is enabled in the current
+ * environment or if the supplied ifProfileValue is
+ * null
*/
private static boolean isTestEnabledInThisEnvironment(ProfileValueSource profileValueSource,
IfProfileValue ifProfileValue) {
+ if (ifProfileValue == null) {
+ return true;
+ }
+
String environmentValue = profileValueSource.get(ifProfileValue.name());
String[] annotatedValues = ifProfileValue.values();
if (StringUtils.hasLength(ifProfileValue.value())) {
diff --git a/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java b/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java
new file mode 100644
index 00000000000..8a66fde60ea
--- /dev/null
+++ b/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2002-2009 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 static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Method;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Unit tests for {@link ProfileValueUtils}.
+ *
+ * @author Sam Brannen
+ * @since 3.0
+ */
+@RunWith(JUnit4.class)
+public class ProfileValueUtilsTests {
+
+ private static final String NON_ANNOTATED_METHOD = "nonAnnotatedMethod";
+ private static final String ENABLED_ANNOTATED_METHOD = "enabledAnnotatedMethod";
+ private static final String DISABLED_ANNOTATED_METHOD = "disabledAnnotatedMethod";
+
+ private static final String NAME = "ProfileValueUtilsTests.profile_value.name";
+ private static final String VALUE = "enigma";
+
+
+ @BeforeClass
+ public static void setProfileValue() {
+ System.setProperty(NAME, VALUE);
+ }
+
+ private void assertClassIsEnabled(Class> testClass) throws Exception {
+ assertTrue("Test class [" + testClass + "] should be enabled.",
+ ProfileValueUtils.isTestEnabledInThisEnvironment(testClass));
+ }
+
+ private void assertClassIsDisabled(Class> testClass) throws Exception {
+ assertFalse("Test class [" + testClass + "] should be disbled.",
+ ProfileValueUtils.isTestEnabledInThisEnvironment(testClass));
+ }
+
+ private void assertMethodIsEnabled(String methodName, Class> testClass) throws Exception {
+ Method testMethod = testClass.getMethod(methodName);
+ assertTrue("Test method [" + testMethod + "] should be enabled.",
+ ProfileValueUtils.isTestEnabledInThisEnvironment(testMethod, testClass));
+ }
+
+ private void assertMethodIsDisabled(String methodName, Class> testClass) throws Exception {
+ Method testMethod = testClass.getMethod(methodName);
+ assertFalse("Test method [" + testMethod + "] should be disabled.",
+ ProfileValueUtils.isTestEnabledInThisEnvironment(testMethod, testClass));
+ }
+
+ private void assertMethodIsEnabled(ProfileValueSource profileValueSource, String methodName, Class> testClass)
+ throws Exception {
+ Method testMethod = testClass.getMethod(methodName);
+ assertTrue("Test method [" + testMethod + "] should be enabled for ProfileValueSource [" + profileValueSource
+ + "].", ProfileValueUtils.isTestEnabledInThisEnvironment(profileValueSource, testMethod, testClass));
+ }
+
+ private void assertMethodIsDisabled(ProfileValueSource profileValueSource, String methodName, Class> testClass)
+ throws Exception {
+ Method testMethod = testClass.getMethod(methodName);
+ assertFalse("Test method [" + testMethod + "] should be disabled for ProfileValueSource [" + profileValueSource
+ + "].", ProfileValueUtils.isTestEnabledInThisEnvironment(profileValueSource, testMethod, testClass));
+ }
+
+ // -------------------------------------------------------------------
+
+ @Test
+ public void isTestEnabledInThisEnvironmentForProvidedClass() throws Exception {
+ assertClassIsEnabled(NonAnnotated.class);
+ assertClassIsEnabled(EnabledAnnotatedSingleValue.class);
+ assertClassIsEnabled(EnabledAnnotatedMultiValue.class);
+ assertClassIsDisabled(DisabledAnnotatedSingleValue.class);
+ assertClassIsDisabled(DisabledAnnotatedMultiValue.class);
+ }
+
+ @Test
+ public void isTestEnabledInThisEnvironmentForProvidedMethodAndClass() throws Exception {
+ assertMethodIsEnabled(NON_ANNOTATED_METHOD, NonAnnotated.class);
+
+ assertMethodIsEnabled(NON_ANNOTATED_METHOD, EnabledAnnotatedSingleValue.class);
+ assertMethodIsEnabled(ENABLED_ANNOTATED_METHOD, EnabledAnnotatedSingleValue.class);
+ assertMethodIsDisabled(DISABLED_ANNOTATED_METHOD, EnabledAnnotatedSingleValue.class);
+
+ assertMethodIsEnabled(NON_ANNOTATED_METHOD, EnabledAnnotatedMultiValue.class);
+ assertMethodIsEnabled(ENABLED_ANNOTATED_METHOD, EnabledAnnotatedMultiValue.class);
+ assertMethodIsDisabled(DISABLED_ANNOTATED_METHOD, EnabledAnnotatedMultiValue.class);
+
+ assertMethodIsDisabled(NON_ANNOTATED_METHOD, DisabledAnnotatedSingleValue.class);
+ assertMethodIsDisabled(ENABLED_ANNOTATED_METHOD, DisabledAnnotatedSingleValue.class);
+ assertMethodIsDisabled(DISABLED_ANNOTATED_METHOD, DisabledAnnotatedSingleValue.class);
+
+ assertMethodIsDisabled(NON_ANNOTATED_METHOD, DisabledAnnotatedMultiValue.class);
+ assertMethodIsDisabled(ENABLED_ANNOTATED_METHOD, DisabledAnnotatedMultiValue.class);
+ assertMethodIsDisabled(DISABLED_ANNOTATED_METHOD, DisabledAnnotatedMultiValue.class);
+ }
+
+ @Test
+ public void isTestEnabledInThisEnvironmentForProvidedProfileValueSourceMethodAndClass() throws Exception {
+
+ ProfileValueSource profileValueSource = SystemProfileValueSource.getInstance();
+
+ assertMethodIsEnabled(profileValueSource, NON_ANNOTATED_METHOD, NonAnnotated.class);
+
+ assertMethodIsEnabled(profileValueSource, NON_ANNOTATED_METHOD, EnabledAnnotatedSingleValue.class);
+ assertMethodIsEnabled(profileValueSource, ENABLED_ANNOTATED_METHOD, EnabledAnnotatedSingleValue.class);
+ assertMethodIsDisabled(profileValueSource, DISABLED_ANNOTATED_METHOD, EnabledAnnotatedSingleValue.class);
+
+ assertMethodIsEnabled(profileValueSource, NON_ANNOTATED_METHOD, EnabledAnnotatedMultiValue.class);
+ assertMethodIsEnabled(profileValueSource, ENABLED_ANNOTATED_METHOD, EnabledAnnotatedMultiValue.class);
+ assertMethodIsDisabled(profileValueSource, DISABLED_ANNOTATED_METHOD, EnabledAnnotatedMultiValue.class);
+
+ assertMethodIsDisabled(profileValueSource, NON_ANNOTATED_METHOD, DisabledAnnotatedSingleValue.class);
+ assertMethodIsDisabled(profileValueSource, ENABLED_ANNOTATED_METHOD, DisabledAnnotatedSingleValue.class);
+ assertMethodIsDisabled(profileValueSource, DISABLED_ANNOTATED_METHOD, DisabledAnnotatedSingleValue.class);
+
+ assertMethodIsDisabled(profileValueSource, NON_ANNOTATED_METHOD, DisabledAnnotatedMultiValue.class);
+ assertMethodIsDisabled(profileValueSource, ENABLED_ANNOTATED_METHOD, DisabledAnnotatedMultiValue.class);
+ assertMethodIsDisabled(profileValueSource, DISABLED_ANNOTATED_METHOD, DisabledAnnotatedMultiValue.class);
+ }
+
+
+ // -------------------------------------------------------------------
+
+ @SuppressWarnings("unused")
+ private static class NonAnnotated {
+
+ public void nonAnnotatedMethod() {
+ }
+ }
+
+ @SuppressWarnings("unused")
+ @IfProfileValue(name = NAME, value = VALUE)
+ private static class EnabledAnnotatedSingleValue {
+
+ public void nonAnnotatedMethod() {
+ }
+
+ @IfProfileValue(name = NAME, value = VALUE)
+ public void enabledAnnotatedMethod() {
+ }
+
+ @IfProfileValue(name = NAME, value = VALUE + "X")
+ public void disabledAnnotatedMethod() {
+ }
+ }
+
+ @SuppressWarnings("unused")
+ @IfProfileValue(name = NAME, values = { "foo", VALUE, "bar" })
+ private static class EnabledAnnotatedMultiValue {
+
+ public void nonAnnotatedMethod() {
+ }
+
+ @IfProfileValue(name = NAME, value = VALUE)
+ public void enabledAnnotatedMethod() {
+ }
+
+ @IfProfileValue(name = NAME, value = VALUE + "X")
+ public void disabledAnnotatedMethod() {
+ }
+ }
+
+ @SuppressWarnings("unused")
+ @IfProfileValue(name = NAME, value = VALUE + "X")
+ private static class DisabledAnnotatedSingleValue {
+
+ public void nonAnnotatedMethod() {
+ }
+
+ @IfProfileValue(name = NAME, value = VALUE)
+ public void enabledAnnotatedMethod() {
+ }
+
+ @IfProfileValue(name = NAME, value = VALUE + "X")
+ public void disabledAnnotatedMethod() {
+ }
+ }
+
+ @SuppressWarnings("unused")
+ @IfProfileValue(name = NAME, values = { "foo", "bar" })
+ private static class DisabledAnnotatedMultiValue {
+
+ public void nonAnnotatedMethod() {
+ }
+
+ @IfProfileValue(name = NAME, value = VALUE)
+ public void enabledAnnotatedMethod() {
+ }
+
+ @IfProfileValue(name = NAME, value = VALUE + "X")
+ public void disabledAnnotatedMethod() {
+ }
+ }
+
+}
diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/junit38/ProfileValueJUnit38SpringContextTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/junit38/ProfileValueJUnit38SpringContextTests.java
index 8c48a84d70e..92b6322ea3d 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/junit38/ProfileValueJUnit38SpringContextTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/junit38/ProfileValueJUnit38SpringContextTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2009 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.
@@ -16,6 +16,9 @@
package org.springframework.test.context.junit38;
+import java.util.HashMap;
+import java.util.Map;
+
import junit.framework.TestCase;
import junit.framework.TestResult;
@@ -26,61 +29,108 @@ import org.springframework.test.annotation.SystemProfileValueSource;
import org.springframework.test.context.TestExecutionListeners;
/**
- * Verifies proper handling of {@link IfProfileValue @IfProfileValue} and
- * {@link ProfileValueSourceConfiguration @ProfileValueSourceConfiguration} in
- * conjunction with {@link AbstractJUnit38SpringContextTests}.
- *
+ * Verifies proper handling of {@link IfProfileValue @IfProfileValue} and
+ * {@link ProfileValueSourceConfiguration @ProfileValueSourceConfiguration}
+ * in conjunction with {@link AbstractJUnit38SpringContextTests}.
+ *
* @author Sam Brannen
* @since 2.5
*/
public class ProfileValueJUnit38SpringContextTests extends TestCase {
- private static final String NAME = "ProfileValueAnnotationAwareTransactionalTests.profile_value.name";
+ private static final String EMPTY = "testIfProfileValueEmpty";
+ private static final String DISABLED_VIA_WRONG_NAME = "testIfProfileValueDisabledViaWrongName";
+ private static final String DISABLED_VIA_WRONG_VALUE = "testIfProfileValueDisabledViaWrongValue";
+ private static final String ENABLED_VIA_MULTIPLE_VALUES = "testIfProfileValueEnabledViaMultipleValues";
+ private static final String ENABLED_VIA_SINGLE_VALUE = "testIfProfileValueEnabledViaSingleValue";
+ private static final String NOT_CONFIGURED = "testIfProfileValueNotConfigured";
+ private static final String NAME = "ProfileValueAnnotationAwareTransactionalTests.profile_value.name";
private static final String VALUE = "enigma";
+ private final Map