alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Spring Framework example source code file (IfProfileValue.java)

This example Spring Framework source code file (IfProfileValue.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Spring Framework tags/keywords

annotation, documented, documented, ifprofilevalue, inherited, inherited, string, string, target, target

The Spring Framework IfProfileValue.java source code

/*
 * 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.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 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 profile value against which to test.
	 */
	String name();

	/**
	 * A single, permissible <code>value of the profile value
	 * 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 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 {};

}

Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework IfProfileValue.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.