Example usage for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext

List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext

Introduction

In this page you can find the example usage for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext.

Prototype

public AnnotationConfigApplicationContext(String... basePackages) 

Source Link

Document

Create a new AnnotationConfigApplicationContext, scanning for bean definitions in the given packages and automatically refreshing the context.

Usage

From source file:com.nkosy.designpatterns.structural.adapterpattern.test.AdapterPatternTest.java

@BeforeMethod
public void setUpMethod() throws Exception {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
    obj = (TemperatureObjectReporter) ctx.getBean("tempObjectReporter");
    obj2 = (CelciusReporter) ctx.getBean("classReporter");
}

From source file:org.dalesbred.integration.spring.SpringConfigurationTest.java

@Test
public void dalesbredUsesConnectionBoundToSpringTransactions() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SimpleConfiguration.class);
    DataSource dataSource = ctx.getBean(DataSource.class);
    Database db = ctx.getBean(Database.class);

    new TransactionTemplate(new DataSourceTransactionManager(dataSource))
            .execute(status -> db.withTransaction(Propagation.MANDATORY, tx -> {
                assertThat(tx.getConnection(), is(DataSourceUtils.getConnection(dataSource)));
                return "ok";
            }));//from   w ww. j a  va  2  s  . co m
}

From source file:com.ngcamango.rehabcetreweb.test.repository.NextOfKinRepositoryTest.java

@BeforeClass
public static void setUpClass() throws Exception {
    ctx = new AnnotationConfigApplicationContext(ConnectionConfig.class);
    bill = new Bill.Builder(5000.00).build();
    address = new Address.Builder("21 Jump Street").build();
}

From source file:com.nkosy.designpatterns.structural.compositepatttern.CompositeAdapterTest.java

@BeforeMethod
public void setUpMethod() throws Exception {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
    obj = (Composite) ctx.getBean("composite");
}

From source file:cput.testdriven.testDevelopment.java

@Test
@BeforeClass//  w  w w .  j  a  v a 2 s  .c o m
public static void setUpClass() throws Exception {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(TDDConfig.class);
    service = (TDDService) ctx.getBean(" getService ");

}

From source file:com.albert.javatest.JavaTestExample.java

@Ignore
@Test/*w  w  w.j  a  v a  2s . co m*/
public void testChannelHelloWorld() {
    ApplicationContext context = new AnnotationConfigApplicationContext(MyHelloService.class);
    HelloService myHelloService = context.getBean("myHelloService", HelloService.class);
    System.out.println("Printing by HelloService: " + myHelloService.sayHello("abc"));
    System.out
            .println("Printing in HelloWorldExample JUnit, by helloGateway: " + helloGateway.sayHello("World"));
    ((ConfigurableApplicationContext) context).close();
}