Skip to content

Commit e5a2f9c

Browse files
authored
Merge pull request #21 from SourceLabOrg/sp/prepForRelease
Prep for release of 2.0.1
2 parents 83cc6c4 + 548e9c8 commit e5a2f9c

File tree

10 files changed

+83
-23
lines changed

10 files changed

+83
-23
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
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+
## 2.0.1 (04/23/2019)
6+
7+
### Bugfix
8+
- Updated ConnectorPluginConfigValidationResults classes to be publicly scoped. Thanks [tchiotludo](https://github.com/tchiotludo)!
9+
10+
### Internal Dependency Updates
11+
- Updated Google Guava from 27.0.1-JRE to 27.1-JRE
12+
- Updated HttpComponents from 4.5.7 to 4.5.8
13+
514
## 2.0.0 (04/05/2019)
615

716
### Bugfix / Breaking Change

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This client library is released on Maven Central. Add a new dependency to your
1212
<dependency>
1313
<groupId>org.sourcelab</groupId>
1414
<artifactId>kafka-connect-client</artifactId>
15-
<version>2.0.0</version>
15+
<version>2.0.1</version>
1616
</dependency>
1717
```
1818

pom.xml

Lines changed: 6 additions & 7 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>2.0.0</version>
9+
<version>2.0.1</version>
1010
<packaging>jar</packaging>
1111

1212
<!-- Require Maven 3.3.9 -->
@@ -47,10 +47,10 @@
4747
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4848

4949
<!-- guava version -->
50-
<guava.version>27.0.1-jre</guava.version>
50+
<guava.version>27.1-jre</guava.version>
5151

5252
<!-- Http Components version -->
53-
<http-components.version>4.5.7</http-components.version>
53+
<http-components.version>4.5.8</http-components.version>
5454

5555
<!-- Jackson version -->
5656
<jackson.version>2.9.8</jackson.version>
@@ -64,7 +64,7 @@
6464
<checkstyle.version>8.19</checkstyle.version>
6565

6666
<!-- Log4J Version -->
67-
<log4j2.version>2.11.1</log4j2.version>
67+
<log4j2.version>2.11.2</log4j2.version>
6868

6969
<!-- test toggling -->
7070
<skipTests>false</skipTests>
@@ -133,11 +133,10 @@
133133
<dependency>
134134
<groupId>org.mockito</groupId>
135135
<artifactId>mockito-core</artifactId>
136-
<version>2.23.4</version>
136+
<version>2.27.0</version>
137137
<scope>test</scope>
138138
</dependency>
139139

140-
141140
<!-- Data providers on tests -->
142141
<dependency>
143142
<groupId>com.tngtech.java</groupId>
@@ -166,7 +165,7 @@
166165
<dependency>
167166
<groupId>org.eclipse.jetty</groupId>
168167
<artifactId>jetty-server</artifactId>
169-
<version>9.4.14.v20181114</version>
168+
<version>9.4.17.v20190418</version>
170169
<scope>test</scope>
171170
</dependency>
172171
</dependencies>

src/main/java/org/sourcelab/kafka/connect/apiclient/request/JacksonFactory.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import com.fasterxml.jackson.databind.DeserializationFeature;
2121
import com.fasterxml.jackson.databind.ObjectMapper;
2222
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
23+
import com.fasterxml.jackson.databind.type.MapType;
24+
25+
import java.util.Map;
2326

2427
/**
2528
* Creates properly configured Jackson XML Mapper instances.
@@ -32,6 +35,12 @@ public final class JacksonFactory {
3235
*/
3336
private static final ObjectMapper mapper = new ObjectMapper();
3437

38+
/**
39+
* Defines a "type safe" Map[String, String] deserialization type for Jackson.
40+
*/
41+
public static final MapType mapTypeStringString = mapper.getTypeFactory()
42+
.constructMapType(Map.class, String.class, String.class);
43+
3544
/*
3645
* Statically configure the instance.
3746
*/

src/main/java/org/sourcelab/kafka/connect/apiclient/request/get/GetConnectorConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public Object getRequestBody() {
5353

5454
@Override
5555
public Map<String, String> parseResponse(final String responseStr) throws IOException {
56-
return JacksonFactory.newInstance().readValue(responseStr, Map.class);
56+
return JacksonFactory.newInstance().readValue(responseStr, JacksonFactory.mapTypeStringString);
5757
}
5858
}

src/test/java/org/sourcelab/kafka/connect/apiclient/KafkaConnectClientUnitTest.java

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.junit.Test;
2222
import org.sourcelab.kafka.connect.apiclient.rest.RestClient;
2323
import org.sourcelab.kafka.connect.apiclient.rest.RestResponse;
24+
import org.sourcelab.kafka.connect.apiclient.rest.exceptions.ConcurrentConfigModificationException;
25+
import org.sourcelab.kafka.connect.apiclient.rest.exceptions.ResourceNotFoundException;
2426
import org.sourcelab.kafka.connect.apiclient.rest.exceptions.UnauthorizedRequestException;
2527

2628
import static org.mockito.ArgumentMatchers.any;
@@ -32,15 +34,14 @@
3234
*/
3335
public class KafkaConnectClientUnitTest {
3436

37+
private final Configuration configuration = new Configuration("http://localhost:9092");
38+
3539
/**
3640
* This test verifies that if the underlying RestClient returns a response with Http Status Code 401,
3741
* then KafkaConnectClient will throw an UnauthorizedRequestException.
3842
*/
3943
@Test(expected = UnauthorizedRequestException.class)
4044
public void unAuthorizedException() {
41-
// Create configuration
42-
final Configuration configuration = new Configuration("http://localhost:9092");
43-
4445
// Create mock RestResponse
4546
final RestResponse restResponse = new RestResponse("Invalid credentials.", HttpStatus.SC_UNAUTHORIZED);
4647

@@ -55,4 +56,52 @@ public void unAuthorizedException() {
5556
// Call any method that makes a request via RestClient.
5657
client.getConnectors();
5758
}
58-
}
59+
60+
/**
61+
* This test verifies that if the underlying RestClient returns a response with Http Status Code 404,
62+
* then KafkaConnectClient will throw a ResourceNotFoundException.
63+
*/
64+
@Test(expected = ResourceNotFoundException.class)
65+
public void on404_resourceNotFoundException() {
66+
// Create mock RestResponse
67+
final String connectorName = "DoesNotExist";
68+
final String result = "{\"error_code\":404,\"message\":\"Connector " + connectorName + " not found\"}";
69+
70+
final RestResponse restResponse = new RestResponse(result, HttpStatus.SC_NOT_FOUND);
71+
72+
// Create mock RestClient
73+
final RestClient mockRestClient = mock(RestClient.class);
74+
when(mockRestClient.submitRequest(any()))
75+
.thenReturn(restResponse);
76+
77+
// Create client
78+
final KafkaConnectClient client = new KafkaConnectClient(configuration, mockRestClient);
79+
80+
// Call any method that makes a request via RestClient.
81+
client.getConnector(connectorName);
82+
}
83+
84+
/**
85+
* This test verifies that if the underlying RestClient returns a response with Http Status Code 409,
86+
* then KafkaConnectClient will throw a ConcurrentConfigModificationException.
87+
*/
88+
@Test(expected = ConcurrentConfigModificationException.class)
89+
public void on409_concurrentConfigModificationException() {
90+
// Create mock RestResponse
91+
final String connectorName = "DoesNotExist";
92+
final String result = "{\"error_code\":409,\"message\":\"Rebalance in progress.\"}";
93+
94+
final RestResponse restResponse = new RestResponse(result, HttpStatus.SC_CONFLICT);
95+
96+
// Create mock RestClient
97+
final RestClient mockRestClient = mock(RestClient.class);
98+
when(mockRestClient.submitRequest(any()))
99+
.thenReturn(restResponse);
100+
101+
// Create client
102+
final KafkaConnectClient client = new KafkaConnectClient(configuration, mockRestClient);
103+
104+
// Call any method that makes a request via RestClient.
105+
client.getConnector(connectorName);
106+
}
107+
}

src/test/java/org/sourcelab/kafka/connect/apiclient/request/get/connector/GetConnectorPluginsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
import java.io.IOException;
2828
import java.util.ArrayList;
29-
import java.util.Collection;
3029
import java.util.List;
3130

32-
import static org.junit.Assert.*;
31+
import static org.junit.Assert.assertEquals;
32+
import static org.junit.Assert.assertNotNull;
3333

3434
public class GetConnectorPluginsTest extends AbstractRequestTest {
3535
private static final Logger logger = LoggerFactory.getLogger(GetConnectorPluginsTest.class);

src/test/java/org/sourcelab/kafka/connect/apiclient/request/get/connector/GetConnectorTasksTest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,18 @@
1919

2020
import com.google.common.collect.ImmutableMap;
2121
import org.junit.Test;
22-
import org.slf4j.Logger;
23-
import org.slf4j.LoggerFactory;
2422
import org.sourcelab.kafka.connect.apiclient.request.AbstractRequestTest;
25-
import org.sourcelab.kafka.connect.apiclient.request.dto.ConnectorPlugin;
2623
import org.sourcelab.kafka.connect.apiclient.request.dto.Task;
27-
import org.sourcelab.kafka.connect.apiclient.request.get.GetConnectorPlugins;
2824
import org.sourcelab.kafka.connect.apiclient.request.get.GetConnectorTasks;
2925

3026
import java.io.IOException;
3127
import java.util.ArrayList;
32-
import java.util.HashMap;
3328
import java.util.List;
3429

3530
import static org.junit.Assert.assertEquals;
3631
import static org.junit.Assert.assertNotNull;
3732

3833
public class GetConnectorTasksTest extends AbstractRequestTest {
39-
private static final Logger logger = LoggerFactory.getLogger(GetConnectorTasksTest.class);
40-
4134
/**
4235
* Test Parsing GET /connectors response.
4336
*/

src/test/java/testserver/TestHttpServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private void configureServer() {
118118
// SSL requires a certificate so we configure a factory for ssl contents with information pointing to what
119119
// keystore the ssl connection needs to know about. Much more configuration is available the ssl context,
120120
// including things like choosing the particular certificate out of a keystore to be used.
121-
final SslContextFactory sslContextFactory = new SslContextFactory();
121+
final SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
122122

123123
// define server side key
124124
sslContextFactory.setKeyStorePath(keyStoreFile);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"error_code":404,"message":"Connector DoesNotExist not found"}

0 commit comments

Comments
 (0)