Package org.springframework.context.support

Examples of org.springframework.context.support.GenericXmlApplicationContext


  }

  @Test
  public void testGroovyBeanInterface() {
    context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName()+"-groovy-interface-context.xml");
    TestService bean = context.getBean("groovyBean", TestService.class);
    LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);

    assertEquals(0, logAdvice.getCountThrows());
    try {
View Full Code Here


  }


  @Test
  public void testGroovyBeanDynamic() {
    context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName()+"-groovy-dynamic-context.xml");
    TestService bean = context.getBean("groovyBean", TestService.class);
    LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);

    assertEquals(0, logAdvice.getCountThrows());
    try {
View Full Code Here

    assertEquals(0, logAdvice.getCountBefore());
  }

  @Test
  public void testGroovyBeanProxyTargetClass() {
    context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName()+"-groovy-proxy-target-class-context.xml");
    TestService bean = context.getBean("groovyBean", TestService.class);
    LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);

    assertEquals(0, logAdvice.getCountThrows());
    try {
View Full Code Here

*/
public class CacheAdviceNamespaceTests extends AbstractAnnotationTests {

  @Override
  protected ConfigurableApplicationContext getApplicationContext() {
    return new GenericXmlApplicationContext(
        "/org/springframework/cache/config/cache-advice.xml");
  }
View Full Code Here

public class CacheAdviceParserTests {

  @Test
  public void keyAndKeyGeneratorCannotBeSetTogether() {
    try {
      new GenericXmlApplicationContext("/org/springframework/cache/config/cache-advice-invalid.xml");
      fail("Should have failed to load context, one advise define both a key and a key generator");
    } catch (BeanDefinitionStoreException e) { // TODO better exception handling
    }
  }
View Full Code Here

public class LazyScheduledTasksBeanDefinitionParserTests {

  @Test(timeout = 5000)
  public void checkTarget() {
    Task task =
      new GenericXmlApplicationContext(
          LazyScheduledTasksBeanDefinitionParserTests.class,
          "lazyScheduledTasksContext.xml")
        .getBean(Task.class);

    while (!task.executed) {
View Full Code Here

*/
public class AnnotationTests extends AbstractAnnotationTests {

  @Override
  protected ConfigurableApplicationContext getApplicationContext() {
    return new GenericXmlApplicationContext(
        "/org/springframework/cache/config/annotationDrivenCacheConfig.xml");
  }
View Full Code Here

    assertThat("c7", c7.closed, is(true));
  }

  @Test
  public void xml() {
    ConfigurableApplicationContext ctx = new GenericXmlApplicationContext(
        getClass(), "DestroyMethodInferenceTests-context.xml");
    WithLocalCloseMethod x1 = ctx.getBean("x1", WithLocalCloseMethod.class);
    WithLocalCloseMethod x2 = ctx.getBean("x2", WithLocalCloseMethod.class);
    WithLocalCloseMethod x3 = ctx.getBean("x3", WithLocalCloseMethod.class);
    WithNoCloseMethod x4 = ctx.getBean("x4", WithNoCloseMethod.class);
    assertThat(x1.closed, is(false));
    assertThat(x2.closed, is(false));
    assertThat(x3.closed, is(false));
    assertThat(x4.closed, is(false));
    ctx.close();
    assertThat(x1.closed, is(false));
    assertThat(x2.closed, is(true));
    assertThat(x3.closed, is(true));
    assertThat(x4.closed, is(false));
  }
View Full Code Here

  @Test
  public void componentScanRespectsProfileAnnotation() {
    String xmlLocation = "org/springframework/context/annotation/componentScanRespectsProfileAnnotationTests.xml";
    { // should exclude the profile-annotated bean if active profiles remains unset
      GenericXmlApplicationContext context = new GenericXmlApplicationContext();
      context.load(xmlLocation);
      context.refresh();
      assertThat(context.containsBean(ProfileAnnotatedComponent.BEAN_NAME), is(false));
      context.close();
    }
    { // should include the profile-annotated bean with active profiles set
      GenericXmlApplicationContext context = new GenericXmlApplicationContext();
      context.getEnvironment().setActiveProfiles(ProfileAnnotatedComponent.PROFILE_NAME);
      context.load(xmlLocation);
      context.refresh();
      assertThat(context.containsBean(ProfileAnnotatedComponent.BEAN_NAME), is(true));
      context.close();
    }
    { // ensure the same works for AbstractRefreshableApplicationContext impls too
      ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] { xmlLocation },
        false);
      context.getEnvironment().setActiveProfiles(ProfileAnnotatedComponent.PROFILE_NAME);
      context.refresh();
      assertThat(context.containsBean(ProfileAnnotatedComponent.BEAN_NAME), is(true));
      context.close();
    }
  }
View Full Code Here

*/
public class EnableLoadTimeWeavingTests {

  @Test
  public void control() {
    GenericXmlApplicationContext ctx =
      new GenericXmlApplicationContext(getClass(), "EnableLoadTimeWeavingTests-context.xml");
    ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class);
  }
View Full Code Here

TOP

Related Classes of org.springframework.context.support.GenericXmlApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.