/** * Determine if this {@code ContextConfigurationAttributes} instance has * either path-based resource locations or class-based resources. * @return {@code true} if either the {@link #getLocations() locations} * or the {@link #getClasses() classes} array is not empty * @see #hasLocations() * @see #hasClasses() */ public boolean hasResources() { return (hasLocations() || hasClasses()); }
/** * Process <em>annotated classes</em> in the supplied {@link ContextConfigurationAttributes}. * <p>If the <em>annotated classes</em> are {@code null} or empty and * {@link #isGenerateDefaultLocations()} returns {@code true}, this * {@code SmartContextLoader} will attempt to {@link * #detectDefaultConfigurationClasses detect default configuration classes}. * If defaults are detected they will be * {@link ContextConfigurationAttributes#setClasses(Class[]) set} in the * supplied configuration attributes. Otherwise, properties in the supplied * configuration attributes will not be modified. * @param configAttributes the context configuration attributes to process * @see org.springframework.test.context.SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes) * @see #isGenerateDefaultLocations() * @see #detectDefaultConfigurationClasses(Class) */ @Override public void processContextConfiguration(ContextConfigurationAttributes configAttributes) { if (!configAttributes.hasClasses() && isGenerateDefaultLocations()) { configAttributes.setClasses(detectDefaultConfigurationClasses(configAttributes.getDeclaringClass())); } }
public void processContextConfiguration(final ContextConfigurationAttributes configAttributes) { Assert.notNull(configAttributes, "configAttributes must not be null"); Assert.isTrue(!(configAttributes.hasLocations() && configAttributes.hasClasses()), () -> String.format("Cannot process locations AND classes for context configuration %s: " + "configure one or the other, but not both.", configAttributes)); delegateProcessing(getXmlLoader(), configAttributes); else if (configAttributes.hasClasses()) { delegateProcessing(getAnnotationConfigLoader(), configAttributes); Assert.state(!configAttributes.hasClasses(), () -> String.format( "%s should NOT have detected default configuration classes for context configuration %s.", name(getXmlLoader()), configAttributes)); if (configAttributes.hasClasses()) { if (logger.isInfoEnabled()) { logger.info(String.format("%s detected default configuration classes for context configuration %s.", name(getAnnotationConfigLoader()), configAttributes)); if (configAttributes.hasLocations() && configAttributes.hasClasses()) { String msg = String.format( "Configuration error: both default locations AND default configuration classes " +
/** * Process <em>annotated classes</em> in the supplied {@link ContextConfigurationAttributes}. * <p>If the <em>annotated classes</em> are {@code null} or empty and * {@link #isGenerateDefaultLocations()} returns {@code true}, this * {@code SmartContextLoader} will attempt to {@linkplain * #detectDefaultConfigurationClasses detect default configuration classes}. * If defaults are detected they will be * {@linkplain ContextConfigurationAttributes#setClasses(Class[]) set} in the * supplied configuration attributes. Otherwise, properties in the supplied * configuration attributes will not be modified. * @param configAttributes the context configuration attributes to process * @see org.springframework.test.context.SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes) * @see #isGenerateDefaultLocations() * @see #detectDefaultConfigurationClasses(Class) */ @Override public void processContextConfiguration(ContextConfigurationAttributes configAttributes) { if (!configAttributes.hasClasses() && isGenerateDefaultLocations()) { configAttributes.setClasses(detectDefaultConfigurationClasses(configAttributes.getDeclaringClass())); } }
@Override public void processContextConfiguration(ContextConfigurationAttributes configAttributes) { // Detect default XML configuration files: super.processContextConfiguration(configAttributes); // Detect default configuration classes: if (!configAttributes.hasClasses() && isGenerateDefaultLocations()) { configAttributes.setClasses(detectDefaultConfigurationClasses(configAttributes.getDeclaringClass())); } }
@Override public void processContextConfiguration( final ContextConfigurationAttributes configAttributes) { Assert.notNull(configAttributes, "configAttributes must not be null"); Assert.isTrue(!(configAttributes.hasLocations() && configAttributes.hasClasses()), String.format( "Cannot process locations AND classes for context " + "configuration %s; configure one or the other, but not both.", configAttributes));
/** * Determine if this {@code ContextConfigurationAttributes} instance has * either path-based resource locations or class-based resources. * @return {@code true} if either the {@link #getLocations() locations} * or the {@link #getClasses() classes} array is not empty * @see #hasLocations() * @see #hasClasses() */ public boolean hasResources() { return (hasLocations() || hasClasses()); }
/** * Determine if this {@code ContextConfigurationAttributes} instance has * either path-based resource locations or class-based resources. * @return {@code true} if either the {@link #getLocations() locations} * or the {@link #getClasses() classes} array is not empty * @see #hasLocations() * @see #hasClasses() */ public boolean hasResources() { return (hasLocations() || hasClasses()); }
Assert.isTrue(!(configAttributes.hasLocations() && configAttributes.hasClasses()), String.format( "Cannot process locations AND configuration classes for context " + "configuration %s; configure one or the other, but not both.", configAttributes)); delegateProcessing(xmlLoader, configAttributes); else if (configAttributes.hasClasses()) { delegateProcessing(annotationConfigLoader, configAttributes); if (configAttributes.hasClasses()) { throw new IllegalStateException(String.format( "%s should NOT have detected default configuration classes for context configuration %s.", if (configAttributes.hasClasses()) { if (logger.isInfoEnabled()) { logger.info(String.format( if (configAttributes.hasLocations() && configAttributes.hasClasses()) { String message = String.format( "Configuration error: both default locations AND default configuration classes "
public void processContextConfiguration(final ContextConfigurationAttributes configAttributes) { Assert.notNull(configAttributes, "configAttributes must not be null"); Assert.isTrue(!(configAttributes.hasLocations() && configAttributes.hasClasses()), () -> String.format("Cannot process locations AND classes for context configuration %s: " + "configure one or the other, but not both.", configAttributes)); delegateProcessing(getXmlLoader(), configAttributes); else if (configAttributes.hasClasses()) { delegateProcessing(getAnnotationConfigLoader(), configAttributes); Assert.state(!configAttributes.hasClasses(), () -> String.format( "%s should NOT have detected default configuration classes for context configuration %s.", name(getXmlLoader()), configAttributes)); if (configAttributes.hasClasses()) { if (logger.isInfoEnabled()) { logger.info(String.format("%s detected default configuration classes for context configuration %s.", name(getAnnotationConfigLoader()), configAttributes)); if (configAttributes.hasLocations() && configAttributes.hasClasses()) { String msg = String.format( "Configuration error: both default locations AND default configuration classes " +
public void processContextConfiguration(final ContextConfigurationAttributes configAttributes) { Assert.notNull(configAttributes, "configAttributes must not be null"); Assert.isTrue(!(configAttributes.hasLocations() && configAttributes.hasClasses()), String.format( "Cannot process locations AND classes for context configuration %s: " + "configure one or the other, but not both.", configAttributes)); delegateProcessing(getXmlLoader(), configAttributes); else if (configAttributes.hasClasses()) { delegateProcessing(getAnnotationConfigLoader(), configAttributes); if (configAttributes.hasClasses()) { throw new IllegalStateException(String.format( "%s should NOT have detected default configuration classes for context configuration %s.", if (configAttributes.hasClasses()) { if (logger.isInfoEnabled()) { logger.info(String.format( if (configAttributes.hasLocations() && configAttributes.hasClasses()) { String msg = String.format( "Configuration error: both default locations AND default configuration classes " +
/** * Process <em>annotated classes</em> in the supplied {@link ContextConfigurationAttributes}. * <p>If the <em>annotated classes</em> are {@code null} or empty and * {@link #isGenerateDefaultLocations()} returns {@code true}, this * {@code SmartContextLoader} will attempt to {@linkplain * #detectDefaultConfigurationClasses detect default configuration classes}. * If defaults are detected they will be * {@linkplain ContextConfigurationAttributes#setClasses(Class[]) set} in the * supplied configuration attributes. Otherwise, properties in the supplied * configuration attributes will not be modified. * @param configAttributes the context configuration attributes to process * @see org.springframework.test.context.SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes) * @see #isGenerateDefaultLocations() * @see #detectDefaultConfigurationClasses(Class) */ @Override public void processContextConfiguration(ContextConfigurationAttributes configAttributes) { if (!configAttributes.hasClasses() && isGenerateDefaultLocations()) { configAttributes.setClasses(detectDefaultConfigurationClasses(configAttributes.getDeclaringClass())); } }
/** * Process <em>annotated classes</em> in the supplied {@link ContextConfigurationAttributes}. * <p>If the <em>annotated classes</em> are {@code null} or empty and * {@link #isGenerateDefaultLocations()} returns {@code true}, this * {@code SmartContextLoader} will attempt to {@link * #detectDefaultConfigurationClasses detect default configuration classes}. * If defaults are detected they will be * {@link ContextConfigurationAttributes#setClasses(Class[]) set} in the * supplied configuration attributes. Otherwise, properties in the supplied * configuration attributes will not be modified. * @param configAttributes the context configuration attributes to process * @see org.springframework.test.context.SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes) * @see #isGenerateDefaultLocations() * @see #detectDefaultConfigurationClasses(Class) */ @Override public void processContextConfiguration(ContextConfigurationAttributes configAttributes) { if (!configAttributes.hasClasses() && isGenerateDefaultLocations()) { configAttributes.setClasses(detectDefaultConfigurationClasses(configAttributes.getDeclaringClass())); } }
/** * Process <em>annotated classes</em> in the supplied {@link ContextConfigurationAttributes}. * <p>If the <em>annotated classes</em> are {@code null} or empty and * {@link #isGenerateDefaultLocations()} returns {@code true}, this * {@code SmartContextLoader} will attempt to {@linkplain * #detectDefaultConfigurationClasses detect default configuration classes}. * If defaults are detected they will be * {@linkplain ContextConfigurationAttributes#setClasses(Class[]) set} in the * supplied configuration attributes. Otherwise, properties in the supplied * configuration attributes will not be modified. * @param configAttributes the context configuration attributes to process * @see org.springframework.test.context.SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes) * @see #isGenerateDefaultLocations() * @see #detectDefaultConfigurationClasses(Class) */ @Override public void processContextConfiguration(ContextConfigurationAttributes configAttributes) { if (!configAttributes.hasClasses() && isGenerateDefaultLocations()) { configAttributes.setClasses(detectDefaultConfigurationClasses(configAttributes.getDeclaringClass())); } }
/** * Process <em>annotated classes</em> in the supplied {@link ContextConfigurationAttributes}. * <p>If the <em>annotated classes</em> are {@code null} or empty and * {@link #isGenerateDefaultLocations()} returns {@code true}, this * {@code SmartContextLoader} will attempt to {@link * #detectDefaultConfigurationClasses detect default configuration classes}. * If defaults are detected they will be * {@link ContextConfigurationAttributes#setClasses(Class[]) set} in the * supplied configuration attributes. Otherwise, properties in the supplied * configuration attributes will not be modified. * @param configAttributes the context configuration attributes to process * @see org.springframework.test.context.SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes) * @see #isGenerateDefaultLocations() * @see #detectDefaultConfigurationClasses(Class) */ @Override public void processContextConfiguration(ContextConfigurationAttributes configAttributes) { if (!configAttributes.hasClasses() && isGenerateDefaultLocations()) { configAttributes.setClasses(detectDefaultConfigurationClasses(configAttributes.getDeclaringClass())); } }