diff --git a/java_console/io/src/main/java/com/rusefi/io/tcp/TcpConnector.java b/java_console/io/src/main/java/com/rusefi/io/tcp/TcpConnector.java index 94553593db..d9d14640cd 100644 --- a/java_console/io/src/main/java/com/rusefi/io/tcp/TcpConnector.java +++ b/java_console/io/src/main/java/com/rusefi/io/tcp/TcpConnector.java @@ -12,7 +12,7 @@ import java.util.Date; */ public class TcpConnector { public final static int DEFAULT_PORT = 29001; - private static final String LOCALHOST = "localhost"; + public static final String LOCALHOST = "localhost"; public static boolean isTcpPort(String port) { try { diff --git a/java_console/io/src/test/java/com/rusefi/TestHelper.java b/java_console/io/src/test/java/com/rusefi/TestHelper.java index 166aa5a863..38d6fa8a19 100644 --- a/java_console/io/src/test/java/com/rusefi/TestHelper.java +++ b/java_console/io/src/test/java/com/rusefi/TestHelper.java @@ -11,6 +11,7 @@ import com.rusefi.io.IoStream; import com.rusefi.io.LinkConnector; import com.rusefi.io.LinkManager; import com.rusefi.io.tcp.BinaryProtocolServer; +import com.rusefi.io.tcp.TcpConnector; import com.rusefi.io.tcp.TcpIoStream; import com.rusefi.proxy.NetworkConnector; import com.rusefi.server.ControllerInfo; @@ -27,11 +28,11 @@ import java.util.concurrent.TimeUnit; import static com.devexperts.logging.Logging.getLogging; import static com.rusefi.Timeouts.READ_IMAGE_TIMEOUT; +import static com.rusefi.io.tcp.TcpConnector.LOCALHOST; import static org.junit.Assert.assertTrue; public class TestHelper { private static final Logging log = getLogging(TestHelper.class); - public static final String LOCALHOST = "localhost"; public static final String TEST_SIGNATURE_1 = "rusEFI 2020.07.06.frankenso_na6.2468827536"; public static final String TEST_SIGNATURE_2 = "rusEFI 2020.07.11.proteus_f4.1986715563"; public static final ControllerInfo CONTROLLER_INFO = new ControllerInfo("name", "make", "code", Fields.TS_SIGNATURE); @@ -79,7 +80,7 @@ public class TestHelper { } @NotNull - public static IoStream connectToLocalhost(int controllerPort, Logger logger) { + public static IoStream connectToLocalhost(int controllerPort) { IoStream targetEcuSocket; try { targetEcuSocket = new TcpIoStream("[local]", new Socket(LOCALHOST, controllerPort)); diff --git a/java_console/ui/src/test/java/com/rusefi/BackendTestHelper.java b/java_console/ui/src/test/java/com/rusefi/BackendTestHelper.java index 5cbe9a430f..9da3197c51 100644 --- a/java_console/ui/src/test/java/com/rusefi/BackendTestHelper.java +++ b/java_console/ui/src/test/java/com/rusefi/BackendTestHelper.java @@ -1,6 +1,7 @@ package com.rusefi; import com.rusefi.binaryprotocol.BinaryProtocol; +import com.rusefi.io.tcp.TcpConnector; import com.rusefi.server.Backend; import com.rusefi.server.UserDetails; import com.rusefi.server.UserDetailsResolver; @@ -41,7 +42,7 @@ public class BackendTestHelper { } public static void commonServerTest() throws MalformedURLException { - HttpUtil.RUSEFI_PROXY_HOSTNAME = TestHelper.LOCALHOST; + HttpUtil.RUSEFI_PROXY_HOSTNAME = TcpConnector.LOCALHOST; BinaryProtocol.DISABLE_LOCAL_CACHE = true; rusEFISSLContext.init("certificate/test_pkcs12.jks", "password"); diff --git a/java_console/ui/src/test/java/com/rusefi/FullServerTest.java b/java_console/ui/src/test/java/com/rusefi/FullServerTest.java index 41ee74bb77..73c0a5464c 100644 --- a/java_console/ui/src/test/java/com/rusefi/FullServerTest.java +++ b/java_console/ui/src/test/java/com/rusefi/FullServerTest.java @@ -8,6 +8,7 @@ import com.rusefi.config.generated.Fields; import com.rusefi.io.ConnectionStateListener; import com.rusefi.io.LinkManager; import com.rusefi.io.tcp.BinaryProtocolServer; +import com.rusefi.io.tcp.TcpConnector; import com.rusefi.io.tcp.TcpIoStream; import com.rusefi.proxy.NetworkConnector; import com.rusefi.proxy.NetworkConnectorContext; @@ -112,7 +113,7 @@ public class FullServerTest { // start "rusEFI network connector" to connect controller with backend since in real life controller has only local serial port it does not have network NetworkConnector.NetworkConnectorResult networkConnectorResult = networkConnector.start(NetworkConnector.Implementation.Unknown, - TestHelper.TEST_TOKEN_1, TestHelper.LOCALHOST + ":" + controllerPort, networkConnectorContext, NetworkConnector.ReconnectListener.VOID); + TestHelper.TEST_TOKEN_1, TcpConnector.LOCALHOST + ":" + controllerPort, networkConnectorContext, NetworkConnector.ReconnectListener.VOID); ControllerInfo controllerInfo = networkConnectorResult.getControllerInfo(); TestHelper.assertLatch("controllerRegistered", controllerRegistered); @@ -133,7 +134,7 @@ public class FullServerTest { CountDownLatch connectionEstablishedCountDownLatch = new CountDownLatch(1); // connect to proxy and read virtual controller through it - clientManager.startAndConnect(TestHelper.LOCALHOST + ":" + localApplicationProxyContext.authenticatorPort(), new ConnectionStateListener() { + clientManager.startAndConnect(TcpConnector.LOCALHOST + ":" + localApplicationProxyContext.authenticatorPort(), new ConnectionStateListener() { @Override public void onConnectionEstablished() { connectionEstablishedCountDownLatch.countDown(); diff --git a/java_console/ui/src/test/java/com/rusefi/ServerTest.java b/java_console/ui/src/test/java/com/rusefi/ServerTest.java index 39cf0ef246..e91de4d3d9 100644 --- a/java_console/ui/src/test/java/com/rusefi/ServerTest.java +++ b/java_console/ui/src/test/java/com/rusefi/ServerTest.java @@ -5,6 +5,7 @@ import com.rusefi.io.IoStream; import com.rusefi.io.commands.GetOutputsCommand; import com.rusefi.io.commands.HelloCommand; import com.rusefi.io.tcp.BinaryProtocolServer; +import com.rusefi.io.tcp.TcpConnector; import com.rusefi.io.tcp.TcpIoStream; import com.rusefi.proxy.BaseBroadcastingThread; import com.rusefi.proxy.NetworkConnectorContext; @@ -22,7 +23,6 @@ import java.net.Socket; import java.util.List; import java.util.concurrent.CountDownLatch; -import static com.rusefi.TestHelper.LOCALHOST; import static com.rusefi.TestHelper.assertLatch; import static org.junit.Assert.assertEquals; @@ -84,7 +84,7 @@ public class ServerTest { List clients = backend.getControllers(); assertEquals(2, clients.size()); - List onlineUsers = ProxyClient.getOnlineApplications(HttpUtil.RUSEFI_PROXY_JSON_PROTOCOL + TestHelper.LOCALHOST + ":" + httpPort + ProxyClient.LIST_CONTROLLERS_PATH); + List onlineUsers = ProxyClient.getOnlineApplications(HttpUtil.RUSEFI_PROXY_JSON_PROTOCOL + TcpConnector.LOCALHOST + ":" + httpPort + ProxyClient.LIST_CONTROLLERS_PATH); assertEquals(2, onlineUsers.size()); allConnected.countDown(); @@ -195,7 +195,7 @@ covered by FullServerTest } public void connect(int serverPort) throws IOException { - Socket socket = rusEFISSLContext.getSSLSocket(LOCALHOST, serverPort); + Socket socket = rusEFISSLContext.getSSLSocket(TcpConnector.LOCALHOST, serverPort); BaseBroadcastingThread baseBroadcastingThread = new BaseBroadcastingThread(socket, sessionDetails, TcpIoStream.DisconnectListener.VOID, new NetworkConnectorContext()) { diff --git a/java_console/ui/src/test/java/com/rusefi/io/TcpCommunicationIntegrationTest.java b/java_console/ui/src/test/java/com/rusefi/io/TcpCommunicationIntegrationTest.java index 75ec22f902..9fed2d773a 100644 --- a/java_console/ui/src/test/java/com/rusefi/io/TcpCommunicationIntegrationTest.java +++ b/java_console/ui/src/test/java/com/rusefi/io/TcpCommunicationIntegrationTest.java @@ -8,6 +8,7 @@ import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.config.generated.Fields; import com.rusefi.io.tcp.BinaryProtocolProxy; import com.rusefi.io.tcp.BinaryProtocolServer; +import com.rusefi.io.tcp.TcpConnector; import org.junit.Test; import java.io.IOException; @@ -59,7 +60,7 @@ public class TcpCommunicationIntegrationTest { // todo: remove CONFIGURATION_RUSEFI_BINARY or nicer API to disable local file load LinkManager clientManager = new LinkManager(); - clientManager.startAndConnect(TestHelper.LOCALHOST + ":" + port, new ConnectionStateListener() { + clientManager.startAndConnect(TcpConnector.LOCALHOST + ":" + port, new ConnectionStateListener() { @Override public void onConnectionEstablished() { connectionEstablishedCountDownLatch.countDown(); @@ -94,7 +95,7 @@ public class TcpCommunicationIntegrationTest { // connect proxy to virtual controller - IoStream targetEcuSocket = TestHelper.connectToLocalhost(controllerPort, LOGGER); + IoStream targetEcuSocket = TestHelper.connectToLocalhost(controllerPort); final AtomicInteger relayCommandCounter = new AtomicInteger(); BinaryProtocolProxy.createProxy(targetEcuSocket, proxyPort, () -> relayCommandCounter.incrementAndGet()); @@ -102,7 +103,7 @@ public class TcpCommunicationIntegrationTest { // connect to proxy and read virtual controller through it LinkManager clientManager = new LinkManager(); - clientManager.startAndConnect(TestHelper.LOCALHOST + ":" + proxyPort, new ConnectionStateListener() { + clientManager.startAndConnect(TcpConnector.LOCALHOST + ":" + proxyPort, new ConnectionStateListener() { @Override public void onConnectionEstablished() { connectionEstablishedCountDownLatch.countDown(); diff --git a/java_console/ui/src/test/java/com/rusefi/proxy/NetworkConnectorTest.java b/java_console/ui/src/test/java/com/rusefi/proxy/NetworkConnectorTest.java index 573edd7a59..164c263bb5 100644 --- a/java_console/ui/src/test/java/com/rusefi/proxy/NetworkConnectorTest.java +++ b/java_console/ui/src/test/java/com/rusefi/proxy/NetworkConnectorTest.java @@ -7,6 +7,7 @@ import com.rusefi.TestHelper; import com.rusefi.Timeouts; import com.rusefi.config.generated.Fields; import com.rusefi.io.tcp.BinaryProtocolServer; +import com.rusefi.io.tcp.TcpConnector; import com.rusefi.server.Backend; import com.rusefi.server.ControllerConnectionState; import org.junit.Before; @@ -76,7 +77,7 @@ public class NetworkConnectorTest { } }; NetworkConnector networkConnector = new NetworkConnector(); - networkConnector.start(NetworkConnector.Implementation.Unknown, TestHelper.TEST_TOKEN_1, TestHelper.LOCALHOST + ":" + controllerPort, connectorContext, reconnectListener); + networkConnector.start(NetworkConnector.Implementation.Unknown, TestHelper.TEST_TOKEN_1, TcpConnector.LOCALHOST + ":" + controllerPort, connectorContext, reconnectListener); assertLatch(reconnectCounter); diff --git a/java_console/ui/src/test/java/com/rusefi/proxy/client/LocalApplicationProxyTest.java b/java_console/ui/src/test/java/com/rusefi/proxy/client/LocalApplicationProxyTest.java index f61937efed..6bea9bc3fe 100644 --- a/java_console/ui/src/test/java/com/rusefi/proxy/client/LocalApplicationProxyTest.java +++ b/java_console/ui/src/test/java/com/rusefi/proxy/client/LocalApplicationProxyTest.java @@ -31,6 +31,7 @@ import static com.rusefi.binaryprotocol.BinaryProtocol.findCommand; import static com.rusefi.binaryprotocol.BinaryProtocol.sleep; import static com.rusefi.config.generated.Fields.TS_PROTOCOL; import static com.rusefi.io.tcp.BinaryProtocolServer.getPacketLength; +import static com.rusefi.io.tcp.TcpConnector.LOCALHOST; import static com.rusefi.shared.FileUtil.close; import static org.junit.Assert.*;