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:nats.client.spring.JavaConfigAnnotationConfigTest.java

@Test
public void subscribeAnnotation() {
    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
            AnnotationConfig.class);
    try {//from ww w .  j a v a2s .  c  om
        final Nats nats = context.getBean(Nats.class);
        testNatsConfig(context, nats);
    } finally {
        context.close();
    }
}

From source file:com.github.jmnarloch.spring.jaxrs.client.cxf.EnableCxfClientTest.java

/**
 * Tests the registration of the proxy factory in application context.
 *//*from  www .j  a v a  2 s .  c  o  m*/
@Test
public void shouldRegisterClientProxyFactory() {

    // given
    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class);

    // when
    JaxRsClientProxyFactory factory = context.getBean(JaxRsClientProxyFactory.class);

    // then
    assertNotNull(factory);
    assertTrue(CxfClientProxyFactory.class.equals(factory.getClass()));
}

From source file:com.ngcamango.rehabcetreweb.test.services.AppointmentServiceTest.java

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

From source file:com.github.jmnarloch.spring.jaxrs.client.jersey.EnableJerseyClientTest.java

/**
 * Tests the registration of the proxy factory in application context.
 *//*  w  w w. ja  v a 2  s  .  c  o  m*/
@Test
public void shouldRegisterClientProxyFactory() {

    // given
    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class);

    // when
    JaxRsClientProxyFactory factory = context.getBean(JaxRsClientProxyFactory.class);

    // then
    assertNotNull(factory);
    assertTrue(JerseyClientProxyFactory.class.equals(factory.getClass()));
}

From source file:com.github.jmnarloch.spring.jaxrs.client.resteasy.EnableRestEasyClientTest.java

/**
 * Tests the registration of the proxy factory in application context.
 *///from  w  w  w .  j  a v a  2s. co m
@Test
public void shouldRegisterClientProxyFactory() {

    // given
    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class);

    // when
    JaxRsClientProxyFactory factory = context.getBean(JaxRsClientProxyFactory.class);

    // then
    assertNotNull(factory);
    assertTrue(RestEasyClientProxyFactory.class.equals(factory.getClass()));
}

From source file:me.bulat.jivr.core.bootstrap.Bootstrap.java

public Bootstrap() {
    rootContext = new AnnotationConfigApplicationContext(RootConfig.class);
    rootContext.registerShutdownHook();
}

From source file:org.atmosphere.spring.SpringObjectFactory.java

@Override
public <T, U extends T> U newClassInstance(AtmosphereFramework framework, Class<T> classType,
        Class<U> classToInstantiate) throws InstantiationException, IllegalAccessException {
    ApplicationContext context = new AnnotationConfigApplicationContext(classToInstantiate);
    U t = context.getBean(classToInstantiate);
    if (t == null) {
        logger.info("Unable to find {}. Creating the object directly.", classToInstantiate.getName());
        return classToInstantiate.newInstance();
    }/*ww  w .  j av  a  2  s  .  c o  m*/
    return t;
}

From source file:com.tacitknowledge.flip.spring.config.AnnotatedFlipSpringConfigTest.java

@Before
public void setUp() {
    context = new AnnotationConfigApplicationContext(TestCofig.class);
}

From source file:com.vmware.controller.SsoAuthTest.java

@Override
protected Application configure() {
    ApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class);
    return new AppConfig().property("contextConfig", context);
}

From source file:sample.SdkArtifactSampleApp.java

private void assertSdkAvailabilityFromSpringContext() {
    ApplicationContext context = new AnnotationConfigApplicationContext(CustomCredentialsProviderConfig.class);

    checkCredentials(context.getBean(ClcSdk.class).getCredentialsProvider());

    context = new AnnotationConfigApplicationContext(CustomSdkConfigurationConfig.class);

    checkConfiguration(context.getBean(SdkConfiguration.class));
}