use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.
the class DispatcherHandlerTests method preFlightRequest.
@Test
void preFlightRequest() {
WebHandler webHandler = mock(WebHandler.class);
HandlerMapping handlerMapping = mock(HandlerMapping.class);
given((handlerMapping).getHandler(any())).willReturn(Mono.just(webHandler));
StaticApplicationContext context = new StaticApplicationContext();
context.registerBean("handlerMapping", HandlerMapping.class, () -> handlerMapping);
context.registerBean(HandlerAdapter.class, SimpleHandlerAdapter::new);
context.registerBean(HandlerResultHandler.class, StringHandlerResultHandler::new);
context.refresh();
MockServerHttpRequest request = MockServerHttpRequest.options("/").header(HttpHeaders.ORIGIN, "https://domain.com").header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET").build();
MockServerWebExchange exchange = MockServerWebExchange.from(request);
new DispatcherHandler(context).handle(exchange).block(Duration.ofSeconds(0));
verifyNoInteractions(webHandler);
}
use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.
the class WebSocketAnnotationMethodMessageHandlerTests method setUp.
@BeforeEach
public void setUp() throws Exception {
this.applicationContext = new StaticApplicationContext();
this.applicationContext.registerSingleton("controller", TestController.class);
this.applicationContext.registerSingleton("controllerAdvice", TestControllerAdvice.class);
this.applicationContext.refresh();
SubscribableChannel channel = Mockito.mock(SubscribableChannel.class);
SimpMessageSendingOperations brokerTemplate = new SimpMessagingTemplate(channel);
this.messageHandler = new TestWebSocketAnnotationMethodMessageHandler(brokerTemplate, channel, channel);
this.messageHandler.setApplicationContext(this.applicationContext);
this.messageHandler.afterPropertiesSet();
}
use of org.springframework.context.support.StaticApplicationContext in project spring-boot by spring-projects.
the class EndpointRequestTests method assertMatcher.
private RequestMatcherAssert assertMatcher(ServerWebExchangeMatcher matcher, PathMappedEndpoints pathMappedEndpoints) {
StaticApplicationContext context = new StaticApplicationContext();
context.registerBean(WebEndpointProperties.class);
if (pathMappedEndpoints != null) {
context.registerBean(PathMappedEndpoints.class, () -> pathMappedEndpoints);
WebEndpointProperties properties = context.getBean(WebEndpointProperties.class);
if (!properties.getBasePath().equals(pathMappedEndpoints.getBasePath())) {
properties.setBasePath(pathMappedEndpoints.getBasePath());
}
}
return assertThat(new RequestMatcherAssert(context, matcher));
}
use of org.springframework.context.support.StaticApplicationContext in project spring-boot by spring-projects.
the class DelegatingApplicationContextInitializerTests method noInitializers.
@Test
void noInitializers() {
StaticApplicationContext context = new StaticApplicationContext();
this.initializer.initialize(context);
}
use of org.springframework.context.support.StaticApplicationContext in project spring-boot by spring-projects.
the class WelcomePageRouterFunctionFactoryTests method setup.
@BeforeEach
void setup() {
this.applicationContext = new StaticApplicationContext();
this.applicationContext.refresh();
}
Aggregations