summaryrefslogtreecommitdiff
path: root/src/test/java/testing/protocols/BaseProtocolTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/testing/protocols/BaseProtocolTest.java')
-rw-r--r--src/test/java/testing/protocols/BaseProtocolTest.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/java/testing/protocols/BaseProtocolTest.java b/src/test/java/testing/protocols/BaseProtocolTest.java
new file mode 100644
index 0000000..e9cbc81
--- /dev/null
+++ b/src/test/java/testing/protocols/BaseProtocolTest.java
@@ -0,0 +1,45 @@
+package testing.protocols;
+
+import testing.*;
+import org.junit.jupiter.api.*;
+
+/**
+ * Base class for protocol tests providing common setup and utilities.
+ */
+public abstract class BaseProtocolTest {
+ protected HeadlessSimulationRunner runner;
+
+ @BeforeEach
+ public void baseSetup() {
+ runner = new HeadlessSimulationRunner();
+ }
+
+ @AfterEach
+ public void baseTeardown() {
+ if (runner != null) {
+ runner.shutdown();
+ }
+ }
+
+ /**
+ * Run a simulation and get the result with error handling.
+ */
+ protected SimulationResult runSimulation(String file, long duration) {
+ try {
+ return runner.runSimulation(file, duration);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to run simulation: " + file, e);
+ }
+ }
+
+ /**
+ * Create a basic verifier that checks for no errors.
+ */
+ protected ProtocolVerifier createBasicVerifier() {
+ return new ProtocolVerifier()
+ .expectNoLog("ERROR")
+ .expectNoLog("Exception")
+ .expectNoLog("null")
+ .expectNoLog("NullPointer");
+ }
+} \ No newline at end of file