congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
MergedContextConfiguration.getParent
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: spring-projects/spring-framework

/**
 * {@inheritDoc}
 */
@Override
public void put(MergedContextConfiguration key, ApplicationContext context) {
  Assert.notNull(key, "Key must not be null");
  Assert.notNull(context, "ApplicationContext must not be null");
  this.contextMap.put(key, context);
  MergedContextConfiguration child = key;
  MergedContextConfiguration parent = child.getParent();
  while (parent != null) {
    Set<MergedContextConfiguration> list = this.hierarchyMap.computeIfAbsent(parent, k -> new HashSet<>());
    list.add(child);
    child = parent;
    parent = child.getParent();
  }
}
origin: org.springframework.boot/spring-boot-test

/**
 * Return the {@link ApplicationContextInitializer initializers} that will be applied
 * to the context. By default this method will adapt {@link ContextCustomizer context
 * customizers}, add {@link SpringApplication#getInitializers() application
 * initializers} and add
 * {@link MergedContextConfiguration#getContextInitializerClasses() initializers
 * specified on the test}.
 * @param config the source context configuration
 * @param application the application instance
 * @return the initializers to apply
 * @since 2.0.0
 */
protected List<ApplicationContextInitializer<?>> getInitializers(
    MergedContextConfiguration config, SpringApplication application) {
  List<ApplicationContextInitializer<?>> initializers = new ArrayList<>();
  for (ContextCustomizer contextCustomizer : config.getContextCustomizers()) {
    initializers.add(new ContextCustomizerAdapter(contextCustomizer, config));
  }
  initializers.addAll(application.getInitializers());
  for (Class<? extends ApplicationContextInitializer<?>> initializerClass : config
      .getContextInitializerClasses()) {
    initializers.add(BeanUtils.instantiateClass(initializerClass));
  }
  if (config.getParent() != null) {
    initializers.add(new ParentContextApplicationContextInitializer(
        config.getParentApplicationContext()));
  }
  return initializers;
}
origin: spring-projects/spring-framework

MergedContextConfiguration parent = startKey.getParent();
while (parent != null) {
  startKey = parent;
  parent = startKey.getParent();
origin: spring-projects/spring-framework

@Test
public void removeContextHierarchyCacheLevel1() {
  // Load Level 3-A
  TestContext testContext3a = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache);
  testContext3a.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3);
  assertParentContextCount(2);
  // Load Level 3-B
  TestContext testContext3b = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache);
  testContext3b.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4);
  assertParentContextCount(2);
  // Remove Level 1
  // Should also remove Levels 2, 3-A, and 3-B, leaving nothing.
  contextCache.remove(getMergedContextConfiguration(testContext3a).getParent().getParent(),
    HierarchyMode.CURRENT_LEVEL);
  assertContextCacheStatistics(contextCache, "removed level 1", 0, 1, 4);
  assertParentContextCount(0);
}
origin: spring-projects/spring-framework

@Test
public void removeContextHierarchyCacheLevel1WithExhaustiveMode() {
  // Load Level 3-A
  TestContext testContext3a = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache);
  testContext3a.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3);
  assertParentContextCount(2);
  // Load Level 3-B
  TestContext testContext3b = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache);
  testContext3b.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4);
  assertParentContextCount(2);
  // Remove Level 1
  // Should also remove Levels 2, 3-A, and 3-B, leaving nothing.
  contextCache.remove(getMergedContextConfiguration(testContext3a).getParent().getParent(),
    HierarchyMode.EXHAUSTIVE);
  assertContextCacheStatistics(contextCache, "removed level 1", 0, 1, 4);
  assertParentContextCount(0);
}
origin: spring-projects/spring-framework

@Test
public void removeContextHierarchyCacheLevel2WithExhaustiveMode() {
  // Load Level 3-A
  TestContext testContext3a = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache);
  testContext3a.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3);
  assertParentContextCount(2);
  // Load Level 3-B
  TestContext testContext3b = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache);
  testContext3b.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4);
  assertParentContextCount(2);
  // Remove Level 2
  // Should wipe the cache
  contextCache.remove(getMergedContextConfiguration(testContext3a).getParent(), HierarchyMode.EXHAUSTIVE);
  assertContextCacheStatistics(contextCache, "removed level 2", 0, 1, 4);
  assertParentContextCount(0);
}
origin: spring-projects/spring-framework

@Test
public void removeContextHierarchyCacheLevel2() {
  // Load Level 3-A
  TestContext testContext3a = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache);
  testContext3a.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3);
  assertParentContextCount(2);
  // Load Level 3-B
  TestContext testContext3b = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache);
  testContext3b.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4);
  assertParentContextCount(2);
  // Remove Level 2
  // Should also remove Levels 3-A and 3-B, leaving only Level 1 as a context in the
  // cache but also removing the Level 1 hierarchy since all children have been
  // removed.
  contextCache.remove(getMergedContextConfiguration(testContext3a).getParent(), HierarchyMode.CURRENT_LEVEL);
  assertContextCacheStatistics(contextCache, "removed level 2", 1, 1, 4);
  assertParentContextCount(0);
}
origin: spring-projects/spring-framework

@Test
public void removeContextHierarchyCacheLevel3Then2WithExhaustiveMode() {
  // Load Level 3-A
  TestContext testContext3a = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache);
  testContext3a.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3);
  assertParentContextCount(2);
  // Load Level 3-B
  TestContext testContext3b = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache);
  testContext3b.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4);
  assertParentContextCount(2);
  // Remove Level 3-A
  // Should wipe the cache.
  contextCache.remove(getMergedContextConfiguration(testContext3a), HierarchyMode.EXHAUSTIVE);
  assertContextCacheStatistics(contextCache, "removed level 3-A", 0, 1, 4);
  assertParentContextCount(0);
  // Remove Level 2
  // Should not actually do anything since the cache was cleared in the
  // previous step. So the stats should remain the same.
  contextCache.remove(getMergedContextConfiguration(testContext3b).getParent(), HierarchyMode.EXHAUSTIVE);
  assertContextCacheStatistics(contextCache, "removed level 2", 0, 1, 4);
  assertParentContextCount(0);
}
origin: spring-projects/spring-framework

@Test
public void removeContextHierarchyCacheLevel3Then2() {
  // Load Level 3-A
  TestContext testContext3a = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3aTestCase.class, contextCache);
  testContext3a.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A", 3, 0, 3);
  assertParentContextCount(2);
  // Load Level 3-B
  TestContext testContext3b = TestContextTestUtils.buildTestContext(
    ClassHierarchyContextHierarchyLevel3bTestCase.class, contextCache);
  testContext3b.getApplicationContext();
  assertContextCacheStatistics(contextCache, "level 3, A and B", 4, 1, 4);
  assertParentContextCount(2);
  // Remove Level 3-A
  contextCache.remove(getMergedContextConfiguration(testContext3a), HierarchyMode.CURRENT_LEVEL);
  assertContextCacheStatistics(contextCache, "removed level 3-A", 3, 1, 4);
  assertParentContextCount(2);
  // Remove Level 2
  // Should also remove Level 3-B, leaving only Level 1.
  contextCache.remove(getMergedContextConfiguration(testContext3b).getParent(), HierarchyMode.CURRENT_LEVEL);
  assertContextCacheStatistics(contextCache, "removed level 2", 1, 1, 4);
  assertParentContextCount(0);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test

/**
 * {@inheritDoc}
 */
@Override
public void put(MergedContextConfiguration key, ApplicationContext context) {
  Assert.notNull(key, "Key must not be null");
  Assert.notNull(context, "ApplicationContext must not be null");
  this.contextMap.put(key, context);
  MergedContextConfiguration child = key;
  MergedContextConfiguration parent = child.getParent();
  while (parent != null) {
    Set<MergedContextConfiguration> list = this.hierarchyMap.computeIfAbsent(parent, k -> new HashSet<>());
    list.add(child);
    child = parent;
    parent = child.getParent();
  }
}
origin: apache/servicemix-bundles

/**
 * {@inheritDoc}
 */
@Override
public void put(MergedContextConfiguration key, ApplicationContext context) {
  Assert.notNull(key, "Key must not be null");
  Assert.notNull(context, "ApplicationContext must not be null");
  this.contextMap.put(key, context);
  MergedContextConfiguration child = key;
  MergedContextConfiguration parent = child.getParent();
  while (parent != null) {
    Set<MergedContextConfiguration> list = this.hierarchyMap.get(parent);
    if (list == null) {
      list = new HashSet<MergedContextConfiguration>();
      this.hierarchyMap.put(parent, list);
    }
    list.add(child);
    child = parent;
    parent = child.getParent();
  }
}
origin: apache/servicemix-bundles

/**
 * {@inheritDoc}
 */
@Override
public void remove(MergedContextConfiguration key, HierarchyMode hierarchyMode) {
  Assert.notNull(key, "Key must not be null");
  // startKey is the level at which to begin clearing the cache, depending
  // on the configured hierarchy mode.
  MergedContextConfiguration startKey = key;
  if (hierarchyMode == HierarchyMode.EXHAUSTIVE) {
    while (startKey.getParent() != null) {
      startKey = startKey.getParent();
    }
  }
  List<MergedContextConfiguration> removedContexts = new ArrayList<MergedContextConfiguration>();
  remove(removedContexts, startKey);
  // Remove all remaining references to any removed contexts from the
  // hierarchy map.
  for (MergedContextConfiguration currentKey : removedContexts) {
    for (Set<MergedContextConfiguration> children : this.hierarchyMap.values()) {
      children.remove(currentKey);
    }
  }
  // Remove empty entries from the hierarchy map.
  for (MergedContextConfiguration currentKey : this.hierarchyMap.keySet()) {
    if (this.hierarchyMap.get(currentKey).isEmpty()) {
      this.hierarchyMap.remove(currentKey);
    }
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test

MergedContextConfiguration parent = startKey.getParent();
while (parent != null) {
  startKey = parent;
  parent = startKey.getParent();
origin: org.tinygroup/org.tinygroup.tinyspringtest431

public ApplicationContext getParentApplicationContext() {
  MergedContextConfiguration parent = mergedContextConfiguration
      .getParent();
  Assert.state(
      this.contextLoaderDelegate != null,
      "Cannot retrieve a parent application context without access to the CacheAwareContextLoaderDelegate");
  if (parent == null) {
    return this.contextLoaderDelegate.loadContext(parentConfiguration);
  }
  ApplicationContext applicationContext = this.contextLoaderDelegate
      .loadContext(parent);
  if (applicationContext == null) {
    applicationContext = this.contextLoaderDelegate
        .loadContext(parentConfiguration);
  }
  return applicationContext;
}
origin: org.springframework.boot/spring-boot-test

/**
 * Create a new {@link MergedContextConfiguration} with different classes and
 * properties.
 * @param mergedConfig the source config
 * @param classes the replacement classes
 * @param propertySourceProperties the replacement properties
 * @return a new {@link MergedContextConfiguration}
 */
protected final MergedContextConfiguration createModifiedConfig(
    MergedContextConfiguration mergedConfig, Class<?>[] classes,
    String[] propertySourceProperties) {
  return new MergedContextConfiguration(mergedConfig.getTestClass(),
      mergedConfig.getLocations(), classes,
      mergedConfig.getContextInitializerClasses(),
      mergedConfig.getActiveProfiles(),
      mergedConfig.getPropertySourceLocations(), propertySourceProperties,
      mergedConfig.getContextCustomizers(), mergedConfig.getContextLoader(),
      getCacheAwareContextLoaderDelegate(), mergedConfig.getParent());
}
org.springframework.test.contextMergedContextConfigurationgetParent

Javadoc

Get the MergedContextConfiguration for the parent application context in a context hierarchy.

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().
  • getClasses
    Get the merged annotated classes 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
  • 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

  • Start an intent from android
  • getApplicationContext (Context)
  • getSharedPreferences (Context)
  • setRequestProperty (URLConnection)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • JFrame (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now