Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
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
openSource
spring-cloud-netflix
Commits
ce4d560d
Unverified
Commit
ce4d560d
authored
Sep 28, 2017
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix RibbonClientHttpRequestFactoryTests
fixes gh-2314
parent
87e98edd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
17 deletions
+16
-17
RibbonAutoConfiguration.java
...amework/cloud/netflix/ribbon/RibbonAutoConfiguration.java
+2
-7
RibbonClientHttpRequestFactoryTests.java
...d/netflix/ribbon/RibbonClientHttpRequestFactoryTests.java
+14
-10
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.java
View file @
ce4d560d
...
...
@@ -118,7 +118,7 @@ public class RibbonAutoConfiguration {
@Configuration
@ConditionalOnClass
(
HttpRequest
.
class
)
@ConditionalOnRibbonRestClient
protected
static
class
RibbonClient
Config
{
protected
static
class
RibbonClient
HttpRequestFactoryConfiguration
{
@Autowired
private
SpringClientFactory
springClientFactory
;
...
...
@@ -126,12 +126,7 @@ public class RibbonAutoConfiguration {
@Bean
public
RestTemplateCustomizer
restTemplateCustomizer
(
final
RibbonClientHttpRequestFactory
ribbonClientHttpRequestFactory
)
{
return
new
RestTemplateCustomizer
()
{
@Override
public
void
customize
(
RestTemplate
restTemplate
)
{
restTemplate
.
setRequestFactory
(
ribbonClientHttpRequestFactory
);
}
};
return
restTemplate
->
restTemplate
.
setRequestFactory
(
ribbonClientHttpRequestFactory
);
}
@Bean
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonClientHttpRequestFactoryTests.java
View file @
ce4d560d
...
...
@@ -16,12 +16,9 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.lang.reflect.Field
;
import
java.net.URI
;
import
org.junit.Ignore
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
...
...
@@ -30,16 +27,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest.WebEnvironment
;
import
org.springframework.cloud.client.loadbalancer.LoadBalanced
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.RequestEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper
;
import
org.springframework.http.client.ClientHttpRequestFactory
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
...
...
@@ -53,13 +51,17 @@ import org.springframework.web.client.RestTemplate;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.ServerList
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
springframework
.
boot
.
test
.
context
.
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
;
/**
* @author Spencer Gibb
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
RibbonClientHttpRequestFactoryTests
.
App
.
class
,
webEnvironment
=
WebEnvironment
.
RANDOM_PORT
,
value
=
{
@SpringBootTest
(
classes
=
RibbonClientHttpRequestFactoryTests
.
App
.
class
,
webEnvironment
=
RANDOM_PORT
,
value
=
{
"spring.application.name=ribbonclienttest"
,
"spring.jmx.enabled=true"
,
"spring.cloud.netflix.metrics.enabled=false"
,
"ribbon.
http.client.enabled
=true"
})
"spring.cloud.netflix.metrics.enabled=false"
,
"ribbon.
restclient.enabled=true"
,
"debug
=true"
})
@DirtiesContext
public
class
RibbonClientHttpRequestFactoryTests
{
...
...
@@ -71,11 +73,13 @@ public class RibbonClientHttpRequestFactoryTests {
protected
RestTemplate
restTemplate
;
@Test
@Ignore
//FIXME 2.0.0
public
void
requestFactoryIsRibbon
()
{
ClientHttpRequestFactory
requestFactory
=
this
.
restTemplate
.
getRequestFactory
();
assertTrue
(
"wrong RequestFactory type: "
+
requestFactory
.
getClass
(),
requestFactory
instanceof
RibbonClientHttpRequestFactory
);
assertThat
(
requestFactory
).
isInstanceOf
(
AbstractClientHttpRequestFactoryWrapper
.
class
);
Field
field
=
ReflectionUtils
.
findField
(
AbstractClientHttpRequestFactoryWrapper
.
class
,
"requestFactory"
);
ReflectionUtils
.
makeAccessible
(
field
);
ClientHttpRequestFactory
delegate
=
(
ClientHttpRequestFactory
)
ReflectionUtils
.
getField
(
field
,
requestFactory
);
assertThat
(
delegate
).
isInstanceOf
(
RibbonClientHttpRequestFactory
.
class
);
}
@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