Codota Logo
MergedContextConfiguration.getClasses
Code IndexAdd Codota to your IDE (free)

How to use
getClasses
method
in
org.springframework.test.context.MergedContextConfiguration

Best Java code snippets using org.springframework.test.context.MergedContextConfiguration.getClasses (Showing top 20 results out of 315)

  • Common ways to obtain MergedContextConfiguration
private void myMethod () {
MergedContextConfiguration m =
  • Codota IconMergedContextConfiguration mergedContextConfiguration;mergedContextConfiguration.getParent()
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-framework

/**
 * Determine if this {@code MergedContextConfiguration} instance has
 * class-based resources.
 * @return {@code true} if the {@link #getClasses() classes} array is not empty
 * @since 4.0.4
 * @see #hasResources()
 * @see #hasLocations()
 */
public boolean hasClasses() {
  return !ObjectUtils.isEmpty(getClasses());
}
origin: spring-projects/spring-framework

/**
 * Ensure that the supplied {@link MergedContextConfiguration} does not
 * contain {@link MergedContextConfiguration#getClasses() classes}.
 * @since 4.0.4
 * @see AbstractGenericContextLoader#validateMergedContextConfiguration
 */
@Override
protected void validateMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
  if (mergedConfig.hasClasses()) {
    String msg = String.format(
      "Test class [%s] has been configured with @ContextConfiguration's 'classes' attribute %s, "
          + "but %s does not support annotated classes.", mergedConfig.getTestClass().getName(),
      ObjectUtils.nullSafeToString(mergedConfig.getClasses()), getClass().getSimpleName());
    logger.error(msg);
    throw new IllegalStateException(msg);
  }
}
origin: spring-projects/spring-framework

/**
 * Ensure that the supplied {@link MergedContextConfiguration} does not
 * contain {@link MergedContextConfiguration#getClasses() classes}.
 * @since 4.0.4
 * @see AbstractGenericContextLoader#validateMergedContextConfiguration
 */
@Override
protected void validateMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
  if (mergedConfig.hasClasses()) {
    String msg = String.format(
      "Test class [%s] has been configured with @ContextConfiguration's 'classes' attribute %s, "
          + "but %s does not support annotated classes.", mergedConfig.getTestClass().getName(),
      ObjectUtils.nullSafeToString(mergedConfig.getClasses()), getClass().getSimpleName());
    logger.error(msg);
    throw new IllegalStateException(msg);
  }
}
origin: spring-projects/spring-framework

/**
 * Register classes in the supplied {@link GenericApplicationContext context}
 * from the classes in the supplied {@link MergedContextConfiguration}.
 * <p>Each class must represent an <em>annotated class</em>. An
 * {@link AnnotatedBeanDefinitionReader} is used to register the appropriate
 * bean definitions.
 * <p>Note that this method does not call {@link #createBeanDefinitionReader}
 * since {@code AnnotatedBeanDefinitionReader} is not an instance of
 * {@link BeanDefinitionReader}.
 * @param context the context in which the annotated classes should be registered
 * @param mergedConfig the merged configuration from which the classes should be retrieved
 * @see AbstractGenericContextLoader#loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
  Class<?>[] annotatedClasses = mergedConfig.getClasses();
  if (logger.isDebugEnabled()) {
    logger.debug("Registering annotated classes: " + ObjectUtils.nullSafeToString(annotatedClasses));
  }
  new AnnotatedBeanDefinitionReader(context).register(annotatedClasses);
}
origin: spring-projects/spring-framework

@SuppressWarnings("unchecked")
private static void assertCacheContents(DefaultContextCache cache, String... expectedNames) {
  Map<MergedContextConfiguration, ApplicationContext> contextMap =
      (Map<MergedContextConfiguration, ApplicationContext>) ReflectionTestUtils.getField(cache, "contextMap");
  // @formatter:off
  List<String> actualNames = contextMap.keySet().stream()
    .map(cfg -> cfg.getClasses()[0])
    .map(Class::getSimpleName)
    .collect(toList());
  // @formatter:on
  assertEquals(asList(expectedNames), actualNames);
}
origin: spring-projects/spring-framework

@Override
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
  // Order doesn't matter: <bean> always wins over @Bean.
  new XmlBeanDefinitionReader(context).loadBeanDefinitions(mergedConfig.getLocations());
  new AnnotatedBeanDefinitionReader(context).register(mergedConfig.getClasses());
}
origin: spring-projects/spring-framework

void assertMergedConfig(
    MergedContextConfiguration mergedConfig,
    Class<?> expectedTestClass,
    String[] expectedLocations,
    Class<?>[] expectedClasses,
    Set<Class<? extends ApplicationContextInitializer<?>>> expectedInitializerClasses,
    Class<? extends ContextLoader> expectedContextLoaderClass) {
  assertNotNull(mergedConfig);
  assertEquals(expectedTestClass, mergedConfig.getTestClass());
  assertNotNull(mergedConfig.getLocations());
  assertArrayEquals(expectedLocations, mergedConfig.getLocations());
  assertNotNull(mergedConfig.getClasses());
  assertArrayEquals(expectedClasses, mergedConfig.getClasses());
  assertNotNull(mergedConfig.getActiveProfiles());
  if (expectedContextLoaderClass == null) {
    assertNull(mergedConfig.getContextLoader());
  }
  else {
    assertEquals(expectedContextLoaderClass, mergedConfig.getContextLoader().getClass());
  }
  assertNotNull(mergedConfig.getContextInitializerClasses());
  assertEquals(expectedInitializerClasses, mergedConfig.getContextInitializerClasses());
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test

/**
 * Determine if this {@code MergedContextConfiguration} instance has
 * class-based resources.
 * @return {@code true} if the {@link #getClasses() classes} array is not empty
 * @since 4.0.4
 * @see #hasResources()
 * @see #hasLocations()
 */
public boolean hasClasses() {
  return !ObjectUtils.isEmpty(getClasses());
}
origin: apache/servicemix-bundles

/**
 * Determine if this {@code MergedContextConfiguration} instance has
 * class-based resources.
 * @return {@code true} if the {@link #getClasses() classes} array is not empty
 * @since 4.0.4
 * @see #hasResources()
 * @see #hasLocations()
 */
public boolean hasClasses() {
  return !ObjectUtils.isEmpty(getClasses());
}
origin: org.springframework.data/spring-yarn-test-core

private static boolean supports(SmartContextLoader loader, MergedContextConfiguration mergedConfig) {
  if (loader instanceof AnnotationConfigContextLoader) {
    return ObjectUtils.isEmpty(mergedConfig.getLocations()) && !ObjectUtils.isEmpty(mergedConfig.getClasses());
  }
  else {
    return !ObjectUtils.isEmpty(mergedConfig.getLocations()) && ObjectUtils.isEmpty(mergedConfig.getClasses());
  }
}
origin: org.springframework.boot/spring-boot-test

private boolean isFromConfiguration(MergedContextConfiguration candidateConfig,
    ContextConfiguration configuration) {
  ContextConfigurationAttributes attributes = new ContextConfigurationAttributes(
      candidateConfig.getTestClass(), configuration);
  Set<Class<?>> configurationClasses = new HashSet<>(
      Arrays.asList(attributes.getClasses()));
  for (Class<?> candidate : candidateConfig.getClasses()) {
    if (configurationClasses.contains(candidate)) {
      return true;
    }
  }
  return false;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test

/**
 * Ensure that the supplied {@link MergedContextConfiguration} does not
 * contain {@link MergedContextConfiguration#getClasses() classes}.
 * @since 4.0.4
 * @see AbstractGenericContextLoader#validateMergedContextConfiguration
 */
@Override
protected void validateMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
  if (mergedConfig.hasClasses()) {
    String msg = String.format(
      "Test class [%s] has been configured with @ContextConfiguration's 'classes' attribute %s, "
          + "but %s does not support annotated classes.", mergedConfig.getTestClass().getName(),
      ObjectUtils.nullSafeToString(mergedConfig.getClasses()), getClass().getSimpleName());
    logger.error(msg);
    throw new IllegalStateException(msg);
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test

/**
 * Ensure that the supplied {@link MergedContextConfiguration} does not
 * contain {@link MergedContextConfiguration#getClasses() classes}.
 * @since 4.0.4
 * @see AbstractGenericContextLoader#validateMergedContextConfiguration
 */
@Override
protected void validateMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
  if (mergedConfig.hasClasses()) {
    String msg = String.format(
      "Test class [%s] has been configured with @ContextConfiguration's 'classes' attribute %s, "
          + "but %s does not support annotated classes.", mergedConfig.getTestClass().getName(),
      ObjectUtils.nullSafeToString(mergedConfig.getClasses()), getClass().getSimpleName());
    logger.error(msg);
    throw new IllegalStateException(msg);
  }
}
origin: apache/servicemix-bundles

/**
 * Ensure that the supplied {@link MergedContextConfiguration} does not
 * contain {@link MergedContextConfiguration#getClasses() classes}.
 * @since 4.0.4
 * @see AbstractGenericContextLoader#validateMergedContextConfiguration
 */
@Override
protected void validateMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
  if (mergedConfig.hasClasses()) {
    String msg = String.format(
      "Test class [%s] has been configured with @ContextConfiguration's 'classes' attribute %s, "
          + "but %s does not support annotated classes.", mergedConfig.getTestClass().getName(),
      ObjectUtils.nullSafeToString(mergedConfig.getClasses()), getClass().getSimpleName());
    logger.error(msg);
    throw new IllegalStateException(msg);
  }
}
origin: apache/servicemix-bundles

/**
 * Ensure that the supplied {@link MergedContextConfiguration} does not
 * contain {@link MergedContextConfiguration#getClasses() classes}.
 * @since 4.0.4
 * @see AbstractGenericContextLoader#validateMergedContextConfiguration
 */
@Override
protected void validateMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
  if (mergedConfig.hasClasses()) {
    String msg = String.format(
      "Test class [%s] has been configured with @ContextConfiguration's 'classes' attribute %s, "
          + "but %s does not support annotated classes.", mergedConfig.getTestClass().getName(),
      ObjectUtils.nullSafeToString(mergedConfig.getClasses()), getClass().getSimpleName());
    logger.error(msg);
    throw new IllegalStateException(msg);
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test

/**
 * Register classes in the supplied {@link GenericApplicationContext context}
 * from the classes in the supplied {@link MergedContextConfiguration}.
 * <p>Each class must represent an <em>annotated class</em>. An
 * {@link AnnotatedBeanDefinitionReader} is used to register the appropriate
 * bean definitions.
 * <p>Note that this method does not call {@link #createBeanDefinitionReader}
 * since {@code AnnotatedBeanDefinitionReader} is not an instance of
 * {@link BeanDefinitionReader}.
 * @param context the context in which the annotated classes should be registered
 * @param mergedConfig the merged configuration from which the classes should be retrieved
 * @see AbstractGenericContextLoader#loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
  Class<?>[] annotatedClasses = mergedConfig.getClasses();
  if (logger.isDebugEnabled()) {
    logger.debug("Registering annotated classes: " + ObjectUtils.nullSafeToString(annotatedClasses));
  }
  new AnnotatedBeanDefinitionReader(context).register(annotatedClasses);
}
origin: apache/servicemix-bundles

/**
 * Register classes in the supplied {@link GenericApplicationContext context}
 * from the classes in the supplied {@link MergedContextConfiguration}.
 * <p>Each class must represent an <em>annotated class</em>. An
 * {@link AnnotatedBeanDefinitionReader} is used to register the appropriate
 * bean definitions.
 * <p>Note that this method does not call {@link #createBeanDefinitionReader}
 * since {@code AnnotatedBeanDefinitionReader} is not an instance of
 * {@link BeanDefinitionReader}.
 * @param context the context in which the annotated classes should be registered
 * @param mergedConfig the merged configuration from which the classes should be retrieved
 * @see AbstractGenericContextLoader#loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
  Class<?>[] annotatedClasses = mergedConfig.getClasses();
  if (logger.isDebugEnabled()) {
    logger.debug("Registering annotated classes: " + ObjectUtils.nullSafeToString(annotatedClasses));
  }
  new AnnotatedBeanDefinitionReader(context).register(annotatedClasses);
}
origin: org.tinygroup/org.tinygroup.tinyspringtest431

public TinyMergedContextConfiguration(ContextLoader contextLoader,
                   CacheAwareContextLoaderDelegate contextLoaderDelegate,
                   MergedContextConfiguration mergedContextConfiguration,
                   MergedContextConfiguration parentConfiguration) {
  super(mergedContextConfiguration.getTestClass(),
      mergedContextConfiguration.getLocations(),
      mergedContextConfiguration.getClasses(),
      mergedContextConfiguration.getActiveProfiles(), contextLoader);
  this.mergedContextConfiguration = mergedContextConfiguration;
  this.contextLoaderDelegate = contextLoaderDelegate;
  this.parentConfiguration = parentConfiguration;
}
origin: org.springframework.boot/spring-boot-test

protected Class<?>[] getOrFindConfigurationClasses(
    MergedContextConfiguration mergedConfig) {
  Class<?>[] classes = mergedConfig.getClasses();
  if (containsNonTestComponent(classes) || mergedConfig.hasLocations()) {
    return classes;
  }
  Class<?> found = new AnnotatedClassFinder(SpringBootConfiguration.class)
      .findFromClass(mergedConfig.getTestClass());
  Assert.state(found != null,
      "Unable to find a @SpringBootConfiguration, you need to use "
          + "@ContextConfiguration or @SpringBootTest(classes=...) "
          + "with your test");
  logger.info("Found @SpringBootConfiguration " + found.getName() + " for test "
      + mergedConfig.getTestClass());
  return merge(found, classes);
}
origin: org.springframework.boot/spring-boot-test

@Override
public ApplicationContext loadContext(MergedContextConfiguration config)
    throws Exception {
  Class<?>[] configClasses = config.getClasses();
  String[] configLocations = config.getLocations();
  Assert.state(
org.springframework.test.contextMergedContextConfigurationgetClasses

Javadoc

Get the merged annotated classes for the #getTestClass().

Popular methods of MergedContextConfiguration

  • getLocations
    Get the merged resource locations for ApplicationContextconfiguration files for the #getTestClass().
  • getTestClass
    Get the Class associated with this MergedContextConfiguration.
  • getActiveProfiles
    Get the merged active bean definition profiles for the #getTestClass().
  • getContextLoader
    Get the resolved ContextLoader for the #getTestClass().
  • <init>
    Create a new MergedContextConfiguration instance by copying all fields from the supplied MergedConte
  • getParent
    Get the MergedContextConfiguration for the parent application context in a context hierarchy.
  • getParentApplicationContext
    Get the parent ApplicationContext for the context defined by this MergedContextConfiguration from th
  • getContextInitializerClasses
    Get the merged ApplicationContextInitializer classes for the #getTestClass().
  • getPropertySourceProperties
    Get the merged test PropertySource properties for the #getTestClass().Properties will be loaded into
  • hasLocations
    Determine if this MergedContextConfiguration instance has path-based context resource locations.
  • getContextCustomizers
    Get the merged ContextCustomizer that will be applied when the application context is loaded.
  • getPropertySourceLocations
    Get the merged resource locations for test PropertySourcesfor the #getTestClass().
  • getContextCustomizers,
  • getPropertySourceLocations,
  • hasClasses,
  • hashCode,
  • equals,
  • nullSafeClassName,
  • processActiveProfiles,
  • processClasses,
  • processContextCustomizers

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • requestLocationUpdates (LocationManager)
  • getContentResolver (Context)
  • Color (java.awt)
    The Color class is used encapsulate colors in the default sRGB color space or colors in arbitrary co
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now