summaryrefslogtreecommitdiff
path: root/src/test/java/testing/protocols/BaseProtocolTest.java
blob: e9cbc81e7ca225ffadc69d84975ae23159d21cd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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");
    }
}