use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.
the class BProgramRunnerTest method testRun.
/**
* Test of start method, of class BProgramRunner.
* @throws java.lang.Exception
*/
@Test
public void testRun() throws Exception {
BProgram bprog = new SingleResourceBProgram("HotNCold.js");
BProgramRunner sut = new BProgramRunner(bprog);
sut.addListener(new PrintBProgramRunnerListener());
sut.run();
}
use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.
the class BProgramRunnerTest method testExecutorName.
@Test
public void testExecutorName() throws InterruptedException {
BProgram bprog = new StringBProgram("var exName = 'initial value'\n" + "bp.registerBThread( function(){\n" + " exName = bp.getJavaThreadName();\n" + "});");
new BProgramRunner(bprog).run();
String exName = bprog.getFromGlobalScope("exName", String.class).get();
assertTrue("Java executor name is wrong (got:'" + exName + "')", exName.startsWith("BProgramRunner-"));
}
use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.
the class BProgramJsProxyTest method randomProxyText.
@Test
public void randomProxyText() throws InterruptedException {
BProgram sut = new SingleResourceBProgram("RandomProxy.js");
new BProgramRunner(sut).run();
Double boolCount = sut.getFromGlobalScope("boolCount", Double.class).get();
assertEquals(500.0, boolCount, 100);
Double intCount = sut.getFromGlobalScope("intCount", Double.class).get();
assertEquals(500.0, intCount, 100);
Double floatCount = sut.getFromGlobalScope("floatCount", Double.class).get();
assertEquals(500.0, floatCount, 100);
}
use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.
the class BProgramJsProxyTest method logLevelProxyText.
@Test
public void logLevelProxyText() throws InterruptedException {
BProgram sut = new SingleResourceBProgram("RandomProxy.js");
new BProgramRunner(sut).run();
String logLevel1 = sut.getFromGlobalScope("logLevel1", String.class).get();
assertEquals(BProgramJsProxy.LogLevel.Off.name(), logLevel1);
String logLevel2 = sut.getFromGlobalScope("logLevel2", String.class).get();
assertEquals(BProgramJsProxy.LogLevel.Warn.name(), logLevel2);
}
use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.
the class JsEventSetTest method testJsSetData.
@Test
public void testJsSetData() throws InterruptedException, URISyntaxException {
try {
Context.enter();
BProgram bpr = new StringBProgram("Eventset", "var es=bp.EventSet('a',function(e){return e.name=='a';});\n");
new BProgramRunner(bpr).run();
NativeJavaObject sut = (NativeJavaObject) bpr.getGlobalScope().get("es", bpr.getGlobalScope());
JsEventSet jsSut = (JsEventSet) Context.jsToJava(sut, JsEventSet.class);
assertEquals("a", jsSut.getName());
assertTrue(jsSut.toString().contains("a"));
assertTrue(jsSut.toString().contains("JsEventSet"));
assertTrue(jsSut.contains(BEvent.named("a")));
assertFalse(jsSut.contains(BEvent.named("b")));
} finally {
Context.exit();
}
}
Aggregations