Package org.springframework.issues

Source Code of org.springframework.issues.ReproTests$Starter

package org.springframework.issues;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.support.GenericXmlApplicationContext;

public class ReproTests {

  @Test
  public void xml() {
    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.load("classpath:module.xml");
    ctx.refresh();
    Foo foo = ctx.getBean(Foo.class);
    assertNotNull(foo);
    ctx.close();
  }

    @Test
    public void annotation() {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ctx.register(Bar.class);
        ctx.refresh();
        Foo foo = ctx.getBean(Foo.class);
        assertNotNull(foo);
        ctx.close();
    }

    @Test
    public void importResource() {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ctx.register(Starter.class);
        ctx.refresh();
        Foo foo = ctx.getBean(Foo.class);
        assertNotNull(foo);
        ctx.close();
    }

    @Configuration
    @ImportResource("module.xml")
    protected static class Starter {
    }
}
TOP

Related Classes of org.springframework.issues.ReproTests$Starter

TOP
Copyright © 2018 www.massapi.com. 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.