Skip to content

Commit

Permalink
Simplify TestServiceInventory
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo authored and electrum committed Jun 6, 2024
1 parent a97371a commit 24bfc18
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
import org.testng.annotations.Test;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.URI;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
Expand Down Expand Up @@ -89,21 +86,14 @@ public void testHttpServiceInventory()

Server server = null;
try (JettyHttpClient httpClient = new JettyHttpClient()) {
int port;
try (ServerSocket socket = new ServerSocket()) {
socket.bind(new InetSocketAddress(0));
port = socket.getLocalPort();
}
URI baseURI = new URI("http", null, "127.0.0.1", port, null, null, null);

HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setSendServerVersion(false);
httpConfiguration.setSendXPoweredBy(false);

server = new Server();

ServerConnector httpConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration));
httpConnector.setPort(port);
httpConnector.setPort(0);
httpConnector.setName("http");
server.addConnector(httpConnector);

Expand All @@ -118,7 +108,7 @@ public void testHttpServiceInventory()

// test
ServiceInventoryConfig serviceInventoryConfig = new ServiceInventoryConfig()
.setServiceInventoryUri(baseURI);
.setServiceInventoryUri(server.getURI());

ServiceInventory serviceInventory = new ServiceInventory(serviceInventoryConfig,
new NodeInfo("test"),
Expand Down

0 comments on commit 24bfc18

Please sign in to comment.