use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.
the class DfsBProgramVerifierTest method deadlockRun.
@Test
public void deadlockRun() throws Exception {
BProgram program = new SingleResourceBProgram("deadlocking.js");
BProgramRunner rnr = new BProgramRunner(program);
rnr.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = rnr.addListener(new InMemoryEventLoggingListener());
rnr.run();
eventLogger.getEvents().forEach(System.out::println);
assertTrue(eventNamesString(eventLogger.getEvents(), "").matches("^A$"));
}
use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.
the class DfsBProgramVerifierTest method simpleAAABTrace.
@Test
public void simpleAAABTrace() throws Exception {
BProgram program = new SingleResourceBProgram("AAABTrace.js");
DfsBProgramVerifier sut = new DfsBProgramVerifier();
sut.setProgressListener(new BriefPrintDfsVerifierListener());
program.appendSource(Requirements.eventNotSelected("B"));
sut.setVisitedNodeStore(new ForgetfulVisitedStateStore());
VerificationResult res = sut.verify(program);
assertTrue(res.isCounterExampleFound());
assertEquals("AAAB", traceEventNamesString(res.getCounterExampleTrace(), ""));
}
use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.
the class DfsBProgramVerifierTest method deadlockTrace.
@Test
public void deadlockTrace() throws Exception {
BProgram program = new SingleResourceBProgram("deadlocking.js");
DfsBProgramVerifier sut = new DfsBProgramVerifier();
sut.setVisitedNodeStore(new ForgetfulVisitedStateStore());
VerificationResult res = sut.verify(program);
assertTrue(res.isCounterExampleFound());
assertEquals(VerificationResult.ViolationType.Deadlock, res.getViolationType());
assertEquals("A", traceEventNamesString(res.getCounterExampleTrace(), ""));
}
use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.
the class BProgramSyncSnapshotClonerTest method testSerialization.
@Test
public void testSerialization() throws Exception {
System.out.println("\nSTART Serialization test");
BProgram bprog = new SingleResourceBProgram("BProgramSyncSnapshotClonerTest.js");
BProgramSyncSnapshot cur = bprog.setup();
ExecutorService exSvc = ExecutorServiceMaker.makeWithName("test");
cur = cur.start(exSvc);
cur.triggerEvent(cur.getStatements().stream().flatMap(s -> s.getRequest().stream()).findFirst().get(), exSvc, emptySet());
BProgramSyncSnapshotIO io = new BProgramSyncSnapshotIO(bprog);
byte[] out = io.serialize(cur);
System.out.println("de-serializing\n");
io.deserialize(out);
System.out.println("END Serialization test\n");
}
use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.
the class GetTimeTest method test.
@Test
public void test() throws InterruptedException {
BProgram sut = new SingleResourceBProgram("getTimeTest.js");
long timePre = System.currentTimeMillis();
new BProgramRunner(sut).run();
long timePost = System.currentTimeMillis();
Long actual = sut.getFromGlobalScope("theTime", Long.class).get();
assertTrue((actual >= timePre) && (actual <= timePost));
}
Aggregations