Remove deprecated 2.2 code

See gh-19699
This commit is contained in:
Scott Frederick 2020-01-14 13:45:01 -06:00 committed by Stephane Nicoll
parent 2e32cb2af1
commit 8f102aee68
26 changed files with 20 additions and 1387 deletions

View File

@ -1,112 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.autoconfigure.endpoint.condition;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.EndpointExtension;
import org.springframework.context.annotation.Conditional;
import org.springframework.core.env.Environment;
/**
* {@link Conditional @Conditional} that checks whether an endpoint is enabled or not.
* Matches according to the endpoints specific {@link Environment} property, falling back
* to {@code management.endpoints.enabled-by-default} or failing that
* {@link Endpoint#enableByDefault()}.
* <p>
* When placed on a {@code @Bean} method, the endpoint defaults to the return type of the
* factory method:
*
* <pre class="code">
* &#064;Configuration
* public class MyConfiguration {
*
* &#064;ConditionalOnEnableEndpoint
* &#064;Bean
* public MyEndpoint myEndpoint() {
* ...
* }
*
* }</pre>
* <p>
* It is also possible to use the same mechanism for extensions:
*
* <pre class="code">
* &#064;Configuration
* public class MyConfiguration {
*
* &#064;ConditionalOnEnableEndpoint
* &#064;Bean
* public MyEndpointWebExtension myEndpointWebExtension() {
* ...
* }
*
* }</pre>
* <p>
* In the sample above, {@code MyEndpointWebExtension} will be created if the endpoint is
* enabled as defined by the rules above. {@code MyEndpointWebExtension} must be a regular
* extension that refers to an endpoint, something like:
*
* <pre class="code">
* &#064;EndpointWebExtension(endpoint = MyEndpoint.class)
* public class MyEndpointWebExtension {
*
* }</pre>
* <p>
* Alternatively, the target endpoint can be manually specified for components that should
* only be created when a given endpoint is enabled:
*
* <pre class="code">
* &#064;Configuration
* public class MyConfiguration {
*
* &#064;ConditionalOnEnableEndpoint(endpoint = MyEndpoint.class)
* &#064;Bean
* public MyComponent myComponent() {
* ...
* }
*
* }</pre>
*
* @author Stephane Nicoll
* @since 2.0.0
* @see Endpoint
* @deprecated as of 2.2.0 in favor of
* {@link ConditionalOnAvailableEndpoint @ConditionalOnAvailableEndpoint}
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.TYPE })
@Documented
@Conditional(OnEnabledEndpointCondition.class)
@Deprecated
public @interface ConditionalOnEnabledEndpoint {
/**
* The endpoint type that should be checked. Inferred when the return type of the
* {@code @Bean} method is either an {@link Endpoint @Endpoint} or an
* {@link EndpointExtension @EndpointExtension}.
* @return the endpoint type to check
* @since 2.0.6
*/
Class<?> endpoint() default Void.class;
}

View File

@ -1,40 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.autoconfigure.endpoint.condition;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* A condition that checks if an endpoint is enabled.
*
* @author Stephane Nicoll
* @author Andy Wilkinson
* @author Phillip Webb
* @see ConditionalOnEnabledEndpoint
* @deprecated as of 2.2.0 in favor of {@link OnAvailableEndpointCondition}
*/
@Deprecated
class OnEnabledEndpointCondition extends AbstractEndpointCondition {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
return getEnablementOutcome(context, metadata, ConditionalOnEnabledEndpoint.class);
}
}

View File

@ -1,277 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.autoconfigure.endpoint.condition;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.endpoint.EndpointFilter;
import org.springframework.boot.actuate.endpoint.ExposableEndpoint;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.EndpointExtension;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link ConditionalOnEnabledEndpoint @ConditionalOnEnabledEndpoint}.
*
* @author Stephane Nicoll
* @author Andy Wilkinson
*/
@Deprecated
@SuppressWarnings("deprecation")
class ConditionalOnEnabledEndpointTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
@Test
void outcomeWhenEndpointEnabledPropertyIsTrueShouldMatch() {
this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=true")
.withUserConfiguration(FooEndpointEnabledByDefaultFalseConfiguration.class)
.run((context) -> assertThat(context).hasBean("foo"));
}
@Test
void outcomeWhenEndpointEnabledPropertyIsFalseShouldNotMatch() {
this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=false")
.withUserConfiguration(FooEndpointEnabledByDefaultTrueConfiguration.class)
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
}
@Test
void outcomeWhenNoEndpointPropertyAndUserDefinedDefaultIsTrueShouldMatch() {
this.contextRunner.withPropertyValues("management.endpoints.enabled-by-default=true")
.withUserConfiguration(FooEndpointEnabledByDefaultFalseConfiguration.class)
.run((context) -> assertThat(context).hasBean("foo"));
}
@Test
void outcomeWhenNoEndpointPropertyAndUserDefinedDefaultIsFalseShouldNotMatch() {
this.contextRunner.withPropertyValues("management.endpoints.enabled-by-default=false")
.withUserConfiguration(FooEndpointEnabledByDefaultTrueConfiguration.class)
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
}
@Test
void outcomeWhenNoPropertiesAndAnnotationIsEnabledByDefaultShouldMatch() {
this.contextRunner.withUserConfiguration(FooEndpointEnabledByDefaultTrueConfiguration.class)
.run((context) -> assertThat(context).hasBean("foo"));
}
@Test
void outcomeWhenNoPropertiesAndAnnotationIsNotEnabledByDefaultShouldNotMatch() {
this.contextRunner.withUserConfiguration(FooEndpointEnabledByDefaultFalseConfiguration.class)
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
}
@Test
void outcomeWhenNoPropertiesAndExtensionAnnotationIsEnabledByDefaultShouldMatch() {
this.contextRunner.withUserConfiguration(FooEndpointAndExtensionEnabledByDefaultTrueConfiguration.class)
.run((context) -> assertThat(context).hasBean("foo").hasBean("fooExt"));
}
@Test
void outcomeWhenNoPropertiesAndExtensionAnnotationIsNotEnabledByDefaultShouldNotMatch() {
this.contextRunner.withUserConfiguration(FooEndpointAndExtensionEnabledByDefaultFalseConfiguration.class)
.run((context) -> assertThat(context).doesNotHaveBean("foo").doesNotHaveBean("fooExt"));
}
@Test
void outcomeWithReferenceWhenNoPropertiesShouldMatch() {
this.contextRunner
.withUserConfiguration(FooEndpointEnabledByDefaultTrue.class,
ComponentEnabledIfEndpointIsEnabledConfiguration.class)
.run((context) -> assertThat(context).hasBean("fooComponent"));
}
@Test
void outcomeWithReferenceWhenEndpointEnabledPropertyIsTrueShouldMatch() {
this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=true")
.withUserConfiguration(FooEndpointEnabledByDefaultTrue.class,
ComponentEnabledIfEndpointIsEnabledConfiguration.class)
.run((context) -> assertThat(context).hasBean("fooComponent"));
}
@Test
void outcomeWithReferenceWhenEndpointEnabledPropertyIsFalseShouldNotMatch() {
this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=false")
.withUserConfiguration(FooEndpointEnabledByDefaultTrue.class,
ComponentEnabledIfEndpointIsEnabledConfiguration.class)
.run((context) -> assertThat(context).doesNotHaveBean("fooComponent"));
}
@Test
void outcomeWithNoReferenceShouldFail() {
this.contextRunner.withUserConfiguration(ComponentWithNoEndpointReferenceConfiguration.class).run((context) -> {
assertThat(context).hasFailed();
assertThat(context.getStartupFailure().getCause().getMessage())
.contains("No endpoint is specified and the return type of the @Bean method "
+ "is neither an @Endpoint, nor an @EndpointExtension");
});
}
@Test
void outcomeWhenEndpointEnabledPropertyIsTrueAndMixedCaseShouldMatch() {
this.contextRunner.withPropertyValues("management.endpoint.foo-bar.enabled=true")
.withUserConfiguration(FooBarEndpointEnabledByDefaultFalseConfiguration.class)
.run((context) -> assertThat(context).hasBean("fooBar"));
}
@Test
void outcomeWhenEndpointEnabledPropertyIsFalseOnClassShouldNotMatch() {
this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=false")
.withUserConfiguration(FooEndpointEnabledByDefaultTrueOnConfigurationConfiguration.class)
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
}
@Endpoint(id = "foo", enableByDefault = true)
static class FooEndpointEnabledByDefaultTrue {
}
@Endpoint(id = "foo", enableByDefault = false)
static class FooEndpointEnabledByDefaultFalse {
}
@Endpoint(id = "fooBar", enableByDefault = false)
static class FooBarEndpointEnabledByDefaultFalse {
}
@EndpointExtension(endpoint = FooEndpointEnabledByDefaultTrue.class, filter = TestFilter.class)
static class FooEndpointExtensionEnabledByDefaultTrue {
}
@EndpointExtension(endpoint = FooEndpointEnabledByDefaultFalse.class, filter = TestFilter.class)
static class FooEndpointExtensionEnabledByDefaultFalse {
}
static class TestFilter implements EndpointFilter<ExposableEndpoint<?>> {
@Override
public boolean match(ExposableEndpoint<?> endpoint) {
return true;
}
}
@Configuration(proxyBeanMethods = false)
static class FooEndpointEnabledByDefaultTrueConfiguration {
@Bean
@ConditionalOnEnabledEndpoint
FooEndpointEnabledByDefaultTrue foo() {
return new FooEndpointEnabledByDefaultTrue();
}
}
@Configuration(proxyBeanMethods = false)
@ConditionalOnEnabledEndpoint(endpoint = FooEndpointEnabledByDefaultTrue.class)
static class FooEndpointEnabledByDefaultTrueOnConfigurationConfiguration {
@Bean
FooEndpointEnabledByDefaultTrue foo() {
return new FooEndpointEnabledByDefaultTrue();
}
}
@Configuration(proxyBeanMethods = false)
static class FooEndpointEnabledByDefaultFalseConfiguration {
@Bean
@ConditionalOnEnabledEndpoint
FooEndpointEnabledByDefaultFalse foo() {
return new FooEndpointEnabledByDefaultFalse();
}
}
@Configuration(proxyBeanMethods = false)
static class FooBarEndpointEnabledByDefaultFalseConfiguration {
@Bean
@ConditionalOnEnabledEndpoint
FooBarEndpointEnabledByDefaultFalse fooBar() {
return new FooBarEndpointEnabledByDefaultFalse();
}
}
@Configuration(proxyBeanMethods = false)
static class FooEndpointAndExtensionEnabledByDefaultTrueConfiguration {
@Bean
@ConditionalOnEnabledEndpoint
FooEndpointEnabledByDefaultTrue foo() {
return new FooEndpointEnabledByDefaultTrue();
}
@Bean
@ConditionalOnEnabledEndpoint
FooEndpointExtensionEnabledByDefaultTrue fooExt() {
return new FooEndpointExtensionEnabledByDefaultTrue();
}
}
@Configuration(proxyBeanMethods = false)
static class FooEndpointAndExtensionEnabledByDefaultFalseConfiguration {
@Bean
@ConditionalOnEnabledEndpoint
FooEndpointEnabledByDefaultFalse foo() {
return new FooEndpointEnabledByDefaultFalse();
}
@Bean
@ConditionalOnEnabledEndpoint
FooEndpointExtensionEnabledByDefaultFalse fooExt() {
return new FooEndpointExtensionEnabledByDefaultFalse();
}
}
@Configuration(proxyBeanMethods = false)
static class ComponentEnabledIfEndpointIsEnabledConfiguration {
@Bean
@ConditionalOnEnabledEndpoint(endpoint = FooEndpointEnabledByDefaultTrue.class)
String fooComponent() {
return "foo";
}
}
@Configuration(proxyBeanMethods = false)
static class ComponentWithNoEndpointReferenceConfiguration {
@Bean
@ConditionalOnEnabledEndpoint
String fooComponent() {
return "foo";
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,13 +25,6 @@ package org.springframework.boot.actuate.endpoint.http;
*/
public final class ActuatorMediaType {
/**
* Constant for the Actuator V1 media type.
* @deprecated since 2.2.0 as the v1 format is no longer supported
*/
@Deprecated
public static final String V1_JSON = "application/vnd.spring-boot.actuator.v1+json";
/**
* Constant for the Actuator {@link ApiVersion#V2 v2} media type.
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,7 +25,6 @@ import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.ConfirmType;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@ -289,17 +288,6 @@ public class RabbitProperties {
this.requestedChannelMax = requestedChannelMax;
}
@DeprecatedConfigurationProperty(reason = "replaced to support additional confirm types",
replacement = "spring.rabbitmq.publisher-confirm-type")
public boolean isPublisherConfirms() {
return ConfirmType.CORRELATED.equals(this.publisherConfirmType);
}
@Deprecated
public void setPublisherConfirms(boolean publisherConfirms) {
this.publisherConfirmType = (publisherConfirms) ? ConfirmType.CORRELATED : ConfirmType.NONE;
}
public boolean isPublisherReturns() {
return this.publisherReturns;
}
@ -732,28 +720,6 @@ public class RabbitProperties {
this.maxConcurrency = maxConcurrency;
}
/**
* Return the number of messages processed in one transaction.
* @return the number of messages
* @deprecated since 2.2.0 in favor of {@link SimpleContainer#getBatchSize()}
*/
@DeprecatedConfigurationProperty(replacement = "spring.rabbitmq.listener.simple.batch-size")
@Deprecated
public Integer getTransactionSize() {
return getBatchSize();
}
/**
* Set the number of messages processed in one transaction.
* @param transactionSize the number of messages
* @deprecated since 2.2.0 in favor of
* {@link SimpleContainer#setBatchSize(Integer)}
*/
@Deprecated
public void setTransactionSize(Integer transactionSize) {
setBatchSize(transactionSize);
}
public Integer getBatchSize() {
return this.batchSize;
}

View File

@ -1,49 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.boot.ApplicationRunner;
/**
* {@link ApplicationRunner} to {@link JobLauncher launch} Spring Batch jobs. Runs all
* jobs in the surrounding context by default. Can also be used to launch a specific job
* by providing a jobName
*
* @author Dave Syer
* @author Jean-Pierre Bergamin
* @author Mahmoud Ben Hassine
* @since 1.0.0
* @deprecated since 2.2.0 in favor of {@link JobLauncherApplicationRunner}
*/
@Deprecated
public class JobLauncherCommandLineRunner extends JobLauncherApplicationRunner {
/**
* Create a new {@link JobLauncherCommandLineRunner}.
* @param jobLauncher to launch jobs
* @param jobExplorer to check the job repository for previous executions
* @param jobRepository to check if a job instance exists with the given parameters
* when running a job
*/
public JobLauncherCommandLineRunner(JobLauncher jobLauncher, JobExplorer jobExplorer, JobRepository jobRepository) {
super(jobLauncher, jobExplorer, jobRepository);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,8 +21,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.orm.jpa.vendor.Database;
@ -129,20 +127,4 @@ public class JpaProperties {
this.openInView = openInView;
}
/**
* Determine the {@link Database} to use based on this configuration and the primary
* {@link DataSource}.
* @param dataSource the auto-configured data source
* @return {@code Database}
* @deprecated since 2.2.0 in favor of letting the JPA container detect the database
* to use.
*/
@Deprecated
public Database determineDatabase(DataSource dataSource) {
if (this.database != null) {
return this.database;
}
return DatabaseLookup.getDatabase(dataSource);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -201,17 +201,6 @@ class RabbitAutoConfigurationTests {
});
}
@Test
@Deprecated
void testConnectionFactoryPublisherConfirmTypeUsingDeprecatedProperty() {
this.contextRunner.withUserConfiguration(TestConfiguration.class)
.withPropertyValues("spring.rabbitmq.publisher-confirms=true").run((context) -> {
CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.class);
assertThat(connectionFactory.isPublisherConfirms()).isTrue();
assertThat(connectionFactory.isSimplePublisherConfirms()).isFalse();
});
}
@Test
void testConnectionFactoryPublisherConfirmTypeCorrelated() {
this.contextRunner.withUserConfiguration(TestConfiguration.class)
@ -459,18 +448,6 @@ class RabbitAutoConfigurationTests {
});
}
@Test
@Deprecated
void testRabbitListenerContainerFactoryWithDeprecatedTransactionSizeStillWorks() {
this.contextRunner
.withUserConfiguration(MessageConvertersConfiguration.class, MessageRecoverersConfiguration.class)
.withPropertyValues("spring.rabbitmq.listener.simple.transactionSize:20").run((context) -> {
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context
.getBean("rabbitListenerContainerFactory", SimpleRabbitListenerContainerFactory.class);
assertThat(rabbitListenerContainerFactory).hasFieldOrPropertyWithValue("batchSize", 20);
});
}
@Test
void testDirectRabbitListenerContainerFactoryWithCustomSettings() {
this.contextRunner

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.config.DirectRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
@ -293,24 +292,4 @@ class RabbitPropertiesTests {
assertThat(container).hasFieldOrPropertyWithValue("missingQueuesFatal", direct.isMissingQueuesFatal());
}
@Test
@Deprecated
void isPublisherConfirmsShouldDefaultToFalse() {
assertThat(this.properties.isPublisherConfirms()).isEqualTo(false);
}
@Test
@Deprecated
void isPublisherConfirmsWhenPublisherConfirmsTypeSimpleShouldBeFalse() {
this.properties.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.SIMPLE);
assertThat(this.properties.isPublisherConfirms()).isEqualTo(false);
}
@Test
@Deprecated
void isPublisherConfirmsWhenPublisherConfirmsTypeCorrelatedShouldBeTrue() {
this.properties.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
assertThat(this.properties.isPublisherConfirms()).isEqualTo(true);
}
}

View File

@ -1,138 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.orm.jpa;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.function.Consumer;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.vendor.Database;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link JpaProperties}.
*
* @author Stephane Nicoll
*/
class JpaPropertiesTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withUserConfiguration(TestConfiguration.class);
@Test
@Deprecated
@SuppressWarnings("deprecation")
void determineDatabaseNoCheckIfDatabaseIsSet() {
this.contextRunner.withPropertyValues("spring.jpa.database=postgresql")
.run(assertJpaProperties((properties) -> {
DataSource dataSource = mockStandaloneDataSource();
Database database = properties.determineDatabase(dataSource);
assertThat(database).isEqualTo(Database.POSTGRESQL);
try {
verify(dataSource, never()).getConnection();
}
catch (SQLException ex) {
throw new IllegalStateException("Should not happen", ex);
}
}));
}
@Test
@Deprecated
@SuppressWarnings("deprecation")
void determineDatabaseWithKnownUrl() {
this.contextRunner.run(assertJpaProperties((properties) -> {
Database database = properties.determineDatabase(mockDataSource("jdbc:h2:mem:testdb"));
assertThat(database).isEqualTo(Database.H2);
}));
}
@Test
@Deprecated
@SuppressWarnings("deprecation")
void determineDatabaseWithKnownUrlAndUserConfig() {
this.contextRunner.withPropertyValues("spring.jpa.database=mysql").run(assertJpaProperties((properties) -> {
Database database = properties.determineDatabase(mockDataSource("jdbc:h2:mem:testdb"));
assertThat(database).isEqualTo(Database.MYSQL);
}));
}
@Test
@Deprecated
@SuppressWarnings("deprecation")
void determineDatabaseWithUnknownUrl() {
this.contextRunner.run(assertJpaProperties((properties) -> {
Database database = properties.determineDatabase(mockDataSource("jdbc:unknown://localhost"));
assertThat(database).isEqualTo(Database.DEFAULT);
}));
}
private DataSource mockStandaloneDataSource() {
try {
DataSource ds = mock(DataSource.class);
given(ds.getConnection()).willThrow(SQLException.class);
return ds;
}
catch (SQLException ex) {
throw new IllegalStateException("Should not happen", ex);
}
}
private DataSource mockDataSource(String jdbcUrl) {
DataSource ds = mock(DataSource.class);
try {
DatabaseMetaData metadata = mock(DatabaseMetaData.class);
given(metadata.getURL()).willReturn(jdbcUrl);
Connection connection = mock(Connection.class);
given(connection.getMetaData()).willReturn(metadata);
given(ds.getConnection()).willReturn(connection);
}
catch (SQLException ex) {
// Do nothing
}
return ds;
}
private ContextConsumer<AssertableApplicationContext> assertJpaProperties(Consumer<JpaProperties> consumer) {
return (context) -> {
assertThat(context).hasSingleBean(JpaProperties.class);
consumer.accept(context.getBean(JpaProperties.class));
};
}
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(JpaProperties.class)
static class TestConfiguration {
}
}

View File

@ -1,37 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.test.autoconfigure.web.reactive;
import org.springframework.test.web.reactive.server.WebTestClient.Builder;
/**
* A customizer for a {@link Builder}. Any {@code WebTestClientBuilderCustomizer} beans
* found in the application context will be {@link #customize called} to customize the
* auto-configured {@link Builder}.
*
* @author Andy Wilkinson
* @since 2.0.0
* @see WebTestClientAutoConfiguration
* @deprecated since 2.2 in favor of
* {@link org.springframework.boot.test.web.reactive.server.WebTestClientBuilderCustomizer}
*/
@FunctionalInterface
@Deprecated
public interface WebTestClientBuilderCustomizer
extends org.springframework.boot.test.web.reactive.server.WebTestClientBuilderCustomizer {
}

View File

@ -1,69 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.test.rule;
import org.hamcrest.Matcher;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.springframework.boot.test.system.OutputCaptureRule;
/**
* JUnit {@code @Rule} to capture output from System.out and System.err.
*
* @author Phillip Webb
* @author Andy Wilkinson
* @since 1.4.0
* @deprecated since 2.2.0 in favor of {@link OutputCaptureRule}
*/
@Deprecated
public class OutputCapture implements TestRule {
private final OutputCaptureRule delegate = new OutputCaptureRule();
@Override
public Statement apply(Statement base, Description description) {
return this.delegate.apply(base, description);
}
/**
* Discard all currently accumulated output.
*/
public void reset() {
this.delegate.reset();
}
public void flush() {
// Flushing is no longer necessary
}
@Override
public String toString() {
return this.delegate.toString();
}
/**
* Verify that the output is matched by the supplied {@code matcher}. Verification is
* performed after the test method has executed.
* @param matcher the matcher
*/
public void expect(Matcher<? super String> matcher) {
this.delegate.expect(matcher);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -81,15 +81,6 @@ public class OutputCaptureRule implements TestRule, CapturedOutput {
};
}
/**
* Resets the current capture session, clearing its captured output.
* @deprecated since 2.2.0 with no replacement
*/
@Deprecated
public void reset() {
OutputCaptureRule.this.delegate.reset();
}
@Override
public String getAll() {
return this.delegate.getAll();

View File

@ -1,49 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.test.rule;
import org.junit.Rule;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link OutputCapture}.
*
* @author Roland Weisleder
*/
@Deprecated
public class OutputCaptureTests {
@Rule
public OutputCapture outputCapture = new OutputCapture();
@Test
public void toStringShouldReturnAllCapturedOutput() {
System.out.println("Hello World");
assertThat(this.outputCapture.toString()).contains("Hello World");
}
@Test
public void reset() {
System.out.println("Hello");
this.outputCapture.reset();
System.out.println("World");
assertThat(this.outputCapture.toString()).doesNotContain("Hello").contains("World");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -94,15 +94,6 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
@Parameter(property = "spring-boot.run.addResources", defaultValue = "false")
private boolean addResources = false;
/**
* Path to agent jar. NOTE: a forked process is required to use this feature.
* @since 1.0.0
* @deprecated since 2.2.0 in favor of {@code agents}
*/
@Deprecated
@Parameter(property = "spring-boot.run.agent")
private File[] agent;
/**
* Path to agent jars. NOTE: a forked process is required to use this feature.
* @since 2.2.0
@ -240,20 +231,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
return this.fork;
}
/**
* Specify if fork should be enabled by default.
* @return {@code true} if fork should be enabled by default
* @see #logDisabledFork()
* @deprecated as of 2.2.0 in favour of enabling forking by default.
*/
@Deprecated
protected boolean enableForkByDefault() {
return hasAgent() || hasJvmArgs() || hasEnvVariables() || hasWorkingDirectorySet();
}
private boolean hasAgent() {
File[] configuredAgents = determineAgents();
return (configuredAgents != null && configuredAgents.length > 0);
return (this.agents != null && this.agents.length > 0);
}
private boolean hasJvmArgs() {
@ -398,12 +377,11 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
private void addAgents(List<String> args) {
File[] configuredAgents = determineAgents();
if (configuredAgents != null) {
if (this.agents != null) {
if (getLog().isInfoEnabled()) {
getLog().info("Attaching agents: " + Arrays.asList(configuredAgents));
getLog().info("Attaching agents: " + Arrays.asList(this.agents));
}
for (File agent : configuredAgents) {
for (File agent : this.agents) {
args.add("-javaagent:" + agent);
}
}
@ -412,10 +390,6 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
}
private File[] determineAgents() {
return (this.agents != null) ? this.agents : this.agent;
}
private void addActiveProfileArgument(RunArguments arguments) {
if (this.profiles.length > 0) {
StringBuilder arg = new StringBuilder("--spring.profiles.active=");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -62,12 +62,6 @@ public class RunMojo extends AbstractRunMojo {
@Parameter(property = "spring-boot.run.optimizedLaunch", defaultValue = "true")
private boolean optimizedLaunch;
@Override
@Deprecated
protected boolean enableForkByDefault() {
return super.enableForkByDefault() || hasDevtools();
}
@Override
protected void logDisabledFork() {
super.logDisabledFork();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -130,17 +130,6 @@ public final class AnsiColors {
return closest;
}
/**
* Get the closest {@link AnsiColor ANSI color} to the given AWT {@link Color}.
* @param color the color to find
* @return the closest color
* @deprecated since 2.2.0 in favor of {@link #findClosest(Color)}
*/
@Deprecated
public static AnsiColor getClosest(Color color) {
return (AnsiColor) new AnsiColors(BitDepth.FOUR).findClosest(color);
}
/**
* Represents a color stored in LAB form.
*/

View File

@ -1,93 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.context.properties;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
/**
* Utility class to memorize {@code @Bean} definition metadata during initialization of
* the bean factory.
*
* @author Dave Syer
* @since 1.1.0
* @deprecated since 2.2.0 in favor of {@link ConfigurationPropertiesBean}
*/
@Deprecated
public class ConfigurationBeanFactoryMetadata implements ApplicationContextAware {
/**
* The bean name that this class is registered with.
*/
public static final String BEAN_NAME = ConfigurationBeanFactoryMetadata.class.getName();
private ConfigurableApplicationContext applicationContext;
public <A extends Annotation> Map<String, Object> getBeansWithFactoryAnnotation(Class<A> type) {
Map<String, Object> result = new HashMap<>();
for (String name : this.applicationContext.getBeanFactory().getBeanDefinitionNames()) {
if (findFactoryAnnotation(name, type) != null) {
result.put(name, this.applicationContext.getBean(name));
}
}
return result;
}
public <A extends Annotation> A findFactoryAnnotation(String beanName, Class<A> type) {
Method method = findFactoryMethod(beanName);
return (method != null) ? AnnotationUtils.findAnnotation(method, type) : null;
}
public Method findFactoryMethod(String beanName) {
ConfigurableListableBeanFactory beanFactory = this.applicationContext.getBeanFactory();
if (beanFactory.containsBeanDefinition(beanName)) {
BeanDefinition beanDefinition = beanFactory.getMergedBeanDefinition(beanName);
if (beanDefinition instanceof RootBeanDefinition) {
return ((RootBeanDefinition) beanDefinition).getResolvedFactoryMethod();
}
}
return null;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = (ConfigurableApplicationContext) applicationContext;
}
static void register(BeanDefinitionRegistry registry) {
if (!registry.containsBeanDefinition(BEAN_NAME)) {
GenericBeanDefinition definition = new GenericBeanDefinition();
definition.setBeanClass(ConfigurationBeanFactoryMetadata.class);
definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
registry.registerBeanDefinition(ConfigurationBeanFactoryMetadata.BEAN_NAME, definition);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -49,30 +49,12 @@ public class ConfigurationPropertiesBindingPostProcessor
*/
public static final String BEAN_NAME = ConfigurationPropertiesBindingPostProcessor.class.getName();
/**
* The bean name of the configuration properties validator.
* @deprecated since 2.2.0 in favor of
* {@link EnableConfigurationProperties#VALIDATOR_BEAN_NAME}
*/
@Deprecated
public static final String VALIDATOR_BEAN_NAME = EnableConfigurationProperties.VALIDATOR_BEAN_NAME;
private ApplicationContext applicationContext;
private BeanDefinitionRegistry registry;
private ConfigurationPropertiesBinder binder;
/**
* Create a new {@link ConfigurationPropertiesBindingPostProcessor} instance.
* @deprecated since 2.2.0 in favor of
* {@link EnableConfigurationProperties @EnableConfigurationProperties} or
* {@link ConfigurationPropertiesBindingPostProcessor#register(BeanDefinitionRegistry)}
*/
@Deprecated
public ConfigurationPropertiesBindingPostProcessor() {
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;

View File

@ -1,46 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.context.properties;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
/**
* {@link ImportBeanDefinitionRegistrar} for binding externalized application properties
* to {@link ConfigurationProperties @ConfigurationProperties} beans.
*
* @author Dave Syer
* @author Phillip Webb
* @since 1.0.0
* @deprecated since 2.2.0 in favor of
* {@link EnableConfigurationProperties @EnableConfigurationProperties}
*/
@Deprecated
public class ConfigurationPropertiesBindingPostProcessorRegistrar implements ImportBeanDefinitionRegistrar {
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
// Spring Cloud Function may call this with a null importingClassMetadata
if (importingClassMetadata == null) {
EnableConfigurationPropertiesRegistrar.registerInfrastructureBeans(registry);
return;
}
new EnableConfigurationPropertiesRegistrar().registerBeanDefinitions(importingClassMetadata, registry);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -51,7 +51,6 @@ class EnableConfigurationPropertiesRegistrar implements ImportBeanDefinitionRegi
ConfigurationPropertiesBindingPostProcessor.register(registry);
BoundConfigurationProperties.register(registry);
ConfigurationPropertiesBeanDefinitionValidator.register(registry);
ConfigurationBeanFactoryMetadata.register(registry);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import org.springframework.beans.BeanUtils;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@ -113,19 +112,6 @@ public final class BindResult<T> {
return (this.value != null) ? this.value : other.get();
}
/**
* Return the object that was bound, or a new instance of the specified class if no
* value has been bound.
* @param type the type to create if no value was bound
* @return the value, if bound, otherwise a new instance of {@code type}
* @deprecated since 2.2.0 in favor of {@link Binder#bindOrCreate}
*/
@Deprecated
public T orElseCreate(Class<? extends T> type) {
Assert.notNull(type, "Type must not be null");
return (this.value != null) ? this.value : BeanUtils.instantiateClass(type);
}
/**
* Return the object that was bound, or throw an exception to be created by the
* provided supplier if no value has been bound.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,17 +16,11 @@
package org.springframework.boot.web.reactive.context;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.ScopeMetadataResolver;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
/**
@ -99,230 +93,4 @@ public class AnnotationConfigReactiveWebApplicationContext extends AnnotationCon
return new FilteredReactiveWebContextResource(path);
}
/**
* Return the custom {@link BeanNameGenerator} for use with
* {@link AnnotatedBeanDefinitionReader} and/or
* {@link ClassPathBeanDefinitionScanner}, if any.
* @return the bean name generator
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}
*/
@Deprecated
protected final BeanNameGenerator getBeanNameGenerator() {
throw new UnsupportedOperationException();
}
/**
* Return the custom {@link ScopeMetadataResolver} for use with
* {@link AnnotatedBeanDefinitionReader} and/or
* {@link ClassPathBeanDefinitionScanner}, if any.
* @return the scope metadata resolver
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}
*/
@Deprecated
protected ScopeMetadataResolver getScopeMetadataResolver() {
throw new UnsupportedOperationException();
}
/**
* Register a {@link org.springframework.beans.factory.config.BeanDefinition} for any
* classes specified by {@link #register(Class...)} and scan any packages specified by
* {@link #scan(String...)}.
* <p>
* For any values specified by {@link #setConfigLocation(String)} or
* {@link #setConfigLocations(String[])}, attempt first to load each location as a
* class, registering a {@code BeanDefinition} if class loading is successful, and if
* class loading fails (i.e. a {@code ClassNotFoundException} is raised), assume the
* value is a package and attempt to scan it for annotated classes.
* <p>
* Enables the default set of annotation configuration post processors, such that
* {@code @Autowired}, {@code @Required}, and associated annotations can be used.
* <p>
* Configuration class bean definitions are registered with generated bean definition
* names unless the {@code value} attribute is provided to the stereotype annotation.
* @param beanFactory the bean factory to load bean definitions into
* @see #register(Class...)
* @see #scan(String...)
* @see #setConfigLocation(String)
* @see #setConfigLocations(String[])
* @see AnnotatedBeanDefinitionReader
* @see ClassPathBeanDefinitionScanner
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}
*/
@Deprecated
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) {
throw new UnsupportedOperationException();
}
/**
* Build an {@link AnnotatedBeanDefinitionReader} for the given bean factory.
* <p>
* This should be pre-configured with the {@code Environment} (if desired) but not
* with a {@code BeanNameGenerator} or {@code ScopeMetadataResolver} yet.
* @param beanFactory the bean factory to load bean definitions into
* @return the annotated bean definition reader
* @see #getEnvironment()
* @see #getBeanNameGenerator()
* @see #getScopeMetadataResolver()
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}
*/
@Deprecated
protected AnnotatedBeanDefinitionReader getAnnotatedBeanDefinitionReader(DefaultListableBeanFactory beanFactory) {
throw new UnsupportedOperationException();
}
/**
* Build a {@link ClassPathBeanDefinitionScanner} for the given bean factory.
* <p>
* This should be pre-configured with the {@code Environment} (if desired) but not
* with a {@code BeanNameGenerator} or {@code ScopeMetadataResolver} yet.
* @param beanFactory the bean factory to load bean definitions into
* @return the class path bean definition scanner
* @see #getEnvironment()
* @see #getBeanNameGenerator()
* @see #getScopeMetadataResolver()
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}
*/
@Deprecated
protected ClassPathBeanDefinitionScanner getClassPathBeanDefinitionScanner(DefaultListableBeanFactory beanFactory) {
throw new UnsupportedOperationException();
}
/**
* Set the config locations for this application context in init-param style, i.e.
* with distinct locations separated by commas, semicolons or whitespace.
* <p>
* If not set, the implementation may use a default as appropriate.
* @param location the config location
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}. Use
* {@link ImportResource @ImportResource} instead.
*/
@Deprecated
public void setConfigLocation(String location) {
throw new UnsupportedOperationException();
}
/**
* Set the config locations for this application context.
* <p>
* If not set, the implementation may use a default as appropriate.
* @param locations the config locations
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}. Use
* {@link ImportResource @ImportResource} instead.
*/
@Deprecated
public void setConfigLocations(@Nullable String... locations) {
throw new UnsupportedOperationException();
}
/**
* Return an array of resource locations, referring to the XML bean definition files
* that this context should be built with. Can also include location patterns, which
* will get resolved via a ResourcePatternResolver.
* <p>
* The default implementation returns {@code null}. Subclasses can override this to
* provide a set of resource locations to load bean definitions from.
* @return an array of resource locations, or {@code null} if none
* @see #getResources
* @see #getResourcePatternResolver
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}.
*/
@Deprecated
protected String[] getConfigLocations() {
throw new UnsupportedOperationException();
}
/**
* Return the default config locations to use, for the case where no explicit config
* locations have been specified.
* <p>
* The default implementation returns {@code null}, requiring explicit config
* locations.
* @return an array of default config locations, if any
* @see #setConfigLocations
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}.
*/
@Deprecated
protected String[] getDefaultConfigLocations() {
throw new UnsupportedOperationException();
}
/**
* Resolve the given path, replacing placeholders with corresponding environment
* property values if necessary. Applied to config locations.
* @param path the original file path
* @return the resolved file path
* @see org.springframework.core.env.Environment#resolveRequiredPlaceholders(String)
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}.
*/
@Deprecated
protected String resolvePath(String path) {
throw new UnsupportedOperationException();
}
/**
* Determine whether this context currently holds a bean factory, i.e. has been
* refreshed at least once and not been closed yet.
* @return {@code true} if the context holds a bean factory
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}.
*/
@Deprecated
protected final boolean hasBeanFactory() {
return true;
}
/**
* Create an internal bean factory for this context. Called for each
* {@link #refresh()} attempt.
* <p>
* The default implementation creates a
* {@link org.springframework.beans.factory.support.DefaultListableBeanFactory} with
* the {@linkplain #getInternalParentBeanFactory() internal bean factory} of this
* context's parent as parent bean factory. Can be overridden in subclasses, for
* example to customize DefaultListableBeanFactory's settings.
* @return the bean factory for this context
* @see org.springframework.beans.factory.support.DefaultListableBeanFactory#setAllowBeanDefinitionOverriding
* @see org.springframework.beans.factory.support.DefaultListableBeanFactory#setAllowEagerClassLoading
* @see org.springframework.beans.factory.support.DefaultListableBeanFactory#setAllowCircularReferences
* @see org.springframework.beans.factory.support.DefaultListableBeanFactory#setAllowRawInjectionDespiteWrapping
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}.
*/
@Deprecated
protected DefaultListableBeanFactory createBeanFactory() {
throw new UnsupportedOperationException();
}
/**
* Customize the internal bean factory used by this context. Called for each
* {@link #refresh()} attempt.
* <p>
* The default implementation applies this context's
* {@linkplain #setAllowBeanDefinitionOverriding "allowBeanDefinitionOverriding"} and
* {@linkplain #setAllowCircularReferences "allowCircularReferences"} settings, if
* specified. Can be overridden in subclasses to customize any of
* {@link DefaultListableBeanFactory}'s settings.
* @param beanFactory the newly created bean factory for this context
* @see DefaultListableBeanFactory#setAllowBeanDefinitionOverriding
* @see DefaultListableBeanFactory#setAllowCircularReferences
* @see DefaultListableBeanFactory#setAllowRawInjectionDespiteWrapping
* @see DefaultListableBeanFactory#setAllowEagerClassLoading
* @deprecated since 2.2.0 since this class no longer extends
* {@code AbstractRefreshableConfigApplicationContext}.
*/
@Deprecated
protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory) {
throw new UnsupportedOperationException();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -111,19 +111,6 @@ public class ReactiveWebServerApplicationContext extends GenericReactiveWebAppli
return getBeanFactory().getBean(factoryBeanName, ReactiveWebServerFactory.class);
}
/**
* Return the {@link ReactiveWebServerFactory} that should be used to create the
* reactive web server. By default this method searches for a suitable bean in the
* context itself.
* @return a {@link ReactiveWebServerFactory} (never {@code null})
* @deprecated since 2.2.0 in favor of {@link #getWebServerFactoryBeanName()} and
* {@link #getWebServerFactory(String)}
*/
@Deprecated
protected ReactiveWebServerFactory getWebServerFactory() {
return getWebServerFactory(getWebServerFactoryBeanName());
}
@Override
protected void finishRefresh() {
super.finishRefresh();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -99,7 +99,6 @@ import static org.mockito.Mockito.verify;
/**
* Tests for {@link ConfigurationProperties @ConfigurationProperties}-annotated beans.
* Covers {@link EnableConfigurationProperties @EnableConfigurationProperties},
* {@link ConfigurationPropertiesBindingPostProcessorRegistrar},
* {@link ConfigurationPropertiesBindingPostProcessor} and
* {@link ConfigurationPropertiesBinder}.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -150,29 +150,6 @@ class BindResultTests {
assertThat(result.orElseGet(this.supplier)).isEqualTo("bar");
}
@Test
@Deprecated
@SuppressWarnings("deprecation")
void orElseCreateWhenTypeIsNullShouldThrowException() {
BindResult<String> result = BindResult.of("foo");
assertThatIllegalArgumentException().isThrownBy(() -> result.orElseCreate(null))
.withMessageContaining("Type must not be null");
}
@Test
@Deprecated
void orElseCreateWhenHasValueShouldReturnValue() {
BindResult<ExampleBean> result = BindResult.of(new ExampleBean("foo"));
assertThat(result.orElseCreate(ExampleBean.class).getValue()).isEqualTo("foo");
}
@Test
@Deprecated
void orElseCreateWhenHasValueNoShouldReturnCreatedValue() {
BindResult<ExampleBean> result = BindResult.of(null);
assertThat(result.orElseCreate(ExampleBean.class).getValue()).isEqualTo("new");
}
@Test
void orElseThrowWhenHasValueShouldReturnValue() throws Exception {
BindResult<String> result = BindResult.of("foo");