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
7b120c1c
Commit
7b120c1c
authored
May 04, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting
parent
42c053cf
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
212 additions
and
206 deletions
+212
-206
OnEnabledEndpointCondition.java
...figure/endpoint/condition/OnEnabledEndpointCondition.java
+3
-4
IntegrationGraphEndpointAutoConfiguration.java
...ntegration/IntegrationGraphEndpointAutoConfiguration.java
+2
-2
WebClientMetricsAutoConfiguration.java
...trics/web/reactive/WebClientMetricsAutoConfiguration.java
+10
-9
WebFluxMetricsAutoConfiguration.java
...metrics/web/reactive/WebFluxMetricsAutoConfiguration.java
+2
-2
CachesEndpointAutoConfigurationTests.java
...configure/cache/CachesEndpointAutoConfigurationTests.java
+4
-5
ConditionalOnEnabledEndpointTests.java
...endpoint/condition/ConditionalOnEnabledEndpointTests.java
+16
-15
CachesEndpointDocumentationTests.java
...t/web/documentation/CachesEndpointDocumentationTests.java
+19
-19
IntegrationGraphEndpointDocumentationTests.java
...mentation/IntegrationGraphEndpointDocumentationTests.java
+4
-3
IntegrationGraphEndpointAutoConfigurationTests.java
...ation/IntegrationGraphEndpointAutoConfigurationTests.java
+2
-2
HibernateMetricsAutoConfigurationTests.java
...trics/orm/jpa/HibernateMetricsAutoConfigurationTests.java
+4
-3
RestTemplateMetricsAutoConfigurationTests.java
...web/client/RestTemplateMetricsAutoConfigurationTests.java
+21
-19
WebClientMetricsAutoConfigurationTests.java
.../web/reactive/WebClientMetricsAutoConfigurationTests.java
+1
-0
WebFluxMetricsAutoConfigurationTests.java
...cs/web/reactive/WebFluxMetricsAutoConfigurationTests.java
+2
-0
CachesEndpoint.java
...rg/springframework/boot/actuate/cache/CachesEndpoint.java
+16
-18
DefaultWebClientExchangeTagsProvider.java
...reactive/client/DefaultWebClientExchangeTagsProvider.java
+1
-0
MetricsWebClientFilterFunction.java
...s/web/reactive/client/MetricsWebClientFilterFunction.java
+3
-4
WebClientExchangeTags.java
...te/metrics/web/reactive/client/WebClientExchangeTags.java
+9
-8
WebClientExchangeTagsProvider.java
...cs/web/reactive/client/WebClientExchangeTagsProvider.java
+3
-1
package-info.java
...oot/actuate/metrics/web/reactive/client/package-info.java
+2
-2
CachesEndpointTests.java
...ringframework/boot/actuate/cache/CachesEndpointTests.java
+18
-18
CachesEndpointWebIntegrationTests.java
...boot/actuate/cache/CachesEndpointWebIntegrationTests.java
+15
-18
IntegrationGraphEndpointWebIntegrationTests.java
...egration/IntegrationGraphEndpointWebIntegrationTests.java
+8
-6
DefaultWebClientExchangeTagsProviderTests.java
...ive/client/DefaultWebClientExchangeTagsProviderTests.java
+23
-22
MetricsWebClientCustomizerTests.java
.../web/reactive/client/MetricsWebClientCustomizerTests.java
+1
-0
WebClientExchangeTagsTests.java
...trics/web/reactive/client/WebClientExchangeTagsTests.java
+11
-9
CouchbaseConfiguration.java
.../boot/autoconfigure/couchbase/CouchbaseConfiguration.java
+6
-10
DispatcherServletAutoConfiguration.java
...igure/web/servlet/DispatcherServletAutoConfiguration.java
+1
-1
AbstractRunMojo.java
.../java/org/springframework/boot/maven/AbstractRunMojo.java
+1
-0
RunMojo.java
...src/main/java/org/springframework/boot/maven/RunMojo.java
+1
-2
StartMojo.java
...c/main/java/org/springframework/boot/maven/StartMojo.java
+1
-2
EnvVariablesTests.java
...ava/org/springframework/boot/maven/EnvVariablesTests.java
+2
-2
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnEnabledEndpointCondition.java
View file @
7b120c1c
...
@@ -97,10 +97,9 @@ class OnEnabledEndpointCondition extends SpringBootCondition {
...
@@ -97,10 +97,9 @@ class OnEnabledEndpointCondition extends SpringBootCondition {
return
getEndpointAttributes
(
endpointType
);
return
getEndpointAttributes
(
endpointType
);
}
}
private
Class
<?>
getEndpointType
(
ConditionContext
context
,
private
Class
<?>
getEndpointType
(
ConditionContext
context
,
MethodMetadata
metadata
)
{
MethodMetadata
metadata
)
{
Map
<
String
,
Object
>
attributes
=
metadata
Map
<
String
,
Object
>
attributes
=
metadata
.
getAnnotationAttributes
(
.
getAnnotationAttributes
(
ConditionalOnEnabledEndpoint
.
class
.
getName
());
ConditionalOnEnabledEndpoint
.
class
.
getName
());
if
(
attributes
!=
null
&&
attributes
.
containsKey
(
"endpoint"
))
{
if
(
attributes
!=
null
&&
attributes
.
containsKey
(
"endpoint"
))
{
Class
<?>
target
=
(
Class
<?>)
attributes
.
get
(
"endpoint"
);
Class
<?>
target
=
(
Class
<?>)
attributes
.
get
(
"endpoint"
);
if
(
target
!=
Void
.
class
)
{
if
(
target
!=
Void
.
class
)
{
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfiguration.java
View file @
7b120c1c
...
@@ -30,7 +30,8 @@ import org.springframework.integration.support.channel.HeaderChannelRegistry;
...
@@ -30,7 +30,8 @@ import org.springframework.integration.support.channel.HeaderChannelRegistry;
import
org.springframework.integration.support.management.graph.IntegrationGraphServer
;
import
org.springframework.integration.support.management.graph.IntegrationGraphServer
;
/**
/**
* {@link EnableAutoConfiguration Auto-configuration} for the {@link IntegrationGraphEndpoint}.
* {@link EnableAutoConfiguration Auto-configuration} for the
* {@link IntegrationGraphEndpoint}.
*
*
* @author Tim Ysewyn
* @author Tim Ysewyn
* @author Stephane Nicoll
* @author Stephane Nicoll
...
@@ -58,4 +59,3 @@ public class IntegrationGraphEndpointAutoConfiguration {
...
@@ -58,4 +59,3 @@ public class IntegrationGraphEndpointAutoConfiguration {
}
}
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfiguration.java
View file @
7b120c1c
...
@@ -37,20 +37,21 @@ import org.springframework.context.annotation.Configuration;
...
@@ -37,20 +37,21 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.web.reactive.function.client.WebClient
;
import
org.springframework.web.reactive.function.client.WebClient
;
/**
/**
* {@link EnableAutoConfiguration Auto-configuration} for instrumentation
* {@link EnableAutoConfiguration Auto-configuration} for instrumentation
of
*
of
{@link org.springframework.web.reactive.function.client.WebClient}.
* {@link org.springframework.web.reactive.function.client.WebClient}.
*
*
* <p>This is reusing the {@link io.micrometer.core.instrument.config.MeterFilter}
* <p>
* defined in {@link RestTemplateMetricsAutoConfiguration} for limiting the
* This is reusing the {@link io.micrometer.core.instrument.config.MeterFilter} defined in
* cardinality of "uri" tags.
* {@link RestTemplateMetricsAutoConfiguration} for limiting the cardinality of "uri"
* tags.
*
*
* @author Brian Clozel
* @author Brian Clozel
* @since 2.1.0
* @since 2.1.0
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
(
WebClient
.
class
)
@ConditionalOnClass
(
WebClient
.
class
)
@AutoConfigureAfter
({
MetricsAutoConfiguration
.
class
,
@AutoConfigureAfter
({
MetricsAutoConfiguration
.
class
,
SimpleMetricsExportAutoConfiguration
.
class
})
SimpleMetricsExportAutoConfiguration
.
class
})
@AutoConfigureBefore
(
WebClientAutoConfiguration
.
class
)
@AutoConfigureBefore
(
WebClientAutoConfiguration
.
class
)
@ConditionalOnBean
(
MeterRegistry
.
class
)
@ConditionalOnBean
(
MeterRegistry
.
class
)
public
class
WebClientMetricsAutoConfiguration
{
public
class
WebClientMetricsAutoConfiguration
{
...
@@ -62,8 +63,8 @@ public class WebClientMetricsAutoConfiguration {
...
@@ -62,8 +63,8 @@ public class WebClientMetricsAutoConfiguration {
}
}
@Bean
@Bean
public
MetricsWebClientCustomizer
metricsWebClientCustomizer
(
MeterRegistry
meterRegistry
,
public
MetricsWebClientCustomizer
metricsWebClientCustomizer
(
WebClientExchangeTagsProvider
tagsProvider
,
MeterRegistry
meterRegistry
,
WebClientExchangeTagsProvider
tagsProvider
,
MetricsProperties
properties
)
{
MetricsProperties
properties
)
{
return
new
MetricsWebClientCustomizer
(
meterRegistry
,
tagsProvider
,
return
new
MetricsWebClientCustomizer
(
meterRegistry
,
tagsProvider
,
properties
.
getWeb
().
getClient
().
getRequestsMetricName
());
properties
.
getWeb
().
getClient
().
getRequestsMetricName
());
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java
View file @
7b120c1c
...
@@ -33,8 +33,8 @@ import org.springframework.context.annotation.Bean;
...
@@ -33,8 +33,8 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
/**
/**
* {@link EnableAutoConfiguration Auto-configuration} for instrumentation
* {@link EnableAutoConfiguration Auto-configuration} for instrumentation
of Spring
*
of Spring
WebFlux applications.
* WebFlux applications.
*
*
* @author Jon Schneider
* @author Jon Schneider
* @since 2.0.0
* @since 2.0.0
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfigurationTests.java
View file @
7b120c1c
...
@@ -42,15 +42,14 @@ public class CachesEndpointAutoConfigurationTests {
...
@@ -42,15 +42,14 @@ public class CachesEndpointAutoConfigurationTests {
@Test
@Test
public
void
runShouldHaveEndpointBean
()
{
public
void
runShouldHaveEndpointBean
()
{
this
.
contextRunner
.
withUserConfiguration
(
CacheConfiguration
.
class
)
this
.
contextRunner
.
withUserConfiguration
(
CacheConfiguration
.
class
).
run
(
.
run
((
context
)
->
(
context
)
->
assertThat
(
context
).
hasSingleBean
(
CachesEndpoint
.
class
));
assertThat
(
context
).
hasSingleBean
(
CachesEndpoint
.
class
));
}
}
@Test
@Test
public
void
runWithoutCacheManagerShouldHaveEndpointBean
()
{
public
void
runWithoutCacheManagerShouldHaveEndpointBean
()
{
this
.
contextRunner
.
run
(
(
context
)
->
this
.
contextRunner
.
run
(
assertThat
(
context
).
hasSingleBean
(
CachesEndpoint
.
class
));
(
context
)
->
assertThat
(
context
).
hasSingleBean
(
CachesEndpoint
.
class
));
}
}
@Test
@Test
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpointTests.java
View file @
7b120c1c
...
@@ -104,9 +104,10 @@ public class ConditionalOnEnabledEndpointTests {
...
@@ -104,9 +104,10 @@ public class ConditionalOnEnabledEndpointTests {
@Test
@Test
public
void
outcomeWithReferenceWhenNoPropertiesShouldMatch
()
{
public
void
outcomeWithReferenceWhenNoPropertiesShouldMatch
()
{
this
.
contextRunner
.
withUserConfiguration
(
FooEndpointEnabledByDefaultTrue
.
class
,
this
.
contextRunner
ComponentEnabledIfEndpointIsEnabledConfiguration
.
class
).
run
((
context
)
->
.
withUserConfiguration
(
FooEndpointEnabledByDefaultTrue
.
class
,
assertThat
(
context
).
hasBean
(
"fooComponent"
));
ComponentEnabledIfEndpointIsEnabledConfiguration
.
class
)
.
run
((
context
)
->
assertThat
(
context
).
hasBean
(
"fooComponent"
));
}
}
@Test
@Test
...
@@ -114,8 +115,7 @@ public class ConditionalOnEnabledEndpointTests {
...
@@ -114,8 +115,7 @@ public class ConditionalOnEnabledEndpointTests {
this
.
contextRunner
.
withPropertyValues
(
"management.endpoint.foo.enabled=true"
)
this
.
contextRunner
.
withPropertyValues
(
"management.endpoint.foo.enabled=true"
)
.
withUserConfiguration
(
FooEndpointEnabledByDefaultTrue
.
class
,
.
withUserConfiguration
(
FooEndpointEnabledByDefaultTrue
.
class
,
ComponentEnabledIfEndpointIsEnabledConfiguration
.
class
)
ComponentEnabledIfEndpointIsEnabledConfiguration
.
class
)
.
run
((
context
)
->
.
run
((
context
)
->
assertThat
(
context
).
hasBean
(
"fooComponent"
));
assertThat
(
context
).
hasBean
(
"fooComponent"
));
}
}
@Test
@Test
...
@@ -123,22 +123,23 @@ public class ConditionalOnEnabledEndpointTests {
...
@@ -123,22 +123,23 @@ public class ConditionalOnEnabledEndpointTests {
this
.
contextRunner
.
withPropertyValues
(
"management.endpoint.foo.enabled=false"
)
this
.
contextRunner
.
withPropertyValues
(
"management.endpoint.foo.enabled=false"
)
.
withUserConfiguration
(
FooEndpointEnabledByDefaultTrue
.
class
,
.
withUserConfiguration
(
FooEndpointEnabledByDefaultTrue
.
class
,
ComponentEnabledIfEndpointIsEnabledConfiguration
.
class
)
ComponentEnabledIfEndpointIsEnabledConfiguration
.
class
)
.
run
((
context
)
->
.
run
((
context
)
->
assertThat
(
context
).
doesNotHaveBean
(
"fooComponent"
));
assertThat
(
context
).
doesNotHaveBean
(
"fooComponent"
));
}
}
@Test
@Test
public
void
outcomeWithNoReferenceShouldFail
()
{
public
void
outcomeWithNoReferenceShouldFail
()
{
this
.
contextRunner
.
withUserConfiguration
(
this
.
contextRunner
ComponentWithNoEndpointReferenceConfiguration
.
class
).
run
((
context
)
->
{
.
withUserConfiguration
(
assertThat
(
context
).
hasFailed
();
ComponentWithNoEndpointReferenceConfiguration
.
class
)
assertThat
(
context
.
getStartupFailure
().
getCause
().
getMessage
()).
contains
(
.
run
((
context
)
->
{
"No endpoint is specified and the return type of the @Bean method "
assertThat
(
context
).
hasFailed
();
+
"is neither an @Endpoint, nor an @EndpointExtension"
);
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"
);
});
}
}
@Endpoint
(
id
=
"foo"
,
enableByDefault
=
true
)
@Endpoint
(
id
=
"foo"
,
enableByDefault
=
true
)
static
class
FooEndpointEnabledByDefaultTrue
{
static
class
FooEndpointEnabledByDefaultTrue
{
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/CachesEndpointDocumentationTests.java
View file @
7b120c1c
...
@@ -45,6 +45,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
...
@@ -45,6 +45,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
/**
/**
* Tests for generating documentation describing the {@link CachesEndpoint}
* Tests for generating documentation describing the {@link CachesEndpoint}
*
* @author Stephane Nicoll
* @author Stephane Nicoll
*/
*/
public
class
CachesEndpointDocumentationTests
extends
MockMvcEndpointDocumentationTests
{
public
class
CachesEndpointDocumentationTests
extends
MockMvcEndpointDocumentationTests
{
...
@@ -52,11 +53,11 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
...
@@ -52,11 +53,11 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
private
static
final
List
<
FieldDescriptor
>
levelFields
=
Arrays
.
asList
(
private
static
final
List
<
FieldDescriptor
>
levelFields
=
Arrays
.
asList
(
fieldWithPath
(
"name"
).
description
(
"Cache name."
),
fieldWithPath
(
"name"
).
description
(
"Cache name."
),
fieldWithPath
(
"cacheManager"
).
description
(
"Cache manager name."
),
fieldWithPath
(
"cacheManager"
).
description
(
"Cache manager name."
),
fieldWithPath
(
"target"
)
.
description
(
fieldWithPath
(
"target"
)
"Fully qualified name of the native cache."
));
.
description
(
"Fully qualified name of the native cache."
));
private
static
final
List
<
ParameterDescriptor
>
requestParameters
=
Collections
.
singletonList
(
private
static
final
List
<
ParameterDescriptor
>
requestParameters
=
Collections
parameterWithName
(
"cacheManager"
)
.
singletonList
(
parameterWithName
(
"cacheManager"
)
.
description
(
"Name of the cacheManager to qualify the cache. May be "
.
description
(
"Name of the cacheManager to qualify the cache. May be "
+
"omitted if the cache name is unique."
)
+
"omitted if the cache name is unique."
)
.
optional
());
.
optional
());
...
@@ -67,12 +68,11 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
...
@@ -67,12 +68,11 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
.
andDo
(
MockMvcRestDocumentation
.
document
(
"caches/all"
,
responseFields
(
.
andDo
(
MockMvcRestDocumentation
.
document
(
"caches/all"
,
responseFields
(
fieldWithPath
(
"cacheManagers"
)
fieldWithPath
(
"cacheManagers"
)
.
description
(
"Cache managers keyed by id."
),
.
description
(
"Cache managers keyed by id."
),
fieldWithPath
(
"cacheManagers.*"
)
fieldWithPath
(
"cacheManagers.*"
).
description
(
.
description
(
"Caches in the application context keyed by "
"Caches in the application context keyed by "
+
"name."
))
+
"name."
))
.
andWithPrefix
(
"cacheManagers.*.*."
,
.
andWithPrefix
(
"cacheManagers.*.*."
,
fieldWithPath
(
"target"
)
fieldWithPath
(
"target"
).
description
(
.
description
(
"Fully qualified name of the native cache."
))));
"Fully qualified name of the native cache."
))));
}
}
@Test
@Test
...
@@ -91,14 +91,14 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
...
@@ -91,14 +91,14 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
@Test
@Test
public
void
evictNamedCache
()
throws
Exception
{
public
void
evictNamedCache
()
throws
Exception
{
this
.
mockMvc
.
perform
(
this
.
mockMvc
delete
(
"/actuator/caches/countries?cacheManager=anotherCacheManager"
))
.
perform
(
delete
(
.
andExpect
(
status
().
isNoContent
()).
andDo
(
"/actuator/caches/countries?cacheManager=anotherCacheManager"
))
MockMvcRestDocumentation
.
document
(
"caches/evict-named"
,
.
andExpect
(
status
().
isNoContent
())
.
andDo
(
MockMvcRestDocumentation
.
document
(
"caches/evict-named"
,
requestParameters
(
requestParameters
)));
requestParameters
(
requestParameters
)));
}
}
@Configuration
@Configuration
@Import
(
BaseDocumentationConfiguration
.
class
)
@Import
(
BaseDocumentationConfiguration
.
class
)
static
class
TestConfiguration
{
static
class
TestConfiguration
{
...
@@ -106,10 +106,10 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
...
@@ -106,10 +106,10 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
@Bean
@Bean
public
CachesEndpoint
endpoint
()
{
public
CachesEndpoint
endpoint
()
{
Map
<
String
,
CacheManager
>
cacheManagers
=
new
HashMap
<>();
Map
<
String
,
CacheManager
>
cacheManagers
=
new
HashMap
<>();
cacheManagers
.
put
(
"cacheManager"
,
new
ConcurrentMapCacheManager
(
cacheManagers
.
put
(
"cacheManager"
,
"countries"
,
"cities"
));
new
ConcurrentMapCacheManager
(
"countries"
,
"cities"
));
cacheManagers
.
put
(
"anotherCacheManager"
,
new
ConcurrentMapCacheManager
(
cacheManagers
.
put
(
"anotherCacheManager"
,
"countries"
));
new
ConcurrentMapCacheManager
(
"countries"
));
return
new
CachesEndpoint
(
cacheManagers
);
return
new
CachesEndpoint
(
cacheManagers
);
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/IntegrationGraphEndpointDocumentationTests.java
View file @
7b120c1c
...
@@ -35,7 +35,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
...
@@ -35,7 +35,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
*
* @author Tim Ysewyn
* @author Tim Ysewyn
*/
*/
public
class
IntegrationGraphEndpointDocumentationTests
extends
MockMvcEndpointDocumentationTests
{
public
class
IntegrationGraphEndpointDocumentationTests
extends
MockMvcEndpointDocumentationTests
{
@Test
@Test
public
void
graph
()
throws
Exception
{
public
void
graph
()
throws
Exception
{
...
@@ -45,8 +46,8 @@ public class IntegrationGraphEndpointDocumentationTests extends MockMvcEndpointD
...
@@ -45,8 +46,8 @@ public class IntegrationGraphEndpointDocumentationTests extends MockMvcEndpointD
@Test
@Test
public
void
rebuild
()
throws
Exception
{
public
void
rebuild
()
throws
Exception
{
this
.
mockMvc
.
perform
(
post
(
"/actuator/integrationgraph"
))
.
andExpect
(
status
()
this
.
mockMvc
.
perform
(
post
(
"/actuator/integrationgraph"
))
.
isNoContent
())
.
andExpect
(
status
().
isNoContent
())
.
andDo
(
MockMvcRestDocumentation
.
document
(
"integrationgraph/rebuild"
));
.
andDo
(
MockMvcRestDocumentation
.
document
(
"integrationgraph/rebuild"
));
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfigurationTests.java
View file @
7b120c1c
...
@@ -59,8 +59,8 @@ public class IntegrationGraphEndpointAutoConfigurationTests {
...
@@ -59,8 +59,8 @@ public class IntegrationGraphEndpointAutoConfigurationTests {
@Test
@Test
public
void
runWhenSpringIntegrationIsNotEnabledShouldNotHaveEndpointBean
()
{
public
void
runWhenSpringIntegrationIsNotEnabledShouldNotHaveEndpointBean
()
{
ApplicationContextRunner
noSpringIntegrationRunner
=
new
ApplicationContextRunner
()
ApplicationContextRunner
noSpringIntegrationRunner
=
new
ApplicationContextRunner
()
.
withConfiguration
(
AutoConfigurations
.
of
(
.
withConfiguration
(
AutoConfigurations
IntegrationGraphEndpointAutoConfiguration
.
class
));
.
of
(
IntegrationGraphEndpointAutoConfiguration
.
class
));
noSpringIntegrationRunner
.
run
((
context
)
->
{
noSpringIntegrationRunner
.
run
((
context
)
->
{
assertThat
(
context
).
doesNotHaveBean
(
IntegrationGraphEndpoint
.
class
);
assertThat
(
context
).
doesNotHaveBean
(
IntegrationGraphEndpoint
.
class
);
assertThat
(
context
).
doesNotHaveBean
(
IntegrationGraphServer
.
class
);
assertThat
(
context
).
doesNotHaveBean
(
IntegrationGraphServer
.
class
);
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java
View file @
7b120c1c
...
@@ -90,8 +90,9 @@ public class HibernateMetricsAutoConfigurationTests {
...
@@ -90,8 +90,9 @@ public class HibernateMetricsAutoConfigurationTests {
@Test
@Test
public
void
entityManagerFactoryInstrumentationCanBeDisabled
()
{
public
void
entityManagerFactoryInstrumentationCanBeDisabled
()
{
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.enable.hibernate=false"
,
this
.
contextRunner
"spring.jpa.properties.hibernate.generate_statistics:true"
)
.
withPropertyValues
(
"management.metrics.enable.hibernate=false"
,
"spring.jpa.properties.hibernate.generate_statistics:true"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
context
.
getBean
(
EntityManagerFactory
.
class
)
context
.
getBean
(
EntityManagerFactory
.
class
)
.
unwrap
(
SessionFactory
.
class
);
.
unwrap
(
SessionFactory
.
class
);
...
@@ -130,7 +131,7 @@ public class HibernateMetricsAutoConfigurationTests {
...
@@ -130,7 +131,7 @@ public class HibernateMetricsAutoConfigurationTests {
// ensure EntityManagerFactory is not an Hibernate SessionFactory
// ensure EntityManagerFactory is not an Hibernate SessionFactory
assertThatThrownBy
(()
->
context
.
getBean
(
EntityManagerFactory
.
class
)
assertThatThrownBy
(()
->
context
.
getBean
(
EntityManagerFactory
.
class
)
.
unwrap
(
SessionFactory
.
class
))
.
unwrap
(
SessionFactory
.
class
))
.
isInstanceOf
(
PersistenceException
.
class
);
.
isInstanceOf
(
PersistenceException
.
class
);
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
assertThat
(
registry
.
find
(
"hibernate.statements"
).
meter
()).
isNull
();
assertThat
(
registry
.
find
(
"hibernate.statements"
).
meter
()).
isNull
();
});
});
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsAutoConfigurationTests.java
View file @
7b120c1c
...
@@ -78,25 +78,27 @@ public class RestTemplateMetricsAutoConfigurationTests {
...
@@ -78,25 +78,27 @@ public class RestTemplateMetricsAutoConfigurationTests {
this
.
contextRunner
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.web.client.max-uri-tags=10"
)
.
withPropertyValues
(
"management.metrics.web.client.max-uri-tags=10"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
MetricsProperties
properties
=
context
.
getBean
(
MetricsProperties
.
class
);
MetricsProperties
properties
=
context
int
maxUriTags
=
properties
.
getWeb
().
getClient
().
getMaxUriTags
();
.
getBean
(
MetricsProperties
.
class
);
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
int
maxUriTags
=
properties
.
getWeb
().
getClient
().
getMaxUriTags
();
RestTemplate
restTemplate
=
context
.
getBean
(
RestTemplateBuilder
.
class
)
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
.
build
();
RestTemplate
restTemplate
=
context
.
getBean
(
RestTemplateBuilder
.
class
)
MockRestServiceServer
server
=
MockRestServiceServer
.
build
();
.
createServer
(
restTemplate
);
MockRestServiceServer
server
=
MockRestServiceServer
for
(
int
i
=
0
;
i
<
maxUriTags
+
10
;
i
++)
{
.
createServer
(
restTemplate
);
server
.
expect
(
requestTo
(
"/test/"
+
i
))
for
(
int
i
=
0
;
i
<
maxUriTags
+
10
;
i
++)
{
.
andRespond
(
withStatus
(
HttpStatus
.
OK
));
server
.
expect
(
requestTo
(
"/test/"
+
i
))
}
.
andRespond
(
withStatus
(
HttpStatus
.
OK
));
for
(
int
i
=
0
;
i
<
maxUriTags
+
10
;
i
++)
{
}
restTemplate
.
getForObject
(
"/test/"
+
i
,
String
.
class
);
for
(
int
i
=
0
;
i
<
maxUriTags
+
10
;
i
++)
{
}
restTemplate
.
getForObject
(
"/test/"
+
i
,
String
.
class
);
assertThat
(
registry
.
get
(
"http.client.requests"
).
meters
()).
hasSize
(
maxUriTags
);
}
assertThat
(
this
.
out
.
toString
())
assertThat
(
registry
.
get
(
"http.client.requests"
).
meters
())
.
contains
(
"Reached the maximum number of URI tags "
.
hasSize
(
maxUriTags
);
+
"for 'http.client.requests'"
);
assertThat
(
this
.
out
.
toString
())
});
.
contains
(
"Reached the maximum number of URI tags "
+
"for 'http.client.requests'"
);
});
}
}
private
void
validateRestTemplate
(
RestTemplate
restTemplate
,
MeterRegistry
registry
)
{
private
void
validateRestTemplate
(
RestTemplate
restTemplate
,
MeterRegistry
registry
)
{
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfigurationTests.java
View file @
7b120c1c
...
@@ -116,6 +116,7 @@ public class WebClientMetricsAutoConfigurationTests {
...
@@ -116,6 +116,7 @@ public class WebClientMetricsAutoConfigurationTests {
public
WebClientExchangeTagsProvider
customTagProvider
()
{
public
WebClientExchangeTagsProvider
customTagProvider
()
{
return
mock
(
WebClientExchangeTagsProvider
.
class
);
return
mock
(
WebClientExchangeTagsProvider
.
class
);
}
}
}
}
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java
View file @
7b120c1c
...
@@ -65,5 +65,7 @@ public class WebFluxMetricsAutoConfigurationTests {
...
@@ -65,5 +65,7 @@ public class WebFluxMetricsAutoConfigurationTests {
public
WebFluxTagsProvider
customWebFluxTagsProvider
()
{
public
WebFluxTagsProvider
customWebFluxTagsProvider
()
{
return
mock
(
WebFluxTagsProvider
.
class
);
return
mock
(
WebFluxTagsProvider
.
class
);
}
}
}
}
}
}
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java
View file @
7b120c1c
...
@@ -78,8 +78,8 @@ public class CachesEndpoint {
...
@@ -78,8 +78,8 @@ public class CachesEndpoint {
*/
*/
@ReadOperation
@ReadOperation
public
CacheEntry
cache
(
@Selector
String
cache
,
@Nullable
String
cacheManager
)
{
public
CacheEntry
cache
(
@Selector
String
cache
,
@Nullable
String
cacheManager
)
{
return
extractUniqueCacheEntry
(
cache
,
getCacheEntries
(
return
extractUniqueCacheEntry
(
cache
,
(
name
)
->
name
.
equals
(
cache
),
safeEqual
(
cacheManager
)));
getCacheEntries
(
(
name
)
->
name
.
equals
(
cache
),
safeEqual
(
cacheManager
)));
}
}
/**
/**
...
@@ -95,23 +95,23 @@ public class CachesEndpoint {
...
@@ -95,23 +95,23 @@ public class CachesEndpoint {
* Clear the specific {@link Cache}.
* Clear the specific {@link Cache}.
* @param cache then name of the cache
* @param cache then name of the cache
* @param cacheManager the name of the cacheManager (can be {@code null}
* @param cacheManager the name of the cacheManager (can be {@code null}
* @return {@code true} if the cache was cleared or {@code false} if no such cache exists
* @return {@code true} if the cache was cleared or {@code false} if no such cache
* exists
* @throws NonUniqueCacheException if more than one cache with that name exist and no
* @throws NonUniqueCacheException if more than one cache with that name exist and no
*/
*/
@DeleteOperation
@DeleteOperation
public
boolean
clearCache
(
@Selector
String
cache
,
@Nullable
String
cacheManager
)
{
public
boolean
clearCache
(
@Selector
String
cache
,
@Nullable
String
cacheManager
)
{
CacheEntry
entry
=
extractUniqueCacheEntry
(
cache
,
getCacheEntries
(
CacheEntry
entry
=
extractUniqueCacheEntry
(
cache
,
(
name
)
->
name
.
equals
(
cache
),
safeEqual
(
cacheManager
)));
getCacheEntries
(
(
name
)
->
name
.
equals
(
cache
),
safeEqual
(
cacheManager
)));
return
(
entry
!=
null
&&
clearCache
(
entry
));
return
(
entry
!=
null
&&
clearCache
(
entry
));
}
}
private
List
<
CacheEntry
>
getCacheEntries
(
private
List
<
CacheEntry
>
getCacheEntries
(
Predicate
<
String
>
cacheNamePredicate
,
Predicate
<
String
>
cacheNamePredicate
,
Predicate
<
String
>
cacheManagerNamePredicate
)
{
Predicate
<
String
>
cacheManagerNamePredicate
)
{
List
<
CacheEntry
>
entries
=
new
ArrayList
<>();
List
<
CacheEntry
>
entries
=
new
ArrayList
<>();
this
.
cacheManagers
.
keySet
().
stream
().
filter
(
cacheManagerNamePredicate
)
this
.
cacheManagers
.
keySet
().
stream
().
filter
(
cacheManagerNamePredicate
)
.
forEach
((
cacheManagerName
)
->
entries
.
addAll
(
.
forEach
((
cacheManagerName
)
->
entries
getCacheEntries
(
cacheManagerName
,
cacheNamePredicate
)));
.
addAll
(
getCacheEntries
(
cacheManagerName
,
cacheNamePredicate
)));
return
entries
;
return
entries
;
}
}
...
@@ -121,17 +121,15 @@ public class CachesEndpoint {
...
@@ -121,17 +121,15 @@ public class CachesEndpoint {
List
<
CacheEntry
>
entries
=
new
ArrayList
<>();
List
<
CacheEntry
>
entries
=
new
ArrayList
<>();
cacheManager
.
getCacheNames
().
stream
().
filter
(
cacheNamePredicate
)
cacheManager
.
getCacheNames
().
stream
().
filter
(
cacheNamePredicate
)
.
map
(
cacheManager:
:
getCache
).
filter
(
Objects:
:
nonNull
)
.
map
(
cacheManager:
:
getCache
).
filter
(
Objects:
:
nonNull
)
.
forEach
((
cache
)
->
entries
.
add
(
.
forEach
((
cache
)
->
entries
.
add
(
new
CacheEntry
(
cache
,
cacheManagerName
)));
new
CacheEntry
(
cache
,
cacheManagerName
)));
return
entries
;
return
entries
;
}
}
private
CacheEntry
extractUniqueCacheEntry
(
String
cache
,
private
CacheEntry
extractUniqueCacheEntry
(
String
cache
,
List
<
CacheEntry
>
entries
)
{
List
<
CacheEntry
>
entries
)
{
if
(
entries
.
size
()
>
1
)
{
if
(
entries
.
size
()
>
1
)
{
throw
new
NonUniqueCacheException
(
cache
,
entries
.
stream
()
throw
new
NonUniqueCacheException
(
cache
,
.
map
(
CacheEntry:
:
getCacheManager
).
distinct
()
entries
.
stream
()
.
map
(
CacheEntry:
:
getCacheManager
).
distinct
()
.
collect
(
Collectors
.
toList
()));
.
collect
(
Collectors
.
toList
()));
}
}
return
(
entries
.
isEmpty
()
?
null
:
entries
.
get
(
0
));
return
(
entries
.
isEmpty
()
?
null
:
entries
.
get
(
0
));
}
}
...
@@ -152,8 +150,8 @@ public class CachesEndpoint {
...
@@ -152,8 +150,8 @@ public class CachesEndpoint {
}
}
/**
/**
* A report of available {@link Cache caches}, primarily intended for serialization
* A report of available {@link Cache caches}, primarily intended for serialization
to
*
to
JSON.
* JSON.
*/
*/
public
static
final
class
CachesReport
{
public
static
final
class
CachesReport
{
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProvider.java
View file @
7b120c1c
...
@@ -47,4 +47,5 @@ public class DefaultWebClientExchangeTagsProvider
...
@@ -47,4 +47,5 @@ public class DefaultWebClientExchangeTagsProvider
WebClientExchangeTags
.
status
(
throwable
));
WebClientExchangeTags
.
status
(
throwable
));
}
}
}
}
}
}
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunction.java
View file @
7b120c1c
...
@@ -29,8 +29,8 @@ import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
...
@@ -29,8 +29,8 @@ import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import
org.springframework.web.reactive.function.client.ExchangeFunction
;
import
org.springframework.web.reactive.function.client.ExchangeFunction
;
/**
/**
* {@link ExchangeFilterFunction} applied via a
* {@link ExchangeFilterFunction} applied via a
{@link MetricsWebClientCustomizer} to
*
{@link MetricsWebClientCustomizer} to
record metrics.
* record metrics.
*
*
* @author Brian Clozel
* @author Brian Clozel
* @since 2.1.0
* @since 2.1.0
...
@@ -58,8 +58,7 @@ public class MetricsWebClientFilterFunction implements ExchangeFilterFunction {
...
@@ -58,8 +58,7 @@ public class MetricsWebClientFilterFunction implements ExchangeFilterFunction {
.
doOnSuccessOrError
((
clientResponse
,
throwable
)
->
{
.
doOnSuccessOrError
((
clientResponse
,
throwable
)
->
{
Iterable
<
Tag
>
tags
=
this
.
tagProvider
.
tags
(
clientRequest
,
Iterable
<
Tag
>
tags
=
this
.
tagProvider
.
tags
(
clientRequest
,
clientResponse
,
throwable
);
clientResponse
,
throwable
);
Timer
.
builder
(
this
.
metricName
)
Timer
.
builder
(
this
.
metricName
).
tags
(
tags
)
.
tags
(
tags
)
.
description
(
"Timer of WebClient operation"
)
.
description
(
"Timer of WebClient operation"
)
.
register
(
this
.
meterRegistry
)
.
register
(
this
.
meterRegistry
)
.
record
(
System
.
nanoTime
()
-
startTime
,
TimeUnit
.
NANOSECONDS
);
.
record
(
System
.
nanoTime
()
-
startTime
,
TimeUnit
.
NANOSECONDS
);
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java
View file @
7b120c1c
...
@@ -34,7 +34,8 @@ import org.springframework.web.reactive.function.client.WebClient;
...
@@ -34,7 +34,8 @@ import org.springframework.web.reactive.function.client.WebClient;
*/
*/
public
final
class
WebClientExchangeTags
{
public
final
class
WebClientExchangeTags
{
private
static
final
String
URI_TEMPLATE_ATTRIBUTE
=
WebClient
.
class
.
getName
()
+
".uriTemplate"
;
private
static
final
String
URI_TEMPLATE_ATTRIBUTE
=
WebClient
.
class
.
getName
()
+
".uriTemplate"
;
private
static
final
Tag
IO_ERROR
=
Tag
.
of
(
"status"
,
"IO_ERROR"
);
private
static
final
Tag
IO_ERROR
=
Tag
.
of
(
"status"
,
"IO_ERROR"
);
...
@@ -44,8 +45,8 @@ public final class WebClientExchangeTags {
...
@@ -44,8 +45,8 @@ public final class WebClientExchangeTags {
}
}
/**
/**
* Creates a {@code method} {@code Tag} for the
* Creates a {@code method} {@code Tag} for the
{@link ClientHttpRequest#getMethod()
*
{@link ClientHttpRequest#getMethod()
method} of the given {@code request}.
* method} of the given {@code request}.
* @param request the request
* @param request the request
* @return the method tag
* @return the method tag
*/
*/
...
@@ -80,8 +81,8 @@ public final class WebClientExchangeTags {
...
@@ -80,8 +81,8 @@ public final class WebClientExchangeTags {
}
}
/**
/**
* Creates a {@code status} {@code Tag} derived from the
* Creates a {@code status} {@code Tag} derived from the
exception thrown by the
*
exception thrown by the
client.
* client.
* @param throwable the exception
* @param throwable the exception
* @return the status tag
* @return the status tag
*/
*/
...
@@ -90,9 +91,9 @@ public final class WebClientExchangeTags {
...
@@ -90,9 +91,9 @@ public final class WebClientExchangeTags {
}
}
/**
/**
* Create a {@code clientName} {@code Tag} derived from
* Create a {@code clientName} {@code Tag} derived from
the
*
the {@link java.net.URI#getHost host}
*
{@link java.net.URI#getHost host} of the {@link ClientRequest#url() URL} of the
*
of the {@link ClientRequest#url() URL} of the
given {@code request}.
* given {@code request}.
* @param request the request
* @param request the request
* @return the clientName tag
* @return the clientName tag
*/
*/
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsProvider.java
View file @
7b120c1c
...
@@ -38,5 +38,7 @@ public interface WebClientExchangeTagsProvider {
...
@@ -38,5 +38,7 @@ public interface WebClientExchangeTagsProvider {
* @param throwable the exception (may be {@code null})
* @param throwable the exception (may be {@code null})
* @return tags to associate with metrics for the request and response exchange
* @return tags to associate with metrics for the request and response exchange
*/
*/
Iterable
<
Tag
>
tags
(
ClientRequest
request
,
ClientResponse
response
,
Throwable
throwable
);
Iterable
<
Tag
>
tags
(
ClientRequest
request
,
ClientResponse
response
,
Throwable
throwable
);
}
}
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/package-info.java
View file @
7b120c1c
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
*/
*/
/**
/**
* Actuator support for
* Actuator support for
{@link org.springframework.web.reactive.function.client.WebClient}
*
{@link org.springframework.web.reactive.function.client.WebClient}
metrics.
* metrics.
*/
*/
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
web
.
reactive
.
client
;
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
web
.
reactive
.
client
;
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java
View file @
7b120c1c
...
@@ -51,17 +51,17 @@ public class CachesEndpointTests {
...
@@ -51,17 +51,17 @@ public class CachesEndpointTests {
@Test
@Test
public
void
allCachesWithSingleCacheManager
()
{
public
void
allCachesWithSingleCacheManager
()
{
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
Collections
.
singletonMap
(
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
Collections
.
singletonMap
(
"test"
,
"test"
,
new
ConcurrentMapCacheManager
(
"a"
,
"b"
)));
new
ConcurrentMapCacheManager
(
"a"
,
"b"
)));
Map
<
String
,
Map
<
String
,
CacheDescriptor
>>
allDescriptors
=
endpoint
.
caches
()
Map
<
String
,
Map
<
String
,
CacheDescriptor
>>
allDescriptors
=
endpoint
.
caches
()
.
getCacheManagers
();
.
getCacheManagers
();
assertThat
(
allDescriptors
).
containsOnlyKeys
(
"test"
);
assertThat
(
allDescriptors
).
containsOnlyKeys
(
"test"
);
Map
<
String
,
CacheDescriptor
>
descriptors
=
allDescriptors
.
get
(
"test"
);
Map
<
String
,
CacheDescriptor
>
descriptors
=
allDescriptors
.
get
(
"test"
);
assertThat
(
descriptors
).
containsOnlyKeys
(
"a"
,
"b"
);
assertThat
(
descriptors
).
containsOnlyKeys
(
"a"
,
"b"
);
assertThat
(
descriptors
.
get
(
"a"
).
getTarget
())
.
isEqualTo
(
assertThat
(
descriptors
.
get
(
"a"
).
getTarget
())
ConcurrentHashMap
.
class
.
getName
());
.
isEqualTo
(
ConcurrentHashMap
.
class
.
getName
());
assertThat
(
descriptors
.
get
(
"b"
).
getTarget
())
.
isEqualTo
(
assertThat
(
descriptors
.
get
(
"b"
).
getTarget
())
ConcurrentHashMap
.
class
.
getName
());
.
isEqualTo
(
ConcurrentHashMap
.
class
.
getName
());
}
}
@Test
@Test
...
@@ -79,8 +79,8 @@ public class CachesEndpointTests {
...
@@ -79,8 +79,8 @@ public class CachesEndpointTests {
@Test
@Test
public
void
namedCacheWithSingleCacheManager
()
{
public
void
namedCacheWithSingleCacheManager
()
{
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
Collections
.
singletonMap
(
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
Collections
.
singletonMap
(
"test"
,
"test"
,
new
ConcurrentMapCacheManager
(
"b"
,
"a"
)));
new
ConcurrentMapCacheManager
(
"b"
,
"a"
)));
CacheEntry
entry
=
endpoint
.
cache
(
"a"
,
null
);
CacheEntry
entry
=
endpoint
.
cache
(
"a"
,
null
);
assertThat
(
entry
).
isNotNull
();
assertThat
(
entry
).
isNotNull
();
assertThat
(
entry
.
getCacheManager
()).
isEqualTo
(
"test"
);
assertThat
(
entry
.
getCacheManager
()).
isEqualTo
(
"test"
);
...
@@ -103,8 +103,8 @@ public class CachesEndpointTests {
...
@@ -103,8 +103,8 @@ public class CachesEndpointTests {
@Test
@Test
public
void
namedCacheWithUnknownCache
()
{
public
void
namedCacheWithUnknownCache
()
{
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
Collections
.
singletonMap
(
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
Collections
.
singletonMap
(
"test"
,
"test"
,
new
ConcurrentMapCacheManager
(
"b"
,
"a"
)));
new
ConcurrentMapCacheManager
(
"b"
,
"a"
)));
CacheEntry
entry
=
endpoint
.
cache
(
"unknown"
,
null
);
CacheEntry
entry
=
endpoint
.
cache
(
"unknown"
,
null
);
assertThat
(
entry
).
isNull
();
assertThat
(
entry
).
isNull
();
}
}
...
@@ -135,8 +135,8 @@ public class CachesEndpointTests {
...
@@ -135,8 +135,8 @@ public class CachesEndpointTests {
public
void
clearAllCaches
()
{
public
void
clearAllCaches
()
{
Cache
a
=
mockCache
(
"a"
);
Cache
a
=
mockCache
(
"a"
);
Cache
b
=
mockCache
(
"b"
);
Cache
b
=
mockCache
(
"b"
);
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
Collections
.
singletonMap
(
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
"test"
,
cacheManager
(
a
,
b
)));
Collections
.
singletonMap
(
"test"
,
cacheManager
(
a
,
b
)));
endpoint
.
clearCaches
();
endpoint
.
clearCaches
();
verify
(
a
).
clear
();
verify
(
a
).
clear
();
verify
(
b
).
clear
();
verify
(
b
).
clear
();
...
@@ -146,8 +146,8 @@ public class CachesEndpointTests {
...
@@ -146,8 +146,8 @@ public class CachesEndpointTests {
public
void
clearCache
()
{
public
void
clearCache
()
{
Cache
a
=
mockCache
(
"a"
);
Cache
a
=
mockCache
(
"a"
);
Cache
b
=
mockCache
(
"b"
);
Cache
b
=
mockCache
(
"b"
);
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
Collections
.
singletonMap
(
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
"test"
,
cacheManager
(
a
,
b
)));
Collections
.
singletonMap
(
"test"
,
cacheManager
(
a
,
b
)));
assertThat
(
endpoint
.
clearCache
(
"a"
,
null
)).
isTrue
();
assertThat
(
endpoint
.
clearCache
(
"a"
,
null
)).
isTrue
();
verify
(
a
).
clear
();
verify
(
a
).
clear
();
verify
(
b
,
never
()).
clear
();
verify
(
b
,
never
()).
clear
();
...
@@ -184,8 +184,8 @@ public class CachesEndpointTests {
...
@@ -184,8 +184,8 @@ public class CachesEndpointTests {
@Test
@Test
public
void
clearCacheWithUnknownCache
()
{
public
void
clearCacheWithUnknownCache
()
{
Cache
a
=
mockCache
(
"a"
);
Cache
a
=
mockCache
(
"a"
);
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
Collections
.
singletonMap
(
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
"test"
,
cacheManager
(
a
)));
Collections
.
singletonMap
(
"test"
,
cacheManager
(
a
)));
assertThat
(
endpoint
.
clearCache
(
"unknown"
,
null
)).
isFalse
();
assertThat
(
endpoint
.
clearCache
(
"unknown"
,
null
)).
isFalse
();
verify
(
a
,
never
()).
clear
();
verify
(
a
,
never
()).
clear
();
}
}
...
@@ -193,8 +193,8 @@ public class CachesEndpointTests {
...
@@ -193,8 +193,8 @@ public class CachesEndpointTests {
@Test
@Test
public
void
clearCacheWithUnknownCacheManager
()
{
public
void
clearCacheWithUnknownCacheManager
()
{
Cache
a
=
mockCache
(
"a"
);
Cache
a
=
mockCache
(
"a"
);
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
Collections
.
singletonMap
(
CachesEndpoint
endpoint
=
new
CachesEndpoint
(
"test"
,
cacheManager
(
a
)));
Collections
.
singletonMap
(
"test"
,
cacheManager
(
a
)));
assertThat
(
endpoint
.
clearCache
(
"a"
,
"unknown"
)).
isFalse
();
assertThat
(
endpoint
.
clearCache
(
"a"
,
"unknown"
)).
isFalse
();
verify
(
a
,
never
()).
clear
();
verify
(
a
,
never
()).
clear
();
}
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointWebIntegrationTests.java
View file @
7b120c1c
...
@@ -34,7 +34,8 @@ import org.springframework.test.web.reactive.server.WebTestClient;
...
@@ -34,7 +34,8 @@ import org.springframework.test.web.reactive.server.WebTestClient;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
/**
* Integration tests for {@link CachesEndpoint} exposed by Jersey, Spring MVC, and WebFlux.
* Integration tests for {@link CachesEndpoint} exposed by Jersey, Spring MVC, and
* WebFlux.
*
*
* @author Stephane Nicoll
* @author Stephane Nicoll
*/
*/
...
@@ -48,23 +49,22 @@ public class CachesEndpointWebIntegrationTests {
...
@@ -48,23 +49,22 @@ public class CachesEndpointWebIntegrationTests {
@Test
@Test
public
void
allCaches
()
{
public
void
allCaches
()
{
client
.
get
().
uri
(
"/actuator/caches"
).
exchange
().
expectStatus
().
isOk
().
expectBody
()
client
.
get
().
uri
(
"/actuator/caches"
).
exchange
().
expectStatus
().
isOk
().
expectBody
()
.
jsonPath
(
"cacheManagers.one.a.target"
)
.
isEqualTo
(
.
jsonPath
(
"cacheManagers.one.a.target"
)
ConcurrentHashMap
.
class
.
getName
())
.
isEqualTo
(
ConcurrentHashMap
.
class
.
getName
())
.
jsonPath
(
"cacheManagers.one.b.target"
)
.
isEqualTo
(
.
jsonPath
(
"cacheManagers.one.b.target"
)
ConcurrentHashMap
.
class
.
getName
())
.
isEqualTo
(
ConcurrentHashMap
.
class
.
getName
())
.
jsonPath
(
"cacheManagers.two.a.target"
)
.
isEqualTo
(
.
jsonPath
(
"cacheManagers.two.a.target"
)
ConcurrentHashMap
.
class
.
getName
())
.
isEqualTo
(
ConcurrentHashMap
.
class
.
getName
())
.
jsonPath
(
"cacheManagers.two.c.target"
)
.
isEqualTo
(
.
jsonPath
(
"cacheManagers.two.c.target"
)
ConcurrentHashMap
.
class
.
getName
());
.
isEqualTo
(
ConcurrentHashMap
.
class
.
getName
());
}
}
@Test
@Test
public
void
namedCache
()
{
public
void
namedCache
()
{
client
.
get
().
uri
(
"/actuator/caches/b"
).
exchange
().
expectStatus
().
isOk
()
client
.
get
().
uri
(
"/actuator/caches/b"
).
exchange
().
expectStatus
().
isOk
()
.
expectBody
()
.
expectBody
().
jsonPath
(
"name"
).
isEqualTo
(
"b"
).
jsonPath
(
"cacheManager"
)
.
jsonPath
(
"name"
).
isEqualTo
(
"b"
)
.
isEqualTo
(
"one"
).
jsonPath
(
"target"
)
.
jsonPath
(
"cacheManager"
).
isEqualTo
(
"one"
)
.
isEqualTo
(
ConcurrentHashMap
.
class
.
getName
());
.
jsonPath
(
"target"
).
isEqualTo
(
ConcurrentHashMap
.
class
.
getName
());
}
}
@Test
@Test
...
@@ -75,8 +75,7 @@ public class CachesEndpointWebIntegrationTests {
...
@@ -75,8 +75,7 @@ public class CachesEndpointWebIntegrationTests {
@Test
@Test
public
void
namedCacheWithNonUniqueName
()
{
public
void
namedCacheWithNonUniqueName
()
{
client
.
get
().
uri
(
"/actuator/caches/a"
).
exchange
().
expectStatus
()
client
.
get
().
uri
(
"/actuator/caches/a"
).
exchange
().
expectStatus
().
isBadRequest
();
.
isBadRequest
();
}
}
@Test
@Test
...
@@ -95,11 +94,9 @@ public class CachesEndpointWebIntegrationTests {
...
@@ -95,11 +94,9 @@ public class CachesEndpointWebIntegrationTests {
@Test
@Test
public
void
clearNamedCacheWithNonUniqueName
()
{
public
void
clearNamedCacheWithNonUniqueName
()
{
client
.
get
().
uri
(
"/actuator/caches/a"
).
exchange
().
expectStatus
()
client
.
get
().
uri
(
"/actuator/caches/a"
).
exchange
().
expectStatus
().
isBadRequest
();
.
isBadRequest
();
}
}
@Configuration
@Configuration
static
class
TestConfiguration
{
static
class
TestConfiguration
{
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointWebIntegrationTests.java
View file @
7b120c1c
...
@@ -28,7 +28,8 @@ import org.springframework.integration.support.management.graph.IntegrationGraph
...
@@ -28,7 +28,8 @@ import org.springframework.integration.support.management.graph.IntegrationGraph
import
org.springframework.test.web.reactive.server.WebTestClient
;
import
org.springframework.test.web.reactive.server.WebTestClient
;
/**
/**
* Integration tests for {@link IntegrationGraphEndpoint} exposed by Jersey, Spring MVC, and WebFlux.
* Integration tests for {@link IntegrationGraphEndpoint} exposed by Jersey, Spring MVC,
* and WebFlux.
*
*
* @author Tim Ysewyn
* @author Tim Ysewyn
*/
*/
...
@@ -39,8 +40,8 @@ public class IntegrationGraphEndpointWebIntegrationTests {
...
@@ -39,8 +40,8 @@ public class IntegrationGraphEndpointWebIntegrationTests {
@Test
@Test
public
void
graph
()
{
public
void
graph
()
{
client
.
get
().
uri
(
"/actuator/integrationgraph"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
exchange
()
client
.
get
().
uri
(
"/actuator/integrationgraph"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
expectStatus
().
isOk
().
expectBody
()
.
ex
change
().
ex
pectStatus
().
isOk
().
expectBody
()
.
jsonPath
(
"contentDescriptor.providerVersion"
).
isNotEmpty
()
.
jsonPath
(
"contentDescriptor.providerVersion"
).
isNotEmpty
()
.
jsonPath
(
"contentDescriptor.providerFormatVersion"
).
isEqualTo
(
1.0f
)
.
jsonPath
(
"contentDescriptor.providerFormatVersion"
).
isEqualTo
(
1.0f
)
.
jsonPath
(
"contentDescriptor.provider"
).
isEqualTo
(
"spring-integration"
);
.
jsonPath
(
"contentDescriptor.provider"
).
isEqualTo
(
"spring-integration"
);
...
@@ -48,8 +49,8 @@ public class IntegrationGraphEndpointWebIntegrationTests {
...
@@ -48,8 +49,8 @@ public class IntegrationGraphEndpointWebIntegrationTests {
@Test
@Test
public
void
rebuild
()
{
public
void
rebuild
()
{
client
.
post
().
uri
(
"/actuator/integrationgraph"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
exchange
()
client
.
post
().
uri
(
"/actuator/integrationgraph"
).
accept
(
MediaType
.
APPLICATION_JSON
)
.
expectStatus
().
isNoContent
();
.
ex
change
().
ex
pectStatus
().
isNoContent
();
}
}
@Configuration
@Configuration
...
@@ -57,7 +58,8 @@ public class IntegrationGraphEndpointWebIntegrationTests {
...
@@ -57,7 +58,8 @@ public class IntegrationGraphEndpointWebIntegrationTests {
public
static
class
TestConfiguration
{
public
static
class
TestConfiguration
{
@Bean
@Bean
public
IntegrationGraphEndpoint
endpoint
(
IntegrationGraphServer
integrationGraphServer
)
{
public
IntegrationGraphEndpoint
endpoint
(
IntegrationGraphServer
integrationGraphServer
)
{
return
new
IntegrationGraphEndpoint
(
integrationGraphServer
);
return
new
IntegrationGraphEndpoint
(
integrationGraphServer
);
}
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java
View file @
7b120c1c
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
web
.
reactive
.
client
;
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
web
.
reactive
.
client
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URI
;
...
@@ -41,7 +40,8 @@ import static org.mockito.Mockito.mock;
...
@@ -41,7 +40,8 @@ import static org.mockito.Mockito.mock;
*/
*/
public
class
DefaultWebClientExchangeTagsProviderTests
{
public
class
DefaultWebClientExchangeTagsProviderTests
{
private
static
final
String
URI_TEMPLATE_ATTRIBUTE
=
WebClient
.
class
.
getName
()
+
".uriTemplate"
;
private
static
final
String
URI_TEMPLATE_ATTRIBUTE
=
WebClient
.
class
.
getName
()
+
".uriTemplate"
;
private
WebClientExchangeTagsProvider
tagsProvider
=
new
DefaultWebClientExchangeTagsProvider
();
private
WebClientExchangeTagsProvider
tagsProvider
=
new
DefaultWebClientExchangeTagsProvider
();
...
@@ -52,8 +52,10 @@ public class DefaultWebClientExchangeTagsProviderTests {
...
@@ -52,8 +52,10 @@ public class DefaultWebClientExchangeTagsProviderTests {
@Before
@Before
public
void
setup
()
{
public
void
setup
()
{
this
.
request
=
ClientRequest
this
.
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
URI
.
create
(
"http://example.org/projects/spring-boot"
))
.
create
(
HttpMethod
.
GET
,
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"http://example.org/projects/{project}"
)
URI
.
create
(
"http://example.org/projects/spring-boot"
))
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"http://example.org/projects/{project}"
)
.
build
();
.
build
();
this
.
response
=
mock
(
ClientResponse
.
class
);
this
.
response
=
mock
(
ClientResponse
.
class
);
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
...
@@ -62,38 +64,37 @@ public class DefaultWebClientExchangeTagsProviderTests {
...
@@ -62,38 +64,37 @@ public class DefaultWebClientExchangeTagsProviderTests {
@Test
@Test
public
void
tagsShouldBePopulated
()
{
public
void
tagsShouldBePopulated
()
{
Iterable
<
Tag
>
tags
=
this
.
tagsProvider
.
tags
(
this
.
request
,
this
.
response
,
null
);
Iterable
<
Tag
>
tags
=
this
.
tagsProvider
.
tags
(
this
.
request
,
this
.
response
,
null
);
assertThat
(
tags
).
containsExactlyInAnyOrder
(
assertThat
(
tags
).
containsExactlyInAnyOrder
(
Tag
.
of
(
"method"
,
"GET"
),
Tag
.
of
(
"
method"
,
"GET"
),
Tag
.
of
(
"uri"
,
"/projects/{project}
"
),
Tag
.
of
(
"
uri"
,
"/projects/{project}"
),
Tag
.
of
(
"clientName"
,
"example.org
"
),
Tag
.
of
(
"
clientName"
,
"example.org"
),
Tag
.
of
(
"
status"
,
"200"
));
Tag
.
of
(
"status"
,
"200"
));
}
}
@Test
@Test
public
void
tagsWhenNoUriTemplateShouldProvideUriPath
()
{
public
void
tagsWhenNoUriTemplateShouldProvideUriPath
()
{
ClientRequest
request
=
ClientRequest
ClientRequest
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
.
create
(
HttpMethod
.
GET
,
URI
.
create
(
"http://example.org/projects/spring-boot"
))
URI
.
create
(
"http://example.org/projects/spring-boot"
)).
build
();
.
build
();
Iterable
<
Tag
>
tags
=
this
.
tagsProvider
.
tags
(
request
,
this
.
response
,
null
);
Iterable
<
Tag
>
tags
=
this
.
tagsProvider
.
tags
(
request
,
this
.
response
,
null
);
assertThat
(
tags
).
containsExactlyInAnyOrder
(
assertThat
(
tags
).
containsExactlyInAnyOrder
(
Tag
.
of
(
"method"
,
"GET"
),
Tag
.
of
(
"
method"
,
"GET"
),
Tag
.
of
(
"
uri"
,
"/projects/spring-boot"
),
Tag
.
of
(
"uri"
,
"/projects/spring-boot"
),
Tag
.
of
(
"clientName"
,
"example.org"
),
Tag
.
of
(
"status"
,
"200"
));
Tag
.
of
(
"clientName"
,
"example.org"
),
Tag
.
of
(
"status"
,
"200"
));
}
}
@Test
@Test
public
void
tagsWhenIoExceptionShouldReturnIoErrorStatus
()
{
public
void
tagsWhenIoExceptionShouldReturnIoErrorStatus
()
{
Iterable
<
Tag
>
tags
=
this
.
tagsProvider
.
tags
(
this
.
request
,
Iterable
<
Tag
>
tags
=
this
.
tagsProvider
.
tags
(
this
.
request
,
null
,
n
ull
,
n
ew
IOException
());
new
IOException
());
assertThat
(
tags
).
containsExactlyInAnyOrder
(
assertThat
(
tags
).
containsExactlyInAnyOrder
(
Tag
.
of
(
"method"
,
"GET"
),
Tag
.
of
(
"
method"
,
"GET"
),
Tag
.
of
(
"uri"
,
"/projects/{project}
"
),
Tag
.
of
(
"
uri"
,
"/projects/{project}"
),
Tag
.
of
(
"clientName"
,
"example.org
"
),
Tag
.
of
(
"
clientName"
,
"example.org"
),
Tag
.
of
(
"
status"
,
"IO_ERROR"
));
Tag
.
of
(
"status"
,
"IO_ERROR"
));
}
}
@Test
@Test
public
void
tagsWhenExceptionShouldReturnClientErrorStatus
()
{
public
void
tagsWhenExceptionShouldReturnClientErrorStatus
()
{
Iterable
<
Tag
>
tags
=
this
.
tagsProvider
.
tags
(
this
.
request
,
Iterable
<
Tag
>
tags
=
this
.
tagsProvider
.
tags
(
this
.
request
,
null
,
n
ull
,
n
ew
IllegalArgumentException
());
new
IllegalArgumentException
());
assertThat
(
tags
).
containsExactlyInAnyOrder
(
assertThat
(
tags
).
containsExactlyInAnyOrder
(
Tag
.
of
(
"method"
,
"GET"
),
Tag
.
of
(
"
method"
,
"GET"
),
Tag
.
of
(
"uri"
,
"/projects/{project}
"
),
Tag
.
of
(
"
uri"
,
"/projects/{project}"
),
Tag
.
of
(
"clientName"
,
"example.org
"
),
Tag
.
of
(
"
clientName"
,
"example.org"
),
Tag
.
of
(
"
status"
,
"CLIENT_ERROR"
));
Tag
.
of
(
"status"
,
"CLIENT_ERROR"
));
}
}
}
}
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientCustomizerTests.java
View file @
7b120c1c
...
@@ -60,4 +60,5 @@ public class MetricsWebClientCustomizerTests {
...
@@ -60,4 +60,5 @@ public class MetricsWebClientCustomizerTests {
this
.
clientBuilder
.
filters
((
filters
)
->
assertThat
(
filters
).
hasSize
(
1
).
first
()
this
.
clientBuilder
.
filters
((
filters
)
->
assertThat
(
filters
).
hasSize
(
1
).
first
()
.
isInstanceOf
(
MetricsWebClientFilterFunction
.
class
));
.
isInstanceOf
(
MetricsWebClientFilterFunction
.
class
));
}
}
}
}
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java
View file @
7b120c1c
...
@@ -40,7 +40,8 @@ import static org.mockito.Mockito.mock;
...
@@ -40,7 +40,8 @@ import static org.mockito.Mockito.mock;
*/
*/
public
class
WebClientExchangeTagsTests
{
public
class
WebClientExchangeTagsTests
{
private
static
final
String
URI_TEMPLATE_ATTRIBUTE
=
WebClient
.
class
.
getName
()
+
".uriTemplate"
;
private
static
final
String
URI_TEMPLATE_ATTRIBUTE
=
WebClient
.
class
.
getName
()
+
".uriTemplate"
;
private
ClientRequest
request
;
private
ClientRequest
request
;
...
@@ -49,8 +50,10 @@ public class WebClientExchangeTagsTests {
...
@@ -49,8 +50,10 @@ public class WebClientExchangeTagsTests {
@Before
@Before
public
void
setup
()
{
public
void
setup
()
{
this
.
request
=
ClientRequest
this
.
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
URI
.
create
(
"http://example.org/projects/spring-boot"
))
.
create
(
HttpMethod
.
GET
,
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"http://example.org/projects/{project}"
)
URI
.
create
(
"http://example.org/projects/spring-boot"
))
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"http://example.org/projects/{project}"
)
.
build
();
.
build
();
this
.
response
=
mock
(
ClientResponse
.
class
);
this
.
response
=
mock
(
ClientResponse
.
class
);
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
...
@@ -71,18 +74,17 @@ public class WebClientExchangeTagsTests {
...
@@ -71,18 +74,17 @@ public class WebClientExchangeTagsTests {
@Test
@Test
public
void
uriWhenRelativeTemplateIsAvailableShouldReturnTemplate
()
{
public
void
uriWhenRelativeTemplateIsAvailableShouldReturnTemplate
()
{
this
.
request
=
ClientRequest
this
.
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
URI
.
create
(
"http://example.org/projects/spring-boot"
))
.
create
(
HttpMethod
.
GET
,
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"/projects/{project}"
)
URI
.
create
(
"http://example.org/projects/spring-boot"
)
)
.
build
();
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"/projects/{project}"
).
build
();
assertThat
(
WebClientExchangeTags
.
uri
(
this
.
request
))
assertThat
(
WebClientExchangeTags
.
uri
(
this
.
request
))
.
isEqualTo
(
Tag
.
of
(
"uri"
,
"/projects/{project}"
));
.
isEqualTo
(
Tag
.
of
(
"uri"
,
"/projects/{project}"
));
}
}
@Test
@Test
public
void
uriWhenTemplateIsMissingShouldReturnPath
()
{
public
void
uriWhenTemplateIsMissingShouldReturnPath
()
{
this
.
request
=
ClientRequest
this
.
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
.
create
(
HttpMethod
.
GET
,
URI
.
create
(
"http://example.org/projects/spring-boot"
))
URI
.
create
(
"http://example.org/projects/spring-boot"
)).
build
();
.
build
();
assertThat
(
WebClientExchangeTags
.
uri
(
this
.
request
))
assertThat
(
WebClientExchangeTags
.
uri
(
this
.
request
))
.
isEqualTo
(
Tag
.
of
(
"uri"
,
"/projects/spring-boot"
));
.
isEqualTo
(
Tag
.
of
(
"uri"
,
"/projects/spring-boot"
));
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseConfiguration.java
View file @
7b120c1c
...
@@ -59,8 +59,7 @@ public class CouchbaseConfiguration {
...
@@ -59,8 +59,7 @@ public class CouchbaseConfiguration {
@Bean
@Bean
@Primary
@Primary
public
Cluster
couchbaseCluster
()
{
public
Cluster
couchbaseCluster
()
{
return
CouchbaseCluster
.
create
(
couchbaseEnvironment
(),
return
CouchbaseCluster
.
create
(
couchbaseEnvironment
(),
determineBootstrapHosts
());
determineBootstrapHosts
());
}
}
/**
/**
...
@@ -75,10 +74,8 @@ public class CouchbaseConfiguration {
...
@@ -75,10 +74,8 @@ public class CouchbaseConfiguration {
@Primary
@Primary
@DependsOn
(
"couchbaseClient"
)
@DependsOn
(
"couchbaseClient"
)
public
ClusterInfo
couchbaseClusterInfo
()
{
public
ClusterInfo
couchbaseClusterInfo
()
{
return
couchbaseCluster
()
return
couchbaseCluster
().
clusterManager
(
this
.
properties
.
getBucket
().
getName
(),
.
clusterManager
(
this
.
properties
.
getBucket
().
getName
(),
this
.
properties
.
getBucket
().
getPassword
()).
info
();
this
.
properties
.
getBucket
().
getPassword
())
.
info
();
}
}
@Bean
@Bean
...
@@ -113,8 +110,8 @@ public class CouchbaseConfiguration {
...
@@ -113,8 +110,8 @@ public class CouchbaseConfiguration {
builder
=
builder
.
viewServiceConfig
(
getViewServiceConfig
(
endpoints
));
builder
=
builder
.
viewServiceConfig
(
getViewServiceConfig
(
endpoints
));
}
}
if
(
timeouts
.
getSocketConnect
()
!=
null
)
{
if
(
timeouts
.
getSocketConnect
()
!=
null
)
{
builder
=
builder
.
socketConnectTimeout
(
builder
=
builder
(
int
)
timeouts
.
getSocketConnect
().
toMillis
());
.
socketConnectTimeout
(
(
int
)
timeouts
.
getSocketConnect
().
toMillis
());
}
}
if
(
timeouts
.
getView
()
!=
null
)
{
if
(
timeouts
.
getView
()
!=
null
)
{
builder
=
builder
.
viewTimeout
(
timeouts
.
getView
().
toMillis
());
builder
=
builder
.
viewTimeout
(
timeouts
.
getView
().
toMillis
());
...
@@ -147,8 +144,7 @@ public class CouchbaseConfiguration {
...
@@ -147,8 +144,7 @@ public class CouchbaseConfiguration {
private
<
T
>
T
getServiceConfig
(
CouchbaseService
service
,
Integer
fallback
,
private
<
T
>
T
getServiceConfig
(
CouchbaseService
service
,
Integer
fallback
,
BiFunction
<
Integer
,
Integer
,
T
>
factory
)
{
BiFunction
<
Integer
,
Integer
,
T
>
factory
)
{
if
(
service
.
getMinEndpoints
()
!=
1
||
service
.
getMaxEndpoints
()
!=
1
)
{
if
(
service
.
getMinEndpoints
()
!=
1
||
service
.
getMaxEndpoints
()
!=
1
)
{
return
factory
.
apply
(
service
.
getMinEndpoints
(),
return
factory
.
apply
(
service
.
getMinEndpoints
(),
service
.
getMaxEndpoints
());
service
.
getMaxEndpoints
());
}
}
int
endpoints
=
(
fallback
!=
null
?
fallback
:
1
);
int
endpoints
=
(
fallback
!=
null
?
fallback
:
1
);
return
factory
.
apply
(
endpoints
,
endpoints
);
return
factory
.
apply
(
endpoints
,
endpoints
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java
View file @
7b120c1c
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java
View file @
7b120c1c
...
@@ -578,6 +578,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
...
@@ -578,6 +578,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
}
return
String
.
format
(
"-D%s=\"%s\""
,
key
,
value
);
return
String
.
format
(
"-D%s=\"%s\""
,
key
,
value
);
}
}
}
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java
View file @
7b120c1c
...
@@ -67,8 +67,7 @@ public class RunMojo extends AbstractRunMojo {
...
@@ -67,8 +67,7 @@ public class RunMojo extends AbstractRunMojo {
@Override
@Override
protected
void
runWithForkedJvm
(
File
workingDirectory
,
List
<
String
>
args
,
protected
void
runWithForkedJvm
(
File
workingDirectory
,
List
<
String
>
args
,
Map
<
String
,
String
>
environmentVariables
)
Map
<
String
,
String
>
environmentVariables
)
throws
MojoExecutionException
{
throws
MojoExecutionException
{
try
{
try
{
RunProcess
runProcess
=
new
RunProcess
(
workingDirectory
,
RunProcess
runProcess
=
new
RunProcess
(
workingDirectory
,
new
JavaExecutable
().
toString
());
new
JavaExecutable
().
toString
());
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java
View file @
7b120c1c
...
@@ -103,8 +103,7 @@ public class StartMojo extends AbstractRunMojo {
...
@@ -103,8 +103,7 @@ public class StartMojo extends AbstractRunMojo {
}
}
private
RunProcess
runProcess
(
File
workingDirectory
,
List
<
String
>
args
,
private
RunProcess
runProcess
(
File
workingDirectory
,
List
<
String
>
args
,
Map
<
String
,
String
>
environmentVariables
)
Map
<
String
,
String
>
environmentVariables
)
throws
MojoExecutionException
{
throws
MojoExecutionException
{
try
{
try
{
RunProcess
runProcess
=
new
RunProcess
(
workingDirectory
,
RunProcess
runProcess
=
new
RunProcess
(
workingDirectory
,
new
JavaExecutable
().
toString
());
new
JavaExecutable
().
toString
());
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/EnvVariablesTests.java
View file @
7b120c1c
...
@@ -39,8 +39,8 @@ public class EnvVariablesTests {
...
@@ -39,8 +39,8 @@ public class EnvVariablesTests {
@Test
@Test
public
void
asArray
()
{
public
void
asArray
()
{
assertThat
(
new
EnvVariables
(
getTestArgs
()).
asArray
())
assertThat
(
new
EnvVariables
(
getTestArgs
()).
asArray
())
.
contains
(
"key=My Value"
,
.
contains
(
"key=My Value"
,
"key1= tt "
,
"key2= "
,
"key3="
);
"key1= tt "
,
"key2= "
,
"key3="
);
}
}
@Test
@Test
...
...
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