Java Code Examples for org.springframework.test.context.ContextConfigurationAttributes#getContextLoaderClass()

The following examples show how to use org.springframework.test.context.ContextConfigurationAttributes#getContextLoaderClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractTestContextBootstrapper.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Resolve the {@link ContextLoader} {@linkplain Class class} to use for the supplied
 * list of {@link ContextConfigurationAttributes}.
 * <p>Beginning with the first level in the context configuration attributes hierarchy:
 * <ol>
 * <li>If the {@link ContextConfigurationAttributes#getContextLoaderClass()
 * contextLoaderClass} property of {@link ContextConfigurationAttributes} is
 * configured with an explicit class, that class will be returned.</li>
 * <li>If an explicit {@code ContextLoader} class is not specified at the current
 * level in the hierarchy, traverse to the next level in the hierarchy and return to
 * step #1.</li>
 * </ol>
 * @param configAttributesList the list of configuration attributes to process;
 * must not be {@code null}; must be ordered <em>bottom-up</em>
 * (i.e., as if we were traversing up the class hierarchy)
 * @return the {@code ContextLoader} class to use for the supplied configuration
 * attributes, or {@code null} if no explicit loader is found
 * @throws IllegalArgumentException if supplied configuration attributes are
 * {@code null} or <em>empty</em>
 */
@Nullable
protected Class<? extends ContextLoader> resolveExplicitContextLoaderClass(
		List<ContextConfigurationAttributes> configAttributesList) {

	Assert.notNull(configAttributesList, "ContextConfigurationAttributes list must not be null");

	for (ContextConfigurationAttributes configAttributes : configAttributesList) {
		if (logger.isTraceEnabled()) {
			logger.trace(String.format("Resolving ContextLoader for context configuration attributes %s",
					configAttributes));
		}
		Class<? extends ContextLoader> contextLoaderClass = configAttributes.getContextLoaderClass();
		if (ContextLoader.class != contextLoaderClass) {
			if (logger.isDebugEnabled()) {
				logger.debug(String.format(
						"Found explicit ContextLoader class [%s] for context configuration attributes %s",
						contextLoaderClass.getName(), configAttributes));
			}
			return contextLoaderClass;
		}
	}
	return null;
}
 
Example 2
Source File: AbstractTestContextBootstrapper.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Resolve the {@link ContextLoader} {@linkplain Class class} to use for the supplied
 * list of {@link ContextConfigurationAttributes}.
 * <p>Beginning with the first level in the context configuration attributes hierarchy:
 * <ol>
 * <li>If the {@link ContextConfigurationAttributes#getContextLoaderClass()
 * contextLoaderClass} property of {@link ContextConfigurationAttributes} is
 * configured with an explicit class, that class will be returned.</li>
 * <li>If an explicit {@code ContextLoader} class is not specified at the current
 * level in the hierarchy, traverse to the next level in the hierarchy and return to
 * step #1.</li>
 * </ol>
 * @param configAttributesList the list of configuration attributes to process;
 * must not be {@code null}; must be ordered <em>bottom-up</em>
 * (i.e., as if we were traversing up the class hierarchy)
 * @return the {@code ContextLoader} class to use for the supplied configuration
 * attributes, or {@code null} if no explicit loader is found
 * @throws IllegalArgumentException if supplied configuration attributes are
 * {@code null} or <em>empty</em>
 */
@Nullable
protected Class<? extends ContextLoader> resolveExplicitContextLoaderClass(
		List<ContextConfigurationAttributes> configAttributesList) {

	Assert.notNull(configAttributesList, "ContextConfigurationAttributes list must not be null");

	for (ContextConfigurationAttributes configAttributes : configAttributesList) {
		if (logger.isTraceEnabled()) {
			logger.trace(String.format("Resolving ContextLoader for context configuration attributes %s",
					configAttributes));
		}
		Class<? extends ContextLoader> contextLoaderClass = configAttributes.getContextLoaderClass();
		if (ContextLoader.class != contextLoaderClass) {
			if (logger.isDebugEnabled()) {
				logger.debug(String.format(
						"Found explicit ContextLoader class [%s] for context configuration attributes %s",
						contextLoaderClass.getName(), configAttributes));
			}
			return contextLoaderClass;
		}
	}
	return null;
}
 
Example 3
Source File: AbstractTestContextBootstrapper.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Resolve the {@link ContextLoader} {@linkplain Class class} to use for the supplied
 * list of {@link ContextConfigurationAttributes}.
 * <p>Beginning with the first level in the context configuration attributes hierarchy:
 * <ol>
 * <li>If the {@link ContextConfigurationAttributes#getContextLoaderClass()
 * contextLoaderClass} property of {@link ContextConfigurationAttributes} is
 * configured with an explicit class, that class will be returned.</li>
 * <li>If an explicit {@code ContextLoader} class is not specified at the current
 * level in the hierarchy, traverse to the next level in the hierarchy and return to
 * step #1.</li>
 * </ol>
 * @param configAttributesList the list of configuration attributes to process;
 * must not be {@code null} or <em>empty</em>; must be ordered <em>bottom-up</em>
 * (i.e., as if we were traversing up the class hierarchy)
 * @return the {@code ContextLoader} class to use for the supplied configuration
 * attributes, or {@code null} if no explicit loader is found
 * @throws IllegalArgumentException if supplied configuration attributes are
 * {@code null} or <em>empty</em>
 */
protected Class<? extends ContextLoader> resolveExplicitContextLoaderClass(
		List<ContextConfigurationAttributes> configAttributesList) {

	Assert.notEmpty(configAttributesList, "ContextConfigurationAttributes list must not be empty");
	for (ContextConfigurationAttributes configAttributes : configAttributesList) {
		if (logger.isTraceEnabled()) {
			logger.trace(String.format("Resolving ContextLoader for context configuration attributes %s",
				configAttributes));
		}
		Class<? extends ContextLoader> contextLoaderClass = configAttributes.getContextLoaderClass();
		if (ContextLoader.class != contextLoaderClass) {
			if (logger.isDebugEnabled()) {
				logger.debug(String.format(
					"Found explicit ContextLoader class [%s] for context configuration attributes %s",
					contextLoaderClass.getName(), configAttributes));
			}
			return contextLoaderClass;
		}
	}
	return null;
}