Skip to content

Commit a64b3aa

Browse files
authored
Merge pull request #1 from SourceLabOrg/master
Syncing with original repo
2 parents 2354251 + d5d6890 commit a64b3aa

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
The format is based on [Keep a Changelog](http://keepachangelog.com/)
33
and this project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## 3.1.2 (07/21/2021)
6+
7+
- [Issue-54](https://github.com/SourceLabOrg/kafka-connect-client/issues/54) Resolution for issue-54
8+
9+
#### Internal Dependency Updates
10+
- org.apache.logging.log4j from 2.13.2 -> 2.14.1
11+
- org.slf4j:slf4j from 1.7.30 -> 1.7.32
12+
513
## 3.1.1 (04/08/2021)
614

715
#### Bugfixes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This client library is released on Maven Central. Add a new dependency to your
1414
<dependency>
1515
<groupId>org.sourcelab</groupId>
1616
<artifactId>kafka-connect-client</artifactId>
17-
<version>3.1.1</version>
17+
<version>3.1.2</version>
1818
</dependency>
1919
```
2020

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.sourcelab</groupId>
88
<artifactId>kafka-connect-client</artifactId>
9-
<version>3.1.1</version>
9+
<version>3.1.2</version>
1010
<packaging>jar</packaging>
1111

1212
<!-- Require Maven 3.3.9 -->
@@ -64,8 +64,8 @@
6464
<checkstyle.version>8.32</checkstyle.version>
6565

6666
<!-- Log4J Version -->
67-
<log4j2.version>2.13.2</log4j2.version>
68-
<slf4j.version>1.7.30</slf4j.version>
67+
<log4j2.version>2.14.1</log4j2.version>
68+
<slf4j.version>1.7.32</slf4j.version>
6969

7070
<!-- test toggling -->
7171
<skipTests>false</skipTests>
@@ -140,15 +140,15 @@
140140
<dependency>
141141
<groupId>commons-io</groupId>
142142
<artifactId>commons-io</artifactId>
143-
<version>2.8.0</version>
143+
<version>2.11.0</version>
144144
<scope>test</scope>
145145
</dependency>
146146

147147
<!-- Test Http/Https Client -->
148148
<dependency>
149149
<groupId>org.eclipse.jetty</groupId>
150150
<artifactId>jetty-server</artifactId>
151-
<version>9.4.39.v20210325</version>
151+
<version>9.4.43.v20210629</version>
152152
<scope>test</scope>
153153
</dependency>
154154

src/main/java/org/sourcelab/kafka/connect/apiclient/rest/HttpClientRestClient.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void init(final Configuration configuration) {
107107
final HttpsContextBuilder httpsContextBuilder = new HttpsContextBuilder(configuration);
108108

109109
// Setup client builder
110-
final HttpClientBuilder clientBuilder = HttpClientBuilder.create();
110+
final HttpClientBuilder clientBuilder = createHttpClientBuilder();
111111
clientBuilder
112112
// Define timeout
113113
.setConnectionTimeToLive(configuration.getConnectionTimeToLiveInSeconds(), TimeUnit.SECONDS)
@@ -206,6 +206,15 @@ public void close() {
206206
httpClient = null;
207207
}
208208

209+
/**
210+
* Create the HttpClientBuilder which is used to create the HttpClient.
211+
* This method allows users to extend this class and use a custom builder if needed.
212+
* @return The HttpClientBuilder to use for creating the HttpClient.
213+
*/
214+
protected HttpClientBuilder createHttpClientBuilder() {
215+
return HttpClientBuilder.create();
216+
}
217+
209218
/**
210219
* Make a request against the Pardot API.
211220
* @param request The request to submit.

src/test/java/org/sourcelab/kafka/connect/apiclient/rest/HttpClientRestClientTest.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.sourcelab.kafka.connect.apiclient.rest;
1919

20+
import org.apache.http.impl.client.HttpClientBuilder;
2021
import org.junit.BeforeClass;
2122
import org.junit.Test;
2223
import org.sourcelab.kafka.connect.apiclient.Configuration;
@@ -27,6 +28,8 @@
2728
import java.io.File;
2829

2930
import static org.junit.Assert.assertEquals;
31+
import static org.mockito.Mockito.mock;
32+
import static org.mockito.Mockito.verify;
3033

3134
public class HttpClientRestClientTest {
3235

@@ -77,6 +80,29 @@ public void doHttpTest() throws Exception {
7780
}
7881
}
7982

83+
/**
84+
* Test that the HttpClientRestClient actually uses the builder returned from the
85+
* {@link HttpClientRestClient#createHttpClientBuilder()} method.
86+
*/
87+
@Test
88+
public void doHttp_withCustomHttpClientBuilder() {
89+
// Create a mock builder and a rest client that uses the mock builder
90+
final HttpClientBuilder builderMock = mock(HttpClientBuilder.class);
91+
HttpClientRestClient restClient = new HttpClientRestClient() {
92+
@Override
93+
protected HttpClientBuilder createHttpClientBuilder() {
94+
return builderMock;
95+
}
96+
};
97+
98+
// Init the rest client
99+
final Configuration configuration = new Configuration("http://localhost:" + HTTP_PORT);
100+
restClient.init(configuration);
101+
102+
// Verify the mock was used to create the HttpClient
103+
verify(builderMock).build();
104+
}
105+
80106
/**
81107
* Test against Https server.
82108
*/
@@ -186,4 +212,4 @@ public Object parseResponse(final String responseStr) {
186212
return responseStr;
187213
}
188214
}
189-
}
215+
}

0 commit comments

Comments
 (0)