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:zipkin.storage.elasticsearch.ZipkinElasticsearchStorageAutoConfigurationTest.java

@Test
public void doesntProvidesStorageComponent_whenStorageTypeNotElasticsearch() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:cassandra");
    context.register(PropertyPlaceholderAutoConfiguration.class,
            ZipkinElasticsearchStorageAutoConfiguration.class);
    context.refresh();//  w  w w  .  j a v  a  2s. c o m

    thrown.expect(NoSuchBeanDefinitionException.class);
    es();
}

From source file:zipkin.server.ZipkinServerConfigurationTest.java

@Before
public void init() {
    context = new AnnotationConfigApplicationContext();
}

From source file:com.mine.cassandra.sink.CassandraSinkPropertiesTests.java

@Test
public void consistencyLevelCanBeCustomized() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "consistency-level:" + ConsistencyLevel.LOCAL_QUOROM);
    context.register(Conf.class);
    context.refresh();/*w  ww  .j  a v a 2s  .c o  m*/
    CassandraSinkProperties properties = context.getBean(CassandraSinkProperties.class);
    assertThat(properties.getConsistencyLevel(), equalTo(ConsistencyLevel.LOCAL_QUOROM));
    context.close();
}

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

private static AnnotationConfigApplicationContext createContextWithOverridenProperty(String pair) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    addEnvironment(context, pair);//from w  ww.java 2  s . c o m
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinUiAutoConfiguration.class);
    context.refresh();
    return context;
}

From source file:com.kixeye.chassis.support.test.eureka.metadata.MetadataCollectorTest.java

@Before
public void setup() {
    ConfigurationManager.getConfigInstance().setProperty("chassis.eureka.disable", "true");
    ConfigurationManager.getConfigInstance().setProperty("eureka.metadata.prop1", "propValue");
    ConfigurationManager.getConfigInstance().setProperty("eureka.datacenter", "default");

    StandardEnvironment environment = new StandardEnvironment();
    environment.getPropertySources().addFirst(new ArchaiusSpringPropertySource());
    context = new AnnotationConfigApplicationContext();
    context.setEnvironment(environment);
    context.register(MetadataCollectorConfiguration.class);
    context.refresh();/*from  w  w w  . j  a va 2 s .co m*/
    context.start();
}

From source file:zipkin.autoconfigure.collector.scribe.ZipkinScribeCollectorAutoConfigurationTest.java

@Test
public void doesntProvidesCollectorComponent_whenDisabled() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.collector.scribe.enabled:false");
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinScribeCollectorAutoConfiguration.class,
            InMemoryConfiguration.class);
    context.refresh();//from  www.  ja  v a  2s.co  m

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

From source file:zipkin.autoconfigure.collector.kafka.ZipkinKafkaCollectorAutoConfigurationTest.java

@Test
public void doesntProvidesCollectorComponent_whenKafkaZooKeeperUnset() {
    context = new AnnotationConfigApplicationContext();
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinKafkaCollectorAutoConfiguration.class,
            InMemoryConfiguration.class);
    context.refresh();/*from  w  w w.ja v a2  s  .c  om*/

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

From source file:com.greglturnquist.embeddablesdr.SystemDependencySerializerTests.java

@Before
public void setUp() {

    this.ctx = new AnnotationConfigApplicationContext();
    this.ctx.register(SpringDataRestConfig.class);
    this.ctx.refresh();

    this.repository = ctx.getBean(SystemRepository.class);
    this.module = ctx.getBean(PersistentEntityJackson2Module.class);
    this.serializer = ctx.getBean(SystemDependencySerializer.class);
    this.mapper = ctx.getBean("objectMapper", ObjectMapper.class);
}

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

@Test
public void providesStorageComponent_whenStorageTypeMySQL() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:mysql");
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinMySQLStorageAutoConfiguration.class);
    context.refresh();/*  www . j a v a2  s .  c  o m*/

    assertThat(context.getBean(MySQLStorage.class)).isNotNull();
}

From source file:com.avanza.ymer.MirrorEnvironment.java

public ApplicationContext getMongoClientContext() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.getBeanFactory().registerSingleton("mongoDbFactory",
            new SimpleMongoDbFactory(mongoServer.getMongo(), TEST_MIRROR_DB_NAME));
    context.refresh();/*from  ww w. ja  v a 2  s .c om*/
    return context;
}