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.autoconfigure.storage.cassandra3.ZipkinCassandra3StorageAutoConfigurationTest.java

@Test
public void doesntProvidesStorageComponent_whenStorageTypeNotCassandra() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:elasticsearch");
    context.register(PropertyPlaceholderAutoConfiguration.class,
            ZipkinCassandra3StorageAutoConfiguration.class);
    context.refresh();//from www . j  av  a  2  s . c o  m

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

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

@Test
public void canOverridesProperty_defaultLookback() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.ui.defaultLookback:100");
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinUiAutoConfiguration.class);
    context.refresh();/*www .jav  a  2 s  .c  o  m*/

    assertThat(context.getBean(ZipkinUiProperties.class).getDefaultLookback()).isEqualTo(100);
}

From source file:zipkin.autoconfigure.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();/*from   w ww  .  ja v  a2s . c  o  m*/

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

From source file:at.ac.univie.isc.asio.spring.SpringContextFactory.java

public AnnotationConfigApplicationContext named(final String label) {
    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.setParent(root);/*from w  w w.  j a  v  a  2  s  .  c om*/
    context.setId(root.getId() + ":" + label + ":" + counter.getAndIncrement());
    context.setDisplayName(label);
    return context;
}

From source file:org.wicketTutorial.WicketApplication.java

/**
 * @see org.apache.wicket.Application#init()
 *///w w  w  .j  a va2 s . co m
@Override
public void init() {
    super.init();

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.scan("org.wicketTutorial.ejbBean");
    ctx.refresh();

    getComponentInstantiationListeners().add(new SpringComponentInjector(this, ctx));
}

From source file:be.lavait.spring.boot.axon.AxonAutoConfigurationTest.java

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

From source file:org.wicketTutorial.springinjection.WicketApplication.java

/**
 * @see org.apache.wicket.Application#init()
 *//*  w ww  . j  ava 2s  . c om*/
@Override
public void init() {
    super.init();

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.scan("org.wicketTutorial.springinjection.ejbBean");
    ctx.refresh();

    getComponentInstantiationListeners().add(new SpringComponentInjector(this, ctx));
}

From source file:com.acme.ModuleConfigurationTest.java

@Test
public void test() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    Properties properties = new Properties();
    properties.put("prefix", "foo");
    properties.put("suffix", "bar");
    context.getEnvironment().getPropertySources().addLast(new PropertiesPropertySource("options", properties));
    context.register(TestConfiguration.class);
    context.refresh();//from  w w w  . j a  va 2  s .c om

    MessageChannel input = context.getBean("input", MessageChannel.class);
    SubscribableChannel output = context.getBean("output", SubscribableChannel.class);

    final AtomicBoolean handled = new AtomicBoolean();
    output.subscribe(new MessageHandler() {
        @Override
        public void handleMessage(Message<?> message) throws MessagingException {
            handled.set(true);
            assertEquals("foohellobar", message.getPayload());
        }
    });
    input.send(new GenericMessage<String>("hello"));
    assertTrue(handled.get());
}

From source file:com.github.eddumelendez.autoconfigure.data.ldap.LdapDataAutoConfigurationTests.java

@Test
public void templateExists() {
    this.context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.ldap.urls:ldap://localhost:389");
    this.context.register(PropertyPlaceholderAutoConfiguration.class, LdapAutoConfiguration.class,
            LdapDataAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBeanNamesForType(LdapTemplate.class).length).isEqualTo(1);
}

From source file:zipkin.autoconfigure.storage.elasticsearch.aws.ZipkinElasticsearchAwsStorageAutoConfigurationTest.java

@Test
public void doesntProvideAWSSignatureVersion4_whenStorageTypeNotElasticsearch() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:cassandra");
    context.register(PropertyPlaceholderAutoConfiguration.class,
            ZipkinElasticsearchAwsStorageAutoConfiguration.class);
    context.refresh();/*from   w w  w.j  a  v  a2s.  c om*/

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