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 {
...
@@ -118,7 +118,7 @@ public class RibbonAutoConfiguration {
@Configuration
@Configuration
@ConditionalOnClass
(
HttpRequest
.
class
)
@ConditionalOnClass
(
HttpRequest
.
class
)
@ConditionalOnRibbonRestClient
@ConditionalOnRibbonRestClient
protected
static
class
RibbonClient
Config
{
protected
static
class
RibbonClient
HttpRequestFactoryConfiguration
{
@Autowired
@Autowired
private
SpringClientFactory
springClientFactory
;
private
SpringClientFactory
springClientFactory
;
...
@@ -126,12 +126,7 @@ public class RibbonAutoConfiguration {
...
@@ -126,12 +126,7 @@ public class RibbonAutoConfiguration {
@Bean
@Bean
public
RestTemplateCustomizer
restTemplateCustomizer
(
public
RestTemplateCustomizer
restTemplateCustomizer
(
final
RibbonClientHttpRequestFactory
ribbonClientHttpRequestFactory
)
{
final
RibbonClientHttpRequestFactory
ribbonClientHttpRequestFactory
)
{
return
new
RestTemplateCustomizer
()
{
return
restTemplate
->
restTemplate
.
setRequestFactory
(
ribbonClientHttpRequestFactory
);
@Override
public
void
customize
(
RestTemplate
restTemplate
)
{
restTemplate
.
setRequestFactory
(
ribbonClientHttpRequestFactory
);
}
};
}
}
@Bean
@Bean
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonClientHttpRequestFactoryTests.java
View file @
ce4d560d
...
@@ -16,12 +16,9 @@
...
@@ -16,12 +16,9 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.lang.reflect.Field
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.net.URI
;
import
java.net.URI
;
import
org.junit.Ignore
;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
...
@@ -30,16 +27,17 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -30,16 +27,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.test.context.SpringBootTest
;
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.cloud.client.loadbalancer.LoadBalanced
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.RequestEntity
;
import
org.springframework.http.RequestEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper
;
import
org.springframework.http.client.ClientHttpRequestFactory
;
import
org.springframework.http.client.ClientHttpRequestFactory
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
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.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestHeader
;
...
@@ -53,13 +51,17 @@ import org.springframework.web.client.RestTemplate;
...
@@ -53,13 +51,17 @@ import org.springframework.web.client.RestTemplate;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.ServerList
;
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
* @author Spencer Gibb
*/
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@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.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
@DirtiesContext
public
class
RibbonClientHttpRequestFactoryTests
{
public
class
RibbonClientHttpRequestFactoryTests
{
...
@@ -71,11 +73,13 @@ public class RibbonClientHttpRequestFactoryTests {
...
@@ -71,11 +73,13 @@ public class RibbonClientHttpRequestFactoryTests {
protected
RestTemplate
restTemplate
;
protected
RestTemplate
restTemplate
;
@Test
@Test
@Ignore
//FIXME 2.0.0
public
void
requestFactoryIsRibbon
()
{
public
void
requestFactoryIsRibbon
()
{
ClientHttpRequestFactory
requestFactory
=
this
.
restTemplate
.
getRequestFactory
();
ClientHttpRequestFactory
requestFactory
=
this
.
restTemplate
.
getRequestFactory
();
assertTrue
(
"wrong RequestFactory type: "
+
requestFactory
.
getClass
(),
assertThat
(
requestFactory
).
isInstanceOf
(
AbstractClientHttpRequestFactoryWrapper
.
class
);
requestFactory
instanceof
RibbonClientHttpRequestFactory
);
Field
field
=
ReflectionUtils
.
findField
(
AbstractClientHttpRequestFactoryWrapper
.
class
,
"requestFactory"
);
ReflectionUtils
.
makeAccessible
(
field
);
ClientHttpRequestFactory
delegate
=
(
ClientHttpRequestFactory
)
ReflectionUtils
.
getField
(
field
,
requestFactory
);
assertThat
(
delegate
).
isInstanceOf
(
RibbonClientHttpRequestFactory
.
class
);
}
}
@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