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
a82b5266
Commit
a82b5266
authored
May 15, 2019
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
Closes gh-16858
parents
e03f3b8e
e2dc278c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
2 deletions
+78
-2
ClientHttpConnectorConfiguration.java
...ive/function/client/ClientHttpConnectorConfiguration.java
+9
-2
ClientHttpConnectorConfigurationTests.java
...unction/client/ClientHttpConnectorConfigurationTests.java
+69
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorConfiguration.java
View file @
a82b5266
...
...
@@ -18,6 +18,9 @@ package org.springframework.boot.autoconfigure.web.reactive.function.client;
import
java.util.function.Function
;
import
org.eclipse.jetty.client.HttpClient
;
import
org.eclipse.jetty.util.ssl.SslContextFactory
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -73,8 +76,12 @@ class ClientHttpConnectorConfiguration {
@Bean
public
JettyClientHttpConnector
jettyClientHttpConnector
(
JettyResourceFactory
jettyResourceFactory
)
{
return
new
JettyClientHttpConnector
(
jettyResourceFactory
,
(
httpClient
)
->
{
});
SslContextFactory
sslContextFactory
=
new
SslContextFactory
.
Client
();
HttpClient
httpClient
=
new
HttpClient
(
sslContextFactory
);
httpClient
.
setExecutor
(
jettyResourceFactory
.
getExecutor
());
httpClient
.
setByteBufferPool
(
jettyResourceFactory
.
getByteBufferPool
());
httpClient
.
setScheduler
(
jettyResourceFactory
.
getScheduler
());
return
new
JettyClientHttpConnector
(
httpClient
);
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorConfigurationTests.java
0 → 100644
View file @
a82b5266
/*
* Copyright 2012-2019 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
web
.
reactive
.
function
.
client
;
import
java.util.concurrent.Executor
;
import
org.eclipse.jetty.client.HttpClient
;
import
org.eclipse.jetty.io.ByteBufferPool
;
import
org.eclipse.jetty.util.thread.Scheduler
;
import
org.junit.Test
;
import
org.springframework.http.client.reactive.JettyClientHttpConnector
;
import
org.springframework.http.client.reactive.JettyResourceFactory
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
* Tests for {@link ClientHttpConnectorConfiguration}.
*
* @author Phillip Webb
*/
public
class
ClientHttpConnectorConfigurationTests
{
@Test
public
void
jettyClientHttpConnectorAppliesJettyResourceFactory
()
{
Executor
executor
=
mock
(
Executor
.
class
);
ByteBufferPool
byteBufferPool
=
mock
(
ByteBufferPool
.
class
);
Scheduler
scheduler
=
mock
(
Scheduler
.
class
);
JettyResourceFactory
jettyResourceFactory
=
new
JettyResourceFactory
();
jettyResourceFactory
.
setExecutor
(
executor
);
jettyResourceFactory
.
setByteBufferPool
(
byteBufferPool
);
jettyResourceFactory
.
setScheduler
(
scheduler
);
JettyClientHttpConnector
connector
=
new
ClientHttpConnectorConfiguration
.
JettyClient
()
.
jettyClientHttpConnector
(
jettyResourceFactory
);
HttpClient
httpClient
=
(
HttpClient
)
ReflectionTestUtils
.
getField
(
connector
,
"httpClient"
);
assertThat
(
httpClient
.
getExecutor
()).
isSameAs
(
executor
);
assertThat
(
httpClient
.
getByteBufferPool
()).
isSameAs
(
byteBufferPool
);
assertThat
(
httpClient
.
getScheduler
()).
isSameAs
(
scheduler
);
}
@Test
public
void
JettyResourceFactoryHasSslContextFactory
()
{
// gh-16810
JettyResourceFactory
jettyResourceFactory
=
new
JettyResourceFactory
();
JettyClientHttpConnector
connector
=
new
ClientHttpConnectorConfiguration
.
JettyClient
()
.
jettyClientHttpConnector
(
jettyResourceFactory
);
HttpClient
httpClient
=
(
HttpClient
)
ReflectionTestUtils
.
getField
(
connector
,
"httpClient"
);
assertThat
(
httpClient
.
getSslContextFactory
()).
isNotNull
();
}
}
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