Use new backend features for extracted samples
Update extracted samples to make use of code folding and chomping. See gh-6313
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -31,7 +30,7 @@ public class ThirdPartyConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
class AnotherComponent {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.constructorbinding;
|
||||
|
||||
//tag::code[]
|
||||
import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
|
||||
@@ -28,18 +27,22 @@ import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
@ConfigurationProperties("acme")
|
||||
public class AcmeProperties {
|
||||
|
||||
// @fold:on // fields...
|
||||
private final boolean enabled;
|
||||
|
||||
private final InetAddress remoteAddress;
|
||||
|
||||
private final Security security;
|
||||
|
||||
// @fold:off
|
||||
|
||||
public AcmeProperties(boolean enabled, InetAddress remoteAddress, Security security) {
|
||||
this.enabled = enabled;
|
||||
this.remoteAddress = remoteAddress;
|
||||
this.security = security;
|
||||
}
|
||||
|
||||
// @fold:on // getters...
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
@@ -51,21 +54,26 @@ public class AcmeProperties {
|
||||
public Security getSecurity() {
|
||||
return this.security;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
public static class Security {
|
||||
|
||||
// @fold:on // fields...
|
||||
private final String username;
|
||||
|
||||
private final String password;
|
||||
|
||||
private final List<String> roles;
|
||||
|
||||
// @fold:off
|
||||
|
||||
public Security(String username, String password, @DefaultValue("USER") List<String> roles) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
// @fold:on // getters...
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
@@ -77,8 +85,8 @@ public class AcmeProperties {
|
||||
public List<String> getRoles() {
|
||||
return this.roles;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.datasize.constructorbinding;
|
||||
|
||||
// tag::code[]
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.ConstructorBinding;
|
||||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
@@ -28,16 +27,19 @@ import org.springframework.util.unit.DataUnit;
|
||||
@ConstructorBinding
|
||||
public class AppIoProperties {
|
||||
|
||||
// @fold:on // fields...
|
||||
private final DataSize bufferSize;
|
||||
|
||||
private final DataSize sizeThreshold;
|
||||
|
||||
// @fold:off
|
||||
public AppIoProperties(@DataSizeUnit(DataUnit.MEGABYTES) @DefaultValue("2MB") DataSize bufferSize,
|
||||
@DefaultValue("512B") DataSize sizeThreshold) {
|
||||
this.bufferSize = bufferSize;
|
||||
this.sizeThreshold = sizeThreshold;
|
||||
}
|
||||
|
||||
// @fold:on // getters...
|
||||
public DataSize getBufferSize() {
|
||||
return this.bufferSize;
|
||||
}
|
||||
@@ -45,6 +47,6 @@ public class AppIoProperties {
|
||||
public DataSize getSizeThreshold() {
|
||||
return this.sizeThreshold;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.datasize.javabeanbinding;
|
||||
|
||||
// tag::code[]
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.convert.DataSizeUnit;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
@@ -30,6 +29,7 @@ public class AppIoProperties {
|
||||
|
||||
private DataSize sizeThreshold = DataSize.ofBytes(512);
|
||||
|
||||
// @fold:on // getters/setters...
|
||||
public DataSize getBufferSize() {
|
||||
return this.bufferSize;
|
||||
}
|
||||
@@ -45,6 +45,6 @@ public class AppIoProperties {
|
||||
public void setSizeThreshold(DataSize sizeThreshold) {
|
||||
this.sizeThreshold = sizeThreshold;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.duration.constructorbinding;
|
||||
|
||||
// tag::code[]
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
@@ -29,16 +28,19 @@ import org.springframework.boot.convert.DurationUnit;
|
||||
@ConstructorBinding
|
||||
public class AppSystemProperties {
|
||||
|
||||
// @fold:on // fields...
|
||||
private final Duration sessionTimeout;
|
||||
|
||||
private final Duration readTimeout;
|
||||
|
||||
// @fold:off
|
||||
public AppSystemProperties(@DurationUnit(ChronoUnit.SECONDS) @DefaultValue("30s") Duration sessionTimeout,
|
||||
@DefaultValue("1000ms") Duration readTimeout) {
|
||||
this.sessionTimeout = sessionTimeout;
|
||||
this.readTimeout = readTimeout;
|
||||
}
|
||||
|
||||
// @fold:on // getters...
|
||||
public Duration getSessionTimeout() {
|
||||
return this.sessionTimeout;
|
||||
}
|
||||
@@ -46,6 +48,6 @@ public class AppSystemProperties {
|
||||
public Duration getReadTimeout() {
|
||||
return this.readTimeout;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.duration.javabeanbinding;
|
||||
|
||||
// tag::code[]
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
@@ -31,6 +30,7 @@ public class AppSystemProperties {
|
||||
|
||||
private Duration readTimeout = Duration.ofMillis(1000);
|
||||
|
||||
// @fold:on // getters / setters...
|
||||
public Duration getSessionTimeout() {
|
||||
return this.sessionTimeout;
|
||||
}
|
||||
@@ -46,6 +46,6 @@ public class AppSystemProperties {
|
||||
public void setReadTimeout(Duration readTimeout) {
|
||||
this.readTimeout = readTimeout;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.enable;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
|
||||
@@ -25,4 +24,3 @@ import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
public class MyApplication {
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.enable;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -25,7 +24,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class MyConfiguration {
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
class AcmeProperties {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.javabeanbinding;
|
||||
|
||||
//tag::code[]
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -33,6 +32,7 @@ public class AcmeProperties {
|
||||
|
||||
private final Security security = new Security();
|
||||
|
||||
// @fold:on // getters / setters...
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
@@ -52,6 +52,7 @@ public class AcmeProperties {
|
||||
public Security getSecurity() {
|
||||
return this.security;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
public static class Security {
|
||||
|
||||
@@ -61,6 +62,7 @@ public class AcmeProperties {
|
||||
|
||||
private List<String> roles = new ArrayList<>(Collections.singleton("USER"));
|
||||
|
||||
// @fold:on // getters / setters...
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
@@ -84,8 +86,8 @@ public class AcmeProperties {
|
||||
public void setRoles(List<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.merge.list;
|
||||
|
||||
//tag::code[]
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,7 +31,7 @@ public class AcmeProperties {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp: file
|
||||
|
||||
class MyPojo {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.merge.map;
|
||||
|
||||
//tag::code[]
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -32,7 +31,7 @@ public class AcmeProperties {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
class MyPojo {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.relaxed;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "acme.my-project.person")
|
||||
@@ -33,4 +32,3 @@ public class OwnerProperties {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.use;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@@ -37,7 +36,7 @@ public class MyService {
|
||||
// ...
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
class AcmeProperties {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.validate;
|
||||
|
||||
//tag::code[]
|
||||
import java.net.InetAddress;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
@@ -31,6 +30,7 @@ public class AcmeProperties {
|
||||
@NotNull
|
||||
private InetAddress remoteAddress;
|
||||
|
||||
// @fold:on // getters/setters...
|
||||
public InetAddress getRemoteAddress() {
|
||||
return this.remoteAddress;
|
||||
}
|
||||
@@ -38,6 +38,6 @@ public class AcmeProperties {
|
||||
public void setRemoteAddress(InetAddress remoteAddress) {
|
||||
this.remoteAddress = remoteAddress;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.validate.nested;
|
||||
|
||||
//tag::code[]
|
||||
import java.net.InetAddress;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -36,6 +35,7 @@ public class AcmeProperties {
|
||||
@Valid
|
||||
private final Security security = new Security();
|
||||
|
||||
// @fold:on // getters/setters...
|
||||
public InetAddress getRemoteAddress() {
|
||||
return this.remoteAddress;
|
||||
}
|
||||
@@ -47,12 +47,14 @@ public class AcmeProperties {
|
||||
public Security getSecurity() {
|
||||
return this.security;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
public static class Security {
|
||||
|
||||
@NotEmpty
|
||||
private String username;
|
||||
|
||||
// @fold:on // getters/setters...
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
@@ -60,8 +62,8 @@ public class AcmeProperties {
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.valueinjection;
|
||||
|
||||
// tag::code[]
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -29,4 +28,3 @@ public class MyBean {
|
||||
// ...
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.messaging;
|
||||
|
||||
// tag::code[]
|
||||
import org.apache.kafka.common.serialization.Serdes;
|
||||
import org.apache.kafka.streams.KeyValue;
|
||||
import org.apache.kafka.streams.StreamsBuilder;
|
||||
@@ -41,4 +40,3 @@ public class KafkaStreamsConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.nosql;
|
||||
|
||||
// tag::code[]
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.cache.CouchbaseCacheManagerBuilderCustomizer;
|
||||
@@ -38,4 +37,3 @@ public class CouchbaseCacheManagerConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.nosql;
|
||||
|
||||
// tag::code[]
|
||||
import org.neo4j.driver.Driver;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -34,4 +33,3 @@ public class Neo4jReactiveTransactionManagerConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.nosql;
|
||||
|
||||
// tag::code[]
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer;
|
||||
@@ -38,4 +37,3 @@ public class RedisCacheManagerConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.profiles;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@@ -27,4 +26,3 @@ public class ProductionConfiguration {
|
||||
// ...
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.resttemplate;
|
||||
|
||||
// tag::code[]
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.client.RestTemplateBuilderConfigurer;
|
||||
@@ -34,4 +33,3 @@ public class RestTemplateBuilderConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.resttemplate;
|
||||
|
||||
// tag::code[]
|
||||
import org.apache.http.HttpException;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpRequest;
|
||||
@@ -56,4 +55,3 @@ public class RestTemplateProxyCustomizer implements RestTemplateCustomizer {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.security;
|
||||
|
||||
// tag::code[]
|
||||
import org.springframework.boot.autoconfigure.security.reactive.PathRequest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -37,4 +36,3 @@ public class CustomWebFluxSecurityConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.springapplication;
|
||||
|
||||
//tag::code[]
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
@@ -35,4 +34,3 @@ public class ApplicationArgumentsExample {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.springapplication;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -29,4 +28,3 @@ public class CommandLineRunnerExample implements CommandLineRunner {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.springapplication.availability;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.boot.availability.AvailabilityChangeEvent;
|
||||
import org.springframework.boot.availability.LivenessState;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
@@ -41,7 +40,7 @@ public class LocalCacheVerifier {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
class CacheCompletelyBrokenException extends RuntimeException {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.springapplication.availability;
|
||||
|
||||
// tag::code[]
|
||||
import org.springframework.boot.availability.AvailabilityChangeEvent;
|
||||
import org.springframework.boot.availability.ReadinessState;
|
||||
import org.springframework.context.event.EventListener;
|
||||
@@ -38,4 +37,3 @@ public class ReadinessStateExporter {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.springapplication.exitcode;
|
||||
|
||||
// tag::code[]
|
||||
import org.springframework.boot.ExitCodeGenerator;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -35,4 +34,3 @@ public class MyApplication {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -23,12 +23,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class MyApplication {
|
||||
|
||||
// tag::code[]
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(MyApplication.class);
|
||||
application.setBannerMode(Banner.Mode.OFF);
|
||||
application.run(args);
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
}
|
||||
|
||||
@@ -22,10 +22,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class MyApplication {
|
||||
|
||||
// tag::code[]
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MyApplication.class, args);
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing;
|
||||
|
||||
// tag::code[]
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -35,4 +34,3 @@ class ApplicationArgumentTests {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing;
|
||||
|
||||
// tag::code[]
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -38,4 +37,3 @@ class MockMvcTests {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing;
|
||||
|
||||
// tag::code[]
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -34,4 +33,3 @@ class MockWebTestClientTests {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing;
|
||||
|
||||
// tag::code[]
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
@@ -35,4 +34,3 @@ class OutputCaptureTests {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing;
|
||||
|
||||
// tag::code[]
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,4 +35,3 @@ class RandomPortTestRestTemplateTests {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing;
|
||||
|
||||
// tag::code[]
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -33,4 +32,3 @@ class RandomPortWebTestClientTests {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing.jmx;
|
||||
|
||||
// tag::code[]
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
|
||||
@@ -45,4 +44,3 @@ class SampleJmxTests {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing.restdocs.restassured;
|
||||
|
||||
// tag::code[]
|
||||
import org.springframework.boot.test.autoconfigure.restdocs.RestDocsRestAssuredConfigurationCustomizer;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.restdocs.restassured3.RestAssuredRestDocumentationConfigurer;
|
||||
@@ -31,4 +30,3 @@ public class AdvancedRestDocsConfiguration implements RestDocsRestAssuredConfigu
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing.restdocs.restassured;
|
||||
|
||||
// tag::code[]
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -36,9 +35,15 @@ class UserDocumentationTests {
|
||||
|
||||
@Test
|
||||
void listUsers(@Autowired RequestSpecification documentationSpec, @LocalServerPort int port) {
|
||||
given(documentationSpec).filter(document("list-users")).when().port(port).get("/").then().assertThat()
|
||||
.statusCode(is(200));
|
||||
// @formatter:off
|
||||
given(documentationSpec)
|
||||
.filter(document("list-users"))
|
||||
.when()
|
||||
.port(port)
|
||||
.get("/")
|
||||
.then().assertThat()
|
||||
.statusCode(is(200));
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing.restdocs.webclient;
|
||||
|
||||
// tag::code[]
|
||||
import org.springframework.boot.test.autoconfigure.restdocs.RestDocsWebTestClientConfigurationCustomizer;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentationConfigurer;
|
||||
@@ -30,4 +29,3 @@ public class AdvancedRestDocsConfiguration implements RestDocsWebTestClientConfi
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing.restdocs.webclient;
|
||||
|
||||
// tag::code[]
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -35,9 +34,15 @@ class UsersDocumentationTests {
|
||||
|
||||
@Test
|
||||
void listUsers() {
|
||||
this.webTestClient.get().uri("/").exchange().expectStatus().isOk().expectBody()
|
||||
.consumeWith(document("list-users"));
|
||||
// @formatter:off
|
||||
this.webTestClient
|
||||
.get().uri("/")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.isOk()
|
||||
.expectBody()
|
||||
.consumeWith(document("list-users"));
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.testing.webclient;
|
||||
|
||||
// tag::code[]
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -56,4 +55,3 @@ class SampleWebClientTests {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications;
|
||||
|
||||
//tag::code[]
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||
@@ -40,7 +39,7 @@ public class HttpMessageConvertersConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
class AdditionalHttpMessageConverter extends AbstractHttpMessageConverter<Object> {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications;
|
||||
|
||||
// tag::code[]
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
@@ -32,4 +31,3 @@ public class TomcatServerCustomizer implements WebServerFactoryCustomizer<Tomcat
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.json;
|
||||
|
||||
//tag::code[]
|
||||
import java.io.IOException;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
@@ -59,7 +58,7 @@ public class MyJsonComponent {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
class MyObject {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.json.object;
|
||||
|
||||
//tag::code[]
|
||||
import java.io.IOException;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
@@ -57,7 +56,7 @@ public class MyJsonComponent {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
class MyObject {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.servlet;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
@@ -38,4 +37,3 @@ public class CorsConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.servlet;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.boot.web.server.ErrorPage;
|
||||
import org.springframework.boot.web.server.ErrorPageRegistrar;
|
||||
import org.springframework.boot.web.server.ErrorPageRegistry;
|
||||
@@ -37,4 +36,3 @@ public class ErrorPageConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.servlet;
|
||||
|
||||
//tag::code[]
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -44,7 +43,7 @@ public class MyControllerAdvice extends ResponseEntityExceptionHandler {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
class AcmeController {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.servlet;
|
||||
|
||||
//tag::code[]
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -38,4 +37,3 @@ public class MyErrorViewResolver implements ErrorViewResolver {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.servlet;
|
||||
|
||||
//tag::code[]
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
@@ -55,7 +54,7 @@ public class MyRestController {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
interface UserRepository extends CrudRepository<User, Long> {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.servlet;
|
||||
|
||||
//tag::code[]
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
@@ -43,7 +42,7 @@ public class ServletFilterConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
class MyFilter extends GenericFilterBean {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.webflux;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.boot.web.codec.CodecCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -35,4 +34,3 @@ public class CodecConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.webflux;
|
||||
|
||||
//tag::code[]
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.WebProperties.Resources;
|
||||
@@ -56,4 +55,3 @@ public class CustomErrorWebExceptionHandler extends AbstractErrorWebExceptionHan
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.webflux;
|
||||
|
||||
//tag::code[]
|
||||
import java.util.List;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -58,7 +57,7 @@ public class MyRestController {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
// @chomp:file
|
||||
|
||||
interface UserRepository extends ReactiveCrudRepository<User, Long> {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.webflux.fn;
|
||||
|
||||
//tag::code[]
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -45,4 +44,3 @@ public class RoutingConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.webapplications.webflux.fn;
|
||||
|
||||
//tag::code[]
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -27,19 +26,15 @@ import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
public class UserHandler {
|
||||
|
||||
public Mono<ServerResponse> getUser(ServerRequest request) {
|
||||
// ...
|
||||
return ServerResponse.ok().build();
|
||||
/**/ return ServerResponse.ok().build();
|
||||
}
|
||||
|
||||
public Mono<ServerResponse> getUserCustomers(ServerRequest request) {
|
||||
// ...
|
||||
return ServerResponse.ok().build();
|
||||
/**/ return ServerResponse.ok().build();
|
||||
}
|
||||
|
||||
public Mono<ServerResponse> deleteUser(ServerRequest request) {
|
||||
// ...
|
||||
return ServerResponse.ok().build();
|
||||
/**/ return ServerResponse.ok().build();
|
||||
}
|
||||
|
||||
}
|
||||
// end::code[]
|
||||
|
||||
Reference in New Issue
Block a user