use of org.btrplace.model.DefaultModel in project scheduler by btrplace.
the class SchedulerExceptionTest method testBasic.
@Test
public void testBasic() {
Model mo = new DefaultModel();
SchedulerException ex = new SchedulerException(mo, "foo");
Assert.assertEquals(ex.getModel(), mo);
Assert.assertEquals(ex.getMessage(), "foo");
SchedulerException ex2 = new SchedulerException(mo, "foo", ex);
Assert.assertEquals(ex2.getModel(), mo);
Assert.assertEquals(ex2.getMessage(), "foo");
Assert.assertEquals(ex2.getCause(), ex);
}
use of org.btrplace.model.DefaultModel in project scheduler by btrplace.
the class ScriptBuilderTest method testStringSupport.
public void testStringSupport() throws ScriptBuilderException {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Script v = b.build("namespace foo; VM[1..10] : tiny;\n$arr = {\"foo\",\"bar\", \"baz\"};$arr2 = $arr + {\"git\"}; $out = \"come \" + \"out \" + 5 + \" \" + VM1; export $arr2,$out to *;");
BtrpString out = (BtrpString) v.getImportable("$out");
BtrpSet arr2 = (BtrpSet) v.getImportable("$arr2");
Assert.assertEquals(out.toString(), "come out 5 foo.VM1");
Assert.assertEquals(arr2.size(), 4);
}
use of org.btrplace.model.DefaultModel in project scheduler by btrplace.
the class ScriptBuilderTest method testTemplateWithOptions.
@Test
public void testTemplateWithOptions() throws ScriptBuilderException {
Model mo = new DefaultModel();
ScriptBuilder b = new ScriptBuilder(mo);
Script v = b.build("namespace test.template;\nVM[1..3] : tinyVMs<migratable,start=\"7.5\",stop=12>;");
Assert.assertEquals(v.getVMs().size(), 3);
for (VM el : v.getVMs()) {
// 3 + 1 (the template)
Assert.assertEquals(mo.getAttributes().getKeys(el).size(), 4);
Assert.assertEquals(mo.getAttributes().get(el, "migratable", false), true);
Assert.assertEquals(mo.getAttributes().get(el, "start", -1.5), 7.5);
Assert.assertEquals(mo.getAttributes().get(el, "stop", -1), 12);
}
}
use of org.btrplace.model.DefaultModel in project scheduler by btrplace.
the class ScriptBuilderTest method testSetManipulation.
public void testSetManipulation() throws ScriptBuilderException {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Script v = b.build(new File(RC_ROOT + "setManip.btrp"));
BtrpSet t1 = (BtrpSet) v.getImportable("$T1");
BtrpSet t2 = (BtrpSet) v.getImportable("$T2");
BtrpSet t3 = (BtrpSet) v.getImportable("$T3");
BtrpNumber x = (BtrpNumber) v.getImportable("$x");
BtrpNumber res = (BtrpNumber) v.getImportable("$res");
BtrpNumber res2 = (BtrpNumber) v.getImportable("$res2");
BtrpNumber res3 = (BtrpNumber) v.getImportable("$res3");
BtrpNumber y = (BtrpNumber) v.getImportable("$y");
Assert.assertEquals(t1.size() + t2.size() + t3.size(), 100);
Assert.assertEquals(x.getIntValue(), 12);
Assert.assertEquals(y.getIntValue(), 3);
BtrpSet C = (BtrpSet) v.getImportable("$C");
Assert.assertEquals(C.size(), 90);
BtrpSet a = (BtrpSet) v.getImportable("$a");
Assert.assertEquals(res, BtrpNumber.TRUE);
Assert.assertEquals(res2, BtrpNumber.TRUE);
Assert.assertEquals(res3, BtrpNumber.TRUE);
Assert.assertEquals(a.degree(), 2);
Assert.assertEquals(a.size(), 4);
}
use of org.btrplace.model.DefaultModel in project scheduler by btrplace.
the class ScriptBuilderTest method testIfStatement.
public void testIfStatement() {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
try {
Script v = b.build(new File(RC_ROOT + "ifStatement.btrp"));
BtrpNumber first = (BtrpNumber) v.getImportable("$first");
BtrpNumber second = (BtrpNumber) v.getImportable("$second");
BtrpNumber third = (BtrpNumber) v.getImportable("$third");
Assert.assertNotNull(first);
Assert.assertNotNull(second);
Assert.assertEquals(first, BtrpNumber.TRUE);
Assert.assertEquals(second, BtrpNumber.TRUE);
Assert.assertEquals(third.getIntValue(), 5);
} catch (ScriptBuilderException x) {
Assert.fail(x.getMessage(), x);
}
}
Aggregations