mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-10-02 21:27:46 +00:00
Rework and refactoring
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
package io.xpipe.api.test;
|
||||
|
||||
import io.xpipe.api.connector.XPipeConnection;
|
||||
import io.xpipe.beacon.BeaconClient;
|
||||
import io.xpipe.beacon.BeaconServer;
|
||||
|
||||
public class ConnectionFactory {
|
||||
|
||||
private static boolean alreadyStarted;
|
||||
|
||||
public static void start() throws Exception {
|
||||
if (BeaconServer.isRunning()) {
|
||||
alreadyStarted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BeaconServer.tryStart()) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
XPipeConnection.waitForStartup().orElseThrow();
|
||||
if (!BeaconServer.isRunning()) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
public static void stop() throws Exception {
|
||||
if (alreadyStarted) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BeaconServer.isRunning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var client = new BeaconClient();
|
||||
if (!BeaconServer.tryStop(client)) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
XPipeConnection.waitForShutdown();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package io.xpipe.api.test;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
||||
public class DaemonControl {
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() throws Exception {
|
||||
ConnectionFactory.start();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void teardown() throws Exception {
|
||||
ConnectionFactory.stop();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user