Search in sources :

Example 36 with StaticApplicationContext

use of org.springframework.context.support.StaticApplicationContext in project spring-boot by spring-projects.

the class EventPublishingRunListenerTests method shouldPublishLifecycleEvents.

@Test
void shouldPublishLifecycleEvents() {
    StaticApplicationContext context = new StaticApplicationContext();
    assertThat(this.eventListener.receivedEvents()).isEmpty();
    this.runListener.starting(this.bootstrapContext);
    checkApplicationEvents(ApplicationStartingEvent.class);
    this.runListener.environmentPrepared(this.bootstrapContext, null);
    checkApplicationEvents(ApplicationEnvironmentPreparedEvent.class);
    this.runListener.contextPrepared(context);
    checkApplicationEvents(ApplicationContextInitializedEvent.class);
    this.runListener.contextLoaded(context);
    checkApplicationEvents(ApplicationPreparedEvent.class);
    context.refresh();
    this.runListener.started(context, null);
    checkApplicationEvents(ApplicationStartedEvent.class, AvailabilityChangeEvent.class);
    this.runListener.ready(context, null);
    checkApplicationEvents(ApplicationReadyEvent.class, AvailabilityChangeEvent.class);
}
Also used : StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) Test(org.junit.jupiter.api.Test)

Example 37 with StaticApplicationContext

use of org.springframework.context.support.StaticApplicationContext in project spring-boot by spring-projects.

the class ApplicationContextServerWebExchangeMatcherTests method matchesWhenContextClassIsExistingBeanShouldProvideBean.

@Test
void matchesWhenContextClassIsExistingBeanShouldProvideBean() {
    ServerWebExchange exchange = createExchange();
    StaticApplicationContext context = (StaticApplicationContext) exchange.getApplicationContext();
    context.registerSingleton("existingBean", ExistingBean.class);
    assertThat(new TestApplicationContextServerWebExchangeMatcher<>(ExistingBean.class).callMatchesAndReturnProvidedContext(exchange).get()).isEqualTo(context.getBean(ExistingBean.class));
}
Also used : ServerWebExchange(org.springframework.web.server.ServerWebExchange) MockServerWebExchange(org.springframework.mock.web.server.MockServerWebExchange) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) Test(org.junit.jupiter.api.Test)

Example 38 with StaticApplicationContext

use of org.springframework.context.support.StaticApplicationContext in project spring-boot by spring-projects.

the class ApplicationContextAssertTests method setup.

@BeforeEach
void setup() {
    this.parent = new StaticApplicationContext();
    this.context = new StaticApplicationContext();
    this.context.setParent(this.parent);
}
Also used : StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 39 with StaticApplicationContext

use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.

the class MethodMessageHandlerTests method setup.

@BeforeEach
public void setup() {
    List<String> destinationPrefixes = Arrays.asList("/test");
    this.messageHandler = new TestMethodMessageHandler();
    this.messageHandler.setApplicationContext(new StaticApplicationContext());
    this.messageHandler.setDestinationPrefixes(destinationPrefixes);
    this.messageHandler.afterPropertiesSet();
    this.testController = new TestController();
    this.messageHandler.registerHandler(this.testController);
}
Also used : StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 40 with StaticApplicationContext

use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.

the class MessageBrokerConfigurationTests method simpValidatorMvc.

@Test
public void simpValidatorMvc() {
    StaticApplicationContext appCxt = new StaticApplicationContext();
    appCxt.registerSingleton("mvcValidator", TestValidator.class);
    AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig() {
    };
    config.setApplicationContext(appCxt);
    assertThat(config.simpValidator()).isNotNull();
    assertThat(config.simpValidator()).isInstanceOf(TestValidator.class);
}
Also used : StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) Test(org.junit.jupiter.api.Test)

Aggregations

StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)322 Test (org.junit.jupiter.api.Test)218 lombok.val (lombok.val)159 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)59 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)39 BeforeEach (org.junit.jupiter.api.BeforeEach)36 Test (org.junit.Test)34 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)31 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)25 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)20 HashSet (java.util.HashSet)19 MockRequestContext (org.springframework.webflow.test.MockRequestContext)19 InMemoryServiceRegistry (org.apereo.cas.services.InMemoryServiceRegistry)16 MockServletContext (org.springframework.mock.web.MockServletContext)16 MultifactorAuthenticationProviderBypassProperties (org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProviderBypassProperties)15 BeanDefinitionReader (org.springframework.beans.factory.support.BeanDefinitionReader)13 ApplicationContext (org.springframework.context.ApplicationContext)12 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 QueueChannel (org.springframework.integration.channel.QueueChannel)11