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() 

Source Link

Document

Create a new AnnotationConfigApplicationContext that needs to be populated through #register calls and then manually #refresh refreshed .

Usage

From source file:shiver.me.timbers.spring.security.integration.ITJwtConfigurationMutualExclusivity.java

@Test(expected = BeanCreationException.class)
public void Cannot_apply_the_adaptor_if_the_annotation_is_present() {
    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(getClass());/*w  w w . j  a v a 2  s . c  o  m*/
    context.refresh();
}

From source file:org.ocelotds.spring.SpringResolver.java

public AnnotationConfigApplicationContext getApplicationContext() {
    logger.debug("Init Spring context");
    if (applicationContext == null) {
        applicationContext = new AnnotationConfigApplicationContext();
        ClientScope clientScope = new ClientScope();
        applicationContext.getBeanFactory().registerScope(clientScope.getConversationId(), clientScope);
        for (Object ocelotSpringConfig : ocelotSpringConfigs) {
            logger.info("Find context Spring {}", ocelotSpringConfig.getClass());
            applicationContext.register(ocelotSpringConfig.getClass());
        }// w ww . j a  v a 2s.  c  o  m
        applicationContext.refresh();
    }
    return applicationContext;
}

From source file:com.comcast.cats.domain.configuration.CatsHomeTest.java

public CatsHomeTest() {
    setCatsHome(getTargetDirectory());//from  w w w  .j ava  2  s. com

    AnnotationConfigApplicationContext appCtx = new AnnotationConfigApplicationContext();
    appCtx.register(CatsHome.class);
    appCtx.refresh();
    ctx = appCtx;

}

From source file:io.gravitee.reporter.elastic.ElasticsearchReporterTest.java

public void init() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(ReporterConfiguration.class);
    ctx.refresh();/*from w ww . j a va 2s  . c  om*/
    this.reporter = ctx.getBean(ElasticsearchReporter.class);
}

From source file:com.avanza.astrix.integration.tests.AstrixApplicationTest.java

@Test(expected = IllegalArgumentException.class)
public void throwsExceptionIfExportedRemoteServiceDoesNotPointToAnApiProvider() throws Exception {
    appContext = new AnnotationConfigApplicationContext();
    appContext.register(MyAppConfig.class);
    appContext.refresh();//from   ww  w  . j a  va2s  . com
}

From source file:zipkin.autoconfigure.ui.ZipkinUiAutoConfigurationTest.java

private static AnnotationConfigApplicationContext createContext() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinUiAutoConfiguration.class);
    context.refresh();//from  w w  w . j  a  va  2s.  com
    return context;
}

From source file:com.cisco.cta.taxii.adapter.settings.BindExceptionHandlerTest.java

@Test
public void invalidPollEndpoint() throws Exception {
    try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
        ctx.register(SettingsConfiguration.class);
        ctx.getEnvironment().getPropertySources()
                .addFirst(exclude(validProperties(), "taxiiService.pollEndpoint"));
        ctx.refresh();//from   w  w  w  .ja  va 2s .  c o m
        fail("The context creation must fail because of invalid configuration.");
    } catch (NestedRuntimeException e) {
        BindException be = (BindException) e.getRootCause();
        handler.handle(be);
        verify(err).println(contains("pollEndpoint has illegal value"));
    }
}

From source file:zipkin.autoconfigure.storage.mysql.ZipkinMySQLStorageAutoConfigurationTests.java

@Test
public void doesntProvidesStorageComponent_whenStorageTypeNotMySQL() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:cassandra");
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinMySQLStorageAutoConfiguration.class);
    context.refresh();//from  w  w  w  .  ja  va2  s  . c o m

    thrown.expect(NoSuchBeanDefinitionException.class);
    context.getBean(MySQLStorage.class);
}

From source file:org.deshang.content.indexing.App.java

private App() {
    context = new AnnotationConfigApplicationContext();
    context.getEnvironment().setActiveProfiles(APP_ACTIVE_PROFILE_NAMES);
    context.scan(APP_CONFIG_PACKAGE_NAME, APP_SERVICE_PACKAGE_NAME, APP_REPOSITORY_PACKAGE_NAME);
    context.refresh();//w w w . j  a  va2 s.co m
}

From source file:zipkin.autoconfigure.storage.cassandra.ZipkinCassandraStorageAutoConfigurationTest.java

@Test
public void doesntProvidesStorageComponent_whenStorageTypeNotCassandra() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:elasticsearch");
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinCassandraStorageAutoConfiguration.class);
    context.refresh();/*from   www  . ja  v a2 s . c  o  m*/

    thrown.expect(NoSuchBeanDefinitionException.class);
    context.getBean(CassandraStorage.class);
}