Refine spring-boot-docs package restructure
Refine the package restructure started in 91ccc23462 to help provide
a solid foundation for code snippets. This commit renames many of the
classes so that they no longer end in `Example`. It also removes some
of the inner types that were previously used. Many tag comments have
also been moved to ensure that `import` statements are available in
the docs.
Closes gh-25089
This commit is contained in:
@@ -36,12 +36,12 @@ import org.springframework.context.annotation.Import;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link MetricsHealthMicrometerExportExample}.
|
||||
* Tests for {@link MetricsHealthMicrometerExport}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@SpringBootTest
|
||||
class MetricsHealthMicrometerExportExampleTests {
|
||||
class MetricsHealthMicrometerExportTests {
|
||||
|
||||
@Autowired
|
||||
private MeterRegistry registry;
|
||||
@@ -53,14 +53,14 @@ class MetricsHealthMicrometerExportExampleTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Import(MetricsHealthMicrometerExportExample.HealthMetricsConfiguration.class)
|
||||
@Import(MetricsHealthMicrometerExport.HealthMetricsConfiguration.class)
|
||||
@ImportAutoConfiguration(classes = { HealthContributorAutoConfiguration.class, MetricsAutoConfiguration.class,
|
||||
HealthEndpointAutoConfiguration.class })
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
MetricsHealthMicrometerExportExample example() {
|
||||
return new MetricsHealthMicrometerExportExample();
|
||||
MetricsHealthMicrometerExport example() {
|
||||
return new MetricsHealthMicrometerExport();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -32,14 +32,14 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for {@link BasicDataSourceExample}.
|
||||
* Test for {@link BasicDataSourceConfiguration}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(properties = "app.datasource.jdbcUrl=jdbc:h2:mem:basic;DB_CLOSE_DELAY=-1")
|
||||
@Import(BasicDataSourceExample.BasicDataSourceConfiguration.class)
|
||||
class BasicDataSourceExampleTests {
|
||||
@Import(BasicDataSourceConfiguration.class)
|
||||
class BasicDataSourceConfigurationTests {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
@@ -32,14 +32,14 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link CompleteTwoDataSourcesExample}.
|
||||
* Tests for {@link CompleteDataSourcesConfiguration}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest
|
||||
@Import(CompleteTwoDataSourcesExample.CompleteDataSourcesConfiguration.class)
|
||||
class CompleteTwoDataSourcesExampleTests {
|
||||
@Import(CompleteDataSourcesConfiguration.class)
|
||||
class CompleteDataSourcesConfigurationTests {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
@@ -33,15 +33,15 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for {@link SimpleDataSourceExample}.
|
||||
* Test for {@link ConfigurableDataSourceConfiguration}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(properties = { "app.datasource.url=jdbc:h2:mem:configurable;DB_CLOSE_DELAY=-1",
|
||||
"app.datasource.configuration.maximum-pool-size=42" })
|
||||
@Import(ConfigurableDataSourceExample.ConfigurableDataSourceConfiguration.class)
|
||||
class ConfigurableDataSourceExampleTests {
|
||||
@Import(ConfigurableDataSourceConfiguration.class)
|
||||
class ConfigurableDataSourceConfigurationTests {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
@@ -33,15 +33,15 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for {@link SimpleDataSourceExample}.
|
||||
* Test for {@link SimpleDataSourceConfiguration}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(properties = { "app.datasource.jdbc-url=jdbc:h2:mem:simple;DB_CLOSE_DELAY=-1",
|
||||
"app.datasource.maximum-pool-size=42" })
|
||||
@Import(SimpleDataSourceExample.SimpleDataSourceConfiguration.class)
|
||||
class SimpleDataSourceExampleTests {
|
||||
@Import(SimpleDataSourceConfiguration.class)
|
||||
class SimpleDataSourceConfigurationTests {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
@@ -33,15 +33,15 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link SimpleTwoDataSourcesExample}.
|
||||
* Tests for {@link SimpleDataSourcesConfiguration}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(properties = { "app.datasource.second.url=jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1",
|
||||
"app.datasource.second.max-total=42" })
|
||||
@Import(SimpleTwoDataSourcesExample.SimpleDataSourcesConfiguration.class)
|
||||
class SimpleTwoDataSourcesExampleTests {
|
||||
@Import(SimpleDataSourcesConfiguration.class)
|
||||
class SimpleDataSourcesConfigurationTests {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
@@ -14,15 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.context.embedded;
|
||||
package org.springframework.boot.docs.howto.embeddedwebservers;
|
||||
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.tomcat.util.http.LegacyCookieProcessor;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.docs.howto.embeddedwebservers.TomcatLegacyCookieProcessorExample;
|
||||
import org.springframework.boot.docs.howto.embeddedwebservers.TomcatLegacyCookieProcessorExample.LegacyCookieProcessorConfiguration;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
|
||||
import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor;
|
||||
@@ -33,11 +31,11 @@ import org.springframework.context.annotation.Configuration;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link TomcatLegacyCookieProcessorExample}.
|
||||
* Tests for {@link LegacyCookieProcessorConfiguration}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class TomcatLegacyCookieProcessorExampleTests {
|
||||
class LegacyCookieProcessorConfigurationTests {
|
||||
|
||||
@Test
|
||||
void cookieProcessorIsCustomized() {
|
||||
@@ -24,18 +24,18 @@ import org.springframework.core.env.StandardEnvironment;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link EnvironmentPostProcessorExample}.
|
||||
* Tests for {@link ExampleEnvironmentPostProcessor}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class EnvironmentPostProcessorExampleTests {
|
||||
class ExampleEnvironmentPostProcessorTests {
|
||||
|
||||
private final StandardEnvironment environment = new StandardEnvironment();
|
||||
|
||||
@Test
|
||||
void applyEnvironmentPostProcessor() {
|
||||
assertThat(this.environment.containsProperty("test.foo.bar")).isFalse();
|
||||
new EnvironmentPostProcessorExample().postProcessEnvironment(this.environment, new SpringApplication());
|
||||
new ExampleEnvironmentPostProcessor().postProcessEnvironment(this.environment, new SpringApplication());
|
||||
assertThat(this.environment.containsProperty("test.foo.bar")).isTrue();
|
||||
assertThat(this.environment.getProperty("test.foo.bar")).isEqualTo("value");
|
||||
}
|
||||
Reference in New Issue
Block a user