Skip to content

Commit 43afa02

Browse files
feat: edit example
1 parent 6319f0a commit 43afa02

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

examples/src/main/java/com/influxdb/v3/ProxyExample.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,14 @@ private ProxyExample() { }
4141
public static void main(final String[] args) throws Exception {
4242
// Run docker-compose.yml file to start Envoy proxy
4343

44-
URI queryProxyUri = new URI("proxyUrl");
45-
URI uri = new URI(System.getenv("url"));
46-
47-
ProxyDetector proxyDetector = (targetServerAddress) -> {
48-
InetSocketAddress targetAddress = (InetSocketAddress) targetServerAddress;
49-
if (uri.getHost().equals(targetAddress.getHostString())) {
50-
return HttpConnectProxiedSocketAddress.newBuilder()
51-
.setProxyAddress(new InetSocketAddress(queryProxyUri.getHost(), queryProxyUri.getPort()))
52-
.setTargetAddress(targetAddress)
53-
.build();
54-
}
55-
return null;
56-
};
57-
ProxySelector proxy = ProxySelector.of(new InetSocketAddress(queryProxyUri.getHost(), queryProxyUri.getPort()));
44+
String proxyUrl = "http://127.0.0.1:10000";
45+
String certificateFilePath = "src/test/java/com/influxdb/v3/client/testdata/valid-certificates.pem";
5846
ClientConfig clientConfig = new ClientConfig.Builder()
59-
.host(uri.toString())
60-
.token(System.getenv("token").toCharArray())
61-
.database(System.getenv("database"))
62-
.proxy(proxy)
63-
.queryApiProxy(proxyDetector)
47+
.host(System.getenv("TESTING_INFLUXDB_URL"))
48+
.token(System.getenv("TESTING_INFLUXDB_TOKEN").toCharArray())
49+
.database(System.getenv("TESTING_INFLUXDB_DATABASE"))
50+
.proxyUrl(proxyUrl)
51+
.certificateFilePath(certificateFilePath)
6452
.build();
6553

6654
InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig);
@@ -72,7 +60,7 @@ public static void main(final String[] args) throws Exception {
7260
try (Stream<PointValues> stream = influxDBClient.queryPoints("SELECT * FROM test1")) {
7361
stream.findFirst()
7462
.ifPresent(pointValues -> {
75-
// do something
63+
Assertions.assertThat(pointValues.getField("field")).isEqualTo("field1");
7664
});
7765
}
7866
}

src/main/java/com/influxdb/v3/client/internal/RestClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ private X509TrustManager getX509TrustManagerFromFile(@Nonnull final String fileP
249249
trustStore.setCertificateEntry("alias" + i, cert);
250250
}
251251

252-
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
252+
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
253+
TrustManagerFactory.getDefaultAlgorithm()
254+
);
253255
trustManagerFactory.init(trustStore);
254256
X509TrustManager x509TrustManager = null;
255257
for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) {

0 commit comments

Comments
 (0)