use of il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner 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));
}
use of il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner in project BPjs by bThink-BGU.
the class InterruptHandlerTest method echoEventTest.
@Test
public void echoEventTest() throws InterruptedException {
BProgramRunner sut = new BProgramRunner(new SingleResourceBProgram("InterruptHandler.js"));
sut.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = sut.addListener(new InMemoryEventLoggingListener());
sut.run();
eventLogger.getEvents().forEach(e -> System.out.println(e));
EventPattern expected = new EventPattern().append(new BEvent("boom")).append(new BEvent("boom")).append(new BEvent("internalValue"));
assertTrue(expected.matches(eventLogger.getEvents()));
}
use of il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner in project BPjs by bThink-BGU.
the class InterruptHandlerTest method illegalBsyncTest.
@Test(expected = BProgramException.class)
public void illegalBsyncTest() throws InterruptedException {
BProgramRunner sut = new BProgramRunner(new SingleResourceBProgram("InterruptHandler_illegal.js"));
sut.addListener(new PrintBProgramRunnerListener());
sut.run();
fail("Program should have terminated in error.");
}
Aggregations