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
e578d307
Commit
e578d307
authored
Dec 10, 2018
by
igor-suhorukov
Committed by
Stephane Nicoll
Dec 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace anonymous inner class with lambda
See gh-15438
parent
3a7406fe
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
75 additions
and
232 deletions
+75
-232
PrometheusScrapeEndpointDocumentationTests.java
...mentation/PrometheusScrapeEndpointDocumentationTests.java
+1
-9
MissingRequiredConfigurationFailureAnalyzerTests.java
...ics/MissingRequiredConfigurationFailureAnalyzerTests.java
+1
-9
AtlasMetricsExportAutoConfigurationTests.java
...xport/atlas/AtlasMetricsExportAutoConfigurationTests.java
+1
-8
DatadogMetricsExportAutoConfigurationTests.java
...t/datadog/DatadogMetricsExportAutoConfigurationTests.java
+4
-9
GangliaMetricsExportAutoConfigurationTests.java
...t/ganglia/GangliaMetricsExportAutoConfigurationTests.java
+1
-8
GraphiteMetricsExportAutoConfigurationTests.java
...graphite/GraphiteMetricsExportAutoConfigurationTests.java
+4
-9
HumioMetricsExportAutoConfigurationTests.java
...xport/humio/HumioMetricsExportAutoConfigurationTests.java
+1
-8
InfluxMetricsExportAutoConfigurationTests.java
...ort/influx/InfluxMetricsExportAutoConfigurationTests.java
+1
-8
NewRelicMetricsExportAutoConfigurationTests.java
...newrelic/NewRelicMetricsExportAutoConfigurationTests.java
+7
-12
PrometheusMetricsExportAutoConfigurationTests.java
...etheus/PrometheusMetricsExportAutoConfigurationTests.java
+1
-8
SignalFxMetricsExportAutoConfigurationTests.java
...signalfx/SignalFxMetricsExportAutoConfigurationTests.java
+4
-9
SimpleMetricsExportAutoConfigurationTests.java
...ort/simple/SimpleMetricsExportAutoConfigurationTests.java
+1
-8
WebFluxEndpointIntegrationTests.java
...ndpoint/web/reactive/WebFluxEndpointIntegrationTests.java
+5
-17
HttpTraceWebFilterTests.java
.../actuate/trace/http/reactive/HttpTraceWebFilterTests.java
+11
-42
ReactiveUserDetailsServiceAutoConfigurationTests.java
...ive/ReactiveUserDetailsServiceAutoConfigurationTests.java
+1
-8
ServerPropertiesTests.java
...amework/boot/autoconfigure/web/ServerPropertiesTests.java
+4
-12
SpringApplicationTests.java
...java/org/springframework/boot/SpringApplicationTests.java
+12
-20
JettyServletWebServerFactoryTests.java
...web/embedded/jetty/JettyServletWebServerFactoryTests.java
+11
-16
ServletWebServerApplicationContextTests.java
...vlet/context/ServletWebServerApplicationContextTests.java
+4
-12
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/PrometheusScrapeEndpointDocumentationTests.java
View file @
e578d307
...
...
@@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentatio
import
io.micrometer.core.instrument.Clock
;
import
io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics
;
import
io.micrometer.prometheus.PrometheusConfig
;
import
io.micrometer.prometheus.PrometheusMeterRegistry
;
import
io.prometheus.client.CollectorRegistry
;
import
org.junit.Test
;
...
...
@@ -54,14 +53,7 @@ public class PrometheusScrapeEndpointDocumentationTests
public
PrometheusScrapeEndpoint
endpoint
()
{
CollectorRegistry
collectorRegistry
=
new
CollectorRegistry
(
true
);
PrometheusMeterRegistry
meterRegistry
=
new
PrometheusMeterRegistry
(
new
PrometheusConfig
()
{
@Override
public
String
get
(
String
key
)
{
return
null
;
}
},
collectorRegistry
,
Clock
.
SYSTEM
);
(
key
)
->
null
,
collectorRegistry
,
Clock
.
SYSTEM
);
new
JvmMemoryMetrics
().
bindTo
(
meterRegistry
);
return
new
PrometheusScrapeEndpoint
(
collectorRegistry
);
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MissingRequiredConfigurationFailureAnalyzerTests.java
View file @
e578d307
...
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
;
import
io.micrometer.core.instrument.Clock
;
import
io.micrometer.newrelic.NewRelicConfig
;
import
io.micrometer.newrelic.NewRelicMeterRegistry
;
import
org.junit.Test
;
...
...
@@ -64,14 +63,7 @@ public class MissingRequiredConfigurationFailureAnalyzerTests {
@Bean
public
NewRelicMeterRegistry
meterRegistry
()
{
return
new
NewRelicMeterRegistry
(
new
NewRelicConfig
()
{
@Override
public
String
get
(
String
key
)
{
return
null
;
}
},
Clock
.
SYSTEM
);
return
new
NewRelicMeterRegistry
((
key
)
->
null
,
Clock
.
SYSTEM
);
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasMetricsExportAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -107,14 +107,7 @@ public class AtlasMetricsExportAutoConfigurationTests {
@Bean
public
AtlasConfig
customConfig
()
{
return
new
AtlasConfig
()
{
@Override
public
String
get
(
String
k
)
{
return
null
;
}
};
return
(
k
)
->
null
;
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogMetricsExportAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -116,16 +116,11 @@ public class DatadogMetricsExportAutoConfigurationTests {
@Bean
public
DatadogConfig
customConfig
()
{
return
new
DatadogConfig
()
{
@Override
public
String
get
(
String
k
)
{
if
(
"datadog.apiKey"
.
equals
(
k
))
{
return
"12345"
;
}
return
null
;
return
(
k
)
->
{
if
(
"datadog.apiKey"
.
equals
(
k
))
{
return
"12345"
;
}
return
null
;
};
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaMetricsExportAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -107,14 +107,7 @@ public class GangliaMetricsExportAutoConfigurationTests {
@Bean
public
GangliaConfig
customConfig
()
{
return
new
GangliaConfig
()
{
@Override
public
String
get
(
String
k
)
{
return
null
;
}
};
return
(
k
)
->
null
;
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/graphite/GraphiteMetricsExportAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -124,16 +124,11 @@ public class GraphiteMetricsExportAutoConfigurationTests {
@Bean
public
GraphiteConfig
customConfig
()
{
return
new
GraphiteConfig
()
{
@Override
public
String
get
(
String
k
)
{
if
(
"Graphite.apiKey"
.
equals
(
k
))
{
return
"12345"
;
}
return
null
;
return
(
k
)
->
{
if
(
"Graphite.apiKey"
.
equals
(
k
))
{
return
"12345"
;
}
return
null
;
};
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/humio/HumioMetricsExportAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -109,14 +109,7 @@ public class HumioMetricsExportAutoConfigurationTests {
@Bean
public
HumioConfig
customConfig
()
{
return
new
HumioConfig
()
{
@Override
public
String
get
(
String
k
)
{
return
null
;
}
};
return
(
k
)
->
null
;
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxMetricsExportAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -107,14 +107,7 @@ public class InfluxMetricsExportAutoConfigurationTests {
@Bean
public
InfluxConfig
customConfig
()
{
return
new
InfluxConfig
()
{
@Override
public
String
get
(
String
k
)
{
return
null
;
}
};
return
(
k
)
->
null
;
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -129,19 +129,14 @@ public class NewRelicMetricsExportAutoConfigurationTests {
@Bean
public
NewRelicConfig
customConfig
()
{
return
new
NewRelicConfig
()
{
@Override
public
String
get
(
String
k
)
{
if
(
"newrelic.accountId"
.
equals
(
k
))
{
return
"abcde"
;
}
if
(
"newrelic.apiKey"
.
equals
(
k
))
{
return
"12345"
;
}
return
null
;
return
(
k
)
->
{
if
(
"newrelic.accountId"
.
equals
(
k
))
{
return
"abcde"
;
}
if
(
"newrelic.apiKey"
.
equals
(
k
))
{
return
"12345"
;
}
return
null
;
};
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -157,14 +157,7 @@ public class PrometheusMetricsExportAutoConfigurationTests {
@Bean
public
PrometheusConfig
customConfig
()
{
return
new
PrometheusConfig
()
{
@Override
public
String
get
(
String
k
)
{
return
null
;
}
};
return
(
k
)
->
null
;
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxMetricsExportAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -124,16 +124,11 @@ public class SignalFxMetricsExportAutoConfigurationTests {
@Bean
public
SignalFxConfig
customConfig
()
{
return
new
SignalFxConfig
()
{
@Override
public
String
get
(
String
k
)
{
if
(
"signalfx.accessToken"
.
equals
(
k
))
{
return
"abcde"
;
}
return
null
;
return
(
k
)
->
{
if
(
"signalfx.accessToken"
.
equals
(
k
))
{
return
"abcde"
;
}
return
null
;
};
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -90,14 +90,7 @@ public class SimpleMetricsExportAutoConfigurationTests {
@Bean
public
SimpleConfig
customConfig
()
{
return
new
SimpleConfig
()
{
@Override
public
String
get
(
String
k
)
{
return
null
;
}
};
return
(
k
)
->
null
;
}
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointIntegrationTests.java
View file @
e578d307
...
...
@@ -19,7 +19,6 @@ package org.springframework.boot.actuate.endpoint.web.reactive;
import
java.util.Arrays
;
import
org.junit.Test
;
import
reactor.core.publisher.Mono
;
import
org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver
;
import
org.springframework.boot.actuate.endpoint.web.EndpointMapping
;
...
...
@@ -44,9 +43,7 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
import
org.springframework.security.core.context.ReactiveSecurityContextHolder
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.reactive.config.EnableWebFlux
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.WebFilter
;
import
org.springframework.web.server.WebFilterChain
;
import
org.springframework.web.server.adapter.WebHttpHandlerBuilder
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -148,20 +145,11 @@ public class WebFluxEndpointIntegrationTests extends
@Bean
public
WebFilter
webFilter
()
{
return
new
WebFilter
()
{
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
WebFilterChain
chain
)
{
return
chain
.
filter
(
exchange
).
subscriberContext
(
ReactiveSecurityContextHolder
.
withAuthentication
(
new
UsernamePasswordAuthenticationToken
(
"Alice"
,
"secret"
,
Arrays
.
asList
(
new
SimpleGrantedAuthority
(
"ROLE_ACTUATOR"
)))));
}
};
return
(
exchange
,
chain
)
->
chain
.
filter
(
exchange
)
.
subscriberContext
(
ReactiveSecurityContextHolder
.
withAuthentication
(
new
UsernamePasswordAuthenticationToken
(
"Alice"
,
"secret"
,
Arrays
.
asList
(
new
SimpleGrantedAuthority
(
"ROLE_ACTUATOR"
)))));
}
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/http/reactive/HttpTraceWebFilterTests.java
View file @
e578d307
...
...
@@ -33,9 +33,7 @@ import org.springframework.boot.actuate.trace.http.Include;
import
org.springframework.boot.actuate.web.trace.reactive.HttpTraceWebFilter
;
import
org.springframework.mock.http.server.reactive.MockServerHttpRequest
;
import
org.springframework.mock.web.server.MockServerWebExchange
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.ServerWebExchangeDecorator
;
import
org.springframework.web.server.WebFilterChain
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
junit
.
Assert
.
fail
;
...
...
@@ -62,14 +60,7 @@ public class HttpTraceWebFilterTests {
this
.
filter
.
filter
(
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"https://api.example.com"
)),
new
WebFilterChain
()
{
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
return
Mono
.
empty
();
}
}).
block
(
Duration
.
ofSeconds
(
30
));
(
exchange
)
->
Mono
.
empty
()).
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
}
...
...
@@ -79,15 +70,10 @@ public class HttpTraceWebFilterTests {
this
.
filter
.
filter
(
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"https://api.example.com"
)),
new
WebFilterChain
()
{
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
exchange
.
getSession
().
block
(
Duration
.
ofSeconds
(
30
))
(
exchange
)
->
{
exchange
.
getSession
().
block
(
Duration
.
ofSeconds
(
30
))
.
getAttributes
().
put
(
"a"
,
"alpha"
);
return
Mono
.
empty
();
}
return
Mono
.
empty
();
}).
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
Session
session
=
this
.
repository
.
findAll
().
get
(
0
).
getSession
();
...
...
@@ -101,14 +87,9 @@ public class HttpTraceWebFilterTests {
this
.
filter
.
filter
(
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"https://api.example.com"
)),
new
WebFilterChain
()
{
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
exchange
.
getSession
().
block
(
Duration
.
ofSeconds
(
30
));
return
Mono
.
empty
();
}
(
exchange
)
->
{
exchange
.
getSession
().
block
(
Duration
.
ofSeconds
(
30
));
return
Mono
.
empty
();
}).
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
Session
session
=
this
.
repository
.
findAll
().
get
(
0
).
getSession
();
...
...
@@ -127,15 +108,10 @@ public class HttpTraceWebFilterTests {
return
Mono
.
just
(
principal
);
}
},
new
WebFilterChain
()
{
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
exchange
.
getSession
().
block
(
Duration
.
ofSeconds
(
30
)).
getAttributes
()
},
(
exchange
)
->
{
exchange
.
getSession
().
block
(
Duration
.
ofSeconds
(
30
)).
getAttributes
()
.
put
(
"a"
,
"alpha"
);
return
Mono
.
empty
();
}
return
Mono
.
empty
();
}).
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
org
.
springframework
.
boot
.
actuate
.
trace
.
http
.
HttpTrace
.
Principal
tracedPrincipal
=
this
.
repository
...
...
@@ -151,14 +127,7 @@ public class HttpTraceWebFilterTests {
this
.
filter
.
filter
(
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"https://api.example.com"
)),
new
WebFilterChain
()
{
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
return
Mono
.
error
(
new
RuntimeException
());
}
}).
block
(
Duration
.
ofSeconds
(
30
));
(
exchange
)
->
Mono
.
error
(
new
RuntimeException
())).
block
(
Duration
.
ofSeconds
(
30
));
fail
();
}
catch
(
Exception
ex
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveUserDetailsServiceAutoConfigurationTests.java
View file @
e578d307
...
...
@@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.security.reactive;
import
java.time.Duration
;
import
org.junit.Test
;
import
reactor.core.publisher.Mono
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.autoconfigure.security.SecurityProperties
;
...
...
@@ -30,7 +29,6 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.context.annotation.Import
;
import
org.springframework.security.authentication.ReactiveAuthenticationManager
;
import
org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.userdetails.MapReactiveUserDetailsService
;
import
org.springframework.security.core.userdetails.ReactiveUserDetailsService
;
import
org.springframework.security.core.userdetails.User
;
...
...
@@ -156,12 +154,7 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
@Bean
public
ReactiveAuthenticationManager
reactiveAuthenticationManager
()
{
return
new
ReactiveAuthenticationManager
()
{
@Override
public
Mono
<
Authentication
>
authenticate
(
Authentication
authentication
)
{
return
null
;
}
};
return
(
authentication
)
->
null
;
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
View file @
e578d307
...
...
@@ -26,7 +26,6 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.concurrent.atomic.AtomicReference
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -270,13 +269,9 @@ public class ServerPropertiesTests {
@Test
public
void
jettyMaxHttpPostSizeMatchesDefault
()
throws
Exception
{
JettyServletWebServerFactory
jettyFactory
=
new
JettyServletWebServerFactory
(
0
);
JettyWebServer
jetty
=
(
JettyWebServer
)
jettyFactory
.
getWebServer
(
new
ServletContextInitializer
()
{
@Override
public
void
onStartup
(
ServletContext
servletContext
)
throws
ServletException
{
servletContext
.
addServlet
(
"formPost"
,
new
HttpServlet
()
{
JettyWebServer
jetty
=
(
JettyWebServer
)
jettyFactory
.
getWebServer
(
(
ServletContextInitializer
)
(
servletContext
)
->
servletContext
.
addServlet
(
"formPost"
,
new
HttpServlet
()
{
@Override
protected
void
doPost
(
HttpServletRequest
req
,
...
...
@@ -285,10 +280,7 @@ public class ServerPropertiesTests {
req
.
getParameterMap
();
}
}).
addMapping
(
"/form"
);
}
});
}).
addMapping
(
"/form"
));
jetty
.
start
();
org
.
eclipse
.
jetty
.
server
.
Connector
connector
=
jetty
.
getServer
()
.
getConnectors
()[
0
];
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java
View file @
e578d307
...
...
@@ -669,26 +669,18 @@ public class SpringApplicationTests {
CommandLineRunner
commandLineRunner
=
mock
(
CommandLineRunner
.
class
);
application
.
addInitializers
((
context
)
->
{
ConfigurableListableBeanFactory
beanFactory
=
context
.
getBeanFactory
();
beanFactory
.
registerSingleton
(
"commandLineRunner"
,
new
CommandLineRunner
()
{
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
assertThat
(
SpringApplicationTests
.
this
.
output
.
toString
())
.
contains
(
"Started"
);
commandLineRunner
.
run
(
args
);
}
});
beanFactory
.
registerSingleton
(
"applicationRunner"
,
new
ApplicationRunner
()
{
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
assertThat
(
SpringApplicationTests
.
this
.
output
.
toString
())
.
contains
(
"Started"
);
applicationRunner
.
run
(
args
);
}
});
beanFactory
.
registerSingleton
(
"commandLineRunner"
,
(
CommandLineRunner
)
(
args
)
->
{
assertThat
(
SpringApplicationTests
.
this
.
output
.
toString
())
.
contains
(
"Started"
);
commandLineRunner
.
run
(
args
);
});
beanFactory
.
registerSingleton
(
"applicationRunner"
,
(
ApplicationRunner
)
(
args
)
->
{
assertThat
(
SpringApplicationTests
.
this
.
output
.
toString
())
.
contains
(
"Started"
);
applicationRunner
.
run
(
args
);
});
});
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
ApplicationListener
<
ApplicationReadyEvent
>
eventListener
=
mock
(
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactoryTests.java
View file @
e578d307
...
...
@@ -301,25 +301,20 @@ public class JettyServletWebServerFactoryTests
@Test
public
void
faultyListenerCausesStartFailure
()
throws
Exception
{
JettyServletWebServerFactory
factory
=
getFactory
();
factory
.
addServerCustomizers
(
new
JettyServerCustomizer
()
{
factory
.
addServerCustomizers
((
JettyServerCustomizer
)
(
server
)
->
{
Collection
<
WebAppContext
>
contexts
=
server
.
getBeans
(
WebAppContext
.
class
);
contexts
.
iterator
().
next
().
addEventListener
(
new
ServletContextListener
()
{
@Override
public
void
customize
(
Server
server
)
{
Collection
<
WebAppContext
>
contexts
=
server
.
getBeans
(
WebAppContext
.
class
);
contexts
.
iterator
().
next
().
addEventListener
(
new
ServletContextListener
()
{
@Override
public
void
contextInitialized
(
ServletContextEvent
sce
)
{
throw
new
RuntimeException
(
);
}
@Override
public
void
contextInitialized
(
ServletContextEvent
sce
)
{
throw
new
RuntimeException
();
}
@Override
public
void
contextDestroyed
(
ServletContextEvent
sce
)
{
}
});
}
@Override
public
void
contextDestroyed
(
ServletContextEvent
sce
)
{
}
});
});
assertThatExceptionOfType
(
WebServerException
.
class
).
isThrownBy
(()
->
{
JettyWebServer
jettyWebServer
=
(
JettyWebServer
)
factory
.
getWebServer
();
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java
View file @
e578d307
...
...
@@ -38,11 +38,9 @@ import org.mockito.Captor;
import
org.mockito.InOrder
;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.MutablePropertyValues
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.BeanFactoryPostProcessor
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.config.ConstructorArgumentValues
;
import
org.springframework.beans.factory.config.Scope
;
...
...
@@ -475,16 +473,10 @@ public class ServletWebServerApplicationContextTests {
beanDefinition
.
setAutowireMode
(
AbstractBeanDefinition
.
AUTOWIRE_CONSTRUCTOR
);
this
.
context
.
registerBeanDefinition
(
"withAutowiredServletRequest"
,
beanDefinition
);
this
.
context
.
addBeanFactoryPostProcessor
(
new
BeanFactoryPostProcessor
()
{
@Override
public
void
postProcessBeanFactory
(
ConfigurableListableBeanFactory
beanFactory
)
throws
BeansException
{
WithAutowiredServletRequest
bean
=
beanFactory
.
getBean
(
WithAutowiredServletRequest
.
class
);
assertThat
(
bean
.
getRequest
()).
isNotNull
();
}
this
.
context
.
addBeanFactoryPostProcessor
((
beanFactory
)
->
{
WithAutowiredServletRequest
bean
=
beanFactory
.
getBean
(
WithAutowiredServletRequest
.
class
);
assertThat
(
bean
.
getRequest
()).
isNotNull
();
});
this
.
context
.
refresh
();
String
output
=
this
.
output
.
toString
().
substring
(
initialOutputLength
);
...
...
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