use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.
the class SimpAnnotationMethodMessageHandlerTests method setup.
@BeforeEach
public void setup() {
SimpMessagingTemplate brokerTemplate = new SimpMessagingTemplate(this.channel);
brokerTemplate.setMessageConverter(this.converter);
this.messageHandler = new TestSimpAnnotationMethodMessageHandler(brokerTemplate, this.channel, this.channel);
this.messageHandler.setApplicationContext(new StaticApplicationContext());
this.messageHandler.setValidator(new StringTestValidator(TEST_INVALID_VALUE));
this.messageHandler.afterPropertiesSet();
}
use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.
the class DynamicPropertiesContextCustomizerTests method emptyPropertyNameResultsInException.
@Test
void emptyPropertyNameResultsInException() throws Exception {
DynamicPropertiesContextCustomizer customizer = customizerFor("emptyName");
ConfigurableApplicationContext context = new StaticApplicationContext();
assertThatIllegalArgumentException().isThrownBy(() -> customizer.customizeContext(context, mock(MergedContextConfiguration.class))).withMessage("'name' must not be null or blank");
}
use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.
the class DynamicPropertiesContextCustomizerTests method nullValueSupplierResultsInException.
@Test
void nullValueSupplierResultsInException() throws Exception {
DynamicPropertiesContextCustomizer customizer = customizerFor("nullValueSupplier");
ConfigurableApplicationContext context = new StaticApplicationContext();
assertThatIllegalArgumentException().isThrownBy(() -> customizer.customizeContext(context, mock(MergedContextConfiguration.class))).withMessage("'valueSupplier' must not be null");
}
use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.
the class DynamicPropertiesContextCustomizerTests method customizeContextAddsPropertySource.
@Test
void customizeContextAddsPropertySource() throws Exception {
ConfigurableApplicationContext context = new StaticApplicationContext();
DynamicPropertiesContextCustomizer customizer = customizerFor("valid1", "valid2");
customizer.customizeContext(context, mock(MergedContextConfiguration.class));
ConfigurableEnvironment environment = context.getEnvironment();
assertThat(environment.getRequiredProperty("p1a")).isEqualTo("v1a");
assertThat(environment.getRequiredProperty("p1b")).isEqualTo("v1b");
assertThat(environment.getRequiredProperty("p2a")).isEqualTo("v2a");
assertThat(environment.getRequiredProperty("p2b")).isEqualTo("v2b");
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class ExcludedAuthenticationHandlerAuthenticationPolicyTests method verifyOperation.
@Test
public void verifyOperation() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
val input = new ExcludedAuthenticationHandlerAuthenticationPolicy(Set.of("Hello"), true);
assertTrue(input.isSatisfiedBy(CoreAuthenticationTestUtils.getAuthentication(), Set.of(), applicationContext, Optional.empty()).isSuccess());
}
Aggregations