org.springframework.test.context

Class ContextConfigurationAttributes

  • java.lang.Object
    • org.springframework.test.context.ContextConfigurationAttributes
    • Constructor Detail

      • ContextConfigurationAttributes

        public ContextConfigurationAttributes(java.lang.Class<?> declaringClass)
        Construct a new ContextConfigurationAttributes instance with default values.
        Parameters:
        declaringClass - the test class that declared @ContextConfiguration, either explicitly or implicitly
        Since:
        4.3
      • ContextConfigurationAttributes

        public ContextConfigurationAttributes(java.lang.Class<?> declaringClass,
                                              ContextConfiguration contextConfiguration)
        Construct a new ContextConfigurationAttributes instance for the supplied @ContextConfiguration annotation and the test class that declared it.
        Parameters:
        declaringClass - the test class that declared @ContextConfiguration
        contextConfiguration - the annotation from which to retrieve the attributes
      • ContextConfigurationAttributes

        public ContextConfigurationAttributes(java.lang.Class<?> declaringClass,
                                              AnnotationAttributes annAttrs)
        Construct a new ContextConfigurationAttributes instance for the supplied AnnotationAttributes (parsed from a @ContextConfiguration annotation) and the test class that declared them.
        Parameters:
        declaringClass - the test class that declared @ContextConfiguration
        annAttrs - the annotation attributes from which to retrieve the attributes
      • ContextConfigurationAttributes

        public ContextConfigurationAttributes(java.lang.Class<?> declaringClass,
                                              java.lang.String[] locations,
                                              java.lang.Class<?>[] classes,
                                              boolean inheritLocations,
                                              java.lang.Class<? extends ApplicationContextInitializer<?>>[] initializers,
                                              boolean inheritInitializers,
                                              java.lang.Class<? extends ContextLoader> contextLoaderClass)
        Construct a new ContextConfigurationAttributes instance for the test class that declared the @ContextConfiguration annotation and its corresponding attributes.
        Parameters:
        declaringClass - the test class that declared @ContextConfiguration
        locations - the resource locations declared via @ContextConfiguration
        classes - the annotated classes declared via @ContextConfiguration
        inheritLocations - the inheritLocations flag declared via @ContextConfiguration
        initializers - the context initializers declared via @ContextConfiguration
        inheritInitializers - the inheritInitializers flag declared via @ContextConfiguration
        contextLoaderClass - the ContextLoader class declared via @ContextConfiguration
        Throws:
        java.lang.IllegalArgumentException - if the declaringClass or contextLoaderClass is null
      • ContextConfigurationAttributes

        public ContextConfigurationAttributes(java.lang.Class<?> declaringClass,
                                              java.lang.String[] locations,
                                              java.lang.Class<?>[] classes,
                                              boolean inheritLocations,
                                              java.lang.Class<? extends ApplicationContextInitializer<?>>[] initializers,
                                              boolean inheritInitializers,
                                              @Nullable
                                              java.lang.String name,
                                              java.lang.Class<? extends ContextLoader> contextLoaderClass)
        Construct a new ContextConfigurationAttributes instance for the test class that declared the @ContextConfiguration annotation and its corresponding attributes.
        Parameters:
        declaringClass - the test class that declared @ContextConfiguration
        locations - the resource locations declared via @ContextConfiguration
        classes - the annotated classes declared via @ContextConfiguration
        inheritLocations - the inheritLocations flag declared via @ContextConfiguration
        initializers - the context initializers declared via @ContextConfiguration
        inheritInitializers - the inheritInitializers flag declared via @ContextConfiguration
        name - the name of level in the context hierarchy, or null if not applicable
        contextLoaderClass - the ContextLoader class declared via @ContextConfiguration
        Throws:
        java.lang.IllegalArgumentException - if the declaringClass or contextLoaderClass is null
    • Method Detail

      • getDeclaringClass

        public java.lang.Class<?> getDeclaringClass()
        Get the class that declared the @ContextConfiguration annotation, either explicitly or implicitly.
        Returns:
        the declaring class (never null)
      • setClasses

        public void setClasses(java.lang.Class<?>... classes)
        Set the processed annotated classes, effectively overriding the original value declared via @ContextConfiguration.
        See Also:
        getClasses()
      • hasClasses

        public boolean hasClasses()
        Determine if this ContextConfigurationAttributes instance has class-based resources.
        Returns:
        true if the classes array is not empty
        See Also:
        hasResources(), hasLocations()
      • setLocations

        public void setLocations(java.lang.String... locations)
        Set the processed resource locations, effectively overriding the original value declared via @ContextConfiguration.
        See Also:
        getLocations()
      • hasLocations

        public boolean hasLocations()
        Determine if this ContextConfigurationAttributes instance has path-based resource locations.
        Returns:
        true if the locations array is not empty
        See Also:
        hasResources(), hasClasses()
      • hasResources

        public boolean hasResources()
        Determine if this ContextConfigurationAttributes instance has either path-based resource locations or class-based resources.
        Returns:
        true if either the locations or the classes array is not empty
        See Also:
        hasLocations(), hasClasses()
      • getInitializers

        public java.lang.Class<? extends ApplicationContextInitializer<?>>[] getInitializers()
        Get the ApplicationContextInitializer classes that were declared via @ContextConfiguration.
        Returns:
        the ApplicationContextInitializer classes
        Since:
        3.2
      • isInheritInitializers

        public boolean isInheritInitializers()
        Get the inheritInitializers flag that was declared via @ContextConfiguration.
        Returns:
        the inheritInitializers flag
        Since:
        3.2
      • hashCode

        public int hashCode()
        Generate a unique hash code for all properties of this ContextConfigurationAttributes instance excluding the name.
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Provide a String representation of the context configuration attributes and declaring class.
        Overrides:
        toString in class java.lang.Object