Package org.springframework.context.support

Examples of org.springframework.context.support.GenericXmlApplicationContext


    assertThat(v1("classpath:org/springframework/issues/PropertySourcesPlaceholderConfigurerTrue-context.xml"), equalTo("v1-local"));
  }

  public String v1(String resourceLocation) {

    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.load(resourceLocation);
    ctx.refresh();

    try {
      return ctx.getBean(TestBean.class).getName();
    }
    finally {
      ctx.close();
    }
  }
View Full Code Here


   * the way BeanFactoryPostProcessors are processed.  See {@link #workaround()} below
   * for a solution to this.
   */
  @Test
  public void repro() {
    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.load("ReproTests-repro.xml");
    ctx.refresh();
  }
View Full Code Here

*/
public class ReproTests {

  @Test
  public void repro() {
    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.load("classpath:org/springframework/issues/ReproTests-context.xml");
    ctx.refresh();

    //Foo foo = ctx.getBean(Foo.class);
    //Bar bar = ctx.getBean(Bar.class);

    //assertThat(foo.getBar(), sameInstance(bar));
View Full Code Here

  @Test
  public void workaround() {
    Map<String,Object> localProps = new HashMap<String,Object>();
    localProps.put("resourceDirPlaceHolder", "myResourceDir");

    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.getEnvironment()
      .getPropertySources()
        .addFirst(new MapPropertySource("localProps", localProps));
    ctx.load("ReproTests-workaround.xml");
    ctx.refresh();
  }
View Full Code Here

public class ReproTests {

  @Test
  public void repro() {
    System.out.println("here");
    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    System.out.println("there");
    ctx.load("classpath:org/springframework/issues/ReproTests-context.xml");
    ctx.refresh();

    Foo foo = ctx.getBean(Foo.class);
    Bar bar = ctx.getBean(Bar.class);

    assertThat(foo.getBar(), sameInstance(bar));
    ctx.close();
  }
View Full Code Here

public class ReproTests {

  @Test
  public void repro() {
    GenericXmlApplicationContext context = new GenericXmlApplicationContext("context.xml");
    MyReciever bean = context.getBean(MyReciever.class);
    bean.callMethod();
  }
View Full Code Here

  public void fails() throws Exception {
    repro("ReproTests-context-fails.xml");
  }

  private void repro(String xml) {
    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.getEnvironment().setIgnoreUnresolvableNestedPlaceholders(true);
    ctx.load("classpath:org/springframework/issues/" + xml);
    ctx.refresh();

    Foo foo = ctx.getBean(Foo.class);
    assertEquals(foo.getAbc(), "${none}");
    assertEquals(foo.getAbc2(), "test");
    ctx.close();
  }
View Full Code Here

  public void repro() {
    StopWatch stopWatch = new StopWatch("Prototyped Bean Creation");
   
    // initial load
        stopWatch.start("Initializing");
        GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
        ctx.load("classpath:org/springframework/issues/ReproTests-context.xml");
        ctx.refresh();
    ctx.getBean("ParentBeanGroup");
    stopWatch.stop();
   
    stopWatch.start("Creating");
      for (int i = 0; i < ITERATIONS; i++) {
          ctx.getBean("ParentBeanGroup");
      }
      stopWatch.stop();
      System.out.println(stopWatch.prettyPrint());
   }
View Full Code Here

  }

  @Test
  public void testRootContextWithJdbcUsers() throws Exception {
    System.setProperty("spring.profiles.active", "jdbc");
    GenericXmlApplicationContext context = new GenericXmlApplicationContext(new ClassPathResource(getClass()
        .getSimpleName() + "-context.xml", getClass()));
    @SuppressWarnings("unchecked")
    Map<String, String> value = context.getBean("value", Map.class);
    assertEquals("{platform.foo=bar}", value.toString());
    context.close();
  }
View Full Code Here

public class ActiveMQTest {

  @Test
  public void testJmsConnectionFactory() {
    GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
    applicationContext.getEnvironment().setActiveProfiles("test");
    applicationContext.load("/jmsContext.xml");
    applicationContext.refresh();
    String[] profiles = applicationContext.getEnvironment().getActiveProfiles();
    Assert.assertTrue(ArrayUtils.contains(profiles, "test"));
    String[] beanNames = applicationContext.getBeanDefinitionNames();
    Assert.assertTrue(ArrayUtils.contains(beanNames, "jmsConnectionFactory"));
  }
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.