use of org.btrplace.btrpsl.template.DefaultTemplateFactory in project scheduler by btrplace.
the class ScriptBuilderTest method testTemplateReassignment.
@Test(expectedExceptions = { ScriptBuilderException.class })
public void testTemplateReassignment() throws ScriptBuilderException {
Model mo = new DefaultModel();
VM v = mo.newVM();
VM v2 = mo.newVM();
mo.getMapping().addReadyVM(v);
mo.getMapping().addReadyVM(v2);
mo.getAttributes().put(v, "template", "t1");
mo.getAttributes().put(v2, "template", "tiny");
NamingService<Node> nsNodes = NamingService.newNodeNS();
NamingService<VM> nsVMs = NamingService.newVMNS();
mo.attach(nsNodes);
mo.attach(nsVMs);
nsVMs.register(v, "foo.VM1");
nsVMs.register(v2, "foo.VM2");
ScriptBuilder b = new ScriptBuilder(100, mo);
b.setTemplateFactory(new DefaultTemplateFactory(nsNodes, nsVMs, mo));
b.getTemplateFactory().register(new DefaultTemplateFactoryTest.MockVMTemplate("tiny"));
b.getTemplateFactory().register(new DefaultTemplateFactoryTest.MockVMTemplate("t1"));
ErrorReporter r;
try {
Script scr = b.build("namespace foo; VM[1,2] : tiny;");
System.out.println(scr.getVMs());
} catch (ScriptBuilderException ex) {
System.out.println(ex);
r = ex.getErrorReporter();
Assert.assertEquals(r.getErrors().size(), 1);
throw ex;
}
}
Aggregations