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);
}
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));
}
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);
}
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);
}
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);
}
Aggregations