|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2017 the original author or authors.
|
|
|
|
* Copyright 2012-2019 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -16,7 +16,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.context;
|
|
|
|
package org.springframework.boot.context;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Assume;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
@ -26,6 +25,9 @@ import org.springframework.core.env.ConfigurableEnvironment;
|
|
|
|
import org.springframework.core.env.StandardEnvironment;
|
|
|
|
import org.springframework.core.env.StandardEnvironment;
|
|
|
|
import org.springframework.test.context.support.TestPropertySourceUtils;
|
|
|
|
import org.springframework.test.context.support.TestPropertySourceUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Tests for {@link FileEncodingApplicationListener}.
|
|
|
|
* Tests for {@link FileEncodingApplicationListener}.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -40,12 +42,13 @@ public class FileEncodingApplicationListenerTests {
|
|
|
|
private final ApplicationEnvironmentPreparedEvent event = new ApplicationEnvironmentPreparedEvent(
|
|
|
|
private final ApplicationEnvironmentPreparedEvent event = new ApplicationEnvironmentPreparedEvent(
|
|
|
|
new SpringApplication(), new String[0], this.environment);
|
|
|
|
new SpringApplication(), new String[0], this.environment);
|
|
|
|
|
|
|
|
|
|
|
|
@Test(expected = IllegalStateException.class)
|
|
|
|
@Test
|
|
|
|
public void testIllegalState() {
|
|
|
|
public void testIllegalState() {
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
|
|
|
|
"spring.mandatory_file_encoding=FOO");
|
|
|
|
"spring.mandatory_file_encoding=FOO");
|
|
|
|
ConfigurationPropertySources.attach(this.environment);
|
|
|
|
ConfigurationPropertySources.attach(this.environment);
|
|
|
|
this.initializer.onApplicationEvent(this.event);
|
|
|
|
assertThatIllegalStateException()
|
|
|
|
|
|
|
|
.isThrownBy(() -> this.initializer.onApplicationEvent(this.event));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -55,7 +58,7 @@ public class FileEncodingApplicationListenerTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testSunnyDayMandated() {
|
|
|
|
public void testSunnyDayMandated() {
|
|
|
|
Assume.assumeNotNull(System.getProperty("file.encoding"));
|
|
|
|
assertThat(System.getProperty("file.encoding")).isNotNull();
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
|
|
|
|
"spring.mandatory_file_encoding:" + System.getProperty("file.encoding"));
|
|
|
|
"spring.mandatory_file_encoding:" + System.getProperty("file.encoding"));
|
|
|
|
ConfigurationPropertySources.attach(this.environment);
|
|
|
|
ConfigurationPropertySources.attach(this.environment);
|
|
|
|