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
1a0d53de
Commit
1a0d53de
authored
Oct 15, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace ReflectionTestUtils usage by hasFieldOrPropertyWithValue
Closes gh-14696
parent
cfa130b2
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
59 additions
and
83 deletions
+59
-83
ReactiveTokenValidatorTests.java
...re/cloudfoundry/reactive/ReactiveTokenValidatorTests.java
+8
-12
ServletEndpointManagementContextConfigurationTests.java
...b/ServletEndpointManagementContextConfigurationTests.java
+2
-5
RabbitAutoConfigurationTests.java
...boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
+2
-2
FreeMarkerAutoConfigurationServletIntegrationTests.java
...r/FreeMarkerAutoConfigurationServletIntegrationTests.java
+2
-3
ActiveMQAutoConfigurationTests.java
...onfigure/jms/activemq/ActiveMQAutoConfigurationTests.java
+8
-9
ArtemisAutoConfigurationTests.java
...oconfigure/jms/artemis/ArtemisAutoConfigurationTests.java
+8
-9
JmxAutoConfigurationTests.java
...ork/boot/autoconfigure/jmx/JmxAutoConfigurationTests.java
+3
-4
LdapAutoConfigurationTests.java
...k/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java
+8
-8
SessionAutoConfigurationTests.java
.../autoconfigure/session/SessionAutoConfigurationTests.java
+2
-3
RestartApplicationListenerTests.java
...oot/devtools/restart/RestartApplicationListenerTests.java
+4
-7
SpringBootTestWebEnvironmentMockTests.java
...t/test/context/SpringBootTestWebEnvironmentMockTests.java
+3
-4
SpringBootTestWebEnvironmentMockWithWebAppConfigurationTests.java
...otTestWebEnvironmentMockWithWebAppConfigurationTests.java
+3
-4
TestRestTemplateTests.java
...framework/boot/test/web/client/TestRestTemplateTests.java
+2
-4
HttpWebServiceMessageSenderBuilderSimpleIntegrationTests.java
...WebServiceMessageSenderBuilderSimpleIntegrationTests.java
+2
-5
HttpWebServiceMessageSenderBuilderTests.java
...vices/client/HttpWebServiceMessageSenderBuilderTests.java
+2
-4
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidatorTests.java
View file @
1a0d53de
...
...
@@ -111,9 +111,8 @@ public class ReactiveTokenValidatorTests {
assertThat
(((
CloudFoundryAuthorizationException
)
ex
).
getReason
())
.
isEqualTo
(
Reason
.
INVALID_KEY_ID
);
}).
verify
();
Object
cachedTokenKeys
=
ReflectionTestUtils
.
getField
(
this
.
tokenValidator
,
"cachedTokenKeys"
);
assertThat
(
cachedTokenKeys
).
isEqualTo
(
VALID_KEYS
);
assertThat
(
this
.
tokenValidator
).
hasFieldOrPropertyWithValue
(
"cachedTokenKeys"
,
VALID_KEYS
);
fetchTokenKeys
.
assertWasSubscribed
();
}
...
...
@@ -133,9 +132,8 @@ public class ReactiveTokenValidatorTests {
.
create
(
this
.
tokenValidator
.
validate
(
new
Token
(
getSignedToken
(
header
.
getBytes
(),
claims
.
getBytes
()))))
.
verifyComplete
();
Object
cachedTokenKeys
=
ReflectionTestUtils
.
getField
(
this
.
tokenValidator
,
"cachedTokenKeys"
);
assertThat
(
cachedTokenKeys
).
isEqualTo
(
VALID_KEYS
);
assertThat
(
this
.
tokenValidator
).
hasFieldOrPropertyWithValue
(
"cachedTokenKeys"
,
VALID_KEYS
);
fetchTokenKeys
.
assertWasSubscribed
();
}
...
...
@@ -152,9 +150,8 @@ public class ReactiveTokenValidatorTests {
.
create
(
this
.
tokenValidator
.
validate
(
new
Token
(
getSignedToken
(
header
.
getBytes
(),
claims
.
getBytes
()))))
.
verifyComplete
();
Object
cachedTokenKeys
=
ReflectionTestUtils
.
getField
(
this
.
tokenValidator
,
"cachedTokenKeys"
);
assertThat
(
cachedTokenKeys
).
isEqualTo
(
VALID_KEYS
);
assertThat
(
this
.
tokenValidator
).
hasFieldOrPropertyWithValue
(
"cachedTokenKeys"
,
VALID_KEYS
);
fetchTokenKeys
.
assertWasSubscribed
();
}
...
...
@@ -177,9 +174,8 @@ public class ReactiveTokenValidatorTests {
assertThat
(((
CloudFoundryAuthorizationException
)
ex
).
getReason
())
.
isEqualTo
(
Reason
.
INVALID_KEY_ID
);
}).
verify
();
Object
cachedTokenKeys
=
ReflectionTestUtils
.
getField
(
this
.
tokenValidator
,
"cachedTokenKeys"
);
assertThat
(
cachedTokenKeys
).
isEqualTo
(
VALID_KEYS
);
assertThat
(
this
.
tokenValidator
).
hasFieldOrPropertyWithValue
(
"cachedTokenKeys"
,
VALID_KEYS
);
fetchTokenKeys
.
assertWasSubscribed
();
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfigurationTests.java
View file @
1a0d53de
...
...
@@ -31,7 +31,6 @@ import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.web.servlet.DispatcherServlet
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -54,8 +53,7 @@ public class ServletEndpointManagementContextConfigurationTests {
assertThat
(
context
).
hasSingleBean
(
ServletEndpointRegistrar
.
class
);
ServletEndpointRegistrar
bean
=
context
.
getBean
(
ServletEndpointRegistrar
.
class
);
String
basePath
=
(
String
)
ReflectionTestUtils
.
getField
(
bean
,
"basePath"
);
assertThat
(
basePath
).
isEqualTo
(
"/test/actuator"
);
assertThat
(
bean
).
hasFieldOrPropertyWithValue
(
"basePath"
,
"/test/actuator"
);
});
}
...
...
@@ -67,8 +65,7 @@ public class ServletEndpointManagementContextConfigurationTests {
assertThat
(
context
).
hasSingleBean
(
ServletEndpointRegistrar
.
class
);
ServletEndpointRegistrar
bean
=
context
.
getBean
(
ServletEndpointRegistrar
.
class
);
String
basePath
=
(
String
)
ReflectionTestUtils
.
getField
(
bean
,
"basePath"
);
assertThat
(
basePath
).
isEqualTo
(
"/actuator"
);
assertThat
(
bean
).
hasFieldOrPropertyWithValue
(
"basePath"
,
"/actuator"
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
View file @
1a0d53de
...
...
@@ -326,8 +326,8 @@ public class RabbitAutoConfigurationTests {
.
withPropertyValues
(
"spring.rabbitmq.template.queue:default-queue"
)
.
run
((
context
)
->
{
RabbitTemplate
rabbitTemplate
=
context
.
getBean
(
RabbitTemplate
.
class
);
assertThat
(
ReflectionTestUtils
.
getField
(
rabbitTemplate
,
"queue"
))
.
isEqualTo
(
"default-queue"
);
assertThat
(
rabbitTemplate
).
hasFieldOrPropertyWithValue
(
"queue"
,
"default-queue"
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java
View file @
1a0d53de
...
...
@@ -32,7 +32,6 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.mock.web.MockHttpServletResponse
;
import
org.springframework.mock.web.MockServletContext
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.servlet.View
;
import
org.springframework.web.servlet.resource.ResourceUrlEncodingFilter
;
...
...
@@ -131,8 +130,8 @@ public class FreeMarkerAutoConfigurationServletIntegrationTests {
registerAndRefreshContext
(
"spring.freemarker.allow-session-override:true"
);
AbstractTemplateViewResolver
viewResolver
=
this
.
context
.
getBean
(
FreeMarkerViewResolver
.
class
);
assertThat
(
ReflectionTestUtils
.
getField
(
viewResolver
,
"allowSessionOverride"
))
.
isEqualTo
(
true
);
assertThat
(
viewResolver
).
hasFieldOrPropertyWithValue
(
"allowSessionOverride"
,
true
);
}
@SuppressWarnings
(
"deprecation"
)
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfigurationTests.java
View file @
1a0d53de
...
...
@@ -28,7 +28,6 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jms.connection.CachingConnectionFactory
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.util.StringUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -82,10 +81,10 @@ public class ActiveMQAutoConfigurationTests {
.
getBean
(
CachingConnectionFactory
.
class
);
assertThat
(
connectionFactory
.
getTargetConnectionFactory
())
.
isInstanceOf
(
ActiveMQConnectionFactory
.
class
);
assertThat
(
ReflectionTestUtils
.
getField
(
connectionFactory
,
"cacheConsumers"
)).
isEqualTo
(
false
);
assertThat
(
ReflectionTestUtils
.
getField
(
connectionFactory
,
"cacheProducers"
)).
isEqualTo
(
true
);
assertThat
(
connectionFactory
)
.
hasFieldOrPropertyWithValue
(
"cacheConsumers"
,
false
);
assertThat
(
connectionFactory
)
.
hasFieldOrPropertyWithValue
(
"cacheProducers"
,
true
);
assertThat
(
connectionFactory
.
getSessionCacheSize
()).
isEqualTo
(
1
);
});
}
...
...
@@ -101,10 +100,10 @@ public class ActiveMQAutoConfigurationTests {
assertThat
(
context
).
hasSingleBean
(
CachingConnectionFactory
.
class
);
CachingConnectionFactory
connectionFactory
=
context
.
getBean
(
CachingConnectionFactory
.
class
);
assertThat
(
ReflectionTestUtils
.
getField
(
connectionFactory
,
"cacheConsumers"
)).
isEqualTo
(
true
);
assertThat
(
ReflectionTestUtils
.
getField
(
connectionFactory
,
"cacheProducers"
)).
isEqualTo
(
false
);
assertThat
(
connectionFactory
)
.
hasFieldOrPropertyWithValue
(
"cacheConsumers"
,
true
);
assertThat
(
connectionFactory
)
.
hasFieldOrPropertyWithValue
(
"cacheProducers"
,
false
);
assertThat
(
connectionFactory
.
getSessionCacheSize
()).
isEqualTo
(
10
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java
View file @
1a0d53de
...
...
@@ -53,7 +53,6 @@ import org.springframework.jms.core.JmsTemplate;
import
org.springframework.jms.core.SessionCallback
;
import
org.springframework.jms.support.destination.DestinationResolver
;
import
org.springframework.jms.support.destination.DynamicDestinationResolver
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -82,10 +81,10 @@ public class ArtemisAutoConfigurationTests {
.
getBean
(
CachingConnectionFactory
.
class
);
assertThat
(
connectionFactory
.
getTargetConnectionFactory
())
.
isInstanceOf
(
ActiveMQConnectionFactory
.
class
);
assertThat
(
ReflectionTestUtils
.
getField
(
connectionFactory
,
"cacheConsumers"
)).
isEqualTo
(
false
);
assertThat
(
ReflectionTestUtils
.
getField
(
connectionFactory
,
"cacheProducers"
)).
isEqualTo
(
true
);
assertThat
(
connectionFactory
)
.
hasFieldOrPropertyWithValue
(
"cacheConsumers"
,
false
);
assertThat
(
connectionFactory
)
.
hasFieldOrPropertyWithValue
(
"cacheProducers"
,
true
);
assertThat
(
connectionFactory
.
getSessionCacheSize
()).
isEqualTo
(
1
);
});
}
...
...
@@ -101,10 +100,10 @@ public class ArtemisAutoConfigurationTests {
assertThat
(
context
).
hasSingleBean
(
CachingConnectionFactory
.
class
);
CachingConnectionFactory
connectionFactory
=
context
.
getBean
(
CachingConnectionFactory
.
class
);
assertThat
(
ReflectionTestUtils
.
getField
(
connectionFactory
,
"cacheConsumers"
)).
isEqualTo
(
true
);
assertThat
(
ReflectionTestUtils
.
getField
(
connectionFactory
,
"cacheProducers"
)).
isEqualTo
(
false
);
assertThat
(
connectionFactory
)
.
hasFieldOrPropertyWithValue
(
"cacheConsumers"
,
true
);
assertThat
(
connectionFactory
)
.
hasFieldOrPropertyWithValue
(
"cacheProducers"
,
false
);
assertThat
(
connectionFactory
.
getSessionCacheSize
()).
isEqualTo
(
10
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfigurationTests.java
View file @
1a0d53de
...
...
@@ -102,10 +102,9 @@ public class JmxAutoConfigurationTests {
assertThat
(
mBeanExporter
).
isNotNull
();
MetadataNamingStrategy
naming
=
(
MetadataNamingStrategy
)
ReflectionTestUtils
.
getField
(
mBeanExporter
,
"namingStrategy"
);
assertThat
(
ReflectionTestUtils
.
getField
(
naming
,
"defaultDomain"
))
.
isEqualTo
(
"my-test-domain"
);
assertThat
(
ReflectionTestUtils
.
getField
(
naming
,
"ensureUniqueRuntimeObjectNames"
))
.
isEqualTo
(
true
);
assertThat
(
naming
).
hasFieldOrPropertyWithValue
(
"defaultDomain"
,
"my-test-domain"
);
assertThat
(
naming
).
hasFieldOrPropertyWithValue
(
"ensureUniqueRuntimeObjectNames"
,
true
);
}
@Test
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java
View file @
1a0d53de
...
...
@@ -48,8 +48,7 @@ public class LdapAutoConfigurationTests {
public
void
contextSourceWithDefaultUrl
()
{
this
.
contextRunner
.
run
((
context
)
->
{
LdapContextSource
contextSource
=
context
.
getBean
(
LdapContextSource
.
class
);
String
[]
urls
=
(
String
[])
ReflectionTestUtils
.
getField
(
contextSource
,
"urls"
);
String
[]
urls
=
getUrls
(
contextSource
);
assertThat
(
urls
).
containsExactly
(
"ldap://localhost:389"
);
assertThat
(
contextSource
.
isAnonymousReadOnly
()).
isFalse
();
});
...
...
@@ -61,8 +60,7 @@ public class LdapAutoConfigurationTests {
.
run
((
context
)
->
{
ContextSource
contextSource
=
context
.
getBean
(
LdapContextSource
.
class
);
String
[]
urls
=
(
String
[])
ReflectionTestUtils
.
getField
(
contextSource
,
"urls"
);
String
[]
urls
=
getUrls
(
contextSource
);
assertThat
(
urls
).
containsExactly
(
"ldap://localhost:123"
);
});
}
...
...
@@ -76,8 +74,7 @@ public class LdapAutoConfigurationTests {
ContextSource
contextSource
=
context
.
getBean
(
LdapContextSource
.
class
);
LdapProperties
ldapProperties
=
context
.
getBean
(
LdapProperties
.
class
);
String
[]
urls
=
(
String
[])
ReflectionTestUtils
.
getField
(
contextSource
,
"urls"
);
String
[]
urls
=
getUrls
(
contextSource
);
assertThat
(
urls
).
containsExactly
(
"ldap://localhost:123"
,
"ldap://mycompany:123"
);
assertThat
(
ldapProperties
.
getUrls
()).
hasSize
(
2
);
...
...
@@ -117,13 +114,16 @@ public class LdapAutoConfigurationTests {
.
run
((
context
)
->
{
LdapContextSource
contextSource
=
context
.
getBean
(
LdapContextSource
.
class
);
String
[]
urls
=
(
String
[])
ReflectionTestUtils
.
getField
(
contextSource
,
"urls"
);
String
[]
urls
=
getUrls
(
contextSource
);
assertThat
(
urls
).
containsExactly
(
"ldap://localhost:389"
);
assertThat
(
contextSource
.
isAnonymousReadOnly
()).
isFalse
();
});
}
private
String
[]
getUrls
(
ContextSource
contextSource
)
{
return
(
String
[])
ReflectionTestUtils
.
getField
(
contextSource
,
"urls"
);
}
@Configuration
static
class
PooledContextSourceConfig
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java
View file @
1a0d53de
...
...
@@ -180,9 +180,8 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
.
getField
(
filter
,
"httpSessionIdResolver"
);
DefaultCookieSerializer
cookieSerializer
=
(
DefaultCookieSerializer
)
ReflectionTestUtils
.
getField
(
sessionIdResolver
,
"cookieSerializer"
);
String
cookieName
=
(
String
)
ReflectionTestUtils
.
getField
(
cookieSerializer
,
"cookieName"
);
assertThat
(
cookieName
).
isEqualTo
(
"testname"
);
assertThat
(
cookieSerializer
).
hasFieldOrPropertyWithValue
(
"cookieName"
,
"testname"
);
});
}
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java
View file @
1a0d53de
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -63,8 +63,7 @@ public class RestartApplicationListenerTests {
@Test
public
void
initializeWithReady
()
{
testInitialize
(
false
);
assertThat
(
ReflectionTestUtils
.
getField
(
Restarter
.
getInstance
(),
"args"
))
.
isEqualTo
(
ARGS
);
assertThat
(
Restarter
.
getInstance
()).
hasFieldOrPropertyWithValue
(
"args"
,
ARGS
);
assertThat
(
Restarter
.
getInstance
().
isFinished
()).
isTrue
();
assertThat
((
List
<?>)
ReflectionTestUtils
.
getField
(
Restarter
.
getInstance
(),
"rootContexts"
)).
isNotEmpty
();
...
...
@@ -73,8 +72,7 @@ public class RestartApplicationListenerTests {
@Test
public
void
initializeWithFail
()
{
testInitialize
(
true
);
assertThat
(
ReflectionTestUtils
.
getField
(
Restarter
.
getInstance
(),
"args"
))
.
isEqualTo
(
ARGS
);
assertThat
(
Restarter
.
getInstance
()).
hasFieldOrPropertyWithValue
(
"args"
,
ARGS
);
assertThat
(
Restarter
.
getInstance
().
isFinished
()).
isTrue
();
assertThat
((
List
<?>)
ReflectionTestUtils
.
getField
(
Restarter
.
getInstance
(),
"rootContexts"
)).
isEmpty
();
...
...
@@ -84,8 +82,7 @@ public class RestartApplicationListenerTests {
public
void
disableWithSystemProperty
()
{
System
.
setProperty
(
ENABLED_PROPERTY
,
"false"
);
testInitialize
(
false
);
assertThat
(
ReflectionTestUtils
.
getField
(
Restarter
.
getInstance
(),
"enabled"
))
.
isEqualTo
(
false
);
assertThat
(
Restarter
.
getInstance
()).
hasFieldOrPropertyWithValue
(
"enabled"
,
false
);
}
private
void
testInitialize
(
boolean
failed
)
{
...
...
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestWebEnvironmentMockTests.java
View file @
1a0d53de
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -29,7 +29,6 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.context.support.PropertySourcesPlaceholderConfigurer
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.context.request.RequestAttributes
;
import
org.springframework.web.context.request.RequestContextHolder
;
...
...
@@ -78,8 +77,8 @@ public class SpringBootTestWebEnvironmentMockTests {
@Test
public
void
resourcePath
()
{
assertThat
(
ReflectionTestUtils
.
getField
(
this
.
servletContext
,
"resourceBasePath"
))
.
isEqualTo
(
"src/main/webapp"
);
assertThat
(
this
.
servletContext
).
hasFieldOrPropertyWithValue
(
"resourceBasePath"
,
"src/main/webapp"
);
}
@Configuration
...
...
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestWebEnvironmentMockWithWebAppConfigurationTests.java
View file @
1a0d53de
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -29,7 +29,6 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -51,8 +50,8 @@ public class SpringBootTestWebEnvironmentMockWithWebAppConfigurationTests {
@Test
public
void
resourcePath
()
{
assertThat
(
ReflectionTestUtils
.
getField
(
this
.
servletContext
,
"resourceBasePath"
))
.
isEqualTo
(
"src/mymain/mywebapp"
);
assertThat
(
this
.
servletContext
).
hasFieldOrPropertyWithValue
(
"resourceBasePath"
,
"src/mymain/mywebapp"
);
}
@Configuration
...
...
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java
View file @
1a0d53de
...
...
@@ -372,10 +372,8 @@ public class TestRestTemplateTests {
assertThat
(
requestFactoryInterceptors
).
hasSize
(
1
);
ClientHttpRequestInterceptor
interceptor
=
requestFactoryInterceptors
.
get
(
0
);
assertThat
(
interceptor
).
isInstanceOf
(
BasicAuthorizationInterceptor
.
class
);
assertThat
(
ReflectionTestUtils
.
getField
(
interceptor
,
"username"
))
.
isEqualTo
(
username
);
assertThat
(
ReflectionTestUtils
.
getField
(
interceptor
,
"password"
))
.
isEqualTo
(
password
);
assertThat
(
interceptor
).
hasFieldOrPropertyWithValue
(
"username"
,
username
);
assertThat
(
interceptor
).
hasFieldOrPropertyWithValue
(
"password"
,
password
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/HttpWebServiceMessageSenderBuilderSimpleIntegrationTests.java
View file @
1a0d53de
...
...
@@ -25,7 +25,6 @@ import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions
import
org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner
;
import
org.springframework.http.client.ClientHttpRequestFactory
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.ws.transport.WebServiceMessageSender
;
import
org.springframework.ws.transport.http.ClientHttpRequestMessageSender
;
...
...
@@ -56,10 +55,8 @@ public class HttpWebServiceMessageSenderBuilderSimpleIntegrationTests {
.
setReadTimeout
(
Duration
.
ofSeconds
(
2
)).
build
();
SimpleClientHttpRequestFactory
requestFactory
=
assertSimpleClientRequestFactory
(
messageSender
);
assertThat
(
ReflectionTestUtils
.
getField
(
requestFactory
,
"connectTimeout"
))
.
isEqualTo
(
5000
);
assertThat
(
ReflectionTestUtils
.
getField
(
requestFactory
,
"readTimeout"
))
.
isEqualTo
(
2000
);
assertThat
(
requestFactory
).
hasFieldOrPropertyWithValue
(
"connectTimeout"
,
5000
);
assertThat
(
requestFactory
).
hasFieldOrPropertyWithValue
(
"readTimeout"
,
2000
);
}
private
SimpleClientHttpRequestFactory
assertSimpleClientRequestFactory
(
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/HttpWebServiceMessageSenderBuilderTests.java
View file @
1a0d53de
...
...
@@ -56,10 +56,8 @@ public class HttpWebServiceMessageSenderBuilderTests {
.
setReadTimeout
(
Duration
.
ofSeconds
(
2
)));
SimpleClientHttpRequestFactory
requestFactory
=
(
SimpleClientHttpRequestFactory
)
messageSender
.
getRequestFactory
();
assertThat
(
ReflectionTestUtils
.
getField
(
requestFactory
,
"connectTimeout"
))
.
isEqualTo
(
5000
);
assertThat
(
ReflectionTestUtils
.
getField
(
requestFactory
,
"readTimeout"
))
.
isEqualTo
(
2000
);
assertThat
(
requestFactory
).
hasFieldOrPropertyWithValue
(
"connectTimeout"
,
5000
);
assertThat
(
requestFactory
).
hasFieldOrPropertyWithValue
(
"readTimeout"
,
2000
);
}
@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