use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class ConfigurationPropertiesBindingPostProcessorTests method testValidationWithCustomValidatorNotSupported.
@Test
public void testValidationWithCustomValidatorNotSupported() {
MockEnvironment env = new MockEnvironment();
env.setProperty("test.foo", "bar");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(env);
this.context.register(TestConfigurationWithCustomValidator.class, PropertyWithValidatingSetter.class);
assertBindingFailure(1);
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class SpringBootJoranConfiguratorTests method setup.
@Before
public void setup() {
this.environment = new MockEnvironment();
this.initializationContext = new LoggingInitializationContext(this.environment);
this.configurator = new SpringBootJoranConfigurator(this.initializationContext);
StaticLoggerBinder binder = StaticLoggerBinder.getSingleton();
this.context = (LoggerContext) binder.getLoggerFactory();
this.logger = this.context.getLogger(getClass());
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class LogbackLoggingSystemTests method setup.
@Before
public void setup() {
this.loggingSystem.cleanUp();
this.logger = new SLF4JLogFactory().getInstance(getClass().getName());
this.environment = new MockEnvironment();
this.initializationContext = new LoggingInitializationContext(this.environment);
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class LogbackLoggingSystemTests method testConsolePatternProperty.
@Test
public void testConsolePatternProperty() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("logging.pattern.console", "%logger %msg");
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(environment);
this.loggingSystem.initialize(loggingInitializationContext, null, null);
this.logger.info("Hello world");
String output = this.output.toString().trim();
assertThat(getLineWithText(output, "Hello world")).doesNotContain("INFO");
}
use of org.springframework.mock.env.MockEnvironment in project spring-boot by spring-projects.
the class LogbackLoggingSystemTests method testFilePatternProperty.
@Test
public void testFilePatternProperty() throws Exception {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("logging.pattern.file", "%logger %msg");
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(environment);
File file = new File(tmpDir(), "logback-test.log");
LogFile logFile = getLogFile(file.getPath(), null);
this.loggingSystem.initialize(loggingInitializationContext, null, logFile);
this.logger.info("Hello world");
String output = this.output.toString().trim();
assertThat(getLineWithText(output, "Hello world")).contains("INFO");
assertThat(getLineWithText(file, "Hello world")).doesNotContain("INFO");
}
Aggregations