From 5d912cd8fdd667af3fe47c63b99a2c899ce60555 Mon Sep 17 00:00:00 2001 From: Laura Date: Tue, 26 Mar 2024 16:48:08 +0100 Subject: [PATCH] removed examples --- example-transports/README.md | 1 - example-transports/build.gradle.kts | 55 --- .../netty/InputStreamBinaryData.java | 90 ----- .../netty/NettyElasticsearchTransport.java | 70 ---- .../netty/NettyTransportHttpClient.java | 380 ------------------ .../transport/TransportHttpClientTest.java | 143 ------- .../transport/netty/NettyClientTest.java | 30 -- .../rest_client/RestTransportClientTest.java | 39 -- 8 files changed, 808 deletions(-) delete mode 100644 example-transports/README.md delete mode 100644 example-transports/build.gradle.kts delete mode 100644 example-transports/src/main/java/co/elastic/clients/transport/netty/InputStreamBinaryData.java delete mode 100644 example-transports/src/main/java/co/elastic/clients/transport/netty/NettyElasticsearchTransport.java delete mode 100644 example-transports/src/main/java/co/elastic/clients/transport/netty/NettyTransportHttpClient.java delete mode 100644 example-transports/src/test/java/co/elastic/clients/transport/TransportHttpClientTest.java delete mode 100644 example-transports/src/test/java/co/elastic/clients/transport/netty/NettyClientTest.java delete mode 100644 example-transports/src/test/java/co/elastic/clients/transport/rest_client/RestTransportClientTest.java diff --git a/example-transports/README.md b/example-transports/README.md deleted file mode 100644 index a94b5dc3e..000000000 --- a/example-transports/README.md +++ /dev/null @@ -1 +0,0 @@ -This directory contains experimental implementations of the `TransportHttpClient` interface. They are to be used as examples and inspiration and should not be considered production-ready. diff --git a/example-transports/build.gradle.kts b/example-transports/build.gradle.kts deleted file mode 100644 index 12849f582..000000000 --- a/example-transports/build.gradle.kts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you 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 - * - * http://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. - */ - -plugins { - java - `java-library` - `java-test-fixtures` -} - -tasks.withType { - useJUnitPlatform() -} - -java { - targetCompatibility = JavaVersion.VERSION_17 -} - - -dependencies { - val jacksonVersion = "2.13.3" - - api("io.netty", "netty-codec-http", "4.1.93.Final") - - implementation(project(":java-client")) - - // Apache 2.0 - // https://github.com/FasterXML/jackson - testImplementation("com.fasterxml.jackson.core", "jackson-core", jacksonVersion) - testImplementation("com.fasterxml.jackson.core", "jackson-databind", jacksonVersion) - - // EPL-2.0 - // https://junit.org/junit5/ - testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0") - -} -repositories { - mavenCentral() -} diff --git a/example-transports/src/main/java/co/elastic/clients/transport/netty/InputStreamBinaryData.java b/example-transports/src/main/java/co/elastic/clients/transport/netty/InputStreamBinaryData.java deleted file mode 100644 index 47683bdb7..000000000 --- a/example-transports/src/main/java/co/elastic/clients/transport/netty/InputStreamBinaryData.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you 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 - * - * http://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 co.elastic.clients.transport.netty; - -import co.elastic.clients.util.BinaryData; -import co.elastic.clients.util.NoCopyByteArrayOutputStream; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.ByteBuffer; - -public class InputStreamBinaryData implements BinaryData { - - private final String contentType; - private final InputStream inputStream; - private boolean consumed = false; - - public InputStreamBinaryData(String contentType, InputStream inputStream) { - this.contentType = contentType; - this.inputStream = inputStream; - } - - @Override - public String contentType() { - return contentType; - } - - @Override - public void writeTo(OutputStream out) throws IOException { - consume(); - try { - byte[] buffer = new byte[8192]; - int len; - while ((len = inputStream.read(buffer)) > 0) { - out.write(buffer, 0, len); - } - } finally { - inputStream.close(); - } - } - - @Override - public ByteBuffer asByteBuffer() throws IOException { - consume(); - NoCopyByteArrayOutputStream baos = new NoCopyByteArrayOutputStream(); - writeTo(baos); - return baos.asByteBuffer(); - } - - @Override - public InputStream asInputStream() throws IOException { - consume(); - return inputStream; - } - - @Override - public boolean isRepeatable() { - return false; - } - - @Override - public long size() { - return -1; - } - - private void consume() throws IllegalStateException { - if (consumed) { - throw new IllegalStateException("Data has already been consumed"); - } - consumed = true; - } -} diff --git a/example-transports/src/main/java/co/elastic/clients/transport/netty/NettyElasticsearchTransport.java b/example-transports/src/main/java/co/elastic/clients/transport/netty/NettyElasticsearchTransport.java deleted file mode 100644 index 3317eb3be..000000000 --- a/example-transports/src/main/java/co/elastic/clients/transport/netty/NettyElasticsearchTransport.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you 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 - * - * http://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 co.elastic.clients.transport.netty; - -import co.elastic.clients.json.JsonpMapper; -import co.elastic.clients.transport.ElasticsearchTransportBase; -import co.elastic.clients.transport.TransportOptions; -import co.elastic.clients.transport.http.TransportHttpClient; - -import javax.annotation.Nullable; -import java.io.IOException; -import java.util.concurrent.CompletableFuture; - -public class NettyElasticsearchTransport extends ElasticsearchTransportBase { - - public NettyElasticsearchTransport(TransportHttpClient.Node node, TransportOptions options, JsonpMapper jsonpMapper) { - super(new SingleNodeHttpClient(new NettyTransportHttpClient(), node), options, jsonpMapper); - } - - public static class SingleNodeHttpClient implements TransportHttpClient { - private final TransportHttpClient client; - private final Node node; - - public SingleNodeHttpClient(TransportHttpClient client, Node node) { - this.client = client; - this.node = node; - } - - @Override - public TransportOptions createOptions(@Nullable TransportOptions options) { - return client.createOptions(options); - } - - @Override - public Response performRequest( - String endpointId, @Nullable Node ignoredNode, Request request, TransportOptions options - ) throws IOException { - return client.performRequest(endpointId, node, request, options); - } - - @Override - public CompletableFuture performRequestAsync( - String endpointId, @Nullable Node ignoredNode, Request request, TransportOptions options - ) { - return client.performRequestAsync(endpointId, node, request, options); - } - - @Override - public void close() throws IOException { - client.close(); - } - } -} diff --git a/example-transports/src/main/java/co/elastic/clients/transport/netty/NettyTransportHttpClient.java b/example-transports/src/main/java/co/elastic/clients/transport/netty/NettyTransportHttpClient.java deleted file mode 100644 index fcd4b9747..000000000 --- a/example-transports/src/main/java/co/elastic/clients/transport/netty/NettyTransportHttpClient.java +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you 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 - * - * http://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 co.elastic.clients.transport.netty; - -import co.elastic.clients.transport.DefaultTransportOptions; -import co.elastic.clients.transport.TransportOptions; -import co.elastic.clients.transport.http.TransportHttpClient; -import co.elastic.clients.util.BinaryData; -import io.netty.bootstrap.Bootstrap; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufInputStream; -import io.netty.buffer.Unpooled; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOption; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioSocketChannel; -import io.netty.handler.codec.http.DefaultFullHttpRequest; -import io.netty.handler.codec.http.FullHttpRequest; -import io.netty.handler.codec.http.HttpClientCodec; -import io.netty.handler.codec.http.HttpContent; -import io.netty.handler.codec.http.HttpHeaderNames; -import io.netty.handler.codec.http.HttpHeaders; -import io.netty.handler.codec.http.HttpMethod; -import io.netty.handler.codec.http.HttpObject; -import io.netty.handler.codec.http.HttpResponse; -import io.netty.handler.codec.http.HttpVersion; -import io.netty.handler.codec.http.LastHttpContent; -import io.netty.handler.ssl.SslContext; -import io.netty.handler.ssl.SslContextBuilder; -import io.netty.handler.ssl.util.InsecureTrustManagerFactory; -import io.netty.util.concurrent.Future; - -import javax.annotation.Nullable; -import javax.net.ssl.SSLException; -import java.io.IOException; -import java.net.URLEncoder; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.stream.Collectors; - -/** - * Prototype implementation of {@link TransportHttpClient} based on Netty. Not production-ready. - */ -public class NettyTransportHttpClient implements TransportHttpClient { - - private final NioEventLoopGroup workerGroup = new NioEventLoopGroup(); - private final SslContext sslContext; - - public NettyTransportHttpClient() { - try { - // Trust any certificate. DO NOT USE IN PRODUCTION! - this.sslContext = SslContextBuilder - .forClient() - .trustManager(InsecureTrustManagerFactory.INSTANCE) - .build(); - } catch (SSLException e) { - throw new RuntimeException(e); - } - } - - @Override - public DefaultTransportOptions createOptions(@Nullable TransportOptions options) { - return DefaultTransportOptions.of(options); - } - - @Override - public Response performRequest(String endpointId, Node node, Request request, TransportOptions options) throws IOException { - try { - return performRequestAsync(endpointId, node, request, options).get(); - } catch (InterruptedException ie) { - throw new RuntimeException(ie); - } catch (ExecutionException ee) { - // Remove one nesting level - throw new RuntimeException(ee.getCause()); - } - } - - @Override - public CompletableFuture performRequestAsync(String endpointId, Node node, Request request, TransportOptions options) { - - CompletableFuture promise = new CompletableFuture() { - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - // TODO: cancel pending request - return super.cancel(mayInterruptIfRunning); - } - }; - - Bootstrap bootstrap = new Bootstrap(); - bootstrap.group(workerGroup) - .channel(NioSocketChannel.class) - .option(ChannelOption.SO_KEEPALIVE, true) - .handler(new ChannelInitializer() { - @Override - protected void initChannel(SocketChannel ch) throws Exception { - ChannelPipeline pipeline = ch.pipeline(); - if (node.uri().getScheme().equals("https")) { - pipeline.addLast(sslContext.newHandler(ch.alloc())); - } - pipeline.addLast(new HttpClientCodec()); - pipeline.addLast(new ChannelHandler(node, promise)); - } - }); - - String uri = request.path(); - - // If the node is not at the server root, prepend its path. - String nodePath = node.uri().getRawPath(); - if (nodePath.length() > 1) { - if (uri.charAt(0) == '/') { - uri = uri.substring(1); - } - uri = nodePath + uri; - } - - // Append query parameters - String queryString = queryString(request, options); - if (queryString != null) { - uri = uri + "?" + queryString; - } - - ByteBuf nettyBody; - Iterable body = request.body(); - if (body == null) { - nettyBody = Unpooled.buffer(0); - } else { - List bufs; - if (body instanceof List) { - bufs = (List)body; - } else { - bufs = new ArrayList<>(); - for (ByteBuffer buf: body) { - bufs.add(buf); - } - } - nettyBody = Unpooled.wrappedBuffer(bufs.toArray(new ByteBuffer[bufs.size()])); - } - - FullHttpRequest nettyRequest = new DefaultFullHttpRequest( - HttpVersion.HTTP_1_1, - HttpMethod.valueOf(request.method()), - uri, - nettyBody - ); - - HttpHeaders nettyHeaders = nettyRequest.headers(); - // Netty doesn't set Content-Length automatically with FullRequest. - nettyHeaders.set(HttpHeaderNames.CONTENT_LENGTH, nettyBody.readableBytes()); - - int port = node.uri().getPort(); - if (port == -1) { - port = node.uri().getScheme().equals("https") ? 443 : 80; - } - - nettyHeaders.set(HttpHeaderNames.HOST, node.uri().getHost() + ":" + port); - - request.headers().forEach(nettyHeaders::set); - options.headers().stream().forEach((kv) -> nettyHeaders.set(kv.getKey(), kv.getValue())); - - ChannelFuture future0 = bootstrap.connect(node.uri().getHost(), port); - future0.addListener((ChannelFutureListener) future1 -> { - if (checkSuccess(future1, promise)) { - ChannelFuture future2 = future1.channel().writeAndFlush(nettyRequest); - future2.addListener((ChannelFutureListener) future3 -> { - if (checkSuccess(future3, promise)) { - // Log request sent? - } - }); - } - }); - - future0.addListener(future4 -> { - if (future4.cause() != null) { - promise.completeExceptionally(future4.cause()); - } else if (future4.isCancelled()) { - promise.completeExceptionally(new RuntimeException("Request was cancelled")); - } - }); - - return promise; - } - - private String queryString(Request request, TransportOptions options) { - Map requestParams = request.queryParams(); - Map optionsParams = options == null ? Collections.emptyMap() : options.queryParameters(); - - Map allParams; - if (requestParams.isEmpty()) { - allParams = optionsParams; - } else if (optionsParams.isEmpty()) { - allParams = requestParams; - } else { - allParams = new HashMap<>(requestParams); - allParams.putAll(optionsParams); - } - - if (allParams.isEmpty()) { - return null; - } else { - return allParams - .entrySet() - .stream() - .map(e -> { - return URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + - URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8); - }) - .collect(Collectors.joining("&")); - } - } - - private boolean checkSuccess(Future future, CompletableFuture promise) { - if (future.isSuccess()) { - return true; - } - - if (future.cause() != null) { - promise.completeExceptionally(future.cause()); - } else if (future.isCancelled()) { - promise.completeExceptionally(new RuntimeException("Request was cancelled")); - } else { - promise.completeExceptionally(new RuntimeException("Unexpected future state")); - } - return false; - } - - private static void dump(Future future, String name) { - System.err.println("Future " + name + " - " + future); - System.err.println(" Done : " + future.isDone()); - System.err.println(" Success : " + future.isSuccess()); - System.err.println(" Cancelled: " + future.isCancelled()); - if (future.cause() != null) { - System.err.println(" Cause : " + future.cause()); - } - System.err.flush(); - } - - private static class ChannelHandler extends SimpleChannelInboundHandler { - - private final CompletableFuture promise; - private final Node node; - private volatile HttpResponse response; - private volatile List body; - - ChannelHandler(Node node, CompletableFuture promise) { - this.node = node; - this.promise = promise; - } - - @Override - protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { - if (msg instanceof HttpResponse) { - this.response = (HttpResponse) msg; - - } else if(msg instanceof HttpContent) { - System.err.flush(); - HttpContent content = (HttpContent) msg; - ByteBuf buf = content.content(); - if (buf.readableBytes() > 0) { - buf.retain(); - if (this.body == null) { - this.body = new ArrayList<>(); - } - this.body.add(buf); - } - - if(msg instanceof LastHttpContent) { - promise.complete(new NettyResponse(node, response, body)); - ctx.close(); - } - } - } - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - promise.completeExceptionally(cause); - ctx.close(); - } - } - - @Override - public void close() throws IOException { - workerGroup.shutdownGracefully(); - } - - private static class NettyResponse implements TransportHttpClient.Response { - - private final Node node; - private final HttpResponse response; - @Nullable - private final List body; - - NettyResponse(Node node, HttpResponse response, @Nullable List body) { - this.node = node; - this.response = response; - this.body = body; - } - - @Override - public Node node() { - return node; - } - - @Override - public int statusCode() { - return response.status().code(); - } - - @Override - public String header(String name) { - return response.headers().get(name); - } - - @Override - public List headers(String name) { - return response.headers().getAll(name); // returns an empty list if no values - } - - @Nullable - @Override - public BinaryData body() throws IOException { - if (body == null) { - return null; - } - - ByteBuf byteBuf = Unpooled.wrappedBuffer(body.size(), body.toArray(new ByteBuf[body.size()])); - return new InputStreamBinaryData( - response.headers().get(HttpHeaderNames.CONTENT_TYPE), - new ByteBufInputStream(byteBuf, true) - ); - } - - @Nullable - @Override - public HttpResponse originalResponse() { - return this.response; - } - - @Override - public void close() throws IOException { - if (body != null) { - for (ByteBuf buf: body) { - // May have been released already if body() was consumed - if (buf.refCnt() > 0) { - buf.release(); - } - } - body.clear(); - } - } - } -} diff --git a/example-transports/src/test/java/co/elastic/clients/transport/TransportHttpClientTest.java b/example-transports/src/test/java/co/elastic/clients/transport/TransportHttpClientTest.java deleted file mode 100644 index ba2a42956..000000000 --- a/example-transports/src/test/java/co/elastic/clients/transport/TransportHttpClientTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you 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 - * - * http://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 co.elastic.clients.transport; - -import co.elastic.clients.transport.http.HeaderMap; -import co.elastic.clients.transport.http.TransportHttpClient; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.sun.net.httpserver.Headers; -import com.sun.net.httpserver.HttpServer; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.io.OutputStream; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public abstract class TransportHttpClientTest extends Assertions { - - public static record EchoResponse(Map> headers, String body) { - } - - protected static HttpServer server; - protected final Client httpClient; - - @BeforeAll - public static void startEchoServer() throws Exception { - server = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); - - server.createContext("/root/echo", exchange -> { - - byte[] bytes = exchange.getRequestBody().readAllBytes(); - exchange.getRequestBody().close(); - - Headers requestHeaders = exchange.getRequestHeaders(); - - exchange.getResponseHeaders().add("Content-Type", "application/json"); - exchange.sendResponseHeaders(200, 0); - - var response = new EchoResponse( - requestHeaders, new String(bytes, StandardCharsets.UTF_8) - ); - - OutputStream out = exchange.getResponseBody(); - new ObjectMapper().writeValue(out, response); - out.close(); - }); - - server.start(); - } - - @AfterAll - public static void stopEchoServer() { - server.stop(0); - } - - public TransportHttpClientTest(Client httpClient) { - this.httpClient = httpClient; - } - - @Test - public void testClient() throws Exception { - - List requestBody = List.of( - ByteBuffer.wrap("Hello world\n".getBytes(StandardCharsets.UTF_8)), - ByteBuffer.wrap("Hello universe\n".getBytes(StandardCharsets.UTF_8)) - ); - - TransportHttpClient.Node node = new TransportHttpClient.Node( - "http://" + server.getAddress().getHostString() + ":" + server.getAddress().getPort() + "/" - ); - - TransportOptions options = new DefaultTransportOptions.Builder() - .addHeader("X-Options-Header", "options value") - .build(); - - HeaderMap headers = new HeaderMap(); - headers.put("Content-Type", "text/plain"); - headers.put("X-Request-Header", "request value"); - TransportHttpClient.Response response = httpClient.performRequest( - "foo", - node, - new TransportHttpClient.Request("POST", "/root/echo", Map.of(), headers, requestBody), - options - ); - - assertEquals("application/json", response.body().contentType()); - - EchoResponse echoResponse = new ObjectMapper().readValue(response.body().asInputStream(), EchoResponse.class); - - var echoHeaders = normalizeHeaders(echoResponse.headers()); - assertEquals("text/plain", echoHeaders.get("content-type")); - assertEquals("options value", echoHeaders.get("x-options-header")); - assertEquals("request value", echoHeaders.get("x-request-header")); - - dump(echoHeaders); - - assertEquals("Hello world\nHello universe\n", echoResponse.body); - } - - /** - * Set all header names to lowercase and only keep the 1st header value - */ - private static Map normalizeHeaders(Map> headers) { - var result = new HashMap(); - headers.forEach((k, v) -> { - if (v.size() != 1) { - fail("Header '" + k + "' should have a single value, but was: " + headers); - } - result.put(k.toLowerCase(), v.get(0)); - }); - return result; - } - - private static void dump(Map map) { - map.forEach((k, v) -> { - System.out.println(k + "=" + v); - }); - } -} diff --git a/example-transports/src/test/java/co/elastic/clients/transport/netty/NettyClientTest.java b/example-transports/src/test/java/co/elastic/clients/transport/netty/NettyClientTest.java deleted file mode 100644 index a41e007c2..000000000 --- a/example-transports/src/test/java/co/elastic/clients/transport/netty/NettyClientTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you 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 - * - * http://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 co.elastic.clients.transport.netty; - - -import co.elastic.clients.transport.TransportHttpClientTest; - -public class NettyClientTest extends TransportHttpClientTest { - - public NettyClientTest() throws Exception { - super(new NettyTransportHttpClient()); - } -} diff --git a/example-transports/src/test/java/co/elastic/clients/transport/rest_client/RestTransportClientTest.java b/example-transports/src/test/java/co/elastic/clients/transport/rest_client/RestTransportClientTest.java deleted file mode 100644 index fe0866652..000000000 --- a/example-transports/src/test/java/co/elastic/clients/transport/rest_client/RestTransportClientTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you 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 - * - * http://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 co.elastic.clients.transport.rest_client; - -import co.elastic.clients.transport.TransportHttpClientTest; -import org.apache.http.HttpHost; -import org.elasticsearch.client.RestClient; - -public class RestTransportClientTest extends TransportHttpClientTest { - - public RestTransportClientTest() { - super(createClient()); - } - - private static RestClientHttpClient createClient() { - RestClient restClient = RestClient.builder( - new HttpHost(server.getAddress().getAddress(), server.getAddress().getPort(), "http") - ).build(); - - return new RestClientHttpClient(restClient); - } -}