reducing code duplication
This commit is contained in:
parent
78fecdf191
commit
342c80d270
|
@ -69,9 +69,7 @@ public class FullServerTest {
|
|||
// create virtual controller to which "rusEFI network connector" connects to
|
||||
int controllerPort = 7002;
|
||||
ConfigurationImage controllerImage = prepareImage(value, createIniField(Fields.CYLINDERSCOUNT));
|
||||
CountDownLatch controllerCreated = new CountDownLatch(1);
|
||||
TestHelper.createVirtualController(controllerImage, controllerPort, parameter -> controllerCreated.countDown(), logger);
|
||||
assertTrue(controllerCreated.await(READ_IMAGE_TIMEOUT, TimeUnit.MILLISECONDS));
|
||||
TestHelper.createVirtualController(controllerPort, controllerImage, logger);
|
||||
|
||||
|
||||
// start "rusEFI network connector" to connect controller with backend since in real life controller has only local serial port it does not have network
|
||||
|
|
|
@ -17,6 +17,11 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.rusefi.Timeouts.READ_IMAGE_TIMEOUT;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TestHelper {
|
||||
public static final String LOCALHOST = "localhost";
|
||||
|
@ -68,4 +73,11 @@ public class TestHelper {
|
|||
}
|
||||
return targetEcuSocket;
|
||||
}
|
||||
|
||||
public static BinaryProtocolServer createVirtualController(int controllerPort, ConfigurationImage controllerImage, Logger logger) throws InterruptedException {
|
||||
CountDownLatch controllerCreated = new CountDownLatch(1);
|
||||
BinaryProtocolServer server = createVirtualController(controllerImage, controllerPort, parameter -> controllerCreated.countDown(), logger);
|
||||
assertTrue(controllerCreated.await(READ_IMAGE_TIMEOUT, TimeUnit.MILLISECONDS));
|
||||
return server;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,9 +51,7 @@ public class TcpCommunicationIntegrationTest {
|
|||
ConfigurationImage serverImage = TestHelper.prepareImage(value, iniField);
|
||||
int port = 6100;
|
||||
|
||||
CountDownLatch serverCreated = new CountDownLatch(1);
|
||||
BinaryProtocolServer server = TestHelper.createVirtualController(serverImage, port, parameter -> serverCreated.countDown(), LOGGER);
|
||||
assertTrue(serverCreated.await(30, TimeUnit.SECONDS));
|
||||
BinaryProtocolServer server = TestHelper.createVirtualController(port, serverImage, LOGGER);
|
||||
|
||||
CountDownLatch connectionEstablishedCountDownLatch = new CountDownLatch(1);
|
||||
|
||||
|
@ -90,9 +88,7 @@ public class TcpCommunicationIntegrationTest {
|
|||
int controllerPort = 6102;
|
||||
|
||||
// create virtual controller
|
||||
CountDownLatch serverCreated = new CountDownLatch(1);
|
||||
BinaryProtocolServer server = TestHelper.createVirtualController(serverImage, controllerPort, parameter -> serverCreated.countDown(), LOGGER);
|
||||
assertTrue(serverCreated.await(30, TimeUnit.SECONDS));
|
||||
TestHelper.createVirtualController(controllerPort, serverImage, LOGGER);
|
||||
int proxyPort = 6103;
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||
|
||||
public class UploadQueue {
|
||||
public static final String OUTBOX_FOLDER = FileUtil.RUSEFI_SETTINGS_FOLDER + File.separator + "outbox";
|
||||
private static LinkedBlockingDeque<String> queue = new LinkedBlockingDeque<>(128);
|
||||
private static final LinkedBlockingDeque<String> queue = new LinkedBlockingDeque<>(128);
|
||||
|
||||
private static boolean isStarted;
|
||||
|
||||
|
|
Loading…
Reference in New Issue