Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
4464a5f5
Commit
4464a5f5
authored
May 22, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove code deprecated in 2.0
Closes gh-12962
parent
1ea3e95f
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
6 additions
and
510 deletions
+6
-510
StatsdProperties.java
...autoconfigure/metrics/export/statsd/StatsdProperties.java
+0
-17
StatsdPropertiesConfigAdapter.java
.../metrics/export/statsd/StatsdPropertiesConfigAdapter.java
+0
-6
RouterFunctionMetrics.java
...te/metrics/web/reactive/server/RouterFunctionMetrics.java
+0
-150
CouchbaseConfiguration.java
.../boot/autoconfigure/couchbase/CouchbaseConfiguration.java
+4
-17
CouchbaseProperties.java
...ork/boot/autoconfigure/couchbase/CouchbaseProperties.java
+0
-33
HibernateSettings.java
...amework/boot/autoconfigure/orm/jpa/HibernateSettings.java
+0
-12
CouchbaseAutoConfigurationTests.java
...oconfigure/couchbase/CouchbaseAutoConfigurationTests.java
+2
-18
EnvironmentTestUtils.java
.../springframework/boot/test/util/EnvironmentTestUtils.java
+0
-105
EnvironmentTestUtilsTests.java
...ngframework/boot/test/util/EnvironmentTestUtilsTests.java
+0
-96
SpringApplication.java
...main/java/org/springframework/boot/SpringApplication.java
+0
-24
SpringApplicationBuilder.java
...pringframework/boot/builder/SpringApplicationBuilder.java
+0
-13
AbstractServletWebServerFactory.java
...t/web/servlet/server/AbstractServletWebServerFactory.java
+0
-19
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java
View file @
4464a5f5
...
@@ -21,7 +21,6 @@ import java.time.Duration;
...
@@ -21,7 +21,6 @@ import java.time.Duration;
import
io.micrometer.statsd.StatsdFlavor
;
import
io.micrometer.statsd.StatsdFlavor
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.DeprecatedConfigurationProperty
;
/**
/**
* {@link ConfigurationProperties} for configuring StatsD metrics export.
* {@link ConfigurationProperties} for configuring StatsD metrics export.
...
@@ -65,11 +64,6 @@ public class StatsdProperties {
...
@@ -65,11 +64,6 @@ public class StatsdProperties {
*/
*/
private
Duration
pollingFrequency
=
Duration
.
ofSeconds
(
10
);
private
Duration
pollingFrequency
=
Duration
.
ofSeconds
(
10
);
/**
* Maximum size of the queue of items waiting to be sent to the StatsD server.
*/
private
Integer
queueSize
=
Integer
.
MAX_VALUE
;
/**
/**
* Whether to send unchanged meters to the StatsD server.
* Whether to send unchanged meters to the StatsD server.
*/
*/
...
@@ -123,17 +117,6 @@ public class StatsdProperties {
...
@@ -123,17 +117,6 @@ public class StatsdProperties {
this
.
pollingFrequency
=
pollingFrequency
;
this
.
pollingFrequency
=
pollingFrequency
;
}
}
@Deprecated
@DeprecatedConfigurationProperty
(
reason
=
"No longer configurable and an unbounded queue will always be used"
)
public
Integer
getQueueSize
()
{
return
this
.
queueSize
;
}
@Deprecated
public
void
setQueueSize
(
Integer
queueSize
)
{
this
.
queueSize
=
queueSize
;
}
public
boolean
isPublishUnchangedMeters
()
{
public
boolean
isPublishUnchangedMeters
()
{
return
this
.
publishUnchangedMeters
;
return
this
.
publishUnchangedMeters
;
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java
View file @
4464a5f5
...
@@ -73,12 +73,6 @@ public class StatsdPropertiesConfigAdapter
...
@@ -73,12 +73,6 @@ public class StatsdPropertiesConfigAdapter
StatsdConfig
.
super
::
pollingFrequency
);
StatsdConfig
.
super
::
pollingFrequency
);
}
}
@Override
@Deprecated
public
int
queueSize
()
{
return
get
(
StatsdProperties:
:
getQueueSize
,
StatsdConfig
.
super
::
queueSize
);
}
@Override
@Override
public
boolean
publishUnchangedMeters
()
{
public
boolean
publishUnchangedMeters
()
{
return
get
(
StatsdProperties:
:
isPublishUnchangedMeters
,
return
get
(
StatsdProperties:
:
isPublishUnchangedMeters
,
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/RouterFunctionMetrics.java
deleted
100644 → 0
View file @
1ea3e95f
/*
* Copyright 2012-2018 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
*
* http://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
.
metrics
.
web
.
reactive
.
server
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.BiFunction
;
import
io.micrometer.core.instrument.MeterRegistry
;
import
io.micrometer.core.instrument.Tag
;
import
io.micrometer.core.instrument.Tags
;
import
reactor.core.publisher.Mono
;
import
org.springframework.util.Assert
;
import
org.springframework.web.reactive.function.server.HandlerFilterFunction
;
import
org.springframework.web.reactive.function.server.HandlerFunction
;
import
org.springframework.web.reactive.function.server.RouterFunction
;
import
org.springframework.web.reactive.function.server.ServerRequest
;
import
org.springframework.web.reactive.function.server.ServerResponse
;
/**
* Support class for WebFlux {@link RouterFunction}-related metrics.
*
* @author Jon Schneider
* @since 2.0.0
* @deprecated in favor of the auto-configured {@link MetricsWebFilter}
*/
@Deprecated
public
class
RouterFunctionMetrics
{
private
final
MeterRegistry
registry
;
private
final
BiFunction
<
ServerRequest
,
ServerResponse
,
Iterable
<
Tag
>>
defaultTags
;
public
RouterFunctionMetrics
(
MeterRegistry
registry
)
{
Assert
.
notNull
(
registry
,
"Registry must not be null"
);
this
.
registry
=
registry
;
this
.
defaultTags
=
this
::
defaultTags
;
}
private
RouterFunctionMetrics
(
MeterRegistry
registry
,
BiFunction
<
ServerRequest
,
ServerResponse
,
Iterable
<
Tag
>>
defaultTags
)
{
Assert
.
notNull
(
registry
,
"Registry must not be null"
);
Assert
.
notNull
(
defaultTags
,
"DefaultTags must not be null"
);
this
.
registry
=
registry
;
this
.
defaultTags
=
defaultTags
;
}
private
Iterable
<
Tag
>
defaultTags
(
ServerRequest
request
,
ServerResponse
response
)
{
if
(
response
==
null
)
{
return
Tags
.
of
(
getMethodTag
(
request
));
}
return
Tags
.
of
(
getMethodTag
(
request
),
getStatusTag
(
response
));
}
/**
* Returns a new {@link RouterFunctionMetrics} instance with the specified default
* tags.
* @param defaultTags Generate a list of tags to apply to the timer.
* {@code ServerResponse} may be null.
* @return {@code this} for further configuration
*/
public
RouterFunctionMetrics
defaultTags
(
BiFunction
<
ServerRequest
,
ServerResponse
,
Iterable
<
Tag
>>
defaultTags
)
{
return
new
RouterFunctionMetrics
(
this
.
registry
,
defaultTags
);
}
public
HandlerFilterFunction
<
ServerResponse
,
ServerResponse
>
timer
(
String
name
)
{
return
timer
(
name
,
Tags
.
empty
());
}
public
HandlerFilterFunction
<
ServerResponse
,
ServerResponse
>
timer
(
String
name
,
String
...
tags
)
{
return
timer
(
name
,
Tags
.
of
(
tags
));
}
public
HandlerFilterFunction
<
ServerResponse
,
ServerResponse
>
timer
(
String
name
,
Iterable
<
Tag
>
tags
)
{
return
new
MetricsFilter
(
name
,
Tags
.
of
(
tags
));
}
/**
* Creates a {@code method} tag from the method of the given {@code request}.
* @param request The HTTP request.
* @return A "method" tag whose value is a capitalized method (e.g. GET).
*/
public
static
Tag
getMethodTag
(
ServerRequest
request
)
{
return
Tag
.
of
(
"method"
,
request
.
method
().
toString
());
}
/**
* Creates a {@code status} tag from the status of the given {@code response}.
* @param response The HTTP response.
* @return A "status" tag whose value is the numeric status code.
*/
public
static
Tag
getStatusTag
(
ServerResponse
response
)
{
return
Tag
.
of
(
"status"
,
response
.
statusCode
().
toString
());
}
/**
* {@link HandlerFilterFunction} to handle calling micrometer.
*/
private
class
MetricsFilter
implements
HandlerFilterFunction
<
ServerResponse
,
ServerResponse
>
{
private
final
String
name
;
private
final
Tags
tags
;
MetricsFilter
(
String
name
,
Tags
tags
)
{
this
.
name
=
name
;
this
.
tags
=
tags
;
}
@Override
public
Mono
<
ServerResponse
>
filter
(
ServerRequest
request
,
HandlerFunction
<
ServerResponse
>
next
)
{
long
start
=
System
.
nanoTime
();
return
next
.
handle
(
request
)
.
doOnSuccess
((
response
)
->
timer
(
start
,
request
,
response
))
.
doOnError
((
error
)
->
timer
(
start
,
request
,
null
));
}
private
Iterable
<
Tag
>
getDefaultTags
(
ServerRequest
request
,
ServerResponse
response
)
{
return
RouterFunctionMetrics
.
this
.
defaultTags
.
apply
(
request
,
response
);
}
private
void
timer
(
long
start
,
ServerRequest
request
,
ServerResponse
response
)
{
Tags
allTags
=
this
.
tags
.
and
(
getDefaultTags
(
request
,
response
));
RouterFunctionMetrics
.
this
.
registry
.
timer
(
this
.
name
,
allTags
)
.
record
(
System
.
nanoTime
()
-
start
,
TimeUnit
.
NANOSECONDS
);
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseConfiguration.java
View file @
4464a5f5
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
couchbase
;
package
org
.
springframework
.
boot
.
autoconfigure
.
couchbase
;
import
java.util.List
;
import
java.util.List
;
import
java.util.function.BiFunction
;
import
com.couchbase.client.core.env.KeyValueServiceConfig
;
import
com.couchbase.client.core.env.KeyValueServiceConfig
;
import
com.couchbase.client.core.env.QueryServiceConfig
;
import
com.couchbase.client.core.env.QueryServiceConfig
;
...
@@ -29,7 +28,6 @@ import com.couchbase.client.java.cluster.ClusterInfo;
...
@@ -29,7 +28,6 @@ import com.couchbase.client.java.cluster.ClusterInfo;
import
com.couchbase.client.java.env.DefaultCouchbaseEnvironment
;
import
com.couchbase.client.java.env.DefaultCouchbaseEnvironment
;
import
org.springframework.boot.autoconfigure.couchbase.CouchbaseProperties.Endpoints
;
import
org.springframework.boot.autoconfigure.couchbase.CouchbaseProperties.Endpoints
;
import
org.springframework.boot.autoconfigure.couchbase.CouchbaseProperties.Endpoints.CouchbaseService
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.DependsOn
;
import
org.springframework.context.annotation.DependsOn
;
...
@@ -129,25 +127,14 @@ public class CouchbaseConfiguration {
...
@@ -129,25 +127,14 @@ public class CouchbaseConfiguration {
return
builder
;
return
builder
;
}
}
@SuppressWarnings
(
"deprecation"
)
private
QueryServiceConfig
getQueryServiceConfig
(
Endpoints
endpoints
)
{
private
QueryServiceConfig
getQueryServiceConfig
(
Endpoints
endpoints
)
{
return
getServiceConfig
(
endpoints
.
getQueryservice
(),
endpoints
.
getQuery
(),
return
QueryServiceConfig
.
create
(
endpoints
.
getQueryservice
().
getMinEndpoints
(),
QueryServiceConfig:
:
create
);
endpoints
.
getQueryservice
().
getMaxEndpoints
()
);
}
}
@SuppressWarnings
(
"deprecation"
)
private
ViewServiceConfig
getViewServiceConfig
(
Endpoints
endpoints
)
{
private
ViewServiceConfig
getViewServiceConfig
(
Endpoints
endpoints
)
{
return
getServiceConfig
(
endpoints
.
getViewservice
(),
endpoints
.
getView
(),
return
ViewServiceConfig
.
create
(
endpoints
.
getViewservice
().
getMinEndpoints
(),
ViewServiceConfig:
:
create
);
endpoints
.
getViewservice
().
getMaxEndpoints
());
}
private
<
T
>
T
getServiceConfig
(
CouchbaseService
service
,
Integer
fallback
,
BiFunction
<
Integer
,
Integer
,
T
>
factory
)
{
if
(
service
.
getMinEndpoints
()
!=
1
||
service
.
getMaxEndpoints
()
!=
1
)
{
return
factory
.
apply
(
service
.
getMinEndpoints
(),
service
.
getMaxEndpoints
());
}
int
endpoints
=
(
fallback
!=
null
?
fallback
:
1
);
return
factory
.
apply
(
endpoints
,
endpoints
);
}
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java
View file @
4464a5f5
...
@@ -20,7 +20,6 @@ import java.time.Duration;
...
@@ -20,7 +20,6 @@ import java.time.Duration;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.DeprecatedConfigurationProperty
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
/**
/**
...
@@ -128,16 +127,6 @@ public class CouchbaseProperties {
...
@@ -128,16 +127,6 @@ public class CouchbaseProperties {
*/
*/
private
final
CouchbaseService
viewservice
=
new
CouchbaseService
();
private
final
CouchbaseService
viewservice
=
new
CouchbaseService
();
/**
* Number of sockets per node against the query (N1QL) service.
*/
private
Integer
query
;
/**
* Number of sockets per node against the view service.
*/
private
Integer
view
;
public
int
getKeyValue
()
{
public
int
getKeyValue
()
{
return
this
.
keyValue
;
return
this
.
keyValue
;
}
}
...
@@ -146,32 +135,10 @@ public class CouchbaseProperties {
...
@@ -146,32 +135,10 @@ public class CouchbaseProperties {
this
.
keyValue
=
keyValue
;
this
.
keyValue
=
keyValue
;
}
}
@Deprecated
@DeprecatedConfigurationProperty
(
replacement
=
"spring.couchbase.env.endpoints.queryservice.max-endpoints"
)
public
Integer
getQuery
()
{
return
this
.
query
;
}
@Deprecated
public
void
setQuery
(
Integer
query
)
{
this
.
query
=
query
;
}
public
CouchbaseService
getQueryservice
()
{
public
CouchbaseService
getQueryservice
()
{
return
this
.
queryservice
;
return
this
.
queryservice
;
}
}
@Deprecated
@DeprecatedConfigurationProperty
(
replacement
=
"spring.couchbase.env.endpoints.viewservice.max-endpoints"
)
public
Integer
getView
()
{
return
this
.
view
;
}
@Deprecated
public
void
setView
(
Integer
view
)
{
this
.
view
=
view
;
}
public
CouchbaseService
getViewservice
()
{
public
CouchbaseService
getViewservice
()
{
return
this
.
viewservice
;
return
this
.
viewservice
;
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java
View file @
4464a5f5
...
@@ -37,18 +37,6 @@ public class HibernateSettings {
...
@@ -37,18 +37,6 @@ public class HibernateSettings {
return
this
;
return
this
;
}
}
/**
* Specify the default ddl auto value to use.
* @param ddlAuto the default ddl auto if none is provided
* @return this instance
* @see #ddlAuto(Supplier)
* @deprecated as of 2.0.1 in favour of {@link #ddlAuto(Supplier)}
*/
@Deprecated
public
HibernateSettings
ddlAuto
(
String
ddlAuto
)
{
return
ddlAuto
(()
->
ddlAuto
);
}
public
String
getDdlAuto
()
{
public
String
getDdlAuto
()
{
return
(
this
.
ddlAuto
!=
null
?
this
.
ddlAuto
.
get
()
:
null
);
return
(
this
.
ddlAuto
!=
null
?
this
.
ddlAuto
.
get
()
:
null
);
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java
View file @
4464a5f5
...
@@ -96,18 +96,6 @@ public class CouchbaseAutoConfigurationTests {
...
@@ -96,18 +96,6 @@ public class CouchbaseAutoConfigurationTests {
"spring.couchbase.env.endpoints.viewservice.max-endpoints=6"
);
"spring.couchbase.env.endpoints.viewservice.max-endpoints=6"
);
}
}
@Test
@Deprecated
public
void
customizeEnvEndpointsWithDeprecatedProperties
()
{
testCouchbaseEnv
((
env
)
->
{
assertThat
(
env
.
queryServiceConfig
().
minEndpoints
()).
isEqualTo
(
3
);
assertThat
(
env
.
queryServiceConfig
().
maxEndpoints
()).
isEqualTo
(
3
);
assertThat
(
env
.
viewServiceConfig
().
minEndpoints
()).
isEqualTo
(
4
);
assertThat
(
env
.
viewServiceConfig
().
maxEndpoints
()).
isEqualTo
(
4
);
},
"spring.couchbase.env.endpoints.query=3"
,
"spring.couchbase.env.endpoints.view=4"
);
}
@Test
@Test
public
void
customizeEnvEndpointsUsesNewInfrastructure
()
{
public
void
customizeEnvEndpointsUsesNewInfrastructure
()
{
testCouchbaseEnv
((
env
)
->
{
testCouchbaseEnv
((
env
)
->
{
...
@@ -115,10 +103,8 @@ public class CouchbaseAutoConfigurationTests {
...
@@ -115,10 +103,8 @@ public class CouchbaseAutoConfigurationTests {
assertThat
(
env
.
queryServiceConfig
().
maxEndpoints
()).
isEqualTo
(
5
);
assertThat
(
env
.
queryServiceConfig
().
maxEndpoints
()).
isEqualTo
(
5
);
assertThat
(
env
.
viewServiceConfig
().
minEndpoints
()).
isEqualTo
(
4
);
assertThat
(
env
.
viewServiceConfig
().
minEndpoints
()).
isEqualTo
(
4
);
assertThat
(
env
.
viewServiceConfig
().
maxEndpoints
()).
isEqualTo
(
6
);
assertThat
(
env
.
viewServiceConfig
().
maxEndpoints
()).
isEqualTo
(
6
);
},
"spring.couchbase.env.endpoints.query=33"
,
},
"spring.couchbase.env.endpoints.queryservice.min-endpoints=3"
,
"spring.couchbase.env.endpoints.queryservice.min-endpoints=3"
,
"spring.couchbase.env.endpoints.queryservice.max-endpoints=5"
,
"spring.couchbase.env.endpoints.queryservice.max-endpoints=5"
,
"spring.couchbase.env.endpoints.view=44"
,
"spring.couchbase.env.endpoints.viewservice.min-endpoints=4"
,
"spring.couchbase.env.endpoints.viewservice.min-endpoints=4"
,
"spring.couchbase.env.endpoints.viewservice.max-endpoints=6"
);
"spring.couchbase.env.endpoints.viewservice.max-endpoints=6"
);
}
}
...
@@ -130,9 +116,7 @@ public class CouchbaseAutoConfigurationTests {
...
@@ -130,9 +116,7 @@ public class CouchbaseAutoConfigurationTests {
assertThat
(
env
.
queryServiceConfig
().
maxEndpoints
()).
isEqualTo
(
5
);
assertThat
(
env
.
queryServiceConfig
().
maxEndpoints
()).
isEqualTo
(
5
);
assertThat
(
env
.
viewServiceConfig
().
minEndpoints
()).
isEqualTo
(
1
);
assertThat
(
env
.
viewServiceConfig
().
minEndpoints
()).
isEqualTo
(
1
);
assertThat
(
env
.
viewServiceConfig
().
maxEndpoints
()).
isEqualTo
(
6
);
assertThat
(
env
.
viewServiceConfig
().
maxEndpoints
()).
isEqualTo
(
6
);
},
"spring.couchbase.env.endpoints.query=33"
,
},
"spring.couchbase.env.endpoints.queryservice.max-endpoints=5"
,
"spring.couchbase.env.endpoints.queryservice.max-endpoints=5"
,
"spring.couchbase.env.endpoints.view=44"
,
"spring.couchbase.env.endpoints.viewservice.max-endpoints=6"
);
"spring.couchbase.env.endpoints.viewservice.max-endpoints=6"
);
}
}
...
...
spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/EnvironmentTestUtils.java
deleted
100644 → 0
View file @
1ea3e95f
/*
* Copyright 2012-2018 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
*
* http://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
.
util
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.MutablePropertySources
;
/**
* Test utilities for setting environment values.
*
* @author Dave Syer
* @author Stephane Nicoll
* @since 1.4.0
* @deprecated since 2.0.0 in favor of {@link TestPropertyValues}
*/
@Deprecated
public
abstract
class
EnvironmentTestUtils
{
/**
* Add additional (high priority) values to an {@link Environment} owned by an
* {@link ApplicationContext}. Name-value pairs can be specified with colon (":") or
* equals ("=") separators.
* @param context the context with an environment to modify
* @param pairs the name:value pairs
*/
public
static
void
addEnvironment
(
ConfigurableApplicationContext
context
,
String
...
pairs
)
{
addEnvironment
(
context
.
getEnvironment
(),
pairs
);
}
/**
* Add additional (high priority) values to an {@link Environment}. Name-value pairs
* can be specified with colon (":") or equals ("=") separators.
* @param environment the environment to modify
* @param pairs the name:value pairs
*/
public
static
void
addEnvironment
(
ConfigurableEnvironment
environment
,
String
...
pairs
)
{
addEnvironment
(
"test"
,
environment
,
pairs
);
}
/**
* Add additional (high priority) values to an {@link Environment}. Name-value pairs
* can be specified with colon (":") or equals ("=") separators.
* @param environment the environment to modify
* @param name the property source name
* @param pairs the name:value pairs
*/
public
static
void
addEnvironment
(
String
name
,
ConfigurableEnvironment
environment
,
String
...
pairs
)
{
MutablePropertySources
sources
=
environment
.
getPropertySources
();
Map
<
String
,
Object
>
map
=
getOrAdd
(
sources
,
name
);
for
(
String
pair
:
pairs
)
{
int
index
=
getSeparatorIndex
(
pair
);
String
key
=
(
index
>
0
?
pair
.
substring
(
0
,
index
)
:
pair
);
String
value
=
(
index
>
0
?
pair
.
substring
(
index
+
1
)
:
""
);
map
.
put
(
key
.
trim
(),
value
.
trim
());
}
}
@SuppressWarnings
(
"unchecked"
)
private
static
Map
<
String
,
Object
>
getOrAdd
(
MutablePropertySources
sources
,
String
name
)
{
if
(
sources
.
contains
(
name
))
{
return
(
Map
<
String
,
Object
>)
sources
.
get
(
name
).
getSource
();
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
sources
.
addFirst
(
new
MapPropertySource
(
name
,
map
));
return
map
;
}
private
static
int
getSeparatorIndex
(
String
pair
)
{
int
colonIndex
=
pair
.
indexOf
(
':'
);
int
equalIndex
=
pair
.
indexOf
(
'='
);
if
(
colonIndex
==
-
1
)
{
return
equalIndex
;
}
if
(
equalIndex
==
-
1
)
{
return
colonIndex
;
}
return
Math
.
min
(
colonIndex
,
equalIndex
);
}
}
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/util/EnvironmentTestUtilsTests.java
deleted
100644 → 0
View file @
1ea3e95f
/*
* Copyright 2012-2017 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
*
* http://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
.
util
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.StandardEnvironment
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Tests for {@link EnvironmentTestUtils}.
*
* @author Stephane Nicoll
*/
@Deprecated
public
class
EnvironmentTestUtilsTests
{
private
final
ConfigurableEnvironment
environment
=
new
StandardEnvironment
();
@Test
public
void
addSimplePairEqual
()
{
testAddSimplePair
(
"my.foo"
,
"bar"
,
"="
);
}
@Test
public
void
addSimplePairColon
()
{
testAddSimplePair
(
"my.foo"
,
"bar"
,
":"
);
}
@Test
public
void
addSimplePairEqualWithEqualInValue
()
{
testAddSimplePair
(
"my.foo"
,
"b=ar"
,
"="
);
}
@Test
public
void
addSimplePairEqualWithColonInValue
()
{
testAddSimplePair
(
"my.foo"
,
"b:ar"
,
"="
);
}
@Test
public
void
addSimplePairColonWithColonInValue
()
{
testAddSimplePair
(
"my.foo"
,
"b:ar"
,
":"
);
}
@Test
public
void
addSimplePairColonWithEqualInValue
()
{
testAddSimplePair
(
"my.foo"
,
"b=ar"
,
":"
);
}
@Test
public
void
addPairNoValue
()
{
String
propertyName
=
"my.foo+bar"
;
assertThat
(
this
.
environment
.
containsProperty
(
propertyName
)).
isFalse
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
environment
,
propertyName
);
assertThat
(
this
.
environment
.
containsProperty
(
propertyName
)).
isTrue
();
assertThat
(
this
.
environment
.
getProperty
(
propertyName
)).
isEqualTo
(
""
);
}
private
void
testAddSimplePair
(
String
key
,
String
value
,
String
delimiter
)
{
assertThat
(
this
.
environment
.
containsProperty
(
key
)).
isFalse
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
environment
,
key
+
delimiter
+
value
);
assertThat
(
this
.
environment
.
getProperty
(
key
)).
isEqualTo
(
value
);
}
@Test
public
void
testConfigHasHigherPrecedence
()
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"my.foo"
,
"bar"
);
MapPropertySource
source
=
new
MapPropertySource
(
"sample"
,
map
);
this
.
environment
.
getPropertySources
().
addFirst
(
source
);
assertThat
(
this
.
environment
.
getProperty
(
"my.foo"
)).
isEqualTo
(
"bar"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
environment
,
"my.foo=bar2"
);
assertThat
(
this
.
environment
.
getProperty
(
"my.foo"
)).
isEqualTo
(
"bar2"
);
}
}
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
View file @
4464a5f5
...
@@ -932,17 +932,6 @@ public class SpringApplication {
...
@@ -932,17 +932,6 @@ public class SpringApplication {
this
.
mainApplicationClass
=
mainApplicationClass
;
this
.
mainApplicationClass
=
mainApplicationClass
;
}
}
/**
* Returns whether this {@link SpringApplication} is running within a web environment.
* @return {@code true} if running within a web environment, otherwise {@code false}.
* @see #setWebEnvironment(boolean)
* @deprecated since 2.0.0 in favor of {@link #getWebApplicationType()}
*/
@Deprecated
public
boolean
isWebEnvironment
()
{
return
this
.
webApplicationType
==
WebApplicationType
.
SERVLET
;
}
/**
/**
* Returns the type of web application that is being run.
* Returns the type of web application that is being run.
* @return the type of web application
* @return the type of web application
...
@@ -952,19 +941,6 @@ public class SpringApplication {
...
@@ -952,19 +941,6 @@ public class SpringApplication {
return
this
.
webApplicationType
;
return
this
.
webApplicationType
;
}
}
/**
* Sets if this application is running within a web environment. If not specified will
* attempt to deduce the environment based on the classpath.
* @param webEnvironment if the application is running in a web environment
* @deprecated since 2.0.0 in favor of
* {@link #setWebApplicationType(WebApplicationType)}
*/
@Deprecated
public
void
setWebEnvironment
(
boolean
webEnvironment
)
{
this
.
webApplicationType
=
(
webEnvironment
?
WebApplicationType
.
SERVLET
:
WebApplicationType
.
NONE
);
}
/**
/**
* Sets the type of web application to be run. If not explicitly set the type of web
* Sets the type of web application to be run. If not explicitly set the type of web
* application will be deduced based on the classpath.
* application will be deduced based on the classpath.
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java
View file @
4464a5f5
...
@@ -288,19 +288,6 @@ public class SpringApplicationBuilder {
...
@@ -288,19 +288,6 @@ public class SpringApplicationBuilder {
return
this
;
return
this
;
}
}
/**
* Flag to explicitly request a web or non-web environment (auto detected based on
* classpath if not set).
* @param webEnvironment the flag to set
* @return the current builder
* @deprecated since 2.0.0 in favour of {@link #web(WebApplicationType)}
*/
@Deprecated
public
SpringApplicationBuilder
web
(
boolean
webEnvironment
)
{
this
.
application
.
setWebEnvironment
(
webEnvironment
);
return
this
;
}
/**
/**
* Flag to explicitly request a specific type of web application. Auto-detected based
* Flag to explicitly request a specific type of web application. Auto-detected based
* on the classpath if not set.
* on the classpath if not set.
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactory.java
View file @
4464a5f5
...
@@ -17,9 +17,7 @@
...
@@ -17,9 +17,7 @@
package
org
.
springframework
.
boot
.
web
.
servlet
.
server
;
package
org
.
springframework
.
boot
.
web
.
servlet
.
server
;
import
java.io.File
;
import
java.io.File
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLDecoder
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -282,23 +280,6 @@ public abstract class AbstractServletWebServerFactory
...
@@ -282,23 +280,6 @@ public abstract class AbstractServletWebServerFactory
return
this
.
staticResourceJars
.
getUrls
();
return
this
.
staticResourceJars
.
getUrls
();
}
}
/**
* Converts the given {@code url} into a decoded file path.
* @param url the url to convert
* @return the file path
* @deprecated Since 2.0.2 in favor of {@link File#File(java.net.URI)}
*/
@Deprecated
protected
final
String
getDecodedFile
(
URL
url
)
{
try
{
return
URLDecoder
.
decode
(
url
.
getFile
(),
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
ex
)
{
throw
new
IllegalStateException
(
"Failed to decode '"
+
url
.
getFile
()
+
"' using UTF-8"
);
}
}
protected
final
File
getValidSessionStoreDir
()
{
protected
final
File
getValidSessionStoreDir
()
{
return
getValidSessionStoreDir
(
true
);
return
getValidSessionStoreDir
(
true
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment